diff --git a/res/layout/preference_importance_slider.xml b/res/layout/preference_importance_slider.xml
new file mode 100644
index 00000000000..737254be11b
--- /dev/null
+++ b/res/layout/preference_importance_slider.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/preference_volume_slider.xml b/res/layout/preference_volume_slider.xml
index 878a7104cfe..d279eb6095d 100644
--- a/res/layout/preference_volume_slider.xml
+++ b/res/layout/preference_volume_slider.xml
@@ -20,7 +20,8 @@
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:clickable="false" >
Done
+
+ Importance
+
Rule name
diff --git a/res/xml/topic_notification_settings.xml b/res/xml/topic_notification_settings.xml
index 68260700c8e..174c2731823 100644
--- a/res/xml/topic_notification_settings.xml
+++ b/res/xml/topic_notification_settings.xml
@@ -18,6 +18,13 @@
android:title="@string/topic_notifications_title"
android:key="topic_notification_settings">
+
+
+
getTopics(String pkg, int uid) {
try {
final ParceledListSlice parceledList = sINM.getTopics(pkg, uid);
@@ -156,6 +176,7 @@ public class NotificationBackend {
public Notification.Topic topic;
public boolean priority;
public boolean sensitive;
+ public int importance;
}
}
diff --git a/src/com/android/settings/notification/TopicNotificationSettings.java b/src/com/android/settings/notification/TopicNotificationSettings.java
index 48c611e84c0..71196b72d8f 100644
--- a/src/com/android/settings/notification/TopicNotificationSettings.java
+++ b/src/com/android/settings/notification/TopicNotificationSettings.java
@@ -30,14 +30,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
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.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -50,10 +49,12 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
protected static final String ARG_PACKAGE_INFO = "arg_info";
private static final String KEY_BYPASS_DND = "bypass_dnd";
private static final String KEY_SENSITIVE = "sensitive";
+ private static final String KEY_IMPORTANCE = "importance";
private final NotificationBackend mBackend = new NotificationBackend();
private Context mContext;
+ private ImportanceSeekBarPreference mImportance;
private SwitchPreference mPriority;
private SwitchPreference mSensitive;
private TopicRow mTopicRow;
@@ -122,11 +123,27 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
mIsSystemPackage = Utils.isSystemPackage(pm, info);
addPreferencesFromResource(R.xml.topic_notification_settings);
+ mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
mPriority = (SwitchPreference) findPreference(KEY_BYPASS_DND);
mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE);
mTopicRow = mBackend.loadTopicRow(pm, info.applicationInfo, topic);
+ mImportance.setMax(4);
+ // TODO: stop defaulting to 'normal' in the UI when there are mocks for this scenario.
+ int importance =
+ mTopicRow.importance == NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED
+ ? NotificationListenerService.Ranking.IMPORTANCE_DEFAULT
+ : mTopicRow.importance;
+ mImportance.setProgress(
+ importance + ImportanceSeekBarPreference.IMPORTANCE_PROGRESS_OFFSET);
+ mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
+ @Override
+ public void onImportanceChanged(int progress) {
+ mBackend.setImportance(mTopicRow.pkg, mTopicRow.uid, mTopicRow.topic,
+ progress - ImportanceSeekBarPreference.IMPORTANCE_PROGRESS_OFFSET);
+ }
+ });
mPriority.setChecked(mTopicRow.priority);
mSensitive.setChecked(mTopicRow.sensitive);
@@ -167,6 +184,7 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
setVisible(mPriority, mIsSystemPackage || !banned);
setVisible(mSensitive, mIsSystemPackage || !banned && lockscreenSecure
&& lockscreenNotificationsEnabled && allowPrivate);
+ setVisible(mImportance, !banned);
}
private void setVisible(Preference p, boolean visible) {