From 1666fbc3aa16d584956b2acba3dd0d5ad7040165 Mon Sep 17 00:00:00 2001 From: leticiars Date: Wed, 20 Jul 2022 22:29:04 +0000 Subject: [PATCH] [Checkbox] Updated checkbox to M3 look. The checkbox is now composed of an `app:buttonCompat` button drawable (the squared icon) and an `app:buttonIcon` icon drawable (the checkmark icon) layered on top of it. The animation has also been updated. PiperOrigin-RevId: 462244130 (cherry picked from commit 8fae47a39e5244b8eb48c625597d985887db486f) --- docs/components/Checkbox.md | 20 +- .../material/checkbox/MaterialCheckBox.java | 330 +++++++++++++++++- .../checkbox/res-public/values/public.xml | 3 + .../color/m3_checkbox_button_icon_tint.xml | 30 ++ .../res/drawable/mtrl_checkbox_button.xml | 37 ++ ...mtrl_checkbox_button_checked_unchecked.xml | 55 +++ .../drawable/mtrl_checkbox_button_icon.xml | 37 ++ ...checkbox_button_icon_checked_unchecked.xml | 55 +++ ...checkbox_button_icon_unchecked_checked.xml | 55 +++ ...mtrl_checkbox_button_unchecked_checked.xml | 55 +++ .../res/drawable/mtrl_ic_check_mark.xml | 33 ++ .../res/drawable/mtrl_ic_checkbox_checked.xml | 38 ++ .../drawable/mtrl_ic_checkbox_unchecked.xml | 29 ++ .../material/checkbox/res/values/attrs.xml | 29 +- .../material/checkbox/res/values/strings.xml | 10 + .../material/checkbox/res/values/styles.xml | 10 +- .../material/internal/DrawableUtils.java | 149 ++++++++ .../materialswitch/MaterialSwitch.java | 116 +----- 18 files changed, 965 insertions(+), 126 deletions(-) create mode 100644 lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_icon_tint.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_checked_unchecked.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_checked_unchecked.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_unchecked_checked.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_unchecked_checked.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_check_mark.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_checked.xml create mode 100644 lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_unchecked.xml create mode 100644 lib/java/com/google/android/material/internal/DrawableUtils.java diff --git a/docs/components/Checkbox.md b/docs/components/Checkbox.md index 650d0454034..bfe695473d9 100644 --- a/docs/components/Checkbox.md +++ b/docs/components/Checkbox.md @@ -147,17 +147,22 @@ checkbox.setOnCheckedChangeListener { buttonView, isChecked -> ### Checkbox attributes +The checkbox is composed of an `app:buttonCompat` button drawable (the squared +icon) and an `app:buttonIcon` icon drawable (the checkmark icon) layered on top +of it. + Element | Attribute | Related method(s) | Default value -------------------------- | ------------------------------------------ | ---------------------------------------------------------- | ------------- **To use material colors** | `app:useMaterialThemeColors` | `setUseMaterialThemeColors`
`isUseMaterialThemeColors` | `true` (ignored if `app:buttonTint` is set) -**Color** | `app:buttonTint` | `setButtonTintList`
`getButtonTintList` | `?attr/colorOnSurface` (see all [states](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_tint.xml)) +**Button drawable** | `app:buttonCompat` | `setButtonDrawable`
`getButtonDrawable` | [@mtrl_checkbox_button](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button.xml) +**Button tint** | `app:buttonTint` | `setButtonTintList`
`getButtonTintList` | `?attr/colorOnSurface` (see all [states](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_tint.xml)) +**Button icon drawable** | `app:buttonIcon` | `setButtonIconDrawable`
`getButtonIconDrawable` | [@mtrl_checkbox_button_icon](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon.xml) +**Button icon tint** | `app:buttonIconTint` | `setButtonIconTintList`
`getButtonIconTintList` | `?attr/colorOnPrimary` (see all [states](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_icon_tint.xml)) **Min size** | `android:minWidth`
`android:minHeight` | `(set/get)MinWidth`
`(set/get)MinHeight` | `?attr/minTouchTargetSize` **Centered icon if no text** | `app:centerIfNoTextEnabled` | `setCenterIfNoTextEnabled`
`isCenterIfNoTextEnabled` | `true` -The color of the checkbox defaults to `?attr/colorOnSurface` (unchecked) and -`?attr/colorPrimary` (checked) defined in your app theme. If you want to -override this behavior, as you might with a custom drawable that should not be -tinted, set `app:useMaterialThemeColors` to `false`: +**Note:** If you'd like to change the default colors, override the above tint +attributes or set them to `@null` and `app:useMaterialThemeColors` to `false`. ```xml ``` +**Note:** If setting a custom `app:buttonCompat`, make sure to also set +`app:buttonIcon` if an icon is desired. The checkbox does not support having a +custom `app:buttonCompat` and preserving the default `app:buttonIcon` checkmark +at the same time. + ### Text label attributes Element | Attribute | Related method(s) | Default value diff --git a/lib/java/com/google/android/material/checkbox/MaterialCheckBox.java b/lib/java/com/google/android/material/checkbox/MaterialCheckBox.java index 76578d221aa..a4dee2d1e47 100644 --- a/lib/java/com/google/android/material/checkbox/MaterialCheckBox.java +++ b/lib/java/com/google/android/material/checkbox/MaterialCheckBox.java @@ -22,20 +22,31 @@ import android.content.Context; import android.content.res.ColorStateList; -import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.PorterDuff; +import android.graphics.PorterDuff.Mode; import android.graphics.Rect; +import android.graphics.drawable.AnimatedStateListDrawable; import android.graphics.drawable.Drawable; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; +import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.widget.AppCompatCheckBox; +import androidx.appcompat.widget.TintTypedArray; import android.text.TextUtils; import android.util.AttributeSet; import android.view.accessibility.AccessibilityNodeInfo; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.widget.CompoundButtonCompat; +import androidx.core.widget.TintableCompoundButton; +import androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback; +import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat; import com.google.android.material.color.MaterialColors; +import com.google.android.material.internal.DrawableUtils; import com.google.android.material.internal.ThemeEnforcement; import com.google.android.material.internal.ViewUtils; import com.google.android.material.resources.MaterialResources; @@ -44,15 +55,23 @@ /** * A class that creates a Material Themed CheckBox. * - *

This class uses attributes from the Material Theme to style a CheckBox. Excepting color - * changes, it behaves identically to {@link AppCompatCheckBox}. Your theme's {@code - * ?attr/colorControlActivated}, {@code ?attr/colorSurface}, and {@code ?attr/colorOnSurface} must - * be set. + *

This class uses attributes from the Material Theme to style a CheckBox. It behaves similarly + * to {@link AppCompatCheckBox}, but with color changes and the support of an error state. + * + *

The checkbox is composed of an {@code app:buttonCompat} button drawable (the squared icon) and + * an {@code app:buttonIcon} icon drawable (the checkmark icon) layered on top of it. Their colors + * can be customized via {@code app:buttonTint} and {@code app:buttonIconTint} respectively. + * + *

If setting a custom {@code app:buttonCompat}, make sure to also set {@code app:buttonIcon} if + * an icon is desired. The checkbox does not support having a custom {@code app:buttonCompat} and + * preserving the default {@code app:buttonIcon} checkmark at the same time. + * */ public class MaterialCheckBox extends AppCompatCheckBox { private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_CompoundButton_CheckBox; + private static final int[] ERROR_STATE_SET = {R.attr.state_error}; private static final int[][] CHECKBOX_STATES = new int[][] { @@ -70,6 +89,45 @@ public class MaterialCheckBox extends AppCompatCheckBox { private boolean errorShown; private CharSequence errorAccessibilityLabel; + @Nullable private Drawable buttonDrawable; + @Nullable private Drawable buttonIconDrawable; + private boolean usingDefaultButtonDrawable; + + @Nullable ColorStateList buttonTintList; + @Nullable ColorStateList buttonIconTintList; + @NonNull private PorterDuff.Mode buttonIconTintMode; + + private int[] currentStateChecked; + + @Nullable + private final AnimatedVectorDrawableCompat transitionToUnchecked = + AnimatedVectorDrawableCompat.create( + getContext(), R.drawable.mtrl_checkbox_button_checked_unchecked); + private final AnimationCallback transitionToUncheckedCallback = + new AnimationCallback() { + @Override + public void onAnimationStart(Drawable drawable) { + super.onAnimationStart(drawable); + if (buttonTintList != null) { + // Have the color remain on the checked state while the animation is happening. + DrawableCompat.setTint( + drawable, + buttonTintList.getColorForState( + currentStateChecked, buttonTintList.getDefaultColor())); + } + } + + @Override + public void onAnimationEnd(Drawable drawable) { + super.onAnimationEnd(drawable); + if (buttonTintList != null) { + DrawableCompat.setTintList( + drawable, + buttonTintList); + } + } + }; + /** * Callback interface invoked when the checkbox error state changes. */ @@ -97,19 +155,31 @@ public MaterialCheckBox(Context context, @Nullable AttributeSet attrs, int defSt // Ensure we are using the correctly themed context rather than the context that was passed in. context = getContext(); - TypedArray attributes = - ThemeEnforcement.obtainStyledAttributes( + buttonDrawable = CompoundButtonCompat.getButtonDrawable(this); + buttonTintList = getSuperButtonTintList(); + // Always use our custom tinting logic. + ((TintableCompoundButton) this).setSupportButtonTintList(null); + + TintTypedArray attributes = + ThemeEnforcement.obtainTintedStyledAttributes( context, attrs, R.styleable.MaterialCheckBox, defStyleAttr, DEF_STYLE_RES); - // If buttonTint is specified, read it using MaterialResources to allow themeable attributes in - // all API levels. - if (attributes.hasValue(R.styleable.MaterialCheckBox_buttonTint)) { - CompoundButtonCompat.setButtonTintList( - this, - MaterialResources.getColorStateList( - context, attributes, R.styleable.MaterialCheckBox_buttonTint)); + buttonIconDrawable = attributes.getDrawable(R.styleable.MaterialCheckBox_buttonIcon); + // If there's not a custom drawable set, we set our own. + if (buttonDrawable == null) { + buttonDrawable = AppCompatResources.getDrawable(context, R.drawable.mtrl_checkbox_button); + usingDefaultButtonDrawable = true; + if (buttonIconDrawable == null) { + buttonIconDrawable = + AppCompatResources.getDrawable(context, R.drawable.mtrl_checkbox_button_icon); + } } - + buttonIconTintList = + MaterialResources.getColorStateList( + context, attributes, R.styleable.MaterialCheckBox_buttonIconTint); + buttonIconTintMode = + ViewUtils.parseTintMode( + attributes.getInt(R.styleable.MaterialCheckBox_buttonIconTintMode, -1), Mode.SRC_IN); useMaterialThemeColors = attributes.getBoolean(R.styleable.MaterialCheckBox_useMaterialThemeColors, false); centerIfNoTextEnabled = @@ -119,6 +189,19 @@ public MaterialCheckBox(Context context, @Nullable AttributeSet attrs, int defSt attributes.getText(R.styleable.MaterialCheckBox_errorAccessibilityLabel); attributes.recycle(); + + refreshButtonDrawable(); + + // This is needed due to a KitKat bug where the drawable states don't get updated correctly + // in time. + if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) { + post( + () -> { + if (buttonIconDrawable != null) { + buttonIconDrawable.invalidateSelf(); + } + }); + } } @Override @@ -152,7 +235,7 @@ protected void onDraw(Canvas canvas) { protected void onAttachedToWindow() { super.onAttachedToWindow(); - if (useMaterialThemeColors && CompoundButtonCompat.getButtonTintList(this) == null) { + if (useMaterialThemeColors && buttonTintList == null && buttonIconTintList == null) { setUseMaterialThemeColors(true); } } @@ -165,6 +248,8 @@ protected int[] onCreateDrawableState(int extraSpace) { mergeDrawableStates(drawableStates, ERROR_STATE_SET); } + currentStateChecked = DrawableUtils.getCheckedState(drawableStates); + return drawableStates; } @@ -194,6 +279,7 @@ public void setErrorShown(boolean errorShown) { } this.errorShown = errorShown; refreshDrawableState(); + jumpDrawablesToCurrentState(); for (OnErrorChangedListener listener : onErrorChangedListeners) { listener.onErrorChanged(this, this.errorShown); } @@ -272,10 +358,146 @@ public void clearOnErrorChangedListeners() { onErrorChangedListeners.clear(); } + @Override + public void setButtonDrawable(@DrawableRes int resId) { + setButtonDrawable(AppCompatResources.getDrawable(getContext(), resId)); + } + + @Override + public void setButtonDrawable(@Nullable Drawable drawable) { + buttonDrawable = drawable; + usingDefaultButtonDrawable = false; + refreshButtonDrawable(); + } + + @Override + @Nullable + public Drawable getButtonDrawable() { + return buttonDrawable; + } + + @Override + public void setButtonTintList(@Nullable ColorStateList tintList) { + if (buttonTintList == tintList) { + return; + } + buttonTintList = tintList; + refreshButtonDrawable(); + } + + @Nullable + @Override + public ColorStateList getButtonTintList() { + return buttonTintList; + } + + @Override + public void setButtonTintMode(@Nullable Mode tintMode) { + ((TintableCompoundButton) this).setSupportButtonTintMode(tintMode); + refreshButtonDrawable(); + } + + /** + * Sets the button icon drawable of the checkbox. + * + *

The icon will be layered above the button drawable set by {@link + * #setButtonDrawable(Drawable)}. + * + * @param resId resource id of the drawable to set, or 0 to clear and remove the icon + * @see #getButtonIconDrawable() + * @attr ref com.google.android.material.R.styleable#MaterialCheckBox_buttonIcon + */ + public void setButtonIconDrawableResource(@DrawableRes int resId) { + setButtonIconDrawable(AppCompatResources.getDrawable(getContext(), resId)); + } + + /** + * Sets the button icon drawable of the checkbox. + * + *

The icon will be layered above the button drawable set by {@link + * #setButtonDrawable(Drawable)}. + * + * @param drawable the icon drawable to be set + * @see #getButtonIconDrawable() + * @attr ref com.google.android.material.R.styleable#MaterialCheckBox_buttonIcon + */ + public void setButtonIconDrawable(@Nullable Drawable drawable) { + buttonIconDrawable = drawable; + refreshButtonDrawable(); + } + + /** + * Returns the button icon drawable, or null if none. + * + *

This method expects that the icon will be the second layer of a two-layer drawable. + * + * @see #setButtonIconDrawable(Drawable) + * @attr ref com.google.android.material.R.styleable#MaterialCheckBox_buttonIcon + */ + @Nullable + public Drawable getButtonIconDrawable() { + return buttonIconDrawable; + } + + /** + * Sets the checkbox button icon's tint list, if an icon is present. + * + *

This method expects that the icon will be the second layer of a two-layer drawable. + * + * @param tintList the tint to set on the button icon + * @see #getButtonIconTintList() + * @attr ref com.google.android.material.R.styleable#MaterialCheckBox_buttonIconTint + */ + public void setButtonIconTintList(@Nullable ColorStateList tintList) { + if (buttonIconTintList == tintList) { + return; + } + buttonIconTintList = tintList; + refreshButtonDrawable(); + } + + /** + * Returns the checkbox button icon's tint list. + * + * @see #setButtonIconTintList(ColorStateList) + * @attr ref com.google.android.material.R.styleable#MaterialCheckBox_buttonIconTint + */ + @Nullable + public ColorStateList getButtonIconTintList() { + return buttonIconTintList; + } + + /** + * Specifies the blending mode used to apply the tint specified by + * {@link #setButtonIconTintList(ColorStateList)}} to the button icon drawable. The default mode + * is {@link PorterDuff.Mode#SRC_IN}. + * + * @see #getButtonIconTintMode() + * @param tintMode the blending mode used to apply the tint + * @attr ref com.google.android.material.R.styleable#MaterialCheckBox_buttonIconTintMode + */ + public void setButtonIconTintMode(@NonNull PorterDuff.Mode tintMode) { + if (buttonIconTintMode == tintMode) { + return; + } + buttonIconTintMode = tintMode; + refreshButtonDrawable(); + } + + /** + * Returns the blending mode used to apply the tint to the button icon drawable. + * + * @see #setButtonIconTintMode(Mode) + * @attr ref com.google.android.material.R.styleable#MaterialSwitch_buttonIconTintMode + */ + @NonNull + public PorterDuff.Mode getButtonIconTintMode() { + return buttonIconTintMode; + } + /** * Forces the {@link MaterialCheckBox} to use colors from a Material Theme. Overrides any - * specified ButtonTintList. If set to false, sets the tints to null. Use {@link - * MaterialCheckBox#setSupportButtonTintList} to change button tints. + * specified ButtonTintList. If set to false, sets the tints to null. */ public void setUseMaterialThemeColors(boolean useMaterialThemeColors) { this.useMaterialThemeColors = useMaterialThemeColors; @@ -307,6 +529,78 @@ public boolean isCenterIfNoTextEnabled() { return centerIfNoTextEnabled; } + private void refreshButtonDrawable() { + buttonDrawable = + DrawableUtils.createTintableDrawableIfNeeded( + buttonDrawable, buttonTintList, CompoundButtonCompat.getButtonTintMode(this)); + buttonIconDrawable = + DrawableUtils.createTintableDrawableIfNeeded( + buttonIconDrawable, buttonIconTintList, buttonIconTintMode); + + setUpDefaultButtonDrawableAnimationIfNeeded(); + updateButtonTints(); + + super.setButtonDrawable( + DrawableUtils.compositeTwoLayeredDrawable(buttonDrawable, buttonIconDrawable)); + + refreshDrawableState(); + } + + @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (buttonIconDrawable != null) { + buttonIconDrawable.jumpToCurrentState(); + } + } + + /** + * Set the transition animation from checked to unchecked programmatically so that we can control + * the color change between states. + */ + private void setUpDefaultButtonDrawableAnimationIfNeeded() { + if (!usingDefaultButtonDrawable) { + return; + } + + if (transitionToUnchecked != null) { + transitionToUnchecked.unregisterAnimationCallback(transitionToUncheckedCallback); + transitionToUnchecked.registerAnimationCallback(transitionToUncheckedCallback); + } + + // Due to a framework bug where AnimatedStateListDrawableCompat doesn't support constant state + // in lower APIs while LayerDrawable assumes it does, causing a crash, we can only have the + // color change animation in N+. + if (VERSION.SDK_INT >= VERSION_CODES.N + && buttonDrawable instanceof AnimatedStateListDrawable + && transitionToUnchecked != null) { + ((AnimatedStateListDrawable) buttonDrawable) + .addTransition( + R.id.checked, R.id.unchecked, transitionToUnchecked, /* reversible= */ false); + } + } + + private void updateButtonTints() { + if (buttonDrawable != null && buttonTintList != null) { + DrawableCompat.setTintList(buttonDrawable, buttonTintList); + } + + if (buttonIconDrawable != null && buttonIconTintList != null) { + DrawableCompat.setTintList(buttonIconDrawable, buttonIconTintList); + } + } + + @Nullable + private ColorStateList getSuperButtonTintList() { + if (buttonTintList != null) { + return buttonTintList; + } + if (VERSION.SDK_INT >= 21 && super.getButtonTintList() != null) { + return super.getButtonTintList(); + } + return ((TintableCompoundButton) this).getSupportButtonTintList(); + } + private ColorStateList getMaterialThemeColorsTintList() { if (materialThemeColorsTintList == null) { int[] checkBoxColorsList = new int[CHECKBOX_STATES.length]; diff --git a/lib/java/com/google/android/material/checkbox/res-public/values/public.xml b/lib/java/com/google/android/material/checkbox/res-public/values/public.xml index 4466c0a6af7..40b67f84105 100644 --- a/lib/java/com/google/android/material/checkbox/res-public/values/public.xml +++ b/lib/java/com/google/android/material/checkbox/res-public/values/public.xml @@ -19,6 +19,9 @@ + + + diff --git a/lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_icon_tint.xml b/lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_icon_tint.xml new file mode 100644 index 00000000000..4ce9322bbe3 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/color/m3_checkbox_button_icon_tint.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button.xml new file mode 100644 index 00000000000..92e6b42440d --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button.xml @@ -0,0 +1,37 @@ + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_checked_unchecked.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_checked_unchecked.xml new file mode 100644 index 00000000000..646cc7db2ad --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_checked_unchecked.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon.xml new file mode 100644 index 00000000000..6c0462437d5 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon.xml @@ -0,0 +1,37 @@ + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_checked_unchecked.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_checked_unchecked.xml new file mode 100644 index 00000000000..0eb97208885 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_checked_unchecked.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_unchecked_checked.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_unchecked_checked.xml new file mode 100644 index 00000000000..f1c4c062ba6 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_icon_unchecked_checked.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_unchecked_checked.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_unchecked_checked.xml new file mode 100644 index 00000000000..6a3b8eddd49 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_checkbox_button_unchecked_checked.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_check_mark.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_check_mark.xml new file mode 100644 index 00000000000..849f64d7000 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_check_mark.xml @@ -0,0 +1,33 @@ + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_checked.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_checked.xml new file mode 100644 index 00000000000..dd0ef0e3d70 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_checked.xml @@ -0,0 +1,38 @@ + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_unchecked.xml b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_unchecked.xml new file mode 100644 index 00000000000..8b7c498a3f9 --- /dev/null +++ b/lib/java/com/google/android/material/checkbox/res/drawable/mtrl_ic_checkbox_unchecked.xml @@ -0,0 +1,29 @@ + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/values/attrs.xml b/lib/java/com/google/android/material/checkbox/res/values/attrs.xml index 90e8766b20d..d63c39c9ec8 100644 --- a/lib/java/com/google/android/material/checkbox/res/values/attrs.xml +++ b/lib/java/com/google/android/material/checkbox/res/values/attrs.xml @@ -21,8 +21,35 @@ be ignored. This value should be set to false when using custom drawables that should not be tinted. This value is ignored if a buttonTint is set. --> - + + + + + + + + + + + + + + + + + + + + diff --git a/lib/java/com/google/android/material/checkbox/res/values/strings.xml b/lib/java/com/google/android/material/checkbox/res/values/strings.xml index 95bd57d99f5..7d4d5889420 100644 --- a/lib/java/com/google/android/material/checkbox/res/values/strings.xml +++ b/lib/java/com/google/android/material/checkbox/res/values/strings.xml @@ -19,4 +19,14 @@ Error: invalid + button + button path + icon + icon path + + M23,7H9C7.9,7,7,7.9,7,9v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V9C25,7.9,24.1,7,23,7z + + M23,7H9C7.9,7,7,7.9,7,9v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V9C25,7.9,24.1,7,23,7z M23,23H9V9h14V23z + + M14,18.2 11.4,15.6 10,17 14,21 22,13 20.6,11.6z diff --git a/lib/java/com/google/android/material/checkbox/res/values/styles.xml b/lib/java/com/google/android/material/checkbox/res/values/styles.xml index 259469b895f..b9ccc3980b1 100644 --- a/lib/java/com/google/android/material/checkbox/res/values/styles.xml +++ b/lib/java/com/google/android/material/checkbox/res/values/styles.xml @@ -26,8 +26,16 @@