Merge "Disabling state saving for search textbox as search results are not preserved across activity recreate" into ub-launcher3-master
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index dec0a92..824a554 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -277,8 +277,12 @@
DeviceProfile profile = new DeviceProfile(context, inv, mwSize, mwSize, mwSize.x, mwSize.y,
isLandscape);
- // Hide labels on the workspace.
- profile.adjustToHideWorkspaceLabels();
+ // If there isn't enough vertical cell padding with the labels displayed, hide the labels.
+ float workspaceCellPaddingY = profile.getCellSize().y - profile.iconSizePx
+ - iconDrawablePaddingPx - profile.iconTextSizePx;
+ if (workspaceCellPaddingY < profile.iconDrawablePaddingPx * 2) {
+ profile.adjustToHideWorkspaceLabels();
+ }
// We use these scales to measure and layout the widgets using their full invariant profile
// sizes and then draw them scaled and centered to fit in their multi-window mode cellspans.
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index f02d5d2..99f3803 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -252,6 +252,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.
@@ -373,6 +377,7 @@
mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
}
+ mOrientation = getResources().getConfiguration().orientation;
mSharedPrefs = Utilities.getPrefs(this);
mIsSafeModeEnabled = getPackageManager().isSafeMode();
mModel = app.setLauncher(this);
@@ -1565,6 +1570,8 @@
return mSharedPrefs;
}
+ public int getOrientation() { return mOrientation; }
+
@Override
protected void onNewIntent(Intent intent) {
long startTime = 0;
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java
index b65b74e..7fe1308 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java
@@ -142,9 +142,8 @@
return false;
}
- public boolean isReinflateRequired() {
+ public boolean isReinflateRequired(int orientation) {
// Re-inflate is required if the orientation has changed since last inflated.
- int orientation = mContext.getResources().getConfiguration().orientation;
if (mPreviousOrientation != orientation) {
return true;
}
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index de424ab..c2d5501 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -111,7 +111,7 @@
}
@Override
- public boolean isReinflateRequired() {
+ public boolean isReinflateRequired(int orientation) {
// Re inflate is required any time the widget restore status changes
return mStartState != mInfo.restoreStatus;
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c432a53..dfcb331 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1067,7 +1067,7 @@
&& v.getTag() instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag();
LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) v;
- if (lahv.isReinflateRequired()) {
+ if (lahv.isReinflateRequired(mLauncher.getOrientation())) {
// Remove and rebind the current widget (which was inflated in the wrong
// orientation), but don't delete it from the database
mLauncher.removeItem(lahv, info, false /* deleteFromDb */);
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 6bbe3ea..f0b650b 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -362,9 +362,12 @@
int size = apps.size();
for (int i = 0; i < size; ++i) {
AppInfo info = apps.get(i);
- AdapterItem appItem = AdapterItem.asPredictedApp(i, "", info, i);
- appItem.rowAppIndex = i;
- mAdapterItems.set(i, appItem);
+ AdapterItem orgItem = mAdapterItems.get(i);
+ AdapterItem newItem = AdapterItem.asPredictedApp(orgItem.position, "", info,
+ orgItem.appIndex);
+ newItem.rowAppIndex = orgItem.rowAppIndex;
+
+ mAdapterItems.set(i, newItem);
mFilteredApps.set(i, info);
mAdapter.notifyItemChanged(i);
}
diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java
index d26f9f6..65acaa9 100644
--- a/src/com/android/launcher3/qsb/QsbContainerView.java
+++ b/src/com/android/launcher3/qsb/QsbContainerView.java
@@ -36,6 +36,7 @@
import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -79,10 +80,15 @@
private AppWidgetProviderInfo mWidgetInfo;
private QsbWidgetHostView mQsb;
+ // We need to store the orientation here, due to a bug (b/64916689) that results in widgets
+ // being inflated in the wrong orientation.
+ private int mOrientation;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mQsbWidgetHost = new QsbWidgetHost(getActivity());
+ mOrientation = getContext().getResources().getConfiguration().orientation;
}
private FrameLayout mWrapper;
@@ -193,7 +199,7 @@
@Override
public void onResume() {
super.onResume();
- if (mQsb != null && mQsb.isReinflateRequired()) {
+ if (mQsb != null && mQsb.isReinflateRequired(mOrientation)) {
rebindFragment();
}
}
diff --git a/src/com/android/launcher3/qsb/QsbWidgetHostView.java b/src/com/android/launcher3/qsb/QsbWidgetHostView.java
index 8b6fa16..a8a41f6 100644
--- a/src/com/android/launcher3/qsb/QsbWidgetHostView.java
+++ b/src/com/android/launcher3/qsb/QsbWidgetHostView.java
@@ -47,9 +47,9 @@
}
- public boolean isReinflateRequired() {
+ public boolean isReinflateRequired(int orientation) {
// Re-inflate is required if the orientation has changed since last inflation.
- return mPreviousOrientation != getResources().getConfiguration().orientation;
+ return mPreviousOrientation != orientation;
}