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

Commit 20cfeede authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Refactor the SmartReply classes

Test: atest SystemUITests
Bug: 161333455
Change-Id: I48cb109e45e9d76b7edbaa36a1afb7fe5a08320d
parent 46d087a8
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ import com.android.systemui.statusbar.notification.stack.SwipeableView;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.InflatedSmartReplies.SmartRepliesAndActions;
import com.android.systemui.statusbar.policy.InflatedSmartReplyState;
import com.android.systemui.wmshell.BubblesManager;

import java.io.FileDescriptor;
@@ -3196,8 +3196,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    /**
     * Returns the Smart Suggestions backing the smart suggestion buttons in the notification.
     */
    public SmartRepliesAndActions getExistingSmartRepliesAndActions() {
        return mPrivateLayout.getCurrentSmartRepliesAndActions();
    public InflatedSmartReplyState getExistingSmartReplyState() {
        return mPrivateLayout.getCurrentSmartReplyState();
    }

    @VisibleForTesting
+26 −28
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ import com.android.systemui.statusbar.notification.MediaNotificationProcessor;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.InflatedSmartReplies;
import com.android.systemui.statusbar.policy.InflatedSmartReplies.SmartRepliesAndActions;
import com.android.systemui.statusbar.policy.SmartRepliesAndActionsInflater;
import com.android.systemui.statusbar.policy.InflatedSmartReplyState;
import com.android.systemui.statusbar.policy.InflatedSmartReplyViewHolder;
import com.android.systemui.statusbar.policy.SmartReplyStateInflater;
import com.android.systemui.util.Assert;

import java.util.HashMap;
@@ -74,7 +74,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
    private final NotifRemoteViewCache mRemoteViewCache;
    private final ConversationNotificationProcessor mConversationProcessor;
    private final Executor mBgExecutor;
    private final SmartRepliesAndActionsInflater mSmartRepliesAndActionsInflater;
    private final SmartReplyStateInflater mSmartReplyStateInflater;

    @Inject
    NotificationContentInflater(
@@ -83,13 +83,13 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            ConversationNotificationProcessor conversationProcessor,
            MediaFeatureFlag mediaFeatureFlag,
            @Background Executor bgExecutor,
            SmartRepliesAndActionsInflater smartRepliesInflater) {
            SmartReplyStateInflater smartRepliesInflater) {
        mRemoteViewCache = remoteViewCache;
        mRemoteInputManager = remoteInputManager;
        mConversationProcessor = conversationProcessor;
        mIsMediaInQS = mediaFeatureFlag.getEnabled();
        mBgExecutor = bgExecutor;
        mSmartRepliesAndActionsInflater = smartRepliesInflater;
        mSmartReplyStateInflater = smartRepliesInflater;
    }

    @Override
@@ -133,7 +133,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                callback,
                mRemoteInputManager.getRemoteViewsOnClickHandler(),
                mIsMediaInQS,
                mSmartRepliesAndActionsInflater);
                mSmartReplyStateInflater);
        if (mInflateSynchronously) {
            task.onPostExecute(task.doInBackground());
        } else {
@@ -150,7 +150,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            @InflationFlag int reInflateFlags,
            Notification.Builder builder,
            Context packageContext,
            SmartRepliesAndActionsInflater smartRepliesInflater) {
            SmartReplyStateInflater smartRepliesInflater) {
        InflationProgress result = createRemoteViews(reInflateFlags,
                builder,
                bindParams.isLowPriority,
@@ -160,7 +160,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder

        result = inflateSmartReplyViews(result, reInflateFlags, entry,
                row.getContext(), packageContext,
                row.getExistingSmartRepliesAndActions(),
                row.getExistingSmartReplyState(),
                smartRepliesInflater);

        apply(
@@ -268,8 +268,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            NotificationEntry entry,
            Context context,
            Context packageContext,
            SmartRepliesAndActions previousSmartRepliesAndActions,
            SmartRepliesAndActionsInflater inflater) {
            InflatedSmartReplyState previousSmartReplyState,
            SmartReplyStateInflater inflater) {
        boolean inflateContracted = (reInflateFlags & FLAG_CONTENT_VIEW_CONTRACTED) != 0
                && result.newContentView != null;
        boolean inflateExpanded = (reInflateFlags & FLAG_CONTENT_VIEW_EXPANDED) != 0
@@ -277,17 +277,17 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        boolean inflateHeadsUp = (reInflateFlags & FLAG_CONTENT_VIEW_HEADS_UP) != 0
                && result.newHeadsUpView != null;
        if (inflateContracted || inflateExpanded || inflateHeadsUp) {
            result.inflatedSmartRepliesAndActions = inflater.inflateRepliesAndActions(entry);
            result.inflatedSmartReplyState = inflater.inflateSmartReplyState(entry);
        }
        if (inflateExpanded) {
            result.expandedInflatedSmartReplies = inflater.inflateSmartReplies(
                    context, packageContext, entry, previousSmartRepliesAndActions,
                    result.inflatedSmartRepliesAndActions);
            result.expandedInflatedSmartReplies = inflater.inflateSmartReplyViewHolder(
                    context, packageContext, entry, previousSmartReplyState,
                    result.inflatedSmartReplyState);
        }
        if (inflateHeadsUp) {
            result.headsUpInflatedSmartReplies = inflater.inflateSmartReplies(
                    context, packageContext, entry, previousSmartRepliesAndActions,
                    result.inflatedSmartRepliesAndActions);
            result.headsUpInflatedSmartReplies = inflater.inflateSmartReplyViewHolder(
                    context, packageContext, entry, previousSmartReplyState,
                    result.inflatedSmartReplyState);
        }
        return result;
    }
@@ -636,8 +636,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                setRepliesAndActions = true;
            }
            if (setRepliesAndActions) {
                privateLayout.setInflatedSmartRepliesAndActions(
                        result.inflatedSmartRepliesAndActions);
                privateLayout.setInflatedSmartReplyState(result.inflatedSmartReplyState);
            }

            if ((reInflateFlags & FLAG_CONTENT_VIEW_PUBLIC) != 0) {
@@ -728,7 +727,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        private CancellationSignal mCancellationSignal;
        private final ConversationNotificationProcessor mConversationProcessor;
        private final boolean mIsMediaInQS;
        private final SmartRepliesAndActionsInflater mSmartRepliesInflater;
        private final SmartReplyStateInflater mSmartRepliesInflater;

        private AsyncInflationTask(
                Executor bgExecutor,
@@ -744,7 +743,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                InflationCallback callback,
                RemoteViews.OnClickHandler remoteViewClickHandler,
                boolean isMediaFlagEnabled,
                SmartRepliesAndActionsInflater smartRepliesInflater) {
                SmartReplyStateInflater smartRepliesInflater) {
            mEntry = entry;
            mRow = row;
            mBgExecutor = bgExecutor;
@@ -795,15 +794,14 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                InflationProgress inflationProgress = createRemoteViews(mReInflateFlags,
                        recoveredBuilder, mIsLowPriority, mUsesIncreasedHeight,
                        mUsesIncreasedHeadsUpHeight, packageContext);
                SmartRepliesAndActions repliesAndActions =
                        mRow.getExistingSmartRepliesAndActions();
                InflatedSmartReplyState previousSmartReplyState = mRow.getExistingSmartReplyState();
                return inflateSmartReplyViews(
                        inflationProgress,
                        mReInflateFlags,
                        mEntry,
                        mContext,
                        packageContext,
                        repliesAndActions,
                        previousSmartReplyState,
                        mSmartRepliesInflater);
            } catch (Exception e) {
                mError = e;
@@ -898,9 +896,9 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        private CharSequence headsUpStatusBarText;
        private CharSequence headsUpStatusBarTextPublic;

        private SmartRepliesAndActions inflatedSmartRepliesAndActions;
        private InflatedSmartReplies expandedInflatedSmartReplies;
        private InflatedSmartReplies headsUpInflatedSmartReplies;
        private InflatedSmartReplyState inflatedSmartReplyState;
        private InflatedSmartReplyViewHolder expandedInflatedSmartReplies;
        private InflatedSmartReplyViewHolder headsUpInflatedSmartReplies;
    }

    @VisibleForTesting
+45 −50
Original line number Diff line number Diff line
@@ -58,11 +58,11 @@ import com.android.systemui.statusbar.notification.collection.render.GroupMember
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationCustomViewWrapper;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.policy.InflatedSmartReplies;
import com.android.systemui.statusbar.policy.InflatedSmartReplies.SmartRepliesAndActions;
import com.android.systemui.statusbar.policy.InflatedSmartReplyState;
import com.android.systemui.statusbar.policy.InflatedSmartReplyViewHolder;
import com.android.systemui.statusbar.policy.RemoteInputView;
import com.android.systemui.statusbar.policy.SmartRepliesAndActionsInflaterKt;
import com.android.systemui.statusbar.policy.SmartReplyConstants;
import com.android.systemui.statusbar.policy.SmartReplyStateInflaterKt;
import com.android.systemui.statusbar.policy.SmartReplyView;

import java.io.FileDescriptor;
@@ -108,9 +108,9 @@ public class NotificationContentView extends FrameLayout {
    private SmartReplyView mExpandedSmartReplyView;
    private SmartReplyView mHeadsUpSmartReplyView;
    private SmartReplyController mSmartReplyController;
    private InflatedSmartReplies mExpandedInflatedSmartReplies;
    private InflatedSmartReplies mHeadsUpInflatedSmartReplies;
    private SmartRepliesAndActions mCurrentSmartRepliesAndActions;
    private InflatedSmartReplyViewHolder mExpandedInflatedSmartReplies;
    private InflatedSmartReplyViewHolder mHeadsUpInflatedSmartReplies;
    private InflatedSmartReplyState mCurrentSmartReplyState;

    private NotificationViewWrapper mContractedWrapper;
    private NotificationViewWrapper mExpandedWrapper;
@@ -1191,7 +1191,7 @@ public class NotificationContentView extends FrameLayout {

        applyRemoteInput(entry, hasFreeformRemoteInput(entry));

        if (mCurrentSmartRepliesAndActions == null) {
        if (mCurrentSmartReplyState == null) {
            if (DEBUG) {
                Log.d(TAG, "InflatedSmartReplies are null, don't add smart replies.");
            }
@@ -1200,12 +1200,10 @@ public class NotificationContentView extends FrameLayout {
        if (DEBUG) {
            Log.d(TAG, String.format("Adding suggestions for %s, %d actions, and %d replies.",
                    entry.getSbn().getKey(),
                    mCurrentSmartRepliesAndActions.smartActions == null ? 0 :
                            mCurrentSmartRepliesAndActions.smartActions.actions.size(),
                    mCurrentSmartRepliesAndActions.smartReplies == null ? 0 :
                            mCurrentSmartRepliesAndActions.smartReplies.choices.size()));
                    mCurrentSmartReplyState.getSmartActionsList().size(),
                    mCurrentSmartReplyState.getSmartRepliesList().size()));
        }
        applySmartReplyView(mCurrentSmartRepliesAndActions, entry);
        applySmartReplyView(mCurrentSmartReplyState, entry);
    }

    private void applyRemoteInput(NotificationEntry entry, boolean hasFreeformRemoteInput) {
@@ -1409,29 +1407,27 @@ public class NotificationContentView extends FrameLayout {
    }

    private void applySmartReplyView(
            SmartRepliesAndActions smartRepliesAndActions,
            InflatedSmartReplyState state,
            NotificationEntry entry) {
        if (mContractedChild != null) {
            applyExternalSmartReplyState(mContractedChild, smartRepliesAndActions);
            applyExternalSmartReplyState(mContractedChild, state);
        }
        if (mExpandedChild != null) {
            applyExternalSmartReplyState(mExpandedChild, smartRepliesAndActions);
            mExpandedSmartReplyView = applySmartReplyView(mExpandedChild, smartRepliesAndActions,
            applyExternalSmartReplyState(mExpandedChild, state);
            mExpandedSmartReplyView = applySmartReplyView(mExpandedChild, state,
                    entry, mExpandedInflatedSmartReplies);
            if (mExpandedSmartReplyView != null) {
                if (smartRepliesAndActions.smartReplies != null
                        || smartRepliesAndActions.smartActions != null) {
                    int numSmartReplies = smartRepliesAndActions.smartReplies == null
                            ? 0 : smartRepliesAndActions.smartReplies.choices.size();
                    int numSmartActions = smartRepliesAndActions.smartActions == null
                            ? 0 : smartRepliesAndActions.smartActions.actions.size();
                    boolean fromAssistant = smartRepliesAndActions.smartReplies == null
                            ? smartRepliesAndActions.smartActions.fromAssistant
                            : smartRepliesAndActions.smartReplies.fromAssistant;
                    boolean editBeforeSending = smartRepliesAndActions.smartReplies != null
                SmartReplyView.SmartReplies smartReplies = state.getSmartReplies();
                SmartReplyView.SmartActions smartActions = state.getSmartActions();
                if (smartReplies != null || smartActions != null) {
                    int numSmartReplies = smartReplies == null ? 0 : smartReplies.choices.size();
                    int numSmartActions = smartActions == null ? 0 : smartActions.actions.size();
                    boolean fromAssistant = smartReplies == null
                            ? smartActions.fromAssistant
                            : smartReplies.fromAssistant;
                    boolean editBeforeSending = smartReplies != null
                            && mSmartReplyConstants.getEffectiveEditChoicesBeforeSending(
                                    smartRepliesAndActions.smartReplies.remoteInput
                                            .getEditChoicesBeforeSending());
                                    smartReplies.remoteInput.getEditChoicesBeforeSending());

                    mSmartReplyController.smartSuggestionsAdded(entry, numSmartReplies,
                            numSmartActions, fromAssistant, editBeforeSending);
@@ -1439,16 +1435,16 @@ public class NotificationContentView extends FrameLayout {
            }
        }
        if (mHeadsUpChild != null) {
            applyExternalSmartReplyState(mHeadsUpChild, smartRepliesAndActions);
            applyExternalSmartReplyState(mHeadsUpChild, state);
            if (mSmartReplyConstants.getShowInHeadsUp()) {
                mHeadsUpSmartReplyView = applySmartReplyView(mHeadsUpChild, smartRepliesAndActions,
                mHeadsUpSmartReplyView = applySmartReplyView(mHeadsUpChild, state,
                        entry, mHeadsUpInflatedSmartReplies);
            }
        }
    }

    private void applyExternalSmartReplyState(View view, SmartRepliesAndActions state) {
        boolean hasPhishingAlert = state != null && state.hasPhishingAction;
    private void applyExternalSmartReplyState(View view, InflatedSmartReplyState state) {
        boolean hasPhishingAlert = state != null && state.getHasPhishingAction();
        View phishingAlertIcon = view.findViewById(com.android.internal.R.id.phishing_alert);
        if (phishingAlertIcon != null) {
            if (DEBUG) {
@@ -1456,8 +1452,8 @@ public class NotificationContentView extends FrameLayout {
            }
            phishingAlertIcon.setVisibility(hasPhishingAlert ? View.VISIBLE : View.GONE);
        }
        List<Integer> suppressedActionIndices = state != null && state.suppressedActions != null
                ? state.suppressedActions.suppressedActionIndices
        List<Integer> suppressedActionIndices = state != null
                ? state.getSuppressedActionIndices()
                : Collections.emptyList();
        ViewGroup actionsList = view.findViewById(com.android.internal.R.id.actions);
        if (actionsList != null) {
@@ -1477,8 +1473,8 @@ public class NotificationContentView extends FrameLayout {

    @Nullable
    private SmartReplyView applySmartReplyView(View view,
            SmartRepliesAndActions smartRepliesAndActions,
            NotificationEntry entry, InflatedSmartReplies inflatedSmartReplyView) {
            InflatedSmartReplyState smartReplyState,
            NotificationEntry entry, InflatedSmartReplyViewHolder inflatedSmartReplyViewHolder) {
        View smartReplyContainerCandidate = view.findViewById(
                com.android.internal.R.id.smart_reply_container);
        if (!(smartReplyContainerCandidate instanceof LinearLayout)) {
@@ -1486,8 +1482,7 @@ public class NotificationContentView extends FrameLayout {
        }

        LinearLayout smartReplyContainer = (LinearLayout) smartReplyContainerCandidate;
        if (!SmartRepliesAndActionsInflaterKt
                .shouldShowSmartReplyView(entry, smartRepliesAndActions)) {
        if (!SmartReplyStateInflaterKt.shouldShowSmartReplyView(entry, smartReplyState)) {
            smartReplyContainer.setVisibility(View.GONE);
            return null;
        }
@@ -1500,15 +1495,15 @@ public class NotificationContentView extends FrameLayout {
            smartReplyContainer.removeAllViews();
        }
        if (smartReplyContainer.getChildCount() == 0
                && inflatedSmartReplyView != null
                && inflatedSmartReplyView.getSmartReplyView() != null) {
            smartReplyView = inflatedSmartReplyView.getSmartReplyView();
                && inflatedSmartReplyViewHolder != null
                && inflatedSmartReplyViewHolder.getSmartReplyView() != null) {
            smartReplyView = inflatedSmartReplyViewHolder.getSmartReplyView();
            smartReplyContainer.addView(smartReplyView);
        }
        if (smartReplyView != null) {
            smartReplyView.resetSmartSuggestions(smartReplyContainer);
            smartReplyView.addPreInflatedButtons(
                    inflatedSmartReplyView.getSmartSuggestionButtons());
                    inflatedSmartReplyViewHolder.getSmartSuggestionButtons());
            // Ensure the colors of the smart suggestion buttons are up-to-date.
            smartReplyView.setBackgroundTintColor(entry.getRow().getCurrentBackgroundTint());
            smartReplyContainer.setVisibility(View.VISIBLE);
@@ -1524,7 +1519,7 @@ public class NotificationContentView extends FrameLayout {
     * {@link SmartReplyView} related to the expanded notification state is cleared.
     */
    public void setExpandedInflatedSmartReplies(
            @Nullable InflatedSmartReplies inflatedSmartReplies) {
            @Nullable InflatedSmartReplyViewHolder inflatedSmartReplies) {
        mExpandedInflatedSmartReplies = inflatedSmartReplies;
        if (inflatedSmartReplies == null) {
            mExpandedSmartReplyView = null;
@@ -1539,7 +1534,7 @@ public class NotificationContentView extends FrameLayout {
     * {@link SmartReplyView} related to the heads-up notification state is cleared.
     */
    public void setHeadsUpInflatedSmartReplies(
            @Nullable InflatedSmartReplies inflatedSmartReplies) {
            @Nullable InflatedSmartReplyViewHolder inflatedSmartReplies) {
        mHeadsUpInflatedSmartReplies = inflatedSmartReplies;
        if (inflatedSmartReplies == null) {
            mHeadsUpSmartReplyView = null;
@@ -1550,18 +1545,18 @@ public class NotificationContentView extends FrameLayout {
     * Set pre-inflated replies and actions for the notification.
     * This can be relevant to any state of the notification, even contracted, because smart actions
     * may cause a phishing alert to be made visible.
     * @param inflatedSmartRepliesAndActions the pre-inflated list of replies and actions
     * @param smartReplyState the pre-inflated list of replies and actions
     */
    public void setInflatedSmartRepliesAndActions(
            @NonNull SmartRepliesAndActions inflatedSmartRepliesAndActions) {
        mCurrentSmartRepliesAndActions = inflatedSmartRepliesAndActions;
    public void setInflatedSmartReplyState(
            @NonNull InflatedSmartReplyState smartReplyState) {
        mCurrentSmartReplyState = smartReplyState;
    }

    /**
     * Returns the smart replies and actions currently shown in the notification.
     */
    @Nullable public SmartRepliesAndActions getCurrentSmartRepliesAndActions() {
        return mCurrentSmartRepliesAndActions;
    @Nullable public InflatedSmartReplyState getCurrentSmartReplyState() {
        return mCurrentSmartReplyState;
    }

    public void closeRemoteInput() {
+0 −95
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.policy;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Notification;
import android.widget.Button;

import java.util.Collections;
import java.util.List;

/**
 * Holder for inflated smart replies and actions. These objects should be inflated on a background
 * thread, to later be accessed and modified on the (performance critical) UI thread.
 */
public class InflatedSmartReplies {
    @Nullable private final SmartReplyView mSmartReplyView;
    @Nullable private final List<Button> mSmartSuggestionButtons;

    public InflatedSmartReplies(
            @Nullable SmartReplyView smartReplyView,
            @Nullable List<Button> smartSuggestionButtons) {
        mSmartReplyView = smartReplyView;
        mSmartSuggestionButtons = smartSuggestionButtons;
    }

    @Nullable public SmartReplyView getSmartReplyView() {
        return mSmartReplyView;
    }

    @Nullable public List<Button> getSmartSuggestionButtons() {
        return mSmartSuggestionButtons;
    }

    /**
     * A storage for smart replies and smart action.
     */
    public static class SmartRepliesAndActions {
        @Nullable public final SmartReplyView.SmartReplies smartReplies;
        @Nullable public final SmartReplyView.SmartActions smartActions;
        @Nullable public final SuppressedActions suppressedActions;
        public final boolean hasPhishingAction;

        SmartRepliesAndActions(
                @Nullable SmartReplyView.SmartReplies smartReplies,
                @Nullable SmartReplyView.SmartActions smartActions,
                @Nullable SuppressedActions suppressedActions,
                boolean hasPhishingAction) {
            this.smartReplies = smartReplies;
            this.smartActions = smartActions;
            this.suppressedActions = suppressedActions;
            this.hasPhishingAction = hasPhishingAction;
        }

        @NonNull public List<CharSequence> getSmartRepliesList() {
            return smartReplies == null ? Collections.emptyList() : smartReplies.choices;
        }

        @NonNull public List<Notification.Action> getSmartActionsList() {
            return smartActions == null ? Collections.emptyList() : smartActions.actions;
        }

        @NonNull public List<Integer> getSuppressedActionIndices() {
            return suppressedActions == null ? Collections.emptyList()
                    : suppressedActions.suppressedActionIndices;
        }

        /**
         * Data class for standard actions suppressed by the smart actions.
         */
        public static class SuppressedActions {
            @NonNull
            public final List<Integer> suppressedActionIndices;

            public SuppressedActions(@NonNull List<Integer> suppressedActionIndices) {
                this.suppressedActionIndices = suppressedActionIndices;
            }
        }
    }
}
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.systemui.statusbar.policy

import android.app.Notification
import com.android.systemui.statusbar.policy.SmartReplyView.SmartActions
import com.android.systemui.statusbar.policy.SmartReplyView.SmartReplies

/**
 * A storage for smart replies, smart actions, and related state
 */
class InflatedSmartReplyState internal constructor(
    val smartReplies: SmartReplies?,
    val smartActions: SmartActions?,
    val suppressedActions: SuppressedActions?,
    val hasPhishingAction: Boolean
) {
    val smartRepliesList: List<CharSequence>
        get() = smartReplies?.choices ?: emptyList()
    val smartActionsList: List<Notification.Action>
        get() = smartActions?.actions ?: emptyList()
    val suppressedActionIndices: List<Int>
        get() = suppressedActions?.suppressedActionIndices ?: emptyList()

    /**
     * Data class for standard actions suppressed by the smart actions.
     */
    class SuppressedActions(val suppressedActionIndices: List<Int>)
}
 No newline at end of file
Loading