Skip to content

Commit

Permalink
[CheckBox] Integrated tokens
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 478796974
  • Loading branch information
leticiarossi authored and paulfthomas committed Oct 4, 2022
1 parent 9806ad9 commit e67e68d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
Expand Up @@ -411,6 +411,11 @@ public void setCheckedState(@CheckedState int checkedState) {
}

broadcasting = false;

// This is needed due to a pre-21 bug where the drawable states don't get updated correctly.
if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP && buttonIconDrawable != null) {
refreshDrawableState();
}
}
}

Expand Down
Expand Up @@ -17,17 +17,17 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Disabled -->
<item android:color="?attr/colorSurface" android:state_enabled="false"/>
<item android:color="@macro/m3_comp_checkbox_selected_disabled_icon_color" android:state_enabled="false"/>

<!-- Error -->
<item android:color="?attr/colorOnError" app:state_error="true"/>
<item android:color="@macro/m3_comp_checkbox_selected_error_icon_color" app:state_error="true"/>

<!-- Indeterminate -->
<item android:color="?attr/colorOnPrimary" app:state_indeterminate="true"/>
<item android:color="@macro/m3_comp_checkbox_selected_icon_color" app:state_indeterminate="true"/>

<!-- Checked -->
<item android:color="?attr/colorOnPrimary" android:state_checked="true"/>
<item android:color="@macro/m3_comp_checkbox_selected_icon_color" android:state_checked="true"/>

<!-- Unchecked -->
<item android:color="?attr/colorOnPrimary" android:state_checked="false"/>
<item android:color="@macro/m3_comp_checkbox_selected_icon_color" android:state_checked="false"/>
</selector>
Expand Up @@ -17,16 +17,18 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Disabled -->
<item android:alpha="@dimen/material_emphasis_disabled" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
<item android:alpha="@dimen/m3_comp_checkbox_selected_disabled_container_opacity"
android:color="@macro/m3_comp_checkbox_selected_disabled_container_color"
android:state_enabled="false"/>

<!-- Error -->
<item android:color="?attr/colorError" app:state_error="true"/>
<item android:color="@macro/m3_comp_checkbox_selected_error_container_color" app:state_error="true"/>

<!-- Indeterminate -->
<item android:color="?attr/colorPrimary" app:state_indeterminate="true"/>
<item android:color="@macro/m3_comp_checkbox_selected_container_color" app:state_indeterminate="true"/>

<!-- Checked -->
<item android:color="?attr/colorPrimary" android:state_checked="true"/>
<item android:color="@macro/m3_comp_checkbox_selected_container_color" android:state_checked="true"/>

<!-- Unchecked -->
<item android:color="?attr/colorOnSurface" android:state_checked="false"/>
Expand Down
@@ -0,0 +1,33 @@
<?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.126 -->

<resources>
<!-- Generated from token set (md.comp.checkbox) in default context. -->
<!-- Enabled - Container -->
<macro name="m3_comp_checkbox_selected_container_color">?attr/colorPrimary</macro>
<macro name="m3_comp_checkbox_selected_error_container_color">?attr/colorError</macro>
<!-- Enabled - Icon -->
<macro name="m3_comp_checkbox_selected_icon_color">?attr/colorOnPrimary</macro>
<macro name="m3_comp_checkbox_selected_error_icon_color">?attr/colorOnError</macro>
<!-- Disabled - Container -->
<macro name="m3_comp_checkbox_selected_disabled_container_color">?attr/colorOnSurface</macro>
<item name="m3_comp_checkbox_selected_disabled_container_opacity" format="float" type="dimen">0.38</item>
<!-- Disabled - Icon -->
<macro name="m3_comp_checkbox_selected_disabled_icon_color">?attr/colorSurface</macro>
</resources>

0 comments on commit e67e68d

Please sign in to comment.