Update all home screen widgets size upon workspace inset change
Test: Add a clock widget to the home screen. Then, change the navigation
gesture. Go to home screen to confirm the clock widget is rendered
as expected in the portrait. Then, rotate the device to landscape.
Confirmed the clock widget is rendered correctly in the landscape.
Fix: 202837404
Change-Id: I93b70c53f10c8150131b183defc8baf01e5924a8
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index fc717c9..ce06c6e 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -329,6 +329,7 @@
}
updateWorkspaceScreensPadding();
+ updateWorkspaceWidgetsSizes();
}
private void updateWorkspaceScreensPadding() {
@@ -360,6 +361,25 @@
}
}
+ private void updateWorkspaceWidgetsSizes() {
+ int numberOfScreens = mScreenOrder.size();
+ for (int i = 0; i < numberOfScreens; i++) {
+ ShortcutAndWidgetContainer shortcutAndWidgetContainer =
+ mWorkspaceScreens.get(mScreenOrder.get(i)).getShortcutsAndWidgets();
+ int shortcutsAndWidgetCount = shortcutAndWidgetContainer.getChildCount();
+ for (int j = 0; j < shortcutsAndWidgetCount; j++) {
+ View view = shortcutAndWidgetContainer.getChildAt(j);
+ if (view instanceof LauncherAppWidgetHostView
+ && view.getTag() instanceof LauncherAppWidgetInfo) {
+ LauncherAppWidgetInfo launcherAppWidgetInfo =
+ (LauncherAppWidgetInfo) view.getTag();
+ WidgetSizes.updateWidgetSizeRanges((LauncherAppWidgetHostView) view,
+ mLauncher, launcherAppWidgetInfo.spanX, launcherAppWidgetInfo.spanY);
+ }
+ }
+ }
+ }
+
/**
* Estimates the size of an item using spans: hSpan, vSpan.
*