diff options
author | Dan Sandler <dsandler@android.com> | 2015-05-06 15:18:49 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2015-05-15 12:35:21 +0000 |
commit | d63f9321e62064660d426efd5abbd885c4a24652 (patch) | |
tree | 96d7252ec6ba03410097d24a93abed13e52516d7 /graphics | |
parent | aee0c2ce39fe92716bb76d33d6f8cc8789467cf6 (diff) | |
download | frameworks_base-d63f9321e62064660d426efd5abbd885c4a24652.zip frameworks_base-d63f9321e62064660d426efd5abbd885c4a24652.tar.gz frameworks_base-d63f9321e62064660d426efd5abbd885c4a24652.tar.bz2 |
Icon support comes to Notification.
And you may ask yourself: what is that beautiful icon?
And you may ask yourself: where does that API go to?
And you may ask yourself: is it a resource? is it a Bitmap?
And you may say to yourself: my god, what have I done
(This patch fixes a number of bugs in the initial
implementation, but other than that, it's the same as it
ever was.)
Bug: 18568715
Bug: 21141842
Change-Id: I1d3f9427abd7f0bb57e533fcfac708851ff644b6
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/Icon.java | 84 |
1 files changed, 68 insertions, 16 deletions
diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java index ca6af74..7b4329a 100644 --- a/graphics/java/android/graphics/drawable/Icon.java +++ b/graphics/java/android/graphics/drawable/Icon.java @@ -53,10 +53,14 @@ import java.io.OutputStream; public final class Icon implements Parcelable { private static final String TAG = "Icon"; - private static final int TYPE_BITMAP = 1; - private static final int TYPE_RESOURCE = 2; - private static final int TYPE_DATA = 3; - private static final int TYPE_URI = 4; + /** @hide */ + public static final int TYPE_BITMAP = 1; + /** @hide */ + public static final int TYPE_RESOURCE = 2; + /** @hide */ + public static final int TYPE_DATA = 3; + /** @hide */ + public static final int TYPE_URI = 4; private static final int VERSION_STREAM_SERIALIZER = 1; @@ -81,15 +85,34 @@ public final class Icon implements Parcelable { // TYPE_DATA: data offset private int mInt2; - // Internal accessors for different mType variants - private Bitmap getBitmap() { + /** + * @return The type of image data held in this Icon. One of + * {@link #TYPE_BITMAP}, + * {@link #TYPE_RESOURCE}, + * {@link #TYPE_DATA}, or + * {@link #TYPE_URI}. + * @hide + */ + public int getType() { + return mType; + } + + /** + * @return The {@link android.graphics.Bitmap} held by this {@link #TYPE_BITMAP} Icon. + * @hide + */ + public Bitmap getBitmap() { if (mType != TYPE_BITMAP) { throw new IllegalStateException("called getBitmap() on " + this); } return (Bitmap) mObj1; } - private int getDataLength() { + /** + * @return The length of the compressed bitmap byte array held by this {@link #TYPE_DATA} Icon. + * @hide + */ + public int getDataLength() { if (mType != TYPE_DATA) { throw new IllegalStateException("called getDataLength() on " + this); } @@ -98,7 +121,12 @@ public final class Icon implements Parcelable { } } - private int getDataOffset() { + /** + * @return The offset into the byte array held by this {@link #TYPE_DATA} Icon at which + * valid compressed bitmap data is found. + * @hide + */ + public int getDataOffset() { if (mType != TYPE_DATA) { throw new IllegalStateException("called getDataOffset() on " + this); } @@ -107,7 +135,12 @@ public final class Icon implements Parcelable { } } - private byte[] getDataBytes() { + /** + * @return The byte array held by this {@link #TYPE_DATA} Icon ctonaining compressed + * bitmap data. + * @hide + */ + public byte[] getDataBytes() { if (mType != TYPE_DATA) { throw new IllegalStateException("called getDataBytes() on " + this); } @@ -116,39 +149,58 @@ public final class Icon implements Parcelable { } } - private Resources getResources() { + /** + * @return The {@link android.content.res.Resources} for this {@link #TYPE_RESOURCE} Icon. + * @hide + */ + public Resources getResources() { if (mType != TYPE_RESOURCE) { throw new IllegalStateException("called getResources() on " + this); } return (Resources) mObj1; } - private String getResPackage() { + /** + * @return The package containing resources for this {@link #TYPE_RESOURCE} Icon. + * @hide + */ + public String getResPackage() { if (mType != TYPE_RESOURCE) { throw new IllegalStateException("called getResPackage() on " + this); } return mString1; } - private int getResId() { + /** + * @return The resource ID for this {@link #TYPE_RESOURCE} Icon. + * @hide + */ + public int getResId() { if (mType != TYPE_RESOURCE) { throw new IllegalStateException("called getResId() on " + this); } return mInt1; } - private String getUriString() { + /** + * @return The URI (as a String) for this {@link #TYPE_URI} Icon. + * @hide + */ + public String getUriString() { if (mType != TYPE_URI) { throw new IllegalStateException("called getUriString() on " + this); } return mString1; } - private Uri getUri() { + /** + * @return The {@link android.net.Uri} for this {@link #TYPE_URI} Icon. + * @hide + */ + public Uri getUri() { return Uri.parse(getUriString()); } - // Convert a int32 into a four-char string private static final String typeToString(int x) { switch (x) { case TYPE_BITMAP: return "BITMAP"; @@ -482,7 +534,7 @@ public final class Icon implements Parcelable { sb.append(" pkg=") .append(getResPackage()) .append(" id=") - .append(String.format("%08x", getResId())); + .append(String.format("0x%08x", getResId())); break; case TYPE_DATA: sb.append(" len=").append(getDataLength()); |