diff options
author | 2023-05-13 00:03:44 +0000 | |
---|---|---|
committer | 2023-05-13 00:03:44 +0000 | |
commit | f1281e40ca7ec970877f280f5a983eec0155ab66 (patch) | |
tree | 4837e25d46bc4ab4819da75065e03289edb27ca6 | |
parent | f5c803dcba8a0b6a19d594b0e2726f525d3efa82 (diff) | |
parent | ecb2746404f623699d49d142c79aa9eb67ef32da (diff) |
Merge "A workaround for swipe-down-to-dismiss issue" into udc-dev am: ecb2746404
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/IntentResolver/+/23214121
Change-Id: Iaa209f16c2759c85cab88f2b9230e4644a3c5bb9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-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: |