@@ -964,6 +964,58 @@ public void updateMemoryUsageEstimate(MemoryUsageCounter counter) {
964964 public final static int TAG = 4 ;
965965 }
966966
967+ /**
968+ * Helper action to set compound drawables on a TextView. Supports relative
969+ * (s/t/e/b) or cardinal (l/t/r/b) arrangement.
970+ */
971+ private class TextViewDrawableAction extends Action {
972+ public TextViewDrawableAction (int viewId , boolean isRelative , int d1 , int d2 , int d3 , int d4 ) {
973+ this .viewId = viewId ;
974+ this .isRelative = isRelative ;
975+ this .d1 = d1 ;
976+ this .d2 = d2 ;
977+ this .d3 = d3 ;
978+ this .d4 = d4 ;
979+ }
980+
981+ public TextViewDrawableAction (Parcel parcel ) {
982+ viewId = parcel .readInt ();
983+ isRelative = (parcel .readInt () != 0 );
984+ d1 = parcel .readInt ();
985+ d2 = parcel .readInt ();
986+ d3 = parcel .readInt ();
987+ d4 = parcel .readInt ();
988+ }
989+
990+ public void writeToParcel (Parcel dest , int flags ) {
991+ dest .writeInt (TAG );
992+ dest .writeInt (viewId );
993+ dest .writeInt (isRelative ? 1 : 0 );
994+ dest .writeInt (d1 );
995+ dest .writeInt (d2 );
996+ dest .writeInt (d3 );
997+ dest .writeInt (d4 );
998+ }
999+
1000+ @ Override
1001+ public void apply (View root , ViewGroup rootParent ) {
1002+ final Context context = root .getContext ();
1003+ final TextView target = (TextView ) root .findViewById (viewId );
1004+ if (target == null ) return ;
1005+ if (isRelative ) {
1006+ target .setCompoundDrawablesRelativeWithIntrinsicBounds (d1 , d2 , d3 , d4 );
1007+ } else {
1008+ target .setCompoundDrawablesWithIntrinsicBounds (d1 , d2 , d3 , d4 );
1009+ }
1010+ }
1011+
1012+ int viewId ;
1013+ boolean isRelative = false ;
1014+ int d1 , d2 , d3 , d4 ;
1015+
1016+ public final static int TAG = 11 ;
1017+ }
1018+
9671019 /**
9681020 * Simple class used to keep track of memory usage in a RemoteViews.
9691021 *
@@ -1043,6 +1095,9 @@ public RemoteViews(Parcel parcel) {
10431095 case SetRemoteViewsAdapterIntent .TAG :
10441096 mActions .add (new SetRemoteViewsAdapterIntent (parcel ));
10451097 break ;
1098+ case TextViewDrawableAction .TAG :
1099+ mActions .add (new TextViewDrawableAction (parcel ));
1100+ break ;
10461101 default :
10471102 throw new ActionException ("Tag " + tag + " not found" );
10481103 }
@@ -1194,6 +1249,35 @@ public void setTextViewText(int viewId, CharSequence text) {
11941249 setCharSequence (viewId , "setText" , text );
11951250 }
11961251
1252+ /**
1253+ * Equivalent to calling
1254+ * {@link TextView#setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)}.
1255+ *
1256+ * @param viewId The id of the view whose text should change
1257+ * @param left The id of a drawable to place to the left of the text, or 0
1258+ * @param top The id of a drawable to place above the text, or 0
1259+ * @param right The id of a drawable to place to the right of the text, or 0
1260+ * @param bottom The id of a drawable to place below the text, or 0
1261+ */
1262+ public void setTextViewCompoundDrawables (int viewId , int left , int top , int right , int bottom ) {
1263+ addAction (new TextViewDrawableAction (viewId , false , left , top , right , bottom ));
1264+ }
1265+
1266+ /**
1267+ * Equivalent to calling {@link
1268+ * TextView#setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int)}.
1269+ *
1270+ * @param viewId The id of the view whose text should change
1271+ * @param start The id of a drawable to place before the text (relative to the
1272+ * layout direction), or 0
1273+ * @param top The id of a drawable to place above the text, or 0
1274+ * @param end The id of a drawable to place after the text, or 0
1275+ * @param bottom The id of a drawable to place below the text, or 0
1276+ */
1277+ public void setTextViewCompoundDrawablesRelative (int viewId , int start , int top , int end , int bottom ) {
1278+ addAction (new TextViewDrawableAction (viewId , true , start , top , end , bottom ));
1279+ }
1280+
11971281 /**
11981282 * Equivalent to calling ImageView.setImageResource
11991283 *
0 commit comments