Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fec58c26 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Show topic settings inline if user has configured topics.

Change-Id: Icf51faad61b3ae4261991691a1d679b190ea712a
parent d6c90a88
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+6 −6
Original line number Diff line number Diff line
@@ -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()));
+2 −2
Original line number Diff line number Diff line
@@ -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);
        }

        /**
+1 −1
Original line number Diff line number Diff line
@@ -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);

+6 −7
Original line number Diff line number Diff line
@@ -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 {
        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) {