/** * Shows the simplified settings UI if the device configuration if the device configuration * dictates that a simplified, single-pane UI should be shown. */ private void setupSimplePreferencesScreen() { // if (!isSimplePreferences(this)) { // return; // } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. addPreferencesFromResource(R.xml.pref_container); // Add 'personal' preferences, and a corresponding header PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_personal); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_personal); // Add 'location' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_location); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_location); // Add 'display' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_display); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_display); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. // bindPreferenceSummaryToValue(findPreference("example_text")); bindPreferenceSummaryToValue(findPreference("temperature_preference")); bindPreferenceSummaryToValue(findPreference("dressing_style")); // bindPreferenceSummaryToValue(findPreference("sync_frequency")); }
public static PreferenceCategory Category( Context paramContext, PreferenceScreen paramPreferenceScreen, String paramString) { PreferenceCategory localPreferenceCategory = new PreferenceCategory(paramContext); localPreferenceCategory.setTitle(paramString); paramPreferenceScreen.addPreference(localPreferenceCategory); return localPreferenceCategory; }
// update the channel list ui by channel array private void updateChannelUIList() { MmsLog.d(LOG_TAG, "updateChannelUIList start"); mChannelListPreference.removeAll(); int length = mChannelArray.size(); for (int i = 0; i < length; i++) { Preference channel = new Preference(this); int keyId = mChannelArray.get(i).getKeyId(); String channelName = mChannelArray.get(i).getChannelName(); int channelId = mChannelArray.get(i).getChannelId(); boolean channelState = mChannelArray.get(i).getChannelState(); String title = channelName + "(" + String.valueOf(channelId) + ")"; channel.setTitle(title); final CellBroadcastChannel oldChannel = new CellBroadcastChannel(keyId, channelId, channelName, channelState); if (channelState) { channel.setSummary(R.string.enable); } else { channel.setSummary(R.string.disable); } channel.setOnPreferenceClickListener( new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference arg0) { showEditChannelDialog(oldChannel); return false; } }); mChannelListPreference.addPreference(channel); } MmsLog.d(LOG_TAG, "updateChannelUIList end"); }
/** * Shows the simplified settings UI if the device configuration if the device configuration * dictates that a simplified, single-pane UI should be shown. */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_notifications); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_notification); // Add 'data and sync' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_data_sync); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_data_sync); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference("example_text")); bindPreferenceSummaryToValue(findPreference("example_list")); bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); bindPreferenceSummaryToValue(findPreference("sync_frequency")); }
/** Create all the preference widgets in the view */ private void createView() { PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); createRestoreDefaultPrefs(root); createTrackPrefs(root); createMutePrefs(root); createInstrumentPrefs(root); PreferenceCategory sheetTitle = new PreferenceCategory(this); sheetTitle.setTitle(R.string.sheet_prefs_title); root.addPreference(sheetTitle); createScrollPrefs(root); createShowPianoPrefs(root); createShowLyricsPrefs(root); if (options.tracks.length != 2) { createTwoStaffsPrefs(root); } createShowLetterPrefs(root); createTransposePrefs(root); createKeySignaturePrefs(root); createTimeSignaturePrefs(root); createCombineIntervalPrefs(root); createColorPrefs(root); createPlayMeasuresInLoopPrefs(root); setPreferenceScreen(root); }
private void loadAccountPreference() { mAccountCategory.removeAll(); Preference accountPref = new Preference(this); final String defaultAccount = getSyncAccountName(this); accountPref.setTitle(getString(R.string.preferences_account_title)); accountPref.setSummary(getString(R.string.preferences_account_summary)); accountPref.setOnPreferenceClickListener( new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { if (!GTaskSyncService.isSyncing()) { if (TextUtils.isEmpty(defaultAccount)) { // the first time to set account showSelectAccountAlertDialog(); } else { // if the account has already been set, we need to promp // user about the risk showChangeAccountConfirmAlertDialog(); } } else { Toast.makeText( NotesPreferenceActivity.this, R.string.preferences_toast_cannot_change_account, Toast.LENGTH_SHORT) .show(); } return true; } }); mAccountCategory.addPreference(accountPref); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_design); // Bind the summaries of EditText/List/Dialog/Ringtone preferences // to their values. When their values change, their summaries are // updated to reflect the new value, per the Android Design // guidelines. ActivitySettings.bindPreferenceSummaryToValue( findPreference(this.getString(R.string.pref_design_key_col_num))); // textSize Preference prefTextSize = findPreference(this.getString(R.string.pref_design_key_text_size)); prefTextSize.setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { FragmentDialogTextAppearance frag = FragmentDialogTextAppearance.newInstance(); frag.show(getFragmentManager(), "TextAppearance"); return false; } }); // hide cats or tags default Preference preference = findPreference(getString(R.string.pref_design_key_category_in_cats_or_tags)); PreferenceCategory mCategory = (PreferenceCategory) findPreference(getString(R.string.pref_design_main_category_key)); mCategory.removePreference(preference); }
/** * Shows the simplified settings UI if the device configuration dictates that a simplified, * single-pane UI should be shown. */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!SettingsActivity.isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. this.addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. PreferenceCategory preferencesFakeHeader = new PreferenceCategory(this); preferencesFakeHeader.setTitle(R.string.pref_header_notifications); this.getPreferenceScreen().addPreference(preferencesFakeHeader); this.addPreferencesFromResource(R.xml.pref_notification); // Add 'Other' preferences, and a corresponding header. PreferenceCategory otherFakeHeader = new PreferenceCategory(this); otherFakeHeader.setTitle(R.string.pref_header_other); this.getPreferenceScreen().addPreference(otherFakeHeader); this.addPreferencesFromResource(R.xml.pref_other); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to their values. // When their values change, their summaries are updated to reflect the new value, per the // Android Design guidelines. SettingsActivity.bindPreferenceSummaryToValue( this.findPreference(this.getString(R.string.pref_key_notifications_alarms_ringtone))); }
/** * Shows the simplified settings UI if the device configuration if the device configuration * dictates that a simplified, single-pane UI should be shown. */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } addPreferencesFromResource(R.xml.pref_blank); // Add 'filters' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.filters); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_filters); bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_log_level))); setupTagFilterPreference(this, findPreference(getString(R.string.pref_tag_filter))); sTagFilterPref = findPreference(getString(R.string.pref_tag_filter)); // Add 'appearance' preferences. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.appearance); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_appearance); // Add 'info' preferences. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.information); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_info); setupOpenSourceInfoPreference(this, findPreference(getString(R.string.pref_info_open_source))); setupVersionPref(this, findPreference(getString(R.string.pref_version))); }
private void changeVoltage(final boolean isPlus) { final int prefsIndex = mCategory.getPreferenceCount(); CustomPreference pref; String value; boolean isCurrent = false; for (int i = 0; i < prefsIndex; i++) { pref = (CustomPreference) mCategory.getPreference(i); if (pref != null) { if (isVdd) { if (isPlus) { pref.setCustomSummaryKeyPlus(25000); } else { pref.setCustomSummaryKeyMinus(25000); } } else { if (isPlus) { pref.setCustomSummaryKeyPlus(25); } else { pref.setCustomSummaryKeyMinus(25); } } value = pref.getKey(); if (value != null) { isCurrent = value.equals(mValues[i]); } } } if (isCurrent) { mButtonLayout.setVisibility(View.GONE); } else { mButtonLayout.setVisibility(View.VISIBLE); } }
@Override protected void onResume() { super.onResume(); // TODO Auto-generated method stub if (!PreyStatus.getInstance().isPreyConfigurationActivityResume()) { Intent intent = new Intent(getApplicationContext(), LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("EXIT", true); try { startActivity(intent); } catch (Exception e) { } finish(); } try { if (PreyEmail.getEmail(getApplicationContext()) != null) { PreferenceCategory mCategory = (PreferenceCategory) findPreference("PREFS_CAT_PREFS"); Preference p2 = findPreference(PreyConfig.PREFS_SCHEDULED); mCategory.removePreference(p2); } } catch (Exception e) { } PreyConfig preyConfig = PreyConfig.getPreyConfig(getApplicationContext()); Preference p = findPreference("PREFS_ADMIN_DEVICE"); if (preyConfig.isFroyoOrAbove()) { if (FroyoSupport.getInstance(getApplicationContext()).isAdminActive()) { p.setTitle(R.string.preferences_admin_enabled_title); p.setSummary(R.string.preferences_admin_enabled_summary); } else { p.setTitle(R.string.preferences_admin_disabled_title); p.setSummary(R.string.preferences_admin_disabled_summary); } } else p.setEnabled(false); p = findPreference("PREFS_ABOUT"); p.setSummary("Version " + preyConfig.getPreyVersion() + " - Prey Inc."); Preference pGo = findPreference("PREFS_GOTO_WEB_CONTROL_PANEL"); pGo.setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl(); PreyLogger.d("url control:" + url); Intent internetIntent = new Intent(Intent.ACTION_VIEW); internetIntent.setData(Uri.parse(url)); try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } catch (Exception e) { } return false; } }); }
private void hideGPSCategory() { PreferenceScreen preferenceScreen = getPreferenceScreen(); PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(getResources().getString(R.string.pref_gps_category)); if (preferenceCategory != null) { preferenceCategory.removeAll(); preferenceScreen.removePreference((Preference) preferenceCategory); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.advanced); if (!ShellUtils.isRooted()) { PreferenceCategory bypassCategoryPref = (PreferenceCategory) findPreference("Bypass"); bypassCategoryPref.removePreference(bypassCategoryPref.findPreference("TcpScramblerEnabled")); } }
private void updateHardKeyboards() { mHardKeyboardPreferenceList.clear(); if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY) { final int[] devices = InputDevice.getDeviceIds(); for (int i = 0; i < devices.length; i++) { InputDevice device = InputDevice.getDevice(devices[i]); if (device != null && !device.isVirtual() && device.isFullKeyboard()) { final String inputDeviceDescriptor = device.getDescriptor(); final String keyboardLayoutDescriptor = mIm.getCurrentKeyboardLayoutForInputDevice(inputDeviceDescriptor); final KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ? mIm.getKeyboardLayout(keyboardLayoutDescriptor) : null; final PreferenceScreen pref = new PreferenceScreen(getActivity(), null); pref.setTitle(device.getName()); if (keyboardLayout != null) { pref.setSummary(keyboardLayout.toString()); } else { pref.setSummary(R.string.keyboard_layout_default_label); } pref.setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { showKeyboardLayoutDialog(inputDeviceDescriptor); return true; } }); mHardKeyboardPreferenceList.add(pref); } } } if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = mHardKeyboardCategory.getPreferenceCount(); i-- > 0; ) { final Preference pref = mHardKeyboardCategory.getPreference(i); if (pref.getOrder() < 1000) { mHardKeyboardCategory.removePreference(pref); } } Collections.sort(mHardKeyboardPreferenceList); final int count = mHardKeyboardPreferenceList.size(); for (int i = 0; i < count; i++) { final Preference pref = mHardKeyboardPreferenceList.get(i); pref.setOrder(i); mHardKeyboardCategory.addPreference(pref); } getPreferenceScreen().addPreference(mHardKeyboardCategory); } else { getPreferenceScreen().removePreference(mHardKeyboardCategory); } }
void hideShowRunWhenCategories(String runwhen) { switch (runwhen) { case ServiceSettings.SCHEDULED: catBetween.setEnabled(true); break; default: catBetween.setEnabled(false); break; } }
private void initSummary(Preference p) { if (p instanceof PreferenceCategory) { PreferenceCategory pCat = (PreferenceCategory) p; for (int i = 0; i < pCat.getPreferenceCount(); i++) { initSummary(pCat.getPreference(i)); } } else { updatePrefSummary(p); } }
private void initSummary(Preference p) { if (p instanceof PreferenceCategory) { PreferenceCategory pCat = (PreferenceCategory) p; for (int i = 0; i < pCat.getPreferenceCount(); i++) { if (!pCat.getPreference(i).getKey().equals(KEY_PREF_SERVER_PASS)) { initSummary(pCat.getPreference(i)); } } } else { updatePrefSummary(p); } }
private void initializeAllPreferences() { mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY); mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY); // Large text. mToggleLargeTextPreference = (CheckBoxPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE); // Power button ends calls. mTogglePowerButtonEndsCallPreference = (CheckBoxPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE); if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) || !Utils.isVoiceCapable(getActivity())) { mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference); } // Auto-rotate screen mToggleAutoRotateScreenPreference = (CheckBoxPreference) findPreference(TOGGLE_AUTO_ROTATE_SCREEN_PREFERENCE); // Speak passwords. mToggleSpeakPasswordPreference = (CheckBoxPreference) findPreference(TOGGLE_SPEAK_PASSWORD_PREFERENCE); // Touch exploration enabled. mToggleTouchExplorationPreference = findPreference(TOGGLE_TOUCH_EXPLORATION_PREFERENCE); // Long press timeout. mSelectLongPressTimeoutPreference = (ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE); mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this); if (mLongPressTimeoutValuetoTitleMap.size() == 0) { String[] timeoutValues = getResources().getStringArray(R.array.long_press_timeout_selector_values); mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]); String[] timeoutTitles = getResources().getStringArray(R.array.long_press_timeout_selector_titles); final int timeoutValueCount = timeoutValues.length; for (int i = 0; i < timeoutValueCount; i++) { mLongPressTimeoutValuetoTitleMap.put(timeoutValues[i], timeoutTitles[i]); } } // Script injection. mToggleScriptInjectionPreference = (AccessibilityEnableScriptInjectionPreference) findPreference(TOGGLE_SCRIPT_INJECTION_PREFERENCE); // IPO mIpoSetting = (CheckBoxPreference) findPreference(IPO_SETTING); if (!FeatureOption.MTK_IPO_SUPPORT) { mSystemsCategory.removePreference(mIpoSetting); } }
/** Create the "Select Tracks to Mute" checkboxes. */ private void createMutePrefs(PreferenceScreen root) { PreferenceCategory muteTracksTitle = new PreferenceCategory(this); muteTracksTitle.setTitle(R.string.select_tracks_to_mute); root.addPreference(muteTracksTitle); muteTracks = new CheckBoxPreference[options.mute.length]; for (int i = 0; i < options.mute.length; i++) { muteTracks[i] = new CheckBoxPreference(this); muteTracks[i].setTitle("Track " + i); muteTracks[i].setChecked(options.mute[i]); root.addPreference(muteTracks[i]); } }
/** Create the "Select Tracks to Display" checkboxes. */ private void createTrackPrefs(PreferenceScreen root) { PreferenceCategory selectTracksTitle = new PreferenceCategory(this); selectTracksTitle.setTitle(R.string.select_tracks_to_display); root.addPreference(selectTracksTitle); selectTracks = new CheckBoxPreference[options.tracks.length]; for (int i = 0; i < options.tracks.length; i++) { selectTracks[i] = new CheckBoxPreference(this); selectTracks[i].setTitle("Track " + i); selectTracks[i].setChecked(options.tracks[i]); root.addPreference(selectTracks[i]); } }
public void onIabPurchaseFinished(IabResult result, Purchase purchase) { if (result.isFailure()) { Toast.makeText(mContext, R.string.unable_to_purchase, Toast.LENGTH_LONG).show(); sharedPreferences.edit().putBoolean("TRIAL", true).commit(); return; } else if (purchase.getSku().equals(ITEM_SKU)) { Toast.makeText(mContext, R.string.ALMusic_trial_time_removed, Toast.LENGTH_LONG).show(); mApp.getSharedPreferences().edit().putBoolean("TRIAL", false).commit(); PreferenceCategory upgradePrefCategory = (PreferenceCategory) preferenceManager.findPreference("upgrade_pref_category"); upgradePrefCategory.removeAll(); } }
/** Method is beeing called on any click of an preference... */ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference.getKey().equals(KEY_WIFI_BASED_SCREEN)) { mWifiList = mWifiManager.getConfiguredNetworks(); if (mWifiList == null) { return false; } for (WifiConfiguration wifi : mWifiList) { // Friendly SSID-Name String ssid = wifi.SSID.replaceAll("\"", ""); // Add PreferenceScreen for each network PreferenceScreen pref = getPreferenceManager().createPreferenceScreen(this); pref.setPersistent(false); pref.setKey("wifiNetwork" + ssid); pref.setTitle(ssid); Intent intent = new Intent(this, ConnectionSettings.class); intent.putExtra("SSID", ssid); pref.setIntent(intent); if (WifiConfiguration.Status.CURRENT == wifi.status) pref.setSummary(R.string.connected); else pref.setSummary(R.string.notInRange); mWifibasedCategory.addPreference(pref); } } return false; }
/** * Iterate through debug buttons, adding a special debug preference click listener to each of * them. */ protected void connectDebugButtons() { // Separate listener to really separate debug logic from main code paths. final OnPreferenceClickListener listener = new DebugPreferenceClickListener(); // We don't want to use Android resource strings for debug UI, so we just // use the keys throughout. final PreferenceCategory debugCategory = (PreferenceCategory) ensureFindPreference("debug_category"); debugCategory.setTitle(debugCategory.getKey()); for (int i = 0; i < debugCategory.getPreferenceCount(); i++) { final Preference button = debugCategory.getPreference(i); button.setTitle(button.getKey()); // Not very friendly, but this is for debugging only! button.setOnPreferenceClickListener(listener); } }
@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // this is important because although the handler classes that read // these settings // are in the same package, they are executed in the context of the // hooked package getPreferenceManager().setSharedPreferencesMode(Context.MODE_WORLD_READABLE); addPreferencesFromResource(R.xml.settings); mPrefs = getPreferenceScreen().getSharedPreferences(); AppPickerPreference.sPrefsFragment = this; AppPickerPreference.cleanupAsync(getActivity()); PreferenceCategory mPrefCatLsShortcuts = (PreferenceCategory) findPreference(PREF_CAT_KEY_LOCKSCREEN_SHORTCUTS); mPrefs = getPreferenceManager().getSharedPreferences(); if (isPackageInstalled(getActivity(), "com.ceco.lollipop.gravitybox") && mPrefs.getBoolean("welcome", true)) { AlertDialog alert = new AlertDialog.Builder(getActivity()) .setTitle(R.string.warning) .setMessage(R.string.gravitybox_installed) .setCancelable(false) .setPositiveButton(android.R.string.ok, null) .create(); alert.show(); mPrefs.edit().putBoolean("welcome", false).apply(); } for (int i = 0; i < PREF_KEY_LOCKSCREEN_SHORTCUT.size(); i++) { AppPickerPreference appPref = new AppPickerPreference(getActivity(), null); appPref.setKey(PREF_KEY_LOCKSCREEN_SHORTCUT.get(i)); appPref.setTitle(String.format(getString(R.string.pref_app_launcher_slot_title), i + 1)); appPref.setDialogTitle(appPref.getTitle()); appPref.setDefaultSummary(getString(R.string.app_picker_none)); appPref.setSummary(getString(R.string.app_picker_none)); mPrefCatLsShortcuts.addPreference(appPref); if (mPrefs.getString(appPref.getKey(), null) == null) { mPrefs.edit().putString(appPref.getKey(), null).apply(); } } }
protected void updateSyncServerPreference() { final String syncServer = fxAccount.getTokenServerURI(); final boolean shouldBeShown = ALWAYS_SHOW_SYNC_SERVER || !FxAccountConstants.DEFAULT_TOKEN_SERVER_ENDPOINT.equals(syncServer); final boolean currentlyShown = null != findPreference(syncServerPreference.getKey()); if (currentlyShown != shouldBeShown) { if (shouldBeShown) { syncCategory.addPreference(syncServerPreference); } else { syncCategory.removePreference(syncServerPreference); } } // Always set the summary, because on first run, the preference is visible, // and the above block will be skipped if there is a custom value. syncServerPreference.setSummary(syncServer); }
protected void showNeedsMasterSyncAutomaticallyEnabled() { syncCategory.setTitle(R.string.fxaccount_status_sync); needsMasterSyncAutomaticallyEnabledPreference.setTitle( AppConstants.Versions.preLollipop ? R.string.fxaccount_status_needs_master_sync_automatically_enabled : R.string.fxaccount_status_needs_master_sync_automatically_enabled_v21); showOnlyOneErrorPreference(needsMasterSyncAutomaticallyEnabledPreference); setCheckboxesEnabled(false); }
@Override public void onResume() { super.onResume(); mSettingsObserver.resume(); mIm.registerInputDeviceListener(this, null); if (!mIsOnlyImeSettings) { if (mLanguagePref != null) { Configuration conf = getResources().getConfiguration(); String language = conf.locale.getLanguage(); String localeString; // TODO: This is not an accurate way to display the locale, as it is // just working around the fact that we support limited dialects // and want to pretend that the language is valid for all locales. // We need a way to support languages that aren't tied to a particular // locale instead of hiding the locale qualifier. if (hasOnlyOneLanguageInstance(language, Resources.getSystem().getAssets().getLocales())) { localeString = conf.locale.getDisplayLanguage(conf.locale); } else { localeString = conf.locale.getDisplayName(conf.locale); } if (localeString.length() > 1) { localeString = Character.toUpperCase(localeString.charAt(0)) + localeString.substring(1); mLanguagePref.setSummary(localeString); } } updateUserDictionaryPreference(findPreference(KEY_USER_DICTIONARY_SETTINGS)); if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) { mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this); } } if (mStatusBarImeSwitcher != null) { mStatusBarImeSwitcher.setChecked( Settings.System.getInt( getActivity().getContentResolver(), Settings.System.STATUS_BAR_IME_SWITCHER, 1) != 0); } // Hard keyboard if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = 0; i < sHardKeyboardKeys.length; ++i) { CheckBoxPreference chkPref = (CheckBoxPreference) mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i]); chkPref.setChecked(System.getInt(getContentResolver(), sSystemSettingNames[i], 1) > 0); } } updateInputDevices(); // IME InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(this, getContentResolver(), mImis, null); updateActiveInputMethodsSummary(); }
private void updateNetworks(Context context) { if (SHOW_MOBILE_CATEGORY && hasReadyMobileRadio(context)) { mMobileCategory.removeAll(); mMobileCategory.addPreference(buildMobilePref(context)); } else { getPreferenceScreen().removePreference(mMobileCategory); } mWifiCategory.removeAll(); if (hasWifiRadio(context) && mWifiManager.isWifiEnabled()) { for (WifiConfiguration config : mWifiManager.getConfiguredNetworks()) { if (config.SSID != null) { mWifiCategory.addPreference(buildWifiPref(context, config)); } } } else { mWifiCategory.addPreference(mWifiDisabled); } }
/** * Create the "Select Instruments For Each Track " lists. The list of possible instruments is in * MidiFile.java. */ private void createInstrumentPrefs(PreferenceScreen root) { PreferenceCategory selectInstrTitle = new PreferenceCategory(this); selectInstrTitle.setTitle(R.string.select_instruments_per_track); root.addPreference(selectInstrTitle); selectInstruments = new ListPreference[options.tracks.length]; for (int i = 0; i < options.instruments.length; i++) { selectInstruments[i] = new ListPreference(this); selectInstruments[i].setOnPreferenceChangeListener(this); selectInstruments[i].setEntries(MidiFile.Instruments); selectInstruments[i].setEntryValues(MidiFile.Instruments); selectInstruments[i].setTitle("Track " + i); selectInstruments[i].setValueIndex(options.instruments[i]); selectInstruments[i].setSummary(selectInstruments[i].getEntry()); root.addPreference(selectInstruments[i]); } setAllToPiano = new Preference(this); setAllToPiano.setTitle(R.string.set_all_to_piano); setAllToPiano.setOnPreferenceClickListener(this); root.addPreference(setAllToPiano); }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { // Input Method stuff if (Utils.isMonkeyRunning()) { return false; } if (preference == mStatusBarImeSwitcher) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.STATUS_BAR_IME_SWITCHER, mStatusBarImeSwitcher.isChecked() ? 1 : 0); return true; } else if (preference instanceof PreferenceScreen) { if (preference.getFragment() != null) { // Fragment will be handled correctly by the super class. } else if (KEY_CURRENT_INPUT_METHOD.equals(preference.getKey())) { final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showInputMethodPicker(); } } else if (preference instanceof CheckBoxPreference) { final CheckBoxPreference chkPref = (CheckBoxPreference) preference; if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = 0; i < sHardKeyboardKeys.length; ++i) { if (chkPref == mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i])) { System.putInt( getContentResolver(), sSystemSettingNames[i], chkPref.isChecked() ? 1 : 0); return true; } } } if (chkPref == mGameControllerCategory.findPreference("vibrate_input_devices")) { System.putInt( getContentResolver(), Settings.System.VIBRATE_INPUT_DEVICES, chkPref.isChecked() ? 1 : 0); return true; } } return super.onPreferenceTreeClick(preferenceScreen, preference); }