From 76cf236596d395d6936d37208bd99e46f89b4893 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 20 Mar 2018 14:13:16 -0700 Subject: [PATCH] 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 --- .../uioverrides/FastOverviewState.java | 2 +- .../launcher3/uioverrides/UiFactory.java | 23 +++++-------------- src/com/android/launcher3/LauncherState.java | 10 +++++++- .../launcher3/states/SpringLoadedState.java | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java index de056a7a1d..6543e8cf31 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java @@ -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; diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 49792ac256..5b54221486 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -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) { diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 9fef64ae1b..d5a2120912 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -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; diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java index 89a9e2d7d1..90d3821a30 100644 --- a/src/com/android/launcher3/states/SpringLoadedState.java +++ b/src/com/android/launcher3/states/SpringLoadedState.java @@ -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);