From 9aa1c9e9256674de2e75d0fa1d61cc10a85d416b Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Mon, 9 Apr 2018 11:31:15 -0400 Subject: [PATCH] Add link to onboarding screen Test: runtest systemui-notification Bug: 77658931 Change-Id: I70210b5d5e0de27ff38a6b2f5d8201266b6ec4d6 --- core/java/android/app/NotificationManager.java | 26 ++++++++++++++++++++++ core/java/android/provider/Settings.java | 17 ++++++++++++++ core/res/res/drawable/ic_zen_24dp.xml | 26 ++++++++++++++++++++++ core/res/res/values/strings.xml | 4 ++-- core/res/res/values/symbols.xml | 1 + .../android/server/notification/ZenModeHelper.java | 10 ++++++--- 6 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 core/res/res/drawable/ic_zen_24dp.xml diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 5113fd0cc368..757fc643d9a3 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -1338,6 +1338,32 @@ public class NotificationManager { return false; } + /** + * @hide + */ + public static int toggleScreenOffEffectsSuppressed(int currentEffects, boolean suppress) { + return toggleEffects(currentEffects, SCREEN_OFF_SUPPRESSED_EFFECTS, suppress); + } + + /** + * @hide + */ + public static int toggleScreenOnEffectsSuppressed(int currentEffects, boolean suppress) { + return toggleEffects(currentEffects, SCREEN_ON_SUPPRESSED_EFFECTS, suppress); + } + + private static int toggleEffects(int currentEffects, int[] effects, boolean suppress) { + for (int i = 0; i < effects.length; i++) { + final int effect = effects[i]; + if (suppress) { + currentEffects |= effect; + } else { + currentEffects &= ~effect; + } + } + return currentEffects; + } + public static String suppressedEffectsToString(int effects) { if (effects <= 0) return ""; final StringBuilder sb = new StringBuilder(); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index c361137e1fdc..5aee23930131 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1179,6 +1179,23 @@ public final class Settings { public static final String ACTION_ZEN_MODE_SETTINGS = "android.settings.ZEN_MODE_SETTINGS"; /** + * Activity Action: Show Zen Mode visual effects configuration settings. + * + * @hide + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ZEN_MODE_BLOCKED_EFFECTS_SETTINGS = + "android.settings.ZEN_MODE_BLOCKED_EFFECTS_SETTINGS"; + + /** + * Activity Action: Show Zen Mode onboarding activity. + * + * @hide + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ZEN_MODE_ONBOARDING = "android.settings.ZEN_MODE_ONBOARDING"; + + /** * Activity Action: Show Zen Mode (aka Do Not Disturb) priority configuration settings. */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) diff --git a/core/res/res/drawable/ic_zen_24dp.xml b/core/res/res/drawable/ic_zen_24dp.xml new file mode 100644 index 000000000000..790bfb97c60c --- /dev/null +++ b/core/res/res/drawable/ic_zen_24dp.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 715be5b47d1c..1798d45e29b3 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4943,9 +4943,9 @@ Do Not Disturb - Do Not Disturb is hiding notifications to help you focus + New: Do Not Disturb is hiding notifications - This is new behavior. Tap to change. + Tap to learn more and change. Do Not Disturb has changed diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 683a72c424b4..b6f0b709e9e3 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2549,6 +2549,7 @@ + diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java index 586abc16fe34..156f70259938 100644 --- a/services/core/java/com/android/server/notification/ZenModeHelper.java +++ b/services/core/java/com/android/server/notification/ZenModeHelper.java @@ -32,6 +32,7 @@ import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.database.ContentObserver; +import android.graphics.drawable.Icon; import android.media.AudioAttributes; import android.media.AudioManager; import android.media.AudioManagerInternal; @@ -1198,8 +1199,6 @@ public class ZenModeHelper { @VisibleForTesting protected Notification createZenUpgradeNotification() { - Intent intent = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, mContext.getResources().getString(R.string.global_action_settings)); @@ -1210,15 +1209,20 @@ public class ZenModeHelper { title = R.string.zen_upgrade_notification_visd_title; content = R.string.zen_upgrade_notification_visd_content; } + Intent onboardingIntent = new Intent(Settings.ZEN_MODE_ONBOARDING); + onboardingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); return new Notification.Builder(mContext, SystemNotificationChannels.DO_NOT_DISTURB) + .setAutoCancel(true) .setSmallIcon(R.drawable.ic_settings_24dp) + .setLargeIcon(Icon.createWithResource(mContext, R.drawable.ic_zen_24dp)) .setContentTitle(mContext.getResources().getString(title)) .setContentText(mContext.getResources().getString(content)) + .setContentIntent(PendingIntent.getActivity(mContext, 0, onboardingIntent, + PendingIntent.FLAG_UPDATE_CURRENT)) .setAutoCancel(true) .setLocalOnly(true) .addExtras(extras) .setStyle(new Notification.BigTextStyle()) - .setContentIntent(PendingIntent.getActivity(mContext, 0, intent, 0, null)) .build(); } -- 2.11.0