Importance slide updates.
- Make settings match systemui - prevent users from blocking system notification topics, and share said code with systemui Bug: 26575595 Change-Id: I3911046e2f96897b26b9b9597835a8d7b771996f
This commit is contained in:
@@ -70,7 +70,6 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
||||
private PreferenceCategory mCategories;
|
||||
private AppRow mAppRow;
|
||||
private boolean mCreated;
|
||||
private boolean mIsSystemPackage;
|
||||
private int mUid;
|
||||
|
||||
@Override
|
||||
@@ -126,12 +125,10 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
||||
toastAndFinish();
|
||||
return;
|
||||
}
|
||||
mIsSystemPackage = Utils.isSystemPackage(pm, info);
|
||||
|
||||
addPreferencesFromResource(R.xml.app_notification_settings);
|
||||
mBlock = (SwitchPreference) findPreference(KEY_BLOCK);
|
||||
|
||||
mAppRow = mBackend.loadAppRow(pm, info.applicationInfo);
|
||||
mAppRow = mBackend.loadAppRow(pm, info);
|
||||
|
||||
// load settings intent
|
||||
ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
|
||||
@@ -160,7 +157,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
|
||||
mBlock.setChecked(mAppRow.banned);
|
||||
updateDependents(mAppRow.banned);
|
||||
updateDependents(mAppRow.systemApp, mAppRow.banned);
|
||||
|
||||
mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
@@ -171,7 +168,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
final boolean success = mBackend.setNotificationsBanned(pkg, mUid, banned);
|
||||
if (success) {
|
||||
updateDependents(banned);
|
||||
updateDependents(mAppRow.systemApp, banned);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -200,8 +197,8 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDependents(boolean banned) {
|
||||
setVisible(mBlock, !mIsSystemPackage);
|
||||
private void updateDependents(boolean isSystemPackage, boolean banned) {
|
||||
setVisible(mBlock, !isSystemPackage);
|
||||
if (mCategories != null) {
|
||||
setVisible(mCategories, !banned);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
|
||||
private Callback mCallback;
|
||||
private TextView mSummaryTextView;
|
||||
private String mSummary;
|
||||
private int mMinProgress;
|
||||
|
||||
public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
@@ -59,6 +60,10 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public void setMinimumProgress(int minProgress) {
|
||||
mMinProgress = minProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
@@ -72,8 +77,12 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromTouch) {
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
|
||||
super.onProgressChanged(seekBar, progress, fromTouch);
|
||||
if (progress < mMinProgress) {
|
||||
seekBar.setProgress(mMinProgress);
|
||||
progress = mMinProgress;
|
||||
}
|
||||
if (mSummaryTextView != null) {
|
||||
mSummaryTextView.setText(getProgressSummary(progress));
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@ import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.ServiceManager;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.util.Log;
|
||||
import com.android.settingslib.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -52,12 +54,19 @@ public class NotificationBackend {
|
||||
return row;
|
||||
}
|
||||
|
||||
public TopicRow loadTopicRow(PackageManager pm, ApplicationInfo app, Notification.Topic topic) {
|
||||
public AppRow loadAppRow(PackageManager pm, PackageInfo app) {
|
||||
final AppRow row = loadAppRow(pm, app.applicationInfo);
|
||||
row.systemApp = Utils.isSystemPackage(pm, app);
|
||||
return row;
|
||||
}
|
||||
|
||||
public TopicRow loadTopicRow(PackageManager pm, PackageInfo app, Notification.Topic topic) {
|
||||
final TopicRow row = new TopicRow();
|
||||
row.pkg = app.packageName;
|
||||
row.uid = app.uid;
|
||||
row.uid = app.applicationInfo.uid;
|
||||
row.label = topic.getLabel();
|
||||
row.icon = app.loadIcon(pm);
|
||||
row.icon = app.applicationInfo.loadIcon(pm);
|
||||
row.systemApp = Utils.isSystemPackage(pm, app);
|
||||
row.topic = topic;
|
||||
row.priority = getBypassZenMode(row.pkg, row.uid, row.topic);
|
||||
row.sensitive = getSensitive(row.pkg, row.uid, row.topic);
|
||||
@@ -170,6 +179,7 @@ public class NotificationBackend {
|
||||
public Intent settingsIntent;
|
||||
public boolean banned;
|
||||
public boolean first; // first app in section
|
||||
public boolean systemApp;
|
||||
}
|
||||
|
||||
public static class TopicRow extends AppRow {
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.NotificationListenerService.Ranking;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
@@ -130,9 +131,11 @@ public class TopicNotificationSettings extends SettingsPreferenceFragment {
|
||||
mPriority = (SwitchPreference) findPreference(KEY_BYPASS_DND);
|
||||
mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE);
|
||||
|
||||
mTopicRow = mBackend.loadTopicRow(pm, info.applicationInfo, topic);
|
||||
mTopicRow = mBackend.loadTopicRow(pm, info, topic);
|
||||
|
||||
mImportance.setMax(4);
|
||||
mImportance.setMinimumProgress(
|
||||
mTopicRow.systemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
|
||||
mImportance.setMax(Ranking.IMPORTANCE_MAX);
|
||||
// TODO: stop defaulting to 'normal' in the UI when there are mocks for this scenario.
|
||||
int importance =
|
||||
mTopicRow.importance == NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED
|
||||
|
||||
Reference in New Issue
Block a user