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

Commit b52b31fe authored by Yingyan Hua's avatar Yingyan Hua Committed by Android (Google) Code Review
Browse files

Merge "[MagicAction] Created didcated xml layout for magic action and...

Merge "[MagicAction] Created didcated xml layout for magic action and refactored shouldShowSmartReplyView to switch the layout based on whether it is magic action." into main
parents 76f60eea 941fa431
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
<Button xmlns:android="http://schemas.android.com/apk/res/android"
        style="@android:style/Widget.Material.Button"
        android:stateListAnimator="@null"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:minWidth="0dp"
        android:minHeight="@dimen/smart_reply_button_min_height"
        android:paddingVertical="@dimen/smart_reply_button_padding_vertical"
        android:background="@drawable/smart_reply_button_background"
        android:gravity="center"
        android:fontFamily="roboto-medium"
        android:textSize="@dimen/smart_reply_button_font_size"
        android:lineSpacingExtra="@dimen/smart_reply_button_line_spacing_extra"
        android:textColor="@color/smart_reply_button_text"
        android:paddingStart="@dimen/smart_reply_button_action_padding_left"
        android:paddingEnd="@dimen/smart_reply_button_padding_horizontal"
        android:drawablePadding="@dimen/smart_action_button_icon_padding"
        android:textStyle="normal"
        android:ellipsize="none"/>
+21 −15
Original line number Diff line number Diff line
@@ -396,17 +396,22 @@ constructor(
        action: Notification.Action,
        delayOnClickListener: Boolean,
        packageContext: Context,
    ): Button =
        (LayoutInflater.from(parent.context).inflate(R.layout.smart_action_button, parent, false)
    ): Button {
        val isMagicAction = Flags.notificationMagicActionsTreatment() &&
                smartActions.fromAssistant &&
                action.extras.getBoolean(Notification.Action.EXTRA_IS_MAGIC, false)
        val layoutRes = if (isMagicAction) {
            R.layout.magic_action_button
        } else {
            R.layout.smart_action_button
        }
        return (LayoutInflater.from(parent.context).inflate(layoutRes, parent, false)
                as Button)
            .apply {
                text = action.title

                if (Flags.notificationMagicActionsTreatment()) {
                    if (
                        smartActions.fromAssistant &&
                            action.extras.getBoolean(Notification.Action.EXTRA_IS_MAGIC, false)
                    ) {
                // TODO: Move the MagicActionBackgroundDrawable to MagicActionButton once
                //  MagicActionButton is created.
                if (isMagicAction) {
                    background = MagicActionBackgroundDrawable(parent.context)
                    val textColor =
                        parent.context.getColor(
@@ -414,7 +419,6 @@ constructor(
                        )
                    setTextColor(textColor)
                }
                }

                // We received the Icon from the application - so use the Context of the application
                // to
@@ -442,6 +446,8 @@ constructor(
                (layoutParams as SmartReplyView.LayoutParams).mButtonType = SmartButtonType.ACTION
            }

    }

    private fun onSmartActionClick(
        entry: NotificationEntry,
        smartActions: SmartActions,