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

Commit 9403a362 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adds an icon to noisy notifications."

parents 48910eb4 a3226490
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40366,6 +40366,7 @@ package android.service.notification {
  public static class NotificationListenerService.Ranking {
    ctor public NotificationListenerService.Ranking();
    method public boolean audiblyAlerted();
    method public boolean canShowBadge();
    method public android.app.NotificationChannel getChannel();
    method public int getImportance();
+1 −0
Original line number Diff line number Diff line
@@ -4457,6 +4457,7 @@ public class Notification implements Parcelable
            contentView.setViewVisibility(R.id.time, View.GONE);
            contentView.setImageViewIcon(R.id.profile_badge, null);
            contentView.setViewVisibility(R.id.profile_badge, View.GONE);
            contentView.setViewVisibility(R.id.alerted_icon, View.GONE);
            mN.mUsesStandardHeader = false;
        }

+31 −4
Original line number Diff line number Diff line
@@ -1461,6 +1461,7 @@ public abstract class NotificationListenerService extends Service {
        private boolean mShowBadge;
        private @UserSentiment int mUserSentiment = USER_SENTIMENT_NEUTRAL;
        private boolean mHidden;
        private boolean mAudiblyAlerted;
        private ArrayList<Notification.Action> mSmartActions;
        private ArrayList<CharSequence> mSmartReplies;

@@ -1626,6 +1627,15 @@ public abstract class NotificationListenerService extends Service {
            return mHidden;
        }

        /**
         * Returns whether this notification alerted the user via sound or vibration.
         *
         * @return true if the notification alerted the user, false otherwise.
         */
        public boolean audiblyAlerted() {
            return mAudiblyAlerted;
        }

        /**
         * @hide
         */
@@ -1635,8 +1645,8 @@ public abstract class NotificationListenerService extends Service {
                CharSequence explanation, String overrideGroupKey,
                NotificationChannel channel, ArrayList<String> overridePeople,
                ArrayList<SnoozeCriterion> snoozeCriteria, boolean showBadge,
                int userSentiment, boolean hidden, ArrayList<Notification.Action> smartActions,
                ArrayList<CharSequence> smartReplies) {
                int userSentiment, boolean hidden, boolean audiblyAlerted,
                ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies) {
            mKey = key;
            mRank = rank;
            mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW;
@@ -1652,6 +1662,7 @@ public abstract class NotificationListenerService extends Service {
            mShowBadge = showBadge;
            mUserSentiment = userSentiment;
            mHidden = hidden;
            mAudiblyAlerted = audiblyAlerted;
            mSmartActions = smartActions;
            mSmartReplies = smartReplies;
        }
@@ -1703,6 +1714,7 @@ public abstract class NotificationListenerService extends Service {
        private ArrayMap<String, Boolean> mShowBadge;
        private ArrayMap<String, Integer> mUserSentiment;
        private ArrayMap<String, Boolean> mHidden;
        private ArrayMap<String, Boolean> mAudiblyAlerted;
        private ArrayMap<String, ArrayList<Notification.Action>> mSmartActions;
        private ArrayMap<String, ArrayList<CharSequence>> mSmartReplies;

@@ -1733,8 +1745,8 @@ public abstract class NotificationListenerService extends Service {
                    getVisibilityOverride(key), getSuppressedVisualEffects(key),
                    getImportance(key), getImportanceExplanation(key), getOverrideGroupKey(key),
                    getChannel(key), getOverridePeople(key), getSnoozeCriteria(key),
                    getShowBadge(key), getUserSentiment(key), getHidden(key), getSmartActions(key),
                    getSmartReplies(key));
                    getShowBadge(key), getUserSentiment(key), getHidden(key),
                    getAudiblyAlerted(key), getSmartActions(key), getSmartReplies(key));
            return rank >= 0;
        }

@@ -1872,6 +1884,16 @@ public abstract class NotificationListenerService extends Service {
            return hidden == null ? false : hidden.booleanValue();
        }

        private boolean getAudiblyAlerted(String key) {
            synchronized (this) {
                if (mAudiblyAlerted == null) {
                    buildAudiblyAlertedLocked();
                }
            }
            Boolean audiblyAlerted = mAudiblyAlerted.get(key);
            return audiblyAlerted == null ? false : audiblyAlerted.booleanValue();
        }

        private ArrayList<Notification.Action> getSmartActions(String key) {
            synchronized (this) {
                if (mSmartActions == null) {
@@ -2006,6 +2028,11 @@ public abstract class NotificationListenerService extends Service {
            mHidden = buildBooleanMapFromBundle(mRankingUpdate.getHidden());
        }

        // Locked by 'this'
        private void buildAudiblyAlertedLocked() {
            mAudiblyAlerted = buildBooleanMapFromBundle(mRankingUpdate.getAudiblyAlerted());
        }

        // Locked by 'this'
        private void buildSmartActions() {
            Bundle smartActions = mRankingUpdate.getSmartActions();
+9 −1
Original line number Diff line number Diff line
@@ -39,13 +39,14 @@ public class NotificationRankingUpdate implements Parcelable {
    private final Bundle mHidden;
    private final Bundle mSmartActions;
    private final Bundle mSmartReplies;
    private final Bundle mAudiblyAlerted;

    public NotificationRankingUpdate(String[] keys, String[] interceptedKeys,
            Bundle visibilityOverrides, Bundle suppressedVisualEffects,
            int[] importance, Bundle explanation, Bundle overrideGroupKeys,
            Bundle channels, Bundle overridePeople, Bundle snoozeCriteria,
            Bundle showBadge, Bundle userSentiment, Bundle hidden, Bundle smartActions,
            Bundle smartReplies) {
            Bundle smartReplies, Bundle audiblyAlerted) {
        mKeys = keys;
        mInterceptedKeys = interceptedKeys;
        mVisibilityOverrides = visibilityOverrides;
@@ -61,6 +62,7 @@ public class NotificationRankingUpdate implements Parcelable {
        mHidden = hidden;
        mSmartActions = smartActions;
        mSmartReplies = smartReplies;
        mAudiblyAlerted = audiblyAlerted;
    }

    public NotificationRankingUpdate(Parcel in) {
@@ -80,6 +82,7 @@ public class NotificationRankingUpdate implements Parcelable {
        mHidden = in.readBundle();
        mSmartActions = in.readBundle();
        mSmartReplies = in.readBundle();
        mAudiblyAlerted = in.readBundle();
    }

    @Override
@@ -104,6 +107,7 @@ public class NotificationRankingUpdate implements Parcelable {
        out.writeBundle(mHidden);
        out.writeBundle(mSmartActions);
        out.writeBundle(mSmartReplies);
        out.writeBundle(mAudiblyAlerted);
    }

    public static final Parcelable.Creator<NotificationRankingUpdate> CREATOR
@@ -176,4 +180,8 @@ public class NotificationRankingUpdate implements Parcelable {
    public Bundle getSmartReplies() {
        return mSmartReplies;
    }

    public Bundle getAudiblyAlerted() {
        return mAudiblyAlerted;
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public class NotificationHeaderView extends ViewGroup {
    private View mCameraIcon;
    private View mMicIcon;
    private View mAppOps;
    private View mAudiblyAlertedIcon;
    private int mIconColor;
    private int mOriginalNotificationColor;
    private boolean mExpanded;
@@ -121,6 +122,7 @@ public class NotificationHeaderView extends ViewGroup {
        mMicIcon = findViewById(com.android.internal.R.id.mic);
        mOverlayIcon = findViewById(com.android.internal.R.id.overlay);
        mAppOps = findViewById(com.android.internal.R.id.app_ops);
        mAudiblyAlertedIcon = findViewById(com.android.internal.R.id.alerted_icon);
    }

    @Override
@@ -216,6 +218,11 @@ public class NotificationHeaderView extends ViewGroup {
                layoutRight = end - paddingEnd;
                end = layoutLeft = layoutRight - child.getMeasuredWidth();
            }
            if (child == mAudiblyAlertedIcon) {
                int paddingEnd = mContentEndMargin;
                layoutRight = end - paddingEnd;
                end = layoutLeft = layoutRight - child.getMeasuredWidth();
            }
            if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
                int ltrLeft = layoutLeft;
                layoutLeft = getWidth() - layoutRight;
@@ -337,6 +344,11 @@ public class NotificationHeaderView extends ViewGroup {
                ? View.VISIBLE : View.GONE);
    }

    /** Updates icon visibility based on the noisiness of the notification. */
    public void setAudiblyAlerted(boolean audiblyAlerted) {
        mAudiblyAlertedIcon.setVisibility(audiblyAlerted ? View.VISIBLE : View.GONE);
    }

    private void updateExpandButton() {
        int drawableId;
        int contentDescriptionId;
Loading