From 44d0b5355d2dd39f6d1b0349bc3685ec4573a04a Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 14 Mar 2016 14:08:12 -0700 Subject: [PATCH] Closing folder in onSaveInstanceState folderInfo.isOpened is part of static model, where is the open folder state is part of the UI. This resets the static model, when the UI is about to be reset This also causes the folders to get closed when launcher gets hidden Partial revert of: Ie1318b82b497957b99603b11ec338dd50d51b962 Bug: 27596291, 24900496, 27624924 Change-Id: I30c2bb99a19fdd95a1b997d07066f80be812e2c0 --- src/com/android/launcher3/Launcher.java | 29 ++++--------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c8eb9cc56a..e411527522 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -184,8 +184,6 @@ public class Launcher extends Activity private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen"; // Type: int private static final String RUNTIME_STATE = "launcher.state"; - // Type: long - private static final String RUNTIME_STATE_OPEN_FOLDER_ID = "launcher.open_folder_id"; // Type: Content Values / parcelable private static final String RUNTIME_STATE_PENDING_ADD_ITEM = "launcher.add_item"; // Type: parcelable @@ -1956,10 +1954,10 @@ public class Launcher extends Activity super.onSaveInstanceState(outState); outState.putInt(RUNTIME_STATE, mState.ordinal()); - Folder openFolder = mWorkspace.getOpenFolder(); - if (openFolder != null) { - outState.putLong(RUNTIME_STATE_OPEN_FOLDER_ID, openFolder.mInfo.id); - } + // We close any open folder since it will not be re-opened, and we need to make sure + // this state is reflected. + // TODO: Move folderInfo.isOpened out of the model and make it a UI state. + closeFolder(false); if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 && mWaitingForResult) { @@ -4148,25 +4146,6 @@ public class Launcher extends Activity mWorkspace.getChildAt(mWorkspace.getCurrentPage()).requestFocus(); } - long folderId = mSavedState.getLong(RUNTIME_STATE_OPEN_FOLDER_ID); - if (folderId != 0) { - View view = mWorkspace.getHomescreenIconByItemId(folderId); - if (view instanceof FolderIcon) { - FolderIcon icon = (FolderIcon) view; - FolderInfo info = icon.getFolderInfo(); - long currentScreenId = mWorkspace.getScreenIdForPageIndex( - mWorkspace.getNextPage()); - if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT - || info.screenId == currentScreenId) { - // We can show the folder - openFolder(icon, false); - } else { - Launcher.addDumpLog(TAG, "Saved state contains folder " + info + - " but current screen is " + currentScreenId); - } - } - } - mSavedState = null; }