Fix bug where widgets are inflated in the wrong orientation.
The bug is that in onResume, the context may tell us the wrong
orientation.
As a workaround, we store the orientation that the Launcher
is created with, and we use that orientation to check whether
we actually need to reinflate the widgets.
Bug: 64916689
Change-Id: I5194debbd217a573d1f177c31d8c0abdf9da51b5
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 1e12b42..522e96a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -251,6 +251,10 @@
// Main container view and the model for the widget tray screen.
@Thunk WidgetsContainerView mWidgetsView;
+ // We need to store the orientation Launcher was created with, due to a bug (b/64916689)
+ // that results in widgets being inflated in the wrong orientation.
+ private int mOrientation;
+
// We set the state in both onCreate and then onNewIntent in some cases, which causes both
// scroll issues (because the workspace may not have been measured yet) and extra work.
// Instead, just save the state that we need to restore Launcher to, and commit it in onResume.
@@ -383,6 +387,7 @@
mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
}
+ mOrientation = getResources().getConfiguration().orientation;
mSharedPrefs = Utilities.getPrefs(this);
mIsSafeModeEnabled = getPackageManager().isSafeMode();
mModel = app.setLauncher(this);
@@ -1669,6 +1674,8 @@
return mSharedPrefs;
}
+ public int getOrientation() { return mOrientation; }
+
@Override
protected void onNewIntent(Intent intent) {
long startTime = 0;