void setTopicImportance(String pkg, int uid, in Notification.Topic topic, int importance);
int getTopicImportance(String pkg, int uid, in Notification.Topic topic);
void setAppImportance(String pkg, int uid, int importance);
+ boolean doesAppUseTopics(String pkg, int uid);
// TODO: Remove this when callers have been migrated to the equivalent
// INotificationListener method.
<!-- [CHAR_LIMIT=NONE] Battery saver: Feature description -->
<string name="battery_saver_description">To help improve battery life, battery saver reduces your device’s performance and limits vibration, location services, and most background data. Email, messaging, and other apps that rely on syncing may not update unless you open them.\n\nBattery saver turns off automatically when your device is charging.</string>
-
- <!-- [CHAR LIMIT=100] Notification importance slider title -->
- <string name="notification_importance_title">Importance</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
- <string name="notification_importance_blocked">Blocked: Never show these notifications</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
- <string name="notification_importance_low">Low: Silently show at the bottom of the notification list</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
- <string name="notification_importance_default">Normal: Silently show these notifications</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
- <string name="notification_importance_high">High: Show at the top of the notifications list and make sound</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
- <string name="notification_importance_max">Urgent: Peek onto the screen and make sound</string>
-
<!-- Zen mode condition - summary: time duration in minutes. [CHAR LIMIT=NONE] -->
<plurals name="zen_mode_duration_minutes_summary">
<item quantity="one">For one minute (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
<java-symbol type="array" name="config_system_condition_providers" />
<java-symbol type="string" name="muted_by" />
<java-symbol type="string" name="zen_mode_alarm" />
- <java-symbol type="string" name="notification_importance_blocked" />
- <java-symbol type="string" name="notification_importance_low" />
- <java-symbol type="string" name="notification_importance_default" />
- <java-symbol type="string" name="notification_importance_high" />
- <java-symbol type="string" name="notification_importance_max" />
- <java-symbol type="string" name="notification_importance_title" />
<java-symbol type="string" name="select_day" />
<java-symbol type="string" name="select_year" />
<!-- Adding Quick Settings tiles -->
<uses-permission android:name="android.permission.BIND_QUICK_SETTINGS_TILE" />
+ <!-- Block notifications inline notifications -->
+ <uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
+
<application
android:name=".SystemUIApplication"
android:persistent="true"
</FrameLayout>
- <RadioGroup android:layout_width="wrap_content"
+ <RadioGroup
+ android:id="@+id/apply_to"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dp">
<RadioButton android:id="@+id/apply_to_topic"
package com.android.systemui.statusbar;
+import android.annotation.IdRes;
import android.app.INotificationManager;
import android.app.Notification;
import android.content.Context;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RadioButton;
+import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.TextView;
? new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(
com.android.internal.R.string.default_notification_topic_label))
: sbn.getNotification().getTopic();
+ boolean doesAppUseTopics = false;
+ try {
+ doesAppUseTopics = sINM.doesAppUseTopics(sbn.getPackageName(), sbn.getUid());
+ } catch (RemoteException e) {}
+ final boolean appUsesTopics = doesAppUseTopics;
final RadioButton applyToTopic = (RadioButton) row.findViewById(R.id.apply_to_topic);
- if (sbn.getNotification().getTopic() != null) {
- applyToTopic.setVisibility(View.VISIBLE);
- applyToTopic.setChecked(true);
- applyToTopic.setText(mContext.getString(R.string.apply_to_topic, topic.getLabel()));
- row.findViewById(R.id.apply_to_app).setVisibility(View.VISIBLE);
- }
-
+ applyToTopic.setChecked(true);
+ final View applyToApp = row.findViewById(R.id.apply_to_app);
final TextView topicSummary = ((TextView) row.findViewById(R.id.summary));
final TextView topicTitle = ((TextView) row.findViewById(R.id.title));
- SeekBar seekBar = (SeekBar) row.findViewById(R.id.seekbar);
+ final SeekBar seekBar = (SeekBar) row.findViewById(R.id.seekbar);
+ final RadioGroup applyTo = (RadioGroup) row.findViewById(R.id.apply_to);
+ applyTo.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
+ try {
+ switch (checkedId) {
+ case R.id.apply_to_topic:
+ sINM.setTopicImportance(sbn.getPackageName(), sbn.getUid(), topic,
+ seekBar.getProgress());
+ break;
+ default:
+ sINM.setAppImportance(sbn.getPackageName(), sbn.getUid(),
+ seekBar.getProgress());
+ }
+ } catch (RemoteException e) {
+ // :(
+ }
+ }
+ });
+
seekBar.setMax(4);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
updateTitleAndSummary(progress);
if (fromUser) {
+ if (appUsesTopics) {
+ applyToTopic.setVisibility(View.VISIBLE);
+
+ applyToTopic.setText(
+ mContext.getString(R.string.apply_to_topic, topic.getLabel()));
+ applyToApp.setVisibility(View.VISIBLE);
+ }
try {
if (applyToTopic.isChecked()) {
sINM.setTopicImportance(sbn.getPackageName(), sbn.getUid(), topic,
@Override
public void setAppImportance(String pkg, int uid, int importance) {
enforceSystemOrSystemUI("Caller not system or systemui");
+ setNotificationsEnabledForPackageImpl(pkg, uid,
+ importance != NotificationListenerService.Ranking.IMPORTANCE_NONE);
mRankingHelper.setAppImportance(pkg, uid, importance);
savePolicyFile();
}
+ @Override
+ public boolean doesAppUseTopics(String pkg, int uid) {
+ enforceSystemOrSystemUI("Caller not system or systemui");
+ return mRankingHelper.doesAppUseTopics(pkg, uid);
+ }
+
/**
* System-only API for getting a list of current (i.e. not cleared) notifications.
*
int getTopicImportance(String packageName, int uid, Notification.Topic topic);
void setAppImportance(String packageName, int uid, int importance);
+
+ boolean doesAppUseTopics(String packageName, int uid);
}
} else {
r = getOrCreateRecord(name, uid);
}
+ r.importance = safeInt(parser, ATT_IMPORTANCE, DEFAULT_IMPORTANCE);
// Migrate package level settings to the default topic.
// Might be overwritten by parseTopics.
updateConfig();
}
+ @Override
+ public boolean doesAppUseTopics(String pkgName, int uid) {
+ final Record r = getOrCreateRecord(pkgName, uid);
+ int numTopics = r.topics.size();
+ if (numTopics == 0
+ || (numTopics == 1 && r.topics.containsKey(Notification.TOPIC_DEFAULT))) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
private Topic getOrCreateTopic(Record r, Notification.Topic topic) {
if (topic == null) {
topic = createDefaultTopic();