Java Code Examples for android.preference.ListPreference#setEnabled()
The following examples show how to use
android.preference.ListPreference#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static ListPreference List(Context context, PreferenceCategory category, int caption, int summary, int dialogCaption, String key, Object defaultValue, CharSequence[] entries, CharSequence[] entryValues, boolean enabled) { ListPreference retval = new ListPreference(context); if (caption > 0) retval.setTitle(caption); if (summary > 0) retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); if (dialogCaption > 0) retval.setDialogTitle(dialogCaption); retval.setEntries(entries); retval.setEntryValues(entryValues); if (category != null) category.addPreference(retval); return retval; }
Example 2
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static ListPreference List(Context context, PreferenceCategory category, String caption, String summary, String dialogCaption, String key, Object defaultValue, CharSequence[] entries, CharSequence[] entryValues, boolean enabled) { ListPreference retval = new ListPreference(context); retval.setTitle(caption); retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); retval.setDialogTitle(dialogCaption); retval.setEntries(entries); retval.setEntryValues(entryValues); if (category != null) category.addPreference(retval); return retval; }
Example 3
Source File: SettingsFragment.java From Linphone4Android with GNU General Public License v3.0 | 5 votes |
private void initLimeEncryptionPreference(ListPreference pref) { List<CharSequence> entries = new ArrayList<CharSequence>(); List<CharSequence> values = new ArrayList<CharSequence>(); entries.add(getString(R.string.lime_encryption_entry_disabled)); values.add(LinphoneLimeState.Disabled.toString()); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc == null || !lc.isLimeEncryptionAvailable()) { setListPreferenceValues(pref, entries, values); pref.setEnabled(false); return; } entries.add(getString(R.string.lime_encryption_entry_mandatory)); values.add(LinphoneLimeState.Mandatory.toString()); entries.add(getString(R.string.lime_encryption_entry_preferred)); values.add(LinphoneLimeState.Preferred.toString()); setListPreferenceValues(pref, entries, values); LinphoneLimeState lime = mPrefs.getLimeEncryption(); if (lime == LinphoneLimeState.Disabled) { pref.setSummary(getString(R.string.lime_encryption_entry_disabled)); } else if (lime == LinphoneLimeState.Mandatory) { pref.setSummary(getString(R.string.lime_encryption_entry_mandatory)); } else if (lime == LinphoneLimeState.Preferred) { pref.setSummary(getString(R.string.lime_encryption_entry_preferred)); } pref.setValue(lime.toString()); }
Example 4
Source File: PrefFragment.java From Aurora with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if ("select_linkage".equals(preference.getKey())) { CheckBoxPreference checkBox = (CheckBoxPreference) findPreference("select_linkage"); ListPreference editBox = (ListPreference) findPreference("select_city"); editBox.setEnabled(checkBox.isChecked()); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
Example 5
Source File: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private static void initPref_locale(Activity activity, ListPreference localePref) { final String[] localeDisplay = activity.getResources().getStringArray(R.array.locale_display); final String[] localeDisplayNative = activity.getResources().getStringArray(R.array.locale_display_native); final String[] localeValues = activity.getResources().getStringArray(R.array.locale_values); Integer[] index = getSortedOrder(localeDisplayNative); CharSequence[] entries = new CharSequence[localeValues.length]; CharSequence[] values = new CharSequence[localeValues.length]; for (int i=0; i<index.length; i++) { int j = index[i]; CharSequence formattedDisplayString; CharSequence localeDisplay_j = (localeDisplay.length > j ? localeDisplay[j] : localeValues[j]); CharSequence localeDisplayNative_j = (localeDisplayNative.length > j ? localeDisplayNative[j] : localeValues[j]); if (localeDisplay_j.equals(localeDisplayNative_j)) { formattedDisplayString = localeDisplayNative_j; } else { String localizedName = "(" + localeDisplay_j + ")"; String displayString = localeDisplayNative_j + " " + localizedName; formattedDisplayString = SuntimesUtils.createRelativeSpan(null, displayString, localizedName, 0.7f); } entries[i] = formattedDisplayString; values[i] = localeValues[j]; } localePref.setEntries(entries); localePref.setEntryValues(values); AppSettings.LocaleMode localeMode = AppSettings.loadLocaleModePref(activity); localePref.setEnabled(localeMode == AppSettings.LocaleMode.CUSTOM_LOCALE); }
Example 6
Source File: SettingsFragment.java From MedtronicUploader with GNU General Public License v2.0 | 5 votes |
private void addMedtronicOptionsListener(){ final EditTextPreference med_id = (EditTextPreference)findPreference("medtronic_cgm_id"); final EditTextPreference gluc_id = (EditTextPreference)findPreference("glucometer_cgm_id"); final EditTextPreference sensor_id = (EditTextPreference)findPreference("sensor_cgm_id"); final ListPreference calib_type = (ListPreference)findPreference("calibrationType"); final ListPreference glucSrcType = (ListPreference)findPreference("glucSrcTypes"); med_id.setEnabled(true); gluc_id.setEnabled(true); sensor_id.setEnabled(true); calib_type.setEnabled(true); glucSrcType.setEnabled(true); }
Example 7
Source File: SingleWebsitePreferences.java From delion with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon(getDisabledInChromeIcon(contentType)); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 8
Source File: AdvancedSettingsFragment.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_advanced); final Resources res = getResources(); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}. AudioAndHapticFeedbackManager.init(context); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (!Settings.isInternal(prefs)) { removePreference(Settings.SCREEN_DEBUG); } if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) { removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); } // TODO: consolidate key preview dismiss delay with the key preview animation parameters. if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } else { // TODO: Cleanup this setup. final ListPreference keyPreviewPopupDismissDelay = (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger( R.integer.config_key_preview_linger_timeout)); keyPreviewPopupDismissDelay.setEntries(new String[] { res.getString(R.string.key_preview_popup_dismiss_no_delay), res.getString(R.string.key_preview_popup_dismiss_default_delay), }); keyPreviewPopupDismissDelay.setEntryValues(new String[] { "0", popupDismissDelayDefaultValue }); if (null == keyPreviewPopupDismissDelay.getValue()) { keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue); } keyPreviewPopupDismissDelay.setEnabled( Settings.readKeyPreviewPopupEnabled(prefs, res)); } setupKeypressVibrationDurationSettings(); setupKeypressSoundVolumeSettings(); setupKeyLongpressTimeoutSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings(); }
Example 9
Source File: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 4 votes |
private static void updatePref_ui_themeOverride(String mode, ListPreference darkPref, ListPreference lightPref) { darkPref.setEnabled(AppSettings.THEME_DARK.equals(mode) || AppSettings.THEME_DAYNIGHT.equals(mode)); lightPref.setEnabled(AppSettings.THEME_LIGHT.equals(mode) || AppSettings.THEME_DAYNIGHT.equals(mode)); }
Example 10
Source File: SingleWebsitePreferences.java From 365browser with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon( ContentSettingsResources.getDisabledIcon(contentType, getResources())); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 11
Source File: SingleWebsitePreferences.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon( ContentSettingsResources.getDisabledIcon(contentType, getResources())); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 12
Source File: AdvancedSettingsFragment.java From openboard with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_advanced); final Resources res = getResources(); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}. AudioAndHapticFeedbackManager.init(context); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (!Settings.isInternal(prefs)) { removePreference(Settings.SCREEN_DEBUG); } if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) { removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); } // TODO: consolidate key preview dismiss delay with the key preview animation parameters. if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } else { // TODO: Cleanup this setup. final ListPreference keyPreviewPopupDismissDelay = (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger( R.integer.config_key_preview_linger_timeout)); keyPreviewPopupDismissDelay.setEntries(new String[] { res.getString(R.string.key_preview_popup_dismiss_no_delay), res.getString(R.string.key_preview_popup_dismiss_default_delay), }); keyPreviewPopupDismissDelay.setEntryValues(new String[] { "0", popupDismissDelayDefaultValue }); if (null == keyPreviewPopupDismissDelay.getValue()) { keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue); } keyPreviewPopupDismissDelay.setEnabled( Settings.readKeyPreviewPopupEnabled(prefs, res)); } setupKeypressVibrationDurationSettings(); setupKeypressSoundVolumeSettings(); setupKeyLongpressTimeoutSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings(); }
Example 13
Source File: BrailleBackPreferencesActivity.java From brailleback with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); mStatusPreference = findPreferenceByResId(R.string.pref_connection_status_key); mStatusPreference.setOnPreferenceClickListener(this); assignKeyBindingsIntent(); mBrailleTypePreference = (ListPreference) findPreferenceByResId( R.string.pref_braille_type_key); mBrailleTypePreference.setOnPreferenceChangeListener(this); mSixDotTablePreference = (ListPreference) findPreferenceByResId( R.string.pref_six_dot_braille_table_key); mSixDotTablePreference.setOnPreferenceChangeListener(this); mEightDotTablePreference = (ListPreference) findPreferenceByResId( R.string.pref_eight_dot_braille_table_key); mEightDotTablePreference.setOnPreferenceChangeListener(this); mOverlayPreference = findPreferenceByResId( R.string.pref_braille_overlay_key); mOverlayPreference.setOnPreferenceChangeListener(this); mOverlayTutorialPreference = findPreferenceByResId( R.string.pref_braille_overlay_tutorial_key); mOverlayTutorialPreference.setOnPreferenceClickListener(this); mLicensesPreference = findPreferenceByResId(R.string.pref_os_license_key); mLicensesPreference.setOnPreferenceClickListener(this); mLogLevelPreference = (ListPreference) findPreferenceByResId( R.string.pref_log_level_key); mLogLevelPreference.setOnPreferenceChangeListener(this); if (BuildConfig.DEBUG) { int logLevel = PreferenceUtils.getLogLevel(this); updateListPreferenceSummary(mLogLevelPreference, Integer.toString(logLevel)); mLogLevelPreference.setEnabled(false); } }
Example 14
Source File: AdvancedSettingsFragment.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_advanced); final Resources res = getResources(); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}. AudioAndHapticFeedbackManager.init(context); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (!Settings.isInternal(prefs)) { removePreference(Settings.SCREEN_DEBUG); } if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) { removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); } // TODO: consolidate key preview dismiss delay with the key preview animation parameters. if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } else { // TODO: Cleanup this setup. final ListPreference keyPreviewPopupDismissDelay = (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger( R.integer.config_key_preview_linger_timeout)); keyPreviewPopupDismissDelay.setEntries(new String[] { res.getString(R.string.key_preview_popup_dismiss_no_delay), res.getString(R.string.key_preview_popup_dismiss_default_delay), }); keyPreviewPopupDismissDelay.setEntryValues(new String[] { "0", popupDismissDelayDefaultValue }); if (null == keyPreviewPopupDismissDelay.getValue()) { keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue); } keyPreviewPopupDismissDelay.setEnabled( Settings.readKeyPreviewPopupEnabled(prefs, res)); } setupKeypressVibrationDurationSettings(); setupKeypressSoundVolumeSettings(); setupKeyLongpressTimeoutSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings(); }
Example 15
Source File: SettingsFragment.java From Linphone4Android with GNU General Public License v3.0 | 4 votes |
private void initMediaEncryptionPreference(ListPreference pref) { List<CharSequence> entries = new ArrayList<CharSequence>(); List<CharSequence> values = new ArrayList<CharSequence>(); entries.add(getString(R.string.pref_none)); values.add(getString(R.string.pref_media_encryption_key_none)); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc == null || getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) { setListPreferenceValues(pref, entries, values); return; } boolean hasZrtp = lc.mediaEncryptionSupported(MediaEncryption.ZRTP); boolean hasSrtp = lc.mediaEncryptionSupported(MediaEncryption.SRTP); boolean hasDtls = lc.mediaEncryptionSupported(MediaEncryption.DTLS); if (!hasSrtp && !hasZrtp && !hasDtls) { pref.setEnabled(false); } else { if (hasSrtp){ entries.add(getString(R.string.media_encryption_srtp)); values.add(getString(R.string.pref_media_encryption_key_srtp)); } if (hasZrtp){ entries.add(getString(R.string.media_encryption_zrtp)); values.add(getString(R.string.pref_media_encryption_key_zrtp)); } if (hasDtls){ entries.add(getString(R.string.media_encryption_dtls)); values.add(getString(R.string.pref_media_encryption_key_dtls)); } setListPreferenceValues(pref, entries, values); } MediaEncryption value = mPrefs.getMediaEncryption(); pref.setSummary(value.toString()); String key = getString(R.string.pref_media_encryption_key_none); if (value.toString().equals(getString(R.string.media_encryption_srtp))) key = getString(R.string.pref_media_encryption_key_srtp); else if (value.toString().equals(getString(R.string.media_encryption_zrtp))) key = getString(R.string.pref_media_encryption_key_zrtp); else if (value.toString().equals(getString(R.string.media_encryption_dtls))) key = getString(R.string.pref_media_encryption_key_dtls); pref.setValue(key); }
Example 16
Source File: SettingsActivity.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_updates); SensorManager senSensorManager = (SensorManager) getActivity() .getSystemService(Context.SENSOR_SERVICE); Sensor senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); boolean deviceHasAccelerometer = senSensorManager.registerListener( sensorListener, senAccelerometer, SensorManager.SENSOR_DELAY_FASTEST); senSensorManager.unregisterListener(sensorListener); Preference updateWidgetUpdatePref = findPreference(Constants.KEY_PREF_LOCATION_AUTO_UPDATE_PERIOD); ListPreference updateListPref = (ListPreference) updateWidgetUpdatePref; int accIndex = updateListPref.findIndexOfValue("0"); if (!deviceHasAccelerometer) { CharSequence[] entries = updateListPref.getEntries(); CharSequence[] newEntries = new CharSequence[entries.length - 1]; int i = 0; int j = 0; for (CharSequence entry : entries) { if (i != accIndex) { newEntries[j] = entries[i]; j++; } i++; } updateListPref.setEntries(newEntries); if (updateListPref.getValue() == null) { updateListPref.setValueIndex(updateListPref.findIndexOfValue("60") - 1); } } else if (updateListPref.getValue() == null) { updateListPref.setValueIndex(accIndex); } LocationsDbHelper locationsDbHelper = LocationsDbHelper.getInstance(getActivity()); List<Location> availableLocations = locationsDbHelper.getAllRows(); boolean oneNoautoLocationAvailable = false; for (Location location: availableLocations) { if (location.getOrderId() != 0) { oneNoautoLocationAvailable = true; break; } } if (!oneNoautoLocationAvailable) { ListPreference locationPreference = (ListPreference) findPreference("location_update_period_pref_key"); locationPreference.setEnabled(false); } ListPreference locationAutoPreference = (ListPreference) findPreference("location_auto_update_period_pref_key"); locationAutoPreference.setEnabled(locationsDbHelper.getLocationByOrderId(0).isEnabled()); }
Example 17
Source File: AdvancedSettingsFragment.java From Android-Keyboard with Apache License 2.0 | 4 votes |
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_advanced); final Resources res = getResources(); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}. AudioAndHapticFeedbackManager.init(context); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (!Settings.isInternal(prefs)) { removePreference(Settings.SCREEN_DEBUG); } if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) { removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); } // TODO: consolidate key preview dismiss delay with the key preview animation parameters. if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } else { // TODO: Cleanup this setup. final ListPreference keyPreviewPopupDismissDelay = (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger( R.integer.config_key_preview_linger_timeout)); keyPreviewPopupDismissDelay.setEntries(new String[] { res.getString(R.string.key_preview_popup_dismiss_no_delay), res.getString(R.string.key_preview_popup_dismiss_default_delay), }); keyPreviewPopupDismissDelay.setEntryValues(new String[] { "0", popupDismissDelayDefaultValue }); if (null == keyPreviewPopupDismissDelay.getValue()) { keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue); } keyPreviewPopupDismissDelay.setEnabled( Settings.readKeyPreviewPopupEnabled(prefs, res)); } setupKeypressVibrationDurationSettings(); setupKeypressSoundVolumeSettings(); setupKeyLongpressTimeoutSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings(); }