Java Code Examples for android.preference.PreferenceScreen#getPreferenceCount()
The following examples show how to use
android.preference.PreferenceScreen#getPreferenceCount() .
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: CameraSettingsActivity.java From Camera2 with Apache License 2.0 | 6 votes |
private PreferenceScreen findByKey(PreferenceScreen parent, String key) { if (key.equals(parent.getKey())) { return parent; } else { for (int i = 0; i < parent.getPreferenceCount(); i++) { Preference child = parent.getPreference(i); if (child instanceof PreferenceScreen) { PreferenceScreen match = findByKey((PreferenceScreen) child, key); if (match != null) { return match; } } } return null; } }
Example 2
Source File: PreferenceCompatFragment.java From Audinaut with GNU General Public License v3.0 | 6 votes |
private PreferenceScreen addPreferencesFromResource(int resId) { requirePreferenceManager(); PreferenceScreen screen = inflateFromResource(getActivity(), resId, getPreferenceScreen()); setPreferenceScreen(screen); for (int i = 0; i < screen.getPreferenceCount(); i++) { Preference preference = screen.getPreference(i); if (preference instanceof PreferenceScreen && preference.getKey() != null) { preference.setOnPreferenceClickListener(preference1 -> { onStartNewFragment(preference1.getKey()); return false; }); } } return screen; }
Example 3
Source File: Settings.java From trekarta with GNU General Public License v3.0 | 6 votes |
@Override public void onResume() { super.onResume(); PreferenceScreen preferenceScreen = getPreferenceScreen(); for (int i = 0; i < preferenceScreen.getPreferenceCount(); i++) { Preference preference = preferenceScreen.getPreference(i); if (preference instanceof PreferenceGroup) { PreferenceGroup preferenceGroup = (PreferenceGroup) preference; for (int j = 0; j < preferenceGroup.getPreferenceCount(); j++) { Preference subPref = preferenceGroup.getPreference(j); updatePreference(subPref, subPref.getKey()); } } else { updatePreference(preference, preference.getKey()); } } }
Example 4
Source File: SettingsFragment.java From NoiseCapture with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); PreferenceScreen preferenceScreen = getPreferenceScreen(); SharedPreferenceListener sharedPreferenceListener = new SharedPreferenceListener(); for(int idPreference = 0; idPreference < preferenceScreen.getPreferenceCount(); idPreference++) { Preference preference = preferenceScreen.getPreference(idPreference); if(preference instanceof PreferenceGroup) { PreferenceGroup preferenceGroup = (PreferenceGroup)preference; for(int IdGroupReference = 0; IdGroupReference < preferenceGroup.getPreferenceCount(); IdGroupReference++) { preference = preferenceGroup.getPreference(IdGroupReference); preference.setOnPreferenceChangeListener(sharedPreferenceListener); } } else { preference.setOnPreferenceChangeListener(sharedPreferenceListener); } } }
Example 5
Source File: SettingsFragment.java From NightWidget with GNU General Public License v2.0 | 6 votes |
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 if (p instanceof PreferenceScreen) { PreferenceScreen pSc = (PreferenceScreen) p; for (int i = 0; i < pSc.getPreferenceCount(); i++) { initSummary(pSc.getPreference(i)); } } else { updatePrefSummary(p); } }
Example 6
Source File: ThemeSettingsFragment.java From openboard with GNU General Public License v3.0 | 5 votes |
private void updateSelected() { final PreferenceScreen screen = getPreferenceScreen(); final int count = screen.getPreferenceCount(); for (int index = 0; index < count; index++) { final Preference preference = screen.getPreference(index); if (preference instanceof KeyboardThemePreference) { final KeyboardThemePreference pref = (KeyboardThemePreference)preference; final boolean selected = (mSelectedThemeId == pref.mThemeId); pref.setSelected(selected); } } }
Example 7
Source File: ThemeSettingsFragment.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 5 votes |
private void updateSelected() { final PreferenceScreen screen = getPreferenceScreen(); final int count = screen.getPreferenceCount(); for (int index = 0; index < count; index++) { final Preference preference = screen.getPreference(index); if (preference instanceof KeyboardThemePreference) { final KeyboardThemePreference pref = (KeyboardThemePreference)preference; final boolean selected = (mSelectedThemeId == pref.mThemeId); pref.setSelected(selected); } } }
Example 8
Source File: ThemeSettingsFragment.java From simple-keyboard with Apache License 2.0 | 5 votes |
private void updateSelected() { final PreferenceScreen screen = getPreferenceScreen(); final int count = screen.getPreferenceCount(); for (int index = 0; index < count; index++) { final Preference preference = screen.getPreference(index); if (preference instanceof KeyboardThemePreference) { final KeyboardThemePreference pref = (KeyboardThemePreference)preference; final boolean selected = (mSelectedThemeId == pref.mThemeId); pref.setSelected(selected); } } }
Example 9
Source File: ThemeSettingsFragment.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
private void updateSelected() { final PreferenceScreen screen = getPreferenceScreen(); final int count = screen.getPreferenceCount(); for (int index = 0; index < count; index++) { final Preference preference = screen.getPreference(index); if (preference instanceof KeyboardThemePreference) { final KeyboardThemePreference pref = (KeyboardThemePreference)preference; final boolean selected = (mSelectedThemeId == pref.mThemeId); pref.setSelected(selected); } } }
Example 10
Source File: SettingsFragment.java From 600SeriesAndroidUploader with MIT License | 5 votes |
private void initSummary(Preference p) { if (p instanceof PreferenceScreen) { PreferenceScreen pScr = (PreferenceScreen) p; for (int i = 0; i < pScr.getPreferenceCount(); i++) { initSummary(pScr.getPreference(i)); } } else if (p instanceof PreferenceCategory) { PreferenceCategory pCat = (PreferenceCategory) p; for (int i = 0; i < pCat.getPreferenceCount(); i++) { initSummary(pCat.getPreference(i)); } } else { updatePrefSummary(p); } }
Example 11
Source File: SettingsFragment.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
public void updatePreferenceScreen(PreferenceScreen screen) { for (int i = 0; i < screen.getPreferenceCount(); ++i) { Preference preference = screen.getPreference(i); if (preference instanceof PreferenceGroup) { PreferenceGroup preferenceGroup = (PreferenceGroup) preference; for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) { Preference singlePref = preferenceGroup.getPreference(j); updatePreference(singlePref, singlePref.getKey()); } } else { updatePreference(preference, preference.getKey()); } } }
Example 12
Source File: ThemeSettingsFragment.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
private void updateSelected() { final PreferenceScreen screen = getPreferenceScreen(); final int count = screen.getPreferenceCount(); for (int index = 0; index < count; index++) { final Preference preference = screen.getPreference(index); if (preference instanceof KeyboardThemePreference) { final KeyboardThemePreference pref = (KeyboardThemePreference)preference; final boolean selected = (mSelectedThemeId == pref.mThemeId); pref.setSelected(selected); } } }
Example 13
Source File: SettingsActivity.java From syncthing-android with Mozilla Public License 2.0 | 5 votes |
private void setPreferenceCategoryChangeListener( Preference category, Preference.OnPreferenceChangeListener listener) { PreferenceScreen ps = (PreferenceScreen) category; for (int i = 0; i < ps.getPreferenceCount(); i++) { Preference p = ps.getPreference(i); p.setOnPreferenceChangeListener(listener); } }
Example 14
Source File: Preferences.java From Androzic with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); Bundle arguments = getArguments(); if (arguments == null) return; String resource = arguments.getString("resource"); if (resource != null) { int res = getActivity().getResources().getIdentifier(resource, "xml", getActivity().getPackageName()); addPreferencesFromResource(res); } if (arguments.getBoolean("disable", false)) { PreferenceScreen screen = getPreferenceScreen(); for (int i = 0; i < screen.getPreferenceCount(); i++) { getPreferenceScreen().getPreference(i).setEnabled(false); } } help = arguments.getInt("help", 0); }
Example 15
Source File: XmlSettingsActivity.java From WhereYouGo with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.settings); needRestart = false; /* workaround: I don't really know why I cannot call CustomActivity.customOnCreate(this); - OMG! */ switch (Preferences.APPEARANCE_FONT_SIZE) { case PreferenceValues.VALUE_FONT_SIZE_SMALL: this.setTheme(R.style.FontSizeSmall); break; case PreferenceValues.VALUE_FONT_SIZE_MEDIUM: this.setTheme(R.style.FontSizeMedium); break; case PreferenceValues.VALUE_FONT_SIZE_LARGE: this.setTheme(R.style.FontSizeLarge); break; } /* * */ addPreferencesFromResource(R.xml.whereyougo_preferences); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); /* * Remove internal preferences */ Preference somePreference = findPreference(R.string.pref_KEY_X_HIDDEN_PREFERENCES); PreferenceScreen preferenceScreen = getPreferenceScreen(); preferenceScreen.removePreference(somePreference); /* * Register OnClick handler */ Preference preferenceRoot = findPreference(R.string.pref_KEY_S_ROOT); preferenceRoot.setOnPreferenceClickListener(this); Preference preferenceAbout = findPreference(R.string.pref_KEY_X_ABOUT); if (preferenceAbout != null) { preferenceAbout.setOnPreferenceClickListener(this); } /* * Workaround: Update/set value preview */ // String dir = Preferences.getStringPreference( R.string.pref_KEY_S_ROOT ); // x.setSummary( "(" + dir + ") " + Locale.getString( R.string.pref_root_desc ) ); // TODO make it better :-( /* TODO - check this code */ if (!Utils.isAndroid201OrMore()) { Preference prefSensorFilter = findPreference(R.string.pref_KEY_S_SENSORS_ORIENT_FILTER); if (prefSensorFilter != null) { prefSensorFilter.setEnabled(false); } } if (getIntent() != null && getIntent().hasExtra(getString(R.string.pref_KEY_X_LOGIN_PREFERENCES))) { Preference preferenceLogin = findPreference(R.string.pref_KEY_X_LOGIN_PREFERENCES); if (preferenceLogin != null) { PreferenceScreen screen = getPreferenceScreen(); for (int i = 0; i < screen.getPreferenceCount(); ++i) { if (screen.getPreference(i) == preferenceLogin) { getIntent().putExtra(getString(R.string.pref_KEY_X_LOGIN_PREFERENCES), false); screen.onItemClick(null, null, i, 0); break; } } } } /* * Enable/disable status bar propertie */ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { CheckBoxPreference status_bar = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_STATUSBAR); CheckBoxPreference gps_hide = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_GPS_DISABLE_WHEN_HIDE); CheckBoxPreference gps_guiding = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_GUIDING_GPS_REQUIRED); if (gps_hide.isChecked()) { status_bar.setEnabled(!gps_guiding.isChecked()); } else { status_bar.setEnabled(false); } } }