summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Launcher.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-06-01 17:17:08 -0700
committerAdam Cohen <adamcohen@google.com>2012-06-04 12:18:04 -0700
commit06dff35763bc46884b6464a9bf4406d32cdcaea4 (patch)
tree197f97d8c6e43df01730841136db5bbd9c4f515d /src/com/android/launcher2/Launcher.java
parent1fa57ee628a135dbbf34af43765ecf9d43c37cbc (diff)
downloadandroid_packages_apps_Trebuchet-06dff35763bc46884b6464a9bf4406d32cdcaea4.tar.gz
android_packages_apps_Trebuchet-06dff35763bc46884b6464a9bf4406d32cdcaea4.tar.bz2
android_packages_apps_Trebuchet-06dff35763bc46884b6464a9bf4406d32cdcaea4.zip
Fixing issue where widgets could be inflated in wrong orientation (issue 6584646)
Change-Id: I24ea7f59345e8f62daf36c13cb43e1ab0180e805
Diffstat (limited to 'src/com/android/launcher2/Launcher.java')
-rw-r--r--src/com/android/launcher2/Launcher.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index b2f27b960..3354d49bd 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -682,6 +682,31 @@ public final class Launcher extends Activity
// Resets the previous all apps icon press state
mAppsCustomizeContent.resetDrawableState();
}
+ // It is possible that widgets can receive updates while launcher is not in the foreground.
+ // Consequently, the widgets will be inflated in the orientation of the foreground activity
+ // (framework issue). On resuming, we ensure that any widgets are inflated for the current
+ // orientation.
+ reinflateWidgetsIfNecessary();
+ }
+
+ void reinflateWidgetsIfNecessary() {
+ for (LauncherAppWidgetInfo info: LauncherModel.getWidgets()) {
+ LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView;
+ if (lahv != null && lahv.orientationChangedSincedInflation()) {
+ AppWidgetProviderInfo pInfo = lahv.getAppWidgetInfo();
+
+ // Remove the current widget which is inflated with the wrong orientation
+ getWorkspace().getParentCellLayoutForView(lahv).removeView(lahv);
+ // Re-inflate the widget using the correct orientation
+ AppWidgetHostView widget = mAppWidgetHost.createView(this, info.appWidgetId, pInfo);
+
+ // Add the new widget back
+ widget.setTag(info);
+ info.hostView = widget;
+ getWorkspace().addInScreen(widget, info.container, info.screen,
+ info.cellX, info.cellY, info.spanX, info.spanY);
+ }
+ }
}
@Override