summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormenghanli <menghanli@google.com>2020-01-20 17:34:31 +0800
committermenghanli <menghanli@google.com>2020-01-21 15:58:43 +0800
commitbf460320741f585d0933737fc68ae531e00f5bed (patch)
treef5d3fcfa191f228a50ca59416edf636ad0db6f50
parent251bbaa0081c7231c837349fa98101bb410e30cb (diff)
downloadpackages_apps_Settings-bf460320741f585d0933737fc68ae531e00f5bed.tar.gz
packages_apps_Settings-bf460320741f585d0933737fc68ae531e00f5bed.tar.bz2
packages_apps_Settings-bf460320741f585d0933737fc68ae531e00f5bed.zip
Support accessibility shortcut secondary action (10/n)
Integrate with Talkback enabled and change the behavior as below: 1. Show 3-finger swipe up from bottom summary 2. Show 3-finger icons for edit shortcut dialog 3. Dismiss the running the edit shortcut dialog Bug: 142530063 Bug: 142531156 Bug: 147989432 Test: make RunSettingsRoboTests2 Change-Id: I2f34b8eebfdc5a385d72402e95a8b1d0bde4a428
-rw-r--r--res/drawable/accessibility_shortcut_type_software_gesture_talkback.pngbin0 -> 2476 bytes
-rw-r--r--res/values/strings.xml16
-rw-r--r--src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java43
-rw-r--r--src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java24
-rw-r--r--src/com/android/settings/accessibility/AccessibilityUtil.java7
-rw-r--r--src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java35
-rw-r--r--src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java49
-rw-r--r--src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java47
-rw-r--r--src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java42
9 files changed, 182 insertions, 81 deletions
diff --git a/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png b/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png
new file mode 100644
index 0000000000..a8d86aa5f8
--- /dev/null
+++ b/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4b5be08481..db95210af9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4818,13 +4818,13 @@
<!-- Message for the Accessibility tutorial dialog when user enables an accessibility service while using the 3-button nav bar. [CHAR LIMIT=NONE] -->
<string name="accessibility_tutorial_dialog_message_button">To turn this service on or off, tap the accessibility button <xliff:g id="accessibility_icon" example="[Icon]">%s</xliff:g> on the bottom of your screen.\n\nTo switch between services, touch &amp; hold the accessibility button.</string>
<!-- Message for the Accessibility tutorial dialog when user enables an accessibility service while using gesture navigation and touch exploration is not enabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_tutorial_dialog_message_gesture_without_talkback">To turn this service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold.</string>
+ <string name="accessibility_tutorial_dialog_message_gesture">To turn this service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold.</string>
<!-- Message for the Accessibility tutorial dialog when user enables an accessibility service while using gesture navigation and touch exploration is enabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_tutorial_dialog_message_gesture_with_talkback">To turn this service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
+ <string name="accessibility_tutorial_dialog_message_gesture_talkback">To turn this service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
<!-- Message for the Accessibility tutorial dialog when user chooses gesture navigation in navigation settings, an accessibility service is using the accessibility button, and touch exploration is disabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_tutorial_dialog_message_gesture_settings_without_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold.</string>
+ <string name="accessibility_tutorial_dialog_message_gesture_settings">To turn an accessibility service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold.</string>
<!-- Message for the Accessibility tutorial dialog when user chooses gesture navigation in navigation settings, an accessibility service is using the accessibility button, and touch exploration is enabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_tutorial_dialog_message_gesture_settings_with_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
+ <string name="accessibility_tutorial_dialog_message_gesture_settings_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
<!-- Button for the Accessibility tutorial dialog to dismiss the dialog when user clicks it. [CHAR LIMIT=10] -->
<string name="accessibility_tutorial_dialog_button">Got it</string>
<!-- Title for accessibility shortcut preference for accessibility apps. [CHAR LIMIT=40] -->
@@ -4839,12 +4839,16 @@
<string name="accessibility_shortcut_edit_dialog_title_daltonizer">Shortcut to open Color correction</string>
<!-- Title for software shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_title_software">Accessibility Button</string>
- <!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
+ <!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation is enabled. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_title_software_gesture">2-finger swipe up from bottom</string>
+ <!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation and touch exploration are enabled. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_shortcut_edit_dialog_title_software_gesture_talkback">3-finger swipe up from bottom</string>
<!-- Summary for software shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_summary_software">Tap the <xliff:g id="accessibility_icon" example="[Icon]">%s</xliff:g> button at the bottom of your screen</string>
- <!-- Summary for software shortcut in gesture mode in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
+ <!-- Summary for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation is enabled. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture">Swipe up with 2 fingers from edge of screen</string>
+ <!-- Summary for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation and touch exploration are enabled [CHAR LIMIT=NONE] -->
+ <string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up with 3 fingers from edge of screen</string>
<!-- Title for hardware shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
<!-- Summary for hardware shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
diff --git a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
index 7136172a75..c96013f5bb 100644
--- a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
+++ b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
@@ -171,7 +171,7 @@ public class AccessibilityEditDialogUtils {
private static void initMagnifyFullScreen(Context context, View view) {
final View dialogView = view.findViewById(R.id.magnify_full_screen);
- final String title = context.getString(
+ final CharSequence title = context.getText(
R.string.accessibility_magnification_area_settings_full_screen);
// TODO(b/146019459): Use vector drawable instead of temporal png file to avoid distorted.
setupShortcutWidget(dialogView, title, R.drawable.accessibility_magnification_full_screen);
@@ -179,7 +179,7 @@ public class AccessibilityEditDialogUtils {
private static void initMagnifyWindowScreen(Context context, View view) {
final View dialogView = view.findViewById(R.id.magnify_window_screen);
- final String title = context.getString(
+ final CharSequence title = context.getText(
R.string.accessibility_magnification_area_settings_window_screen);
// TODO(b/146019459): Use vector drawable instead of temporal png file to avoid distorted.
setupShortcutWidget(dialogView, title,
@@ -214,9 +214,9 @@ public class AccessibilityEditDialogUtils {
private static void initHardwareShortcut(Context context, View view) {
final View dialogView = view.findViewById(R.id.hardware_shortcut);
- final String title = context.getString(
+ final CharSequence title = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_hardware);
- final String summary = context.getString(
+ final CharSequence summary = context.getText(
R.string.accessibility_shortcut_edit_dialog_summary_hardware);
setupShortcutWidget(dialogView, title, summary,
R.drawable.accessibility_shortcut_type_hardware);
@@ -225,9 +225,9 @@ public class AccessibilityEditDialogUtils {
private static void initMagnifyShortcut(Context context, View view) {
final View dialogView = view.findViewById(R.id.triple_tap_shortcut);
- final String title = context.getString(
+ final CharSequence title = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_triple_tap);
- final String summary = context.getString(
+ final CharSequence summary = context.getText(
R.string.accessibility_shortcut_edit_dialog_summary_triple_tap);
setupShortcutWidget(dialogView, title, summary,
R.drawable.accessibility_shortcut_type_triple_tap);
@@ -244,23 +244,34 @@ public class AccessibilityEditDialogUtils {
}
private static CharSequence retrieveTitle(Context context) {
- return context.getString(AccessibilityUtil.isGestureNavigateEnabled(context)
- ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
- : R.string.accessibility_shortcut_edit_dialog_title_software);
+ int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
+ : R.string.accessibility_shortcut_edit_dialog_title_software_gesture;
+ }
+ return context.getText(resId);
}
private static CharSequence retrieveSummary(Context context, int lineHeight) {
- return AccessibilityUtil.isGestureNavigateEnabled(context)
- ? context.getString(
- R.string.accessibility_shortcut_edit_dialog_summary_software_gesture)
- : getSummaryStringWithIcon(context, lineHeight);
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ final int resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_shortcut_edit_dialog_summary_software_gesture_talkback
+ : R.string.accessibility_shortcut_edit_dialog_summary_software_gesture;
+ return context.getText(resId);
+ }
+ return getSummaryStringWithIcon(context, lineHeight);
}
private static int retrieveImageResId(Context context) {
- return AccessibilityUtil.isGestureNavigateEnabled(context)
- ? R.drawable.accessibility_shortcut_type_software_gesture
- : R.drawable.accessibility_shortcut_type_software;
// TODO(b/142531156): Use vector drawable instead of temporal png file to avoid distorted.
+ int resId = R.drawable.accessibility_shortcut_type_software;
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.drawable.accessibility_shortcut_type_software_gesture_talkback
+ : R.drawable.accessibility_shortcut_type_software_gesture;
+ }
+ return resId;
}
private static SpannableString getSummaryStringWithIcon(Context context, int lineHeight) {
diff --git a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
index 5e6eced04e..0c8644f649 100644
--- a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
@@ -27,7 +27,6 @@ import android.view.LayoutInflater;
import android.view.TextureView;
import android.view.View;
import android.view.Window;
-import android.view.accessibility.AccessibilityManager;
import android.widget.TextView;
import androidx.annotation.ColorInt;
@@ -117,13 +116,13 @@ public class AccessibilityGestureNavigationTutorial {
R.id.gesture_tutorial_video);
final TextView gestureTutorialMessage = content.findViewById(
R.id.gesture_tutorial_message);
- VideoPlayer.create(context, isTouchExploreOn(context)
+ VideoPlayer.create(context, AccessibilityUtil.isTouchExploreEnabled(context)
? R.raw.illustration_accessibility_gesture_three_finger
: R.raw.illustration_accessibility_gesture_two_finger,
gestureTutorialVideo);
- gestureTutorialMessage.setText(isTouchExploreOn(context)
- ? R.string.accessibility_tutorial_dialog_message_gesture_with_talkback
- : R.string.accessibility_tutorial_dialog_message_gesture_without_talkback);
+ gestureTutorialMessage.setText(AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_tutorial_dialog_message_gesture_talkback
+ : R.string.accessibility_tutorial_dialog_message_gesture);
break;
case DialogType.GESTURE_NAVIGATION_SETTINGS:
content = inflater.inflate(
@@ -132,14 +131,14 @@ public class AccessibilityGestureNavigationTutorial {
R.id.gesture_tutorial_video);
final TextView gestureSettingsTutorialMessage = content.findViewById(
R.id.gesture_tutorial_message);
- VideoPlayer.create(context, isTouchExploreOn(context)
+ VideoPlayer.create(context, AccessibilityUtil.isTouchExploreEnabled(context)
? R.raw.illustration_accessibility_gesture_three_finger
: R.raw.illustration_accessibility_gesture_two_finger,
gestureSettingsTutorialVideo);
- gestureSettingsTutorialMessage.setText(isTouchExploreOn(context)
- ?
- R.string.accessibility_tutorial_dialog_message_gesture_settings_with_talkback
- : R.string.accessibility_tutorial_dialog_message_gesture_settings_without_talkback);
+ final int stringResId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_tutorial_dialog_message_gesture_settings_talkback
+ : R.string.accessibility_tutorial_dialog_message_gesture_settings;
+ gestureSettingsTutorialMessage.setText(stringResId);
break;
}
@@ -203,9 +202,4 @@ public class AccessibilityGestureNavigationTutorial {
typedArray.recycle();
return colorResId;
}
-
- private static boolean isTouchExploreOn(Context context) {
- return ((AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE))
- .isTouchExplorationEnabled();
- }
}
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index fefb406549..8da6fbb920 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
+import android.view.accessibility.AccessibilityManager;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
@@ -139,6 +140,12 @@ final class AccessibilityUtil {
== NAV_BAR_MODE_GESTURAL;
}
+ /** Determines if a touch explore is being used. */
+ public static boolean isTouchExploreEnabled(Context context) {
+ final AccessibilityManager am = context.getSystemService(AccessibilityManager.class);
+ return am.isTouchExplorationEnabled();
+ }
+
/**
* Gets the corresponding fragment type of a given accessibility service.
*
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 8a0b7e1630..87c1bf8886 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -35,10 +35,13 @@ import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.text.TextUtils;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import androidx.preference.PreferenceCategory;
@@ -67,6 +70,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
+ private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private int mUserShortcutType = UserShortcutType.DEFAULT;
// Used to restore the edit dialog status.
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
@@ -115,6 +119,16 @@ public class ToggleAccessibilityServicePreferenceFragment extends
}
@Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
+ removeDialog(DialogType.EDIT_SHORTCUT);
+ mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+ };
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+
+ @Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// Restore the user shortcut type.
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
@@ -122,6 +136,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
UserShortcutType.DEFAULT);
}
initShortcutPreference();
+
super.onViewCreated(view, savedInstanceState);
}
@@ -134,7 +149,12 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override
public void onResume() {
super.onResume();
+
mSettingsContentObserver.register(getContentResolver());
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
updateSwitchBarToggleSwitch();
updateShortcutPreferenceData();
updateShortcutPreference();
@@ -143,6 +163,10 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override
public void onPause() {
mSettingsContentObserver.unregister(getContentResolver());
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
super.onPause();
}
@@ -284,10 +308,13 @@ public class ToggleAccessibilityServicePreferenceFragment extends
private String getShortcutTypeSummary(Context context) {
final int shortcutType = getUserShortcutType(context, UserShortcutType.SOFTWARE);
- final CharSequence softwareTitle =
- context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
- ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
- : R.string.accessibility_shortcut_edit_dialog_title_software);
+ int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
+ : R.string.accessibility_shortcut_edit_dialog_title_software_gesture;
+ }
+ final CharSequence softwareTitle = context.getText(resId);
List<CharSequence> list = new ArrayList<>();
if ((shortcutType & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index 4cc51b4cdd..80fd92f3e0 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -31,6 +31,8 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import android.widget.Switch;
@@ -64,6 +66,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private final Handler mHandler = new Handler();
+ private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private SettingsContentObserver mSettingsContentObserver;
private int mUserShortcutType = UserShortcutType.DEFAULT;
// Used to restore the edit dialog status.
@@ -72,18 +75,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
private CheckBox mHardwareTypeCheckBox;
@Override
- public void onStart() {
- super.onStart();
- mSettingsContentObserver.register(getContentResolver());
- }
-
- @Override
- public void onStop() {
- mSettingsContentObserver.unregister(getContentResolver());
- super.onStop();
- }
-
- @Override
public int getMetricsCategory() {
return SettingsEnums.ACCESSIBILITY_COLOR_INVERSION_SETTINGS;
}
@@ -143,6 +134,11 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
== State.ON);
}
};
+
+ mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
+ removeDialog(DIALOG_ID_EDIT_SHORTCUT);
+ mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+ };
return super.onCreateView(inflater, container, savedInstanceState);
}
@@ -174,14 +170,30 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
@Override
public void onResume() {
super.onResume();
+
+ mSettingsContentObserver.register(getContentResolver());
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
updateShortcutPreferenceData();
updateShortcutPreference();
}
@Override
+ public void onPause() {
+ mSettingsContentObserver.unregister(getContentResolver());
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
+ super.onPause();
+ }
+
+ @Override
public Dialog onCreateDialog(int dialogId) {
if (dialogId == DIALOG_ID_EDIT_SHORTCUT) {
- final CharSequence dialogTitle = getActivity().getString(
+ final CharSequence dialogTitle = getActivity().getText(
R.string.accessibility_shortcut_edit_dialog_title_daltonizer);
final AlertDialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
getActivity(),
@@ -257,10 +269,13 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
private String getShortcutTypeSummary(Context context) {
final int shortcutType = getUserShortcutType(context, UserShortcutType.SOFTWARE);
- final CharSequence softwareTitle =
- context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
- ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
- : R.string.accessibility_shortcut_edit_dialog_title_software);
+ int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
+ : R.string.accessibility_shortcut_edit_dialog_title_software_gesture;
+ }
+ final CharSequence softwareTitle = context.getText(resId);
List<CharSequence> list = new ArrayList<>();
if ((shortcutType & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 91ad7650da..ca9524121c 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -32,6 +32,8 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import android.widget.Switch;
@@ -67,6 +69,7 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
private final Handler mHandler = new Handler();
+ private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private SettingsContentObserver mSettingsContentObserver;
private int mUserShortcutType = UserShortcutType.DEFAULT;
// Used to restore the edit dialog status.
@@ -109,6 +112,11 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
== State.ON);
}
};
+
+ mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
+ removeDialog(DIALOG_ID_EDIT_SHORTCUT);
+ mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+ };
return super.onCreateView(inflater, container, savedInstanceState);
}
@@ -140,6 +148,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
@Override
public void onResume() {
super.onResume();
+
+ mSettingsContentObserver.register(getContentResolver());
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
for (AbstractPreferenceController controller :
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
((DaltonizerRadioButtonPreferenceController) controller).setOnChangeListener(this);
@@ -152,17 +166,23 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
@Override
public void onPause() {
- super.onPause();
+ mSettingsContentObserver.unregister(getContentResolver());
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
for (AbstractPreferenceController controller :
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
((DaltonizerRadioButtonPreferenceController) controller).setOnChangeListener(null);
}
+
+ super.onPause();
}
@Override
public Dialog onCreateDialog(int dialogId) {
if (dialogId == DIALOG_ID_EDIT_SHORTCUT) {
- final CharSequence dialogTitle = getActivity().getString(
+ final CharSequence dialogTitle = getActivity().getText(
R.string.accessibility_shortcut_edit_dialog_title_daltonizer);
final AlertDialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
getActivity(),
@@ -238,10 +258,13 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
private String getShortcutTypeSummary(Context context) {
final int shortcutType = getUserShortcutType(context, UserShortcutType.SOFTWARE);
- final CharSequence softwareTitle =
- context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
- ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
- : R.string.accessibility_shortcut_edit_dialog_title_software);
+ int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
+ : R.string.accessibility_shortcut_edit_dialog_title_software_gesture;
+ }
+ final CharSequence softwareTitle = context.getText(resId);
List<CharSequence> list = new ArrayList<>();
if ((shortcutType & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
@@ -289,18 +312,6 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
}
@Override
- public void onStart() {
- super.onStart();
- mSettingsContentObserver.register(getContentResolver());
- }
-
- @Override
- public void onStop() {
- mSettingsContentObserver.unregister(getContentResolver());
- super.onStop();
- }
-
- @Override
public int getMetricsCategory() {
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index a6434534d2..8e4da9de78 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -33,8 +33,12 @@ import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout.LayoutParams;
@@ -65,6 +69,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
private static final String SETTINGS_KEY = "screen_magnification_settings";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
+ private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private int mUserShortcutType = UserShortcutType.DEFAULT;
// Used to restore the edit dialog status.
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
@@ -165,6 +170,16 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
@Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
+ removeDialog(DialogType.EDIT_SHORTCUT);
+ mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+ };
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+
+ @Override
public void onViewCreated(View view, Bundle savedInstanceState) {
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
mVideoPreference = new VideoPreference(getPrefContext());
@@ -174,6 +189,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
preferenceScreen.addPreference(mVideoPreference);
initShortcutPreference();
+
mSettingsPreference = new Preference(getPrefContext());
mSettingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
mSettingsPreference.setKey(SETTINGS_KEY);
@@ -206,6 +222,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
public void onResume() {
super.onResume();
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
VideoView videoView = (VideoView) getView().findViewById(R.id.video);
if (videoView != null) {
videoView.start();
@@ -217,6 +237,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
@Override
+ public void onPause() {
+ final AccessibilityManager am = getPrefContext().getSystemService(
+ AccessibilityManager.class);
+ am.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+
+ super.onPause();
+ }
+
+ @Override
public Dialog onCreateDialog(int dialogId) {
switch (dialogId) {
case DialogType.GESTURE_NAVIGATION_TUTORIAL:
@@ -226,7 +255,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return AccessibilityGestureNavigationTutorial
.showAccessibilityButtonTutorialDialog(getActivity());
case DialogType.EDIT_SHORTCUT:
- final CharSequence dialogTitle = getActivity().getString(
+ final CharSequence dialogTitle = getActivity().getText(
R.string.accessibility_shortcut_edit_dialog_title_magnification);
final AlertDialog dialog =
AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
@@ -323,10 +352,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
private String getShortcutTypeSummary(Context context) {
final int shortcutType = getUserShortcutType(context, UserShortcutType.DEFAULT);
- final CharSequence softwareTitle =
- context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
- ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
- : R.string.accessibility_shortcut_edit_dialog_title_software);
+ int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
+ resId = AccessibilityUtil.isTouchExploreEnabled(context)
+ ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
+ : R.string.accessibility_shortcut_edit_dialog_title_software_gesture;
+ }
+ final CharSequence softwareTitle = context.getText(resId);
List<CharSequence> list = new ArrayList<>();
if ((shortcutType & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {