summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorDan Sandler <dsandler@android.com>2015-05-06 15:18:49 -0400
committerDan Sandler <dsandler@android.com>2015-05-13 23:50:43 -0400
commit08a04c15245c970856022d0779aa27d4d63cdee3 (patch)
treeb2f405077560e5200fc2d55ae5f37eaf22f616ee /graphics
parenta22a380fbbe224783d8b82440ca8692b0ff5b0a2 (diff)
downloadframeworks_base-08a04c15245c970856022d0779aa27d4d63cdee3.zip
frameworks_base-08a04c15245c970856022d0779aa27d4d63cdee3.tar.gz
frameworks_base-08a04c15245c970856022d0779aa27d4d63cdee3.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 Bug: 18568715 Change-Id: I4377b311c538bd1cf36b3fba22326bae81af40c9
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/Icon.java82
1 files changed, 67 insertions, 15 deletions
diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java
index 668a14a..37fb703 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";