Talkback read heading content of dialpad page.
To add pane titles for emergency shortcut buttons page and emergency
dialpad page. The accessibility service would auto focus to the
heading.
Test: Manually
Change-Id: I274634eccf6b4ce11a1e419a2b7e49ac4346a4f0
Fixes: 111891667
diff --git a/res/layout/emergency_dialer.xml b/res/layout/emergency_dialer.xml
index cdb9530..7f99664 100644
--- a/res/layout/emergency_dialer.xml
+++ b/res/layout/emergency_dialer.xml
@@ -22,6 +22,7 @@
<!-- Emergency dialer shortcuts layout-->
<FrameLayout
android:id="@+id/emergency_dialer_shortcuts"
+ android:accessibilityPaneTitle="@string/emergencyDialerIconLabel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
@@ -52,6 +53,7 @@
<!--Emergency Dialer Layout-->
<FrameLayout
android:id="@+id/emergency_dialer"
+ android:accessibilityPaneTitle="@string/pane_title_emergency_dialpad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="36dp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6b7a105..7773af6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1399,6 +1399,13 @@
-->
<string name="description_dialpad_button">show dialpad</string>
+ <!-- Pane title of the Emergency Dialpad
+
+ Used by AccessibilityService to announce the purpose of the pane of emergency dialpad.
+ [CHAR LIMIT=NONE]
+ -->
+ <string name="pane_title_emergency_dialpad">Emergency Dialpad</string>
+
<!-- Visual voicemail on/off title [CHAR LIMIT=40] -->
<string name="voicemail_visual_voicemail_switch_title">Visual Voicemail</string>
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 7e5b1ce..7d20dc5 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -61,8 +61,10 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView;
import com.android.internal.colorextraction.ColorExtractor;
@@ -173,6 +175,30 @@
}
};
+ /**
+ * Customize accessibility methods in View.
+ */
+ private AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() {
+
+ /**
+ * Stop AccessiblityService from reading the title of a hidden View.
+ *
+ * <p>The crossfade animation will set the visibility of fade out view to {@link View.GONE}
+ * in the animation end. The view with an accessibility pane title would call the
+ * {@link AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED} event, which would trigger the
+ * accessibility service to read the pane title of fade out view instead of pane title of
+ * fade in view. So it need to filter out the event called by vanished pane.
+ */
+ @Override
+ public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
+ if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
+ && host.getVisibility() == View.GONE) {
+ return;
+ }
+ super.onPopulateAccessibilityEvent(host, event);
+ }
+ };
+
private String mLastNumber; // last number we tried to dial. Used to restore error dialog.
// Background gradient
@@ -927,6 +953,9 @@
mEmergencyShortcutView = findViewById(R.id.emergency_dialer_shortcuts);
mDialpadView = findViewById(R.id.emergency_dialer);
+ mEmergencyShortcutView.setAccessibilityDelegate(mAccessibilityDelegate);
+ mDialpadView.setAccessibilityDelegate(mAccessibilityDelegate);
+
final View dialpadButton = findViewById(R.id.floating_action_button_dialpad);
dialpadButton.setOnClickListener(this);