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

Commit 76cf2365 authored by Tony Wickham's avatar Tony Wickham
Browse files

Hide back button in drag-n-drop and quick scrub

Add a state flag to hide the back button, used by NORMAL, SPRING_LOADED,
and FAST_OVERVIEW states.

Bug: 74390697
Change-Id: Ifdb2aa41691db4594ea597fc5b5839967711b43d
parent ada91b94
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.quickstep.views.RecentsView;
public class FastOverviewState extends OverviewState {

    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_DISABLE_RESTORE
            | FLAG_DISABLE_INTERACTION | FLAG_OVERVIEW_UI;
            | FLAG_DISABLE_INTERACTION | FLAG_OVERVIEW_UI | FLAG_HIDE_BACK_BUTTON;

    private static final boolean DEBUG_DIFFERENT_UI = false;

+6 −17
Original line number Diff line number Diff line
@@ -16,16 +16,12 @@

package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherState.NORMAL;

import android.content.Context;
import android.view.View;
import android.view.View.AccessibilityDelegate;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsModel;
@@ -59,22 +55,15 @@ public class UiFactory {
    }

    public static void onLauncherStateOrFocusChanged(Launcher launcher) {
        boolean shouldBackButtonBeVisible = launcher == null
                || !launcher.isInState(NORMAL)
                || !launcher.hasWindowFocus();
        if (!shouldBackButtonBeVisible) {
        boolean shouldBackButtonBeHidden = launcher != null
                && launcher.getStateManager().getState().hideBackButton
                && launcher.hasWindowFocus();
        if (shouldBackButtonBeHidden) {
            // Show the back button if there is a floating view visible.
            DragLayer dragLayer = launcher.getDragLayer();
            for (int i = dragLayer.getChildCount() - 1; i >= 0; i--) {
                View child = dragLayer.getChildAt(i);
                if (child instanceof AbstractFloatingView) {
                    shouldBackButtonBeVisible = true;
                    break;
                }
            }
            shouldBackButtonBeHidden = AbstractFloatingView.getTopOpenView(launcher) == null;
        }
        OverviewInteractionState.getInstance(launcher)
                .setBackButtonVisible(shouldBackButtonBeVisible);
                .setBackButtonVisible(!shouldBackButtonBeHidden);
    }

    public static void resetOverview(Launcher launcher) {
+9 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public class LauncherState {
    protected static final int FLAG_ALL_APPS_SCRIM = 1 << 7;
    protected static final int FLAG_DISABLE_INTERACTION = 1 << 8;
    protected static final int FLAG_OVERVIEW_UI = 1 << 9;
    protected static final int FLAG_HIDE_BACK_BUTTON = 1 << 10;

    protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER =
            new PageAlphaProvider(ACCEL_2) {
@@ -75,7 +76,7 @@ public class LauncherState {
     * TODO: Create a separate class for NORMAL state.
     */
    public static final LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE,
            0, FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED);
            0, FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON);

    /**
     * Various Launcher states arranged in the increasing order of UI layers
@@ -140,6 +141,12 @@ public class LauncherState {
     */
    public final boolean overviewUi;

    /**
     * True if the back button should be hidden when in this state (assuming no floating views are
     * open, launcher has window focus, etc).
     */
    public final boolean hideBackButton;

    public LauncherState(int id, int containerType, int transitionDuration, int flags) {
        this.containerType = containerType;
        this.transitionDuration = transitionDuration;
@@ -157,6 +164,7 @@ public class LauncherState {
        this.disablePageClipping = (flags & FLAG_DISABLE_PAGE_CLIPPING) != 0;
        this.disableInteraction = (flags & FLAG_DISABLE_INTERACTION) != 0;
        this.overviewUi = (flags & FLAG_OVERVIEW_UI) != 0;
        this.hideBackButton = (flags & FLAG_HIDE_BACK_BUTTON) != 0;

        this.ordinal = id;
        sAllStates[id] = this;
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class SpringLoadedState extends LauncherState {

    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE |
            FLAG_DISABLE_ACCESSIBILITY | FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED |
            FLAG_DISABLE_PAGE_CLIPPING | FLAG_PAGE_BACKGROUNDS;
            FLAG_DISABLE_PAGE_CLIPPING | FLAG_PAGE_BACKGROUNDS | FLAG_HIDE_BACK_BUTTON;

    public SpringLoadedState(int id) {
        super(id, ContainerType.OVERVIEW, SPRING_LOADED_TRANSITION_MS, STATE_FLAGS);