summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-08-25 19:13:46 -0700
committerSteve Kondik <steve@cyngn.com>2015-10-27 15:12:09 -0700
commitaa19010d9fac5e4bc8a12f94b4007ee3c7502e06 (patch)
tree24e0150835e0d6d9b3e541b64fd11cc995f7f89b /core/java
parent956451ac799e7aaa596871ef8a7f96872c1f2da1 (diff)
downloadframeworks_base-aa19010d9fac5e4bc8a12f94b4007ee3c7502e06.zip
frameworks_base-aa19010d9fac5e4bc8a12f94b4007ee3c7502e06.tar.gz
frameworks_base-aa19010d9fac5e4bc8a12f94b4007ee3c7502e06.tar.bz2
Show icon of package associated with Toast
For all those times you have some random app or background service that posts a Toast and you have no idea who's posting it. This adds an icon badge to the top left corner of the Toast to show the app's icon the Toast belongs to. Change-Id: I82bf23664eea134f3b1f89ad5a99f6be73906ba8
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/Toast.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index 207f675..4b31af0 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -21,9 +21,11 @@ import android.annotation.StringRes;
import android.app.INotificationManager;
import android.app.ITransientNotification;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
+import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -400,6 +402,18 @@ public class Toast {
if (context == null) {
context = mView.getContext();
}
+
+ ImageView appIcon = (ImageView) mView.findViewById(android.R.id.icon);
+ if (appIcon != null) {
+ PackageManager pm = context.getPackageManager();
+ Drawable icon = null;
+ try {
+ icon = pm.getApplicationIcon(packageName);
+ } catch (PackageManager.NameNotFoundException e) {
+ // nothing to do
+ }
+ appIcon.setImageDrawable(icon);
+ }
mWM = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
// We can resolve the Gravity here by using the Locale for getting
// the layout direction