Merge "Notification filter changes." into nyc-dev

This commit is contained in:
Julia Reynolds
2016-03-03 16:43:58 +00:00
committed by Android (Google) Code Review
4 changed files with 91 additions and 8 deletions

View File

@@ -5974,7 +5974,7 @@
<string name="notification_importance_default">Normal: Allow these notification to make sounds</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
<string name="notification_importance_high">High: Peek onto the screen and allow sound and allow sound</string>
<string name="notification_importance_high">High: Peek onto the screen and allow sound</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
<string name="notification_importance_max">Urgent: Show at the top of the notifications list, peek onto the screen and allow sound</string>
@@ -6434,6 +6434,8 @@
<string name="notifications_enabled">Normal</string>
<!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
<string name="notifications_disabled">Blocked</string>
<!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
<string name="notifications_silenced">Silenced</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] -->
@@ -6476,6 +6478,14 @@
<string name="filter_notif_blocked_apps">Blocked</string>
<!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
<string name="filter_with_domain_urls_apps">With domain URLs</string>
<!-- Label for showing apps with priority notifications in list [CHAR LIMIT=30] -->
<string name="filter_notif_priority_apps">Overrides Do Not Disturb</string>
<!-- Label for showing apps redacting sensitive notifications in list [CHAR LIMIT=30] -->
<string name="filter_notif_sensitive_apps">No sensitive content on lock screen</string>
<!-- Label for showing apps hiding notifications from lockscreen [CHAR LIMIT=30] -->
<string name="filter_notif_hide_notifications_apps">Never shown on lock screen</string>
<!-- Filter label for apps that the user has silenced [CHAR LIMIT=40] -->
<string name="filter_notif_silent">Shown silently</string>
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
<string name="advanced_apps">Advanced</string>

View File

@@ -15,7 +15,9 @@
*/
package com.android.settings.applications;
import android.app.Notification;
import android.content.pm.PackageManager;
import android.service.notification.NotificationListenerService;
import com.android.settings.notification.NotificationBackend;
import com.android.settings.notification.NotificationBackend.AppRow;
@@ -70,4 +72,55 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
return false;
}
};
public static final AppFilter FILTER_APP_NOTIFICATION_SILENCED = new AppFilter() {
@Override
public void init() {
}
@Override
public boolean filterApp(AppEntry info) {
if (info == null) {
return false;
}
AppRow row = (AppRow) info.extraInfo;
return row.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE
&& row.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT;
}
};
public static final AppFilter FILTER_APP_NOTIFICATION_PRIORITY = new AppFilter() {
@Override
public void init() {
}
@Override
public boolean filterApp(AppEntry info) {
return info.extraInfo != null && ((AppRow) info.extraInfo).appBypassDnd;
}
};
public static final AppFilter FILTER_APP_NOTIFICATION_HIDE_SENSITIVE = new AppFilter() {
@Override
public void init() {
}
@Override
public boolean filterApp(AppEntry info) {
return info.extraInfo != null
&& ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_PRIVATE;
}
};
public static final AppFilter FILTER_APP_NOTIFICATION_HIDE_ALL = new AppFilter() {
@Override
public void init() {
}
@Override
public boolean filterApp(AppEntry info) {
return info.extraInfo != null
&& ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_SECRET;
}
};
}

View File

@@ -50,6 +50,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.notification.NotificationListenerService;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceCategory;
@@ -1007,8 +1008,11 @@ 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.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE
&& appRow.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT) {
return context.getString(R.string.notifications_silenced);
}
return context.getString(R.string.notifications_enabled);
return "";
}
private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {

View File

@@ -126,12 +126,16 @@ public class ManageApplications extends InstrumentedFragment
public static final int FILTER_APPS_ENABLED = 3;
public static final int FILTER_APPS_DISABLED = 4;
public static final int FILTER_APPS_BLOCKED = 5;
public static final int FILTER_APPS_PERSONAL = 6;
public static final int FILTER_APPS_WORK = 7;
public static final int FILTER_APPS_WITH_DOMAIN_URLS = 8;
public static final int FILTER_APPS_USAGE_ACCESS = 9;
public static final int FILTER_APPS_WITH_OVERLAY = 10;
public static final int FILTER_APPS_WRITE_SETTINGS = 11;
public static final int FILTER_APPS_SILENT = 6;
public static final int FILTER_APPS_SENSITIVE = 7;
public static final int FILTER_APPS_HIDE_NOTIFICATIONS = 8;
public static final int FILTER_APPS_PRIORITY = 9;
public static final int FILTER_APPS_PERSONAL = 10;
public static final int FILTER_APPS_WORK = 11;
public static final int FILTER_APPS_WITH_DOMAIN_URLS = 12;
public static final int FILTER_APPS_USAGE_ACCESS = 13;
public static final int FILTER_APPS_WITH_OVERLAY = 14;
public static final int FILTER_APPS_WRITE_SETTINGS = 15;
// This is the string labels for the filter modes above, the order must be kept in sync.
public static final int[] FILTER_LABELS = new int[]{
@@ -141,6 +145,10 @@ public class ManageApplications extends InstrumentedFragment
R.string.filter_enabled_apps, // Enabled
R.string.filter_apps_disabled, // Disabled
R.string.filter_notif_blocked_apps, // Blocked Notifications
R.string.filter_notif_silent, // Silenced Notifications
R.string.filter_notif_sensitive_apps, // Sensitive Notifications
R.string.filter_notif_hide_notifications_apps, // Sensitive Notifications
R.string.filter_notif_priority_apps, // Priority Notifications
R.string.filter_personal_apps, // Personal
R.string.filter_work_apps, // Work
R.string.filter_with_domain_urls_apps, // Domain URLs
@@ -159,6 +167,10 @@ public class ManageApplications extends InstrumentedFragment
ApplicationsState.FILTER_ALL_ENABLED, // Enabled
ApplicationsState.FILTER_DISABLED, // Disabled
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED, // Blocked Notifications
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_SILENCED, // Silenced Notifications
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_HIDE_SENSITIVE, // Sensitive Notifications
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_HIDE_ALL, // Hide all Notifications
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_PRIORITY, // Priority Notifications
ApplicationsState.FILTER_PERSONAL, // Personal
ApplicationsState.FILTER_WORK, // Work
ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs
@@ -343,6 +355,10 @@ public class ManageApplications extends InstrumentedFragment
}
if (mListType == LIST_TYPE_NOTIFICATION) {
mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
mFilterAdapter.enableFilter(FILTER_APPS_SILENT);
mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE);
mFilterAdapter.enableFilter(FILTER_APPS_HIDE_NOTIFICATIONS);
mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY);
}
if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);