Skip to content

Commit e67e68d

Browse files
leticiarossipaulfthomas
authored andcommitted
[CheckBox] Integrated tokens
PiperOrigin-RevId: 478796974
1 parent 9806ad9 commit e67e68d

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

lib/java/com/google/android/material/checkbox/MaterialCheckBox.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ public void setCheckedState(@CheckedState int checkedState) {
411411
}
412412

413413
broadcasting = false;
414+
415+
// This is needed due to a pre-21 bug where the drawable states don't get updated correctly.
416+
if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP && buttonIconDrawable != null) {
417+
refreshDrawableState();
418+
}
414419
}
415420
}
416421

lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_icon_tint.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
<selector xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:app="http://schemas.android.com/apk/res-auto">
1919
<!-- Disabled -->
20-
<item android:color="?attr/colorSurface" android:state_enabled="false"/>
20+
<item android:color="@macro/m3_comp_checkbox_selected_disabled_icon_color" android:state_enabled="false"/>
2121

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

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

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

3131
<!-- Unchecked -->
32-
<item android:color="?attr/colorOnPrimary" android:state_checked="false"/>
32+
<item android:color="@macro/m3_comp_checkbox_selected_icon_color" android:state_checked="false"/>
3333
</selector>

lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_tint.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
<selector xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:app="http://schemas.android.com/apk/res-auto">
1919
<!-- Disabled -->
20-
<item android:alpha="@dimen/material_emphasis_disabled" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
20+
<item android:alpha="@dimen/m3_comp_checkbox_selected_disabled_container_opacity"
21+
android:color="@macro/m3_comp_checkbox_selected_disabled_container_color"
22+
android:state_enabled="false"/>
2123

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

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

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

3133
<!-- Unchecked -->
3234
<item android:color="?attr/colorOnSurface" android:state_checked="false"/>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2022 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+
<!-- AUTOGENERATED FILE. DO NOT MODIFY. -->
18+
<!-- Version: v0.126 -->
19+
20+
<resources>
21+
<!-- Generated from token set (md.comp.checkbox) in default context. -->
22+
<!-- Enabled - Container -->
23+
<macro name="m3_comp_checkbox_selected_container_color">?attr/colorPrimary</macro>
24+
<macro name="m3_comp_checkbox_selected_error_container_color">?attr/colorError</macro>
25+
<!-- Enabled - Icon -->
26+
<macro name="m3_comp_checkbox_selected_icon_color">?attr/colorOnPrimary</macro>
27+
<macro name="m3_comp_checkbox_selected_error_icon_color">?attr/colorOnError</macro>
28+
<!-- Disabled - Container -->
29+
<macro name="m3_comp_checkbox_selected_disabled_container_color">?attr/colorOnSurface</macro>
30+
<item name="m3_comp_checkbox_selected_disabled_container_opacity" format="float" type="dimen">0.38</item>
31+
<!-- Disabled - Icon -->
32+
<macro name="m3_comp_checkbox_selected_disabled_icon_color">?attr/colorSurface</macro>
33+
</resources>

0 commit comments

Comments
 (0)