diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-10-10 13:50:36 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-10-10 13:50:40 -0700 |
commit | 849d64bc1d87629b3a8979bee3e88e71d6083c42 (patch) | |
tree | 1f9450be5b0e6aec2b7baeffc552fe1d6e86dd30 /src | |
parent | 553074f0fc2aa46f44797b72f1457146697645b6 (diff) | |
download | packages_apps_settings-849d64bc1d87629b3a8979bee3e88e71d6083c42.zip packages_apps_settings-849d64bc1d87629b3a8979bee3e88e71d6083c42.tar.gz packages_apps_settings-849d64bc1d87629b3a8979bee3e88e71d6083c42.tar.bz2 |
Accessibility enabled by gesture not reflected in settings screen.
1. We have added a global gesture to enable accessibility which is long press
on power followed by a long press with two fingers. If this gesture is
performed when the settings for an accessibility service are on the screen,
accessibility and the screen-reader are enabled while the UI does not reflect
that and the user may try to enable the already enabled screen-reader which
will show two irrelevant warning dialogs - one for enabling the screen-reader
and one for enabling explore by touch (assuming the screen-reader requests it).
This change adds a simple content observer for the relevant accessibility
settings which upon a change calls the functions to refresh the settings UI.
bug:7309127
Change-Id: I214c64877086eeb1fe156bcc195aa4e2931d6bdb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/AccessibilitySettings.java | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/src/com/android/settings/AccessibilitySettings.java b/src/com/android/settings/AccessibilitySettings.java index d055345..b6556a9 100644 --- a/src/com/android/settings/AccessibilitySettings.java +++ b/src/com/android/settings/AccessibilitySettings.java @@ -23,6 +23,7 @@ import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.app.Dialog; import android.content.ComponentName; +import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -125,6 +126,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements private static final String EXTRA_DISABLE_WARNING_MESSAGE = "disable_warning_message"; private static final String EXTRA_SETTINGS_TITLE = "settings_title"; private static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_component_name"; + private static final String EXTRA_SERVICE_COMPONENT_NAME = "service_component_name"; // Dialog IDs. private static final int DIALOG_ID_NO_ACCESSIBILITY_SERVICES = 1; @@ -152,7 +154,13 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements }; private final SettingsContentObserver mSettingsContentObserver = - new SettingsContentObserver(mHandler); + new SettingsContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange, Uri uri) { + loadInstalledServices(); + updateServicesPreferences(); + } + }; private final RotationPolicy.RotationPolicyListener mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() { @@ -194,7 +202,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements offerInstallAccessibilitySerivceOnce(); mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false); - mSettingsContentObserver.register(); + mSettingsContentObserver.register(getContentResolver()); RotationPolicy.registerRotationPolicyListener(getActivity(), mRotationPolicyListener); } @@ -204,7 +212,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements mSettingsPackageMonitor.unregister(); RotationPolicy.unregisterRotationPolicyListener(getActivity(), mRotationPolicyListener); - mSettingsContentObserver.unregister(); + mSettingsContentObserver.unregister(getContentResolver()); super.onPause(); } @@ -431,6 +439,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements settingsClassName).flattenToString()); } + extras.putString(EXTRA_SERVICE_COMPONENT_NAME, componentName.flattenToString()); + mServicesCategory.addPreference(preference); } @@ -689,14 +699,39 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements private static final int DIALOG_ID_ENABLE_WARNING = 1; private static final int DIALOG_ID_DISABLE_WARNING = 2; + private final SettingsContentObserver mSettingsContentObserver = + new SettingsContentObserver(new Handler()) { + @Override + public void onChange(boolean selfChange, Uri uri) { + String settingValue = Settings.Secure.getString(getContentResolver(), + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES); + final boolean enabled = settingValue.contains(mComponentName); + mToggleSwitch.setCheckedInternal(enabled); + } + }; + private CharSequence mEnableWarningTitle; private CharSequence mEnableWarningMessage; private CharSequence mDisableWarningTitle; private CharSequence mDisableWarningMessage; + private String mComponentName; + private int mShownDialogId; @Override + public void onResume() { + mSettingsContentObserver.register(getContentResolver()); + super.onResume(); + } + + @Override + public void onPause() { + mSettingsContentObserver.unregister(getContentResolver()); + super.onPause(); + } + + @Override public void onPreferenceToggled(String preferenceKey, boolean enabled) { // Parse the enabled services. Set<ComponentName> enabledServices = getEnabledServicesFromSettings(getActivity()); @@ -851,6 +886,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements // Disable warning message. mDisableWarningMessage = arguments.getString( AccessibilitySettings.EXTRA_DISABLE_WARNING_MESSAGE); + // Component name. + mComponentName = arguments.getString(EXTRA_SERVICE_COMPONENT_NAME); } } @@ -1016,27 +1053,24 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements } } - private final class SettingsContentObserver extends ContentObserver { + private static abstract class SettingsContentObserver extends ContentObserver { public SettingsContentObserver(Handler handler) { super(handler); } - public void register() { - getContentResolver().registerContentObserver(Settings.Secure.getUriFor( + public void register(ContentResolver contentResolver) { + contentResolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.ACCESSIBILITY_ENABLED), false, this); - getContentResolver().registerContentObserver(Settings.Secure.getUriFor( + contentResolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES), false, this); } - public void unregister() { - getContentResolver().unregisterContentObserver(this); + public void unregister(ContentResolver contentResolver) { + contentResolver.unregisterContentObserver(this); } @Override - public void onChange(boolean selfChange, Uri uri) { - loadInstalledServices(); - updateServicesPreferences(); - } + public abstract void onChange(boolean selfChange, Uri uri); } } |