From 7d121342404a75f5836b0498ab0654c8bc2ba212 Mon Sep 17 00:00:00 2001 From: Becky Qiu Date: Wed, 6 May 2020 15:04:23 -0700 Subject: [PATCH] [Overview Actions] Change actions view UI based on different nav modes. 1. Change the overview actions container to 66dp height. 2. For 3 button mode, container will have 8dp bottom margin. 3. For gesture mode, container will have 16dp bottom margin. 4. Action buttons and close button will always be in the center vertically. Spec: https://docs.google.com/presentation/d/1gXWNdCRXvXuEhgDmE0TX2KYqCxIQBXVtWKdl4pKrno8/edit#slide=id.g840c32b190_3_6 Demo: - 3 button: https://screenshot.googleplex.com/2Y3uMaJMi9E - gesture: https://screenshot.googleplex.com/XzaKHpp5ke9 Test: tested for both modes and when switch between. Bug: 155444592 Change-Id: If66d369df0218b7ee2abab8a3f345488bf223b16 --- .../states/OverviewModalTaskState.java | 2 +- .../quickstep/views/OverviewActionsView.java | 18 ++++++++++++++++++ quickstep/res/values/dimens.xml | 6 ++++-- .../launcher3/BaseQuickstepLauncher.java | 10 +++++++++- .../quickstep/util/WindowSizeStrategy.java | 16 +++++++++++++++- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java index 4e868b0c1b..a7e7d3a436 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java @@ -56,7 +56,7 @@ public class OverviewModalTaskState extends OverviewState { int taskHeight = out.height(); float topMargin = res.getDimension(R.dimen.task_thumbnail_top_margin); - float bottomMargin = res.getDimension(R.dimen.task_thumbnail_bottom_margin_with_actions); + float bottomMargin = res.getDimension(R.dimen.overview_actions_top_margin); float newHeight = taskHeight + topMargin + bottomMargin; float scale = newHeight / taskHeight; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java index 0af1c0ed36..7201b02ce0 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java @@ -31,6 +31,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.R; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.TaskOverlayFactory.OverlayUICallbacks; import java.lang.annotation.Retention; @@ -141,4 +142,21 @@ public class OverviewActionsView extends FrameLayo public AlphaProperty getVisibilityAlpha() { return mMultiValueAlpha.getProperty(INDEX_VISIBILITY_ALPHA); } + + /** Updates vertical margins for different navigation mode. */ + public void updateVerticalMarginForNavModeChange(Mode mode) { + int topMargin = getResources() + .getDimensionPixelSize(R.dimen.overview_actions_top_margin); + int bottomMargin = 0; + if (mode == Mode.THREE_BUTTONS) { + bottomMargin = getResources() + .getDimensionPixelSize(R.dimen.overview_actions_bottom_margin_three_button); + } else { + bottomMargin = getResources() + .getDimensionPixelSize(R.dimen.overview_actions_bottom_margin_gesture); + } + LayoutParams params = (LayoutParams) getLayoutParams(); + params.setMargins( + params.leftMargin, topMargin, params.rightMargin, bottomMargin); + } } diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index b06dc6b01d..5c306516c2 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -17,14 +17,16 @@ 24dp - 44dp 12dp 48dp 2dp - 110dp + 66dp + 44dp + 16dp + 8dp 16dp 10dp diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 10e3a28088..9d64d09cc8 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -92,6 +92,9 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override public void onNavigationModeChanged(Mode newMode) { getDragLayer().recreateControllers(); + if (mActionsView != null && isOverviewActionsEnabled()) { + mActionsView.updateVerticalMarginForNavModeChange(newMode); + } } @Override @@ -167,13 +170,18 @@ public abstract class BaseQuickstepLauncher extends Launcher mActionsView = findViewById(R.id.overview_actions_view); ((RecentsView) getOverviewPanel()).init(mActionsView); - if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(this)) { + if (isOverviewActionsEnabled()) { // Overview is above all other launcher elements, including qsb, so move it to the top. getOverviewPanel().bringToFront(); mActionsView.bringToFront(); + mActionsView.updateVerticalMarginForNavModeChange(SysUINavigationMode.getMode(this)); } } + private boolean isOverviewActionsEnabled() { + return FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(this); + } + public T getActionsView() { return (T) mActionsView; } diff --git a/quickstep/src/com/android/quickstep/util/WindowSizeStrategy.java b/quickstep/src/com/android/quickstep/util/WindowSizeStrategy.java index 8bb0d7094e..81a19247ed 100644 --- a/quickstep/src/com/android/quickstep/util/WindowSizeStrategy.java +++ b/quickstep/src/com/android/quickstep/util/WindowSizeStrategy.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.getMode; import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import static com.android.quickstep.util.LayoutUtils.getDefaultSwipeHeight; @@ -26,6 +27,7 @@ import android.graphics.Rect; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; +import com.android.quickstep.SysUINavigationMode.Mode; /** * Utility class to wrap different layout behavior for Launcher and RecentsView @@ -136,7 +138,19 @@ public abstract class WindowSizeStrategy { if (showOverviewActions(context)) { //TODO: this needs to account for the swipe gesture height and accessibility // UI when shown. - return res.getDimensionPixelSize(R.dimen.overview_actions_height); + float actionsBottomMargin = 0; + if (getMode(context) == Mode.THREE_BUTTONS) { + actionsBottomMargin = res.getDimensionPixelSize( + R.dimen.overview_actions_bottom_margin_three_button); + } else { + actionsBottomMargin = res.getDimensionPixelSize( + R.dimen.overview_actions_bottom_margin_gesture); + } + float actionsTopMargin = res.getDimensionPixelSize( + R.dimen.overview_actions_top_margin); + float actionsHeight = actionsTopMargin + actionsBottomMargin + + res.getDimensionPixelSize(R.dimen.overview_actions_height); + return actionsHeight; } else { return getDefaultSwipeHeight(context, dp) + dp.workspacePageIndicatorHeight + res.getDimensionPixelSize(