summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--core/java/android/widget/ImageView.java17
-rw-r--r--core/java/android/widget/RemoteViews.java36
4 files changed, 59 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 5fac213..42a0b61 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -40267,6 +40267,7 @@ package android.widget {
method public void setImageAlpha(int);
method public void setImageBitmap(android.graphics.Bitmap);
method public void setImageDrawable(android.graphics.drawable.Drawable);
+ method public void setImageIcon(android.graphics.drawable.Icon);
method public void setImageLevel(int);
method public void setImageMatrix(android.graphics.Matrix);
method public void setImageResource(int);
@@ -40847,7 +40848,9 @@ package android.widget {
method public void setDouble(int, java.lang.String, double);
method public void setEmptyView(int, int);
method public void setFloat(int, java.lang.String, float);
+ method public void setIcon(int, java.lang.String, android.graphics.drawable.Icon);
method public void setImageViewBitmap(int, android.graphics.Bitmap);
+ method public void setImageViewIcon(int, android.graphics.drawable.Icon);
method public void setImageViewResource(int, int);
method public void setImageViewUri(int, android.net.Uri);
method public void setInt(int, java.lang.String, int);
diff --git a/api/system-current.txt b/api/system-current.txt
index d727b22..7d5bdd4 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -42842,6 +42842,7 @@ package android.widget {
method public void setImageAlpha(int);
method public void setImageBitmap(android.graphics.Bitmap);
method public void setImageDrawable(android.graphics.drawable.Drawable);
+ method public void setImageIcon(android.graphics.drawable.Icon);
method public void setImageLevel(int);
method public void setImageMatrix(android.graphics.Matrix);
method public void setImageResource(int);
@@ -43422,7 +43423,9 @@ package android.widget {
method public void setDouble(int, java.lang.String, double);
method public void setEmptyView(int, int);
method public void setFloat(int, java.lang.String, float);
+ method public void setIcon(int, java.lang.String, android.graphics.drawable.Icon);
method public void setImageViewBitmap(int, android.graphics.Bitmap);
+ method public void setImageViewIcon(int, android.graphics.drawable.Icon);
method public void setImageViewResource(int, int);
method public void setImageViewUri(int, android.net.Uri);
method public void setInt(int, java.lang.String, int);
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 05059bc..94cda88 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -36,8 +36,10 @@ import android.graphics.RectF;
import android.graphics.Xfermode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Build;
+import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -462,6 +464,21 @@ public class ImageView extends View {
}
/**
+ * Sets the content of this ImageView to the specified Icon.
+ *
+ * <p class="note">Depending on the Icon type, this may do Bitmap reading and decoding
+ * on the UI thread, which can cause UI jank. If that's a concern, consider using
+ * {@link Icon#loadDrawableAsync(Context, Handler, Icon.OnDrawableLoadedListener)}
+ * and then {@link #setImageDrawable(android.graphics.drawable.Drawable)} instead.</p>
+ *
+ * @param icon an Icon holding the desired image
+ */
+ @android.view.RemotableViewMethod
+ public void setImageIcon(Icon icon) {
+ setImageDrawable(icon.loadDrawable(mContext));
+ }
+
+ /**
* Applies a tint to the image drawable. Does not modify the current tint
* mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
* <p>
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index a10be11..dc75fd0 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -35,6 +35,7 @@ import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -1072,6 +1073,7 @@ public class RemoteViews implements Parcelable, Filter {
static final int BUNDLE = 13;
static final int INTENT = 14;
static final int COLOR_STATE_LIST = 15;
+ static final int ICON = 16;
String methodName;
int type;
@@ -1150,6 +1152,10 @@ public class RemoteViews implements Parcelable, Filter {
this.value = ColorStateList.CREATOR.createFromParcel(in);
}
break;
+ case ICON:
+ if (in.readInt() != 0) {
+ this.value = Icon.CREATOR.createFromParcel(in);
+ }
default:
break;
}
@@ -1225,6 +1231,13 @@ public class RemoteViews implements Parcelable, Filter {
if (this.value != null) {
((ColorStateList)this.value).writeToParcel(out, flags);
}
+ break;
+ case ICON:
+ out.writeInt(this.value != null ? 1 : 0);
+ if (this.value != null) {
+ ((Icon)this.value).writeToParcel(out, flags);
+ }
+ break;
default:
break;
}
@@ -1262,6 +1275,8 @@ public class RemoteViews implements Parcelable, Filter {
return Intent.class;
case COLOR_STATE_LIST:
return ColorStateList.class;
+ case ICON:
+ return Icon.class;
default:
return null;
}
@@ -2082,6 +2097,16 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Equivalent to calling ImageView.setImageIcon
+ *
+ * @param viewId The id of the view whose bitmap should change
+ * @param icon The new Icon for the ImageView
+ */
+ public void setImageViewIcon(int viewId, Icon icon) {
+ setIcon(viewId, "setImageIcon", icon);
+ }
+
+ /**
* Equivalent to calling AdapterView.setEmptyView
*
* @param viewId The id of the view on which to set the empty view
@@ -2519,6 +2544,17 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Call a method taking one Icon on a view in the layout for this RemoteViews.
+ *
+ * @param viewId The id of the view on which to call the method.
+ * @param methodName The name of the method to call.
+ * @param value The {@link android.graphics.drawable.Icon} to pass the method.
+ */
+ public void setIcon(int viewId, String methodName, Icon value) {
+ addAction(new ReflectionAction(viewId, methodName, ReflectionAction.ICON, value));
+ }
+
+ /**
* Equivalent to calling View.setContentDescription(CharSequence).
*
* @param viewId The id of the view whose content description should change.