diff --git a/packages/SystemUI/res/values-night/dimens.xml b/packages/SystemUI/res/values-night/dimens.xml
index d2d4198b77286..9fc86db48c804 100644
--- a/packages/SystemUI/res/values-night/dimens.xml
+++ b/packages/SystemUI/res/values-night/dimens.xml
@@ -20,4 +20,7 @@
375dp
+
+ 1dp
+ -2dp
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index ede6260cfdea1..5dc705093665d 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1323,8 +1323,8 @@
3dp
- 1dp
- -2dp
+ 0dp
+ 0dp
16dp
6dp
36dp
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuView.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuView.java
index 22c387ee2f5ac..7e53d3a6ed52f 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuView.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuView.java
@@ -77,8 +77,14 @@ class MenuView extends FrameLayout {
}
private void onEdgeChanged() {
+ final int[] insets = mMenuViewAppearance.getMenuInsets();
+ getContainerViewInsetLayer().setLayerInset(INDEX_MENU_ITEM, insets[0], insets[1], insets[2],
+ insets[3]);
+
final GradientDrawable gradientDrawable = getContainerViewGradient();
gradientDrawable.setCornerRadii(mMenuViewAppearance.getMenuRadii());
+ gradientDrawable.setStroke(mMenuViewAppearance.getMenuStrokeWidth(),
+ mMenuViewAppearance.getMenuStrokeColor());
}
@SuppressLint("NotifyDataSetChanged")
@@ -104,7 +110,7 @@ class MenuView extends FrameLayout {
mMenuViewModel.unregisterContentObservers();
}
- private void loadLayoutResources() {
+ void loadLayoutResources() {
mMenuViewAppearance.update();
setBackground(mMenuViewAppearance.getMenuBackground());
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java
index ccb297fa00d05..8af14dad8d19f 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java
@@ -20,6 +20,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
+import androidx.annotation.DimenRes;
+
import com.android.systemui.R;
/**
@@ -32,6 +34,9 @@ class MenuViewAppearance {
private int mSmallIconSize;
private int mSmallSingleRadius;
private int mSmallMultipleRadius;
+ private int mStrokeWidth;
+ private int mStrokeColor;
+ private int mInset;
private int mElevation;
private float[] mRadii;
private Drawable mBackgroundDrawable;
@@ -52,6 +57,9 @@ class MenuViewAppearance {
mSmallMultipleRadius = mRes.getDimensionPixelSize(
R.dimen.accessibility_floating_menu_small_multiple_radius);
mRadii = createRadii(getMenuRadius(mTargetFeaturesSize));
+ mStrokeWidth = mRes.getDimensionPixelSize(R.dimen.accessibility_floating_menu_stroke_width);
+ mStrokeColor = mRes.getColor(R.color.accessibility_floating_menu_stroke_dark);
+ mInset = mRes.getDimensionPixelSize(R.dimen.accessibility_floating_menu_stroke_inset);
mElevation = mRes.getDimensionPixelSize(R.dimen.accessibility_floating_menu_elevation);
final Drawable drawable =
mRes.getDrawable(R.drawable.accessibility_floating_menu_background);
@@ -80,11 +88,28 @@ class MenuViewAppearance {
return mSmallPadding;
}
+ int[] getMenuInsets() {
+ return new int[]{mInset, 0, 0, 0};
+ }
+
+ int getMenuStrokeWidth() {
+ return mStrokeWidth;
+ }
+
+ int getMenuStrokeColor() {
+ return mStrokeColor;
+ }
+
float[] getMenuRadii() {
return mRadii;
}
private int getMenuRadius(int itemCount) {
+ return getSmallSize(itemCount);
+ }
+
+ @DimenRes
+ private int getSmallSize(int itemCount) {
return itemCount > 1 ? mSmallMultipleRadius : mSmallSingleRadius;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java
new file mode 100644
index 0000000000000..513044d2c20d6
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2022 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.systemui.accessibility.floatingmenu;
+
+import static android.app.UiModeManager.MODE_NIGHT_YES;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.app.UiModeManager;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/** Tests for {@link MenuView}. */
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@SmallTest
+public class MenuViewTest extends SysuiTestCase {
+ private static final int INDEX_MENU_ITEM = 0;
+ private int mNightMode;
+ private UiModeManager mUiModeManager;
+ private MenuView mMenuView;
+
+ @Before
+ public void setUp() throws Exception {
+ mUiModeManager = mContext.getSystemService(UiModeManager.class);
+ mNightMode = mUiModeManager.getNightMode();
+ mUiModeManager.setNightMode(MODE_NIGHT_YES);
+ final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext);
+ final MenuViewAppearance stubMenuViewAppearance = new MenuViewAppearance(mContext);
+ mMenuView = spy(new MenuView(mContext, stubMenuViewModel, stubMenuViewAppearance));
+ }
+
+ @Test
+ public void onConfigurationChanged_updateViewModel() {
+ mMenuView.onConfigurationChanged(/* newConfig= */ null);
+
+ verify(mMenuView).loadLayoutResources();
+ }
+
+ @Test
+ public void insetsOnDarkTheme_menuOnLeft_matchInsets() {
+ mMenuView.onConfigurationChanged(/* newConfig= */ null);
+ final InstantInsetLayerDrawable insetLayerDrawable =
+ (InstantInsetLayerDrawable) mMenuView.getBackground();
+ final boolean areInsetsMatched = insetLayerDrawable.getLayerInsetLeft(INDEX_MENU_ITEM) != 0
+ && insetLayerDrawable.getLayerInsetRight(INDEX_MENU_ITEM) == 0;
+
+ assertThat(areInsetsMatched).isTrue();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ mUiModeManager.setNightMode(mNightMode);
+ }
+}