summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index ce1c10863acd..0ed72e4df02b 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -1638,6 +1638,47 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Helper action to set layout margin on a View.
+ */
+ private class ViewMarginEndAction extends Action {
+ public ViewMarginEndAction(int viewId, int end) {
+ this.viewId = viewId;
+ this.end = end;
+ }
+
+ public ViewMarginEndAction(Parcel parcel) {
+ viewId = parcel.readInt();
+ end = parcel.readInt();
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(TAG);
+ dest.writeInt(viewId);
+ dest.writeInt(end);
+ }
+
+ @Override
+ public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
+ final View target = root.findViewById(viewId);
+ if (target == null) {
+ return;
+ }
+ ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
+ if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
+ ((ViewGroup.MarginLayoutParams) layoutParams).setMarginEnd(end);
+ }
+ }
+
+ public String getActionName() {
+ return "ViewMarginEndAction";
+ }
+
+ int end;
+
+ public final static int TAG = 19;
+ }
+
+ /**
* Helper action to set a color filter on a compound drawable on a TextView. Supports relative
* (s/t/e/b) or cardinal (l/t/r/b) arrangement.
*/
@@ -1942,6 +1983,9 @@ public class RemoteViews implements Parcelable, Filter {
case SetRemoteInputsAction.TAG:
mActions.add(new SetRemoteInputsAction(parcel));
break;
+ case ViewMarginEndAction.TAG:
+ mActions.add(new ViewMarginEndAction(parcel));
+ break;
default:
throw new ActionException("Tag " + tag + " not found");
}
@@ -2549,6 +2593,19 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * @hide
+ * Equivalent to calling {@link android.view.ViewGroup.MarginLayoutParams#setMarginEnd(int)}.
+ * Only works if the {@link View#getLayoutParams()} supports margins.
+ * Hidden for now since we don't want to support this for all different layout margins yet.
+ *
+ * @param viewId The id of the view to change
+ * @param endMargin the left padding in pixels
+ */
+ public void setViewLayoutMarginEnd(int viewId, int endMargin) {
+ addAction(new ViewMarginEndAction(viewId, endMargin));
+ }
+
+ /**
* 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.