diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9ab180d90db..9d2f1f0d610 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5699,7 +5699,26 @@
Topic notifications
+
+ Categories
+
+ Importance
+
+
+ Blocked: Never show these notifications
+
+
+ Low: Silently show at the bottom of the notification list
+
+
+ Normal: Silently show these notifications
+
+
+ High: Show at the top of the notifications list and make sound
+
+
+ Urgent: Peek onto the screen and make sound
Notification access
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 6e27a075b38..5f00caf865c 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -30,7 +30,12 @@
+
+
diff --git a/res/xml/topic_notification_settings.xml b/res/xml/topic_notification_settings.xml
index 174c2731823..d5f28b32a65 100644
--- a/res/xml/topic_notification_settings.xml
+++ b/res/xml/topic_notification_settings.xml
@@ -21,7 +21,7 @@
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index deba7d41b24..2ee2b811089 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -28,10 +28,12 @@ import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
+import android.service.notification.NotificationListenerService;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
+import android.support.v7.preference.PreferenceCategory;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
@@ -55,6 +57,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
private static final String KEY_BLOCK = "block";
private static final String KEY_APP_SETTINGS = "app_settings";
+ private static final String KEY_CATEGORIES = "categories";
private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
= new Intent(Intent.ACTION_MAIN)
@@ -64,6 +67,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
private Context mContext;
private SwitchPreference mBlock;
+ private PreferenceCategory mCategories;
private AppRow mAppRow;
private boolean mCreated;
private boolean mIsSystemPackage;
@@ -136,6 +140,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
// Add topics
List topics = mBackend.getTopics(pkg, mUid);
+ mCategories = (PreferenceCategory) getPreferenceScreen().findPreference(KEY_CATEGORIES);
for (Notification.Topic topic : topics) {
Preference topicPreference = new Preference(mContext);
topicPreference.setKey(topic.getId());
@@ -151,8 +156,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
TopicNotificationSettings.class.getName(),
topicArgs, null, R.string.topic_notifications_title, null, false);
topicPreference.setIntent(topicIntent);
- // Add preference to the settings menu.
- getPreferenceScreen().addPreference(topicPreference);
+ mCategories.addPreference(topicPreference);
}
mBlock.setChecked(mAppRow.banned);
@@ -198,6 +202,9 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
private void updateDependents(boolean banned) {
setVisible(mBlock, !mIsSystemPackage);
+ if (mCategories != null) {
+ setVisible(mCategories, !banned);
+ }
}
private void setVisible(Preference p, boolean visible) {
diff --git a/src/com/android/settings/notification/ImportanceSeekBarPreference.java b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
index ec774678637..58892e32cd3 100644
--- a/src/com/android/settings/notification/ImportanceSeekBarPreference.java
+++ b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
@@ -90,20 +90,15 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
private String getProgressSummary(int progress) {
switch (progress) {
case NotificationListenerService.Ranking.IMPORTANCE_NONE:
- return getContext().getString(
- com.android.internal.R.string.notification_importance_blocked);
+ return getContext().getString(R.string.notification_importance_blocked);
case NotificationListenerService.Ranking.IMPORTANCE_LOW:
- return getContext().getString(
- com.android.internal.R.string.notification_importance_low);
+ return getContext().getString(R.string.notification_importance_low);
case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
- return getContext().getString(
- com.android.internal.R.string.notification_importance_default);
+ return getContext().getString(R.string.notification_importance_default);
case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
- return getContext().getString(
- com.android.internal.R.string.notification_importance_high);
+ return getContext().getString(R.string.notification_importance_high);
case NotificationListenerService.Ranking.IMPORTANCE_MAX:
- return getContext().getString(
- com.android.internal.R.string.notification_importance_max);
+ return getContext().getString(R.string.notification_importance_max);
default:
return "";
}
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 4c1f6ea655d..15f82fe02c3 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -144,7 +144,7 @@ public class NotificationBackend {
return sINM.getTopicImportance(pkg, uid, topic);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
- return NotificationListenerService.Ranking.IMPORTANCE_DEFAULT;
+ return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
}
}
diff --git a/src/com/android/settings/notification/TopicNotificationSettings.java b/src/com/android/settings/notification/TopicNotificationSettings.java
index e847e347a4a..e8586c27af6 100644
--- a/src/com/android/settings/notification/TopicNotificationSettings.java
+++ b/src/com/android/settings/notification/TopicNotificationSettings.java
@@ -21,11 +21,11 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.settings.AppHeader;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.notification.NotificationBackend.TopicRow;
import android.app.Notification;
+import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -59,8 +59,8 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
private SwitchPreference mSensitive;
private TopicRow mTopicRow;
private boolean mCreated;
- private boolean mIsSystemPackage;
private int mUid;
+ private boolean mDndVisualEffectsSuppressed;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -94,6 +94,10 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
return;
}
+ NotificationManager.Policy policy =
+ NotificationManager.from(mContext).getNotificationPolicy();
+ mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
+
final Notification.Topic topic = args != null && args.containsKey(ARG_TOPIC)
? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
@@ -120,7 +124,6 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
}
final PackageManager pm = getPackageManager();
- mIsSystemPackage = Utils.isSystemPackage(pm, info);
addPreferencesFromResource(R.xml.topic_notification_settings);
mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
@@ -140,6 +143,7 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
@Override
public void onImportanceChanged(int progress) {
mBackend.setImportance(mTopicRow.pkg, mTopicRow.uid, mTopicRow.topic, progress);
+ updateDependents(progress);
}
});
mPriority.setChecked(mTopicRow.priority);
@@ -160,7 +164,7 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
return mBackend.setSensitive(info.packageName, mUid, topic, sensitive);
}
});
- updateDependents(mTopicRow.banned);
+ updateDependents(mTopicRow.importance);
}
@@ -173,16 +177,17 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
}
}
- private void updateDependents(boolean banned) {
+ private void updateDependents(int importance) {
final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure(
UserHandle.myUserId());
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
- setVisible(mPriority, mIsSystemPackage || !banned);
- setVisible(mSensitive, mIsSystemPackage || !banned && lockscreenSecure
- && lockscreenNotificationsEnabled && allowPrivate);
- setVisible(mImportance, !banned);
+
+ setVisible(mPriority, importance > NotificationListenerService.Ranking.IMPORTANCE_DEFAULT
+ && !mDndVisualEffectsSuppressed);
+ setVisible(mSensitive, (importance > NotificationListenerService.Ranking.IMPORTANCE_LOW)
+ && lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
}
private void setVisible(Preference p, boolean visible) {