Loading res/values/bools.xml +6 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,12 @@ <!-- Whether default_home should be shown or not. --> <bool name="config_show_default_home">true</bool> <!-- Whether color correction preference should be shown or not. --> <bool name="config_show_color_correction_preference">true</bool> <!-- Whether color inversion preference should be shown or not. --> <bool name="config_show_color_inversion_preference">true</bool> <!-- Whether accessibility shortcut preference should be shown or not. --> <bool name="config_show_accessibility_shortcut_preference">true</bool> Loading src/com/android/settings/accessibility/AccessibilitySettings.java +20 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements // Preferences private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE = "toggle_high_text_contrast_preference"; private static final String TOGGLE_INVERSION_PREFERENCE = "toggle_inversion_preference"; private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE = "toggle_power_button_ends_call_preference"; private static final String TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE = Loading @@ -113,9 +111,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements "tts_settings_preference"; private static final String AUTOCLICK_PREFERENCE_SCREEN = "autoclick_preference_screen"; private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN = "daltonizer_preference_screen"; @VisibleForTesting static final String TOGGLE_INVERSION_PREFERENCE = "toggle_inversion_preference"; @VisibleForTesting static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN = "daltonizer_preference_screen"; @VisibleForTesting static final String ACCESSIBILITY_SHORTCUT_PREFERENCE = "accessibility_shortcut_preference"; Loading Loading @@ -619,6 +619,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements displayCategory.addPreference(mToggleInversionPreference); displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen); } checkColorCorrectionVisibility(mDisplayDaltonizerPreferenceScreen); checkColorInversionVisibility(mToggleInversionPreference); // Text contrast. mToggleHighTextContrastPreference.setChecked( Loading Loading @@ -769,6 +771,20 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements } } @VisibleForTesting void checkColorCorrectionVisibility(Preference preference) { if (!getContext().getResources().getBoolean( R.bool.config_show_color_correction_preference)) { removePreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN); } } @VisibleForTesting void checkColorInversionVisibility(Preference preference) { if (!getContext().getResources().getBoolean( R.bool.config_show_color_inversion_preference)) { removePreference(TOGGLE_INVERSION_PREFERENCE); } } @VisibleForTesting void checkAccessibilityShortcutVisibility(Preference preference) { if (!getContext().getResources().getBoolean( R.bool.config_show_accessibility_shortcut_preference)) { Loading tests/robotests/res/values-mcc999/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,6 @@ <bool name="config_show_tts_settings_summary">false</bool> <bool name="config_show_pointer_speed">false</bool> <bool name="config_show_vibrate_input_devices">false</bool> <bool name="config_show_color_correction_preference">false</bool> <bool name="config_show_color_inversion_preference">false</bool> </resources> tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java +45 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ public class AccessibilitySettingsTest { private Context mContext; private AccessibilitySettings mFragment; private boolean mAccessibilityShortcutPreferenceRemoved; private boolean mColorInversionPreferenceRemoved; private boolean mColorCorrectionPreferenceRemoved; @Before public void setUp() { Loading @@ -60,7 +62,16 @@ public class AccessibilitySettingsTest { protected boolean removePreference(String key) { if (AccessibilitySettings.ACCESSIBILITY_SHORTCUT_PREFERENCE.equals(key)) { mAccessibilityShortcutPreferenceRemoved = true; return true; } if (AccessibilitySettings.TOGGLE_INVERSION_PREFERENCE.equals(key)) { mColorInversionPreferenceRemoved = true; return true; } if (AccessibilitySettings.DISPLAY_DALTONIZER_PREFERENCE_SCREEN.equals(key)) { mColorCorrectionPreferenceRemoved = true; return true; } return false; Loading Loading @@ -104,4 +115,38 @@ public class AccessibilitySettingsTest { assertThat(niks).contains(AccessibilitySettings.ACCESSIBILITY_SHORTCUT_PREFERENCE); } @Test public void testColorInversionPreference_byDefault_shouldBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorInversionVisibility(preference); assertThat(mColorInversionPreferenceRemoved).isEqualTo(false); } @Test @Config(qualifiers = "mcc999") public void testColorInversionPreference_ifDisabled_shouldNotBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorInversionVisibility(preference); assertThat(mColorInversionPreferenceRemoved).isEqualTo(true); } @Test public void testColorCorrectionPreference_byDefault_shouldBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorCorrectionVisibility(preference); assertThat(mColorCorrectionPreferenceRemoved).isEqualTo(false); } @Test @Config(qualifiers = "mcc999") public void testColorCorrectionPreference_ifDisabled_shouldNotBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorCorrectionVisibility(preference); assertThat(mColorCorrectionPreferenceRemoved).isEqualTo(true); } } Loading
res/values/bools.xml +6 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,12 @@ <!-- Whether default_home should be shown or not. --> <bool name="config_show_default_home">true</bool> <!-- Whether color correction preference should be shown or not. --> <bool name="config_show_color_correction_preference">true</bool> <!-- Whether color inversion preference should be shown or not. --> <bool name="config_show_color_inversion_preference">true</bool> <!-- Whether accessibility shortcut preference should be shown or not. --> <bool name="config_show_accessibility_shortcut_preference">true</bool> Loading
src/com/android/settings/accessibility/AccessibilitySettings.java +20 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements // Preferences private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE = "toggle_high_text_contrast_preference"; private static final String TOGGLE_INVERSION_PREFERENCE = "toggle_inversion_preference"; private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE = "toggle_power_button_ends_call_preference"; private static final String TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE = Loading @@ -113,9 +111,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements "tts_settings_preference"; private static final String AUTOCLICK_PREFERENCE_SCREEN = "autoclick_preference_screen"; private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN = "daltonizer_preference_screen"; @VisibleForTesting static final String TOGGLE_INVERSION_PREFERENCE = "toggle_inversion_preference"; @VisibleForTesting static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN = "daltonizer_preference_screen"; @VisibleForTesting static final String ACCESSIBILITY_SHORTCUT_PREFERENCE = "accessibility_shortcut_preference"; Loading Loading @@ -619,6 +619,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements displayCategory.addPreference(mToggleInversionPreference); displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen); } checkColorCorrectionVisibility(mDisplayDaltonizerPreferenceScreen); checkColorInversionVisibility(mToggleInversionPreference); // Text contrast. mToggleHighTextContrastPreference.setChecked( Loading Loading @@ -769,6 +771,20 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements } } @VisibleForTesting void checkColorCorrectionVisibility(Preference preference) { if (!getContext().getResources().getBoolean( R.bool.config_show_color_correction_preference)) { removePreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN); } } @VisibleForTesting void checkColorInversionVisibility(Preference preference) { if (!getContext().getResources().getBoolean( R.bool.config_show_color_inversion_preference)) { removePreference(TOGGLE_INVERSION_PREFERENCE); } } @VisibleForTesting void checkAccessibilityShortcutVisibility(Preference preference) { if (!getContext().getResources().getBoolean( R.bool.config_show_accessibility_shortcut_preference)) { Loading
tests/robotests/res/values-mcc999/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,6 @@ <bool name="config_show_tts_settings_summary">false</bool> <bool name="config_show_pointer_speed">false</bool> <bool name="config_show_vibrate_input_devices">false</bool> <bool name="config_show_color_correction_preference">false</bool> <bool name="config_show_color_inversion_preference">false</bool> </resources>
tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java +45 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ public class AccessibilitySettingsTest { private Context mContext; private AccessibilitySettings mFragment; private boolean mAccessibilityShortcutPreferenceRemoved; private boolean mColorInversionPreferenceRemoved; private boolean mColorCorrectionPreferenceRemoved; @Before public void setUp() { Loading @@ -60,7 +62,16 @@ public class AccessibilitySettingsTest { protected boolean removePreference(String key) { if (AccessibilitySettings.ACCESSIBILITY_SHORTCUT_PREFERENCE.equals(key)) { mAccessibilityShortcutPreferenceRemoved = true; return true; } if (AccessibilitySettings.TOGGLE_INVERSION_PREFERENCE.equals(key)) { mColorInversionPreferenceRemoved = true; return true; } if (AccessibilitySettings.DISPLAY_DALTONIZER_PREFERENCE_SCREEN.equals(key)) { mColorCorrectionPreferenceRemoved = true; return true; } return false; Loading Loading @@ -104,4 +115,38 @@ public class AccessibilitySettingsTest { assertThat(niks).contains(AccessibilitySettings.ACCESSIBILITY_SHORTCUT_PREFERENCE); } @Test public void testColorInversionPreference_byDefault_shouldBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorInversionVisibility(preference); assertThat(mColorInversionPreferenceRemoved).isEqualTo(false); } @Test @Config(qualifiers = "mcc999") public void testColorInversionPreference_ifDisabled_shouldNotBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorInversionVisibility(preference); assertThat(mColorInversionPreferenceRemoved).isEqualTo(true); } @Test public void testColorCorrectionPreference_byDefault_shouldBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorCorrectionVisibility(preference); assertThat(mColorCorrectionPreferenceRemoved).isEqualTo(false); } @Test @Config(qualifiers = "mcc999") public void testColorCorrectionPreference_ifDisabled_shouldNotBeShown() { final Preference preference = new Preference(mContext); mFragment.checkColorCorrectionVisibility(preference); assertThat(mColorCorrectionPreferenceRemoved).isEqualTo(true); } }