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:
John Spurlock
2015-03-18 15:33:29 -04:00
parent ad56c0af02
commit 3fb88d743e
4 changed files with 92 additions and 32 deletions

View File

@@ -5815,22 +5815,28 @@
<string name="loading_notification_apps">Loading apps...</string>
<!-- [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-->
<string name="app_notification_block_summary">Never show notifications from this app</string>
<!-- [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-->
<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 -->
<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-->
<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 -->
<string name="app_notification_row_banned">Blocked</string>

View File

@@ -23,7 +23,7 @@
android:key="block"
android:title="@string/app_notification_block_title"
android:summary="@string/app_notification_block_summary"
android:disableDependentsState="true"
android:order="1"
android:persistent="false" />
<!-- Priority -->
@@ -31,7 +31,15 @@
android:key="priority"
android:title="@string/app_notification_priority_title"
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" />
<!-- Sensitive -->
@@ -39,6 +47,7 @@
android:key="sensitive"
android:title="@string/app_notification_sensitive_title"
android:summary="@string/app_notification_sensitive_summary"
android:order="4"
android:persistent="false" />
</PreferenceScreen>

View File

@@ -46,6 +46,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
private static final String KEY_BLOCK = "block";
private static final String KEY_PRIORITY = "priority";
private static final String KEY_PEEKABLE = "peekable";
private static final String KEY_SENSITIVE = "sensitive";
static final String EXTRA_HAS_SETTINGS_INTENT = "has_settings_intent";
@@ -56,9 +57,11 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
private Context mContext;
private SwitchPreference mBlock;
private SwitchPreference mPriority;
private SwitchPreference mPeekable;
private SwitchPreference mSensitive;
private AppRow mAppRow;
private boolean mCreated;
private boolean mIsSystemPackage;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -104,19 +107,14 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
toastAndFinish();
return;
}
mIsSystemPackage = Utils.isSystemPackage(pm, info);
addPreferencesFromResource(R.xml.app_notification_settings);
mBlock = (SwitchPreference) findPreference(KEY_BLOCK);
mPriority = (SwitchPreference) findPreference(KEY_PRIORITY);
mPeekable = (SwitchPreference) findPreference(KEY_PEEKABLE);
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);
if (intent.hasExtra(EXTRA_HAS_SETTINGS_INTENT)) {
// use settings intent from extra
@@ -131,16 +129,20 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
}
mBlock.setChecked(mAppRow.banned);
updateDependents(mAppRow.banned);
mPriority.setChecked(mAppRow.priority);
if (mSensitive != null) {
mSensitive.setChecked(mAppRow.sensitive);
}
mPeekable.setChecked(mAppRow.peekable);
mSensitive.setChecked(mAppRow.sensitive);
mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean block = (Boolean) newValue;
return mBackend.setNotificationsBanned(pkg, uid, block);
final boolean banned = (Boolean) newValue;
final boolean success = mBackend.setNotificationsBanned(pkg, uid, banned);
if (success) {
updateDependents(banned);
}
return success;
}
});
@@ -152,20 +154,42 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
}
});
if (mSensitive != null) {
mSensitive.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean sensitive = (Boolean) newValue;
return mBackend.setSensitive(pkg, uid, sensitive);
}
});
}
mPeekable.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean peekable = (Boolean) newValue;
return mBackend.setPeekable(pkg, uid, peekable);
}
});
// Users cannot block notifications from system/signature packages
if (Utils.isSystemPackage(pm, info)) {
getPreferenceScreen().removePreference(mBlock);
mPriority.setDependency(null); // don't have it depend on a preference that's gone
mSensitive.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean sensitive = (Boolean) newValue;
return mBackend.setSensitive(pkg, uid, sensitive);
}
});
}
private void updateDependents(boolean banned) {
final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure();
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
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);
}
}

View File

@@ -364,6 +364,7 @@ public class NotificationAppList extends PinnedHeaderListFragment
public Intent settingsIntent;
public boolean banned;
public boolean priority;
public boolean peekable;
public boolean sensitive;
public boolean first; // first app in section
}
@@ -391,6 +392,7 @@ public class NotificationAppList extends PinnedHeaderListFragment
row.icon = app.loadIcon(pm);
row.banned = backend.getNotificationsBanned(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);
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) {
try {
return sINM.getPackageVisibilityOverride(pkg, uid) == Notification.VISIBILITY_PRIVATE;