Add shadow to KQS view
Shadow matches the transient taskbar shadow (implementation inspired by
TaskbarBackgroundRenderer).
Bug:399862815
Flag: EXEMPT (UX) bugfix
Test: On desktop device, open taskbar overflow in overview, and verify a
shadow is shown (making outline of KQS view visible against
overview background)
Change-Id: I9527d8448439e87789c9e036edb464590349c3dd
This commit is contained in:
1 parent
af24c515c9
commit
17d97b2131
3 files changed
+56
-2
No files matched your search
@@ -26,8 +26,12 @@ import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.icu.text.MessageFormat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
@@ -53,8 +57,10 @@ import com.android.internal.jank.Cuj;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatedFloat;
|
||||
import com.android.launcher3.icons.GraphicsUtils;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.util.DesktopTask;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
@@ -103,6 +109,11 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
|
||||
private static final long CONTENT_ALPHA_ANIMATION_DURATION_MS = 83;
|
||||
private static final long CONTENT_ALPHA_ANIMATION_START_DELAY_MS = 83;
|
||||
|
||||
private static final int DARK_THEME_STROKE_ALPHA = 51;
|
||||
private static final int LIGHT_THEME_STROKE_ALPHA = 41;
|
||||
private static final int DARK_THEME_SHADOW_ALPHA = 51;
|
||||
private static final int LIGHT_THEME_SHADOW_ALPHA = 25;
|
||||
|
||||
private final AnimatedFloat mOutlineAnimationProgress = new AnimatedFloat(
|
||||
this::invalidateOutline);
|
||||
|
||||
@@ -122,6 +133,14 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
|
||||
private int mOutlineRadius;
|
||||
private boolean mIsRtl;
|
||||
|
||||
// Used to paint a background with a shadow.
|
||||
private final Paint mBackgroundPaint = new Paint();
|
||||
private float mBackgroundShadowBlur;
|
||||
private float mBackgroundShadowDistance;
|
||||
private final Paint mStrokePaint = new Paint();
|
||||
private final RectF mLastBackgroundRect = new RectF();
|
||||
|
||||
|
||||
private int mOverviewTaskIndex = -1;
|
||||
private int mDesktopTaskIndex = -1;
|
||||
|
||||
@@ -184,11 +203,47 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
|
||||
|
||||
mIsRtl = Utilities.isRtl(resources);
|
||||
|
||||
mBackgroundPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
|
||||
mBackgroundPaint.setStyle(Paint.Style.FILL);
|
||||
mBackgroundPaint.setColor(
|
||||
Themes.getAttrColor(getContext(), R.attr.overviewScrimColorFallback));
|
||||
mBackgroundShadowBlur = resources.getDimension(R.dimen.transient_taskbar_shadow_blur);
|
||||
mBackgroundShadowDistance = resources.getDimension(
|
||||
R.dimen.transient_taskbar_key_shadow_distance);
|
||||
|
||||
|
||||
mStrokePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
|
||||
mStrokePaint.setStyle(Paint.Style.STROKE);
|
||||
mStrokePaint.setStrokeWidth(
|
||||
getResources().getDimension(R.dimen.transient_taskbar_stroke_width));
|
||||
mStrokePaint.setColor(
|
||||
getResources().getColor(R.color.taskbar_stroke, getContext().getTheme()));
|
||||
|
||||
TypefaceUtils.setTypeface(
|
||||
mNoRecentItemsPane.findViewById(R.id.no_recent_items_text),
|
||||
FontFamily.GSF_LABEL_LARGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
||||
boolean isDarkTheme = Utilities.isDarkTheme(getContext());
|
||||
mStrokePaint.setAlpha(isDarkTheme ? DARK_THEME_STROKE_ALPHA : LIGHT_THEME_STROKE_ALPHA);
|
||||
|
||||
// Draw shadow.
|
||||
mBackgroundPaint.setShadowLayer(
|
||||
mBackgroundShadowBlur,
|
||||
0,
|
||||
mBackgroundShadowDistance,
|
||||
GraphicsUtils.setColorAlphaBound(Color.BLACK,
|
||||
isDarkTheme ? DARK_THEME_SHADOW_ALPHA : LIGHT_THEME_SHADOW_ALPHA));
|
||||
mLastBackgroundRect.set(0, 0, getWidth(), getHeight());
|
||||
|
||||
canvas.drawRoundRect(mLastBackgroundRect, mOutlineRadius, mOutlineRadius, mBackgroundPaint);
|
||||
canvas.drawRoundRect(mLastBackgroundRect, mOutlineRadius, mOutlineRadius, mStrokePaint);
|
||||
}
|
||||
|
||||
private void registerOnBackInvokedCallback() {
|
||||
OnBackInvokedDispatcher dispatcher = findOnBackInvokedDispatcher();
|
||||
|
||||
|
||||
Reference in new issue
Block a user