From 2bb5134413309246b383b6ccedf6369650d1a47f Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Sat, 20 Mar 2021 01:13:45 +0100 Subject: [PATCH] Fix widget scrolling issue on right panel Since we added support for multiple panels on the home screen, we need to call cancelLongPress on all the visible pages not just on the leftmost visible page. Test: manual Bug: 178582378 Change-Id: I88ded543a16b1bbf2a53a627e5725f68b42e742b --- src/com/android/launcher3/PagedView.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index b084eb1b9b..72eff620d7 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -63,6 +63,7 @@ import com.android.launcher3.util.Thunk; import com.android.launcher3.views.ActivityContext; import java.util.ArrayList; +import java.util.List; /** * An abstraction of the original Workspace which supports browsing through a @@ -303,6 +304,21 @@ public abstract class PagedView extends ViewGrou return 1; } + /** + * Returns the currently visible pages. + */ + protected Iterable getVisiblePages() { + int panelCount = getPanelCount(); + List visiblePages = new ArrayList<>(panelCount); + for (int i = mCurrentPage; i < mCurrentPage + panelCount; i++) { + View page = getPageAt(i); + if (page != null) { + visiblePages.add(page); + } + } + return visiblePages; + } + /** * Returns true if the view is on one of the current pages, false otherwise. */ @@ -1052,10 +1068,7 @@ public abstract class PagedView extends ViewGrou // Try canceling the long press. It could also have been scheduled // by a distant descendant, so use the mAllowLongPress flag to block // everything - final View currentPage = getPageAt(mCurrentPage); - if (currentPage != null) { - currentPage.cancelLongPress(); - } + getVisiblePages().forEach(View::cancelLongPress); } protected float getScrollProgress(int screenCenter, View v, int page) {