Merge "SystemUI: Override notification app name" into nyc-dev

This commit is contained in:
Adrian Roos
2016-06-20 18:00:01 +00:00
committed by Android (Google) Code Review
7 changed files with 67 additions and 50 deletions

View File

@@ -16,8 +16,10 @@
package com.android.systemui;
import android.app.Notification;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -48,4 +50,12 @@ public abstract class SystemUI {
mComponents.put(interfaceType, component);
}
}
public static void overrideNotificationAppName(Context context, Notification.Builder n) {
final Bundle extras = new Bundle();
extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
context.getString(com.android.internal.R.string.android_system_label));
n.addExtras(extras);
}
}

View File

@@ -38,6 +38,7 @@ import android.provider.Settings;
import android.util.Slog;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.SystemUIDialog;
@@ -143,6 +144,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color));
SystemUI.overrideNotificationAppName(mContext, nb);
final Notification n = nb.build();
mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
}
@@ -173,8 +175,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
attachLowBatterySound(nb);
mPlaySound = false;
}
final Notification n = nb.build();
mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
SystemUI.overrideNotificationAppName(mContext, nb);
mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, nb.build(), UserHandle.ALL);
}
private PendingIntent pendingActivity(Intent intent) {

View File

@@ -60,6 +60,7 @@ import android.view.animation.Interpolator;
import android.widget.ImageView;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import java.io.File;
import java.io.FileOutputStream;
@@ -165,11 +166,6 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
c.drawColor(overlayColor);
c.setBitmap(null);
// swap "System UI" out for "Android System"
final Bundle extras = new Bundle();
extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
context.getString(com.android.internal.R.string.android_system_label));
// Show the intermediate notification
mTickerAddSpace = !mTickerAddSpace;
mNotificationManager = nManager;
@@ -187,9 +183,9 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now)
.setShowWhen(true)
.addExtras(extras)
.setColor(r.getColor(
com.android.internal.R.color.system_notification_accent_color));
SystemUI.overrideNotificationAppName(context, mPublicNotificationBuilder);
mNotificationBuilder = new Notification.Builder(context)
.setTicker(r.getString(R.string.screenshot_saving_ticker)
@@ -199,11 +195,11 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
.setSmallIcon(R.drawable.stat_notify_image)
.setWhen(now)
.setShowWhen(true)
.addExtras(extras)
.setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color))
.setStyle(mNotificationStyle)
.setPublicVersion(mPublicNotificationBuilder.build());
mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true);
SystemUI.overrideNotificationAppName(context, mNotificationBuilder);
mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
@@ -864,6 +860,7 @@ class GlobalScreenshot {
.setAutoCancel(true)
.setColor(context.getColor(
com.android.internal.R.color.system_notification_accent_color));
SystemUI.overrideNotificationAppName(context, b);
Notification n = new Notification.BigTextStyle(b)
.bigText(errorMsg)

View File

@@ -844,7 +844,6 @@ public abstract class BaseStatusBar extends SystemUI implements
new Intent(BANNER_ACTION_SETUP).setPackage(packageName),
PendingIntent.FLAG_CANCEL_CURRENT);
final Resources res = mContext.getResources();
final int colorRes = com.android.internal.R.color.system_notification_accent_color;
Notification.Builder note = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_android)
@@ -860,6 +859,7 @@ public abstract class BaseStatusBar extends SystemUI implements
.addAction(R.drawable.ic_settings,
mContext.getString(R.string.hidden_notifications_setup),
setupIntent);
overrideNotificationAppName(mContext, note);
NotificationManager noMan =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

View File

@@ -51,6 +51,7 @@ import com.android.internal.util.UserIcons;
import com.android.settingslib.RestrictedLockUtils;
import com.android.systemui.GuestResumeSessionReceiver;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUISecondaryUserService;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.tiles.UserDetailView;
@@ -523,7 +524,7 @@ public class UserSwitcherController {
private void showLogoutNotification(int userId) {
PendingIntent logoutPI = PendingIntent.getBroadcastAsUser(mContext,
0, new Intent(ACTION_LOGOUT_USER), 0, UserHandle.SYSTEM);
Notification notification = new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setVisibility(Notification.VISIBILITY_SECRET)
.setPriority(Notification.PRIORITY_MIN)
.setSmallIcon(R.drawable.ic_person)
@@ -534,10 +535,10 @@ public class UserSwitcherController {
.setShowWhen(false)
.addAction(R.drawable.ic_delete,
mContext.getString(R.string.user_logout_notification_action),
logoutPI)
.build();
logoutPI);
SystemUI.overrideNotificationAppName(mContext, builder);
NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER, ID_LOGOUT_USER,
notification, new UserHandle(userId));
builder.build(), new UserHandle(userId));
}
};
@@ -547,7 +548,7 @@ public class UserSwitcherController {
PendingIntent removeGuestPI = canSwitchUsers ? PendingIntent.getBroadcastAsUser(mContext,
0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM) : null;
Notification notification = new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setVisibility(Notification.VISIBILITY_SECRET)
.setPriority(Notification.PRIORITY_MIN)
.setSmallIcon(R.drawable.ic_person)
@@ -557,10 +558,10 @@ public class UserSwitcherController {
.setShowWhen(false)
.addAction(R.drawable.ic_delete,
mContext.getString(R.string.guest_notification_remove_action),
removeGuestPI)
.build();
removeGuestPI);
SystemUI.overrideNotificationAppName(mContext, builder);
NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST,
notification, new UserHandle(guestUserId));
builder.build(), new UserHandle(guestUserId));
}
private final Runnable mUnpauseRefreshUsers = new Runnable() {

View File

@@ -198,7 +198,7 @@ public class StorageNotification extends SystemUI {
rec.getNickname());
final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
final Notification notif = new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_sd_card_48dp)
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -208,10 +208,11 @@ public class StorageNotification extends SystemUI {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_SYSTEM)
.setDeleteIntent(buildSnoozeIntent(fsUuid))
.build();
.setDeleteIntent(buildSnoozeIntent(fsUuid));
SystemUI.overrideNotificationAppName(mContext, builder);
mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, notif, UserHandle.ALL);
mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder
.build(), UserHandle.ALL);
}
}
}
@@ -224,7 +225,7 @@ public class StorageNotification extends SystemUI {
final CharSequence text = mContext.getString(
R.string.ext_media_unsupported_notification_message, disk.getDescription());
final Notification notif = new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(getSmallIcon(disk, VolumeInfo.STATE_UNMOUNTABLE))
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -233,10 +234,11 @@ public class StorageNotification extends SystemUI {
.setStyle(new Notification.BigTextStyle().bigText(text))
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_ERROR)
.build();
.setCategory(Notification.CATEGORY_ERROR);
SystemUI.overrideNotificationAppName(mContext, builder);
mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, notif, UserHandle.ALL);
mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, builder.build(),
UserHandle.ALL);
} else {
// Yay, we have volumes!
@@ -471,7 +473,7 @@ public class StorageNotification extends SystemUI {
intent = buildWizardMigratePendingIntent(move);
}
final Notification notif = new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_sd_card_48dp)
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -483,10 +485,11 @@ public class StorageNotification extends SystemUI {
.setCategory(Notification.CATEGORY_PROGRESS)
.setPriority(Notification.PRIORITY_LOW)
.setProgress(100, status, false)
.setOngoing(true)
.build();
.setOngoing(true);
SystemUI.overrideNotificationAppName(mContext, builder);
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, notif, UserHandle.ALL);
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID,
builder.build(), UserHandle.ALL);
}
private void onMoveFinished(MoveInfo move, int status) {
@@ -520,7 +523,7 @@ public class StorageNotification extends SystemUI {
intent = null;
}
final Notification notif = new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_sd_card_48dp)
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -531,10 +534,11 @@ public class StorageNotification extends SystemUI {
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_SYSTEM)
.setPriority(Notification.PRIORITY_LOW)
.setAutoCancel(true)
.build();
.setAutoCancel(true);
SystemUI.overrideNotificationAppName(mContext, builder);
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, notif, UserHandle.ALL);
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(),
UserHandle.ALL);
}
private int getSmallIcon(DiskInfo disk, int state) {
@@ -555,7 +559,7 @@ public class StorageNotification extends SystemUI {
private Notification.Builder buildNotificationBuilder(VolumeInfo vol, CharSequence title,
CharSequence text) {
return new Notification.Builder(mContext)
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(getSmallIcon(vol.getDisk(), vol.getState()))
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -563,6 +567,8 @@ public class StorageNotification extends SystemUI {
.setStyle(new Notification.BigTextStyle().bigText(text))
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
overrideNotificationAppName(mContext, builder);
return builder;
}
private PendingIntent buildInitPendingIntent(DiskInfo disk) {

View File

@@ -228,22 +228,23 @@ public class VolumeUI extends SystemUI {
}
final Intent intent = new Intent(Receiver.DISABLE)
.putExtra(Receiver.EXTRA_COMPONENT, component);
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_volume_media)
.setWhen(0)
.setShowWhen(false)
.setOngoing(true)
.setContentTitle(mContext.getString(
R.string.volumeui_notification_title, getAppLabel(component)))
.setContentText(mContext.getString(R.string.volumeui_notification_text))
.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT))
.setPriority(Notification.PRIORITY_MIN)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color));
overrideNotificationAppName(mContext, builder);
mNotificationManager.notify(R.id.notification_volumeui,
new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_volume_media)
.setWhen(0)
.setShowWhen(false)
.setOngoing(true)
.setContentTitle(mContext.getString(
R.string.volumeui_notification_title, getAppLabel(component)))
.setContentText(mContext.getString(R.string.volumeui_notification_text))
.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT))
.setPriority(Notification.PRIORITY_MIN)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color))
.build());
builder.build());
}
}
}