summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget
diff options
context:
space:
mode:
authorMarcel Dopita <m@rcel.cz>2015-10-12 11:30:17 -0700
committerSteve Kondik <shade@chemlab.org>2016-03-16 15:50:51 -0700
commit19c3a8cd2ac39bd517556c7c63b868e45fd621ef (patch)
tree19cf88b5625b506c3d5e8b20e0d14db8f329912c /core/java/android/widget
parentc1fcac6ddfc114e37abe3205cf2f6aba117c4c7a (diff)
downloadframeworks_base-19c3a8cd2ac39bd517556c7c63b868e45fd621ef.zip
frameworks_base-19c3a8cd2ac39bd517556c7c63b868e45fd621ef.tar.gz
frameworks_base-19c3a8cd2ac39bd517556c7c63b868e45fd621ef.tar.bz2
Show icons of only background apps in Toasts
As implemented and discussed in I82bf23664eea134f3b1f89ad5a99f6be73906ba8, this patch disables the icons in Tosts for already foreground apps. It's useful, no questions about that but please be aware of: - Icons in Toasts are also displayed in "tooltips" of ActionBar (when you press and hold an action). I think that goes agains material design as the ActionBar component now doesn't even show app icon. - Toasts from Android OS contain the Green robot. (IMHO: It was never intended for system Toast to have an icon) - Toasts are intended "to be as unobtrusive as possible" and this kinds of break it. (From javadoc) - Icons should stay as workaround for finding that badly designed/intrusive app because: "Your app should not create a dialog or toast if it is not currently on screen." (From notifications design paterns) - Not that relevant but not all users welcome this aesthetic: https://www.reddit.com/r/cyanogenmod/comments/3oazh8/does_the_icon_in_the_toast_notification_bother/ https://www.reddit.com/r/cyanogenmod/comments/3jg5c2/icons_on_toasts/ etc. Change-Id: If748297bd422c7ddbf061da735b8e4ed0a41b425
Diffstat (limited to 'core/java/android/widget')
-rw-r--r--core/java/android/widget/Toast.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index 4b31af0..e8dccab 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -18,6 +18,7 @@ package android.widget;
import android.annotation.IntDef;
import android.annotation.StringRes;
+import android.app.ActivityManager;
import android.app.INotificationManager;
import android.app.ITransientNotification;
import android.content.Context;
@@ -405,14 +406,18 @@ public class Toast {
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
+ ActivityManager am =
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ if (!am.isPackageInForeground(packageName)) {
+ PackageManager pm = context.getPackageManager();
+ Drawable icon = null;
+ try {
+ icon = pm.getApplicationIcon(packageName);
+ } catch (PackageManager.NameNotFoundException e) {
+ // nothing to do
+ }
+ appIcon.setImageDrawable(icon);
}
- appIcon.setImageDrawable(icon);
}
mWM = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
// We can resolve the Gravity here by using the Locale for getting