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

Commit 7f9a369d authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes from topic "phishing_templates" into sc-dev

* changes:
  Refactor the SmartReply classes
  Filter out RemoteInput actions when Phishing action is present
parents d196216e 20cfeede
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -3624,7 +3624,7 @@ public class Notification implements Parcelable
        private Bundle mUserExtras = new Bundle();
        private Style mStyle;
        @UnsupportedAppUsage
        private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
        private ArrayList<Action> mActions = new ArrayList<>(MAX_ACTION_BUTTONS);
        private ArrayList<Person> mPersonList = new ArrayList<>();
        private ContrastColorUtil mColorUtil;
        private boolean mIsLegacy;
@@ -4878,6 +4878,16 @@ public class Notification implements Parcelable
            return this;
        }

        private void bindPhishingAlertIcon(RemoteViews contentView, StandardTemplateParams p) {
            // TODO(b/180334837): Get buy-in on this color, or make sure to give this the
            //  accent color, while still accommodating the colorized state.
            contentView.setDrawableTint(
                    R.id.phishing_alert,
                    false /* targetBackground */,
                    getPrimaryTextColor(p),
                    PorterDuff.Mode.SRC_ATOP);
        }

        private Drawable getProfileBadgeDrawable() {
            if (mContext.getUserId() == UserHandle.USER_SYSTEM) {
                // This user can never be a badged profile,
@@ -5279,6 +5289,7 @@ public class Notification implements Parcelable
                hasTextToLeft |= bindHeaderAppName(contentView, p, true /* force */);
            }
            bindHeaderChronometerAndTime(contentView, p, hasTextToLeft);
            bindPhishingAlertIcon(contentView, p);
            bindProfileBadge(contentView, p);
            bindAlertedIcon(contentView, p);
            bindExpandButton(contentView, p);
@@ -5474,15 +5485,18 @@ public class Notification implements Parcelable
                    RemoteViews.MARGIN_BOTTOM, bottomMarginDimen);
        }

        private static List<Notification.Action> filterOutContextualActions(
                List<Notification.Action> actions) {
            List<Notification.Action> nonContextualActions = new ArrayList<>();
            for (Notification.Action action : actions) {
        /**
         * Returns the actions that are not contextual.
         */
        private @NonNull List<Notification.Action> getNonContextualActions() {
            if (mActions == null) return Collections.emptyList();
            List<Notification.Action> contextualActions = new ArrayList<>();
            for (Notification.Action action : mActions) {
                if (!action.isContextual()) {
                    nonContextualActions.add(action);
                    contextualActions.add(action);
                }
            }
            return nonContextualActions;
            return contextualActions;
        }

        private RemoteViews applyStandardTemplateWithActions(int layoutId,
@@ -5493,9 +5507,9 @@ public class Notification implements Parcelable

            boolean validRemoteInput = false;

            // In the UI contextual actions appear separately from the standard actions, so we
            // In the UI, contextual actions appear separately from the standard actions, so we
            // filter them out here.
            List<Notification.Action> nonContextualActions = filterOutContextualActions(mActions);
            List<Notification.Action> nonContextualActions = getNonContextualActions();

            int N = nonContextualActions.size();
            boolean emphazisedMode = mN.fullScreenIntent != null;
@@ -9241,7 +9255,7 @@ public class Notification implements Parcelable
                lastAction = answerAction;
            }
            // For consistency with the standard actions bar, contextual actions are ignored.
            for (Action action : Builder.filterOutContextualActions(mBuilder.mActions)) {
            for (Action action : mBuilder.getNonContextualActions()) {
                if (actions.size() >= MAX_ACTION_BUTTONS - 1) {
                    break;
                }
+15 −2
Original line number Diff line number Diff line
@@ -101,8 +101,8 @@

    <ImageView
        android:id="@+id/verification_icon"
        android:layout_width="@dimen/notification_badge_size"
        android:layout_height="@dimen/notification_badge_size"
        android:layout_width="@dimen/notification_verification_icon_size"
        android:layout_height="@dimen/notification_verification_icon_size"
        android:layout_gravity="center"
        android:layout_marginStart="4dp"
        android:contentDescription="@string/notification_alerted_content_description"
@@ -139,6 +139,19 @@
        android:visibility="gone"
        />

    <ImageView
        android:id="@+id/phishing_alert"
        android:layout_width="@dimen/notification_phishing_alert_size"
        android:layout_height="@dimen/notification_phishing_alert_size"
        android:layout_marginStart="4dp"
        android:paddingTop="2dp"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_dialog_alert_material"
        android:visibility="gone"
        android:contentDescription="@string/notification_phishing_alert_content_description"
        />


    <ImageView
        android:id="@+id/profile_badge"
        android:layout_width="@dimen/notification_badge_size"
+12 −0
Original line number Diff line number Diff line
@@ -122,6 +122,18 @@
        android:contentDescription="@string/notification_feedback_indicator"
        />

    <ImageView
        android:id="@+id/phishing_alert"
        android:layout_width="@dimen/notification_phishing_alert_size"
        android:layout_height="@dimen/notification_phishing_alert_size"
        android:layout_marginStart="4dp"
        android:baseline="10dp"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_dialog_alert_material"
        android:visibility="gone"
        android:contentDescription="@string/notification_phishing_alert_content_description"
        />

    <ImageView
        android:id="@+id/profile_badge"
        android:layout_width="@dimen/notification_badge_size"
+7 −1
Original line number Diff line number Diff line
@@ -496,14 +496,20 @@
    <!-- The padding on top of inbox style elements -->
    <dimen name="notification_inbox_item_top_padding">5dp</dimen>

    <!-- Size of the verification icon for call notifications -->
    <dimen name="notification_verification_icon_size">@dimen/notification_badge_size</dimen>

    <!-- Size of the feedback indicator for notifications -->
    <dimen name="notification_feedback_size">20dp</dimen>

    <!-- Size of the phishing alert for notifications -->
    <dimen name="notification_phishing_alert_size">@dimen/notification_badge_size</dimen>

    <!-- Size of the profile badge for notifications -->
    <dimen name="notification_badge_size">12dp</dimen>

    <!-- Size of the alerted icon for notifications -->
    <dimen name="notification_alerted_size">12dp</dimen>
    <dimen name="notification_alerted_size">@dimen/notification_badge_size</dimen>

    <!-- Keyguard dimensions -->
    <!-- TEMP -->
+3 −0
Original line number Diff line number Diff line
@@ -5002,6 +5002,9 @@
    <string name="stk_cc_ss_to_ussd">SS request changed to USSD request</string>
    <string name="stk_cc_ss_to_ss">Changed to new SS request</string>

    <!-- Content description of the phishing alert icon in the notification. [CHAR_LIMIT=NONE] -->
    <string name="notification_phishing_alert_content_description">Phishing alert</string>

    <!-- Content description of the work profile icon in the notification. -->
    <string name="notification_work_profile_content_description">Work profile</string>

Loading