SystemUI uses Builder API with NotificationChannel
Some changes to channels based on UX feedback. Test: runtest systemui Change-Id: I1b2f661ba145d6926035f992231dc3c2f8cbf844
This commit is contained in:
@@ -51,9 +51,6 @@ public class PluginInstanceManager<T extends Plugin> {
|
||||
private static final String TAG = "PluginInstanceManager";
|
||||
private static final String PLUGIN_PERMISSION = "com.android.systemui.permission.PLUGIN";
|
||||
|
||||
// must be one of the channels created in NotificationChannels.java
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "ALR";
|
||||
|
||||
private final Context mContext;
|
||||
private final PluginListener<T> mListener;
|
||||
private final String mAction;
|
||||
@@ -310,14 +307,14 @@ public class PluginInstanceManager<T extends Plugin> {
|
||||
mContext.getPackageName());
|
||||
final int color = Resources.getSystem().getIdentifier(
|
||||
"system_notification_accent_color", "color", "android");
|
||||
final Notification.Builder nb = new Notification.Builder(mContext)
|
||||
.setStyle(new Notification.BigTextStyle())
|
||||
.setSmallIcon(icon)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setChannel(NOTIFICATION_CHANNEL_ID)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(color));
|
||||
final Notification.Builder nb = new Notification.Builder(mContext,
|
||||
PluginManager.NOTIFICATION_CHANNEL_ID)
|
||||
.setStyle(new Notification.BigTextStyle())
|
||||
.setSmallIcon(icon)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(color));
|
||||
String label = cls;
|
||||
try {
|
||||
label = mPm.getServiceInfo(component, 0).loadLabel(mPm).toString();
|
||||
|
||||
@@ -55,6 +55,9 @@ public class PluginManager extends BroadcastReceiver {
|
||||
|
||||
static final String DISABLE_PLUGIN = "com.android.systemui.action.DISABLE_PLUGIN";
|
||||
|
||||
// must be one of the channels created in NotificationChannels.java
|
||||
static final String NOTIFICATION_CHANNEL_ID = "ALR";
|
||||
|
||||
private static PluginManager sInstance;
|
||||
|
||||
private final HandlerThread mBackgroundThread;
|
||||
@@ -191,15 +194,16 @@ public class PluginManager extends BroadcastReceiver {
|
||||
} catch (NameNotFoundException e) {
|
||||
}
|
||||
// Localization not required as this will never ever appear in a user build.
|
||||
final Notification.Builder nb = new Notification.Builder(mContext)
|
||||
.setSmallIcon(icon)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setPriority(Notification.PRIORITY_MAX)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(color))
|
||||
.setContentTitle("Plugin \"" + label + "\" has updated")
|
||||
.setContentText("Restart SysUI for changes to take effect.");
|
||||
final Notification.Builder nb =
|
||||
new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
|
||||
.setSmallIcon(icon)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setPriority(Notification.PRIORITY_MAX)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(color))
|
||||
.setContentTitle("Plugin \"" + label + "\" has updated")
|
||||
.setContentText("Restart SysUI for changes to take effect.");
|
||||
Intent i = new Intent("com.android.systemui.action.RESTART").setData(
|
||||
Uri.parse("package://" + pkg));
|
||||
PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, 0);
|
||||
|
||||
@@ -1802,10 +1802,8 @@
|
||||
<string name="notification_channel_alerts">Alerts</string>
|
||||
<!-- Title for the notification channel dedicated to screenshot progress. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_channel_screenshot">Screenshots</string>
|
||||
<!-- Title for the notification channel for urgent security issues. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_channel_security">Security</string>
|
||||
<!-- Title for the notification channel containing multi-user status information. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_channel_user_status">User status</string>
|
||||
<!-- Title for the notification channel for miscellaneous notices. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_channel_general">General Messages</string>
|
||||
<!-- Title for the notification channel for problems with storage (i.e. low disk). [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_channel_storage">Storage</string>
|
||||
|
||||
|
||||
@@ -145,16 +145,16 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
}
|
||||
|
||||
private void showInvalidChargerNotification() {
|
||||
final Notification.Builder nb = new Notification.Builder(mContext)
|
||||
.setSmallIcon(R.drawable.ic_power_low)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setOngoing(true)
|
||||
.setContentTitle(mContext.getString(R.string.invalid_charger_title))
|
||||
.setContentText(mContext.getString(R.string.invalid_charger_text))
|
||||
.setChannel(NotificationChannels.ALERTS)
|
||||
.setColor(mContext.getColor(
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
final Notification.Builder nb =
|
||||
new Notification.Builder(mContext, NotificationChannels.ALERTS)
|
||||
.setSmallIcon(R.drawable.ic_power_low)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setOngoing(true)
|
||||
.setContentTitle(mContext.getString(R.string.invalid_charger_title))
|
||||
.setContentText(mContext.getString(R.string.invalid_charger_text))
|
||||
.setColor(mContext.getColor(
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
SystemUI.overrideNotificationAppName(mContext, nb);
|
||||
final Notification n = nb.build();
|
||||
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL);
|
||||
@@ -164,19 +164,19 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
private void showWarningNotification() {
|
||||
final int textRes = R.string.battery_low_percent_format;
|
||||
final String percentage = NumberFormat.getPercentInstance().format((double) mBatteryLevel / 100.0);
|
||||
final Notification.Builder nb = new Notification.Builder(mContext)
|
||||
.setSmallIcon(R.drawable.ic_power_low)
|
||||
// Bump the notification when the bucket dropped.
|
||||
.setWhen(mBucketDroppedNegativeTimeMs)
|
||||
.setShowWhen(false)
|
||||
.setContentTitle(mContext.getString(R.string.battery_low_title))
|
||||
.setContentText(mContext.getString(textRes, percentage))
|
||||
.setOnlyAlertOnce(true)
|
||||
.setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_WARNING))
|
||||
.setChannel(NotificationChannels.ALERTS)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(
|
||||
com.android.internal.R.color.battery_saver_mode_color));
|
||||
final Notification.Builder nb =
|
||||
new Notification.Builder(mContext, NotificationChannels.ALERTS)
|
||||
.setSmallIcon(R.drawable.ic_power_low)
|
||||
// Bump the notification when the bucket dropped.
|
||||
.setWhen(mBucketDroppedNegativeTimeMs)
|
||||
.setShowWhen(false)
|
||||
.setContentTitle(mContext.getString(R.string.battery_low_title))
|
||||
.setContentText(mContext.getString(textRes, percentage))
|
||||
.setOnlyAlertOnce(true)
|
||||
.setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_WARNING))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(
|
||||
com.android.internal.R.color.battery_saver_mode_color));
|
||||
if (hasBatterySettings()) {
|
||||
nb.setContentIntent(pendingBroadcast(ACTION_SHOW_BATTERY_SETTINGS));
|
||||
}
|
||||
@@ -235,18 +235,18 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
return;
|
||||
}
|
||||
mTempWarning = true;
|
||||
final Notification.Builder nb = new Notification.Builder(mContext)
|
||||
.setSmallIcon(R.drawable.ic_device_thermostat_24)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setContentTitle(mContext.getString(R.string.high_temp_title))
|
||||
.setContentText(mContext.getString(R.string.high_temp_notif_message))
|
||||
.setChannel(NotificationChannels.ALERTS)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setContentIntent(pendingBroadcast(ACTION_CLICKED_TEMP_WARNING))
|
||||
.setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
|
||||
.setColor(mContext.getColor(
|
||||
com.android.internal.R.color.battery_saver_mode_color));
|
||||
final Notification.Builder nb =
|
||||
new Notification.Builder(mContext, NotificationChannels.ALERTS)
|
||||
.setSmallIcon(R.drawable.ic_device_thermostat_24)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setContentTitle(mContext.getString(R.string.high_temp_title))
|
||||
.setContentText(mContext.getString(R.string.high_temp_notif_message))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setContentIntent(pendingBroadcast(ACTION_CLICKED_TEMP_WARNING))
|
||||
.setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
|
||||
.setColor(mContext.getColor(
|
||||
com.android.internal.R.color.battery_saver_mode_color));
|
||||
SystemUI.overrideNotificationAppName(mContext, nb);
|
||||
final Notification n = nb.build();
|
||||
mNoMan.notifyAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, n, UserHandle.ALL);
|
||||
|
||||
@@ -178,20 +178,19 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
||||
.bigPicture(picture.createAshmemBitmap());
|
||||
|
||||
// The public notification will show similar info but with the actual screenshot omitted
|
||||
mPublicNotificationBuilder = new Notification.Builder(context)
|
||||
.setChannel(NotificationChannels.SCREENSHOTS)
|
||||
.setContentTitle(r.getString(R.string.screenshot_saving_title))
|
||||
.setContentText(r.getString(R.string.screenshot_saving_text))
|
||||
.setSmallIcon(R.drawable.stat_notify_image)
|
||||
.setCategory(Notification.CATEGORY_PROGRESS)
|
||||
.setWhen(now)
|
||||
.setShowWhen(true)
|
||||
.setColor(r.getColor(
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
mPublicNotificationBuilder =
|
||||
new Notification.Builder(context, NotificationChannels.SCREENSHOTS)
|
||||
.setContentTitle(r.getString(R.string.screenshot_saving_title))
|
||||
.setContentText(r.getString(R.string.screenshot_saving_text))
|
||||
.setSmallIcon(R.drawable.stat_notify_image)
|
||||
.setCategory(Notification.CATEGORY_PROGRESS)
|
||||
.setWhen(now)
|
||||
.setShowWhen(true)
|
||||
.setColor(r.getColor(
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
SystemUI.overrideNotificationAppName(context, mPublicNotificationBuilder);
|
||||
|
||||
mNotificationBuilder = new Notification.Builder(context)
|
||||
.setChannel(NotificationChannels.SCREENSHOTS)
|
||||
mNotificationBuilder = new Notification.Builder(context, NotificationChannels.SCREENSHOTS)
|
||||
.setTicker(r.getString(R.string.screenshot_saving_ticker)
|
||||
+ (mTickerAddSpace ? " " : ""))
|
||||
.setContentTitle(r.getString(R.string.screenshot_saving_title))
|
||||
@@ -335,7 +334,6 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
// Update the text and the icon for the existing notification
|
||||
mPublicNotificationBuilder
|
||||
.setChannel(NotificationChannels.SCREENSHOTS)
|
||||
.setContentTitle(r.getString(R.string.screenshot_saved_title))
|
||||
.setContentText(r.getString(R.string.screenshot_saved_text))
|
||||
.setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent, 0))
|
||||
@@ -344,7 +342,6 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
||||
.setColor(context.getColor(
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
mNotificationBuilder
|
||||
.setChannel(NotificationChannels.SCREENSHOTS)
|
||||
.setContentTitle(r.getString(R.string.screenshot_saved_title))
|
||||
.setContentText(r.getString(R.string.screenshot_saved_text))
|
||||
.setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent, 0))
|
||||
@@ -858,7 +855,7 @@ class GlobalScreenshot {
|
||||
String errorMsg = r.getString(msgResId);
|
||||
|
||||
// Repurpose the existing notification to notify the user of the error
|
||||
Notification.Builder b = new Notification.Builder(context)
|
||||
Notification.Builder b = new Notification.Builder(context, NotificationChannels.ALERTS)
|
||||
.setTicker(r.getString(R.string.screenshot_failed_title))
|
||||
.setContentTitle(r.getString(R.string.screenshot_failed_title))
|
||||
.setContentText(errorMsg)
|
||||
|
||||
@@ -5776,20 +5776,21 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
final int colorRes = com.android.internal.R.color.system_notification_accent_color;
|
||||
Notification.Builder note = new Notification.Builder(mContext)
|
||||
.setSmallIcon(R.drawable.ic_android)
|
||||
.setContentTitle(mContext.getString(R.string.hidden_notifications_title))
|
||||
.setContentText(mContext.getString(R.string.hidden_notifications_text))
|
||||
.setChannel(NotificationChannels.SECURITY)
|
||||
.setOngoing(true)
|
||||
.setColor(mContext.getColor(colorRes))
|
||||
.setContentIntent(setupIntent)
|
||||
.addAction(R.drawable.ic_close,
|
||||
mContext.getString(R.string.hidden_notifications_cancel),
|
||||
cancelIntent)
|
||||
.addAction(R.drawable.ic_settings,
|
||||
mContext.getString(R.string.hidden_notifications_setup),
|
||||
setupIntent);
|
||||
Notification.Builder note =
|
||||
new Notification.Builder(mContext, NotificationChannels.GENERAL)
|
||||
.setSmallIcon(R.drawable.ic_android)
|
||||
.setContentTitle(mContext.getString(
|
||||
R.string.hidden_notifications_title))
|
||||
.setContentText(mContext.getString(R.string.hidden_notifications_text))
|
||||
.setOngoing(true)
|
||||
.setColor(mContext.getColor(colorRes))
|
||||
.setContentIntent(setupIntent)
|
||||
.addAction(R.drawable.ic_close,
|
||||
mContext.getString(R.string.hidden_notifications_cancel),
|
||||
cancelIntent)
|
||||
.addAction(R.drawable.ic_settings,
|
||||
mContext.getString(R.string.hidden_notifications_setup),
|
||||
setupIntent);
|
||||
overrideNotificationAppName(mContext, note);
|
||||
|
||||
NotificationManager noMan =
|
||||
|
||||
@@ -560,18 +560,20 @@ public class UserSwitcherController {
|
||||
private void showLogoutNotification(int userId) {
|
||||
PendingIntent logoutPI = PendingIntent.getBroadcastAsUser(mContext,
|
||||
0, new Intent(ACTION_LOGOUT_USER), 0, UserHandle.SYSTEM);
|
||||
Notification.Builder builder = new Notification.Builder(mContext)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.setChannel(NotificationChannels.USER)
|
||||
.setSmallIcon(R.drawable.ic_person)
|
||||
.setContentTitle(mContext.getString(R.string.user_logout_notification_title))
|
||||
.setContentText(mContext.getString(R.string.user_logout_notification_text))
|
||||
.setContentIntent(logoutPI)
|
||||
.setOngoing(true)
|
||||
.setShowWhen(false)
|
||||
.addAction(R.drawable.ic_delete,
|
||||
mContext.getString(R.string.user_logout_notification_action),
|
||||
logoutPI);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.GENERAL)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.setSmallIcon(R.drawable.ic_person)
|
||||
.setContentTitle(mContext.getString(
|
||||
R.string.user_logout_notification_title))
|
||||
.setContentText(mContext.getString(
|
||||
R.string.user_logout_notification_text))
|
||||
.setContentIntent(logoutPI)
|
||||
.setOngoing(true)
|
||||
.setShowWhen(false)
|
||||
.addAction(R.drawable.ic_delete,
|
||||
mContext.getString(R.string.user_logout_notification_action),
|
||||
logoutPI);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER,
|
||||
SystemMessage.NOTE_LOGOUT_USER, builder.build(), new UserHandle(userId));
|
||||
@@ -584,17 +586,17 @@ public class UserSwitcherController {
|
||||
PendingIntent removeGuestPI = canSwitchUsers ? PendingIntent.getBroadcastAsUser(mContext,
|
||||
0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM) : null;
|
||||
|
||||
Notification.Builder builder = new Notification.Builder(mContext)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.setChannel(NotificationChannels.USER)
|
||||
.setSmallIcon(R.drawable.ic_person)
|
||||
.setContentTitle(mContext.getString(R.string.guest_notification_title))
|
||||
.setContentText(mContext.getString(R.string.guest_notification_text))
|
||||
.setContentIntent(removeGuestPI)
|
||||
.setShowWhen(false)
|
||||
.addAction(R.drawable.ic_delete,
|
||||
mContext.getString(R.string.guest_notification_remove_action),
|
||||
removeGuestPI);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.GENERAL)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.setSmallIcon(R.drawable.ic_person)
|
||||
.setContentTitle(mContext.getString(R.string.guest_notification_title))
|
||||
.setContentText(mContext.getString(R.string.guest_notification_text))
|
||||
.setContentIntent(removeGuestPI)
|
||||
.setShowWhen(false)
|
||||
.addAction(R.drawable.ic_delete,
|
||||
mContext.getString(R.string.guest_notification_remove_action),
|
||||
removeGuestPI);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST,
|
||||
SystemMessage.NOTE_REMOVE_GUEST, builder.build(), new UserHandle(guestUserId));
|
||||
|
||||
@@ -198,18 +198,19 @@ public class StorageNotification extends SystemUI {
|
||||
rec.getNickname());
|
||||
final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
|
||||
|
||||
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)
|
||||
.setContentText(text)
|
||||
.setContentIntent(buildForgetPendingIntent(rec))
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setChannel(NotificationChannels.STORAGE)
|
||||
.setCategory(Notification.CATEGORY_SYSTEM)
|
||||
.setDeleteIntent(buildSnoozeIntent(fsUuid));
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.STORAGE)
|
||||
.setSmallIcon(R.drawable.ic_sd_card_48dp)
|
||||
.setColor(mContext.getColor(
|
||||
R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setContentIntent(buildForgetPendingIntent(rec))
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setCategory(Notification.CATEGORY_SYSTEM)
|
||||
.setDeleteIntent(buildSnoozeIntent(fsUuid));
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
|
||||
@@ -226,17 +227,17 @@ public class StorageNotification extends SystemUI {
|
||||
final CharSequence text = mContext.getString(
|
||||
R.string.ext_media_unsupported_notification_message, disk.getDescription());
|
||||
|
||||
Notification.Builder builder = new Notification.Builder(mContext)
|
||||
.setChannel(NotificationChannels.STORAGE)
|
||||
.setSmallIcon(getSmallIcon(disk, VolumeInfo.STATE_UNMOUNTABLE))
|
||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setContentIntent(buildInitPendingIntent(disk))
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setCategory(Notification.CATEGORY_ERROR);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.STORAGE)
|
||||
.setSmallIcon(getSmallIcon(disk, VolumeInfo.STATE_UNMOUNTABLE))
|
||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setContentIntent(buildInitPendingIntent(disk))
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setCategory(Notification.CATEGORY_ERROR);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
|
||||
@@ -475,19 +476,19 @@ public class StorageNotification extends SystemUI {
|
||||
intent = buildWizardMigratePendingIntent(move);
|
||||
}
|
||||
|
||||
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)
|
||||
.setContentText(text)
|
||||
.setContentIntent(intent)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setChannel(NotificationChannels.STORAGE)
|
||||
.setCategory(Notification.CATEGORY_PROGRESS)
|
||||
.setProgress(100, status, false)
|
||||
.setOngoing(true);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.STORAGE)
|
||||
.setSmallIcon(R.drawable.ic_sd_card_48dp)
|
||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setContentIntent(intent)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setCategory(Notification.CATEGORY_PROGRESS)
|
||||
.setProgress(100, status, false)
|
||||
.setOngoing(true);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
|
||||
@@ -526,18 +527,18 @@ public class StorageNotification extends SystemUI {
|
||||
intent = null;
|
||||
}
|
||||
|
||||
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)
|
||||
.setContentText(text)
|
||||
.setContentIntent(intent)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setCategory(Notification.CATEGORY_SYSTEM)
|
||||
.setChannel(NotificationChannels.STORAGE)
|
||||
.setAutoCancel(true);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.STORAGE)
|
||||
.setSmallIcon(R.drawable.ic_sd_card_48dp)
|
||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setContentIntent(intent)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true)
|
||||
.setCategory(Notification.CATEGORY_SYSTEM)
|
||||
.setAutoCancel(true);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
|
||||
@@ -562,15 +563,15 @@ public class StorageNotification extends SystemUI {
|
||||
|
||||
private Notification.Builder buildNotificationBuilder(VolumeInfo vol, CharSequence title,
|
||||
CharSequence text) {
|
||||
Notification.Builder builder = new Notification.Builder(mContext)
|
||||
.setChannel(NotificationChannels.STORAGE)
|
||||
.setSmallIcon(getSmallIcon(vol.getDisk(), vol.getState()))
|
||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true);
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(mContext, NotificationChannels.STORAGE)
|
||||
.setSmallIcon(getSmallIcon(vol.getDisk(), vol.getState()))
|
||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(text))
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true);
|
||||
overrideNotificationAppName(mContext, builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ import java.util.Arrays;
|
||||
public class NotificationChannels extends SystemUI {
|
||||
public static String ALERTS = "ALR";
|
||||
public static String SCREENSHOTS = "SCN";
|
||||
public static String SECURITY = "SEC";
|
||||
public static String USER = "USR";
|
||||
public static String GENERAL = "GEN";
|
||||
public static String STORAGE = "DSK";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -42,14 +41,10 @@ public class NotificationChannels extends SystemUI {
|
||||
new NotificationChannel(
|
||||
SCREENSHOTS,
|
||||
context.getString(R.string.notification_channel_screenshot),
|
||||
NotificationManager.IMPORTANCE_DEFAULT),
|
||||
NotificationManager.IMPORTANCE_LOW),
|
||||
new NotificationChannel(
|
||||
SECURITY,
|
||||
context.getString(R.string.notification_channel_security),
|
||||
NotificationManager.IMPORTANCE_HIGH),
|
||||
new NotificationChannel(
|
||||
USER,
|
||||
context.getString(R.string.notification_channel_user_status),
|
||||
GENERAL,
|
||||
context.getString(R.string.notification_channel_general),
|
||||
NotificationManager.IMPORTANCE_MIN),
|
||||
new NotificationChannel(
|
||||
STORAGE,
|
||||
|
||||
@@ -55,9 +55,8 @@ public class ChannelsTest extends SysuiTestCase {
|
||||
Set<String> ALL_CHANNELS = new ArraySet<>(Arrays.asList(
|
||||
NotificationChannels.ALERTS,
|
||||
NotificationChannels.SCREENSHOTS,
|
||||
NotificationChannels.SECURITY,
|
||||
NotificationChannels.USER,
|
||||
NotificationChannels.STORAGE
|
||||
NotificationChannels.STORAGE,
|
||||
NotificationChannels.GENERAL
|
||||
));
|
||||
NotificationChannels.createAll(mContext);
|
||||
ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
|
||||
|
||||
Reference in New Issue
Block a user