summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2012-05-21 14:32:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-21 14:32:40 -0700
commit28e2064ffce14f3c682952203a502cf731da467a (patch)
treec9811ebdcb2e64f1dc7877960a3b379f6ecf3f34 /core/java/android/widget/RemoteViews.java
parent82b65ab73147cbe8a8be16aa844ff121afc3b60f (diff)
parent7a999b820456e49a8c3d76a31d9a23edee746e56 (diff)
am 7a999b82: am 2926948d: Merge "Add RemoteViews.setViewPadding()." into jb-dev
* commit '7a999b820456e49a8c3d76a31d9a23edee746e56': Add RemoteViews.setViewPadding().
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java63
1 files changed, 61 insertions, 2 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 0aee6008727c..be38b6aad8bd 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -1183,8 +1183,7 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
- * Helper action to set compound drawables on a TextView. Supports relative
- * (s/t/e/b) or cardinal (l/t/r/b) arrangement.
+ * Helper action to set text size on a TextView in any supported units.
*/
private class TextViewSizeAction extends Action {
public TextViewSizeAction(int viewId, int units, float size) {
@@ -1222,6 +1221,49 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Helper action to set padding on a View.
+ */
+ private class ViewPaddingAction extends Action {
+ public ViewPaddingAction(int viewId, int left, int top, int right, int bottom) {
+ this.viewId = viewId;
+ this.left = left;
+ this.top = top;
+ this.right = right;
+ this.bottom = bottom;
+ }
+
+ public ViewPaddingAction(Parcel parcel) {
+ viewId = parcel.readInt();
+ left = parcel.readInt();
+ top = parcel.readInt();
+ right = parcel.readInt();
+ bottom = parcel.readInt();
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(TAG);
+ dest.writeInt(viewId);
+ dest.writeInt(left);
+ dest.writeInt(top);
+ dest.writeInt(right);
+ dest.writeInt(bottom);
+ }
+
+ @Override
+ public void apply(View root, ViewGroup rootParent) {
+ final Context context = root.getContext();
+ final View target = root.findViewById(viewId);
+ if (target == null) return;
+ target.setPadding(left, top, right, bottom);
+ }
+
+ int viewId;
+ int left, top, right, bottom;
+
+ public final static int TAG = 14;
+ }
+
+ /**
* Simple class used to keep track of memory usage in a RemoteViews.
*
*/
@@ -1377,6 +1419,9 @@ public class RemoteViews implements Parcelable, Filter {
case TextViewSizeAction.TAG:
mActions.add(new TextViewSizeAction(parcel));
break;
+ case ViewPaddingAction.TAG:
+ mActions.add(new ViewPaddingAction(parcel));
+ break;
case BitmapReflectionAction.TAG:
mActions.add(new BitmapReflectionAction(parcel));
break;
@@ -1856,6 +1901,20 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * @hide
+ * Equivalent to calling {@link View#setPadding(int, int, int, int)}.
+ *
+ * @param viewId The id of the view to change
+ * @param left the left padding in pixels
+ * @param top the top padding in pixels
+ * @param right the right padding in pixels
+ * @param bottom the bottom padding in pixels
+ */
+ public void setViewPadding(int viewId, int left, int top, int right, int bottom) {
+ addAction(new ViewPaddingAction(viewId, left, top, right, bottom));
+ }
+
+ /**
* Call a method taking one boolean on a view in the layout for this RemoteViews.
*
* @param viewId The id of the view on which to call the method.