diff --git a/quickstep/res/drawable/keyboard_quick_switch_view_background.xml b/quickstep/res/drawable/keyboard_quick_switch_view_background.xml index af384c0fe9..d9684cecde 100644 --- a/quickstep/res/drawable/keyboard_quick_switch_view_background.xml +++ b/quickstep/res/drawable/keyboard_quick_switch_view_background.xml @@ -16,6 +16,6 @@ - + diff --git a/quickstep/res/layout/keyboard_quick_switch_view.xml b/quickstep/res/layout/keyboard_quick_switch_view.xml index 2dea79c8a2..39f4d3ee6d 100644 --- a/quickstep/res/layout/keyboard_quick_switch_view.xml +++ b/quickstep/res/layout/keyboard_quick_switch_view.xml @@ -26,7 +26,6 @@ android:layout_marginHorizontal="@dimen/keyboard_quick_switch_margin_ends" android:layout_gravity="center_horizontal" android:background="@drawable/keyboard_quick_switch_view_background" - android:clipToOutline="true" android:alpha="0" android:visibility="invisible" android:focusableInTouchMode="true" diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index 0026396b17..7a17d6d2b9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -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();