private void removeUnnecessaryAdvancedPrefs(PreferenceScreen screen) { PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("category_plugins"); // Disable the emoji/kana buttons to scroll preference if those keys don't exist if (!CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference emojiScrolling = (CheckBoxPreference) screen.findPreference("scrolling_buttons"); if (emojiScrolling != null && plugins != null) { plugins.removePreference(emojiScrolling); } } // Disable the double scroll preference if no scrolling keys if (!CompatHelper.hasScrollKeys() && !CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference doubleScrolling = (CheckBoxPreference) screen.findPreference("double_scrolling"); if (doubleScrolling != null && plugins != null) { plugins.removePreference(doubleScrolling); } } PreferenceCategory workarounds = (PreferenceCategory) screen.findPreference("category_workarounds"); if (workarounds != null) { CheckBoxPreference fixHebrewText = (CheckBoxPreference) screen.findPreference("fixHebrewText"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); if (CompatHelper.getSdkVersion() >= 16) { workarounds.removePreference(fixHebrewText); } } }
PreferenceCategory cat_required = new PreferenceCategory(this); PreferenceCategory cat_general = new PreferenceCategory(this); PreferenceCategory cat_advanced = new PreferenceCategory(this); PreferenceCategory cat_evasion = new PreferenceCategory(this); ArrayList<Preference> required = new ArrayList<Preference>(); ArrayList<Preference> general = new ArrayList<Preference>(); cat_required.setTitle(R.string.required); cat_general.setTitle(R.string.pref_general); cat_advanced.setTitle(R.string.pref_advanced); cat_evasion.setTitle(R.string.evasion); root.addPreference(cat_required); for(Preference i : required) cat_required.addPreference(i); cat_general.addPreference(i); cat_advanced.addPreference(i); cat_evasion.addPreference(i);
@Override protected void onBindView(View view) { super.onBindView(view); TextView titleView = (TextView) view.findViewById(android.R.id.title); titleView.setTextColor(Config.accentColor(context, Helpers.getATEKey(context))); } }
private void updateAdvancedOptions(boolean checked) { PreferenceCategory category = (PreferenceCategory) findPreference("settings_advanced"); for (int i = 1; i < category.getPreferenceCount(); i++) { Preference preference = category.getPreference(i); if (checked) { preference.setEnabled(true); } else { preference.setEnabled(false); if (preference instanceof SwitchPreference) { ((SwitchPreference) preference).setChecked(false); } } } }
watchCategory.removePreference(pebbleSpecialValue); watchCategory.removePreference(pebbleSpecialText); } else { watchCategory.removePreference(pebbleTrend); watchCategory.removePreference(pebbleFilteredLine); watchCategory.removePreference(pebbleTinyDots); watchCategory.removePreference(pebbleHighLine); watchCategory.removePreference(pebbleLowLine); watchCategory.removePreference(pebbleTrendPeriod); watchCategory.removePreference(pebbleDelta); watchCategory.removePreference(pebbleDeltaUnits); watchCategory.removePreference(pebbleShowArrows); watchCategory.removePreference(pebbleSpecialValue); watchCategory.removePreference(pebbleSpecialText); watchCategory.removePreference(pebbleVibrateNoSignal); watchCategory.removePreference(pebbleVibrateNoBluetooth); watchCategory.addPreference(pebbleTrend); watchCategory.addPreference(pebbleFilteredLine); watchCategory.addPreference(pebbleTinyDots); watchCategory.addPreference(pebbleHighLine); watchCategory.addPreference(pebbleLowLine); watchCategory.addPreference(pebbleTrendPeriod); watchCategory.addPreference(pebbleDelta); watchCategory.addPreference(pebbleDeltaUnits); watchCategory.addPreference(pebbleShowArrows); watchCategory.addPreference(pebbleVibrateNoSignal); watchCategory.addPreference(pebbleVibrateNoBluetooth);
@Override public void buildSettingsSection(PreferenceCategory category) { for (ISettingsItem s : mAllSettings) { category.addPreference(s.onCreatePreference(mContext)); } }
@Override public void passwordExceptionListAvailable(int count) { resetList(PREF_CATEGORY_EXCEPTIONS); mNoPasswordExceptions = count == 0; if (mNoPasswordExceptions) { if (mNoPasswords) displayEmptyScreenMessage(); return; } displayManageAccountLink(); PreferenceCategory profileCategory = new PreferenceCategory(getActivity()); profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS); profileCategory.setTitle(R.string.section_saved_passwords_exceptions); profileCategory.setOrder(ORDER_EXCEPTIONS); getPreferenceScreen().addPreference(profileCategory); for (int i = 0; i < count; i++) { String exception = mPasswordManagerHandler.getSavedPasswordException(i); PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity()); screen.setTitle(exception); screen.setOnPreferenceClickListener(this); Bundle args = screen.getExtras(); args.putString(PASSWORD_LIST_URL, exception); args.putInt(PASSWORD_LIST_ID, i); profileCategory.addPreference(screen); } }
private PreferenceCategory getCategory(@StringRes int titleRes) { PreferenceCategory c = new PreferenceCategory(getActivity()); c.setTitle(titleRes); return c; }
@Override public void onReceive(Context context, Intent intent) { final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME); final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME); Log.d(LOG_TAG, "Recieved del application: "+appName+" : "+packageName); appManager.delNotificationApp(packageName); oPrefs.removeSet(packageName); oPrefs.removeString(packageName); PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps"); Preference app = (Preference) findPreference(packageName); category.removePreference(app); // If no more preference in the category, restore the placeholder if(category.getPreferenceCount() <= 0) { category.addPreference(preference_apps_placeholder); } sendNotificationApplications(); } };
private void updateUserPreferences() { users.removeAll(); for (ScaleUser scaleUser : OpenScale.getInstance().getScaleUserList()) { users.addPreference(new UserPreference(getActivity(), users, scaleUser)); } }
pref.removePreference(pref.findPreference(Preferences.KEEP_IN_MESSAGING)); pref.removePreference(pref.findPreference(Preferences.DUALSIM_SIM)); } else { fillDualSimList(preferenceScreen);
PreferenceCategory fakeHeader = new PreferenceCategory(getActivity()); fakeHeader.setTitle(R.string.hdr_pref_about); fakeHeader.setLayoutResource(R.layout.preference_category); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_about);
serverCount++; int instance = serverCount; serversCategory.addPreference(addServer(serverCount)); }); serversCategory.setOrderingAsAdded(false); for (int i = 1; i <= serverCount; i++) { serversCategory.addPreference(addServer(i)); serverSettings.put(String.valueOf(i), new ServerSettings(i));
/** * 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 (!SettingsActivity.isSimplePreferences(this)) { return; } // Class<ContactPreferenceFragment> a = ContactPreferenceFragment.class; // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(this); addPreferencesFromResource(R.xml.pref_contact); SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_FULL_NAME)); SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_ADDRESS)); SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_PHONE_NUMBER)); SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_EMAIL)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.user_cred_prefs); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } String snapp = getIntent().getExtras().getString("netapp"); if (snapp == null) { Log.e(TAG, "Got null snetapp"); finish(); } mNetApp = NetApp.valueOf(snapp); settings = new AppSettings(this); mHeader = (PreferenceCategory) findPreference(KEY_USER_CREDS_HEADER); mHeader.setTitle(mNetApp.getName()); mEditCreds = (EditUserCredentials) findPreference(KEY_EDIT_USER_CREDENTIALS); mEditCreds.setNetApp(mNetApp); mClearCreds = findPreference(KEY_CLEAR_USER_CREDENTIALS); mCreateUser = findPreference(KEY_CREATE_USER); mCreateUser.setSummary(getString(R.string.create_user_summary).replace( "%1", mNetApp.getName())); }
@Test public void inflate_shouldCreateCorrectClasses() throws Exception { final PreferenceScreen screen = inflatePreferenceActivity(); assertThat(screen.getPreference(0)).isInstanceOf(PreferenceCategory.class); PreferenceCategory category = (PreferenceCategory) screen.getPreference(0); assertThat(category.getPreference(0)).isInstanceOf(Preference.class); PreferenceScreen innerScreen = (PreferenceScreen) screen.getPreference(1); assertThat(innerScreen).isInstanceOf(PreferenceScreen.class); assertThat(innerScreen.getKey()).isEqualTo("screen"); assertThat(innerScreen.getTitle().toString()).isEqualTo("Screen Test"); assertThat(innerScreen.getSummary()).isEqualTo("Screen summary"); assertThat(innerScreen.getPreference(0)).isInstanceOf(Preference.class); assertThat(screen.getPreference(2)).isInstanceOf(CheckBoxPreference.class); assertThat(screen.getPreference(3)).isInstanceOf(EditTextPreference.class); assertThat(screen.getPreference(4)).isInstanceOf(ListPreference.class); assertThat(screen.getPreference(5)).isInstanceOf(Preference.class); assertThat(screen.getPreference(6)).isInstanceOf(RingtonePreference.class); assertThat(screen.getPreference(7)).isInstanceOf(Preference.class); }
watchCategory.removePreference(pebbleSpecialValue); watchCategory.removePreference(pebbleSpecialText); } else { watchCategory.removePreference(pebbleTrend); watchCategory.removePreference(pebbleFilteredLine); watchCategory.removePreference(pebbleTinyDots); watchCategory.removePreference(pebbleHighLine); watchCategory.removePreference(pebbleLowLine); watchCategory.removePreference(pebbleTrendPeriod); watchCategory.removePreference(pebbleDelta); watchCategory.removePreference(pebbleDeltaUnits); watchCategory.removePreference(pebbleShowArrows); watchCategory.removePreference(pebbleSpecialValue); watchCategory.removePreference(pebbleSpecialText); watchCategory.removePreference(pebbleVibrateNoSignal); watchCategory.removePreference(pebbleVibrateNoBluetooth); watchCategory.addPreference(pebbleTrend); watchCategory.addPreference(pebbleFilteredLine); watchCategory.addPreference(pebbleTinyDots); watchCategory.addPreference(pebbleHighLine); watchCategory.addPreference(pebbleLowLine); watchCategory.addPreference(pebbleTrendPeriod); watchCategory.addPreference(pebbleDelta); watchCategory.addPreference(pebbleDeltaUnits); watchCategory.addPreference(pebbleShowArrows); watchCategory.addPreference(pebbleVibrateNoSignal); watchCategory.addPreference(pebbleVibrateNoBluetooth);
private void loadUserCredsList() { NetApp[] napps = NetApp.values(); for (NetApp napp : napps) { Preference pref = new Preference(this, null); mUserCredsPrefToAppMap.put(pref, napp); mUserCredsAppToPrefMap.put(napp, pref); mUserCredsList.addPreference(pref); } }
@Override public void passwordListAvailable(int count) { resetList(PREF_CATEGORY_SAVED_PASSWORDS); mNoPasswords = count == 0; if (mNoPasswords) { if (mNoPasswordExceptions) displayEmptyScreenMessage(); return; } displayManageAccountLink(); PreferenceCategory profileCategory = new PreferenceCategory(getActivity()); profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS); profileCategory.setTitle(R.string.section_saved_passwords); profileCategory.setOrder(ORDER_SAVED_PASSWORDS); getPreferenceScreen().addPreference(profileCategory); for (int i = 0; i < count; i++) { PasswordUIView.SavedPasswordEntry saved = mPasswordManagerHandler.getSavedPasswordEntry(i); PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity()); String url = saved.getUrl(); String name = saved.getUserName(); screen.setTitle(url); screen.setOnPreferenceClickListener(this); screen.setSummary(name); Bundle args = screen.getExtras(); args.putString(PASSWORD_LIST_NAME, name); args.putString(PASSWORD_LIST_URL, url); args.putInt(PASSWORD_LIST_ID, i); profileCategory.addPreference(screen); } }
/** * 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_general); // Add 'sending' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_sending); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_sending); // Add 'receiving' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_receiving); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_receiving); // 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("cell_size")); bindPreferenceSummaryToValue(findPreference("code_format")); bindPreferenceSummaryToValue(findPreference("scan_delay")); }