Removing explore by touch from settings.
1. Now accessibility services request this mode and we show a dialog so the user can give a consent. Accessibility servces can toggle this mode at runtime from their settings, for example. bug:5932640 Change-Id: Id4d3e9c83c488f97b7e53d4baadf7de886958a4d
This commit is contained in:
@@ -2879,11 +2879,6 @@
|
|||||||
<string name="accessibility_power_button_ends_call_title">Power button ends call</string>
|
<string name="accessibility_power_button_ends_call_title">Power button ends call</string>
|
||||||
<!-- Title for the accessibility preference to speak passwords. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference to speak passwords. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_speak_password_title">Speak passwords</string>
|
<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] -->
|
|
||||||
<string name="accessibility_touch_exploration_summary" >When Explore by Touch is turned on,
|
|
||||||
you can hear or see descriptions of what\'s under your finger.\n\n This feature is for low-vision users.</string>
|
|
||||||
<!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
|
<!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_long_press_timeout_title">Touch & hold delay</string>
|
<string name="accessibility_long_press_timeout_title">Touch & hold delay</string>
|
||||||
<!-- Title for accessibility preference to install accessibility scripts from Google. [CHAR LIMIT=35] -->
|
<!-- Title for accessibility preference to install accessibility scripts from Google. [CHAR LIMIT=35] -->
|
||||||
@@ -2952,9 +2947,6 @@
|
|||||||
<string name="accessibility_script_injection_security_warning_summary">Do you want apps to
|
<string name="accessibility_script_injection_security_warning_summary">Do you want apps to
|
||||||
install scripts from Google that make their web content more accessible?</string>
|
install scripts from Google that make their web content more accessible?</string>
|
||||||
|
|
||||||
<!-- Warning message that the interaction model changes on enabling touch exploration. [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="accessibility_touch_exploration_warning">This feature changes the
|
|
||||||
way your device responds to touch. Turn it on?</string>
|
|
||||||
<!-- Default description for an accessibility serivice if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
|
<!-- Default description for an accessibility serivice if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_service_default_description">No description provided.</string>
|
<string name="accessibility_service_default_description">No description provided.</string>
|
||||||
|
|
||||||
|
@@ -47,18 +47,6 @@
|
|||||||
android:title="@string/accessibility_speak_password_title"
|
android:title="@string/accessibility_speak_password_title"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="toggle_touch_exploration_preference"
|
|
||||||
android:title="@string/accessibility_touch_exploration_title"
|
|
||||||
android:fragment="com.android.settings.AccessibilitySettings$ToggleTouchExplorationFragment" >
|
|
||||||
<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" />
|
|
||||||
<extra android:name="enable_warning_message" android:value="@string/accessibility_touch_exploration_warning" />
|
|
||||||
<extra android:name="settings_title" android:value="@string/accessibility_menu_item_tutorial" />
|
|
||||||
<extra android:name="settings_component_name" android:value="com.android.settings/com.android.settings.AccessibilityTutorialActivity" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
<PreferenceScreen android:key="tts_settings"
|
<PreferenceScreen android:key="tts_settings"
|
||||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"
|
android:fragment="com.android.settings.tts.TextToSpeechSettings"
|
||||||
android:title="@string/tts_settings_title" />
|
android:title="@string/tts_settings_title" />
|
||||||
|
@@ -92,9 +92,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
private static final char ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR = ':';
|
private static final char ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR = ':';
|
||||||
|
|
||||||
private static final String KEY_ACCESSIBILITY_TUTORIAL_LAUNCHED_ONCE =
|
|
||||||
"key_accessibility_tutorial_launched_once";
|
|
||||||
|
|
||||||
private static final String KEY_INSTALL_ACCESSIBILITY_SERVICE_OFFERED_ONCE =
|
private static final String KEY_INSTALL_ACCESSIBILITY_SERVICE_OFFERED_ONCE =
|
||||||
"key_install_accessibility_service_offered_once";
|
"key_install_accessibility_service_offered_once";
|
||||||
|
|
||||||
@@ -110,8 +107,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
"toggle_auto_rotate_screen_preference";
|
"toggle_auto_rotate_screen_preference";
|
||||||
private static final String TOGGLE_SPEAK_PASSWORD_PREFERENCE =
|
private static final String TOGGLE_SPEAK_PASSWORD_PREFERENCE =
|
||||||
"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 =
|
private static final String SELECT_LONG_PRESS_TIMEOUT_PREFERENCE =
|
||||||
"select_long_press_timeout_preference";
|
"select_long_press_timeout_preference";
|
||||||
private static final String TOGGLE_SCRIPT_INJECTION_PREFERENCE =
|
private static final String TOGGLE_SCRIPT_INJECTION_PREFERENCE =
|
||||||
@@ -162,7 +157,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
private CheckBoxPreference mTogglePowerButtonEndsCallPreference;
|
private CheckBoxPreference mTogglePowerButtonEndsCallPreference;
|
||||||
private CheckBoxPreference mToggleAutoRotateScreenPreference;
|
private CheckBoxPreference mToggleAutoRotateScreenPreference;
|
||||||
private CheckBoxPreference mToggleSpeakPasswordPreference;
|
private CheckBoxPreference mToggleSpeakPasswordPreference;
|
||||||
private Preference mToggleTouchExplorationPreference;
|
|
||||||
private ListPreference mSelectLongPressTimeoutPreference;
|
private ListPreference mSelectLongPressTimeoutPreference;
|
||||||
private AccessibilityEnableScriptInjectionPreference mToggleScriptInjectionPreference;
|
private AccessibilityEnableScriptInjectionPreference mToggleScriptInjectionPreference;
|
||||||
private Preference mNoServicesMessagePreference;
|
private Preference mNoServicesMessagePreference;
|
||||||
@@ -283,9 +277,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
mToggleSpeakPasswordPreference =
|
mToggleSpeakPasswordPreference =
|
||||||
(CheckBoxPreference) findPreference(TOGGLE_SPEAK_PASSWORD_PREFERENCE);
|
(CheckBoxPreference) findPreference(TOGGLE_SPEAK_PASSWORD_PREFERENCE);
|
||||||
|
|
||||||
// Touch exploration enabled.
|
|
||||||
mToggleTouchExplorationPreference = findPreference(TOGGLE_TOUCH_EXPLORATION_PREFERENCE);
|
|
||||||
|
|
||||||
// Long press timeout.
|
// Long press timeout.
|
||||||
mSelectLongPressTimeoutPreference =
|
mSelectLongPressTimeoutPreference =
|
||||||
(ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
|
(ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
|
||||||
@@ -352,7 +343,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
preference.setOrder(i);
|
preference.setOrder(i);
|
||||||
preference.setFragment(ToggleAccessibilityServiceFragment.class.getName());
|
preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
|
||||||
preference.setPersistent(true);
|
preference.setPersistent(true);
|
||||||
|
|
||||||
Bundle extras = preference.getExtras();
|
Bundle extras = preference.getExtras();
|
||||||
@@ -447,25 +438,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
|
Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
|
||||||
mToggleSpeakPasswordPreference.setChecked(speakPasswordEnabled);
|
mToggleSpeakPasswordPreference.setChecked(speakPasswordEnabled);
|
||||||
|
|
||||||
// Touch exploration enabled.
|
|
||||||
if (AccessibilityManager.getInstance(getActivity()).isEnabled()) {
|
|
||||||
mSystemsCategory.addPreference(mToggleTouchExplorationPreference);
|
|
||||||
final boolean touchExplorationEnabled = (Settings.Secure.getInt(getContentResolver(),
|
|
||||||
Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1);
|
|
||||||
if (touchExplorationEnabled) {
|
|
||||||
mToggleTouchExplorationPreference.setSummary(
|
|
||||||
getString(R.string.accessibility_service_state_on));
|
|
||||||
mToggleTouchExplorationPreference.getExtras().putBoolean(EXTRA_CHECKED, true);
|
|
||||||
} else {
|
|
||||||
mToggleTouchExplorationPreference.setSummary(
|
|
||||||
getString(R.string.accessibility_service_state_off));
|
|
||||||
mToggleTouchExplorationPreference.getExtras().putBoolean(EXTRA_CHECKED, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mSystemsCategory.removePreference(mToggleTouchExplorationPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Long press timeout.
|
// Long press timeout.
|
||||||
final int longPressTimeout = Settings.Secure.getInt(getContentResolver(),
|
final int longPressTimeout = Settings.Secure.getInt(getContentResolver(),
|
||||||
Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
|
Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
|
||||||
@@ -632,79 +604,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToggleAccessibilityServiceFragment extends TogglePreferenceFragment {
|
public static class ToggleAccessibilityServicePreferenceFragment
|
||||||
@Override
|
extends SettingsPreferenceFragment implements DialogInterface.OnClickListener {
|
||||||
public void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
|
||||||
// Parse the enabled services.
|
|
||||||
Set<ComponentName> enabledServices = getEnabledServicesFromSettings(getActivity());
|
|
||||||
|
|
||||||
// Determine enabled services and accessibility state.
|
|
||||||
ComponentName toggledService = ComponentName.unflattenFromString(preferenceKey);
|
|
||||||
final boolean accessibilityEnabled;
|
|
||||||
if (enabled) {
|
|
||||||
// Enabling at least one service enables accessibility.
|
|
||||||
accessibilityEnabled = true;
|
|
||||||
enabledServices.add(toggledService);
|
|
||||||
} else {
|
|
||||||
// Check how many enabled and installed services are present.
|
|
||||||
int enabledAndInstalledServiceCount = 0;
|
|
||||||
Set<ComponentName> installedServices = sInstalledServices;
|
|
||||||
for (ComponentName enabledService : enabledServices) {
|
|
||||||
if (installedServices.contains(enabledService)) {
|
|
||||||
enabledAndInstalledServiceCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Disabling the last service disables accessibility.
|
|
||||||
accessibilityEnabled = enabledAndInstalledServiceCount > 1
|
|
||||||
|| (enabledAndInstalledServiceCount == 1
|
|
||||||
&& !installedServices.contains(toggledService));
|
|
||||||
enabledServices.remove(toggledService);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the enabled services setting.
|
|
||||||
StringBuilder enabledServicesBuilder = new StringBuilder();
|
|
||||||
// Keep the enabled services even if they are not installed since we have
|
|
||||||
// no way to know whether the application restore process has completed.
|
|
||||||
// In general the system should be responsible for the clean up not settings.
|
|
||||||
for (ComponentName enabledService : enabledServices) {
|
|
||||||
enabledServicesBuilder.append(enabledService.flattenToString());
|
|
||||||
enabledServicesBuilder.append(ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR);
|
|
||||||
}
|
|
||||||
final int enabledServicesBuilderLength = enabledServicesBuilder.length();
|
|
||||||
if (enabledServicesBuilderLength > 0) {
|
|
||||||
enabledServicesBuilder.deleteCharAt(enabledServicesBuilderLength - 1);
|
|
||||||
}
|
|
||||||
Settings.Secure.putString(getContentResolver(),
|
|
||||||
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
|
|
||||||
enabledServicesBuilder.toString());
|
|
||||||
|
|
||||||
// Update accessibility enabled.
|
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
|
||||||
Settings.Secure.ACCESSIBILITY_ENABLED, accessibilityEnabled ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ToggleTouchExplorationFragment extends TogglePreferenceFragment {
|
|
||||||
@Override
|
|
||||||
public void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
|
||||||
Settings.Secure.TOUCH_EXPLORATION_ENABLED, enabled ? 1 : 0);
|
|
||||||
if (enabled) {
|
|
||||||
SharedPreferences preferences = getActivity().getPreferences(Context.MODE_PRIVATE);
|
|
||||||
final boolean launchAccessibilityTutorial = !preferences.getBoolean(
|
|
||||||
KEY_ACCESSIBILITY_TUTORIAL_LAUNCHED_ONCE, false);
|
|
||||||
if (launchAccessibilityTutorial) {
|
|
||||||
preferences.edit().putBoolean(KEY_ACCESSIBILITY_TUTORIAL_LAUNCHED_ONCE,
|
|
||||||
true).commit();
|
|
||||||
Intent intent = new Intent(AccessibilityTutorialActivity.ACTION);
|
|
||||||
getActivity().startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract static class TogglePreferenceFragment extends SettingsPreferenceFragment
|
|
||||||
implements DialogInterface.OnClickListener {
|
|
||||||
|
|
||||||
private static final int DIALOG_ID_ENABLE_WARNING = 1;
|
private static final int DIALOG_ID_ENABLE_WARNING = 1;
|
||||||
private static final int DIALOG_ID_DISABLE_WARNING = 2;
|
private static final int DIALOG_ID_DISABLE_WARNING = 2;
|
||||||
@@ -717,6 +618,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
private CharSequence mEnableWarningMessage;
|
private CharSequence mEnableWarningMessage;
|
||||||
private CharSequence mDisableWarningTitle;
|
private CharSequence mDisableWarningTitle;
|
||||||
private CharSequence mDisableWarningMessage;
|
private CharSequence mDisableWarningMessage;
|
||||||
|
|
||||||
private Preference mSummaryPreference;
|
private Preference mSummaryPreference;
|
||||||
|
|
||||||
private CharSequence mSettingsTitle;
|
private CharSequence mSettingsTitle;
|
||||||
@@ -782,7 +684,54 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onPreferenceToggled(String preferenceKey, boolean value);
|
public void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||||
|
// Parse the enabled services.
|
||||||
|
Set<ComponentName> enabledServices = getEnabledServicesFromSettings(getActivity());
|
||||||
|
|
||||||
|
// Determine enabled services and accessibility state.
|
||||||
|
ComponentName toggledService = ComponentName.unflattenFromString(preferenceKey);
|
||||||
|
final boolean accessibilityEnabled;
|
||||||
|
if (enabled) {
|
||||||
|
// Enabling at least one service enables accessibility.
|
||||||
|
accessibilityEnabled = true;
|
||||||
|
enabledServices.add(toggledService);
|
||||||
|
} else {
|
||||||
|
// Check how many enabled and installed services are present.
|
||||||
|
int enabledAndInstalledServiceCount = 0;
|
||||||
|
Set<ComponentName> installedServices = sInstalledServices;
|
||||||
|
for (ComponentName enabledService : enabledServices) {
|
||||||
|
if (installedServices.contains(enabledService)) {
|
||||||
|
enabledAndInstalledServiceCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Disabling the last service disables accessibility.
|
||||||
|
accessibilityEnabled = enabledAndInstalledServiceCount > 1
|
||||||
|
|| (enabledAndInstalledServiceCount == 1
|
||||||
|
&& !installedServices.contains(toggledService));
|
||||||
|
enabledServices.remove(toggledService);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the enabled services setting.
|
||||||
|
StringBuilder enabledServicesBuilder = new StringBuilder();
|
||||||
|
// Keep the enabled services even if they are not installed since we have
|
||||||
|
// no way to know whether the application restore process has completed.
|
||||||
|
// In general the system should be responsible for the clean up not settings.
|
||||||
|
for (ComponentName enabledService : enabledServices) {
|
||||||
|
enabledServicesBuilder.append(enabledService.flattenToString());
|
||||||
|
enabledServicesBuilder.append(ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR);
|
||||||
|
}
|
||||||
|
final int enabledServicesBuilderLength = enabledServicesBuilder.length();
|
||||||
|
if (enabledServicesBuilderLength > 0) {
|
||||||
|
enabledServicesBuilder.deleteCharAt(enabledServicesBuilderLength - 1);
|
||||||
|
}
|
||||||
|
Settings.Secure.putString(getContentResolver(),
|
||||||
|
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
|
||||||
|
enabledServicesBuilder.toString());
|
||||||
|
|
||||||
|
// Update accessibility enabled.
|
||||||
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_ENABLED, accessibilityEnabled ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
Reference in New Issue
Block a user