OSDN Git Service

Adding a system preference whether to speak passwords in accessibility mode (settings).
authorSvetoslav Ganov <svetoslavganov@google.com>
Mon, 5 Dec 2011 20:54:53 +0000 (12:54 -0800)
committerSvetoslav Ganov <svetoslavganov@google.com>
Mon, 5 Dec 2011 21:09:27 +0000 (13:09 -0800)
By default we do not speak passwords if the user has no headset. However,
many users find this too restrictive and would like a way to enable
password announcement. While we cannot speak the passwords all the time
,to avoid leaking them, we expose a preference so each user can choose
the option that best works for him/her.

bug:5712607

Change-Id: I1a6e95c392c18dc8d7406b1cef49705756b31254

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

index bca1d09..aa3b94f 100644 (file)
@@ -2760,6 +2760,8 @@ found in the list of installed apps.</string>
     <string name="accessibility_toggle_large_text_title">Large text</string>
     <!-- Title for the accessibility preference to power button to end a call. [CHAR LIMIT=35] -->
     <string name="accessibility_power_button_ends_call_title">Power button ends call</string>
+    <!-- Title for the accessibility preference to speak passwords. [CHAR LIMIT=35] -->
+    <string name="accessibility_speak_password_title">Speak passwords</string>
     <!-- Title for accessibility preference to enable touch exploration mode. [CHAR LIMIT=35] -->
     <string name="accessibility_touch_exploration_title">Explore by touch</string>
     <!-- Summary for accessibility of the touch exploration mode. [CHAR LIMIT=NONE] -->
index 45f1dce..90bdfd9 100644 (file)
                 android:persistent="false"
                 android:order="3"/>
 
+        <CheckBoxPreference
+                android:key="toggle_speak_password_preference"
+                android:title="@string/accessibility_speak_password_title"
+                android:persistent="false"
+                android:order="4"/>
+
         <PreferenceScreen
                 android:key="toggle_touch_exploration_preference"
                 android:title="@string/accessibility_touch_exploration_title"
                 android:fragment="com.android.settings.AccessibilitySettings$ToggleTouchExplorationFragment"
-                android:order="4" >
+                android:order="5" >
                 <extra android:name="title" android:value="@string/accessibility_touch_exploration_title" />
                 <extra android:name="summary" android:value="@string/accessibility_touch_exploration_summary" />
                 <extra android:name="enable_warning_title" android:value="@android:string/dialog_alert_title" />
@@ -63,7 +69,7 @@
                 android:entries="@array/long_press_timeout_selector_titles"
                 android:entryValues="@array/long_press_timeout_selector_values"
                 android:persistent="false"
-                android:order="5"/>
+                android:order="6"/>
 
         <com.android.settings.AccessibilityEnableScriptInjectionPreference
                 android:key="toggle_script_injection_preference"
@@ -74,7 +80,7 @@
                 android:positiveButtonText="@string/accessibility_script_injection_button_allow"
                 android:negativeButtonText="@string/accessibility_script_injection_button_disallow"
                 android:persistent="false"
-                android:order="6"/>
+                android:order="7"/>
 
     </PreferenceCategory>
 
index 9aabe21..827af13 100644 (file)
@@ -108,6 +108,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         "toggle_power_button_ends_call_preference";
     private static final String TOGGLE_AUTO_ROTATE_SCREEN_PREFERENCE =
         "toggle_auto_rotate_screen_preference";
+    private static final String TOGGLE_SPEAK_PASSWORD_PREFERENCE =
+        "toggle_speak_password_preference";
     private static final String TOGGLE_TOUCH_EXPLORATION_PREFERENCE =
         "toggle_touch_exploration_preference";
     private static final String SELECT_LONG_PRESS_TIMEOUT_PREFERENCE =
@@ -159,6 +161,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
     private CheckBoxPreference mToggleLargeTextPreference;
     private CheckBoxPreference mTogglePowerButtonEndsCallPreference;
     private CheckBoxPreference mToggleAutoRotateScreenPreference;
+    private CheckBoxPreference mToggleSpeakPasswordPreference;
     private Preference mToggleTouchExplorationPreference;
     private ListPreference mSelectLongPressTimeoutPreference;
     private AccessibilityEnableScriptInjectionPreference mToggleScriptInjectionPreference;
@@ -213,6 +216,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         } else if (mToggleAutoRotateScreenPreference == preference) {
             handleToggleAutoRotateScreenPreferenceClick();
             return true;
+        } else if (mToggleSpeakPasswordPreference == preference) {
+            handleToggleSpeakPasswordPreferenceClick();
         }
         return super.onPreferenceTreeClick(preferenceScreen, preference);
     }
@@ -248,6 +253,12 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         }
     }
 
+    private void handleToggleSpeakPasswordPreferenceClick() {
+        Settings.Secure.putInt(getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD,
+                mToggleSpeakPasswordPreference.isChecked() ? 1 : 0);
+    }
+
     private void initializeAllPreferences() {
         mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
         mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
@@ -268,6 +279,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
         mToggleAutoRotateScreenPreference =
             (CheckBoxPreference) findPreference(TOGGLE_AUTO_ROTATE_SCREEN_PREFERENCE);
 
+        // Speak passwords.
+        mToggleSpeakPasswordPreference =
+            (CheckBoxPreference) findPreference(TOGGLE_SPEAK_PASSWORD_PREFERENCE);
+
         // Touch exploration enabled.
         mToggleTouchExplorationPreference = findPreference(TOGGLE_TOUCH_EXPLORATION_PREFERENCE);
 
@@ -427,6 +442,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
                 Settings.System.ACCELEROMETER_ROTATION, 0) != 0;
         mToggleAutoRotateScreenPreference.setChecked(autoRotationEnabled);
 
+        // Speak passwords.
+        final boolean speakPasswordEnabled = Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
+        mToggleSpeakPasswordPreference.setChecked(speakPasswordEnabled);
+
         // Touch exploration enabled.
         if (AccessibilityManager.getInstance(getActivity()).isEnabled()) {
             mSystemsCategory.addPreference(mToggleTouchExplorationPreference);