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

Commit 9b1d362f authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Keeping Launcher in overview UI if activity is restarting due to UI mode changes"

parents d0ae95aa 6c0c61ac
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3;

import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
import static android.content.pm.ActivityInfo.CONFIG_UI_MODE;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;

@@ -1136,7 +1137,11 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        int stateOrdinal = savedState.getInt(RUNTIME_STATE, NORMAL.ordinal);
        LauncherState[] stateValues = LauncherState.values();
        LauncherState state = stateValues[stateOrdinal];
        if (!state.shouldDisableRestore()) {

        NonConfigInstance lastInstance = (NonConfigInstance) getLastNonConfigurationInstance();
        boolean forceRestore = lastInstance != null
                && (lastInstance.config.diff(mOldConfig) & CONFIG_UI_MODE) != 0;
        if (forceRestore || !state.shouldDisableRestore()) {
            mStateManager.goToState(state, false /* animated */);
        }

@@ -1375,15 +1380,18 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche

    @Override
    public Object onRetainNonConfigurationInstance() {
        NonConfigInstance instance = new NonConfigInstance();
        instance.config = new Configuration(mOldConfig);

        int width = mDragLayer.getWidth();
        int height = mDragLayer.getHeight();

        // TODO: b/172467144 Remove hardcoded ENABLE_ACTIVITY_CROSSFADE.
        if (!ENABLE_ACTIVITY_CROSSFADE || width <= 0 || height <= 0) {
            return null;
        if (ENABLE_ACTIVITY_CROSSFADE && width > 0 && height > 0) {
            instance.snapshot =
                    BitmapRenderer.createHardwareBitmap(width, height, mDragLayer::draw);
        }

        return BitmapRenderer.createHardwareBitmap(width, height, mDragLayer::draw);
        return instance;
    }

    public AllAppsTransitionController getAllAppsController() {
@@ -2786,15 +2794,14 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
     * updates.
     */
    private void crossFadeWithPreviousAppearance() {
        Bitmap previousAppearanceBitmap = (Bitmap) getLastNonConfigurationInstance();
        NonConfigInstance lastInstance = (NonConfigInstance) getLastNonConfigurationInstance();

        if (previousAppearanceBitmap == null) {
        if (lastInstance == null || lastInstance.snapshot == null) {
            return;
        }

        ImageView crossFadeHelper = new ImageView(this);

        crossFadeHelper.setImageBitmap(previousAppearanceBitmap);
        crossFadeHelper.setImageBitmap(lastInstance.snapshot);
        crossFadeHelper.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);

        InsettableFrameLayout.LayoutParams layoutParams = new InsettableFrameLayout.LayoutParams(
@@ -2814,4 +2821,9 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
                .withEndAction(() -> getRootView().removeView(crossFadeHelper))
                .start();
    }

    private static class NonConfigInstance {
        public Configuration config;
        public Bitmap snapshot;
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -121,7 +121,9 @@ public abstract class StatefulActivity<STATE_TYPE extends BaseState<STATE_TYPE>>
        final int origDragLayerChildCount = dragLayer.getChildCount();
        super.onStop();

        if (!isChangingConfigurations()) {
            getStateManager().moveToRestState();
        }

        // Workaround for b/78520668, explicitly trim memory once UI is hidden
        onTrimMemory(TRIM_MEMORY_UI_HIDDEN);