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

Commit e39690b2 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Launching last task when back button is pressed in overview

Bug: 111158326
Change-Id: Ib38f12f177780d15dbee69e4a27c21aaa9a3e087
parent 0b74a7fe
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;

/**
 * Definition for overview state
@@ -130,4 +131,14 @@ public class OverviewState extends LauncherState {
        DeviceProfile dp = launcher.getDeviceProfile();
        return dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
    }

    @Override
    public void onBackPressed(Launcher launcher) {
        TaskView taskView = launcher.<RecentsView>getOverviewPanel().getRunningTaskView();
        if (taskView != null) {
            taskView.launchTask(true);
        } else {
            super.onBackPressed(launcher);
        }
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -714,12 +714,16 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        setCurrentTask(runningTaskId);
    }

    public TaskView getRunningTaskView() {
        return getTaskView(mRunningTaskId);
    }

    /**
     * Hides the tile associated with {@link #mRunningTaskId}
     */
    public void setRunningTaskHidden(boolean isHidden) {
        mRunningTaskTileHidden = isHidden;
        TaskView runningTask = getTaskView(mRunningTaskId);
        TaskView runningTask = getRunningTaskView();
        if (runningTask != null) {
            runningTask.setAlpha(isHidden ? 0 : mContentAlpha);
        }
@@ -745,7 +749,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
    }

    public void showNextTask() {
        TaskView runningTaskView = getTaskView(mRunningTaskId);
        TaskView runningTaskView = getRunningTaskView();
        if (runningTaskView == null) {
            // Launch the first task
            if (getTaskViewCount() > 0) {
@@ -773,7 +777,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
    }

    private void applyRunningTaskIconScale() {
        TaskView firstTask = getTaskView(mRunningTaskId);
        TaskView firstTask = getRunningTaskView();
        if (firstTask != null) {
            firstTask.setIconScaleAndDim(mRunningTaskIconScaledDown ? 0 : 1);
        }
@@ -781,7 +785,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl

    public void animateUpRunningTaskIconScale() {
        mRunningTaskIconScaledDown = false;
        TaskView firstTask = getTaskView(mRunningTaskId);
        TaskView firstTask = getRunningTaskView();
        if (firstTask != null) {
            firstTask.animateIconScaleAndDimIntoView();
        }
+1 −7
Original line number Diff line number Diff line
@@ -1606,14 +1606,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
        if (topView != null && topView.onBackPressed()) {
            // Handled by the floating view.
        } else if (!isInState(NORMAL)) {
            LauncherState lastState = mStateManager.getLastState();
            ued.logActionCommand(Action.Command.BACK, mStateManager.getState().containerType,
                    lastState.containerType);
            mStateManager.goToState(lastState);
        } else {
            // Back button is a no-op here, but give at least some feedback for the button press
            mWorkspace.showOutlinesTemporarily();
            mStateManager.getState().onBackPressed(this);
        }
    }

+11 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.launcher3.uioverrides.AllAppsState;
import com.android.launcher3.uioverrides.FastOverviewState;
import com.android.launcher3.uioverrides.OverviewState;
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;

import java.util.Arrays;
@@ -251,6 +252,16 @@ public class LauncherState {
        }
    }

    public void onBackPressed(Launcher launcher) {
        if (this != NORMAL) {
            LauncherStateManager lsm = launcher.getStateManager();
            LauncherState lastState = lsm.getLastState();
            launcher.getUserEventDispatcher().logActionCommand(Action.Command.BACK,
                    containerType, lastState.containerType);
            lsm.goToState(lastState);
        }
    }

    protected static void dispatchWindowStateChanged(Launcher launcher) {
        launcher.getWindow().getDecorView().sendAccessibilityEvent(TYPE_WINDOW_STATE_CHANGED);
    }
+0 −6
Original line number Diff line number Diff line
@@ -1291,12 +1291,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
        }
    }

    public void showOutlinesTemporarily() {
        if (!mIsPageInTransition && !isTouchActive()) {
            snapToPage(mCurrentPage);
        }
    }

    private void updatePageAlphaValues() {
        // We need to check the isDragging case because updatePageAlphaValues is called between
        // goToState(SPRING_LOADED) and onStartStateTransition.