Skip to content

Commit

Permalink
[RadioButton] Integrated tokens.
Browse files Browse the repository at this point in the history
Unselected icon color is changed from colorOnSurface to colorOnSurfaceVariant.

PiperOrigin-RevId: 501869216
  • Loading branch information
pekingme authored and raajkumars committed Jan 17, 2023
1 parent d5a3701 commit 7f0db1a
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,30 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Disabled -->
<item android:alpha="@dimen/material_emphasis_disabled" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
<item android:alpha="@dimen/m3_comp_radio_button_disabled_unselected_icon_opacity"
android:color="@macro/m3_comp_radio_button_disabled_unselected_icon_color"
android:state_enabled="false"/>
<item android:alpha="@dimen/m3_comp_radio_button_disabled_selected_icon_opacity"
android:color="@macro/m3_comp_radio_button_disabled_selected_icon_color"
android:state_enabled="false" android:state_pressed="true"/>

<!-- Checked -->
<item android:color="?attr/colorPrimary" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_selected_pressed_icon_color"
android:state_pressed="true" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_selected_focus_icon_color"
android:state_focused="true" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_selected_hover_icon_color"
android:state_hovered="true" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_selected_icon_color"
android:state_checked="true"/>

<!-- Unchecked -->
<item android:color="?attr/colorOnSurface" android:state_checked="false"/>
<item android:color="@macro/m3_comp_radio_button_unselected_pressed_icon_color"
android:state_pressed="true" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_unselected_focus_icon_color"
android:state_focused="true" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_unselected_hover_icon_color"
android:state_hovered="true" android:state_checked="true"/>
<item android:color="@macro/m3_comp_radio_button_unselected_icon_color"
android:state_checked="false"/>
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,33 @@
<!-- Checked. -->

<!-- Uses the primary state layer since tapping a checked radiobutton keeps it checked. -->
<item android:alpha="@dimen/m3_ripple_pressed_alpha" android:color="?attr/colorPrimary"
<item android:alpha="@dimen/m3_comp_radio_button_selected_pressed_state_layer_opacity"
android:color="@macro/m3_comp_radio_button_selected_pressed_state_layer_color"
android:state_pressed="true" android:state_checked="true"/>
<item android:alpha="@dimen/m3_ripple_focused_alpha" android:color="?attr/colorPrimary"
<item android:alpha="@dimen/m3_comp_radio_button_selected_focus_state_layer_opacity"
android:color="@macro/m3_comp_radio_button_selected_focus_state_layer_color"
android:state_focused="true" android:state_checked="true"/>
<item android:alpha="@dimen/m3_ripple_hovered_alpha" android:color="?attr/colorPrimary"
<item android:alpha="@dimen/m3_comp_radio_button_selected_hover_state_layer_opacity"
android:color="@macro/m3_comp_radio_button_selected_hover_state_layer_color"
android:state_hovered="true" android:state_checked="true"/>
<item android:alpha="@dimen/m3_ripple_default_alpha" android:color="?attr/colorPrimary"
<item android:alpha="@dimen/m3_ripple_default_alpha"
android:color="?attr/colorPrimary"
android:state_checked="true"/>

<!-- Unchecked. -->

<!-- Uses the primary state layer since tapping an unchecked radiobutton will turn it blue
(checked). -->
<item android:alpha="@dimen/m3_ripple_selectable_pressed_alpha" android:color="?attr/colorPrimary"
<item android:alpha="@dimen/m3_comp_radio_button_unselected_pressed_state_layer_opacity"
android:color="@macro/m3_comp_radio_button_unselected_pressed_state_layer_color"
android:state_pressed="true"/>
<item android:alpha="@dimen/m3_ripple_focused_alpha" android:color="?attr/colorOnSurface"
<item android:alpha="@dimen/m3_comp_radio_button_unselected_focus_state_layer_opacity"
android:color="@macro/m3_comp_radio_button_unselected_focus_state_layer_color"
android:state_focused="true"/>
<item android:alpha="@dimen/m3_ripple_hovered_alpha" android:color="?attr/colorOnSurface"
<item android:alpha="@dimen/m3_comp_radio_button_unselected_hover_state_layer_opacity"
android:color="@macro/m3_comp_radio_button_unselected_hover_state_layer_color"
android:state_hovered="true"/>
<item android:alpha="@dimen/m3_ripple_default_alpha" android:color="?attr/colorOnSurface"/>
<item android:alpha="@dimen/m3_ripple_default_alpha"
android:color="?attr/colorOnSurface"/>

</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<!-- AUTOGENERATED FILE. DO NOT MODIFY. -->
<!-- Version: v0.147 -->

<resources>

<!-- Generated from token set (md.comp.radio-button) in context (platform=android, audience=3p). -->
<!-- Enabled - Icon -->
<macro name="m3_comp_radio_button_selected_icon_color">?attr/colorPrimary</macro>
<macro name="m3_comp_radio_button_unselected_icon_color">?attr/colorOnSurfaceVariant</macro>
<!-- Disabled - Icon -->
<macro name="m3_comp_radio_button_disabled_selected_icon_color">?attr/colorOnSurface</macro>
<item name="m3_comp_radio_button_disabled_selected_icon_opacity" format="float" type="dimen">0.38</item>
<macro name="m3_comp_radio_button_disabled_unselected_icon_color">?attr/colorOnSurface</macro>
<item name="m3_comp_radio_button_disabled_unselected_icon_opacity" format="float" type="dimen">0.38</item>
<!-- Hovered - State layer -->
<macro name="m3_comp_radio_button_selected_hover_state_layer_color">?attr/colorPrimary</macro>
<dimen name="m3_comp_radio_button_selected_hover_state_layer_opacity">@dimen/m3_sys_state_hover_state_layer_opacity</dimen>
<macro name="m3_comp_radio_button_unselected_hover_state_layer_color">?attr/colorOnSurface</macro>
<dimen name="m3_comp_radio_button_unselected_hover_state_layer_opacity">@dimen/m3_sys_state_hover_state_layer_opacity</dimen>
<!-- Hovered - Icon -->
<macro name="m3_comp_radio_button_selected_hover_icon_color">?attr/colorPrimary</macro>
<macro name="m3_comp_radio_button_unselected_hover_icon_color">?attr/colorOnSurface</macro>
<!-- Focused - State layer -->
<macro name="m3_comp_radio_button_selected_focus_state_layer_color">?attr/colorPrimary</macro>
<dimen name="m3_comp_radio_button_selected_focus_state_layer_opacity">@dimen/m3_sys_state_focus_state_layer_opacity</dimen>
<macro name="m3_comp_radio_button_unselected_focus_state_layer_color">?attr/colorOnSurface</macro>
<dimen name="m3_comp_radio_button_unselected_focus_state_layer_opacity">@dimen/m3_sys_state_focus_state_layer_opacity</dimen>
<!-- Focused - Icon -->
<macro name="m3_comp_radio_button_selected_focus_icon_color">?attr/colorPrimary</macro>
<macro name="m3_comp_radio_button_unselected_focus_icon_color">?attr/colorOnSurface</macro>
<!-- Pressed (rippple) - State layer -->
<macro name="m3_comp_radio_button_selected_pressed_state_layer_color">?attr/colorOnSurface</macro>
<dimen name="m3_comp_radio_button_selected_pressed_state_layer_opacity">@dimen/m3_sys_state_pressed_state_layer_opacity</dimen>
<macro name="m3_comp_radio_button_unselected_pressed_state_layer_color">?attr/colorPrimary</macro>
<dimen name="m3_comp_radio_button_unselected_pressed_state_layer_opacity">@dimen/m3_sys_state_pressed_state_layer_opacity</dimen>
<!-- Pressed (rippple) - Icon -->
<macro name="m3_comp_radio_button_selected_pressed_icon_color">?attr/colorPrimary</macro>
<macro name="m3_comp_radio_button_unselected_pressed_icon_color">?attr/colorOnSurface</macro>

</resources>

0 comments on commit 7f0db1a

Please sign in to comment.