Settings: App notification settings updates.
- Tweak language. - Add new heads-up configuration setting. - Remove instead of disable settings dependent on the banhammer. Bug: 19776495 Change-Id: I3fac1a61bd66acd6db70b461e414c4e55dee9296
This commit is contained in:
@@ -5815,22 +5815,28 @@
|
|||||||
<string name="loading_notification_apps">Loading apps...</string>
|
<string name="loading_notification_apps">Loading apps...</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Block option title -->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Block option title -->
|
||||||
<string name="app_notification_block_title">Block</string>
|
<string name="app_notification_block_title">Block all</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Block option description-->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Block option description-->
|
||||||
<string name="app_notification_block_summary">Never show notifications from this app</string>
|
<string name="app_notification_block_summary">Never show notifications from this app</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Priority option title -->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Priority option title -->
|
||||||
<string name="app_notification_priority_title">Priority</string>
|
<string name="app_notification_priority_title">Treat as priority</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Priority option description-->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Priority option description-->
|
||||||
<string name="app_notification_priority_summary">Show notifications at the top of the list and keep them coming when the device is set to priority interruptions only</string>
|
<string name="app_notification_priority_summary">Let this app\'s notifications be heard when Do not disturb is set to Priority only</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] App notification settings: Peekable option title -->
|
||||||
|
<string name="app_notification_peekable_title">Allow peeking</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] App notification settings: Peekable option description-->
|
||||||
|
<string name="app_notification_peekable_summary">Let this app emphasize certain notifications by sliding them briefly into view on the current screen</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Sensitive option title -->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Sensitive option title -->
|
||||||
<string name="app_notification_sensitive_title">Sensitive</string>
|
<string name="app_notification_sensitive_title">Hide sensitive content</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Sensitive option description-->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Sensitive option description-->
|
||||||
<string name="app_notification_sensitive_summary">When the device is locked, hide any sensitive content from this app\'s notifications</string>
|
<string name="app_notification_sensitive_summary">When the device is locked, hide content in this app\'s notifications that might reveal private information</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when banned -->
|
<!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when banned -->
|
||||||
<string name="app_notification_row_banned">Blocked</string>
|
<string name="app_notification_row_banned">Blocked</string>
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
android:key="block"
|
android:key="block"
|
||||||
android:title="@string/app_notification_block_title"
|
android:title="@string/app_notification_block_title"
|
||||||
android:summary="@string/app_notification_block_summary"
|
android:summary="@string/app_notification_block_summary"
|
||||||
android:disableDependentsState="true"
|
android:order="1"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<!-- Priority -->
|
<!-- Priority -->
|
||||||
@@ -31,7 +31,15 @@
|
|||||||
android:key="priority"
|
android:key="priority"
|
||||||
android:title="@string/app_notification_priority_title"
|
android:title="@string/app_notification_priority_title"
|
||||||
android:summary="@string/app_notification_priority_summary"
|
android:summary="@string/app_notification_priority_summary"
|
||||||
android:dependency="block"
|
android:order="2"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<!-- Peekable -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="peekable"
|
||||||
|
android:title="@string/app_notification_peekable_title"
|
||||||
|
android:summary="@string/app_notification_peekable_summary"
|
||||||
|
android:order="3"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<!-- Sensitive -->
|
<!-- Sensitive -->
|
||||||
@@ -39,6 +47,7 @@
|
|||||||
android:key="sensitive"
|
android:key="sensitive"
|
||||||
android:title="@string/app_notification_sensitive_title"
|
android:title="@string/app_notification_sensitive_title"
|
||||||
android:summary="@string/app_notification_sensitive_summary"
|
android:summary="@string/app_notification_sensitive_summary"
|
||||||
|
android:order="4"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -46,6 +46,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private static final String KEY_BLOCK = "block";
|
private static final String KEY_BLOCK = "block";
|
||||||
private static final String KEY_PRIORITY = "priority";
|
private static final String KEY_PRIORITY = "priority";
|
||||||
|
private static final String KEY_PEEKABLE = "peekable";
|
||||||
private static final String KEY_SENSITIVE = "sensitive";
|
private static final String KEY_SENSITIVE = "sensitive";
|
||||||
|
|
||||||
static final String EXTRA_HAS_SETTINGS_INTENT = "has_settings_intent";
|
static final String EXTRA_HAS_SETTINGS_INTENT = "has_settings_intent";
|
||||||
@@ -56,9 +57,11 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private SwitchPreference mBlock;
|
private SwitchPreference mBlock;
|
||||||
private SwitchPreference mPriority;
|
private SwitchPreference mPriority;
|
||||||
|
private SwitchPreference mPeekable;
|
||||||
private SwitchPreference mSensitive;
|
private SwitchPreference mSensitive;
|
||||||
private AppRow mAppRow;
|
private AppRow mAppRow;
|
||||||
private boolean mCreated;
|
private boolean mCreated;
|
||||||
|
private boolean mIsSystemPackage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
@@ -104,19 +107,14 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
toastAndFinish();
|
toastAndFinish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mIsSystemPackage = Utils.isSystemPackage(pm, info);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.app_notification_settings);
|
addPreferencesFromResource(R.xml.app_notification_settings);
|
||||||
mBlock = (SwitchPreference) findPreference(KEY_BLOCK);
|
mBlock = (SwitchPreference) findPreference(KEY_BLOCK);
|
||||||
mPriority = (SwitchPreference) findPreference(KEY_PRIORITY);
|
mPriority = (SwitchPreference) findPreference(KEY_PRIORITY);
|
||||||
|
mPeekable = (SwitchPreference) findPreference(KEY_PEEKABLE);
|
||||||
mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE);
|
mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE);
|
||||||
|
|
||||||
final boolean secure = new LockPatternUtils(getActivity()).isSecure();
|
|
||||||
final boolean enabled = getLockscreenNotificationsEnabled();
|
|
||||||
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
|
||||||
if (!secure || !enabled || !allowPrivate) {
|
|
||||||
getPreferenceScreen().removePreference(mSensitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
mAppRow = NotificationAppList.loadAppRow(pm, info.applicationInfo, mBackend);
|
mAppRow = NotificationAppList.loadAppRow(pm, info.applicationInfo, mBackend);
|
||||||
if (intent.hasExtra(EXTRA_HAS_SETTINGS_INTENT)) {
|
if (intent.hasExtra(EXTRA_HAS_SETTINGS_INTENT)) {
|
||||||
// use settings intent from extra
|
// use settings intent from extra
|
||||||
@@ -131,16 +129,20 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mBlock.setChecked(mAppRow.banned);
|
mBlock.setChecked(mAppRow.banned);
|
||||||
|
updateDependents(mAppRow.banned);
|
||||||
mPriority.setChecked(mAppRow.priority);
|
mPriority.setChecked(mAppRow.priority);
|
||||||
if (mSensitive != null) {
|
mPeekable.setChecked(mAppRow.peekable);
|
||||||
mSensitive.setChecked(mAppRow.sensitive);
|
mSensitive.setChecked(mAppRow.sensitive);
|
||||||
}
|
|
||||||
|
|
||||||
mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
final boolean block = (Boolean) newValue;
|
final boolean banned = (Boolean) newValue;
|
||||||
return mBackend.setNotificationsBanned(pkg, uid, block);
|
final boolean success = mBackend.setNotificationsBanned(pkg, uid, banned);
|
||||||
|
if (success) {
|
||||||
|
updateDependents(banned);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,7 +154,14 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mSensitive != null) {
|
mPeekable.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
final boolean peekable = (Boolean) newValue;
|
||||||
|
return mBackend.setPeekable(pkg, uid, peekable);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mSensitive.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
mSensitive.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
@@ -162,10 +171,25 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Users cannot block notifications from system/signature packages
|
private void updateDependents(boolean banned) {
|
||||||
if (Utils.isSystemPackage(pm, info)) {
|
final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure();
|
||||||
getPreferenceScreen().removePreference(mBlock);
|
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
|
||||||
mPriority.setDependency(null); // don't have it depend on a preference that's gone
|
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
||||||
|
|
||||||
|
setVisible(mBlock, !mIsSystemPackage);
|
||||||
|
setVisible(mPriority, mIsSystemPackage || !banned);
|
||||||
|
setVisible(mPeekable, mIsSystemPackage || !banned);
|
||||||
|
setVisible(mSensitive, mIsSystemPackage || !banned && lockscreenSecure
|
||||||
|
&& lockscreenNotificationsEnabled && allowPrivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setVisible(Preference p, boolean visible) {
|
||||||
|
final boolean isVisible = getPreferenceScreen().findPreference(p.getKey()) != null;
|
||||||
|
if (isVisible == visible) return;
|
||||||
|
if (visible) {
|
||||||
|
getPreferenceScreen().addPreference(p);
|
||||||
|
} else {
|
||||||
|
getPreferenceScreen().removePreference(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -364,6 +364,7 @@ public class NotificationAppList extends PinnedHeaderListFragment
|
|||||||
public Intent settingsIntent;
|
public Intent settingsIntent;
|
||||||
public boolean banned;
|
public boolean banned;
|
||||||
public boolean priority;
|
public boolean priority;
|
||||||
|
public boolean peekable;
|
||||||
public boolean sensitive;
|
public boolean sensitive;
|
||||||
public boolean first; // first app in section
|
public boolean first; // first app in section
|
||||||
}
|
}
|
||||||
@@ -391,6 +392,7 @@ public class NotificationAppList extends PinnedHeaderListFragment
|
|||||||
row.icon = app.loadIcon(pm);
|
row.icon = app.loadIcon(pm);
|
||||||
row.banned = backend.getNotificationsBanned(row.pkg, row.uid);
|
row.banned = backend.getNotificationsBanned(row.pkg, row.uid);
|
||||||
row.priority = backend.getHighPriority(row.pkg, row.uid);
|
row.priority = backend.getHighPriority(row.pkg, row.uid);
|
||||||
|
row.peekable = backend.getPeekable(row.pkg, row.uid);
|
||||||
row.sensitive = backend.getSensitive(row.pkg, row.uid);
|
row.sensitive = backend.getSensitive(row.pkg, row.uid);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -578,6 +580,25 @@ public class NotificationAppList extends PinnedHeaderListFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getPeekable(String pkg, int uid) {
|
||||||
|
try {
|
||||||
|
return sINM.getPackagePeekable(pkg, uid);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.w(TAG, "Error calling NoMan", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setPeekable(String pkg, int uid, boolean peekable) {
|
||||||
|
try {
|
||||||
|
sINM.setPackagePeekable(pkg, uid, peekable);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.w(TAG, "Error calling NoMan", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getSensitive(String pkg, int uid) {
|
public boolean getSensitive(String pkg, int uid) {
|
||||||
try {
|
try {
|
||||||
return sINM.getPackageVisibilityOverride(pkg, uid) == Notification.VISIBILITY_PRIVATE;
|
return sINM.getPackageVisibilityOverride(pkg, uid) == Notification.VISIBILITY_PRIVATE;
|
||||||
|
Reference in New Issue
Block a user