Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf460320 authored by menghanli's avatar menghanli
Browse files

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
parent 251bbaa0
Loading
Loading
Loading
Loading
+2.42 KiB
Loading image diff...
+10 −6
Original line number Diff line number Diff line
@@ -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] -->
+27 −16
Original line number Diff line number Diff line
@@ -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) {
+9 −15
Original line number Diff line number Diff line
@@ -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();
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -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.
     *
Loading