Merge "Show topic settings inline if user has configured topics." into nyc-dev
am: 597c6d8c5d
* commit '597c6d8c5de14340550313607d0925b8ee40fea9':
Show topic settings inline if user has configured topics.
This commit is contained in:
@@ -56,7 +56,7 @@ interface INotificationManager
|
||||
void setImportance(String pkg, int uid, in Notification.Topic topic, int importance);
|
||||
int getImportance(String pkg, int uid, in Notification.Topic topic);
|
||||
int getTopicImportance(String pkg, String topicId);
|
||||
boolean doesAppUseTopics(String pkg, int uid);
|
||||
boolean doesUserUseTopics(String pkg, int uid);
|
||||
boolean hasBannedTopics(String pkg, int uid);
|
||||
|
||||
// TODO: Remove this when callers have been migrated to the equivalent
|
||||
|
||||
@@ -113,15 +113,15 @@ public class NotificationGuts extends LinearLayout {
|
||||
? new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(
|
||||
com.android.internal.R.string.default_notification_topic_label))
|
||||
: sbn.getNotification().getTopic();
|
||||
boolean doesAppUseTopics = false;
|
||||
boolean doesUserUseTopics = false;
|
||||
try {
|
||||
doesAppUseTopics =
|
||||
mINotificationManager.doesAppUseTopics(sbn.getPackageName(), sbn.getUid());
|
||||
doesUserUseTopics =
|
||||
mINotificationManager.doesUserUseTopics(sbn.getPackageName(), sbn.getUid());
|
||||
} catch (RemoteException e) {}
|
||||
final boolean appUsesTopics = doesAppUseTopics;
|
||||
final boolean userUsesTopics = doesUserUseTopics;
|
||||
|
||||
mApplyToTopic = (RadioButton) row.findViewById(R.id.apply_to_topic);
|
||||
if (appUsesTopics) {
|
||||
if (userUsesTopics) {
|
||||
mApplyToTopic.setChecked(true);
|
||||
}
|
||||
final View applyToApp = row.findViewById(R.id.apply_to_app);
|
||||
@@ -156,7 +156,7 @@ public class NotificationGuts extends LinearLayout {
|
||||
updateTitleAndSummary(progress);
|
||||
if (fromUser) {
|
||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_MODIFY_IMPORTANCE_SLIDER);
|
||||
if (appUsesTopics) {
|
||||
if (userUsesTopics) {
|
||||
mApplyToTopic.setVisibility(View.VISIBLE);
|
||||
mApplyToTopic.setText(
|
||||
mContext.getString(R.string.apply_to_topic, mTopic.getLabel()));
|
||||
|
||||
@@ -1350,9 +1350,9 @@ public class NotificationManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesAppUseTopics(String pkg, int uid) {
|
||||
public boolean doesUserUseTopics(String pkg, int uid) {
|
||||
enforceSystemOrSystemUI("Caller not system or systemui");
|
||||
return mRankingHelper.doesAppUseTopics(pkg, uid);
|
||||
return mRankingHelper.doesUserUseTopics(pkg, uid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface RankingConfig {
|
||||
|
||||
int getImportance(String packageName, int uid, Notification.Topic topic);
|
||||
|
||||
boolean doesAppUseTopics(String packageName, int uid);
|
||||
boolean doesUserUseTopics(String packageName, int uid);
|
||||
|
||||
boolean hasBannedTopics(String packageName, int uid);
|
||||
|
||||
|
||||
@@ -521,15 +521,14 @@ public class RankingHelper implements RankingConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesAppUseTopics(String pkgName, int uid) {
|
||||
public boolean doesUserUseTopics(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;
|
||||
for (Topic topic : r.topics.values()) {
|
||||
if (topic.importance != Ranking.IMPORTANCE_UNSPECIFIED
|
||||
&& r.importance != topic.importance)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Topic getOrCreateTopic(Record r, Notification.Topic topic) {
|
||||
|
||||
Reference in New Issue
Block a user