@@ -1412,39 +1412,108 @@ private class TextViewDrawableAction extends Action {
14121412 public TextViewDrawableAction (int viewId , boolean isRelative , int d1 , int d2 , int d3 , int d4 ) {
14131413 this .viewId = viewId ;
14141414 this .isRelative = isRelative ;
1415+ this .useIcons = false ;
14151416 this .d1 = d1 ;
14161417 this .d2 = d2 ;
14171418 this .d3 = d3 ;
14181419 this .d4 = d4 ;
14191420 }
14201421
1422+ public TextViewDrawableAction (int viewId , boolean isRelative ,
1423+ Icon i1 , Icon i2 , Icon i3 , Icon i4 ) {
1424+ this .viewId = viewId ;
1425+ this .isRelative = isRelative ;
1426+ this .useIcons = true ;
1427+ this .i1 = i1 ;
1428+ this .i2 = i2 ;
1429+ this .i3 = i3 ;
1430+ this .i4 = i4 ;
1431+ }
1432+
14211433 public TextViewDrawableAction (Parcel parcel ) {
14221434 viewId = parcel .readInt ();
14231435 isRelative = (parcel .readInt () != 0 );
1424- d1 = parcel .readInt ();
1425- d2 = parcel .readInt ();
1426- d3 = parcel .readInt ();
1427- d4 = parcel .readInt ();
1436+ useIcons = (parcel .readInt () != 0 );
1437+ if (useIcons ) {
1438+ if (parcel .readInt () != 0 ) {
1439+ i1 = Icon .CREATOR .createFromParcel (parcel );
1440+ }
1441+ if (parcel .readInt () != 0 ) {
1442+ i2 = Icon .CREATOR .createFromParcel (parcel );
1443+ }
1444+ if (parcel .readInt () != 0 ) {
1445+ i3 = Icon .CREATOR .createFromParcel (parcel );
1446+ }
1447+ if (parcel .readInt () != 0 ) {
1448+ i4 = Icon .CREATOR .createFromParcel (parcel );
1449+ }
1450+ } else {
1451+ d1 = parcel .readInt ();
1452+ d2 = parcel .readInt ();
1453+ d3 = parcel .readInt ();
1454+ d4 = parcel .readInt ();
1455+ }
14281456 }
14291457
14301458 public void writeToParcel (Parcel dest , int flags ) {
14311459 dest .writeInt (TAG );
14321460 dest .writeInt (viewId );
14331461 dest .writeInt (isRelative ? 1 : 0 );
1434- dest .writeInt (d1 );
1435- dest .writeInt (d2 );
1436- dest .writeInt (d3 );
1437- dest .writeInt (d4 );
1462+ dest .writeInt (useIcons ? 1 : 0 );
1463+ if (useIcons ) {
1464+ if (i1 != null ) {
1465+ dest .writeInt (1 );
1466+ i1 .writeToParcel (dest , 0 );
1467+ } else {
1468+ dest .writeInt (0 );
1469+ }
1470+ if (i2 != null ) {
1471+ dest .writeInt (1 );
1472+ i2 .writeToParcel (dest , 0 );
1473+ } else {
1474+ dest .writeInt (0 );
1475+ }
1476+ if (i3 != null ) {
1477+ dest .writeInt (1 );
1478+ i3 .writeToParcel (dest , 0 );
1479+ } else {
1480+ dest .writeInt (0 );
1481+ }
1482+ if (i4 != null ) {
1483+ dest .writeInt (1 );
1484+ i4 .writeToParcel (dest , 0 );
1485+ } else {
1486+ dest .writeInt (0 );
1487+ }
1488+ } else {
1489+ dest .writeInt (d1 );
1490+ dest .writeInt (d2 );
1491+ dest .writeInt (d3 );
1492+ dest .writeInt (d4 );
1493+ }
14381494 }
14391495
14401496 @ Override
14411497 public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
14421498 final TextView target = (TextView ) root .findViewById (viewId );
14431499 if (target == null ) return ;
1444- if (isRelative ) {
1445- target .setCompoundDrawablesRelativeWithIntrinsicBounds (d1 , d2 , d3 , d4 );
1500+ if (useIcons ) {
1501+ final Context ctx = target .getContext ();
1502+ final Drawable id1 = i1 == null ? null : i1 .loadDrawable (ctx );
1503+ final Drawable id2 = i2 == null ? null : i2 .loadDrawable (ctx );
1504+ final Drawable id3 = i3 == null ? null : i3 .loadDrawable (ctx );
1505+ final Drawable id4 = i4 == null ? null : i4 .loadDrawable (ctx );
1506+ if (isRelative ) {
1507+ target .setCompoundDrawablesRelativeWithIntrinsicBounds (id1 , id2 , id3 , id4 );
1508+ } else {
1509+ target .setCompoundDrawablesWithIntrinsicBounds (id1 , id2 , id3 , id4 );
1510+ }
14461511 } else {
1447- target .setCompoundDrawablesWithIntrinsicBounds (d1 , d2 , d3 , d4 );
1512+ if (isRelative ) {
1513+ target .setCompoundDrawablesRelativeWithIntrinsicBounds (d1 , d2 , d3 , d4 );
1514+ } else {
1515+ target .setCompoundDrawablesWithIntrinsicBounds (d1 , d2 , d3 , d4 );
1516+ }
14481517 }
14491518 }
14501519
@@ -1453,7 +1522,9 @@ public String getActionName() {
14531522 }
14541523
14551524 boolean isRelative = false ;
1525+ boolean useIcons = false ;
14561526 int d1 , d2 , d3 , d4 ;
1527+ Icon i1 , i2 , i3 , i4 ;
14571528
14581529 public final static int TAG = 11 ;
14591530 }
@@ -2066,6 +2137,41 @@ public void setTextViewCompoundDrawablesRelativeColorFilter(int viewId,
20662137 addAction (new TextViewDrawableColorFilterAction (viewId , true , index , color , mode ));
20672138 }
20682139
2140+ /**
2141+ * Equivalent to calling {@link
2142+ * TextView#setCompoundDrawablesWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)}
2143+ * using the drawables yielded by {@link Icon#loadDrawable(Context)}.
2144+ *
2145+ * @param viewId The id of the view whose text should change
2146+ * @param left an Icon to place to the left of the text, or 0
2147+ * @param top an Icon to place above the text, or 0
2148+ * @param right an Icon to place to the right of the text, or 0
2149+ * @param bottom an Icon to place below the text, or 0
2150+ *
2151+ * @hide
2152+ */
2153+ public void setTextViewCompoundDrawables (int viewId , Icon left , Icon top , Icon right , Icon bottom ) {
2154+ addAction (new TextViewDrawableAction (viewId , false , left , top , right , bottom ));
2155+ }
2156+
2157+ /**
2158+ * Equivalent to calling {@link
2159+ * TextView#setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)}
2160+ * using the drawables yielded by {@link Icon#loadDrawable(Context)}.
2161+ *
2162+ * @param viewId The id of the view whose text should change
2163+ * @param start an Icon to place before the text (relative to the
2164+ * layout direction), or 0
2165+ * @param top an Icon to place above the text, or 0
2166+ * @param end an Icon to place after the text, or 0
2167+ * @param bottom an Icon to place below the text, or 0
2168+ *
2169+ * @hide
2170+ */
2171+ public void setTextViewCompoundDrawablesRelative (int viewId , Icon start , Icon top , Icon end , Icon bottom ) {
2172+ addAction (new TextViewDrawableAction (viewId , true , start , top , end , bottom ));
2173+ }
2174+
20692175 /**
20702176 * Equivalent to calling ImageView.setImageResource
20712177 *
0 commit comments