Merge "Hide back button in drag-n-drop and quick scrub" into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
index de056a7..6543e8c 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
@@ -26,7 +26,7 @@
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 49792ac..5b54221 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 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 9fef64a..d5a2120 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -60,6 +60,7 @@
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 @@
* 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 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 @@
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 89a9e2d..90d3821 100644
--- a/src/com/android/launcher3/states/SpringLoadedState.java
+++ b/src/com/android/launcher3/states/SpringLoadedState.java
@@ -35,7 +35,7 @@
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);