From 6bed350b75ad407ba85ae15d62551194dd0a69d4 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 19 Sep 2017 14:43:17 -0700 Subject: 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 --- src/com/android/launcher3/Launcher.java | 7 +++++++ src/com/android/launcher3/LauncherAppWidgetHostView.java | 3 +-- src/com/android/launcher3/PendingAppWidgetHostView.java | 2 +- src/com/android/launcher3/Workspace.java | 2 +- src/com/android/launcher3/qsb/QsbContainerView.java | 4 +++- src/com/android/launcher3/qsb/QsbWidgetHostView.java | 4 ++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 1e12b423f..522e96a12 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -251,6 +251,10 @@ public class Launcher extends BaseActivity // 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 @@ public class Launcher extends BaseActivity mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); } + mOrientation = getResources().getConfiguration().orientation; mSharedPrefs = Utilities.getPrefs(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); mModel = app.setLauncher(this); @@ -1669,6 +1674,8 @@ public class Launcher extends BaseActivity 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 b65b74ea0..7fe130876 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java @@ -142,9 +142,8 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView 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 de424aba1..c2d550169 100644 --- a/src/com/android/launcher3/PendingAppWidgetHostView.java +++ b/src/com/android/launcher3/PendingAppWidgetHostView.java @@ -111,7 +111,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView } @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 f8d64984e..37ee6d751 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1213,7 +1213,7 @@ public class Workspace extends PagedView && 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/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java index d26f9f646..27a07c217 100644 --- a/src/com/android/launcher3/qsb/QsbContainerView.java +++ b/src/com/android/launcher3/qsb/QsbContainerView.java @@ -36,6 +36,7 @@ import android.widget.FrameLayout; 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; @@ -193,7 +194,8 @@ public class QsbContainerView extends FrameLayout { @Override public void onResume() { super.onResume(); - if (mQsb != null && mQsb.isReinflateRequired()) { + int orientation = Launcher.getLauncher(getContext()).getOrientation(); + if (mQsb != null && mQsb.isReinflateRequired(orientation)) { rebindFragment(); } } diff --git a/src/com/android/launcher3/qsb/QsbWidgetHostView.java b/src/com/android/launcher3/qsb/QsbWidgetHostView.java index 8b6fa1651..a8a41f664 100644 --- a/src/com/android/launcher3/qsb/QsbWidgetHostView.java +++ b/src/com/android/launcher3/qsb/QsbWidgetHostView.java @@ -47,9 +47,9 @@ public class QsbWidgetHostView extends AppWidgetHostView { } - 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; } -- cgit v1.2.3 From 11ee2f6e8fe4075856589fd5dd3e4b5ba326be2c Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 20 Sep 2017 10:18:41 -0700 Subject: Move orientation initialization to onCreate. Bug: 64916689 Change-Id: Iacc04dcc261fc049b83cb81792975414fb00b3cc --- src/com/android/launcher3/qsb/QsbContainerView.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java index 27a07c217..65acaa973 100644 --- a/src/com/android/launcher3/qsb/QsbContainerView.java +++ b/src/com/android/launcher3/qsb/QsbContainerView.java @@ -80,10 +80,15 @@ public class QsbContainerView extends FrameLayout { 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; @@ -194,8 +199,7 @@ public class QsbContainerView extends FrameLayout { @Override public void onResume() { super.onResume(); - int orientation = Launcher.getLauncher(getContext()).getOrientation(); - if (mQsb != null && mQsb.isReinflateRequired(orientation)) { + if (mQsb != null && mQsb.isReinflateRequired(mOrientation)) { rebindFragment(); } } -- cgit v1.2.3 From d772c0aece9a1d4239ec81c59007a41c0a5b5bb8 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Wed, 27 Sep 2017 13:03:20 -0700 Subject: Remove stateUnchanged flag from activity Bug: 65298313 Test: manual 1) Launch messages 2) Tap on FAB to compose new message, IME shows 3) Tap on Home button 4) Verify IME is hidden Change-Id: I1823e70d49921d2c66b5abd9ce5d45592bde923c --- AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7d65bdc0e..23bddf62f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -70,7 +70,7 @@ android:launchMode="singleTask" android:clearTaskOnLaunch="true" android:stateNotNeeded="true" - android:windowSoftInputMode="adjustPan|stateUnchanged" + android:windowSoftInputMode="adjustPan" android:screenOrientation="nosensor" android:configChanges="keyboard|keyboardHidden|navigation" android:resizeableActivity="true" -- cgit v1.2.3 From b808e1102f7f081da5af38fb8e065f9a0320e1bf Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 19 Sep 2017 12:05:54 -0700 Subject: Disabling state saving for search textbox as search results are not preserved across activity recreate Bug: 65661416 Change-Id: I0bd6414cea8d25b341374cd40ecaa270d5f19c18 (cherry picked from commit dee55f92ad3c74797a0e5689d526b1258a3d90b9) --- res/layout/search_container_all_apps.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/res/layout/search_container_all_apps.xml b/res/layout/search_container_all_apps.xml index c4305214d..fc07002cb 100644 --- a/res/layout/search_container_all_apps.xml +++ b/res/layout/search_container_all_apps.xml @@ -19,11 +19,11 @@ android:layout_width="match_parent" android:layout_height="@dimen/all_apps_search_bar_height" android:layout_gravity="center|top" + android:layout_marginBottom="-8dp" android:gravity="center|bottom" - android:saveEnabled="false" android:paddingLeft="@dimen/dynamic_grid_edge_margin" android:paddingRight="@dimen/dynamic_grid_edge_margin" - android:layout_marginBottom="-8dp" > + android:saveEnabled="false" >