Support showing notifications as badges.
And remove unneeded app level settings. Change-Id: I88f506b0704195181d1748a3135f8ee0f39b774f Test: manual for now. will add tests when have real mocks for the pages
This commit is contained in:
@@ -81,64 +81,4 @@ 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 || info.extraInfo == null) {
|
||||
return false;
|
||||
}
|
||||
AppRow row = (AppRow) info.extraInfo;
|
||||
return row.appImportance > NotificationManager.IMPORTANCE_NONE
|
||||
&& row.appImportance < NotificationManager.IMPORTANCE_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter FILTER_APP_NOTIFICATION_PRIORITY = new AppFilter() {
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(AppEntry info) {
|
||||
if (info == null || info.extraInfo == null) {
|
||||
return false;
|
||||
}
|
||||
return ((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) {
|
||||
if (info == null || info.extraInfo == null) {
|
||||
return false;
|
||||
}
|
||||
return ((AppRow) info.extraInfo).lockScreenSecure
|
||||
&& ((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) {
|
||||
if (info == null || info.extraInfo == null) {
|
||||
return false;
|
||||
}
|
||||
return ((AppRow) info.extraInfo).lockScreenSecure
|
||||
&& ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_SECRET;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1088,10 +1088,6 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
return NetworkTemplate.buildTemplateEthernet();
|
||||
}
|
||||
|
||||
public static CharSequence getNotificationSummary(AppEntry appEntry, Context context) {
|
||||
return getNotificationSummary(appEntry, context, new NotificationBackend());
|
||||
}
|
||||
|
||||
public static CharSequence getNotificationSummary(AppEntry appEntry, Context context,
|
||||
NotificationBackend backend) {
|
||||
AppRow appRow = backend.loadAppRow(context, context.getPackageManager(), appEntry.info);
|
||||
@@ -1099,43 +1095,8 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
}
|
||||
|
||||
public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
|
||||
boolean showSlider = Settings.Secure.getInt(
|
||||
context.getContentResolver(), NOTIFICATION_TUNER_SETTING, 0) == 1;
|
||||
List<String> summaryAttributes = new ArrayList<>();
|
||||
StringBuffer summary = new StringBuffer();
|
||||
if (showSlider) {
|
||||
if (appRow.appImportance != NotificationManager.IMPORTANCE_UNSPECIFIED) {
|
||||
summaryAttributes.add(context.getString(
|
||||
R.string.notification_summary_level, appRow.appImportance));
|
||||
}
|
||||
} else {
|
||||
if (appRow.banned) {
|
||||
summaryAttributes.add(context.getString(R.string.notifications_disabled));
|
||||
} else if (appRow.appImportance > NotificationManager.IMPORTANCE_NONE
|
||||
&& appRow.appImportance < NotificationManager.IMPORTANCE_DEFAULT) {
|
||||
summaryAttributes.add(context.getString(R.string.notifications_silenced));
|
||||
}
|
||||
}
|
||||
final boolean lockscreenSecure = new LockPatternUtils(context).isSecure(
|
||||
UserHandle.myUserId());
|
||||
if (lockscreenSecure) {
|
||||
if (appRow.appVisOverride == Notification.VISIBILITY_PRIVATE) {
|
||||
summaryAttributes.add(context.getString(R.string.notifications_redacted));
|
||||
} else if (appRow.appVisOverride == Notification.VISIBILITY_SECRET) {
|
||||
summaryAttributes.add(context.getString(R.string.notifications_hidden));
|
||||
}
|
||||
}
|
||||
if (appRow.appBypassDnd) {
|
||||
summaryAttributes.add(context.getString(R.string.notifications_priority));
|
||||
}
|
||||
final int N = summaryAttributes.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
if (i > 0) {
|
||||
summary.append(context.getString(R.string.notifications_summary_divider));
|
||||
}
|
||||
summary.append(summaryAttributes.get(i));
|
||||
}
|
||||
return summary.toString();
|
||||
// TODO: implement summary when it is known what it should say
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -131,15 +131,11 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
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_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_USAGE_ACCESS = 13;
|
||||
public static final int FILTER_APPS_WITH_OVERLAY = 14;
|
||||
public static final int FILTER_APPS_WRITE_SETTINGS = 15;
|
||||
public static final int FILTER_APPS_PERSONAL = 6;
|
||||
public static final int FILTER_APPS_WORK = 7;
|
||||
public static final int FILTER_APPS_USAGE_ACCESS = 8;
|
||||
public static final int FILTER_APPS_WITH_OVERLAY = 9;
|
||||
public static final int FILTER_APPS_WRITE_SETTINGS = 10;
|
||||
|
||||
// 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[]{
|
||||
@@ -149,10 +145,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
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
|
||||
@@ -171,10 +163,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
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
|
||||
@@ -356,10 +344,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
}
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user