androidx.preference.PreferenceGroup Java Examples
The following examples show how to use
androidx.preference.PreferenceGroup.
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: AppCompatPreferenceActivity.java From onpc with GNU General Public License v3.0 | 6 votes |
static void tintIcons(final Context c, Preference preference) { if (preference instanceof PreferenceGroup) { PreferenceGroup group = ((PreferenceGroup) preference); Utils.setDrawableColorAttr(c, group.getIcon(), android.R.attr.textColorSecondary); for (int i = 0; i < group.getPreferenceCount(); i++) { tintIcons(c, group.getPreference(i)); } } else { Utils.setDrawableColorAttr(c, preference.getIcon(), android.R.attr.textColorSecondary); } }
Example #2
Source File: TalkBackVerbosityPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** Collects all preset-controlled preferences. */ private ArrayList<Preference> collectDetailedPreferences() { ArrayList<Preference> detailedPrefs = new ArrayList<Preference>(); PreferenceGroup prefGroup = (PreferenceGroup) findPreference(R.string.pref_verbosity_category_preset_settings_key); if (prefGroup == null) { return detailedPrefs; } // For each preference... collect for (int p = 0; p < prefGroup.getPreferenceCount(); p++) { Preference preference = prefGroup.getPreference(p); if (preference != null) { detailedPrefs.add(preference); } } return detailedPrefs; }
Example #3
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** * Checks if the device is Android TV and removes preferences that shouldn't be set when on * Android TV. */ private void checkTelevision() { if (FeatureSupport.isTv(getActivity())) { final PreferenceGroup touchCategory = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_touch_exploration_key); final PreferenceGroup miscCategory = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_miscellaneous_key); final Preference dimShortcutPreference = findPreferenceByResId(R.string.pref_dim_volume_three_clicks_key); final Preference suspendShortcutPreference = findPreferenceByResId(R.string.pref_two_volume_long_press_key); final Preference resumePreference = findPreferenceByResId(R.string.pref_resume_talkback_key); getPreferenceScreen().removePreference(touchCategory); miscCategory.removePreference(dimShortcutPreference); miscCategory.removePreference(suspendShortcutPreference); miscCategory.removePreference(resumePreference); } }
Example #4
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** * Ensure that the proximity sensor setting does not appear on devices without a proximity * sensor. */ private void checkProximitySupport() { Activity activity = getActivity(); if (activity == null) { return; } final SensorManager manager = (SensorManager) activity.getSystemService(SENSOR_SERVICE); final Sensor proximity = manager.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (proximity != null) { return; } final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_when_to_speak_key); final TwoStatePreference prefProximity = (TwoStatePreference) findPreferenceByResId(R.string.pref_proximity_key); if (prefProximity != null) { prefProximity.setChecked(false); category.removePreference(prefProximity); } }
Example #5
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** Ensure that the vibration setting does not appear on devices without a vibrator. */ private void checkVibrationSupport() { Activity activity = getActivity(); if (activity == null) { return; } final Vibrator vibrator = (Vibrator) activity.getSystemService(VIBRATOR_SERVICE); if (vibrator != null && vibrator.hasVibrator()) { return; } final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_feedback_key); final TwoStatePreference prefVibration = (TwoStatePreference) findPreferenceByResId(R.string.pref_vibration_key); if (prefVibration != null) { prefVibration.setChecked(false); category.removePreference(prefVibration); } }
Example #6
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** * Since the "%s" summary is currently broken, this sets the preference change listener for all * {@link ListPreference} views to fill in the summary with the current entry value. */ private void fixListSummaries(PreferenceGroup group) { if (group == null) { return; } final int count = group.getPreferenceCount(); for (int i = 0; i < count; i++) { final Preference preference = group.getPreference(i); if (preference instanceof PreferenceGroup) { fixListSummaries((PreferenceGroup) preference); } else if (preference instanceof ListPreference) { // First make sure the current summary is correct, then set the // listener. This is necessary for summaries to show correctly // on SDKs < 14. preferenceChangeListener.onPreferenceChange( preference, ((ListPreference) preference).getValue()); preference.setOnPreferenceChangeListener(preferenceChangeListener); } } }
Example #7
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
private void updateDimingPreferenceStatus() { // Log an error if the device supports volume key shortcuts (i.e. those running Android N or // earlier) but the dim screen shortcut switch is not available. Don't exit the function // because we still want to set up the other switch. final TwoStatePreference dimShortcutPreference = (TwoStatePreference) findPreferenceByResId(R.string.pref_dim_volume_three_clicks_key); if (FeatureSupport.supportsVolumeKeyShortcuts() && dimShortcutPreference == null) { LogUtils.e(TAG, "Expected switch for dim screen shortcut, but switch is not present."); } final TalkBackService talkBack = TalkBackService.getInstance(); if (talkBack == null || !DimScreenControllerApp.isSupportedbyPlatform(talkBack)) { LogUtils.i( TAG, "Either TalkBack could not be found, or the platform does not support screen dimming."); final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_miscellaneous_key); if (category == null) { return; } if (dimShortcutPreference != null) { category.removePreference(dimShortcutPreference); } return; } }
Example #8
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** Assigns the appropriate intent to the tutorial preference. */ private void assignTutorialIntent() { final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_miscellaneous_key); final Preference prefTutorial = findPreferenceByResId(R.string.pref_tutorial_key); if ((category == null) || (prefTutorial == null)) { return; } final int touchscreenState = getResources().getConfiguration().touchscreen; if (touchscreenState == Configuration.TOUCHSCREEN_NOTOUCH) { category.removePreference(prefTutorial); return; } Activity activity = getActivity(); if (activity != null) { final Intent tutorialIntent = new Intent(activity, AccessibilityTutorialActivity.class); tutorialIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); tutorialIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); tutorialIntent.putExtra(TalkBackService.EXTRA_TUTORIAL_INTENT_SOURCE, TUTORIAL_SRC); prefTutorial.setIntent(tutorialIntent); } }
Example #9
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 6 votes |
/** Assigns the intent to open text-to-speech settings. */ private void assignTtsSettingsIntent() { PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_when_to_speak_key); Preference ttsSettingsPreference = findPreferenceByResId(R.string.pref_tts_settings_key); if (category == null || ttsSettingsPreference == null) { return; } Intent ttsSettingsIntent = new Intent(TalkBackService.INTENT_TTS_SETTINGS); ttsSettingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (!canHandleIntent(ttsSettingsIntent)) { // Need to remove preference item if no TTS Settings intent filter in settings app. category.removePreference(ttsSettingsPreference); } ttsSettingsPreference.setIntent(ttsSettingsIntent); }
Example #10
Source File: PreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 6 votes |
/** * Restores the default preferences, which are contained by a specific preference group. * * @param preferenceGroup * The preference group, whose preferences should be restored, as an instance of the * class {@link PreferenceGroup}. The preference group may not be null * @param sharedPreferences * The shared preferences, which should be used to restore the preferences, as an * instance of the type {@link SharedPreferences}. The shared preferences may not be * null */ private void restoreDefaults(@NonNull final PreferenceGroup preferenceGroup, @NonNull final SharedPreferences sharedPreferences) { for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) { Preference preference = preferenceGroup.getPreference(i); if (preference instanceof PreferenceGroup) { restoreDefaults((PreferenceGroup) preference, sharedPreferences); } else if (preference.getKey() != null && !preference.getKey().isEmpty()) { Object oldValue = sharedPreferences.getAll().get(preference.getKey()); if (notifyOnRestoreDefaultValueRequested(preference, oldValue)) { sharedPreferences.edit().remove(preference.getKey()).apply(); preferenceGroup.removePreference(preference); preferenceGroup.addPreference(preference); Object newValue = sharedPreferences.getAll().get(preference.getKey()); notifyOnRestoredDefaultValue(preference, oldValue, newValue); } else { preferenceGroup.removePreference(preference); preferenceGroup.addPreference(preference); } } } }
Example #11
Source File: PreferenceSettingsUtils.java From talkback with Apache License 2.0 | 5 votes |
private static void hidePreferences(PreferenceGroup root, Set<String> preferenceKeysToBeHidden) { for (int i = 0; i < root.getPreferenceCount(); i++) { Preference preference = root.getPreference(i); if (preferenceKeysToBeHidden.contains(preference.getKey())) { root.removePreference(preference); i--; } else if (preference instanceof PreferenceGroup) { hidePreferences((PreferenceGroup) preference, preferenceKeysToBeHidden); } } }
Example #12
Source File: PreferenceSettingsUtils.java From talkback with Apache License 2.0 | 5 votes |
/** * Given an array of resource ids corresponding to the actual String keys for TalkBack * preferences, hide the preferences. This will also be done recursively form the root * PreferenceGroup. */ public static void hidePreferences( final Context context, PreferenceGroup root, int[] prefKeyIds) { if (context == null) { return; } Set<String> hiddenPreferenceKeys = new HashSet<>(); for (int hiddenPreferenceKeyId : prefKeyIds) { hiddenPreferenceKeys.add(context.getString(hiddenPreferenceKeyId)); } hidePreferences(root, hiddenPreferenceKeys); }
Example #13
Source File: AbstractPreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Returns, whether a divider should be drawn above a view, or not. * * @param view * The view, which should be checked, as an instance of the class {@link View}. The * view may not be null * @param recyclerView * The recycler view, the given view belongs to, as an instance of the class {@link * RecyclerView}. The recycler view may not be null * @return True, if a divider should be drawn above the given view, false otherwise */ private boolean shouldDrawDividerAbove(@NonNull final View view, @NonNull final RecyclerView recyclerView) { RecyclerView.ViewHolder viewHolder = recyclerView.getChildViewHolder(view); int position = viewHolder.getAdapterPosition(); if (position > 0) { @SuppressLint("RestrictedApi") Preference preference = adapter.getItem(position); return preference instanceof PreferenceGroup; } return false; }
Example #14
Source File: SettingsActivity.java From AppOpsX with MIT License | 5 votes |
private void setAllPreferencesToAvoidHavingExtraSpace(Preference preference){ if (preference != null){ preference.setIconSpaceReserved(false); if (preference instanceof PreferenceGroup){ PreferenceGroup group = ((PreferenceGroup) preference); int count = group.getPreferenceCount(); for (int i = 0; i < count; i++){ setAllPreferencesToAvoidHavingExtraSpace(group.getPreference(i)); } } } }
Example #15
Source File: SettingsActivity.java From microMathematics with GNU General Public License v3.0 | 5 votes |
private static void tintIcons(final Context c, Preference preference) { if (preference instanceof PreferenceGroup) { PreferenceGroup group = ((PreferenceGroup) preference); for (int i = 0; i < group.getPreferenceCount(); i++) { tintIcons(c, group.getPreference(i)); } } else { CompatUtils.setDrawableColorAttr(c, preference.getIcon(), android.R.attr.textColorSecondary); } }
Example #16
Source File: SearchPreferenceResult.java From SearchPreference with MIT License | 5 votes |
private void doHighlight(final PreferenceFragmentCompat prefsFragment) { final Preference prefResult = prefsFragment.findPreference(getKey()); if (prefResult == null) { Log.e("doHighlight", "Preference not found on given screen"); return; } final RecyclerView recyclerView = prefsFragment.getListView(); final RecyclerView.Adapter<?> adapter = recyclerView.getAdapter(); if (adapter instanceof PreferenceGroup.PreferencePositionCallback) { PreferenceGroup.PreferencePositionCallback callback = (PreferenceGroup.PreferencePositionCallback) adapter; final int position = callback.getPreferenceAdapterPosition(prefResult); if (position != RecyclerView.NO_POSITION) { recyclerView.scrollToPosition(position); recyclerView.postDelayed(() -> { RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position); if (holder != null) { Drawable background = holder.itemView.getBackground(); if (Build.VERSION.SDK_INT >= 21 && background instanceof RippleDrawable) { forceRippleAnimation((RippleDrawable) background); return; } } highlightFallback(prefsFragment, prefResult); }, 200); return; } } highlightFallback(prefsFragment, prefResult); }
Example #17
Source File: AutoInputSettingsFragment.java From SmsCode with GNU General Public License v3.0 | 5 votes |
private void refreshManualFocusIfFailedPreference() { PreferenceGroup autoInputGroup = (PreferenceGroup) findPreference(ENTRY_AUTO_INPUT_CODE); if (FOCUS_MODE_AUTO.equals(mFocusMode)) { // auto-focus // show manual focus if failed preference autoInputGroup.addPreference(mManualFocusIfFailedPref); } else { // manual focus // hide manual focus if failed preference autoInputGroup.removePreference(mManualFocusIfFailedPref); } }
Example #18
Source File: BasePreferenceFragment.java From EdXposedManager with GNU General Public License v3.0 | 5 votes |
private void setAllPreferencesToAvoidHavingExtraSpace(Preference preference) { preference.setIconSpaceReserved(false); if (preference instanceof PreferenceGroup) { PreferenceGroup preferenceGroup = ((PreferenceGroup) preference); for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) { setAllPreferencesToAvoidHavingExtraSpace(preferenceGroup.getPreference(i)); } } }
Example #19
Source File: TalkBackDeveloperPreferencesActivity.java From talkback with Apache License 2.0 | 5 votes |
/** Ensure window-delay setting does not appear on devices without animation toggle. */ private void checkReducedWindowDelaySupport() { if (!FeatureSupport.disableAnimation()) { final PreferenceGroup category = (PreferenceGroup) findPreference(getString(R.string.pref_category_developer_key)); if (category != null) { PreferenceSettingsUtils.hidePreference( context, category, R.string.pref_reduce_window_delay_key); } } }
Example #20
Source File: MainPreferences.java From openScale with GNU General Public License v3.0 | 5 votes |
private static void tintIcons(Preference preference, int color) { if (preference instanceof PreferenceGroup) { PreferenceGroup group = ((PreferenceGroup) preference); for (int i = 0; i < group.getPreferenceCount(); i++) { tintIcons(group.getPreference(i), color); } } else { Drawable icon = preference.getIcon(); if (icon != null) { DrawableCompat.setTint(icon, color); } } }
Example #21
Source File: MeasurementPreferences.java From openScale with GNU General Public License v3.0 | 5 votes |
MeasurementOrderPreference(Context context, PreferenceGroup parent, MeasurementView measurementView) { super(context); parentGroup = parent; measurement = measurementView; gestureDetector = new GestureDetector(getContext(), this); gestureDetector.setIsLongpressEnabled(true); setLayoutResource(R.layout.preference_measurement_order); }
Example #22
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 4 votes |
private void removePreference(int categoryKeyId, int preferenceKeyId) { final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(categoryKeyId); if (category != null) { PreferenceSettingsUtils.hidePreference(context, category, preferenceKeyId); } }
Example #23
Source File: BaseSearchablePolicyPreferenceFragment.java From android-testdpc with Apache License 2.0 | 4 votes |
public HighlightablePreferenceGroupAdapter(PreferenceGroup preferenceGroup) { super(preferenceGroup); }
Example #24
Source File: MeasurementPreferences.java From openScale with GNU General Public License v3.0 | 4 votes |
@Override public PreferenceGroup getParent() { return parentGroup; }
Example #25
Source File: PreferenceSettingsUtils.java From talkback with Apache License 2.0 | 2 votes |
/** * Given the resource id corresponding to the actual String key for TalkBack preference, hide the * preference. This will also be done recursively form the root PreferenceGroup. */ public static void hidePreference(final Context context, PreferenceGroup root, int prefKeyId) { hidePreferences(context, root, new int[] {prefKeyId}); }