OSDN Git Service

Accessibility text contrast control
authorChris Craik <ccraik@google.com>
Wed, 16 Jul 2014 22:13:17 +0000 (15:13 -0700)
committerChris Craik <ccraik@google.com>
Thu, 17 Jul 2014 01:04:26 +0000 (18:04 -0700)
b/14624452

Change-Id: I0f6708680eb37cf8e7dc63cae56b639eaf7c8dbd

res/values/strings.xml
res/xml/accessibility_settings.xml
src/com/android/settings/accessibility/AccessibilitySettings.java

index 69eec26..8f9a44c 100644 (file)
     <string name="accessibility_global_gesture_preference_description">When this feature is turned on, you can quickly enable accessibility features in two steps:\n\nStep 1: Press and hold the power button until you hear a sound or feel a vibration.\n\nStep 2: Touch and hold two fingers until you hear audio confirmation.\n\nIf the device has multiple users, using this shortcut on the lock screen temporarily enables accessibility until the device is unlocked.</string>
     <!-- Title for the accessibility preference to enable large text. [CHAR LIMIT=35] -->
     <string name="accessibility_toggle_large_text_preference_title">Large text</string>
+    <!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
+    <string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
     <!-- Title for the accessibility preference to enable screen magnification. [CHAR LIMIT=35] -->
     <string name="accessibility_toggle_screen_magnification_preference_title">Screen magnification</string>
     <!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
index 3ce5f1b..414affa 100644 (file)
                 android:persistent="false"/>
 
         <CheckBoxPreference
+                android:key="toggle_high_text_contrast_preference"
+                android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
+                android:persistent="false"/>
+
+        <CheckBoxPreference
                 android:key="toggle_power_button_ends_call_preference"
                 android:title="@string/accessibility_power_button_ends_call_prerefence_title"
                 android:persistent="false"/>
index b116290..f035d7b 100644 (file)
@@ -78,6 +78,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
     // Preferences
     private static final String TOGGLE_LARGE_TEXT_PREFERENCE =
             "toggle_large_text_preference";
+    private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
+            "toggle_high_text_contrast_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 =
@@ -182,6 +184,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
     private PreferenceCategory mSystemsCategory;
 
     private CheckBoxPreference mToggleLargeTextPreference;
+    private CheckBoxPreference mToggleHighTextContrastPreference;
     private CheckBoxPreference mTogglePowerButtonEndsCallPreference;
     private CheckBoxPreference mToggleLockScreenRotationPreference;
     private CheckBoxPreference mToggleSpeakPasswordPreference;
@@ -246,6 +249,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         if (mToggleLargeTextPreference == preference) {
             handleToggleLargeTextPreferenceClick();
             return true;
+        } else if (mToggleHighTextContrastPreference == preference) {
+            handleToggleTextContrastPreferenceClick();
+            return true;
         } else if (mTogglePowerButtonEndsCallPreference == preference) {
             handleTogglePowerButtonEndsCallPreferenceClick();
             return true;
@@ -274,6 +280,12 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         }
     }
 
+    private void handleToggleTextContrastPreferenceClick() {
+        Settings.Secure.putInt(getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
+                (mToggleHighTextContrastPreference.isChecked() ? 1 : 0));
+    }
+
     private void handleTogglePowerButtonEndsCallPreferenceClick() {
         Settings.Secure.putInt(getContentResolver(),
                 Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
@@ -325,6 +337,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         mToggleLargeTextPreference =
                 (CheckBoxPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE);
 
+        // Text contrast.
+        mToggleHighTextContrastPreference =
+                (CheckBoxPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
+
         // Power button ends calls.
         mTogglePowerButtonEndsCallPreference =
                 (CheckBoxPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
@@ -493,6 +509,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         }
         mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
 
+        mToggleHighTextContrastPreference.setChecked(
+                AccessibilityManager.getInstance(getActivity()).isHighTextContrastEnabled());
+
         // Power button ends calls.
         if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
                 && Utils.isVoiceCapable(getActivity())) {