From 8cee4f02ea40370a1069aef684558137e82ce94a Mon Sep 17 00:00:00 2001 From: Julia Tuttle Date: Mon, 5 Feb 2024 18:26:51 -0500 Subject: CallStyle: add flag for new action layout Now that there's a bugfix flow for flags, we can use a real flag instead of a makeshift boolean! Bug: 268733030 Flag: ACONFIG com.android.systemui.new_call_style_action_layout DEVELOPMENT Test: manual: disable/enable flag, post callstyle notif, observe actions Change-Id: I6df281cc7d6850b9bc4cd156c699f970f3a661b5 --- core/java/android/app/Notification.java | 12 ++++-------- core/java/android/app/notification.aconfig | 10 ++++++++++ .../internal/widget/EmphasizedNotificationButton.java | 8 ++++---- .../internal/widget/NotificationActionListLayout.java | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 0a34d36f204e..efefda3def92 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -23,6 +23,7 @@ import static android.app.admin.DevicePolicyResources.Drawables.WORK_PROFILE_ICO import static android.app.admin.DevicePolicyResources.UNDEFINED; import static android.graphics.drawable.Icon.TYPE_URI; import static android.graphics.drawable.Icon.TYPE_URI_ADAPTIVE_BITMAP; +import static android.app.Flags.evenlyDividedCallStyleActionLayout; import static java.util.Objects.requireNonNull; @@ -5957,7 +5958,7 @@ public class Notification implements Parcelable // there is enough space to do so (and fall back to the left edge if not). big.setInt(R.id.actions, "setCollapsibleIndentDimen", R.dimen.call_notification_collapsible_indent); - if (CallStyle.USE_NEW_ACTION_LAYOUT) { + if (evenlyDividedCallStyleActionLayout()) { if (CallStyle.DEBUG_NEW_ACTION_LAYOUT) { Log.d(TAG, "setting evenly divided mode on action list"); } @@ -6439,7 +6440,7 @@ public class Notification implements Parcelable title = ContrastColorUtil.ensureColorSpanContrast(title, buttonFillColor); } final CharSequence label = ensureColorSpanContrast(title, p); - if (p.mCallStyleActions && CallStyle.USE_NEW_ACTION_LAYOUT) { + if (p.mCallStyleActions && evenlyDividedCallStyleActionLayout()) { if (CallStyle.DEBUG_NEW_ACTION_LAYOUT) { Log.d(TAG, "new action layout enabled, gluing instead of setting text"); } @@ -6463,7 +6464,7 @@ public class Notification implements Parcelable button.setColorStateList(R.id.action0, "setButtonBackground", ColorStateList.valueOf(buttonFillColor)); if (p.mCallStyleActions) { - if (CallStyle.USE_NEW_ACTION_LAYOUT) { + if (evenlyDividedCallStyleActionLayout()) { if (CallStyle.DEBUG_NEW_ACTION_LAYOUT) { Log.d(TAG, "new action layout enabled, gluing instead of setting icon"); } @@ -9597,11 +9598,6 @@ public class Notification implements Parcelable * */ public static class CallStyle extends Style { - /** - * @hide - */ - public static final boolean USE_NEW_ACTION_LAYOUT = false; - /** * @hide */ diff --git a/core/java/android/app/notification.aconfig b/core/java/android/app/notification.aconfig index c40b23ed3cd0..274d02a79270 100644 --- a/core/java/android/app/notification.aconfig +++ b/core/java/android/app/notification.aconfig @@ -56,4 +56,14 @@ flag { namespace: "systemui" description: "This flag enables the API to allow setting VibrationEffect for NotificationChannels" bug: "241732519" +} + +flag { + name: "evenly_divided_call_style_action_layout" + namespace: "systemui" + description: "Evenly divides horizontal space for action buttons in CallStyle notifications." + bug: "268733030" + metadata { + purpose: PURPOSE_BUGFIX + } } \ No newline at end of file diff --git a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java index 5cda3f2b2bc0..3e065bf9f450 100644 --- a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java +++ b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java @@ -16,8 +16,8 @@ package com.android.internal.widget; +import static android.app.Flags.evenlyDividedCallStyleActionLayout; import static android.app.Notification.CallStyle.DEBUG_NEW_ACTION_LAYOUT; -import static android.app.Notification.CallStyle.USE_NEW_ACTION_LAYOUT; import static android.text.style.DynamicDrawableSpan.ALIGN_CENTER; import android.annotation.NonNull; @@ -166,7 +166,7 @@ public class EmphasizedNotificationButton extends Button { } private void setIconToGlue(@Nullable Drawable icon) { - if (!USE_NEW_ACTION_LAYOUT) { + if (!evenlyDividedCallStyleActionLayout()) { Log.e(TAG, "glueIcon: new action layout disabled; doing nothing"); return; } @@ -207,7 +207,7 @@ public class EmphasizedNotificationButton extends Button { } private void setLabelToGlue(@Nullable CharSequence label) { - if (!USE_NEW_ACTION_LAYOUT) { + if (!evenlyDividedCallStyleActionLayout()) { Log.e(TAG, "glueLabel: new action layout disabled; doing nothing"); return; } @@ -255,7 +255,7 @@ public class EmphasizedNotificationButton extends Button { return; } - if (!USE_NEW_ACTION_LAYOUT) { + if (!evenlyDividedCallStyleActionLayout()) { Log.e(TAG, "glueIconAndLabelIfNeeded: new action layout disabled; doing nothing"); return; } diff --git a/core/java/com/android/internal/widget/NotificationActionListLayout.java b/core/java/com/android/internal/widget/NotificationActionListLayout.java index 69d254499ef4..301dc392c125 100644 --- a/core/java/com/android/internal/widget/NotificationActionListLayout.java +++ b/core/java/com/android/internal/widget/NotificationActionListLayout.java @@ -17,7 +17,7 @@ package com.android.internal.widget; import static android.app.Notification.CallStyle.DEBUG_NEW_ACTION_LAYOUT; -import static android.app.Notification.CallStyle.USE_NEW_ACTION_LAYOUT; +import static android.app.Flags.evenlyDividedCallStyleActionLayout; import android.annotation.DimenRes; import android.app.Notification; @@ -410,7 +410,7 @@ public class NotificationActionListLayout extends LinearLayout { */ @RemotableViewMethod public void setEvenlyDividedMode(boolean evenlyDividedMode) { - if (evenlyDividedMode && !USE_NEW_ACTION_LAYOUT) { + if (evenlyDividedMode && !evenlyDividedCallStyleActionLayout()) { Log.e(TAG, "setEvenlyDividedMode(true) called with new action layout disabled; " + "leaving evenly divided mode disabled"); return; -- cgit v1.2.3-59-g8ed1b