From 514dfa2deb3f3758afd29efdd1a7b83b9333e173 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 26 Mar 2020 15:28:36 -0700 Subject: [PATCH] Changing actions button visibility to match clear-all button > Removing translation when animating actions button Change-Id: I6875e03f9c55f00232c605743348175ea132cb15 --- .../RecentsViewStateController.java | 27 ++++++++---- .../states/BackgroundAppState.java | 2 +- .../uioverrides/states/OverviewPeekState.java | 4 ++ .../uioverrides/states/OverviewState.java | 8 ++-- .../quickstep/views/LauncherRecentsView.java | 4 +- .../launcher3/BaseQuickstepLauncher.java | 13 +++++- .../BaseRecentsViewStateController.java | 44 +++++-------------- src/com/android/launcher3/Launcher.java | 6 --- src/com/android/launcher3/LauncherState.java | 2 +- 9 files changed, 53 insertions(+), 57 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index 549187f9e9..131b71fc53 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -15,18 +15,22 @@ */ package com.android.launcher3.uioverrides; -import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON; +import static com.android.launcher3.LauncherState.OVERVIEW_BUTTONS; +import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE; import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA; import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS; import android.annotation.TargetApi; import android.os.Build; import android.util.FloatProperty; +import android.view.View; +import android.view.animation.Interpolator; import androidx.annotation.NonNull; -import com.android.launcher3.Launcher; +import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.LauncherState; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.PendingAnimation; @@ -44,7 +48,7 @@ import com.android.quickstep.views.RecentsView; public final class RecentsViewStateController extends BaseRecentsViewStateController { - public RecentsViewStateController(Launcher launcher) { + public RecentsViewStateController(BaseQuickstepLauncher launcher) { super(launcher); } @@ -55,7 +59,7 @@ public final class RecentsViewStateController extends mRecentsView.updateEmptyMessage(); mRecentsView.resetTaskVisuals(); } - setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state.getVisibleElements(mLauncher)); + setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state, LINEAR); mRecentsView.setFullscreenProgress(state.getOverviewFullscreenProgress()); } @@ -73,15 +77,22 @@ public final class RecentsViewStateController extends AnimationSuccessListener.forRunnable(mRecentsView::resetTaskVisuals)); } - setAlphas(builder, toState.getVisibleElements(mLauncher)); + setAlphas(builder, toState, + config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT)); builder.setFloat(mRecentsView, FULLSCREEN_PROGRESS, toState.getOverviewFullscreenProgress(), LINEAR); } - private void setAlphas(PropertySetter propertySetter, int visibleElements) { - boolean hasClearAllButton = (visibleElements & RECENTS_CLEAR_ALL_BUTTON) != 0; + private void setAlphas(PropertySetter propertySetter, LauncherState state, + Interpolator actionInterpolator) { + float buttonAlpha = (state.getVisibleElements(mLauncher) & OVERVIEW_BUTTONS) != 0 ? 1 : 0; propertySetter.setFloat(mRecentsView.getClearAllButton(), ClearAllButton.VISIBILITY_ALPHA, - hasClearAllButton ? 1f : 0f, LINEAR); + buttonAlpha, LINEAR); + + View actionsView = mLauncher.getActionsView(); + if (actionsView != null) { + propertySetter.setViewAlpha(actionsView, buttonAlpha, actionInterpolator); + } } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index de3fce13ce..a87d6d14d6 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -90,7 +90,7 @@ public class BackgroundAppState extends OverviewState { @Override public int getVisibleElements(Launcher launcher) { return super.getVisibleElements(launcher) - & ~RECENTS_CLEAR_ALL_BUTTON & ~VERTICAL_SWIPE_INDICATOR; + & ~OVERVIEW_BUTTONS & ~VERTICAL_SWIPE_INDICATOR; } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java index 8087611633..1288e7bf9b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java @@ -25,6 +25,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TR import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.states.StateAnimationConfig; public class OverviewPeekState extends OverviewState { @@ -37,6 +38,9 @@ public class OverviewPeekState extends OverviewState { ScaleAndTranslation result = super.getOverviewScaleAndTranslation(launcher); result.translationX = NORMAL.getOverviewScaleAndTranslation(launcher).translationX - launcher.getResources().getDimension(R.dimen.overview_peek_distance); + if (Utilities.isRtl(launcher.getResources())) { + result.translationX = -result.translationX; + } return result; } 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 bb18340cad..bcfb11c090 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 @@ -165,14 +165,14 @@ public class OverviewState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(launcher)) { - return RECENTS_CLEAR_ALL_BUTTON; + return OVERVIEW_BUTTONS; } else if (launcher.getDeviceProfile().isVerticalBarLayout()) { - return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON; + return VERTICAL_SWIPE_INDICATOR | OVERVIEW_BUTTONS; } else { boolean hasAllAppsHeaderExtra = launcher.getAppsView() != null && launcher.getAppsView().getFloatingHeaderView().hasVisibleContent(); - return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON | - (hasAllAppsHeaderExtra ? ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS); + return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR | OVERVIEW_BUTTONS + | (hasAllAppsHeaderExtra ? ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java index 24703bda4a..e62de186f8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java @@ -19,7 +19,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; -import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON; +import static com.android.launcher3.LauncherState.OVERVIEW_BUTTONS; import static com.android.launcher3.LauncherState.SPRING_LOADED; import static com.android.launcher3.QuickstepAppTransitionManagerImpl.ALL_APPS_PROGRESS_OFF_SCREEN; import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS; @@ -323,7 +323,7 @@ public class LauncherRecentsView extends RecentsView if (enabled) { LauncherState state = mActivity.getStateManager().getState(); boolean hasClearAllButton = (state.getVisibleElements(mActivity) - & RECENTS_CLEAR_ALL_BUTTON) != 0; + & OVERVIEW_BUTTONS) != 0; setDisallowScrollToClearAll(!hasClearAllButton); } } diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 83c67bb5da..135daef6bd 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -34,6 +34,7 @@ import android.content.Intent; import android.content.IntentSender; import android.os.Bundle; import android.os.CancellationSignal; +import android.view.View; import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.LauncherStateManager.StateHandler; @@ -80,6 +81,8 @@ public abstract class BaseQuickstepLauncher extends Launcher private final ShelfPeekAnim mShelfPeekAnim = new ShelfPeekAnim(this); + private View mActionsView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -224,16 +227,22 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override protected void setupViews() { super.setupViews(); + mActionsView = findViewById(R.id.overview_actions_view); + 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(); - if (getActionsView() != null) { - getActionsView().bringToFront(); + if (mActionsView != null) { + mActionsView.bringToFront(); } } } + public View getActionsView() { + return mActionsView; + } + @Override protected void closeOpenViews(boolean animate) { super.closeOpenViews(animate); diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index 03454f77f8..123c988a04 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -17,7 +17,6 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; -import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT; @@ -34,11 +33,10 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import android.util.FloatProperty; import android.view.View; -import android.view.animation.Interpolator; import androidx.annotation.NonNull; -import com.android.launcher3.Launcher; +import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.LauncherStateManager.StateHandler; @@ -55,13 +53,11 @@ import com.android.launcher3.states.StateAnimationConfig; public abstract class BaseRecentsViewStateController implements StateHandler { protected final T mRecentsView; - protected final Launcher mLauncher; - protected final View mActionsView; + protected final BaseQuickstepLauncher mLauncher; - public BaseRecentsViewStateController(@NonNull Launcher launcher) { + public BaseRecentsViewStateController(@NonNull BaseQuickstepLauncher launcher) { mLauncher = launcher; mRecentsView = launcher.getOverviewPanel(); - mActionsView = launcher.getActionsView(); } @Override @@ -69,19 +65,12 @@ public abstract class BaseRecentsViewStateController ScaleAndTranslation scaleAndTranslation = state .getOverviewScaleAndTranslation(mLauncher); SCALE_PROPERTY.set(mRecentsView, scaleAndTranslation.scale); - float translationX = scaleAndTranslation.translationX; - if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { - translationX = -translationX; - } - mRecentsView.setTranslationX(translationX); + mRecentsView.setTranslationX(scaleAndTranslation.translationX); mRecentsView.setTranslationY(scaleAndTranslation.translationY); + getContentAlphaProperty().set(mRecentsView, state.overviewUi ? 1f : 0); OverviewScrim scrim = mLauncher.getDragLayer().getOverviewScrim(); SCRIM_PROGRESS.set(scrim, state.getOverviewScrimAlpha(mLauncher)); - if (mActionsView != null) { - mActionsView.setTranslationX(translationX); - mActionsView.setAlpha(state.overviewUi ? 1f : 0); - } } @Override @@ -107,29 +96,18 @@ public abstract class BaseRecentsViewStateController void setStateWithAnimationInternal(@NonNull final LauncherState toState, @NonNull StateAnimationConfig config, @NonNull PendingAnimation setter) { ScaleAndTranslation scaleAndTranslation = toState.getOverviewScaleAndTranslation(mLauncher); - Interpolator scaleInterpolator = config.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR); - setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndTranslation.scale, scaleInterpolator); - Interpolator translateXInterpolator = config.getInterpolator( - ANIM_OVERVIEW_TRANSLATE_X, LINEAR); - Interpolator translateYInterpolator = config.getInterpolator( - ANIM_OVERVIEW_TRANSLATE_Y, LINEAR); - float translationX = scaleAndTranslation.translationX; - if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { - translationX = -translationX; - } - setter.setFloat(mRecentsView, VIEW_TRANSLATE_X, translationX, translateXInterpolator); + setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndTranslation.scale, + config.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR)); + setter.setFloat(mRecentsView, VIEW_TRANSLATE_X, scaleAndTranslation.translationX, + config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR)); setter.setFloat(mRecentsView, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, - translateYInterpolator); + config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR)); + setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0, config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT)); OverviewScrim scrim = mLauncher.getDragLayer().getOverviewScrim(); setter.setFloat(scrim, SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher), config.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR)); - if (mActionsView != null) { - setter.setFloat(mActionsView, VIEW_TRANSLATE_X, translationX, translateXInterpolator); - setter.setFloat(mActionsView, VIEW_ALPHA, toState.overviewUi ? 1 : 0, - config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT)); - } } /** diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c00a6790df..5b9f676bbd 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -271,7 +271,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, // UI and state for the overview panel private View mOverviewPanel; - private View mActionsView; @Thunk boolean mWorkspaceLoading = true; @@ -1166,7 +1165,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mWorkspace = mDragLayer.findViewById(R.id.workspace); mWorkspace.initParentViews(mDragLayer); mOverviewPanel = findViewById(R.id.overview_panel); - mActionsView = findViewById(R.id.overview_actions_view); mHotseat = findViewById(R.id.hotseat); mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN @@ -1413,10 +1411,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, return (T) mOverviewPanel; } - public View getActionsView() { - return mActionsView; - } - public DropTargetBar getDropTargetBar() { return mDropTargetBar; } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 6ee82cd509..504666a4c2 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -73,7 +73,7 @@ public abstract class LauncherState { public static final int ALL_APPS_HEADER_EXTRA = 1 << 3; // e.g. app predictions public static final int ALL_APPS_CONTENT = 1 << 4; public static final int VERTICAL_SWIPE_INDICATOR = 1 << 5; - public static final int RECENTS_CLEAR_ALL_BUTTON = 1 << 6; + public static final int OVERVIEW_BUTTONS = 1 << 6; /** Mask of all the items that are contained in the apps view. */ public static final int APPS_VIEW_ITEM_MASK =