Skip to content

Commit 89fa002

Browse files
LorDClockaNGenkzsz11
authored andcommitted
Toast icon switch [1/2]
neobuddy89: Enabled by default Change-Id: I59ffd10f20a2ae9491f76380ec9af641e0844928 Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
1 parent c52c26a commit 89fa002

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

core/java/android/provider/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6276,6 +6276,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
62766276
*/
62776277
public static final String STOCK_STATUSBAR_IN_HIDE = "stock_statusbar_in_hide";
62786278

6279+
/**
6280+
* Toast icon
6281+
* @hide
6282+
*/
6283+
public static final String TOAST_ICON = "toast_icon";
6284+
62796285
/**
62806286
* Keys we no longer back up under the current schema, but want to continue to
62816287
* process when restoring historical backup datasets.

core/java/android/widget/Toast.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import android.os.Message;
4343
import android.os.RemoteException;
4444
import android.os.ServiceManager;
45+
import android.provider.Settings;
4546
import android.util.Log;
4647
import android.view.View;
4748
import android.view.WindowManager;
@@ -500,15 +501,17 @@ public static Toast makeText(@NonNull Context context, @Nullable Looper looper,
500501
Toast result = new Toast(context, looper);
501502
View v = ToastPresenter.getTextToastView(context, text);
502503
ImageView appIcon = (ImageView) v.findViewById(android.R.id.icon);
503-
if (appIcon != null) {
504-
PackageManager pm = context.getPackageManager();
505-
Drawable icon = null;
506-
try {
507-
icon = pm.getApplicationIcon(context.getPackageName());
508-
} catch (PackageManager.NameNotFoundException e) {
509-
// nothing to do
504+
if ((Settings.System.getInt(context.getContentResolver(), Settings.System.TOAST_ICON, 1) == 1)) {
505+
if (appIcon != null) {
506+
PackageManager pm = context.getPackageManager();
507+
Drawable icon = null;
508+
try {
509+
icon = pm.getApplicationIcon(context.getPackageName());
510+
} catch (PackageManager.NameNotFoundException e) {
511+
// nothing to do
512+
}
513+
appIcon.setImageDrawable(icon);
510514
}
511-
appIcon.setImageDrawable(icon);
512515
}
513516
result.mNextView = v;
514517
result.mDuration = duration;

0 commit comments

Comments
 (0)