@@ -159,6 +159,7 @@ public class ChipDrawable extends Drawable implements TintAwareDrawable, Callbac
159159
160160 private static final boolean DEBUG = false ;
161161 private static final int [] DEFAULT_STATE = new int [] {android .R .attr .state_enabled };
162+ private static final String NAMESPACE_APP = "http://schemas.android.com/apk/res-auto" ;
162163
163164 // Visuals
164165 @ Nullable private ColorStateList chipBackgroundColor ;
@@ -373,25 +374,39 @@ private void loadFromAttributes(
373374 break ;
374375 }
375376
376- setChipIconVisible (
377- a .getBoolean (R .styleable .Chip_chipIconVisible , false )
378- || a .getBoolean (R .styleable .Chip_chipIconEnabled , false ));
377+ setChipIconVisible (a .getBoolean (R .styleable .Chip_chipIconVisible , false ));
378+ // If the user explicitly sets the deprecated attribute (chipIconEnabled) but NOT the
379+ // replacement attribute (chipIconVisible), use the value specified in the deprecated attribute.
380+ if (attrs .getAttributeValue (NAMESPACE_APP , "chipIconEnabled" ) != null
381+ && attrs .getAttributeValue (NAMESPACE_APP , "chipIconVisible" ) == null ) {
382+ setChipIconVisible (a .getBoolean (R .styleable .Chip_chipIconEnabled , false ));
383+ }
379384 setChipIcon (MaterialResources .getDrawable (context , a , R .styleable .Chip_chipIcon ));
380385 setChipIconTint (MaterialResources .getColorStateList (context , a , R .styleable .Chip_chipIconTint ));
381386 setChipIconSize (a .getDimension (R .styleable .Chip_chipIconSize , 0f ));
382387
383- setCloseIconVisible (
384- a .getBoolean (R .styleable .Chip_closeIconVisible , false )
385- || a .getBoolean (R .styleable .Chip_closeIconEnabled , false ));
388+ setCloseIconVisible (a .getBoolean (R .styleable .Chip_closeIconVisible , false ));
389+ // If the user explicitly sets the deprecated attribute (closeIconEnabled) but NOT the
390+ // replacement attribute (closeIconVisible), use the value specified in the deprecated
391+ // attribute.
392+ if (attrs .getAttributeValue (NAMESPACE_APP , "closeIconEnabled" ) != null
393+ && attrs .getAttributeValue (NAMESPACE_APP , "closeIconVisible" ) == null ) {
394+ setCloseIconVisible (a .getBoolean (R .styleable .Chip_closeIconEnabled , false ));
395+ }
386396 setCloseIcon (MaterialResources .getDrawable (context , a , R .styleable .Chip_closeIcon ));
387397 setCloseIconTint (
388398 MaterialResources .getColorStateList (context , a , R .styleable .Chip_closeIconTint ));
389399 setCloseIconSize (a .getDimension (R .styleable .Chip_closeIconSize , 0f ));
390400
391401 setCheckable (a .getBoolean (R .styleable .Chip_android_checkable , false ));
392- setCheckedIconVisible (
393- a .getBoolean (R .styleable .Chip_checkedIconVisible , false )
394- || a .getBoolean (R .styleable .Chip_checkedIconEnabled , false ));
402+ setCheckedIconVisible (a .getBoolean (R .styleable .Chip_checkedIconVisible , false ));
403+ // If the user explicitly sets the deprecated attribute (checkedIconEnabled) but NOT the
404+ // replacement attribute (checkedIconVisible), use the value specified in the deprecated
405+ // attribute.
406+ if (attrs .getAttributeValue (NAMESPACE_APP , "checkedIconEnabled" ) != null
407+ && attrs .getAttributeValue (NAMESPACE_APP , "checkedIconVisible" ) == null ) {
408+ setCheckedIconVisible (a .getBoolean (R .styleable .Chip_checkedIconEnabled , false ));
409+ }
395410 setCheckedIcon (MaterialResources .getDrawable (context , a , R .styleable .Chip_checkedIcon ));
396411
397412 setShowMotionSpec (MotionSpec .createFromAttribute (context , a , R .styleable .Chip_showMotionSpec ));
0 commit comments