From 04fca1642ce859bb0f6b7fc7a806f469e6390303 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 5 Feb 2020 15:06:52 -0800 Subject: [PATCH] Separate 2-button mode check from ENABLE_OVERVIEW_ACTIONS This will allow us to cleanly remove ENABLE_OVERVIEW_ACTIONS while still keeping the shelf instead of actions in 2-button mode. Bug: 143361609 Change-Id: I5cd43b6d3daeb527c7787b1cb81fae9179d8911c --- .../uioverrides/states/OverviewState.java | 7 ++++-- .../android/quickstep/views/RecentsView.java | 2 +- .../com/android/quickstep/views/TaskView.java | 16 ++++++------ .../launcher3/BaseQuickstepLauncher.java | 12 +++++++++ .../QuickstepProcessInitializer.java | 25 ++----------------- .../quickstep/SysUINavigationMode.java | 6 +++++ .../android/quickstep/util/LayoutUtils.java | 15 +++++------ .../quickstep/views/ShelfScrimView.java | 3 ++- src/com/android/launcher3/Launcher.java | 7 +----- src/com/android/launcher3/LauncherState.java | 11 ++++++-- 10 files changed, 55 insertions(+), 49 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java index 644cfcb3a5..a1c837861d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -33,6 +33,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; +import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import android.graphics.Rect; import android.view.View; @@ -125,7 +126,8 @@ public class OverviewState extends LauncherState { @Override public ScaleAndTranslation getQsbScaleAndTranslation(Launcher launcher) { - if (this == OVERVIEW && ENABLE_OVERVIEW_ACTIONS.get()) { + if (this == OVERVIEW && ENABLE_OVERVIEW_ACTIONS.get() + && removeShelfFromOverview(launcher)) { // Treat the QSB as part of the hotseat so they move together. return getHotseatScaleAndTranslation(launcher); } @@ -158,7 +160,7 @@ public class OverviewState extends LauncherState { if (launcher.getDeviceProfile().isVerticalBarLayout()) { return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON; } else { - if (ENABLE_OVERVIEW_ACTIONS.get()) { + if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(launcher)) { return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON; } @@ -229,6 +231,7 @@ public class OverviewState extends LauncherState { builder.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2); builder.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2); Interpolator translationInterpolator = ENABLE_OVERVIEW_ACTIONS.get() + && removeShelfFromOverview(launcher) ? OVERSHOOT_1_2 : OVERSHOOT_1_7; builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, translationInterpolator); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index c1ea533b2d..aaba308c0e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -346,7 +346,7 @@ public abstract class RecentsView extends PagedView impl setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); mTaskTopMargin = getResources() .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); - mTaskBottomMargin = LayoutUtils.thumbnailBottomMargin(getResources()); + mTaskBottomMargin = LayoutUtils.thumbnailBottomMargin(context); mSquaredTouchSlop = squaredTouchSlop(context); mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index 5954b86446..294bb7b564 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -22,6 +22,7 @@ import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LA import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; +import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -30,7 +31,6 @@ import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.app.ActivityOptions; import android.content.Context; -import android.content.res.Resources; import android.graphics.Outline; import android.graphics.Rect; import android.graphics.RectF; @@ -221,7 +221,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mCurrentFullscreenParams = new FullscreenDrawParams(mCornerRadius); mDigitalWellBeingToast = new DigitalWellBeingToast(mActivity, this); - mOutlineProvider = new TaskOutlineProvider(getResources(), mCurrentFullscreenParams); + mOutlineProvider = new TaskOutlineProvider(getContext(), mCurrentFullscreenParams); setOutlineProvider(mOutlineProvider); } @@ -230,13 +230,14 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { super.onFinishInflate(); mSnapshotView = findViewById(R.id.snapshot); mIconView = findViewById(R.id.icon); + final Context context = getContext(); TaskView.LayoutParams thumbnailParams = (LayoutParams) mSnapshotView.getLayoutParams(); - thumbnailParams.bottomMargin = LayoutUtils.thumbnailBottomMargin(getResources()); + thumbnailParams.bottomMargin = LayoutUtils.thumbnailBottomMargin(context); mSnapshotView.setLayoutParams(thumbnailParams); - if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) { + if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(context)) { mActionsView = mSnapshotView.getTaskOverlay().getActionsView(); if (mActionsView != null) { TaskView.LayoutParams params = new TaskView.LayoutParams(LayoutParams.MATCH_PARENT, @@ -679,9 +680,10 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { private final int mMarginBottom; private FullscreenDrawParams mFullscreenParams; - TaskOutlineProvider(Resources res, FullscreenDrawParams fullscreenParams) { - mMarginTop = res.getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); - mMarginBottom = LayoutUtils.thumbnailBottomMargin(res); + TaskOutlineProvider(Context context, FullscreenDrawParams fullscreenParams) { + mMarginTop = context.getResources().getDimensionPixelSize( + R.dimen.task_thumbnail_top_margin); + mMarginBottom = LayoutUtils.thumbnailBottomMargin(context); mFullscreenParams = fullscreenParams; } diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index ee53386f50..94ff63b5f7 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -25,6 +25,7 @@ import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_COUNT; import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN; import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_COUNT; import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_SEEN; +import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import android.animation.AnimatorSet; import android.animation.ValueAnimator; @@ -35,6 +36,7 @@ import android.os.CancellationSignal; import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.LauncherStateManager.StateHandler; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.WellbeingModel; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.proxy.ProxyActivityStarter; @@ -186,6 +188,16 @@ public abstract class BaseQuickstepLauncher extends Launcher } } + @Override + protected void setupViews() { + super.setupViews(); + + if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(this)) { + // Overview is above all other launcher elements, including qsb, so move it to the top. + getOverviewPanel().bringToFront(); + } + } + @Override protected StateHandler[] createStateHandlers() { return new StateHandler[] { diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java index 9817e32ae9..32268a49b5 100644 --- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java +++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java @@ -15,11 +15,6 @@ */ package com.android.quickstep; -import static android.content.Context.MODE_PRIVATE; - -import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; -import static com.android.launcher3.config.FeatureFlags.FLAGS_PREF_NAME; - import android.content.Context; import android.content.pm.PackageManager; import android.os.UserManager; @@ -27,7 +22,6 @@ import android.util.Log; import com.android.launcher3.BuildConfig; import com.android.launcher3.MainProcessInitializer; -import com.android.launcher3.config.FeatureFlags; import com.android.systemui.shared.system.ThreadedRendererCompat; @SuppressWarnings("unused") @@ -55,22 +49,7 @@ public class QuickstepProcessInitializer extends MainProcessInitializer { super.init(context); // Elevate GPU priority for Quickstep and Remote animations. - ThreadedRendererCompat.setContextPriority(ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG); - - // Force disable some feature flags based on the system ui navigation mode. - SysUINavigationMode.Mode currMode = SysUINavigationMode.INSTANCE.get(context) - .addModeChangeListener(mode -> disableFeatureFlagsForSysuiNavMode(context, mode)); - disableFeatureFlagsForSysuiNavMode(context, currMode); - } - - private void disableFeatureFlagsForSysuiNavMode(Context ctx, SysUINavigationMode.Mode mode) { - if (mode == SysUINavigationMode.Mode.TWO_BUTTONS) { - ctx.getSharedPreferences(FLAGS_PREF_NAME, MODE_PRIVATE) - .edit() - .putBoolean(ENABLE_OVERVIEW_ACTIONS.key, false) - .apply(); - - FeatureFlags.initialize(ctx); - } + ThreadedRendererCompat.setContextPriority( + ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG); } } diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java index 388b323a50..375e589603 100644 --- a/quickstep/src/com/android/quickstep/SysUINavigationMode.java +++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java @@ -122,6 +122,12 @@ public class SysUINavigationMode { } } + /** @return Whether we can remove the shelf from overview. */ + public static boolean removeShelfFromOverview(Context context) { + // The shelf is core to the two-button mode model, so we need to continue supporting it. + return getMode(context) != Mode.TWO_BUTTONS; + } + public interface NavigationModeChangeListener { void onNavigationModeChanged(Mode newMode); diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index b249f48389..9cf55b3e76 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -16,6 +16,7 @@ package com.android.quickstep.util; import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; +import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -59,7 +60,7 @@ public class LayoutUtils { } else { Resources res = context.getResources(); - if (ENABLE_OVERVIEW_ACTIONS.get()) { + if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(context)) { //TODO: this needs to account for the swipe gesture height and accessibility // UI when shown. extraSpace = 0; @@ -112,7 +113,7 @@ public class LayoutUtils { final int paddingResId; if (dp.isVerticalBarLayout()) { paddingResId = R.dimen.landscape_task_card_horz_space; - } else if (ENABLE_OVERVIEW_ACTIONS.get()) { + } else if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(context)) { paddingResId = R.dimen.portrait_task_card_horz_space_big_overview; } else { paddingResId = R.dimen.portrait_task_card_horz_space; @@ -121,7 +122,7 @@ public class LayoutUtils { } float topIconMargin = res.getDimension(R.dimen.task_thumbnail_top_margin); - float bottomMargin = thumbnailBottomMargin(res); + float bottomMargin = thumbnailBottomMargin(context); float paddingVert = res.getDimension(R.dimen.task_card_vert_space); // Note this should be same as dp.availableWidthPx and dp.availableHeightPx unless @@ -147,7 +148,7 @@ public class LayoutUtils { public static int getShelfTrackingDistance(Context context, DeviceProfile dp) { // Track the bottom of the window. - if (ENABLE_OVERVIEW_ACTIONS.get()) { + if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(context)) { Rect taskSize = new Rect(); calculateLauncherTaskSize(context, dp, taskSize); return (dp.heightPx - taskSize.height()) / 2; @@ -162,9 +163,9 @@ public class LayoutUtils { * Get the margin that the task thumbnail view should use. * @return the margin in pixels. */ - public static int thumbnailBottomMargin(Resources resources) { - if (ENABLE_OVERVIEW_ACTIONS.get()) { - return resources.getDimensionPixelSize(R.dimen.overview_actions_height); + public static int thumbnailBottomMargin(Context context) { + if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(context)) { + return context.getResources().getDimensionPixelSize(R.dimen.overview_actions_height); } else { return 0; } diff --git a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java index 7ed1e21dfb..1ce3549f39 100644 --- a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java +++ b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java @@ -160,7 +160,8 @@ public class ShelfScrimView extends ScrimView Context context = getContext(); if ((OVERVIEW.getVisibleElements(mLauncher) & ALL_APPS_HEADER_EXTRA) == 0) { mDragHandleProgress = 1; - if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) { + if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() + && SysUINavigationMode.removeShelfFromOverview(context)) { // Fade in all apps background quickly to distinguish from swiping from nav bar. mMidAlpha = Themes.getAttrInteger(context, R.attr.allAppsInterimScrimAlpha); mMidProgress = OverviewState.getDefaultVerticalProgress(mLauncher); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 43540cec72..d2506588e1 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1138,7 +1138,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, /** * Finds all the views we need and configure them properly. */ - private void setupViews() { + protected void setupViews() { mDragLayer = findViewById(R.id.drag_layer); mFocusHandler = mDragLayer.getFocusIndicatorHelper(); mWorkspace = mDragLayer.findViewById(R.id.workspace); @@ -1174,11 +1174,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mDropTargetBar.setup(mDragController); mAllAppsController.setupViews(mAppsView); - - if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) { - // Overview is above all other launcher elements, including qsb, so move it to the top. - mOverviewPanel.bringToFront(); - } } /** diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 7e06099451..16be391891 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -41,8 +41,10 @@ import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL; import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL; import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORDINAL; +import android.view.View; import android.view.animation.Interpolator; +import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.states.HintState; import com.android.launcher3.states.SpringLoadedState; @@ -337,8 +339,13 @@ public abstract class LauncherState { hotseat.setScaleX(0.92f); hotseat.setScaleY(0.92f); if (ENABLE_OVERVIEW_ACTIONS.get()) { - launcher.getAppsView().setScaleX(0.92f); - launcher.getAppsView().setScaleY(0.92f); + AllAppsContainerView qsbContainer = launcher.getAppsView(); + View qsb = qsbContainer.getSearchView(); + boolean qsbVisible = qsb.getVisibility() == VISIBLE && qsb.getAlpha() > 0; + if (!qsbVisible) { + qsbContainer.setScaleX(0.92f); + qsbContainer.setScaleY(0.92f); + } } } } else if (this == NORMAL && fromState == OVERVIEW_PEEK) {