diff options
author | 2023-05-12 12:49:02 -0700 | |
---|---|---|
committer | 2023-05-12 13:10:37 -0700 | |
commit | 12075972ff2633bc232aa5fdd552c45d9a605b40 (patch) | |
tree | c90698d676426a3e8c2050e06440abbb302223bb /java/src | |
parent | 6df7212d1017517efd372845411eebee3d8c8580 (diff) |
A workaround for swipe-down-to-dismiss issue
Compatibility RecyclerView reports onNestedScroll `consumed` value as
true if scroll is enabled in any direction.
The SysUi RecyclerView reports ture only if can be scrolled in the
direction of the fling.
Add a workaround to ResolverDrawerLayout that restores the legacy
functionality.
Fix: 264005990
Test: manual testing
Change-Id: If379e43c57355489bf8b0265dbab14d796b3dff6
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java b/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java index f5e20510..de76a1d2 100644 --- a/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java +++ b/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java @@ -841,7 +841,14 @@ public class ResolverDrawerLayout extends ViewGroup { @Override public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) { - if (!consumed && Math.abs(velocityY) > mMinFlingVelocity) { + // TODO: find a more suitable way to fix it. + // RecyclerView started reporting `consumed` as true whenever a scrolling is enabled, + // previously the value was based whether the fling can be performed in given direction + // i.e. whether it is at the top or at the bottom. isRecyclerViewAtTheTop method is a + // workaround that restores the legacy functionality. + boolean shouldConsume = (Math.abs(velocityY) > mMinFlingVelocity) + && (!consumed || (velocityY < 0 && isRecyclerViewAtTheTop(target))); + if (shouldConsume) { if (getShowAtTop()) { if (isDismissable() && velocityY > 0) { abortAnimation(); @@ -863,6 +870,21 @@ public class ResolverDrawerLayout extends ViewGroup { return false; } + private static boolean isRecyclerViewAtTheTop(View target) { + // TODO: there's a very similar functionality in #isNestedRecyclerChildScrolled(), + // consolidate the two. + if (!(target instanceof RecyclerView)) { + return false; + } + RecyclerView recyclerView = (RecyclerView) target; + if (recyclerView.getChildCount() == 0) { + return true; + } + View firstChild = recyclerView.getChildAt(0); + return recyclerView.getChildAdapterPosition(firstChild) == 0 + && firstChild.getTop() >= recyclerView.getPaddingTop(); + } + private boolean performAccessibilityActionCommon(int action) { switch (action) { case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: |