From bc83edbf4dda767684c69c932a87262d9fa57965 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 27 May 2020 12:58:40 -0700 Subject: [PATCH] Allows Accessibility to focus on specified view in AbstractFloatingView. Here, the first item in an ArrowPopup or Folder are focused on. Note: There's another pre-existing bug where it announces "Home screen x of y" when the floating view appears; this change doesn't address that. Fixes: 147470419 Change-Id: I1dc70edc21ea7c19a5742208512738d6c4a94067 --- src/com/android/launcher3/AbstractFloatingView.java | 8 +++++++- src/com/android/launcher3/folder/Folder.java | 5 +++++ src/com/android/launcher3/popup/ArrowPopup.java | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java index 572615ff8a..cd27a2ddca 100644 --- a/src/com/android/launcher3/AbstractFloatingView.java +++ b/src/com/android/launcher3/AbstractFloatingView.java @@ -174,7 +174,8 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch targetInfo.first, TYPE_WINDOW_STATE_CHANGED, targetInfo.second); if (mIsOpen) { - performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); + getAccessibilityInitialFocusView().performAccessibilityAction( + AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); } ActivityContext.lookupContext(getContext()).getDragLayer() .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED); @@ -184,6 +185,11 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch return null; } + /** Returns the View that Accessibility services should focus on first. */ + protected View getAccessibilityInitialFocusView() { + return this; + } + /** * Returns a view matching FloatingViewType */ diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index fdf0ea46f2..c7487cb602 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -745,6 +745,11 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo : getContext().getString(R.string.folder_closed)); } + @Override + protected View getAccessibilityInitialFocusView() { + return mContent.getFirstItem(); + } + private void closeComplete(boolean wasAnimated) { // TODO: Clear all active animations. DragLayer parent = (DragLayer) getParent(); diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index 5b0c388332..d5b32fccd1 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -389,6 +389,11 @@ public abstract class ArrowPopup extends Abstrac return Pair.create(this, ""); } + @Override + protected View getAccessibilityInitialFocusView() { + return getChildCount() > 0 ? getChildAt(0) : this; + } + private void animateOpen() { setVisibility(View.VISIBLE);