Esempio n. 1
0
 protected void updateSummaries() {
   // for all text preferences, set summary as current database value
   for (String key : mPref.mValues.keySet()) {
     Preference pref = this.findPreference(key);
     String value = null;
     if (pref == null) {
       continue;
     } else if (pref instanceof CheckBoxPreference) {
       continue;
     } else if (pref instanceof ListPreference) {
       ListPreference lp = (ListPreference) pref;
       value = lp.getEntry() != null ? lp.getEntry().toString() : "";
     } else {
       value = this.mPref.getString(key, "");
     }
     // update summary
     if (!mPref.mSummaries.containsKey(key)) {
       CharSequence s = pref.getSummary();
       mPref.mSummaries.put(key, s != null ? pref.getSummary().toString() : null);
     }
     String summ = mPref.mSummaries.get(key);
     if (summ != null && summ.contains("XXX")) {
       pref.setSummary(summ.replace("XXX", value));
     } else {
       pref.setSummary(value);
     }
   }
 }
Esempio n. 2
0
  @SuppressWarnings("deprecation")
  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    android.preference.Preference pref = findPreference(key);

    if (key.equals(getString(R.string.key_brightness))
        || key.equals(getString(R.string.key_brightness_manual_value))) {
      ListPreference listPref = (ListPreference) findPreference(getString(R.string.key_brightness));
      if (listPref.getValue().equals(getString(R.string.value_brightness_manual))) {
        listPref.setSummary(
            listPref.getEntry()
                + " "
                + (int) (100.0f * BrightnessDialog.getBrighnessLevel(sharedPreferences, this))
                + " "
                + getString(R.string.percents));
      } else {
        listPref.setSummary(listPref.getEntry());
      }
    } else if (pref != null) {
      if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        listPref.setSummary(listPref.getEntry());
      } else if (key.equals(getString(R.string.key_color))) {
        pref.setSummary(ColorDialog.getTextColorString(sharedPreferences, this));
      } else if (key.equals(getString(R.string.key_background_color))) {
        pref.setSummary(ColorDialog.getBackgroundColorString(sharedPreferences, this));
      } else if (key.equals(getString(R.string.key_city))) {
        pref.setSummary(CityDialog.getCityName(sharedPreferences, this));
      }
    }
  }
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals("pref_cameraIndex")) {
     cameraIndexPreference.setSummary(cameraIndexPreference.getEntry());
     buildResolutionListForCameraIndex();
   } else if (key.equals("pref_cameraResolution")) {
     cameraResolutionPreference.setSummary(cameraResolutionPreference.getEntry());
   }
 }
Esempio n. 4
0
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   // Let's do something a preference values changes
   /*
   if (key.equals(KEY_CHECKBOX_PREFERENCE)) {
     mCheckBoxPreference.setSummary(sharedPreferences.getBoolean(key, false) ? "Disable this setting" : "Enable this setting");
   }
   else*/
   if (key.equals(PrefsHelper.PREF_PORTRAIT_SCALING_MODE)) {
     mPrefPortraitMode.setSummary("Current value is '" + mPrefPortraitMode.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_LANDSCAPE_SCALING_MODE)) {
     mPrefLandsMode.setSummary("Current value is '" + mPrefLandsMode.getEntry() + "'");
   }
   if (key.equals(PrefsHelper.PREF_PORTRAIT_FILTER_TYPE)) {
     mPrefPortraitFilterType.setSummary(
         "Current value is '" + mPrefPortraitFilterType.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_LANDSCAPE_FILTER_TYPE)) {
     mPrefLandsFilterType.setSummary("Current value is '" + mPrefLandsFilterType.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_CONTROLLER_TYPE)) {
     mPrefControllerType.setSummary("Current values is '" + mPrefControllerType.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_GLOBAL_VIDEO_RENDER_MODE)) {
     mPrefGlobalVideoRenderMode.setSummary(
         "Current value is '" + mPrefGlobalVideoRenderMode.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_INPUT_EXTERNAL)) {
     mPrefExtInput.setSummary("Current value is '" + mPrefExtInput.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_ANALOG_DZ)) {
     mPrefAnalogDZ.setSummary("Current value is '" + mPrefAnalogDZ.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_TILT_DZ)) {
     mPrefTiltDZ.setSummary("Current value is '" + mPrefTiltDZ.getEntry() + "'");
   }
 }
  @SuppressWarnings("deprecation")
  @Override
  protected void onResume() {
    super.onResume();

    cameraIndexPreference.setSummary(cameraIndexPreference.getEntry());
    cameraResolutionPreference.setSummary(cameraResolutionPreference.getEntry());

    // Register for changes.
    getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  }
Esempio n. 6
0
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    // handle event for the Screen list preference
    if (key == mUIScreenListPreference.getKey()) {
      Log.v(TAG, "on shared preference change in conical settings");

      Log.v(TAG, mUIScreenListPreference.getEntry().toString());

      registerScreenChange(mUIScreenListPreference.getEntry().toString());
      restartLauncher2(activityManager);
    }
  }
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals("host")) {
     hostPref.setSummary(sharedPreferences.getString(key, ""));
   } else if (key.equals("port")) {
     portPref.setSummary(sharedPreferences.getString("port", "8001"));
   } else if (key.equals("password")) {
     String tmp = sharedPreferences.getString("password", null);
     if (tmp == null || tmp.equals("")) {
       passPref.setSummary("None Set");
     } else {
       passPref.setSummary("******");
     }
   } else if (key.equals("text_size")) {
     textSizePref.setSummary(sharedPreferences.getString("text_size", "10"));
   } else if (key.equals("timestamp_format")) {
     timestampformatPref.setSummary(sharedPreferences.getString("timestamp_format", "HH:mm:ss"));
   } else if (key.equals("stunnel_cert")) {
     stunnelCert.setSummary(
         sharedPreferences.getString("stunnel_cert", "/sdcard/weechat/client.p12"));
   } else if (key.equals("stunnel_pass")) {
     String tmp = sharedPreferences.getString("stunnel_pass", null);
     if (tmp == null || tmp.equals("")) {
       stunnelPass.setSummary("None Set");
     } else {
       stunnelPass.setSummary("******");
     }
   } else if (key.equals("ssh_host")) {
     sshHostPref.setSummary(sharedPreferences.getString(key, ""));
   } else if (key.equals("ssh_user")) {
     sshUserPref.setSummary(sharedPreferences.getString(key, ""));
   } else if (key.equals("ssh_port")) {
     sshPortPref.setSummary(sharedPreferences.getString(key, "22"));
   } else if (key.equals("ssh_pass")) {
     String tmp = sharedPreferences.getString("ssh_pass", null);
     if (tmp == null || tmp.equals("")) {
       sshPassPref.setSummary("None Set");
     } else {
       sshPassPref.setSummary("******");
     }
   } else if (key.equals("ssh_keyfile")) {
     sshKeyFilePref.setSummary(sharedPreferences.getString(key, "/sdcard/weechat/sshkey.id_rsa"));
   } else if (key.equals("prefix_align")) {
     prefixPref.setSummary(prefixPref.getEntry());
   } else if (key.equals("connection_type")) {
     connectionTypePref.setSummary(connectionTypePref.getEntry());
   }
 }
 /**
  * 初始化排序选项
  *
  * @param preference
  * @param defaultValue
  */
 private void initOrderListPreference(ListPreference preference, String defaultValue) {
   if (preference.getEntry() == null) {
     preference.setValue(defaultValue);
   }
   preference.setSummary(preference.getEntry());
   preference.setOnPreferenceChangeListener(
       new OnPreferenceChangeListener() {
         public boolean onPreferenceChange(Preference preference, Object newValue) {
           String value = newValue.toString();
           if (value.equals("createTime DESC")) preference.setSummary("按创建时间");
           else if (value.equals("updateTime DESC")) preference.setSummary("按修改时间");
           else if (value.equals("used DESC")) preference.setSummary("按使用频率时间");
           return true;
         }
       });
 }
Esempio n. 9
0
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key.equals(getString(R.string.prefSyncServerUrl_Key))) {

      mSyncServerUrlPref.setSummary(
          sharedPreferences.getString(getString(R.string.prefSyncServerUrl_Key), ""));
      mSyncServerUrlPref.setSummary(mSyncServerUrlPref.getEntry());

      ContentProviderClient client =
          getContentResolver().acquireContentProviderClient(DouiContentProvider.AUTHORITY);
      if (client != null) {
        ((DouiContentProvider) client.getLocalContentProvider()).resetDatabase();
        client.release();
        SyncAdapter.ResetUpdateDate();
        SyncAdapter.requestSync(getApplicationContext());
      }
    } else if (key.equals(getString(R.string.prefSyncRepeatTime_Key))) {
      mSyncRepeatTimePref.setSummary(
          sharedPreferences.getString(getString(R.string.prefSyncRepeatTime_Key), ""));
    } else if (key.equals(getString(R.string.prefIsSyncable_Key))) {
      loadDeviceAccounts();
      ContentResolver.setSyncAutomatically(
          new Account(mSyncAccountPref.getValue(), "com.google"),
          DouiContentProvider.AUTHORITY,
          sharedPreferences.getBoolean(key, false));
    } else if (key.equals(getString(R.string.prefSyncAccount_Key))) {
      mSyncAccountPref.setSummary(
          sharedPreferences.getString(getString(R.string.prefSyncAccount_Key), ""));
    }
  }
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    if (getActivity() == null) return;

    mRingMode.setValue(getPhoneRingModeSettingValue());
    mRingMode.setSummary(mRingMode.getEntry());
    updateQuietHoursSummary();
  }
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    final int ringerMode = mAudioManager.getRingerMode();

    // NB: in the UI we now simply call this "silent mode". A separate
    // setting controls whether we're in RINGER_MODE_SILENT or
    // RINGER_MODE_VIBRATE.
    final boolean silentOrVibrateMode = ringerMode != AudioManager.RINGER_MODE_NORMAL;

    if (silentOrVibrateMode != mSilent.isChecked() || force) {
      mSilent.setChecked(silentOrVibrateMode);
    }

    String phoneVibrateSetting = getPhoneVibrateSettingValue();

    if (!phoneVibrateSetting.equals(mVibrate.getValue()) || force) {
      mVibrate.setValue(phoneVibrateSetting);
    }
    mVibrate.setSummary(mVibrate.getEntry());

    int silentModeStreams =
        Settings.System.getInt(
            getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
    boolean isAlarmInclSilentMode = (silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0;
    mSilent.setSummary(
        isAlarmInclSilentMode
            ? R.string.silent_mode_incl_alarm_summary
            : R.string.silent_mode_summary);
  }
  @Override
  protected void onResume() {
    super.onResume();
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    hostPref.setSummary(sharedPreferences.getString("host", ""));
    portPref.setSummary(sharedPreferences.getString("port", "8001"));
    textSizePref.setSummary(sharedPreferences.getString("text_size", "10"));
    updateBufferFontSummary();

    timestampformatPref.setSummary(sharedPreferences.getString("timestamp_format", "HH:mm:ss"));
    stunnelCert.setSummary(sharedPreferences.getString("stunnel_cert", "Not Set"));

    sshHostPref.setSummary(sharedPreferences.getString("ssh_host", ""));
    sshUserPref.setSummary(sharedPreferences.getString("ssh_user", ""));
    sshPortPref.setSummary(sharedPreferences.getString("ssh_port", "22"));
    sshKeyFilePref.setSummary(sharedPreferences.getString("ssh_keyfile", "Not Set"));

    prefixPref.setSummary(prefixPref.getEntry());
    connectionTypePref.setSummary(connectionTypePref.getEntry());

    if (pingEnabledPref.isChecked()) {
      pingPreferences.setSummary("Enabled");
    } else {
      pingPreferences.setSummary("Disabled");
    }

    String tmp;
    tmp = sharedPreferences.getString("password", null);
    if (tmp == null || tmp.equals("")) {
      passPref.setSummary("None Set");
    } else {
      passPref.setSummary("******");
    }
    tmp = sharedPreferences.getString("stunnel_pass", null);
    if (tmp == null || tmp.equals("")) {
      stunnelPass.setSummary("None Set");
    } else {
      stunnelPass.setSummary("******");
    }
    tmp = sharedPreferences.getString("ssh_pass", null);
    if (tmp == null || tmp.equals("")) {
      sshPassPref.setSummary("None Set");
    } else {
      sshPassPref.setSummary("******");
    }
  }
 /** Handles time zone preference changes */
 @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   String tz;
   final Activity activity = getActivity();
   if (preference == mUseHomeTZ) {
     if ((Boolean) newValue) {
       tz = mTimeZoneId;
     } else {
       tz = CalendarCache.TIMEZONE_TYPE_AUTO;
     }
     Utils.setTimeZone(activity, tz);
     return true;
   } else if (preference == mHideDeclined) {
     mHideDeclined.setChecked((Boolean) newValue);
     Intent intent = new Intent(Utils.getWidgetScheduledUpdateAction(activity));
     intent.setDataAndType(CalendarContract.CONTENT_URI, Utils.APPWIDGET_DATA_TYPE);
     activity.sendBroadcast(intent);
     return true;
   } else if (preference == mWeekStart) {
     mWeekStart.setValue((String) newValue);
     mWeekStart.setSummary(mWeekStart.getEntry());
   } else if (preference == mDefaultReminder) {
     mDefaultReminder.setValue((String) newValue);
     mDefaultReminder.setSummary(mDefaultReminder.getEntry());
   } else if (preference == mSnoozeDelay) {
     mSnoozeDelay.setValue((String) newValue);
     mSnoozeDelay.setSummary(mSnoozeDelay.getEntry());
   } else if (preference == mRingtone) {
     if (newValue instanceof String) {
       Utils.setRingTonePreference(activity, (String) newValue);
       String ringtone = getRingtoneTitleFromUri(activity, (String) newValue);
       mRingtone.setSummary(ringtone == null ? "" : ringtone);
     }
     return true;
   } else if (preference == mVibrate) {
     mVibrate.setChecked((Boolean) newValue);
     return true;
   } else if (preference == mDefaultStart) {
     int i = mDefaultStart.findIndexOfValue((String) newValue);
     mDefaultStart.setSummary(mDefaultStart.getEntries()[i]);
     return true;
   } else {
     return true;
   }
   return false;
 }
 /**
  * 初始化提示音
  *
  * @param preference
  * @param defaultValue
  */
 private void initSoundListPreference(ListPreference preference, String defaultValue) {
   if (preference.getEntry() == null) {
     preference.setValue(defaultValue);
   }
   preference.setSummary(preference.getEntry());
   preference.setOnPreferenceChangeListener(
       new OnPreferenceChangeListener() {
         public boolean onPreferenceChange(Preference preference, Object newValue) {
           String value = newValue.toString();
           if (value.equals("1")) preference.setSummary("开启");
           else if (value.equals("2")) preference.setSummary("关闭");
           else if (value.equals("3")) preference.setSummary("只开启声音");
           else if (value.equals("4")) preference.setSummary("只开启振动");
           return true;
         }
       });
 }
 public void updateRotationTimeout(int timeout) {
   if (timeout == 0) {
     timeout = KEYBOARD_ROTATION_TIMEOUT_DEFAULT;
   }
   mKeyboardRotationTimeout.setValue(Integer.toString(timeout));
   mKeyboardRotationTimeout.setSummary(
       getString(R.string.keyboard_rotation_timeout_summary, mKeyboardRotationTimeout.getEntry()));
 }
Esempio n. 16
0
  protected void updateSummaries() {
    Resources res = getResources();
    // for all text preferences, set summary as current database value
    for (String key : mPref.mValues.keySet()) {
      Preference pref = this.findPreference(key);
      if (key.equals("deckConf")) {
        String groupName = getOptionsGroupName();
        int count = getOptionsGroupCount();
        // Escape "%" in groupName as it's treated as a token
        groupName = groupName.replaceAll("%", "%%");
        pref.setSummary(
            res.getQuantityString(R.plurals.deck_conf_group_summ, count, groupName, count));
        continue;
      }

      String value = null;
      if (pref == null) {
        continue;
      } else if (pref instanceof CheckBoxPreference) {
        continue;
      } else if (pref instanceof ListPreference) {
        ListPreference lp = (ListPreference) pref;
        value = lp.getEntry() != null ? lp.getEntry().toString() : "";
      } else {
        value = this.mPref.getString(key, "");
      }
      // update summary
      if (!mPref.mSummaries.containsKey(key)) {
        CharSequence s = pref.getSummary();
        mPref.mSummaries.put(key, s != null ? pref.getSummary().toString() : null);
      }
      String summ = mPref.mSummaries.get(key);
      if (summ != null && summ.contains("XXX")) {
        pref.setSummary(summ.replace("XXX", value));
      } else {
        pref.setSummary(value);
      }
    }
    // Update summaries of preference items that don't have values (aren't in mValues)
    int subDeckCount = getSubdeckCount();
    this.findPreference("confSetSubdecks")
        .setSummary(
            res.getQuantityString(
                R.plurals.deck_conf_set_subdecks_summ, subDeckCount, subDeckCount));
  }
Esempio n. 17
0
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
          // Meaning a change in our radio buttons was made
          if (key.equals(PREF_KEY_NOTIFICATION_FREQUENCY_TOGGLE)) {
            listPreference.setSummary(
                getString(R.string.text_configured) + listPreference.getEntry().toString());
            if (listPreference.getEntry().equals(getString(R.string.text_daily))) {
              prefs.edit().putBoolean(AlarmsUtility.PREF_ALARM_DAILY, true).commit();
            } else {
              prefs.edit().putBoolean(AlarmsUtility.PREF_ALARM_DAILY, false).commit();
            }

            // Remove the current alarm
            AlarmsUtility.cancelAlarm(getActivity().getApplicationContext());
            // Reset one with the new frequency preference that has been set
            AlarmsUtility.setupAlarm(getActivity().getApplicationContext());
          }
        }
Esempio n. 18
0
  @SuppressWarnings("deprecation")
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Preference pref = findPreference(key);

    if (pref instanceof ListPreference) {
      ListPreference listPref = (ListPreference) pref;
      pref.setSummary(listPref.getEntry());
    }
  }
Esempio n. 19
0
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    if (getActivity() == null) return;

    final int vibrateMode = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);

    mVibrateOnRing.setChecked(vibrateMode == AudioManager.VIBRATE_SETTING_ON);
    mSilentMode.setValue(getPhoneSilentModeSettingValue());

    mSilentMode.setSummary(mSilentMode.getEntry());
  }
Esempio n. 20
0
  /**
   * Set summary of a list field If empty will display default summary If one item selected will
   * display item name
   *
   * @param fieldName the preference key name
   */
  public void setListFieldSummary(String fieldName) {
    PreferenceScreen pfs = getPreferenceScreen();
    ListPreference pref = (ListPreference) pfs.findPreference(fieldName);

    CharSequence val = pref.getEntry();
    if (TextUtils.isEmpty(val)) {
      val = getDefaultFieldSummary(fieldName);
    }
    setPreferenceSummary(pref, val);
  }
  private void updatePrefSummary(Preference p, boolean updatevis) {
    if (p instanceof ListPreference) {
      ListPreference listPref = (ListPreference) p;
      p.setSummary(listPref.getEntry());

    } else if (p instanceof EditTextPreference) {
      EditTextPreference editTextPref = (EditTextPreference) p;
      p.setSummary(editTextPref.getText());
    }
  }
Esempio n. 22
0
 /** Create the "Key Signature" preference */
 private void createKeySignaturePrefs(PreferenceScreen root) {
   key = new ListPreference(this);
   key.setOnPreferenceChangeListener(this);
   key.setTitle(R.string.key_signature);
   key.setEntries(R.array.key_signature_entries);
   key.setEntryValues(R.array.key_signature_values);
   key.setValueIndex(options.key + 1);
   key.setSummary(key.getEntry());
   root.addPreference(key);
 }
Esempio n. 23
0
 /** Create the "Show Note Letters" preference */
 private void createShowLetterPrefs(PreferenceScreen root) {
   showNoteLetters = new ListPreference(this);
   showNoteLetters.setOnPreferenceChangeListener(this);
   showNoteLetters.setTitle(R.string.show_note_letters);
   showNoteLetters.setEntries(R.array.show_note_letter_entries);
   showNoteLetters.setEntryValues(R.array.show_note_letter_values);
   showNoteLetters.setValueIndex(options.showNoteLetters);
   showNoteLetters.setSummary(showNoteLetters.getEntry());
   root.addPreference(showNoteLetters);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    new Thread(
            new Runnable() {
              public void run() {
                GoogleAnalyticsTracker.getInstance().trackPageView("/ColorSettingsActivity");
                GoogleAnalyticsTracker.getInstance().dispatch();
              }
            })
        .start();

    mConf = new ActivityConfigurator(this);
    mConf.onCreate();
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    lastTheme = mPrefs.getString("themes", "default");
    addPreferencesFromResource(R.xml.themesettings);
    addPreferencesFromResource(R.xml.colorsettings);
    ListPreference p = (ListPreference) findPreference("themes");
    p.setSummary(p.getEntry());

    ListPreference f = (ListPreference) findPreference("preferred_font");
    String[] fontList = ((AwfulApplication) getApplication()).getFontList();
    String[] fontNames = new String[fontList.length];
    for (int x = 0; x < fontList.length; x++) {
      Matcher fontName = fontFilename.matcher(fontList[x]);
      if (fontName.find()) {
        fontNames[x] = fontName.group(1).replaceAll("_", " ");
      } else { // if the regex fails, try our best to clean up the filename.
        fontNames[x] =
            fontList[x].replaceAll(".ttf.mp3", "").replaceAll("fonts/", "").replaceAll("_", " ");
      }
    }
    f.setEntries(fontNames);
    f.setEntryValues(fontList);
    f.setSummary(f.getEntry());
    for (String valueSummaryKey : VALUE_SUMMARY_KEYS_LIST) {
      ListPreference pl = (ListPreference) findPreference(valueSummaryKey);
      pl.setSummary(pl.getEntry());
    }
  }
Esempio n. 25
0
  public boolean onPreferenceChange(Preference p, Object newValue) {
    ListPreference l = (ListPreference) p;
    value = (String) newValue;

    updateFlags(value);

    l.setValue(value);
    l.setSummary(l.getEntry());

    return true;
  }
Esempio n. 26
0
 /**
  * Create the "Combine Notes Within Interval" preference. Notes within N milliseconds are combined
  * into a single chord, even though their start times may be slightly different.
  */
 private void createCombineIntervalPrefs(PreferenceScreen root) {
   int selected = options.combineInterval / 20 - 1;
   combineInterval = new ListPreference(this);
   combineInterval.setOnPreferenceChangeListener(this);
   combineInterval.setTitle(R.string.combine_interval);
   combineInterval.setEntries(R.array.combine_interval_entries);
   combineInterval.setEntryValues(R.array.combine_interval_values);
   combineInterval.setValueIndex(selected);
   combineInterval.setSummary(combineInterval.getEntry());
   root.addPreference(combineInterval);
 }
Esempio n. 27
0
 /** Create the "Transpose Notes" preference. The values range from 12, 11, 10, .. -10, -11, -12 */
 private void createTransposePrefs(PreferenceScreen root) {
   int transposeIndex = 12 - options.transpose;
   transpose = new ListPreference(this);
   transpose.setOnPreferenceChangeListener(this);
   transpose.setTitle(R.string.transpose);
   transpose.setEntries(R.array.transpose_entries);
   transpose.setEntryValues(R.array.transpose_values);
   transpose.setValueIndex(transposeIndex);
   transpose.setSummary(transpose.getEntry());
   root.addPreference(transpose);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.input_methods_settings);

    mDisableFullscreenKeyboard =
        (CheckBoxPreference) findPreference(PREF_DISABLE_FULLSCREEN_KEYBOARD);
    mDisableFullscreenKeyboard.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.DISABLE_FULLSCREEN_KEYBOARD, 0)
            == 1);
    mDisableFullscreenKeyboard.setOnPreferenceChangeListener(this);

    // Enable or disable mStatusBarImeSwitcher based on boolean value: config_show_cmIMESwitcher
    final Preference keyImeSwitcherPref = findPreference(KEY_IME_SWITCHER);
    if (keyImeSwitcherPref != null) {
      if (!getResources().getBoolean(com.android.internal.R.bool.config_show_IMESwitcher)) {
        getPreferenceScreen().removePreference(keyImeSwitcherPref);
      } else {
        mStatusBarImeSwitcher = (CheckBoxPreference) keyImeSwitcherPref;
        mStatusBarImeSwitcher.setOnPreferenceChangeListener(this);
      }
    }

    mVolumeKeyCursorControl = (ListPreference) findPreference(VOLUME_KEY_CURSOR_CONTROL);
    if (mVolumeKeyCursorControl != null) {
      mVolumeKeyCursorControl.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getContentResolver(), Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0)));
      mVolumeKeyCursorControl.setSummary(mVolumeKeyCursorControl.getEntry());
      mVolumeKeyCursorControl.setOnPreferenceChangeListener(this);
    }

    mKeyboardRotationToggle = (CheckBoxPreference) findPreference(KEYBOARD_ROTATION_TOGGLE);
    mKeyboardRotationToggle.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.KEYBOARD_ROTATION_TIMEOUT, 0)
            > 0);
    mKeyboardRotationToggle.setOnPreferenceChangeListener(this);

    mKeyboardRotationTimeout = (ListPreference) findPreference(KEYBOARD_ROTATION_TIMEOUT);
    mKeyboardRotationTimeout.setOnPreferenceChangeListener(this);
    updateRotationTimeout(
        Settings.System.getInt(
            getContentResolver(),
            Settings.System.KEYBOARD_ROTATION_TIMEOUT,
            KEYBOARD_ROTATION_TIMEOUT_DEFAULT));

    mShowEnterKey = (CheckBoxPreference) findPreference(SHOW_ENTER_KEY);
    mShowEnterKey.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.FORMAL_TEXT_INPUT, 0) == 1);
    mShowEnterKey.setOnPreferenceChangeListener(this);
  }
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals(LIST_SCALE)) {
     ListPreference listScalePref = (ListPreference) findPreference(LIST_SCALE);
     listScalePref.setSummary(listScalePref.getEntry());
   } else if (key.equals(VIDEO_START_DELAY)) {
     EditTextPreference videoStartPref = (EditTextPreference) findPreference(VIDEO_START_DELAY);
     videoStartPref.setSummary(videoStartPref.getText());
   } else if (key.equals(SEND_EMAIL_ADDRESS)) {
     EditTextPreference emailAddressPref = (EditTextPreference) findPreference(SEND_EMAIL_ADDRESS);
     emailAddressPref.setSummary(emailAddressPref.getText());
   }
 }
  @Override
  protected void onResume() {
    super.onResume();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    mKeepScreenOn.setSummary(mKeepScreenOn.getEntry());
    String val =
        prefs.getString("pref_keep_screen_on", getString(R.string.pref_default_keep_screen_on));

    if ("manual".equals(val)) {
      mScreenBrightness.setEnabled(true);
      mScreenBrightness.setSummary(
          getString(R.string.pref_summary_en_screen_brightness)
              + " "
              + mScreenBrightness.getProgress()
              + "%");
      if (showButtonBrightness) {
        mButtonBrightness.setEnabled(true);
        mButtonBrightness.setSummary(
            getString(R.string.pref_summary_en_button_brightness)
                + " "
                + mButtonBrightness.getProgress()
                + "%");
      } else {
        mButtonBrightness.setEnabled(false);
      }
    } else {
      mScreenBrightness.setEnabled(false);
      mButtonBrightness.setEnabled(false);
    }

    mScreenOrientation.setSummary(mScreenOrientation.getEntry());

    mFont.setSummary(getString(R.string.pref_summary_font) + ": " + mFont.getEntry());

    mScale.setSummary(getString(R.string.pref_summary_scale) + " " + mScale.getProgress() + "%");

    prefs.registerOnSharedPreferenceChangeListener(this);
  }