Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44d0b535 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

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
parent 0da3bc6c
Loading
Loading
Loading
Loading
+4 −25
Original line number Diff line number Diff line
@@ -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;
        }