Skip to content

Commit 8ecb378

Browse files
committed
[Focus Rings] Move toolbar FocusRingDrawable usages from main themes to .FocusRings themes
PiperOrigin-RevId: 897080895
1 parent ca90045 commit 8ecb378

13 files changed

Lines changed: 318 additions & 8 deletions

lib/java/com/google/android/material/appbar/res/values-v24/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- TODO: remove and update main style to use ?attr/controlBackground for android:background. -->
2020
<style name="Widget.Material3.Toolbar.Button.Navigation" parent="Widget.AppCompat.Toolbar.Button.Navigation">
21-
<item name="android:background">@drawable/m3_focus_ring_control_background</item>
21+
<item name="android:background">?attr/toolbarNavigationButtonBackground</item>
2222
</style>
2323

2424
</resources>

lib/java/com/google/android/material/appbar/res/values/attrs.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@
4040
<!-- Color of the circle when using ThemeOverlay.Material3.Toolbar.CircleNavigationButton. -->
4141
<attr name="toolbarNavigationButtonCircleColor" format="color"/>
4242

43+
<!-- The background drawable used by Toolbar and MaterialToolbar navigation buttons in M3+. -->
44+
<attr name="toolbarNavigationButtonBackground" format="color"/>
45+
46+
<!-- The selectableItemBackground drawable used by MaterialToolbars in M3+. -->
47+
<attr name="materialToolbarSelectableItemBackground" format="reference"/>
48+
49+
<!-- The selectableItemBackgroundBorderless drawable used by MaterialToolbars in M3+. -->
50+
<attr name="materialToolbarSelectableItemBackgroundBorderless" format="reference"/>
51+
52+
<!-- The actionBarItemBackground drawable used by MaterialToolbars in M3+. -->
53+
<attr name="materialToolbarActionBarItemBackground" format="reference"/>
54+
4355
<declare-styleable name="AppBarLayout">
4456
<!-- Deprecated. Elevation is now controlled via a state list animator. -->
4557
<attr name="elevation"/>

lib/java/com/google/android/material/appbar/res/values/styles.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@
154154

155155
<style name="ThemeOverlay.Material3.Toolbar" parent="">
156156
<!-- Overridding the AppCompat / Android drawable attributes for correct ripple colors. -->
157-
<item name="selectableItemBackground">@drawable/m3_selectable_item_background</item>
158-
<item name="android:selectableItemBackground">@drawable/m3_selectable_item_background</item>
159-
<item name="selectableItemBackgroundBorderless">@drawable/m3_selectable_item_background_borderless</item>
160-
<item name="android:selectableItemBackgroundBorderless">@drawable/m3_selectable_item_background_borderless</item>
161-
<item name="actionBarItemBackground">@drawable/m3_action_bar_item_background</item>
162-
<item name="android:actionBarItemBackground">@drawable/m3_action_bar_item_background</item>
163-
<item name="controlBackground">@drawable/m3_action_bar_item_background</item>
157+
<item name="selectableItemBackground">?attr/materialToolbarSelectableItemBackground</item>
158+
<item name="android:selectableItemBackground">?attr/materialToolbarSelectableItemBackground</item>
159+
<item name="selectableItemBackgroundBorderless">?attr/materialToolbarSelectableItemBackgroundBorderless</item>
160+
<item name="android:selectableItemBackgroundBorderless">?attr/materialToolbarSelectableItemBackgroundBorderless</item>
161+
<item name="actionBarItemBackground">?attr/materialToolbarActionBarItemBackground</item>
162+
<item name="android:actionBarItemBackground">?attr/materialToolbarActionBarItemBackground</item>
163+
<item name="controlBackground">?attr/materialToolbarActionBarItemBackground</item>
164164
</style>
165165

166166
<style name="ThemeOverlay.Material3.Toolbar.Surface">

lib/java/com/google/android/material/color/res/drawable-v24/m3_action_bar_item_background.xml renamed to lib/java/com/google/android/material/color/res/drawable-v24/m3_focus_ring_toolbar_action_bar_item_background.xml

File renamed without changes.

lib/java/com/google/android/material/color/res/drawable-v24/m3_selectable_item_background.xml renamed to lib/java/com/google/android/material/color/res/drawable-v24/m3_focus_ring_toolbar_selectable_item_background.xml

File renamed without changes.

lib/java/com/google/android/material/color/res/drawable-v24/m3_selectable_item_background_borderless.xml renamed to lib/java/com/google/android/material/color/res/drawable-v24/m3_focus_ring_toolbar_selectable_item_background_borderless.xml

File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2026 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="@color/m3_control_ripple_color_selector"
19+
android:radius="20dp"/>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2026 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="@color/m3_control_ripple_color_selector">
19+
<item android:id="@android:id/mask">
20+
<color android:color="@android:color/white" />
21+
</item>
22+
</ripple>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2026 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="@color/m3_control_ripple_color_selector"/>

lib/java/com/google/android/material/dialog/res/values/themes_base_bridge.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
<item name="focusRingsInnerStrokeWidth">@dimen/mtrl_focus_ring_inner_stroke_width</item>
5353
<item name="focusRingsInnerStrokeInset">@dimen/mtrl_focus_ring_inner_stroke_inset</item>
5454

55+
<!-- Toolbar Drawables. -->
56+
<item name="toolbarNavigationButtonBackground">@drawable/m3_default_control_background</item>
57+
<item name="materialToolbarSelectableItemBackground">@drawable/m3_selectable_item_background</item>
58+
<item name="materialToolbarSelectableItemBackgroundBorderless">@drawable/m3_selectable_item_background_borderless</item>
59+
<item name="materialToolbarActionBarItemBackground">@drawable/m3_action_bar_item_background</item>
60+
5561
<item name="scrimBackground">@color/mtrl_scrim_color</item>
5662
<item name="popupMenuBackground">@drawable/mtrl_popupmenu_background_overlay</item>
5763

@@ -142,6 +148,12 @@
142148
<item name="focusRingsInnerStrokeWidth">@dimen/mtrl_focus_ring_inner_stroke_width</item>
143149
<item name="focusRingsInnerStrokeInset">@dimen/mtrl_focus_ring_inner_stroke_inset</item>
144150

151+
<!-- Toolbar Drawables. -->
152+
<item name="toolbarNavigationButtonBackground">@drawable/m3_default_control_background</item>
153+
<item name="materialToolbarSelectableItemBackground">@drawable/m3_selectable_item_background</item>
154+
<item name="materialToolbarSelectableItemBackgroundBorderless">@drawable/m3_selectable_item_background_borderless</item>
155+
<item name="materialToolbarActionBarItemBackground">@drawable/m3_action_bar_item_background</item>
156+
145157
<item name="scrimBackground">@color/mtrl_scrim_color</item>
146158
<item name="popupMenuBackground">@drawable/mtrl_popupmenu_background</item>
147159

0 commit comments

Comments
 (0)