summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2012-05-21 12:14:05 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-21 12:14:05 -0700
commit97ccf4a8528ff101bc1aed5dbe9798e2fbefa7cd (patch)
tree0d02372a13664d8795639c2d6f61f4d8b4e58386
parent464c4e987998c4335ad837bd165243e50c6ea5f0 (diff)
parent90497c18f72cf3d7ea2fd611502d0da2c9c69879 (diff)
downloadframeworks_base-97ccf4a8528ff101bc1aed5dbe9798e2fbefa7cd.zip
frameworks_base-97ccf4a8528ff101bc1aed5dbe9798e2fbefa7cd.tar.gz
frameworks_base-97ccf4a8528ff101bc1aed5dbe9798e2fbefa7cd.tar.bz2
am 90497c18: Merge "Remotable view method for TextView.setTextSize(int, float)." into jb-dev
* commit '90497c18f72cf3d7ea2fd611502d0da2c9c69879': Remotable view method for TextView.setTextSize(int, float).
-rw-r--r--core/java/android/widget/RemoteViews.java57
1 files changed, 56 insertions, 1 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 51c957a..529a09a 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -37,6 +37,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.LayoutInflater.Filter;
import android.view.RemotableViewMethod;
@@ -1182,6 +1183,45 @@ 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.
+ */
+ private class TextViewSizeAction extends Action {
+ public TextViewSizeAction(int viewId, int units, float size) {
+ this.viewId = viewId;
+ this.units = units;
+ this.size = size;
+ }
+
+ public TextViewSizeAction(Parcel parcel) {
+ viewId = parcel.readInt();
+ units = parcel.readInt();
+ size = parcel.readFloat();
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(TAG);
+ dest.writeInt(viewId);
+ dest.writeInt(units);
+ dest.writeFloat(size);
+ }
+
+ @Override
+ public void apply(View root, ViewGroup rootParent) {
+ final Context context = root.getContext();
+ final TextView target = (TextView) root.findViewById(viewId);
+ if (target == null) return;
+ target.setTextSize(units, size);
+ }
+
+ int viewId;
+ int units;
+ float size;
+
+ public final static int TAG = 13;
+ }
+
+ /**
* Simple class used to keep track of memory usage in a RemoteViews.
*
*/
@@ -1334,6 +1374,9 @@ public class RemoteViews implements Parcelable, Filter {
case TextViewDrawableAction.TAG:
mActions.add(new TextViewDrawableAction(parcel));
break;
+ case TextViewSizeAction.TAG:
+ mActions.add(new TextViewSizeAction(parcel));
+ break;
case BitmapReflectionAction.TAG:
mActions.add(new BitmapReflectionAction(parcel));
break;
@@ -1541,7 +1584,19 @@ public class RemoteViews implements Parcelable, Filter {
public void setTextViewText(int viewId, CharSequence text) {
setCharSequence(viewId, "setText", text);
}
-
+
+ /**
+ * @hide
+ * Equivalent to calling {@link TextView#setTextSize(int, float)}
+ *
+ * @param viewId The id of the view whose text size should change
+ * @param units The units of size (e.g. COMPLEX_UNIT_SP)
+ * @param size The size of the text
+ */
+ public void setTextViewTextSize(int viewId, int units, float size) {
+ addAction(new TextViewSizeAction(viewId, units, size));
+ }
+
/**
* Equivalent to calling
* {@link TextView#setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)}.