summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yingyan Hua <yyhua@google.com> 2025-02-04 10:09:14 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-02-04 10:09:14 -0800
commitb52b31fe4e34be46c1000b067f16d251595c2752 (patch)
tree246144d3fa8259d1e9cee3d6d1d5ba730acf4513
parent76f60eea22f9f3a6ff2d9bfc0a199ce1daa8f6ea (diff)
parent941fa431c00a35d394b78c1ced4b81aae9da39d4 (diff)
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
-rw-r--r--packages/SystemUI/res/layout/magic_action_button.xml19
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt36
2 files changed, 40 insertions, 15 deletions
diff --git a/packages/SystemUI/res/layout/magic_action_button.xml b/packages/SystemUI/res/layout/magic_action_button.xml
new file mode 100644
index 000000000000..59392ef0fb33
--- /dev/null
+++ b/packages/SystemUI/res/layout/magic_action_button.xml
@@ -0,0 +1,19 @@
+<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"/>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt
index 520c5632370b..1887db948b5a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt
@@ -396,24 +396,28 @@ 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)
- ) {
- background = MagicActionBackgroundDrawable(parent.context)
- val textColor =
- parent.context.getColor(
- com.android.internal.R.color.materialColorOnPrimaryContainer
- )
- setTextColor(textColor)
- }
+ // TODO: Move the MagicActionBackgroundDrawable to MagicActionButton once
+ // MagicActionButton is created.
+ if (isMagicAction) {
+ background = MagicActionBackgroundDrawable(parent.context)
+ val textColor =
+ parent.context.getColor(
+ com.android.internal.R.color.materialColorOnPrimaryContainer
+ )
+ setTextColor(textColor)
}
// We received the Icon from the application - so use the Context of the application
@@ -442,6 +446,8 @@ constructor(
(layoutParams as SmartReplyView.LayoutParams).mButtonType = SmartButtonType.ACTION
}
+ }
+
private fun onSmartActionClick(
entry: NotificationEntry,
smartActions: SmartActions,