Skip to content

Commit 3e6219c

Browse files
ikim24afohrman
authored andcommitted
Rolling forward using colorControlActivated instead of colorSecondary for the activated color of MaterialCheckbox, MaterialRadioButton, and SwitchMaterial.
By default, colorControlActivated is set to colorAccent. Non-bridge themes set colorAccent to colorSecondary. PiperOrigin-RevId: 235041384
1 parent 59bc6c3 commit 3e6219c

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
*
3636
* <p>This class uses attributes from the Material Theme to style a CheckBox. Excepting color
3737
* changes, it behaves identically to {@link AppCompatCheckBox}. Your theme's {@code
38-
* ?attr/colorSecondary}, {@code ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must be set.
38+
* ?attr/colorControlActivated}, {@code ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must
39+
* be set.
3940
*/
4041
public class MaterialCheckBox extends AppCompatCheckBox {
4142

@@ -103,12 +104,12 @@ public boolean isUseMaterialThemeColors() {
103104
private ColorStateList getMaterialThemeColorsTintList() {
104105
if (materialThemeColorsTintList == null) {
105106
int[] checkBoxColorsList = new int[ENABLED_CHECKED_STATES.length];
106-
int colorSecondary = MaterialColors.getColor(this, R.attr.colorSecondary);
107+
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
107108
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
108109
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface);
109110

110111
checkBoxColorsList[0] =
111-
MaterialColors.layer(colorSurface, colorSecondary, MaterialColors.ALPHA_FULL);
112+
MaterialColors.layer(colorSurface, colorControlActivated, MaterialColors.ALPHA_FULL);
112113
checkBoxColorsList[1] =
113114
MaterialColors.layer(colorSurface, colorOnSurface, MaterialColors.ALPHA_MEDIUM);
114115
checkBoxColorsList[2] =

lib/java/com/google/android/material/radiobutton/MaterialRadioButton.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
*
3636
* <p>This class uses attributes from the Material Theme to style a RadioButton. Excepting color
3737
* changes, it behaves identically to {@link AppCompatRadioButton}. Your theme's {@code
38-
* ?attr/colorSecondary}, {@code ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must be set.
38+
* ?attr/colorControlActivated}, {@code ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must
39+
* be set.
3940
*/
4041
public class MaterialRadioButton extends AppCompatRadioButton {
4142

@@ -102,13 +103,13 @@ public boolean isUseMaterialThemeColors() {
102103

103104
private ColorStateList getMaterialThemeColorsTintList() {
104105
if (materialThemeColorsTintList == null) {
105-
int colorSecondary = MaterialColors.getColor(this, R.attr.colorSecondary);
106+
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
106107
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface);
107108
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
108109

109110
int[] radioButtonColorList = new int[ENABLED_CHECKED_STATES.length];
110111
radioButtonColorList[0] =
111-
MaterialColors.layer(colorSurface, colorSecondary, MaterialColors.ALPHA_FULL);
112+
MaterialColors.layer(colorSurface, colorControlActivated, MaterialColors.ALPHA_FULL);
112113
radioButtonColorList[1] =
113114
MaterialColors.layer(colorSurface, colorOnSurface, MaterialColors.ALPHA_MEDIUM);
114115
radioButtonColorList[2] =

lib/java/com/google/android/material/switchmaterial/SwitchMaterial.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
* A class that creates a Material Themed Switch.
3434
*
3535
* <p>This class uses attributes from the Material Theme to style a Switch. Excepting color changes,
36-
* it behaves identically to {@link SwitchCompat}. Your theme's {@code ?attr/colorSecondary}, {@code
37-
* ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must be set. Because {@link SwitchCompat}
38-
* does not extend {@link android.widget.Switch}, you must explicitly declare {@link SwitchMaterial}
39-
* in your layout XML.
36+
* it behaves identically to {@link SwitchCompat}. Your theme's {@code ?attr/colorControlActivated},
37+
* {@code ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must be set. Because {@link
38+
* SwitchCompat} does not extend {@link android.widget.Switch}, you must explicitly declare {@link
39+
* SwitchMaterial} in your layout XML.
4040
*/
4141
public class SwitchMaterial extends SwitchCompat {
4242

@@ -113,15 +113,15 @@ public boolean isUseMaterialThemeColors() {
113113
private ColorStateList getMaterialThemeColorsThumbTintList() {
114114
if (materialThemeColorsThumbTintList == null) {
115115
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
116-
int colorSecondary = MaterialColors.getColor(this, R.attr.colorSecondary);
116+
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
117117

118118
int[] switchThumbColorsList = new int[ENABLED_CHECKED_STATES.length];
119119
switchThumbColorsList[0] =
120-
MaterialColors.layer(colorSurface, colorSecondary, MaterialColors.ALPHA_FULL);
120+
MaterialColors.layer(colorSurface, colorControlActivated, MaterialColors.ALPHA_FULL);
121121
switchThumbColorsList[1] =
122122
MaterialColors.layer(colorSurface, colorSurface, MaterialColors.ALPHA_FULL);
123123
switchThumbColorsList[2] =
124-
MaterialColors.layer(colorSurface, colorSecondary, MaterialColors.ALPHA_DISABLED);
124+
MaterialColors.layer(colorSurface, colorControlActivated, MaterialColors.ALPHA_DISABLED);
125125
switchThumbColorsList[3] =
126126
MaterialColors.layer(colorSurface, colorSurface, MaterialColors.ALPHA_FULL);
127127
materialThemeColorsThumbTintList =
@@ -134,14 +134,15 @@ private ColorStateList getMaterialThemeColorsTrackTintList() {
134134
if (materialThemeColorsTrackTintList == null) {
135135
int[] switchTrackColorsList = new int[ENABLED_CHECKED_STATES.length];
136136
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
137-
int colorSecondary = MaterialColors.getColor(this, R.attr.colorSecondary);
137+
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
138138
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface);
139139
switchTrackColorsList[0] =
140-
MaterialColors.layer(colorSurface, colorSecondary, MaterialColors.ALPHA_MEDIUM);
140+
MaterialColors.layer(colorSurface, colorControlActivated, MaterialColors.ALPHA_MEDIUM);
141141
switchTrackColorsList[1] =
142142
MaterialColors.layer(colorSurface, colorOnSurface, MaterialColors.ALPHA_LOW);
143143
switchTrackColorsList[2] =
144-
MaterialColors.layer(colorSurface, colorSecondary, MaterialColors.ALPHA_DISABLED_LOW);
144+
MaterialColors.layer(
145+
colorSurface, colorControlActivated, MaterialColors.ALPHA_DISABLED_LOW);
145146
switchTrackColorsList[3] =
146147
MaterialColors.layer(colorSurface, colorOnSurface, MaterialColors.ALPHA_DISABLED_LOW);
147148
materialThemeColorsTrackTintList =

0 commit comments

Comments
 (0)