Delete Notification Topics.
Bug: 23220370 Change-Id: I072b68650af35ae3d5c5ccf6222dc31f5f36f9bb
This commit is contained in:
@@ -5901,12 +5901,6 @@
|
||||
<!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
|
||||
<string name="app_notifications_title">Notifications</string>
|
||||
|
||||
<!-- Sound & notification > Notification section: Title for the option managing notifications per topic. [CHAR LIMIT=30] -->
|
||||
<string name="topic_notifications_title">Topic notifications</string>
|
||||
|
||||
<!-- [CHAR LIMIT=100] Notification topic list header -->
|
||||
<string name="notification_topic_categories">Categories</string>
|
||||
|
||||
<!-- [CHAR LIMIT=100] Notification importance slider title -->
|
||||
<string name="notification_importance_title">Importance</string>
|
||||
|
||||
@@ -6376,9 +6370,7 @@
|
||||
<!-- App notification summary with notifications enabled [CHAR LIMIT=40] -->
|
||||
<string name="notifications_enabled">Normal</string>
|
||||
<!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
|
||||
<string name="notifications_disabled">Fully Blocked</string>
|
||||
<!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
|
||||
<string name="notifications_partially_disabled">Partially Blocked</string>
|
||||
<string name="notifications_disabled">Blocked</string>
|
||||
<!-- App notification summary with 2 items [CHAR LIMIT=15] -->
|
||||
<string name="notifications_two_items"><xliff:g id="notif_state" example="Priority">%1$s</xliff:g> / <xliff:g id="notif_state" example="Priority">%2$s</xliff:g></string>
|
||||
<!-- App notification summary with 3 items [CHAR LIMIT=15] -->
|
||||
|
@@ -18,7 +18,6 @@
|
||||
android:title="@string/app_notifications_title"
|
||||
android:key="app_notification_settings">
|
||||
|
||||
<!-- Apps without topics -->
|
||||
<!-- Importance -->
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="importance_title"
|
||||
@@ -47,17 +46,4 @@
|
||||
android:summary="@string/app_notification_override_dnd_summary"
|
||||
android:order="6" />
|
||||
|
||||
<!-- Apps with topics -->
|
||||
<!-- Block -->
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:key="block"
|
||||
android:title="@string/app_notification_block_title"
|
||||
android:summary="@string/app_notification_block_summary"
|
||||
android:order="7" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="categories"
|
||||
android:title="@string/notification_topic_categories"
|
||||
android:order="8" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -67,7 +67,7 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
|
||||
return false;
|
||||
}
|
||||
AppRow row = (AppRow) info.extraInfo;
|
||||
return row.banned || row.bannedTopics;
|
||||
return row.banned;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -842,8 +842,6 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
|
||||
if (appRow.banned) {
|
||||
return context.getString(R.string.notifications_disabled);
|
||||
} else if (appRow.bannedTopics) {
|
||||
return context.getString(R.string.notifications_partially_disabled);
|
||||
}
|
||||
return context.getString(R.string.notifications_enabled);
|
||||
}
|
||||
|
@@ -17,11 +17,14 @@
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService.Ranking;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
@@ -32,6 +35,7 @@ import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.AppHeader;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
@@ -50,16 +54,12 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
private static final String TAG = "AppNotificationSettings";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
private static final String KEY_BLOCK = "block";
|
||||
private static final String KEY_CATEGORIES = "categories";
|
||||
|
||||
private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
|
||||
= new Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
|
||||
|
||||
private RestrictedSwitchPreference mBlock;
|
||||
private PreferenceCategory mCategories;
|
||||
private AppRow mAppRow;
|
||||
private boolean mDndVisualEffectsSuppressed;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
@@ -79,8 +79,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.app_notification_settings);
|
||||
mCategories = (PreferenceCategory) findPreference(KEY_CATEGORIES);
|
||||
mBlock = (RestrictedSwitchPreference) findPreference(KEY_BLOCK);
|
||||
mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
|
||||
mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
|
||||
mImportanceTitle = (RestrictedPreference) findPreference(KEY_IMPORTANCE_TITLE);
|
||||
@@ -91,84 +89,49 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
|
||||
mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
|
||||
|
||||
NotificationManager.Policy policy =
|
||||
NotificationManager.from(mContext).getNotificationPolicy();
|
||||
mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
|
||||
|
||||
// load settings intent
|
||||
ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
|
||||
rows.put(mAppRow.pkg, mAppRow);
|
||||
collectConfigActivities(rows);
|
||||
|
||||
// Add topics
|
||||
List<Notification.Topic> topics = mBackend.getTopics(mPkg, mUid);
|
||||
if (topics.size() <= 1) {
|
||||
removeAppPrefs();
|
||||
setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
|
||||
setupPriorityPref(mAppRow.appBypassDnd);
|
||||
setupSensitivePref(mAppRow.appSensitive);
|
||||
} else {
|
||||
removeTopicPrefs();
|
||||
setupBlockSwitch();
|
||||
for (Notification.Topic topic : topics) {
|
||||
RestrictedPreference topicPreference = new RestrictedPreference(getPrefContext());
|
||||
topicPreference.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||
topicPreference.setKey(topic.getId());
|
||||
topicPreference.setTitle(topic.getLabel());
|
||||
// Create intent for this preference.
|
||||
Bundle topicArgs = new Bundle();
|
||||
topicArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
|
||||
topicArgs.putParcelable(TopicNotificationSettings.ARG_TOPIC, topic);
|
||||
topicArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true);
|
||||
topicArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
|
||||
topicArgs.putParcelable(TopicNotificationSettings.ARG_PACKAGE_INFO, mPkgInfo);
|
||||
|
||||
Intent topicIntent = Utils.onBuildStartFragmentIntent(getActivity(),
|
||||
TopicNotificationSettings.class.getName(),
|
||||
topicArgs, null, R.string.topic_notifications_title, null, false);
|
||||
topicPreference.setIntent(topicIntent);
|
||||
mCategories.addPreference(topicPreference);
|
||||
}
|
||||
}
|
||||
setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
|
||||
setupPriorityPref(mAppRow.appBypassDnd);
|
||||
setupSensitivePref(mAppRow.appSensitive);
|
||||
updateDependents(mAppRow.appImportance);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateDependents(int progress) {
|
||||
updateDependents(progress == Ranking.IMPORTANCE_NONE);
|
||||
protected void updateDependents(int importance) {
|
||||
final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure(
|
||||
UserHandle.myUserId());
|
||||
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
|
||||
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
||||
|
||||
setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
|
||||
&& !mDndVisualEffectsSuppressed);
|
||||
setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
|
||||
&& lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
|
||||
}
|
||||
|
||||
private void removeTopicPrefs() {
|
||||
setVisible(mImportance, false);
|
||||
setVisible(mImportanceReset, false);
|
||||
setVisible(mImportanceTitle, false);
|
||||
setVisible(mPriority, false);
|
||||
setVisible(mSensitive, false);
|
||||
protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
|
||||
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
||||
return true;
|
||||
}
|
||||
return importance > minImportanceVisible;
|
||||
}
|
||||
|
||||
private void removeAppPrefs() {
|
||||
setVisible(mBlock, false);
|
||||
setVisible(mCategories, false);
|
||||
private boolean getLockscreenNotificationsEnabled() {
|
||||
return Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
||||
}
|
||||
|
||||
private void updateDependents(boolean banned) {
|
||||
mBlock.setEnabled(!mAppRow.systemApp);
|
||||
mCategories.setEnabled(!banned);
|
||||
}
|
||||
|
||||
private void setupBlockSwitch() {
|
||||
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||
mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean banned = (Boolean) newValue;
|
||||
if (banned) {
|
||||
MetricsLogger.action(getActivity(), MetricsEvent.ACTION_BAN_APP_NOTES, mPkg);
|
||||
}
|
||||
final boolean success = mBackend.setNotificationsBanned(mPkg, mUid, banned);
|
||||
if (success) {
|
||||
updateDependents(banned);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
});
|
||||
mBlock.setChecked(mAppRow.banned);
|
||||
updateDependents(mAppRow.banned);
|
||||
private boolean getLockscreenAllowPrivateNotifications() {
|
||||
return Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
|
||||
}
|
||||
|
||||
private List<ResolveInfo> queryNotificationConfigActivities() {
|
||||
|
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.android.settings.notification;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import android.app.INotificationManager;
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
@@ -24,15 +22,12 @@ 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;
|
||||
|
||||
public class NotificationBackend {
|
||||
private static final String TAG = "NotificationBackend";
|
||||
|
||||
@@ -51,10 +46,9 @@ public class NotificationBackend {
|
||||
}
|
||||
row.icon = app.loadIcon(pm);
|
||||
row.banned = getNotificationsBanned(row.pkg, row.uid);
|
||||
row.appImportance = getImportance(row.pkg, row.uid, null);
|
||||
row.appBypassDnd = getBypassZenMode(row.pkg, row.uid, null);
|
||||
row.appSensitive = getSensitive(row.pkg, row.uid, null);
|
||||
row.bannedTopics = hasBannedTopics(row.pkg, row.uid);
|
||||
row.appImportance = getImportance(row.pkg, row.uid);
|
||||
row.appBypassDnd = getBypassZenMode(row.pkg, row.uid);
|
||||
row.appSensitive = getSensitive(row.pkg, row.uid);
|
||||
return row;
|
||||
}
|
||||
|
||||
@@ -64,31 +58,6 @@ public class NotificationBackend {
|
||||
return row;
|
||||
}
|
||||
|
||||
public TopicRow loadTopicRow(PackageManager pm, PackageInfo app, Notification.Topic topic) {
|
||||
final TopicRow row = new TopicRow();
|
||||
row.pkg = app.packageName;
|
||||
row.uid = app.applicationInfo.uid;
|
||||
row.label = topic.getLabel();
|
||||
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);
|
||||
row.banned = getNotificationsBanned(row.pkg, row.uid);
|
||||
row.importance = getImportance(row.pkg, row.uid, row.topic);
|
||||
return row;
|
||||
}
|
||||
|
||||
public boolean setNotificationsBanned(String pkg, int uid, boolean banned) {
|
||||
try {
|
||||
sINM.setNotificationsEnabledForPackage(pkg, uid, !banned);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getNotificationsBanned(String pkg, int uid) {
|
||||
try {
|
||||
final boolean enabled = sINM.areNotificationsEnabledForPackage(pkg, uid);
|
||||
@@ -99,19 +68,18 @@ public class NotificationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getBypassZenMode(String pkg, int uid, Notification.Topic topic) {
|
||||
public boolean getBypassZenMode(String pkg, int uid) {
|
||||
try {
|
||||
return sINM.getPriority(pkg, uid, topic) == Notification.PRIORITY_MAX;
|
||||
return sINM.getPriority(pkg, uid) == Notification.PRIORITY_MAX;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setBypassZenMode(String pkg, int uid, Notification.Topic topic,
|
||||
boolean bypassZen) {
|
||||
public boolean setBypassZenMode(String pkg, int uid, boolean bypassZen) {
|
||||
try {
|
||||
sINM.setPriority(pkg, uid, topic,
|
||||
sINM.setPriority(pkg, uid,
|
||||
bypassZen ? Notification.PRIORITY_MAX : Notification.PRIORITY_DEFAULT);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@@ -120,19 +88,18 @@ public class NotificationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSensitive(String pkg, int uid, Notification.Topic topic) {
|
||||
public boolean getSensitive(String pkg, int uid) {
|
||||
try {
|
||||
return sINM.getVisibilityOverride(pkg, uid, topic)
|
||||
== Notification.VISIBILITY_PRIVATE;
|
||||
return sINM.getVisibilityOverride(pkg, uid) == Notification.VISIBILITY_PRIVATE;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setSensitive(String pkg, int uid, Notification.Topic topic, boolean sensitive) {
|
||||
public boolean setSensitive(String pkg, int uid, boolean sensitive) {
|
||||
try {
|
||||
sINM.setVisibilityOverride(pkg, uid, topic,
|
||||
sINM.setVisibilityOverride(pkg, uid,
|
||||
sensitive ? Notification.VISIBILITY_PRIVATE
|
||||
: NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE);
|
||||
return true;
|
||||
@@ -142,9 +109,9 @@ public class NotificationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setImportance(String pkg, int uid, Notification.Topic topic, int importance) {
|
||||
public boolean setImportance(String pkg, int uid, int importance) {
|
||||
try {
|
||||
sINM.setImportance(pkg, uid, topic, importance);
|
||||
sINM.setImportance(pkg, uid, importance);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
@@ -152,34 +119,15 @@ public class NotificationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
public int getImportance(String pkg, int uid, Notification.Topic topic) {
|
||||
public int getImportance(String pkg, int uid) {
|
||||
try {
|
||||
return sINM.getImportance(pkg, uid, topic);
|
||||
return sINM.getImportance(pkg, uid);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Notification.Topic> getTopics(String pkg, int uid) {
|
||||
try {
|
||||
final ParceledListSlice<Notification.Topic> parceledList = sINM.getTopics(pkg, uid);
|
||||
return parceledList.getList();
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasBannedTopics(String pkg, int uid) {
|
||||
try {
|
||||
return sINM.hasBannedTopics(pkg, uid);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static class Row {
|
||||
public String section;
|
||||
}
|
||||
@@ -196,13 +144,5 @@ public class NotificationBackend {
|
||||
public int appImportance;
|
||||
public boolean appBypassDnd;
|
||||
public boolean appSensitive;
|
||||
public boolean bannedTopics;
|
||||
}
|
||||
|
||||
public static class TopicRow extends AppRow {
|
||||
public Notification.Topic topic;
|
||||
public boolean priority;
|
||||
public boolean sensitive;
|
||||
public int importance;
|
||||
}
|
||||
}
|
||||
|
@@ -47,9 +47,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
private static final String TAG = "NotifiSettingsBase";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
protected static final String ARG_PACKAGE_INFO = "arg_info";
|
||||
protected static final String ARG_TOPIC = "arg_topic";
|
||||
|
||||
protected static final String KEY_BYPASS_DND = "bypass_dnd";
|
||||
protected static final String KEY_SENSITIVE = "sensitive";
|
||||
protected static final String KEY_IMPORTANCE = "importance";
|
||||
@@ -64,7 +61,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
protected int mUserId;
|
||||
protected String mPkg;
|
||||
protected PackageInfo mPkgInfo;
|
||||
protected Notification.Topic mTopic;
|
||||
protected ImportanceSeekBarPreference mImportance;
|
||||
protected RestrictedPreference mImportanceTitle;
|
||||
protected LayoutPreference mImportanceReset;
|
||||
@@ -113,11 +109,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
mUserId = UserHandle.getUserId(mUid);
|
||||
|
||||
if (DEBUG) Log.d(TAG, "Load details for pkg=" + mPkg + " uid=" + mUid);
|
||||
mPkgInfo = args != null && args.containsKey(ARG_PACKAGE_INFO)
|
||||
? (PackageInfo) args.getParcelable(ARG_PACKAGE_INFO) : null;
|
||||
if (mPkgInfo == null) {
|
||||
mPkgInfo = findPackageInfo(mPkg, mUid);
|
||||
}
|
||||
mPkgInfo = findPackageInfo(mPkg, mUid);
|
||||
if (mPkgInfo == null) {
|
||||
Log.w(TAG, "Failed to find package info: " + Settings.EXTRA_APP_PACKAGE + " was " + mPkg
|
||||
+ ", " + Settings.EXTRA_APP_UID + " was " + mUid);
|
||||
@@ -125,10 +117,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
return;
|
||||
}
|
||||
|
||||
// Will be null for app wide settings.
|
||||
mTopic = args != null && args.containsKey(ARG_TOPIC)
|
||||
? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
|
||||
|
||||
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
|
||||
mContext, mPkg, mUserId);
|
||||
}
|
||||
@@ -177,7 +165,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
|
||||
@Override
|
||||
public void onImportanceChanged(int progress) {
|
||||
mBackend.setImportance(mPkg, mUid, mTopic, progress);
|
||||
mBackend.setImportance(mPkg, mUid, progress);
|
||||
mImportanceTitle.setSummary(getProgressSummary(progress));
|
||||
updateDependents(progress);
|
||||
}
|
||||
@@ -194,7 +182,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
return;
|
||||
}
|
||||
|
||||
mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_UNSPECIFIED);
|
||||
mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_UNSPECIFIED);
|
||||
mImportanceReset.setVisible(false);
|
||||
mImportance.setVisible(false);
|
||||
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
|
||||
@@ -231,7 +219,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean bypassZenMode = (Boolean) newValue;
|
||||
return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, mTopic, bypassZenMode);
|
||||
return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, bypassZenMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -243,7 +231,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean sensitive = (Boolean) newValue;
|
||||
return mBackend.setSensitive(mPkgInfo.packageName, mUid, mTopic, sensitive);
|
||||
return mBackend.setSensitive(mPkgInfo.packageName, mUid, sensitive);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -287,7 +275,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_DEFAULT);
|
||||
mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_DEFAULT);
|
||||
mImportance.setProgress(Ranking.IMPORTANCE_DEFAULT);
|
||||
mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_DEFAULT));
|
||||
mImportance.setVisible(true);
|
||||
|
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.AppHeader;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.notification.NotificationBackend.TopicRow;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService.Ranking;
|
||||
|
||||
/** These settings are per topic, so should not be returned in global search results. */
|
||||
public class TopicNotificationSettings extends NotificationSettingsBase {
|
||||
private static final String TAG = "TopicNotiSettings";
|
||||
private TopicRow mTopicRow;
|
||||
private boolean mDndVisualEffectsSuppressed;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (mTopicRow == null) return;
|
||||
AppHeader.createAppHeader(
|
||||
this, mTopicRow.icon, mTopicRow.label, mTopicRow.pkg, mTopicRow.uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsEvent.NOTIFICATION_TOPIC_NOTIFICATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
NotificationManager.Policy policy =
|
||||
NotificationManager.from(mContext).getNotificationPolicy();
|
||||
mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
|
||||
|
||||
if (mTopic == null) {
|
||||
toastAndFinish();
|
||||
return;
|
||||
}
|
||||
|
||||
addPreferencesFromResource(R.xml.topic_notification_settings);
|
||||
mTopicRow = mBackend.loadTopicRow(mPm, mPkgInfo, mTopic);
|
||||
|
||||
mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
|
||||
mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
|
||||
mImportanceTitle = (RestrictedPreference) findPreference(KEY_IMPORTANCE_TITLE);
|
||||
mPriority = (RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND);
|
||||
mSensitive = (RestrictedSwitchPreference) findPreference(KEY_SENSITIVE);
|
||||
|
||||
setupImportancePrefs(mTopicRow.systemApp, mTopicRow.importance);
|
||||
setupPriorityPref(mTopicRow.priority);
|
||||
setupSensitivePref(mTopicRow.sensitive);
|
||||
|
||||
updateDependents(mTopicRow.importance);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateDependents(int importance) {
|
||||
final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure(
|
||||
UserHandle.myUserId());
|
||||
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
|
||||
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
||||
|
||||
setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
|
||||
&& !mDndVisualEffectsSuppressed);
|
||||
setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
|
||||
&& lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
|
||||
}
|
||||
|
||||
protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
|
||||
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
||||
return true;
|
||||
}
|
||||
return importance > minImportanceVisible;
|
||||
}
|
||||
|
||||
private boolean getLockscreenNotificationsEnabled() {
|
||||
return Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
||||
}
|
||||
|
||||
private boolean getLockscreenAllowPrivateNotifications() {
|
||||
return Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user