Add a setting page for Reduce Bright Colors under A11y

This is essentially a copy page of ToggleDaltonizerPreferenceFragment.
We extend ToggleFeaturePreferenceFragment to maintain consistency with
other shortcut assignable a11y feature.

UI is a draft

This CL:
1) allows users to enabled/disable RBC with the a11y shortcut (button,
gestures, volume keys), if assigned
2) adds a slider and persist switch to the template
ToggleFeaturePreferenceFragment page (which already contains a feature
switch, shortcut preference, and footer description)
3) enables/disables the intensity slider when RBC is on/off
4) sets placeholders for calling into ColorDisplayService in
controllers and tests
5) follows convention set by other color transformations settings and
places feature under Experimental section in A11y settings page if
transformations can't be efficiently performed by hardware

Test: A11y setting and page appears, tested activation with shortcut,
preference controller tests
Bug: b/128465252

Change-Id: I291bb86ce3d855ce052ca70dc7a941a888e2c723
This commit is contained in:
Sally
2020-10-14 18:46:17 +00:00
parent ac76152a6b
commit b9ff672a31
12 changed files with 633 additions and 0 deletions

View File

@@ -97,6 +97,8 @@ public class AccessibilitySettings extends DashboardFragment {
"magnification_preference_screen";
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
"daltonizer_preference";
private static final String DISPLAY_REDUCE_BRIGHT_COLORS_PREFERENCE_SCREEN =
"reduce_bright_colors_preference";
// Extras passed to sub-fragments.
static final String EXTRA_PREFERENCE_KEY = "preference_key";
@@ -170,6 +172,8 @@ public class AccessibilitySettings extends DashboardFragment {
private Preference mDisplayMagnificationPreferenceScreen;
private Preference mDisplayDaltonizerPreferenceScreen;
private Preference mToggleInversionPreference;
private Preference mReduceBrightColorsPreference;
/**
* Check if the color transforms are color accelerated. Some transforms are experimental only
@@ -335,6 +339,10 @@ public class AccessibilitySettings extends DashboardFragment {
// Display color adjustments.
mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
// Reduce brightness.
mReduceBrightColorsPreference =
findPreference(DISPLAY_REDUCE_BRIGHT_COLORS_PREFERENCE_SCREEN);
}
private void updateAllPreferences() {
@@ -488,6 +496,7 @@ public class AccessibilitySettings extends DashboardFragment {
mCategoryToPrefCategoryMap.get(CATEGORY_DISPLAY);
experimentalCategory.removePreference(mToggleInversionPreference);
experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
experimentalCategory.removePreference(mReduceBrightColorsPreference);
mDisplayMagnificationPreferenceScreen.setSummary(
ToggleScreenMagnificationPreferenceFragment.getServiceSummary(getContext()));
mDisplayDaltonizerPreferenceScreen.setOrder(
@@ -502,8 +511,13 @@ public class AccessibilitySettings extends DashboardFragment {
mToggleLargePointerIconPreference.getOrder() + 1);
mToggleInversionPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED));
mReduceBrightColorsPreference.setOrder(
mToggleDisableAnimationsPreference.getOrder() + 1);
mReduceBrightColorsPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED));
displayCategory.addPreference(mToggleInversionPreference);
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
displayCategory.addPreference(mReduceBrightColorsPreference);
}
}