From b4626f46986e12fcc914b545ab2e1636faee3942 Mon Sep 17 00:00:00 2001 From: helencheuk Date: Mon, 11 Dec 2023 11:33:30 +0000 Subject: [PATCH] Add focus outline to launcher Fix: 310953377 Test: TBC Flag: ACONFIG com.android.launcher3.enable_focus_outline Development Change-Id: Ie395ec74c8a4a13a68539ca7ec6496481d96b860 --- aconfig/launcher.aconfig | 7 +++++++ res/layout/folder_icon.xml | 3 ++- res/values/colors.xml | 1 + res/values/dimens.xml | 3 +++ .../keyboard/FocusIndicatorHelper.java | 17 +++++++++++++++-- .../keyboard/ItemFocusIndicatorHelper.java | 16 +++++++++++++--- 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig index af175ce921..210cfd02bb 100644 --- a/aconfig/launcher.aconfig +++ b/aconfig/launcher.aconfig @@ -42,6 +42,13 @@ flag { bug: "257950105" } +flag { + name: "enable_focus_outline" + namespace: "launcher" + description: "Enables focus states outline for launcher." + bug: "310953377" +} + flag { name: "enable_taskbar_no_recreate" namespace: "launcher" diff --git a/res/layout/folder_icon.xml b/res/layout/folder_icon.xml index 4093744628..6af346e042 100644 --- a/res/layout/folder_icon.xml +++ b/res/layout/folder_icon.xml @@ -19,7 +19,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:focusable="true" > + android:focusable="true" + android:defaultFocusHighlightEnabled="false"> #FFF0592B #80c6c5c5 + @color/material_color_on_secondary_container #FF000000 diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 242c4396a5..7c0526b6b0 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -432,6 +432,9 @@ 60dp 8dp + 16dp + 3dp + 16dp 6dp diff --git a/src/com/android/launcher3/keyboard/FocusIndicatorHelper.java b/src/com/android/launcher3/keyboard/FocusIndicatorHelper.java index 83003ffb14..1a7d79755f 100644 --- a/src/com/android/launcher3/keyboard/FocusIndicatorHelper.java +++ b/src/com/android/launcher3/keyboard/FocusIndicatorHelper.java @@ -20,6 +20,7 @@ import android.graphics.Rect; import android.view.View; import android.view.View.OnFocusChangeListener; +import com.android.launcher3.Flags; import com.android.launcher3.R; /** @@ -29,7 +30,8 @@ public abstract class FocusIndicatorHelper extends ItemFocusIndicatorHelper implements AnimatorUpdateListe mContainer = container; mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - mMaxAlpha = Color.alpha(color); mPaint.setColor(0xFF000000 | color); + if (Flags.enableFocusOutline()) { + mPaint.setStyle(Paint.Style.STROKE); + mPaint.setStrokeWidth(container.getResources().getDimensionPixelSize( + R.dimen.focus_outline_stroke_width)); + mRadius = container.getResources().getDimensionPixelSize( + R.dimen.focus_outline_radius); + } else { + mPaint.setStyle(Paint.Style.FILL); + mRadius = container.getResources().getDimensionPixelSize( + R.dimen.grid_visualization_rounding_radius); + } + mMaxAlpha = Color.alpha(color); setAlpha(0); mShift = 0; - mRadius = container.getResources().getDimensionPixelSize( - R.dimen.grid_visualization_rounding_radius); } protected void setAlpha(float alpha) {