From 9176f033d97d4ec9435a5ca61f1b8c051dc46bbf Mon Sep 17 00:00:00 2001 From: Kevin Yao Date: Fri, 31 May 2019 11:52:00 +0800 Subject: [PATCH] User education support on disambiguation dialog Support Accessibility education according to 1. Gesture Navigation is on or off 2. Screen reader feature (such as TalkBack) is enabled or not Manual test screenshot: https://drive.google.com/open?id=1afTDRYPMcZphM5cL0krPDA_Vh9pRX-8x Bug: 133811747 Test: Manual Change-Id: I04ca36c9e88ff14e29103db41cfab2a9b53985d5 --- .../app/AccessibilityButtonChooserActivity.java | 27 +++++++++++++++++++++- .../res/layout/accessibility_button_chooser.xml | 1 + core/res/res/values/strings.xml | 12 ++++++++-- core/res/res/values/symbols.xml | 7 ++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java b/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java index b9ed96395130..7af45fc53ddf 100644 --- a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java +++ b/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java @@ -15,6 +15,8 @@ */ package com.android.internal.app; +import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; + import android.accessibilityservice.AccessibilityServiceInfo; import android.annotation.NonNull; import android.annotation.Nullable; @@ -64,8 +66,21 @@ public class AccessibilityButtonChooserActivity extends Activity { String component = Settings.Secure.getString(getContentResolver(), Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT); + + if (isGestureNavigateEnabled()) { + TextView promptPrologue = findViewById(R.id.accessibility_button_prompt_prologue); + promptPrologue.setText(isTouchExploreOn() + ? R.string.accessibility_gesture_3finger_prompt_text + : R.string.accessibility_gesture_prompt_text); + } + if (TextUtils.isEmpty(component)) { TextView prompt = findViewById(R.id.accessibility_button_prompt); + if (isGestureNavigateEnabled()) { + prompt.setText(isTouchExploreOn() + ? R.string.accessibility_gesture_3finger_instructional_text + : R.string.accessibility_gesture_instructional_text); + } prompt.setVisibility(View.VISIBLE); } @@ -91,6 +106,16 @@ public class AccessibilityButtonChooserActivity extends Activity { }); } + private boolean isGestureNavigateEnabled() { + return NAV_BAR_MODE_GESTURAL == getResources().getInteger( + com.android.internal.R.integer.config_navBarInteractionMode); + } + + private boolean isTouchExploreOn() { + return ((AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE)) + .isTouchExplorationEnabled(); + } + private static List getServiceAccessibilityButtonTargets( @NonNull Context context) { AccessibilityManager ams = (AccessibilityManager) context.getSystemService( @@ -177,4 +202,4 @@ public class AccessibilityButtonChooserActivity extends Activity { return mDrawable; } } -} \ No newline at end of file +} diff --git a/core/res/res/layout/accessibility_button_chooser.xml b/core/res/res/layout/accessibility_button_chooser.xml index 480defbd5935..383780a3ccde 100644 --- a/core/res/res/layout/accessibility_button_chooser.xml +++ b/core/res/res/layout/accessibility_button_chooser.xml @@ -40,6 +40,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="56dp" + android:id="@+id/accessibility_button_prompt_prologue" android:textAppearance="?attr/textAppearanceMedium" android:text="@string/accessibility_button_prompt_text" android:gravity="start|center_vertical" diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 5b917cc4fdf1..d46b3760f51e 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4495,10 +4495,18 @@ %1$s - Choose a feature to use when you tap the Accessibility button: + Choose a service to use when you tap the accessibility button: + + Choose a service to use with the accessibility gesture (swipe up from the bottom of the screen with two fingers): + + Choose a service to use with the accessibility gesture (swipe up from the bottom of the screen with three fingers): - To change features, touch & hold the Accessibility button. + To switch between services, touch & hold the accessibility button. + + To switch between services, swipe up with two fingers and hold. + + To switch between services, swipe up with three fingers and hold. Magnification diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 4af05f699073..89cfa11a7737 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3286,9 +3286,16 @@ + + + + + + + -- 2.11.0