diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-09-02 10:41:43 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-09-02 10:52:07 -0700 |
commit | 52851aa3fd2dd9957e190d779f904f6abaf53fed (patch) | |
tree | a45ec27214e4f1e6e074d15451c0fb469884305b /src/com/android/launcher3/dragndrop | |
parent | 94b510cc683a6436ae82c6d323cbd8b429561b06 (diff) | |
download | android_packages_apps_Trebuchet-52851aa3fd2dd9957e190d779f904f6abaf53fed.tar.gz android_packages_apps_Trebuchet-52851aa3fd2dd9957e190d779f904f6abaf53fed.tar.bz2 android_packages_apps_Trebuchet-52851aa3fd2dd9957e190d779f904f6abaf53fed.zip |
Fixing topView not being considered in all places when calculating accessible
and focusable views
Bug: 30563273
Change-Id: I6253ce33ee5c328efdde2ea733029975b31e5eb8
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragLayer.java | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index dcff89f55..e5ec6ba9f 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -343,16 +343,9 @@ public class DragLayer extends InsettableFrameLayout { } private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) { - AccessibilityManager accessibilityManager = (AccessibilityManager) - getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); - if (accessibilityManager.isEnabled()) { - int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close; - AccessibilityEvent event = AccessibilityEvent.obtain( - AccessibilityEvent.TYPE_VIEW_FOCUSED); - onInitializeAccessibilityEvent(event); - event.getText().add(getContext().getString(stringId)); - accessibilityManager.sendAccessibilityEvent(event); - } + int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close; + Utilities.sendCustomAccessibilityEvent( + this, AccessibilityEvent.TYPE_VIEW_FOCUSED, getContext().getString(stringId)); } private boolean isInAccessibleDrag() { @@ -362,37 +355,27 @@ public class DragLayer extends InsettableFrameLayout { @Override public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { // Shortcuts can appear above folder - View topView = mLauncher.getOpenShortcutsContainer(); - if (topView != null) { - return handleTopViewSendAccessibilityEvent(topView, child, event); - } - - topView = mLauncher.getWorkspace().getOpenFolder(); + View topView = mLauncher.getTopFloatingView(); if (topView != null) { - return handleTopViewSendAccessibilityEvent(topView, child, event); + if (child == topView) { + return super.onRequestSendAccessibilityEvent(child, event); + } + if (isInAccessibleDrag() && child instanceof DropTargetBar) { + return super.onRequestSendAccessibilityEvent(child, event); + } + // Skip propagating onRequestSendAccessibilityEvent for all other children + // which are not topView + return false; } return super.onRequestSendAccessibilityEvent(child, event); } - private boolean handleTopViewSendAccessibilityEvent( - View topView, View child, AccessibilityEvent event) { - if (child == topView) { - return super.onRequestSendAccessibilityEvent(child, event); - } - if (isInAccessibleDrag() && child instanceof DropTargetBar) { - return super.onRequestSendAccessibilityEvent(child, event); - } - // Skip propagating onRequestSendAccessibilityEvent for all other children - // which are not topView - return false; - } - @Override public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) { - Folder currentFolder = mLauncher.getWorkspace().getOpenFolder(); - if (currentFolder != null) { - // Only add the folder as a child for accessibility when it is open - childrenForAccessibility.add(currentFolder); + View topView = mLauncher.getTopFloatingView(); + if (topView != null) { + // Only add the top view as a child for accessibility when it is open + childrenForAccessibility.add(topView); if (isInAccessibleDrag()) { childrenForAccessibility.add(mLauncher.getDropTargetBar()); @@ -1037,6 +1020,26 @@ public class DragLayer extends InsettableFrameLayout { return mBackgroundAlpha; } + @Override + protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { + View topView = mLauncher.getTopFloatingView(); + if (topView != null) { + return topView.requestFocus(direction, previouslyFocusedRect); + } else { + return super.onRequestFocusInDescendants(direction, previouslyFocusedRect); + } + } + + @Override + public void addFocusables(ArrayList<View> views, int direction, int focusableMode) { + View topView = mLauncher.getTopFloatingView(); + if (topView != null) { + topView.addFocusables(views, direction); + } else { + super.addFocusables(views, direction, focusableMode); + } + } + public void setTouchCompleteListener(TouchCompleteListener listener) { mTouchCompleteListener = listener; } |