Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 580f32d7 authored by Geoffrey Pitsch's avatar Geoffrey Pitsch Committed by Android (Google) Code Review
Browse files

Merge "SystemUI uses Builder API with NotificationChannel"

parents e8ae5566 1dc93bc4
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -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,12 +307,12 @@ 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)
                    final Notification.Builder nb = new Notification.Builder(mContext,
                            PluginManager.NOTIFICATION_CHANNEL_ID)
                                    .setStyle(new Notification.BigTextStyle())
                                    .setSmallIcon(icon)
                                    .setWhen(0)
                                    .setShowWhen(false)
                            .setChannel(NOTIFICATION_CHANNEL_ID)
                                    .setVisibility(Notification.VISIBILITY_PUBLIC)
                                    .setColor(mContext.getColor(color));
                    String label = cls;
+13 −9
Original line number Diff line number Diff line
@@ -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,7 +194,8 @@ 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)
                final Notification.Builder nb =
                        new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
                                .setSmallIcon(icon)
                                .setWhen(0)
                                .setShowWhen(false)
+2 −4
Original line number Diff line number Diff line
@@ -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>

+35 −35
Original line number Diff line number Diff line
@@ -145,14 +145,14 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
    }

    private void showInvalidChargerNotification() {
        final Notification.Builder nb = new Notification.Builder(mContext)
        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))
                .setChannel(NotificationChannels.ALERTS)
                        .setColor(mContext.getColor(
                                com.android.internal.R.color.system_notification_accent_color));
        SystemUI.overrideNotificationAppName(mContext, nb);
@@ -164,7 +164,8 @@ 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)
        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)
@@ -173,7 +174,6 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                        .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));
@@ -235,13 +235,13 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            return;
        }
        mTempWarning = true;
        final Notification.Builder nb = new Notification.Builder(mContext)
        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))
                .setChannel(NotificationChannels.ALERTS)
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setContentIntent(pendingBroadcast(ACTION_CLICKED_TEMP_WARNING))
                        .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
+12 −15
Original line number Diff line number Diff line
@@ -178,8 +178,8 @@ 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)
        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)
@@ -190,8 +190,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
                                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)
Loading