From 1f72f9b3def0bc1bfa17c349342f977c8def1fc4 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Wed, 4 Dec 2024 00:45:48 +0000 Subject: [PATCH] Fix issue in scrolling in remote compose widgets There was special check in LauncherAppWidgetHostView to disallow intercept touch events in launcher when the widget is scrollable, the same check needs to be implemented for remote compose widget for scrolling to work properly. Bug: 339721781 Change-Id: I8b824f293ab287a7844f93610b8b952c4aefa3dd Test: manual Flag: EXEMPT bugfix --- .../widget/LauncherAppWidgetHostView.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java index 44ab966472..0cf1f2eab2 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java @@ -68,6 +68,8 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView private static final String TRACE_METHOD_NAME = "appwidget load-widget "; + private static final Integer NO_LAYOUT_ID = Integer.valueOf(0); + private final CheckLongPressHelper mLongPressHelper; protected final ActivityContext mActivityContext; @@ -164,6 +166,21 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView return false; } + private boolean isTaggedAsScrollable() { + // TODO: Introduce new api in AppWidgetHostView to indicate whether the widget is + // scrollable. + for (int i = 0; i < this.getChildCount(); i++) { + View child = this.getChildAt(i); + final Integer layoutId = (Integer) child.getTag(android.R.id.widget_frame); + if (layoutId != null) { + // The layout id is only set to 0 when RemoteViews is created from + // DrawInstructions. + return NO_LAYOUT_ID.equals(layoutId); + } + } + return false; + } + /** * Returns true if the application of {@link RemoteViews} through {@link #updateAppWidget} are * currently being deferred. @@ -266,7 +283,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - mIsScrollable = checkScrollableRecursively(this); + mIsScrollable = isTaggedAsScrollable() || checkScrollableRecursively(this); } /**