Some cleanup in RecentsView
> Merging overview and all-apps scrims into a single View
> Decoupling TaskMenuView from taskView
Bug: 184676497
Test: Manual
Change-Id: I49f7249eaa2a800054385ab8e73a441d6a1b5e16
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index df5f953..5091543 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1191,8 +1191,7 @@
// Setup the drag controller (drop targets have to be added in reverse order in priority)
mDropTargetBar.setup(mDragController);
-
- mAllAppsController.setupViews(mAppsView, mScrimView);
+ mAllAppsController.setupViews(mAppsView);
}
/**
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 1003958..0c509a1 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -209,11 +209,11 @@
return 1f;
}
- public float getWorkspaceScrimAlpha(Launcher launcher) {
+ public float getWorkspaceBackgroundAlpha(Launcher launcher) {
return 0;
}
- public float getOverviewScrimAlpha(Launcher launcher) {
+ public float getWorkspaceScrimAlpha(Launcher launcher) {
return 0;
}
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index e0a4d4a..24de19f 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -38,6 +38,7 @@
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
+import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCRIM_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
import android.animation.ValueAnimator;
@@ -150,7 +151,7 @@
propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y,
hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
- setScrim(propertySetter, state);
+ setScrim(propertySetter, state, config);
}
/**
@@ -165,14 +166,19 @@
- sibling.getLeft() - sibling.getTranslationX());
}
- public void setScrim(PropertySetter propertySetter, LauncherState state) {
+ public void setScrim(PropertySetter propertySetter, LauncherState state,
+ StateAnimationConfig config) {
WorkspaceDragScrim workspaceDragScrim = mLauncher.getDragLayer().getWorkspaceDragScrim();
propertySetter.setFloat(workspaceDragScrim, SCRIM_PROGRESS,
- state.getWorkspaceScrimAlpha(mLauncher), LINEAR);
+ state.getWorkspaceBackgroundAlpha(mLauncher), LINEAR);
SysUiScrim sysUiScrim = mLauncher.getDragLayer().getSysUiScrim();
propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS,
state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
+
+ propertySetter.setViewAlpha(mLauncher.getScrimView(),
+ state.getWorkspaceScrimAlpha(mLauncher),
+ config.getInterpolator(ANIM_WORKSPACE_SCRIM_FADE, LINEAR));
}
public void applyChildState(LauncherState state, CellLayout cl, int childIndex) {
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index c21d774..0060b83 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -43,7 +43,6 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
-import com.android.launcher3.views.ScrimView;
/**
* Handles AllApps view transition.
@@ -72,10 +71,7 @@
}
};
- private static final int APPS_VIEW_ALPHA_CHANNEL_INDEX = 0;
-
private AllAppsContainerView mAppsView;
- private ScrimView mScrimView;
private final Launcher mLauncher;
private boolean mIsVerticalLayout;
@@ -125,8 +121,6 @@
*/
public void setProgress(float progress) {
mProgress = progress;
-
- mScrimView.setProgress(progress);
mAppsView.setTranslationY(mProgress * mShiftRange);
}
@@ -191,9 +185,8 @@
return AnimationSuccessListener.forRunnable(this::onProgressAnimationEnd);
}
- public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) {
+ public void setupViews(AllAppsContainerView appsView) {
mAppsView = appsView;
- mScrimView = scrimView;
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && Utilities.ATLEAST_R) {
mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS,
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
@@ -207,10 +200,6 @@
void setScrollRangeDelta(float delta) {
mScrollRangeDelta = delta;
mShiftRange = mLauncher.getDeviceProfile().heightPx - mScrollRangeDelta;
-
- if (mScrimView != null) {
- mScrimView.reInitUi();
- }
}
/**
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 419c3f1..c80fd90 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -46,7 +46,6 @@
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Workspace;
import com.android.launcher3.folder.Folder;
-import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.graphics.SysUiScrim;
import com.android.launcher3.graphics.WorkspaceDragScrim;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
@@ -84,7 +83,6 @@
// Related to adjacent page hints
private final ViewGroupFocusHelper mFocusIndicatorHelper;
- private final OverviewScrim mOverviewScrim;
private WorkspaceDragScrim mWorkspaceDragScrim;
private SysUiScrim mSysUiScrim;
private LauncherRootView mRootView;
@@ -103,15 +101,12 @@
setChildrenDrawingOrderEnabled(true);
mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
- mOverviewScrim = new OverviewScrim(this);
}
public void setup(DragController dragController, Workspace workspace) {
mDragController = dragController;
recreateControllers();
- mOverviewScrim.setup();
-
mWorkspaceDragScrim = new WorkspaceDragScrim((this));
mWorkspaceDragScrim.setWorkspace(workspace);
@@ -529,20 +524,8 @@
protected void dispatchDraw(Canvas canvas) {
// Draw the background below children.
mWorkspaceDragScrim.draw(canvas);
- mOverviewScrim.updateCurrentScrimmedView(this);
mFocusIndicatorHelper.draw(canvas);
super.dispatchDraw(canvas);
- if (mOverviewScrim.getScrimmedView() == null) {
- mOverviewScrim.draw(canvas);
- }
- }
-
- @Override
- protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
- if (child == mOverviewScrim.getScrimmedView()) {
- mOverviewScrim.draw(canvas);
- }
- return super.drawChild(canvas, child, drawingTime);
}
@Override
@@ -564,8 +547,4 @@
public SysUiScrim getSysUiScrim() {
return mSysUiScrim;
}
-
- public OverviewScrim getOverviewScrim() {
- return mOverviewScrim;
- }
}
diff --git a/src/com/android/launcher3/graphics/OverviewScrim.java b/src/com/android/launcher3/graphics/OverviewScrim.java
deleted file mode 100644
index 7aadb96..0000000
--- a/src/com/android/launcher3/graphics/OverviewScrim.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.graphics;
-
-import static android.view.View.VISIBLE;
-
-import android.util.FloatProperty;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.android.launcher3.R;
-import com.android.launcher3.uioverrides.WallpaperColorInfo;
-import com.android.launcher3.util.Themes;
-
-/**
- * View scrim which draws behind overview (recent apps).
- */
-public class OverviewScrim extends Scrim {
-
- public static final FloatProperty<OverviewScrim> SCRIM_MULTIPLIER =
- new FloatProperty<OverviewScrim>("scrimMultiplier") {
- @Override
- public Float get(OverviewScrim scrim) {
- return scrim.mScrimMultiplier;
- }
-
- @Override
- public void setValue(OverviewScrim scrim, float v) {
- scrim.setScrimMultiplier(v);
- }
- };
-
- private @NonNull View mStableScrimmedView;
- // Might be higher up if mStableScrimmedView is invisible.
- private @Nullable View mCurrentScrimmedView;
-
- private float mScrimMultiplier = 1f;
-
- public OverviewScrim(View view) {
- super(view);
-
- mScrimColor = Themes.getAttrColor(view.getContext(), R.attr.allAppsScrimColor);
- }
-
- /**
- * Initializes once view hierarchy is established.
- */
- public void setup() {
- mStableScrimmedView = mCurrentScrimmedView = mLauncher.getOverviewPanel();
- }
-
- /**
- * @param view The view we want the scrim to be behind
- */
- public void updateStableScrimmedView(View view) {
- mStableScrimmedView = view;
- }
-
- public void updateCurrentScrimmedView(ViewGroup root) {
- // Find the lowest view that is at or above the view we want to show the scrim behind.
- mCurrentScrimmedView = mStableScrimmedView;
- int currentIndex = root.indexOfChild(mCurrentScrimmedView);
- final int childCount = root.getChildCount();
- while (mCurrentScrimmedView != null && mCurrentScrimmedView.getVisibility() != VISIBLE
- && currentIndex < childCount) {
- currentIndex++;
- mCurrentScrimmedView = root.getChildAt(currentIndex);
- }
- }
-
- @Override
- public void onExtractedColorsChanged(WallpaperColorInfo wallpaperColorInfo) {
- // No super, don't respond to wallpaper colors, follow device ones instead
- }
-
- /**
- * @return The view to draw the scrim behind, or null if all visible views should be scrimmed.
- */
- public @Nullable View getScrimmedView() {
- return mCurrentScrimmedView;
- }
-
- private void setScrimMultiplier(float scrimMultiplier) {
- if (Float.compare(mScrimMultiplier, scrimMultiplier) != 0) {
- mScrimMultiplier = scrimMultiplier;
- invalidate();
- }
- }
-
- @Override
- protected int getScrimAlpha() {
- return Math.round(super.getScrimAlpha() * mScrimMultiplier);
- }
-}
diff --git a/src/com/android/launcher3/states/HintState.java b/src/com/android/launcher3/states/HintState.java
index 76f89bc..22c9d5b 100644
--- a/src/com/android/launcher3/states/HintState.java
+++ b/src/com/android/launcher3/states/HintState.java
@@ -49,7 +49,7 @@
}
@Override
- public float getOverviewScrimAlpha(Launcher launcher) {
+ public float getWorkspaceScrimAlpha(Launcher launcher) {
return 0.4f;
}
diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java
index d593013..39bcdc5 100644
--- a/src/com/android/launcher3/states/SpringLoadedState.java
+++ b/src/com/android/launcher3/states/SpringLoadedState.java
@@ -88,7 +88,7 @@
}
@Override
- public float getWorkspaceScrimAlpha(Launcher launcher) {
+ public float getWorkspaceBackgroundAlpha(Launcher launcher) {
return 0.3f;
}
diff --git a/src/com/android/launcher3/states/StateAnimationConfig.java b/src/com/android/launcher3/states/StateAnimationConfig.java
index 8e7dcc0..0dbfb0b 100644
--- a/src/com/android/launcher3/states/StateAnimationConfig.java
+++ b/src/com/android/launcher3/states/StateAnimationConfig.java
@@ -56,7 +56,7 @@
ANIM_OVERVIEW_TRANSLATE_Y,
ANIM_OVERVIEW_FADE,
ANIM_ALL_APPS_FADE,
- ANIM_OVERVIEW_SCRIM_FADE,
+ ANIM_WORKSPACE_SCRIM_FADE,
ANIM_ALL_APPS_HEADER_FADE,
ANIM_OVERVIEW_MODAL,
ANIM_DEPTH,
@@ -75,7 +75,7 @@
public static final int ANIM_OVERVIEW_TRANSLATE_Y = 8;
public static final int ANIM_OVERVIEW_FADE = 9;
public static final int ANIM_ALL_APPS_FADE = 10;
- public static final int ANIM_OVERVIEW_SCRIM_FADE = 11;
+ public static final int ANIM_WORKSPACE_SCRIM_FADE = 11;
public static final int ANIM_ALL_APPS_HEADER_FADE = 12; // e.g. predictions
public static final int ANIM_OVERVIEW_MODAL = 13;
public static final int ANIM_DEPTH = 14;
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index dd5611e..a241e63 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -75,14 +75,6 @@
}
@Override
- public void getCurveProperties(PagedView view, Rect insets, CurveProperties out) {
- out.scroll = view.getScrollY();
- out.halfPageSize = view.getNormalChildHeight() / 2;
- out.halfScreenSize = view.getMeasuredHeight() / 2;
- out.screenCenter = insets.top + view.getPaddingTop() + out.scroll + out.halfPageSize;
- }
-
- @Override
public boolean isLayoutNaturalToLauncher() {
return false;
}
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index 9140a04..b85d08a 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -93,7 +93,6 @@
void delegateScrollTo(PagedView pagedView, int primaryScroll);
void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y);
void scrollerStartScroll(OverScroller scroller, int newPosition);
- void getCurveProperties(PagedView view, Rect insets, CurveProperties out);
boolean isLayoutNaturalToLauncher();
float getTaskMenuX(float x, View thumbnailView);
float getTaskMenuY(float y, View thumbnailView);
@@ -121,13 +120,6 @@
*/
void adjustFloatingIconStartVelocity(PointF velocity);
- class CurveProperties {
- public int scroll;
- public int halfPageSize;
- public int screenCenter;
- public int halfScreenSize;
- }
-
class ChildBounds {
public final int primaryDimension;
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 2ca0340..2fb5952 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -22,7 +22,6 @@
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;
-import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_SIDE;
import android.content.res.Resources;
import android.graphics.PointF;
@@ -74,14 +73,6 @@
}
@Override
- public void getCurveProperties(PagedView view, Rect insets, CurveProperties out) {
- out.scroll = view.getScrollX();
- out.halfPageSize = view.getNormalChildWidth() / 2;
- out.halfScreenSize = view.getMeasuredWidth() / 2;
- out.screenCenter = insets.left + view.getPaddingLeft() + out.scroll + out.halfPageSize;
- }
-
- @Override
public boolean isLayoutNaturalToLauncher() {
return true;
}
diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java
index 72926dd..c9424de 100644
--- a/src/com/android/launcher3/views/ScrimView.java
+++ b/src/com/android/launcher3/views/ScrimView.java
@@ -15,14 +15,9 @@
*/
package com.android.launcher3.views;
-import static androidx.core.graphics.ColorUtils.compositeColors;
-
-import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW;
import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
@@ -32,104 +27,61 @@
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
-import com.android.launcher3.uioverrides.WallpaperColorInfo;
-import com.android.launcher3.uioverrides.WallpaperColorInfo.OnChangeListener;
+import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
/**
* Simple scrim which draws a flat color
*/
-public class ScrimView<T extends Launcher> extends View implements Insettable, OnChangeListener {
- private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = .1f;
+public class ScrimView extends View implements Insettable {
+ private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f;
- protected final T mLauncher;
- private final WallpaperColorInfo mWallpaperColorInfo;
- protected final int mEndScrim;
- protected final boolean mIsScrimDark;
-
- protected float mMaxScrimAlpha;
-
- protected float mProgress = 1;
- protected int mScrimColor;
-
- protected int mCurrentFlatColor;
- protected int mEndFlatColor;
- protected int mEndFlatColorAlpha;
+ private final boolean mIsScrimDark;
+ private SystemUiController mSystemUiController;
public ScrimView(Context context, AttributeSet attrs) {
super(context, attrs);
- mLauncher = Launcher.cast(Launcher.getLauncher(context));
- mWallpaperColorInfo = WallpaperColorInfo.INSTANCE.get(context);
- mEndScrim = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
- mIsScrimDark = ColorUtils.calculateLuminance(mEndScrim) < 0.5f;
-
- mMaxScrimAlpha = 0.7f;
+ mIsScrimDark = ColorUtils.calculateLuminance(
+ Themes.getAttrColor(context, R.attr.allAppsScrimColor)) < 0.5f;
setFocusable(false);
}
@Override
public void setInsets(Rect insets) { }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- mWallpaperColorInfo.addOnChangeListener(this);
- onExtractedColorsChanged(mWallpaperColorInfo);
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- mWallpaperColorInfo.removeOnChangeListener(this);
- }
-
@Override
public boolean hasOverlappingRendering() {
return false;
}
@Override
- public void onExtractedColorsChanged(WallpaperColorInfo wallpaperColorInfo) {
- mScrimColor = wallpaperColorInfo.getMainColor();
- mEndFlatColor = compositeColors(mEndScrim, setColorAlphaBound(
- mScrimColor, Math.round(mMaxScrimAlpha * 255)));
- mEndFlatColorAlpha = Color.alpha(mEndFlatColor);
- updateColors();
- invalidate();
- }
-
- public void setProgress(float progress) {
- if (mProgress != progress) {
- mProgress = progress;
- updateColors();
- updateSysUiColors();
- invalidate();
- }
- }
-
- public void reInitUi() { }
-
- protected void updateColors() {
- mCurrentFlatColor = mProgress >= 1 ? 0 : setColorAlphaBound(
- mEndFlatColor, Math.round((1 - mProgress) * mEndFlatColorAlpha));
- }
-
- protected void updateSysUiColors() {
- // Use a light system UI (dark icons) if all apps is behind at least half of the
- // status bar.
- boolean forceChange = mProgress <= STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD;
- if (forceChange) {
- mLauncher.getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !mIsScrimDark);
- } else {
- mLauncher.getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, 0);
- }
+ protected boolean onSetAlpha(int alpha) {
+ updateSysUiColors();
+ return super.onSetAlpha(alpha);
}
@Override
- protected void onDraw(Canvas canvas) {
- if (mCurrentFlatColor != 0) {
- canvas.drawColor(mCurrentFlatColor);
+ protected void onVisibilityChanged(View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+ updateSysUiColors();
+ }
+
+ private void updateSysUiColors() {
+ // Use a light system UI (dark icons) if all apps is behind at least half of the
+ // status bar.
+ boolean forceChange =
+ getVisibility() == VISIBLE && getAlpha() > STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD;
+ if (forceChange) {
+ getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !mIsScrimDark);
+ } else {
+ getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, 0);
}
}
+
+ private SystemUiController getSystemUiController() {
+ if (mSystemUiController == null) {
+ mSystemUiController = Launcher.getLauncher(getContext()).getSystemUiController();
+ }
+ return mSystemUiController;
+ }
}