From 8b9919de9fca08ed572958f54410e789c6998778 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 7 Apr 2021 14:45:17 -0700 Subject: [PATCH 1/5] Removing some dependency on icon shape Bug: 183641907 Test: Manual Change-Id: Ifd492a850bb9918ad378385abe544362e34e70b0 --- .../uioverrides/PredictedAppIcon.java | 85 ++++++++++++------- src/com/android/launcher3/BubbleTextView.java | 50 +---------- src/com/android/launcher3/DeviceProfile.java | 11 +-- .../android/launcher3/graphics/IconShape.java | 29 ------- .../graphics/PreloadIconDrawable.java | 7 +- 5 files changed, 65 insertions(+), 117 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java index b4aa596760..5ba1fe17b2 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java +++ b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java @@ -15,12 +15,11 @@ */ package com.android.launcher3.uioverrides; -import static com.android.launcher3.graphics.IconShape.getShape; - import android.content.Context; import android.graphics.BlurMaskFilter; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Rect; @@ -37,6 +36,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.graphics.IconPalette; +import com.android.launcher3.icons.GraphicsUtils; import com.android.launcher3.icons.IconNormalizer; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.model.data.WorkspaceItemInfo; @@ -58,9 +58,13 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView { private final DeviceProfile mDeviceProfile; private final Paint mIconRingPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final Path mRingPath = new Path(); - private boolean mIsPinned = false; - private final int mNormalizedIconRadius; + private final int mNormalizedIconSize; + private final Path mShapePath; + private final Matrix mTmpMatrix = new Matrix(); + private final BlurMaskFilter mShadowFilter; + + private boolean mIsPinned = false; private int mPlateColor; boolean mDrawForDrag = false; @@ -75,24 +79,18 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView { public PredictedAppIcon(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mDeviceProfile = ActivityContext.lookupContext(context).getDeviceProfile(); - mNormalizedIconRadius = IconNormalizer.getNormalizedCircleSize(getIconSize()) / 2; + mNormalizedIconSize = IconNormalizer.getNormalizedCircleSize(getIconSize()); int shadowSize = context.getResources().getDimensionPixelSize( R.dimen.blur_size_thin_outline); mShadowFilter = new BlurMaskFilter(shadowSize, BlurMaskFilter.Blur.OUTER); + mShapePath = GraphicsUtils.getShapePath(mNormalizedIconSize); } @Override public void onDraw(Canvas canvas) { int count = canvas.save(); if (!mIsPinned) { - boolean isBadged = false; - if (getTag() instanceof WorkspaceItemInfo) { - WorkspaceItemInfo info = (WorkspaceItemInfo) getTag(); - isBadged = !Process.myUserHandle().equals(info.user) - || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT - || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; - } - drawEffect(canvas, isBadged); + drawEffect(canvas); canvas.translate(getWidth() * RING_EFFECT_RATIO, getHeight() * RING_EFFECT_RATIO); canvas.scale(1 - 2 * RING_EFFECT_RATIO, 1 - 2 * RING_EFFECT_RATIO); } @@ -161,33 +159,58 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView { } private int getOutlineOffsetX() { - return (getMeasuredWidth() / 2) - mNormalizedIconRadius; + return (getMeasuredWidth() - mNormalizedIconSize) / 2; } private int getOutlineOffsetY() { if (mDisplay != DISPLAY_TASKBAR) { return getPaddingTop() + mDeviceProfile.folderIconOffsetYPx; } - return (getMeasuredHeight() / 2) - mNormalizedIconRadius; + return (getMeasuredHeight() - mNormalizedIconSize) / 2; } - private void drawEffect(Canvas canvas, boolean isBadged) { + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + updateRingPath(); + } + + @Override + public void setTag(Object tag) { + super.setTag(tag); + updateRingPath(); + } + + private void updateRingPath() { + boolean isBadged = false; + if (getTag() instanceof WorkspaceItemInfo) { + WorkspaceItemInfo info = (WorkspaceItemInfo) getTag(); + isBadged = !Process.myUserHandle().equals(info.user) + || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT + || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; + } + + mRingPath.reset(); + mTmpMatrix.setTranslate(getOutlineOffsetX(), getOutlineOffsetY()); + + mRingPath.addPath(mShapePath, mTmpMatrix); + if (isBadged) { + float outlineSize = mNormalizedIconSize * RING_EFFECT_RATIO; + float iconSize = getIconSize() * (1 - 2 * RING_EFFECT_RATIO); + float badgeSize = LauncherIcons.getBadgeSizeForIconSize((int) iconSize) + outlineSize; + float scale = badgeSize / mNormalizedIconSize; + mTmpMatrix.postTranslate(mNormalizedIconSize, mNormalizedIconSize); + mTmpMatrix.preScale(scale, scale); + mTmpMatrix.preTranslate(-mNormalizedIconSize, -mNormalizedIconSize); + mRingPath.addPath(mShapePath, mTmpMatrix); + } + } + + private void drawEffect(Canvas canvas) { // Don't draw ring effect if item is about to be dragged. if (mDrawForDrag) { return; } - mRingPath.reset(); - getShape().addToPath(mRingPath, getOutlineOffsetX(), getOutlineOffsetY(), - mNormalizedIconRadius); - if (isBadged) { - float outlineSize = mNormalizedIconRadius * RING_EFFECT_RATIO * 2; - float iconSize = getIconSize() * (1 - 2 * RING_EFFECT_RATIO); - float badgeSize = LauncherIcons.getBadgeSizeForIconSize((int) iconSize) + outlineSize; - float badgeInset = mNormalizedIconRadius * 2 - badgeSize; - getShape().addToPath(mRingPath, getOutlineOffsetX() + badgeInset, - getOutlineOffsetY() + badgeInset, badgeSize / 2); - - } mIconRingPaint.setColor(RING_SHADOW_COLOR); mIconRingPaint.setMaskFilter(mShadowFilter); canvas.drawPath(mRingPath, mIconRingPaint); @@ -249,8 +272,10 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView { */ @Override public void drawUnderItem(Canvas canvas) { - getShape().drawShape(canvas, mIcon.getOutlineOffsetX(), mIcon.getOutlineOffsetY(), - mIcon.mNormalizedIconRadius, mOutlinePaint); + canvas.save(); + canvas.translate(mIcon.getOutlineOffsetX(), mIcon.getOutlineOffsetY()); + canvas.drawPath(mIcon.mShapePath, mOutlinePaint); + canvas.restore(); } /** diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index d333b49a3a..2ace796ca0 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -16,7 +16,6 @@ package com.android.launcher3; -import static com.android.launcher3.graphics.IconShape.getShape; import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon; import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; @@ -26,16 +25,13 @@ import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; -import android.graphics.BlurMaskFilter; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.Path; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.os.Process; import android.text.TextUtils.TruncateAt; import android.util.AttributeSet; import android.util.Property; @@ -50,7 +46,6 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dot.DotInfo; import com.android.launcher3.dragndrop.DraggableView; import com.android.launcher3.folder.FolderIcon; @@ -60,7 +55,6 @@ import com.android.launcher3.graphics.PreloadIconDrawable; import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver; -import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.icons.PlaceHolderIconDrawable; import com.android.launcher3.icons.cache.HandlerRunnable; import com.android.launcher3.model.data.AppInfo; @@ -97,11 +91,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private float mScaleForReorderBounce = 1f; - protected final Paint mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - private final Path mHighlightPath = new Path(); - protected int mHighlightColor = Color.TRANSPARENT; - private final BlurMaskFilter mHighlightShadowFilter; - private static final Property DOT_SCALE_PROPERTY = new Property(Float.TYPE, "dotScale") { @Override @@ -220,10 +209,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, setEllipsize(TruncateAt.END); setAccessibilityDelegate(mActivity.getAccessibilityDelegate()); setTextAlpha(1f); - - int shadowSize = context.getResources().getDimensionPixelSize( - R.dimen.blur_size_click_shadow); - mHighlightShadowFilter = new BlurMaskFilter(shadowSize, BlurMaskFilter.Blur.INNER); } @Override @@ -451,41 +436,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, @Override public void onDraw(Canvas canvas) { - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && mHighlightColor != Color.TRANSPARENT) { - int count = canvas.save(); - drawFocusHighlight(canvas); - canvas.restoreToCount(count); - } super.onDraw(canvas); drawDotIfNecessary(canvas); } - protected void drawFocusHighlight(Canvas canvas) { - boolean isBadged = getTag() instanceof ItemInfo && !Process.myUserHandle().equals( - ((ItemInfo) getTag()).user); - float insetScale = (HIGHLIGHT_SCALE - 1) / 2; - canvas.translate(-getIconSize() * insetScale, -insetScale * getIconSize()); - float outlineSize = getIconSize() * HIGHLIGHT_SCALE; - mHighlightPath.reset(); - mHighlightPaint.reset(); - getIconBounds(mDotParams.iconBounds); - getShape().addToPath(mHighlightPath, mDotParams.iconBounds.left, mDotParams.iconBounds.top, - outlineSize / 2); - if (isBadged) { - float borderSize = outlineSize - getIconSize(); - float badgeSize = LauncherIcons.getBadgeSizeForIconSize(getIconSize()) + borderSize; - float badgeInset = outlineSize - badgeSize; - getShape().addToPath(mHighlightPath, mDotParams.iconBounds.left + badgeInset, - mDotParams.iconBounds.top + badgeInset, badgeSize / 2); - } - mHighlightPaint.setMaskFilter(mHighlightShadowFilter); - mHighlightPaint.setColor(mDotParams.color); - canvas.drawPath(mHighlightPath, mHighlightPaint); - mHighlightPaint.setMaskFilter(null); - mHighlightPaint.setColor(mHighlightColor); - canvas.drawPath(mHighlightPath, mHighlightPaint); - } - /** * Draws the notification dot in the top right corner of the icon bounds. * @@ -921,11 +875,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, @Override public SafeCloseable prepareDrawDragView() { - int highlightColor = mHighlightColor; - mHighlightColor = Color.TRANSPARENT; resetIconScale(); setForceHideDot(true); - return () -> mHighlightColor = highlightColor; + return () -> { }; } private void resetIconScale() { diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index aea38a054b..e17ef2910c 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -22,6 +22,7 @@ import static com.android.launcher3.Utilities.dpiFromPx; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Path; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; @@ -32,8 +33,8 @@ import android.view.WindowManager; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.DevicePaddings.DevicePadding; import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.graphics.IconShape; import com.android.launcher3.icons.DotRenderer; +import com.android.launcher3.icons.GraphicsUtils; import com.android.launcher3.icons.IconNormalizer; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; @@ -46,6 +47,7 @@ public class DeviceProfile { private static final float TABLET_MIN_DPS = 600; private static final float LARGE_TABLET_MIN_DPS = 720; + private static final int DEFAULT_DOT_SIZE = 100; public final InvariantDeviceProfile inv; private final Info mInfo; @@ -351,11 +353,10 @@ public class DeviceProfile { updateWorkspacePadding(); // This is done last, after iconSizePx is calculated above. - mDotRendererWorkSpace = new DotRenderer(iconSizePx, IconShape.getShapePath(), - IconShape.DEFAULT_PATH_SIZE); + Path dotPath = GraphicsUtils.getShapePath(DEFAULT_DOT_SIZE); + mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE); mDotRendererAllApps = iconSizePx == allAppsIconSizePx ? mDotRendererWorkSpace : - new DotRenderer(allAppsIconSizePx, IconShape.getShapePath(), - IconShape.DEFAULT_PATH_SIZE); + new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE); } private void setCellLayoutBorderSpacing(int borderSpacing) { diff --git a/src/com/android/launcher3/graphics/IconShape.java b/src/com/android/launcher3/graphics/IconShape.java index b208a40d35..2da679c422 100644 --- a/src/com/android/launcher3/graphics/IconShape.java +++ b/src/com/android/launcher3/graphics/IconShape.java @@ -37,20 +37,14 @@ import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.util.AttributeSet; -import android.util.SparseArray; -import android.util.TypedValue; import android.util.Xml; import android.view.View; import android.view.ViewOutlineProvider; -import androidx.annotation.Nullable; - import com.android.launcher3.R; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.icons.GraphicsUtils; import com.android.launcher3.icons.IconNormalizer; -import com.android.launcher3.util.IntArray; -import com.android.launcher3.util.Themes; import com.android.launcher3.views.ClipPathView; import org.xmlpull.v1.XmlPullParser; @@ -66,30 +60,16 @@ import java.util.List; public abstract class IconShape { private static IconShape sInstance = new Circle(); - private static Path sShapePath; private static float sNormalizationScale = ICON_VISIBLE_AREA_FACTOR; - public static final int DEFAULT_PATH_SIZE = 100; - public static IconShape getShape() { return sInstance; } - public static Path getShapePath() { - if (sShapePath == null) { - Path p = new Path(); - getShape().addToPath(p, 0, 0, DEFAULT_PATH_SIZE * 0.5f); - sShapePath = p; - } - return sShapePath; - } - public static float getNormalizationScale() { return sNormalizationScale; } - private SparseArray mAttrs; - public boolean enableShapeDetection(){ return false; }; @@ -102,11 +82,6 @@ public abstract class IconShape { public abstract Animator createRevealAnimator(T target, Rect startRect, Rect endRect, float endRadius, boolean isReversed); - @Nullable - public TypedValue getAttrValue(int attr) { - return mAttrs == null ? null : mAttrs.get(attr); - } - /** * Abstract shape where the reveal animation is a derivative of a round rect animation */ @@ -410,7 +385,6 @@ public abstract class IconShape { final int depth = parser.getDepth(); int[] radiusAttr = new int[] {R.attr.folderIconRadius}; - IntArray keysToIgnore = new IntArray(0); while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { @@ -421,7 +395,6 @@ public abstract class IconShape { IconShape shape = getShapeDefinition(parser.getName(), a.getFloat(0, 1)); a.recycle(); - shape.mAttrs = Themes.createValueMap(context, attrs, keysToIgnore); result.add(shape); } } @@ -467,8 +440,6 @@ public abstract class IconShape { } // Initialize shape properties - drawable.setBounds(0, 0, DEFAULT_PATH_SIZE, DEFAULT_PATH_SIZE); - sShapePath = new Path(drawable.getIconMask()); sNormalizationScale = IconNormalizer.normalizeAdaptiveIcon(drawable, size, null); } } diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java index ac0ec5f7f7..13ae866efb 100644 --- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java +++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java @@ -17,9 +17,6 @@ package com.android.launcher3.graphics; -import static com.android.launcher3.graphics.IconShape.DEFAULT_PATH_SIZE; -import static com.android.launcher3.graphics.IconShape.getShapePath; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; @@ -39,6 +36,7 @@ import android.view.ContextThemeWrapper; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.icons.FastBitmapDrawable; +import com.android.launcher3.icons.GraphicsUtils; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.util.Themes; @@ -62,6 +60,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable { } }; + private static final int DEFAULT_PATH_SIZE = 100; private static final float PROGRESS_WIDTH = 7; private static final float PROGRESS_GAP = 2; private static final int MAX_PAINT_ALPHA = 255; @@ -132,7 +131,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable { boolean isDarkMode) { super(info.bitmap); mItem = info; - mShapePath = getShapePath(); + mShapePath = GraphicsUtils.getShapePath(DEFAULT_PATH_SIZE); mScaledTrackPath = new Path(); mScaledProgressPath = new Path(); From 8c383f97e4537c24affd0cd01631047509da2908 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Thu, 22 Apr 2021 22:46:38 -0500 Subject: [PATCH 2/5] [Search][Motion] Separate AllApps scrim and content interpolation video: https://drive.google.com/file/d/18jTh8Lc8hf-c1GBGaWERHo4QIvAHBA8J/view?usp=sharing&resourcekey=0-RDJgw-ecOW3nnF6_tWkgCg Bug: 183001675 Test: visual Change-Id: Idb177fd3e31ac41f57379ac45b80e7246c0dd156 --- src/com/android/launcher3/Launcher.java | 2 +- .../WorkspaceStateTransitionAnimation.java | 5 --- .../allapps/AllAppsTransitionController.java | 12 +++++-- .../android/launcher3/views/ScrimView.java | 32 ++++++++++++++++--- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index a54c791aff..36d3625299 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1197,7 +1197,7 @@ public class Launcher extends StatefulActivity implements Launche // Setup the drag controller (drop targets have to be added in reverse order in priority) mDropTargetBar.setup(mDragController); - mAllAppsController.setupViews(mAppsView); + mAllAppsController.setupViews(mAppsView, mScrimView); } /** diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index ed854dcd0e..41962a4104 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -36,7 +36,6 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCA 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 static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM; @@ -165,10 +164,6 @@ public class WorkspaceStateTransitionAnimation { 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 c61c0d6d53..5c1bffb2d1 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -43,6 +43,7 @@ import com.android.launcher3.anim.PropertySetter; 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. @@ -70,10 +71,11 @@ public class AllAppsTransitionController controller.setProgress(progress); } }; + private final Launcher mLauncher; private AllAppsContainerView mAppsView; + private ScrimView mScrimView; - private final Launcher mLauncher; private boolean mIsVerticalLayout; // Animation in this class is controlled by a single variable {@link mProgress}. @@ -121,6 +123,8 @@ public class AllAppsTransitionController */ public void setProgress(float progress) { mProgress = progress; + //Note: Take inverted progress so progress=0 maps to a transparent scrim + mScrimView.setProgress(1 - progress); mAppsView.setTranslationY(mProgress * mShiftRange); } @@ -185,8 +189,12 @@ public class AllAppsTransitionController return AnimationSuccessListener.forRunnable(this::onProgressAnimationEnd); } - public void setupViews(AllAppsContainerView appsView) { + /** + * Setup views + */ + public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) { 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 diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java index c9424de152..9b809ae486 100644 --- a/src/com/android/launcher3/views/ScrimView.java +++ b/src/com/android/launcher3/views/ScrimView.java @@ -15,18 +15,21 @@ */ package com.android.launcher3.views; +import static com.android.launcher3.anim.Interpolators.ACCEL; import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; +import android.view.animation.Interpolator; import androidx.core.graphics.ColorUtils; import com.android.launcher3.Insettable; import com.android.launcher3.Launcher; import com.android.launcher3.R; +import com.android.launcher3.anim.Interpolators; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.Themes; @@ -36,9 +39,22 @@ import com.android.launcher3.util.Themes; public class ScrimView extends View implements Insettable { private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f; + + private static final float TINT_DECAY_MULTIPLIER = .5f; + + //min progress for scrim to become visible + private static final float SCRIM_VISIBLE_THRESHOLD = .1f; + //max progress where scrim alpha animates. + private static final float SCRIM_SOLID_THRESHOLD = .5f; + private final Interpolator mScrimInterpolator = Interpolators.clampToProgress(ACCEL, + SCRIM_VISIBLE_THRESHOLD, + SCRIM_SOLID_THRESHOLD); + private final boolean mIsScrimDark; private SystemUiController mSystemUiController; + private float mProgress; + public ScrimView(Context context, AttributeSet attrs) { super(context, attrs); mIsScrimDark = ColorUtils.calculateLuminance( @@ -47,17 +63,23 @@ public class ScrimView extends View implements Insettable { } @Override - public void setInsets(Rect insets) { } + public void setInsets(Rect insets) { + } @Override public boolean hasOverlappingRendering() { return false; } - @Override - protected boolean onSetAlpha(int alpha) { - updateSysUiColors(); - return super.onSetAlpha(alpha); + /** + * Set progress of scrim animation. + * Note: progress should range from 0 for transparent to 1 for solid + */ + public void setProgress(float progress) { + if (mProgress != progress) { + mProgress = progress; + setAlpha(mScrimInterpolator.getInterpolation(progress)); + } } @Override From fd6d942220499bb218a99d1dd9cb85b870de706d Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 22 Apr 2021 19:10:21 +0100 Subject: [PATCH 3/5] Pass WindowContext to DisplayInfoChangeListener - WindowContext (or updated DisplayContext for Pre-S) contains updated Resources to be used for the listener Fixes: 181215299 Fixes: 176656141 Test: Swap between large/small screen, large sreen UI is seen Test: Swap between font size, launcher icon text is updated Test: Start secondary home Test: Repeat the above tests with Utilities.ATLEAST_S hardcoded to false Change-Id: Ib33025ac0276c84fe2b3213e9946721e5988e3da --- .../launcher3/BaseQuickstepLauncher.java | 10 ++++---- .../RecentsAnimationDeviceState.java | 4 ++-- .../quickstep/RotationTouchHelper.java | 4 ++-- .../launcher3/BaseDraggingActivity.java | 3 ++- .../launcher3/InvariantDeviceProfile.java | 6 ++--- .../launcher3/util/DisplayController.java | 23 ++++++++++++------- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index caf52e3542..7aae38c7f1 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -27,12 +27,11 @@ import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SY import android.animation.AnimatorSet; import android.animation.ValueAnimator; import android.app.ActivityOptions; +import android.content.Context; import android.content.Intent; import android.content.IntentSender; -import android.os.Binder; import android.os.Bundle; import android.os.CancellationSignal; -import android.os.IBinder; import android.view.View; import androidx.annotation.Nullable; @@ -41,7 +40,6 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.model.WellbeingModel; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.proxy.ProxyActivityStarter; import com.android.launcher3.proxy.StartActivityParams; @@ -73,7 +71,6 @@ import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; -import java.util.HashMap; import java.util.List; import java.util.stream.Stream; @@ -240,8 +237,9 @@ public abstract class BaseQuickstepLauncher extends Launcher } @Override - public void onDisplayInfoChanged(DisplayController.Info info, int flags) { - super.onDisplayInfoChanged(info, flags); + public void onDisplayInfoChanged(Context context, DisplayController.Info info, + int flags) { + super.onDisplayInfoChanged(context, info, flags); if ((flags & CHANGE_SIZE) != 0) { addTaskbarIfNecessary(); } diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index 6cf12a3865..b4f13307a4 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -241,7 +241,7 @@ public class RecentsAnimationDeviceState implements public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) { mDisplayController.removeChangeListener(this); mDisplayController.addChangeListener(this); - onDisplayInfoChanged(mDisplayController.getInfo(), CHANGE_ALL); + onDisplayInfoChanged(mContext, mDisplayController.getInfo(), CHANGE_ALL); if (newMode == NO_BUTTON) { mExclusionListener.register(); @@ -254,7 +254,7 @@ public class RecentsAnimationDeviceState implements } @Override - public void onDisplayInfoChanged(Info info, int flags) { + public void onDisplayInfoChanged(Context context, Info info, int flags) { if (info.id != getDisplayId() || flags == CHANGE_FRAME_DELAY) { // ignore displays that aren't running launcher and frame refresh rate changes return; diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java index d4ad1760ef..f4688a1dc1 100644 --- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java +++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java @@ -225,7 +225,7 @@ public class RotationTouchHelper implements public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) { mDisplayController.removeChangeListener(this); mDisplayController.addChangeListener(this); - onDisplayInfoChanged(mDisplayController.getInfo(), CHANGE_ALL); + onDisplayInfoChanged(mContext, mDisplayController.getInfo(), CHANGE_ALL); mOrientationTouchTransformer.setNavigationMode(newMode, mDisplayController.getInfo(), mContext.getResources()); @@ -243,7 +243,7 @@ public class RotationTouchHelper implements } @Override - public void onDisplayInfoChanged(Info info, int flags) { + public void onDisplayInfoChanged(Context context, Info info, int flags) { if (info.id != mDisplayId|| flags == CHANGE_FRAME_DELAY) { // ignore displays that aren't running launcher and frame refresh rate changes return; diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index cc9f594257..4c5f9f247f 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -21,6 +21,7 @@ import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION; import android.app.ActivityOptions; import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; import android.content.pm.LauncherApps; import android.content.res.Configuration; @@ -296,7 +297,7 @@ public abstract class BaseDraggingActivity extends BaseActivity } @Override - public void onDisplayInfoChanged(Info info, int flags) { + public void onDisplayInfoChanged(Context context, Info info, int flags) { if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.updateIsSeascape(this)) { reapplyUi(); } diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 11dc0c4736..1332e14af0 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -203,9 +203,9 @@ public class InvariantDeviceProfile { .apply(); DisplayController.INSTANCE.get(context).addChangeListener( - (info, flags) -> { + (displayContext, info, flags) -> { if ((flags & (CHANGE_SIZE | CHANGE_DENSITY)) != 0) { - onConfigChanged(context); + onConfigChanged(displayContext); } }); mOverlayMonitor = new OverlayMonitor(context); @@ -226,7 +226,7 @@ public class InvariantDeviceProfile { */ public InvariantDeviceProfile(Context context, Display display) { // Ensure that the main device profile is initialized - InvariantDeviceProfile originalProfile = INSTANCE.get(context); + INSTANCE.get(context); String gridName = getCurrentGridName(context); // Get the display info based on default display and interpolate it to existing display diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index 07c89b9b43..75c089e754 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -87,7 +87,7 @@ public class DisplayController implements DisplayListener, ComponentCallbacks { new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } - mInfo = createInfo(display); + mInfo = new Info(getContext(display), display); mDM.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler()); } @@ -125,7 +125,13 @@ public class DisplayController implements DisplayListener, ComponentCallbacks { */ public interface DisplayInfoChangeListener { - void onDisplayInfoChanged(Info info, int flags); + /** + * Invoked when display info has changed. + * @param context updated context associated with the display. + * @param info updated display information. + * @param flags bitmask indicating type of change. + */ + void onDisplayInfoChanged(Context context, Info info, int flags); } /** @@ -172,14 +178,15 @@ public class DisplayController implements DisplayListener, ComponentCallbacks { return mInfo; } - private Info createInfo(Display display) { - return new Info(mContext.createDisplayContext(display), display); + private Context getContext(Display display) { + return Utilities.ATLEAST_S ? mWindowContext : mContext.createDisplayContext(display); } @AnyThread private void handleInfoChange(Display display) { Info oldInfo = mInfo; - Info newInfo = createInfo(display); + Context context = getContext(display); + Info newInfo = new Info(context, display); int change = 0; if (newInfo.hasDifferentSize(oldInfo)) { change |= CHANGE_SIZE; @@ -197,13 +204,13 @@ public class DisplayController implements DisplayListener, ComponentCallbacks { if (change != 0) { mInfo = newInfo; final int flags = change; - MAIN_EXECUTOR.execute(() -> notifyChange(flags)); + MAIN_EXECUTOR.execute(() -> notifyChange(context, flags)); } } - private void notifyChange(int flags) { + private void notifyChange(Context context, int flags) { for (int i = mListeners.size() - 1; i >= 0; i--) { - mListeners.get(i).onDisplayInfoChanged(mInfo, flags); + mListeners.get(i).onDisplayInfoChanged(context, mInfo, flags); } } From 0fdd43ab0dbd72da2ab19cf6fffdc0ac94572604 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 23 Apr 2021 23:53:16 +0000 Subject: [PATCH 4/5] Revert "Revert "Default shell_starting_surface to true to match platform behavior."" This reverts commit 250f568cb2aa719ae25feaa1e5b349ac372df9a1. Reason for revert: b/186121207 should be fixed Change-Id: Ia374d9ad251134979999d794331e3b375d183996 --- .../src/com/android/launcher3/QuickstepTransitionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 009ca27603..b72cf394c5 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -110,7 +110,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener private static final String TAG = "QuickstepTransition"; private static final boolean ENABLE_SHELL_STARTING_SURFACE = - SystemProperties.getBoolean("persist.debug.shell_starting_surface", false); + SystemProperties.getBoolean("persist.debug.shell_starting_surface", true); /** Duration of status bar animations. */ public static final int STATUS_BAR_TRANSITION_DURATION = 120; From b7f5ab04ad51a0461204f1124a3599cb8dc98804 Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Thu, 15 Apr 2021 18:17:17 +0100 Subject: [PATCH 5/5] Fix few UI bugs in widget picker. - Update colors for widget picker (b/184236316) - Adjust padding according to mocks (b/184236316) - Make sure view holders refresh corners in search mode. (b/185099541) - Fix search bar shadow being cropped (b/183602001) Bug: 184236316 Bug: 185099541 Bug: 183602001 Test: Manually tested Change-Id: Ifa33e090cdf31c95db9c1145e623ef55c42dd52e --- .../widgets_picker_surface.xml | 23 ++++++++++++++++++ res/color-v31/widgets_picker_surface.xml | 23 ++++++++++++++++++ res/color/widgets_picker_surface.xml | 23 ++++++++++++++++++ res/drawable/widgets_list_bottom_ripple.xml | 2 +- res/drawable/widgets_list_middle_ripple.xml | 2 +- .../widgets_list_single_item_ripple.xml | 2 +- res/drawable/widgets_list_top_ripple.xml | 2 +- .../widgets_recommendation_background.xml | 24 +++++++++++++++++++ res/layout/widgets_full_sheet.xml | 2 +- ..._full_sheet_search_and_recommendations.xml | 7 ++++-- res/layout/widgets_list_row_header.xml | 2 +- res/layout/widgets_table_container.xml | 2 +- .../widget/picker/WidgetsDiffReporter.java | 4 ++-- 13 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 res/color-night-v31/widgets_picker_surface.xml create mode 100644 res/color-v31/widgets_picker_surface.xml create mode 100644 res/color/widgets_picker_surface.xml create mode 100644 res/drawable/widgets_recommendation_background.xml diff --git a/res/color-night-v31/widgets_picker_surface.xml b/res/color-night-v31/widgets_picker_surface.xml new file mode 100644 index 0000000000..fbc9e43828 --- /dev/null +++ b/res/color-night-v31/widgets_picker_surface.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/res/color-v31/widgets_picker_surface.xml b/res/color-v31/widgets_picker_surface.xml new file mode 100644 index 0000000000..30f3032541 --- /dev/null +++ b/res/color-v31/widgets_picker_surface.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/res/color/widgets_picker_surface.xml b/res/color/widgets_picker_surface.xml new file mode 100644 index 0000000000..61501108f0 --- /dev/null +++ b/res/color/widgets_picker_surface.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/res/drawable/widgets_list_bottom_ripple.xml b/res/drawable/widgets_list_bottom_ripple.xml index 3a26091f14..72262d4d7c 100644 --- a/res/drawable/widgets_list_bottom_ripple.xml +++ b/res/drawable/widgets_list_bottom_ripple.xml @@ -30,7 +30,7 @@ - + - + - + - + + + + + + \ No newline at end of file diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml index 172284b4df..a01aa2c581 100644 --- a/res/layout/widgets_full_sheet.xml +++ b/res/layout/widgets_full_sheet.xml @@ -25,7 +25,7 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?android:attr/colorBackgroundFloating" + android:background="?android:attr/colorBackground" android:elevation="4dp"> + android:orientation="vertical" + android:clipToPadding="false"> + android:visibility="gone"/> diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml index 8259c16612..f4b413097b 100644 --- a/res/layout/widgets_list_row_header.xml +++ b/res/layout/widgets_list_row_header.xml @@ -19,7 +19,7 @@ android:id="@+id/widgets_list_header" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" + android:layout_marginHorizontal="16dp" android:background="@drawable/widgets_list_middle_ripple" android:layout_marginBottom="@dimen/widget_list_entry_bottom_margin" android:paddingVertical="@dimen/widget_list_header_view_vertical_padding" diff --git a/res/layout/widgets_table_container.xml b/res/layout/widgets_table_container.xml index 0b5f0b9d6c..e63483ddd8 100644 --- a/res/layout/widgets_table_container.xml +++ b/res/layout/widgets_table_container.xml @@ -18,6 +18,6 @@ android:id="@+id/widgets_table" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" + android:layout_marginHorizontal="16dp" android:background="@drawable/widgets_list_middle_ripple" android:layout_marginBottom="@dimen/widget_list_entry_bottom_margin"/> diff --git a/src/com/android/launcher3/widget/picker/WidgetsDiffReporter.java b/src/com/android/launcher3/widget/picker/WidgetsDiffReporter.java index 2366609b3f..42896ba350 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsDiffReporter.java +++ b/src/com/android/launcher3/widget/picker/WidgetsDiffReporter.java @@ -181,8 +181,8 @@ public class WidgetsDiffReporter { } if (newRow instanceof WidgetsListSearchHeaderEntry && curRow instanceof WidgetsListSearchHeaderEntry) { - return ((WidgetsListSearchHeaderEntry) newRow).hasEntryUpdated() - || !curRow.equals(newRow); + // Always refresh search header entries to reset rounded corners in their view holder. + return true; } return false; }