use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class TextAndDisplayFragment method updateSystemPreferences.
/**
* Updates preferences related to system configurations.
*/
private void updateSystemPreferences() {
final PreferenceCategory experimentalCategory = getPreferenceScreen().findPreference(CATEGORY_EXPERIMENTAL);
if (ColorDisplayManager.isColorTransformAccelerated(getContext())) {
mDisplayDaltonizerPreferenceScreen.setSummary(AccessibilityUtil.getSummary(getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED));
getPreferenceScreen().removePreference(experimentalCategory);
} else {
// Move following preferences to experimental category if device don't supports HWC
// hardware-accelerated color transform.
getPreferenceScreen().removePreference(mDisplayDaltonizerPreferenceScreen);
getPreferenceScreen().removePreference(mToggleDisableAnimationsPreference);
getPreferenceScreen().removePreference(mToggleLargePointerIconPreference);
experimentalCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
experimentalCategory.addPreference(mToggleDisableAnimationsPreference);
experimentalCategory.addPreference(mToggleLargePointerIconPreference);
}
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class AccessibilityShortcutPreferenceFragment method initGeneralCategory.
@VisibleForTesting
void initGeneralCategory() {
final PreferenceCategory generalCategory = new PreferenceCategory(getPrefContext());
generalCategory.setKey(KEY_GENERAL_CATEGORY);
generalCategory.setTitle(getGeneralCategoryDescription(null));
getPreferenceScreen().addPreference(generalCategory);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class AccessibilitySettings method updatePreferenceCategoryVisibility.
/**
* Updates the visibility of a category according to its child preference count.
*
* @param categoryKey The key of the category which needs to check
*/
private void updatePreferenceCategoryVisibility(String categoryKey) {
final PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
category.setVisible(category.getPreferenceCount() != 0);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class AccessibilitySettings method updateServicePreferences.
protected void updateServicePreferences() {
// Since services category is auto generated we have to do a pass
// to generate it since services can come and go and then based on
// the global accessibility state to decided whether it is enabled.
final ArrayList<Preference> servicePreferences = new ArrayList<>(mServicePreferenceToPreferenceCategoryMap.keySet());
for (int i = 0; i < servicePreferences.size(); i++) {
Preference service = servicePreferences.get(i);
PreferenceCategory category = mServicePreferenceToPreferenceCategoryMap.get(service);
category.removePreference(service);
}
initializePreBundledServicesMapFromArray(CATEGORY_SCREEN_READER, R.array.config_preinstalled_screen_reader_services);
initializePreBundledServicesMapFromArray(CATEGORY_CAPTIONS, R.array.config_preinstalled_captions_services);
initializePreBundledServicesMapFromArray(CATEGORY_AUDIO, R.array.config_preinstalled_audio_services);
initializePreBundledServicesMapFromArray(CATEGORY_DISPLAY, R.array.config_preinstalled_display_services);
initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL, R.array.config_preinstalled_interaction_control_services);
final List<RestrictedPreference> preferenceList = getInstalledAccessibilityList(getPrefContext());
final PreferenceCategory downloadedServicesCategory = mCategoryToPrefCategoryMap.get(CATEGORY_DOWNLOADED_SERVICES);
for (int i = 0, count = preferenceList.size(); i < count; ++i) {
final RestrictedPreference preference = preferenceList.get(i);
final ComponentName componentName = preference.getExtras().getParcelable(EXTRA_COMPONENT_NAME);
PreferenceCategory prefCategory = downloadedServicesCategory;
// Set the appropriate category if the service comes pre-installed.
if (mPreBundledServiceComponentToCategoryMap.containsKey(componentName)) {
prefCategory = mPreBundledServiceComponentToCategoryMap.get(componentName);
}
prefCategory.addPreference(preference);
mServicePreferenceToPreferenceCategoryMap.put(preference, prefCategory);
}
// Update the order of all the category according to the order defined in xml file.
updateCategoryOrderFromArray(CATEGORY_SCREEN_READER, R.array.config_order_screen_reader_services);
updateCategoryOrderFromArray(CATEGORY_CAPTIONS, R.array.config_order_captions_services);
updateCategoryOrderFromArray(CATEGORY_AUDIO, R.array.config_order_audio_services);
updateCategoryOrderFromArray(CATEGORY_INTERACTION_CONTROL, R.array.config_order_interaction_control_services);
updateCategoryOrderFromArray(CATEGORY_DISPLAY, R.array.config_order_display_services);
// Need to check each time when updateServicePreferences() called.
if (downloadedServicesCategory.getPreferenceCount() == 0) {
getPreferenceScreen().removePreference(downloadedServicesCategory);
} else {
getPreferenceScreen().addPreference(downloadedServicesCategory);
}
// Hide screen reader category if it is empty.
updatePreferenceCategoryVisibility(CATEGORY_SCREEN_READER);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class ChannelListPreferenceController method updateGroupList.
private void updateGroupList(@NonNull PreferenceCategory groupPrefsList, @NonNull List<NotificationChannelGroup> channelGroups) {
// Update the list, but optimize for the most common case where the list hasn't changed.
int numFinalGroups = channelGroups.size();
int initialPrefCount = groupPrefsList.getPreferenceCount();
List<PreferenceCategory> finalOrderedGroups = new ArrayList<>(numFinalGroups);
for (int i = 0; i < numFinalGroups; i++) {
NotificationChannelGroup group = channelGroups.get(i);
PreferenceCategory groupCategory = findOrCreateGroupCategoryForKey(groupPrefsList, group.getId(), i);
finalOrderedGroups.add(groupCategory);
updateGroupPreferences(group, groupCategory);
}
int postAddPrefCount = groupPrefsList.getPreferenceCount();
// If any groups were inserted (into a non-empty list) or need to be removed, we need to
// remove all groups and re-add them all.
// This is required to ensure proper ordering of inserted groups, and it simplifies logic
// at the cost of computation in the rare case that the list is changing.
boolean hasInsertions = initialPrefCount != 0 && initialPrefCount != numFinalGroups;
boolean requiresRemoval = postAddPrefCount != numFinalGroups;
if (hasInsertions || requiresRemoval) {
groupPrefsList.removeAll();
for (PreferenceCategory group : finalOrderedGroups) {
groupPrefsList.addPreference(group);
}
}
}
Aggregations