summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
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 /packages/SystemUI
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 'packages/SystemUI')
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java56
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java6
4 files changed, 32 insertions, 48 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 715f4e4..be33085 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -194,7 +194,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
// we compose the final post-save notification below.
mNotificationBuilder.setLargeIcon(croppedIcon);
// But we still don't set it for the expanded view, allowing the smallIcon to show here.
- mNotificationStyle.bigLargeIcon(null);
+ mNotificationStyle.bigLargeIcon((Bitmap) null);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 2913c7d..1e488f3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -1390,9 +1390,9 @@ public abstract class BaseStatusBar extends SystemUI implements
final ImageView profileBadge = (ImageView) publicViewLocal.findViewById(
R.id.profile_badge_line3);
- final StatusBarIcon ic = new StatusBarIcon(entry.notification.getPackageName(),
+ final StatusBarIcon ic = new StatusBarIcon(
entry.notification.getUser(),
- entry.notification.getNotification().icon,
+ entry.notification.getNotification().getSmallIcon(),
entry.notification.getNotification().iconLevel,
entry.notification.getNotification().number,
entry.notification.getNotification().tickerText);
@@ -1770,9 +1770,9 @@ public abstract class BaseStatusBar extends SystemUI implements
sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()), n);
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- final StatusBarIcon ic = new StatusBarIcon(sbn.getPackageName(),
+ final StatusBarIcon ic = new StatusBarIcon(
sbn.getUser(),
- n.icon,
+ n.getSmallIcon(),
n.iconLevel,
n.number,
n.tickerText);
@@ -1916,9 +1916,9 @@ public abstract class BaseStatusBar extends SystemUI implements
try {
if (entry.icon != null) {
// Update the icon
- final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(),
+ final StatusBarIcon ic = new StatusBarIcon(
notification.getUser(),
- n.icon,
+ n.getSmallIcon(),
n.iconLevel,
n.number,
n.tickerText);
@@ -1938,9 +1938,9 @@ public abstract class BaseStatusBar extends SystemUI implements
}
if (!updateSuccessful) {
if (DEBUG) Log.d(TAG, "not reusing notification for key: " + key);
- final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(),
+ final StatusBarIcon ic = new StatusBarIcon(
notification.getUser(),
- n.icon,
+ n.getSmallIcon(),
n.iconLevel,
n.number,
n.tickerText);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index e6847d8..3294e15 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -24,6 +24,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -100,13 +101,23 @@ public class StatusBarIconView extends AnimatedImageView {
return a.equals(b);
}
+ public boolean equalIcons(Icon a, Icon b) {
+ if (a == b) return true;
+ if (a.getType() != b.getType()) return false;
+ switch (a.getType()) {
+ case Icon.TYPE_RESOURCE:
+ return a.getResPackage().equals(b.getResPackage()) && a.getResId() == b.getResId();
+ case Icon.TYPE_URI:
+ return a.getUriString().equals(b.getUriString());
+ default:
+ return false;
+ }
+ }
/**
* Returns whether the set succeeded.
*/
public boolean set(StatusBarIcon icon) {
- final boolean iconEquals = mIcon != null
- && streq(mIcon.iconPackage, icon.iconPackage)
- && mIcon.iconId == icon.iconId;
+ final boolean iconEquals = mIcon != null && equalIcons(mIcon.icon, icon.icon);
final boolean levelEquals = iconEquals
&& mIcon.iconLevel == icon.iconLevel;
final boolean visibilityEquals = mIcon != null
@@ -167,45 +178,18 @@ public class StatusBarIconView extends AnimatedImageView {
}
/**
- * Returns the right icon to use for this item, respecting the iconId and
- * iconPackage (if set)
+ * Returns the right icon to use for this item
*
- * @param context Context to use to get resources if iconPackage is not set
+ * @param context Context to use to get resources
* @return Drawable for this item, or null if the package or item could not
* be found
*/
public static Drawable getIcon(Context context, StatusBarIcon icon) {
- Resources r = null;
-
- if (icon.iconPackage != null) {
- try {
- int userId = icon.user.getIdentifier();
- if (userId == UserHandle.USER_ALL) {
- userId = UserHandle.USER_OWNER;
- }
- r = context.getPackageManager()
- .getResourcesForApplicationAsUser(icon.iconPackage, userId);
- } catch (PackageManager.NameNotFoundException ex) {
- Log.e(TAG, "Icon package not found: " + icon.iconPackage);
- return null;
- }
- } else {
- r = context.getResources();
+ int userId = icon.user.getIdentifier();
+ if (userId == UserHandle.USER_ALL) {
+ userId = UserHandle.USER_OWNER;
}
-
- if (icon.iconId == 0) {
- return null;
- }
-
- try {
- return r.getDrawable(icon.iconId);
- } catch (RuntimeException e) {
- Log.w(TAG, "Icon not found in "
- + (icon.iconPackage != null ? icon.iconId : "<system>")
- + ": " + Integer.toHexString(icon.iconId));
- }
-
- return null;
+ return icon.icon.loadDrawableAsUser(context, userId);
}
public StatusBarIcon getStatusBarIcon() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
index 44168bc..26d1c86 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
+import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.Gravity;
@@ -132,8 +133,7 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode {
break;
} else {
StatusBarIcon icon = v.getStatusBarIcon();
- icon.iconPackage = iconPkg;
- icon.iconId = iconId;
+ icon.icon = Icon.createWithResource(icon.icon.getResPackage(), iconId);
v.set(icon);
v.updateDrawable();
return;
@@ -152,4 +152,4 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode {
v.set(icon);
addView(v, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize));
}
-} \ No newline at end of file
+}