1111import android .graphics .drawable .BitmapDrawable ;
1212import android .graphics .drawable .Drawable ;
1313import android .util .AttributeSet ;
14+ import android .util .Log ;
1415
1516import androidx .annotation .ColorInt ;
1617import androidx .annotation .Dimension ;
@@ -26,6 +27,7 @@ public class AppCompatIconButton extends AppCompatButton {
2627 private Rect srcRect ;
2728 private Rect destRect ;
2829
30+ private boolean textAllCaps ;
2931 @ Dimension
3032 private int iconPadding ;
3133 @ Dimension
@@ -44,8 +46,6 @@ private enum Align {
4446
4547 private Align direction ;
4648
47-
48-
4949 public AppCompatIconButton (Context context ) {
5050 this (context , null );
5151 }
@@ -63,6 +63,8 @@ public AppCompatIconButton(Context context, AttributeSet attrs, int defStyle) {
6363 private void applyStyles (Context context , @ Nullable AttributeSet attrs , int defStyleAttr ) {
6464 TypedArray typedArray = context .obtainStyledAttributes (attrs ,
6565 R .styleable .AppCompatIconButton , defStyleAttr , R .style .AppCompatIconButtonStyle );
66+ textAllCaps = typedArray .getBoolean (R .styleable .AppCompatIconButton_ib_textAllCaps ,
67+ false );
6668 iconPadding = typedArray .getDimensionPixelSize (
6769 R .styleable .AppCompatIconButton_ib_iconPadding , 0 );
6870 iconSize = typedArray .getDimensionPixelSize (
@@ -113,6 +115,9 @@ private void init() {
113115 paint .setColorFilter (new PorterDuffColorFilter (iconColor , PorterDuff .Mode .SRC_ATOP ));
114116 srcRect = new Rect (0 , 0 , icon .getWidth (), icon .getHeight ());
115117 }
118+ if (textAllCaps ) {
119+ setText (getText ().toString ().toUpperCase ());
120+ }
116121 destRect = new Rect ();
117122 }
118123
0 commit comments