@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getPreferenceManager() != null) {
      addPreferencesFromResource(R.xml.operator_preferences);
      PreferenceScreen prefSet = getPreferenceScreen();

      mOperatorDisplayStyle = (ListPreference) prefSet.findPreference(OPERATOR_STYLE);
      mOperatorDisplayStyle.setOnPreferenceChangeListener(this);

      mOperatorDisplayText = (EditTextPreference) prefSet.findPreference(OPERATOR_TEXT);
      mOperatorDisplayText.setOnPreferenceChangeListener(this);

      if (mOperatorDisplayText != null) {
        String operLabel = mOperatorDisplayText.getText();
        if (TextUtils.isEmpty(operLabel)) {
          mOperatorDisplayText.setSummary(getString(R.string.operator_display_summary));
        } else {
          mOperatorDisplayText.setSummary(mOperatorDisplayText.getText());
        }
      }

      int index = Settings.System.getInt(getContentResolver(), CARRIER_LABEL_TYPE, 0);
      index = index > (mOperatorDisplayStyle.getEntries().length - 1) ? 0 : index;
      mOperatorDisplayStyle.setSummary(mOperatorDisplayStyle.getEntries()[index]);

      mOperatorDisplayText.setEnabled(index == 3);
    }
  }
 @Override
 public boolean onPreferenceChange(Preference pref, Object newValue) {
   if (KEY_AUTO_SILENCE.equals(pref.getKey())) {
     final ListPreference autoSilencePref = (ListPreference) pref;
     String delay = (String) newValue;
     updateAutoSnoozeSummary(autoSilencePref, delay);
   } else if (KEY_CLOCK_STYLE.equals(pref.getKey())) {
     final ListPreference clockStylePref = (ListPreference) pref;
     final int idx = clockStylePref.findIndexOfValue((String) newValue);
     clockStylePref.setSummary(clockStylePref.getEntries()[idx]);
   } else if (KEY_HOME_TZ.equals(pref.getKey())) {
     final ListPreference homeTimezonePref = (ListPreference) pref;
     final int idx = homeTimezonePref.findIndexOfValue((String) newValue);
     homeTimezonePref.setSummary(homeTimezonePref.getEntries()[idx]);
     notifyHomeTimeZoneChanged();
   } else if (KEY_AUTO_HOME_CLOCK.equals(pref.getKey())) {
     final boolean autoHomeClockEnabled = ((CheckBoxPreference) pref).isChecked();
     final Preference homeTimeZonePref = findPreference(KEY_HOME_TZ);
     homeTimeZonePref.setEnabled(!autoHomeClockEnabled);
     notifyHomeTimeZoneChanged();
   } else if (KEY_VOLUME_BUTTONS.equals(pref.getKey())) {
     final ListPreference volumeButtonsPref = (ListPreference) pref;
     final int index = volumeButtonsPref.findIndexOfValue((String) newValue);
     volumeButtonsPref.setSummary(volumeButtonsPref.getEntries()[index]);
   } else if (KEY_WEEK_START.equals(pref.getKey())) {
     final ListPreference weekStartPref = (ListPreference) findPreference(KEY_WEEK_START);
     final int idx = weekStartPref.findIndexOfValue((String) newValue);
     weekStartPref.setSummary(weekStartPref.getEntries()[idx]);
   }
   // Set result so DeskClock knows to refresh itself
   getActivity().setResult(RESULT_OK);
   return true;
 }
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if (preference == mNetTrafficState) {
     int intState = Integer.valueOf((String) newValue);
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_UP, getBit(intState, MASK_UP));
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_DOWN, getBit(intState, MASK_DOWN));
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_STATE,
         mNetTrafficVal);
     int index = mNetTrafficState.findIndexOfValue((String) newValue);
     mNetTrafficState.setSummary(mNetTrafficState.getEntries()[index]);
     updateNetworkTrafficState(index);
     return true;
   } else if (preference == mNetTrafficColor) {
     String hex = ColorPickerPreference.convertToARGB(Integer.valueOf(String.valueOf(newValue)));
     preference.setSummary(hex);
     int intHex = ColorPickerPreference.convertToColorInt(hex);
     Settings.System.putInt(getContentResolver(), Settings.System.NETWORK_TRAFFIC_COLOR, intHex);
     return true;
   } else if (preference == mNetTrafficUnit) {
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_UNIT, ((String) newValue).equals("1"));
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_STATE,
         mNetTrafficVal);
     int index = mNetTrafficUnit.findIndexOfValue((String) newValue);
     mNetTrafficUnit.setSummary(mNetTrafficUnit.getEntries()[index]);
     return true;
   } else if (preference == mNetTrafficPeriod) {
     int intState = Integer.valueOf((String) newValue);
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_PERIOD, false) + (intState << 16);
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_STATE,
         mNetTrafficVal);
     int index = mNetTrafficPeriod.findIndexOfValue((String) newValue);
     mNetTrafficPeriod.setSummary(mNetTrafficPeriod.getEntries()[index]);
     return true;
   } else if (preference == mNetTrafficAutohide) {
     boolean value = (Boolean) newValue;
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_AUTOHIDE,
         value ? 1 : 0);
     return true;
   } else if (preference == mNetTrafficAutohideThreshold) {
     int threshold = (Integer) newValue;
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD,
         threshold * 1);
     return true;
   }
   return false;
 }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);
            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else {
            preference.setSummary(stringValue);
          }

          // detect errors
          if (preference.getKey().equals("sos_uri")) {
            try {
              URL url = new URL(value.toString());
              if (!url.getProtocol().equals("http") && !url.getProtocol().equals("https"))
                throw new Exception("SOS URL must be HTTP or HTTPS");
            } catch (Exception e) {
              AlertDialog.Builder dlgAlert = new AlertDialog.Builder(preference.getContext());
              dlgAlert.setMessage("Invalid SOS URL");
              dlgAlert.setTitle(e.getMessage());
              dlgAlert.setPositiveButton("OK", null);
              dlgAlert.setCancelable(true);
              dlgAlert.create().show();
            }
          }

          return true;
        }
 private void disableUnusableTimeouts(ListPreference screenTimeoutPreference) {
   final DevicePolicyManager dpm =
       (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
   final long maxTimeout = dpm != null ? dpm.getMaximumTimeToLock(null) : 0;
   if (maxTimeout == 0) {
     return; // policy not enforced
   }
   final CharSequence[] entries = screenTimeoutPreference.getEntries();
   final CharSequence[] values = screenTimeoutPreference.getEntryValues();
   ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
   ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.parseLong(values[i].toString());
     if (timeout <= maxTimeout) {
       revisedEntries.add(entries[i]);
       revisedValues.add(values[i]);
     }
   }
   if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
     screenTimeoutPreference.setEntries(
         revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
     screenTimeoutPreference.setEntryValues(
         revisedValues.toArray(new CharSequence[revisedValues.size()]));
     final int userPreference = Integer.parseInt(screenTimeoutPreference.getValue());
     if (userPreference <= maxTimeout) {
       screenTimeoutPreference.setValue(String.valueOf(userPreference));
     } else {
       // There will be no highlighted selection since nothing in the list matches
       // maxTimeout. The user can still select anything less than maxTimeout.
       // TODO: maybe append maxTimeout to the list and mark selected.
     }
   }
   screenTimeoutPreference.setEnabled(revisedEntries.size() > 0);
 }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            // For list preferences, look up the correct display value in
            // the preference's 'entries' list.
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);
            // Set the summary to reflect the new value.
            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else if (preference instanceof CheckBoxPreference) {
            // Trigger the listener immediately with the preference's
            // current value.
            if (preference.getKey().equals("prefHumidityOnTop")) {
              preference.setSummary(
                  Boolean.valueOf(stringValue)
                      ? R.string.pref_on_top_humidity_summary_yes
                      : R.string.pref_on_top_humidity_summary_no);
            }
          } else if (preference instanceof EditTextPreference) {
          } else {
            // For all other preferences, set the summary to the value's
            // simple string representation.
            preference.setSummary(stringValue);
          }
          return true;
        }
 private void disableUnusableTimeouts(long maxTimeout) {
   final CharSequence[] entries = mLockAfter.getEntries();
   final CharSequence[] values = mLockAfter.getEntryValues();
   ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
   ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.valueOf(values[i].toString());
     if (timeout <= maxTimeout) {
       revisedEntries.add(entries[i]);
       revisedValues.add(values[i]);
     }
   }
   if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
     mLockAfter.setEntries(revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
     mLockAfter.setEntryValues(revisedValues.toArray(new CharSequence[revisedValues.size()]));
     final int userPreference = Integer.valueOf(mLockAfter.getValue());
     if (userPreference <= maxTimeout) {
       mLockAfter.setValue(String.valueOf(userPreference));
     } else {
       // There will be no highlighted selection since nothing in the list matches
       // maxTimeout. The user can still select anything less than maxTimeout.
       // TODO: maybe append maxTimeout to the list and mark selected.
     }
   }
   mLockAfter.setEnabled(revisedEntries.size() > 0);
 }
  @Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
      // For list preferences, look up the correct display value in
      // the preference's 'entries' list (since they have separate labels/values).
      ListPreference listPreference = (ListPreference) preference;
      int prefIndex = listPreference.findIndexOfValue(stringValue);
      if (prefIndex >= 0) {
        preference.setSummary(listPreference.getEntries()[prefIndex]);
      }
    } else if (key.equals(getString(R.string.pref_location_key))) {
      @SunshineSyncAdapter.LocationStatus int status = Utility.getLocationStatus(this);
      switch (status) {
        case SunshineSyncAdapter.LOCATION_STATUS_OK:
          preference.setSummary(stringValue);
          break;
        case SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN:
          preference.setSummary(getString(R.string.pref_location_unknown_description, newValue));
          break;
        case SunshineSyncAdapter.LOCATION_STATUS_INVALID:
          preference.setSummary(getString(R.string.pref_location_error_description, newValue));
          break;
        default:
          preference.setSummary(stringValue);
      }
    } else {
      // For other preferences, set the summary to the value's simple string representation.
      preference.setSummary(stringValue);
    }
    return true;
  }
 @Override
 public void updateSummary(
     @NonNull Preference preference, @NonNull Config.Option option, @NonNull Object value) {
   int pos = -(int) value + 2;
   ListPreference cbp = (ListPreference) preference;
   cbp.setSummary(cbp.getEntries()[pos]);
 }
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
          if (preference instanceof ListPreference && newValue instanceof String) {
            final ListPreference listPreference = (ListPreference) preference;
            final int index = listPreference.findIndexOfValue((String) newValue);
            final CharSequence[] entries = listPreference.getEntries();

            if (index >= 0 && index < entries.length) {
              preference.setSummary(entries[index].toString().replaceAll("%", "%%"));
            } else {
              preference.setSummary("");
            }
          }

          final String key = preference.getKey();
          if (getString(R.string.pref_resume_talkback_key).equals(key)) {
            final String oldValue =
                SharedPreferencesUtils.getStringPref(
                    mPrefs,
                    getResources(),
                    R.string.pref_resume_talkback_key,
                    R.string.pref_resume_talkback_default);
            if (!newValue.equals(oldValue)) {
              // Reset the suspend warning dialog when the resume
              // preference changes.
              SharedPreferencesUtils.putBooleanPref(
                  mPrefs, getResources(), R.string.pref_show_suspension_confirmation_dialog, true);
            }
          }

          return true;
        }
 /**
  * For each list dialog, we display the value selected in the "summary" text. When a new value is
  * selected from the list dialog, update the summary to the selected entry.
  */
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   ListPreference list = (ListPreference) preference;
   int index = list.findIndexOfValue((String) newValue);
   CharSequence entry = list.getEntries()[index];
   preference.setSummary(entry);
   return true;
 }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);

            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else if (preference instanceof RingtonePreference) {
            if (TextUtils.isEmpty(stringValue)) {
              preference.setSummary(R.string.pref_ringtone_silent);
            } else {
              Ringtone ringtone =
                  RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue));

              if (ringtone == null) {
                preference.setSummary(null);
              } else {
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
              }
            }
          } else {
            preference.setSummary(stringValue);
          }
          return true;
        }
  @Override
  public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    // are we starting the preference activity?
    if (!mBindingPreference) {
      if (preference.getKey().equals(getString(R.string.pref_location_key))) {
        FetchWeatherTask weatherTask = new FetchWeatherTask(this);
        String location = value.toString();
        weatherTask.execute(location);
      } else {
        // notify code that weather may be impacted
        getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
      }
    }

    if (preference instanceof ListPreference) {
      // For list preferences, look up the correct display value in
      // the preference's 'entries' list (since they have separate labels/values).
      ListPreference listPreference = (ListPreference) preference;
      int prefIndex = listPreference.findIndexOfValue(stringValue);
      if (prefIndex >= 0) {
        preference.setSummary(listPreference.getEntries()[prefIndex]);
      }
    } else {
      // For other preferences, set the summary to the value's simple string representation.
      preference.setSummary(stringValue);
    }
    return true;
  }
 private void updateAppProcessLimitOptions() {
   try {
     int limit = ActivityManagerNative.getDefault().getProcessLimit();
     CharSequence[] values = mAppProcessLimit.getEntryValues();
     for (int i = 0; i < values.length; i++) {
       int val = Integer.parseInt(values[i].toString());
       if (val >= limit) {
         mAppProcessLimit.setValueIndex(i);
         mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[i]);
         return;
       }
     }
     mAppProcessLimit.setValueIndex(0);
     mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[0]);
   } catch (RemoteException e) {
   }
 }
 private void updateAnimationScaleValue(int which, ListPreference pref) {
   try {
     float scale = mWindowManager.getAnimationScale(which);
     CharSequence[] values = pref.getEntryValues();
     for (int i = 0; i < values.length; i++) {
       float val = Float.parseFloat(values[i].toString());
       if (scale <= val) {
         pref.setValueIndex(i);
         pref.setSummary(pref.getEntries()[i]);
         return;
       }
     }
     pref.setValueIndex(values.length - 1);
     pref.setSummary(pref.getEntries()[0]);
   } catch (RemoteException e) {
   }
 }
  private void updateOpenGLTracesOptions() {
    String value = SystemProperties.get(OPENGL_TRACES_PROPERTY);
    if (value == null) {
      value = "";
    }

    CharSequence[] values = mOpenGLTraces.getEntryValues();
    for (int i = 0; i < values.length; i++) {
      if (value.contentEquals(values[i])) {
        mOpenGLTraces.setValueIndex(i);
        mOpenGLTraces.setSummary(mOpenGLTraces.getEntries()[i]);
        return;
      }
    }
    mOpenGLTraces.setValueIndex(0);
    mOpenGLTraces.setSummary(mOpenGLTraces.getEntries()[0]);
  }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          // Do not bind toggles.
          if (preference instanceof CheckBoxPreference
              || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
                  && preference instanceof TwoStatePreference)) {
            return true;
          }

          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            // For list preferences, look up the correct display value in
            // the preference's 'entries' list.
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);

            // Set the summary to reflect the new value.
            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

          } else if (preference instanceof RingtonePreference) {
            // For ringtone preferences, look up the correct display value
            // using RingtoneManager.
            if (TextUtils.isEmpty(stringValue)) {
              // Empty values correspond to 'silent' (no ringtone).
              preference.setSummary(R.string.ringtone_silent);
            } else {
              Ringtone ringtone =
                  RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue));

              if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
              } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
              }
            }

          } else if (preference instanceof EditTextPreference) {
            EditTextPreference textPreference = (EditTextPreference) preference;
            int inputType = textPreference.getEditText().getInputType();
            if (inputType == (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)) {
              preference.setSummary(stringValue.replaceAll(".", "*"));
            } else {
              preference.setSummary(stringValue);
            }
          } else {
            // For all other preferences, set the summary to the value's
            // simple string representation.
            preference.setSummary(stringValue);
          }
          return true;
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.general_system_property_pref);

    mSetting = new SystemPropertySetting(this);

    boolean value;

    value = mSetting.getCameraSound();
    mCameraSound = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_CAMERA_SOUND);
    mCameraSound.setChecked(value);
    mCameraSound.setOnPreferenceChangeListener(this);

    String lcdDensity = mSetting.getLcdDensity();
    mLcdDensity = (SeekBarPreference) findPreference(SystemPropertySetting.KEY_LCD_DENSITY);
    mLcdDensity.setValue(300, 120, Integer.valueOf(lcdDensity));
    mLcdDensity.setSummary(Misc.getCurrentValueText(this, lcdDensity));
    mLcdDensity.setOnPreferenceDoneListener(this);

    value = mSetting.getCrtEffect();
    mCrtEffect = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_CRT_EFFECT);
    mCrtEffect.setChecked(value);
    mCrtEffect.setOnPreferenceChangeListener(this);

    value = mSetting.getLogger();
    mLogger = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_LOGGER);
    mLogger.setChecked(value);
    mLogger.setOnPreferenceChangeListener(this);

    value = mSetting.getCifs();
    mCifs = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_CIFS);
    mCifs.setChecked(value);
    mCifs.setOnPreferenceChangeListener(this);

    value = mSetting.getNtfs();
    mNtfs = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_NTFS);
    mNtfs.setChecked(value);
    mNtfs.setOnPreferenceChangeListener(this);

    value = mSetting.getJ4fs();
    mJ4fs = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_J4FS);
    mJ4fs.setChecked(value);
    mJ4fs.setOnPreferenceChangeListener(this);

    String strValue = mSetting.getUsbConfig();
    mUsbConfig = (ListPreference) findPreference(SystemPropertySetting.KEY_USB_CONFIG);
    mUsbConfig.setValue(strValue);
    mUsbConfig.setSummary(
        Misc.getCurrentValueText(
            this,
            Misc.getEntryFromEntryValue(
                mUsbConfig.getEntries(), mUsbConfig.getEntryValues(), strValue)));
    mUsbConfig.setOnPreferenceChangeListener(this);
  }
  private void updateOverlayDisplayDevicesOptions() {
    String value =
        Settings.Global.getString(
            getActivity().getContentResolver(), Settings.Global.OVERLAY_DISPLAY_DEVICES);
    if (value == null) {
      value = "";
    }

    CharSequence[] values = mOverlayDisplayDevices.getEntryValues();
    for (int i = 0; i < values.length; i++) {
      if (value.contentEquals(values[i])) {
        mOverlayDisplayDevices.setValueIndex(i);
        mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[i]);
        return;
      }
    }
    mOverlayDisplayDevices.setValueIndex(0);
    mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[0]);
  }
Exemple #20
0
 public boolean onPreferenceChange(Preference paramPreference, Object paramObject) {
   ListPreference localListPreference = (ListPreference) paramPreference;
   int i = localListPreference.findIndexOfValue((String) paramObject);
   String str = localListPreference.getEntries()[i].toString();
   Settings localSettings = this.a;
   Object[] arrayOfObject = new Object[1];
   arrayOfObject[0] = str;
   paramPreference.setTitle(localSettings.getString(2131296703, arrayOfObject));
   return true;
 }
  private void updateListSummary(Preference preference, Object newValue) {
    ListPreference list = (ListPreference) preference;
    CharSequence[] values = list.getEntryValues();
    int i;
    for (i = 0; i < values.length; i++) {
      if (values[i].equals(newValue)) break;
    }
    if (i >= values.length) i = 0;

    list.setSummary(list.getEntries()[i]);
  }
  /** Set preference summary. */
  private void setPreferenceSummary(Preference pref, Object value) {
    String stringValue = value.toString();

    if (pref instanceof ListPreference) {
      ListPreference listPreference = (ListPreference) pref;
      int prefIndex = listPreference.findIndexOfValue(stringValue);
      if (prefIndex >= 0) {
        listPreference.setSummary(listPreference.getEntries()[prefIndex]);

        Log.v("Settings", "summary = " + listPreference.getSummary());
      }
    }
  }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);

            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else preference.setSummary(stringValue);

          return true;
        }
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference.getKey().equals("selectapp")) {
      ListPreference mAppPref = (ListPreference) preference;
      CharSequence[] mEntries = mAppPref.getEntries();
      mAppPref.setTitle(mEntries[mAppPref.findIndexOfValue((String) newValue)]);

      PackageManager pm = getActivity().getPackageManager();

      try {
        mAppPref.setIcon(pm.getApplicationIcon((String) newValue));
      } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (preference.getKey().equals("selectadvancedapp")) {
      ListPreference mAdvancedAppPref = (ListPreference) preference;
      CharSequence[] mEntries = mAdvancedAppPref.getEntries();
      mAdvancedAppPref.setTitle(mEntries[mAdvancedAppPref.findIndexOfValue((String) newValue)]);

      PackageManager pm = getActivity().getPackageManager();

      try {
        mAdvancedAppPref.setIcon(pm.getApplicationIcon((String) newValue));
      } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (preference.getKey().equals("baud_rate")) {
      ListPreference baudRatePref = (ListPreference) preference;
      CharSequence[] mEntries = baudRatePref.getEntries();
      baudRatePref.setTitle(mEntries[baudRatePref.findIndexOfValue((String) newValue)]);
    }

    return true;
  }
 public boolean onPreferenceChange(Preference preference, Object objValue) {
   if (preference == mVolumeKeyCursorControl) {
     String volumeKeyCursorControl = (String) objValue;
     int val = Integer.parseInt(volumeKeyCursorControl);
     Settings.System.putInt(getContentResolver(), Settings.System.VOLUME_KEY_CURSOR_CONTROL, val);
     int index = mVolumeKeyCursorControl.findIndexOfValue(volumeKeyCursorControl);
     mVolumeKeyCursorControl.setSummary(mVolumeKeyCursorControl.getEntries()[index]);
     return true;
   } else if (preference == mDisableFullscreenKeyboard) {
     Settings.System.putInt(
         getContentResolver(),
         Settings.System.DISABLE_FULLSCREEN_KEYBOARD,
         (Boolean) objValue ? 1 : 0);
     return true;
   } else if (preference == mStatusBarImeSwitcher) {
     Settings.System.putInt(
         getContentResolver(),
         Settings.System.STATUS_BAR_IME_SWITCHER,
         (Boolean) objValue ? 1 : 0);
     return true;
   } else if (preference == mKeyboardRotationToggle) {
     boolean isAutoRotate =
         (Settings.System.getIntForUser(
                 getContentResolver(),
                 Settings.System.ACCELEROMETER_ROTATION,
                 0,
                 UserHandle.USER_CURRENT)
             == 1);
     if (isAutoRotate && (Boolean) objValue) {
       showDialogInner(DLG_KEYBOARD_ROTATION);
     }
     Settings.System.putInt(
         getContentResolver(),
         Settings.System.KEYBOARD_ROTATION_TIMEOUT,
         (Boolean) objValue ? KEYBOARD_ROTATION_TIMEOUT_DEFAULT : 0);
     updateRotationTimeout(KEYBOARD_ROTATION_TIMEOUT_DEFAULT);
     return true;
   } else if (preference == mShowEnterKey) {
     Settings.System.putInt(
         getContentResolver(), Settings.System.FORMAL_TEXT_INPUT, (Boolean) objValue ? 1 : 0);
     return true;
   } else if (preference == mKeyboardRotationTimeout) {
     int timeout = Integer.parseInt((String) objValue);
     Settings.System.putInt(
         getContentResolver(), Settings.System.KEYBOARD_ROTATION_TIMEOUT, timeout);
     updateRotationTimeout(timeout);
     return true;
   }
   return false;
 }
  private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
      ListPreference listPreference = (ListPreference) preference;
      int prefIndex = listPreference.findIndexOfValue(stringValue);
      if (prefIndex >= 0) {
        preference.setSummary(listPreference.getEntries()[prefIndex]);
      }
    } else {
      preference.setSummary(stringValue);
    }
  }
    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
      String stringValue = newValue.toString();

      if (preference instanceof ListPreference) {

        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
          preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
      } else {
        preference.setSummary(stringValue);
      }
      return true;
    }
 private void updateLockAfterPreferenceSummary() {
   // Update summary message with current value
   long currentTimeout =
       Settings.Secure.getLong(
           getContentResolver(), Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
   final CharSequence[] entries = mLockAfter.getEntries();
   final CharSequence[] values = mLockAfter.getEntryValues();
   int best = 0;
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.valueOf(values[i].toString());
     if (currentTimeout >= timeout) {
       best = i;
     }
   }
   mLockAfter.setSummary(getString(R.string.lock_after_timeout_summary, entries[best]));
 }
  @Override
  public boolean onPreferenceChange(Preference preference, Object newObj) {
    String objValue = newObj.toString();

    if (preference instanceof ListPreference) {

      ListPreference listPreference = (ListPreference) preference;
      int indexOfPref = listPreference.findIndexOfValue(objValue);
      if (indexOfPref >= 0) {
        preference.setSummary(listPreference.getEntries()[indexOfPref]);
      }
    } else {
      preference.setSummary(objValue);
    }
    return true;
  }
  public boolean onPreferenceChange(Preference preference, Object objValue) {
    Log.v(TAG, "onPreferenceChange()  objValue::" + objValue.toString());

    if (preference == wifiListPref) {
      String wifiBSSID = objValue.toString();
      String wifiSSID = null;

      CharSequence[] entries = wifiListPref.getEntries();
      CharSequence[] entryValues = wifiListPref.getEntryValues();

      Log.v(TAG, "=======================================\n");
      for (int i = 0; i < entryValues.length; i++) {
        if (entryValues[i].equals(wifiBSSID)) {
          Log.d(TAG, (i + 1) + "entries[i].equals(wifiBSSID)");
          Log.d(TAG, (i + 1) + ". entries : " + entries[i]);

          wifiSSID = entries[i].toString();
          // set sharedPrefs.
          setWifiSetting(wifiSSID, wifiBSSID);
          wifiListPref.setSummary(wifiSSID);
          wifiListPref.setValue(wifiBSSID);
        }
      }
      Log.v(TAG, "=======================================\n");

      String connectedWifi = WifiReceiver.getConnectedWifiBSSID(this);
      String wifimode = WifiReceiver.getWifiSettingBSSID(this);
      Log.e(TAG, "connectedWifi::" + connectedWifi + ", wifimode" + wifimode);
      if (connectedWifi == null || wifimode == null) {
        Log.e(TAG, "failed wifi info");
        WifiReceiver.cancleNotification(this);
        Toast.makeText(this, "failed wifi info", Toast.LENGTH_SHORT);
      }

      if (connectedWifi != null && connectedWifi.equals(wifimode)) { // connected wifi mode
        Log.d(TAG, "noti.start");

        // set Notification
        WifiReceiver.setNotification(this);
        WifiReceiver.WifiState = true;
      } else {
        WifiReceiver.cancleNotification(this);
      }
    }
    return false;
  }