From 04ae75a461c127325caf7d4c59abef24ea7462ac Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Wed, 24 Feb 2021 06:26:19 +0000 Subject: [PATCH] Revert "Add API to let apps color CallStyle notifications themse..." Revert "Add CTS tests for CallStyle, including setting color hints." Revert submission 13661867-call_style_colors Reason for revert: Possible culprit of b/181087733 Reverted Changes: I537191e7c:Add API to let apps color CallStyle notifications ... I8bd00b8c2:Add CTS tests for CallStyle, including setting col... Change-Id: Ia8699f6ef151000212606bea598a2abefa6b53a7 --- core/api/current.txt | 4 -- core/java/android/app/Notification.java | 88 +++++-------------------- core/res/res/values/config.xml | 3 - core/res/res/values/symbols.xml | 1 - 4 files changed, 15 insertions(+), 81 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 46e775424b6df..5dee655094232 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -5587,7 +5587,6 @@ package android.app { field public static final int DEFAULT_LIGHTS = 4; // 0x4 field public static final int DEFAULT_SOUND = 1; // 0x1 field public static final int DEFAULT_VIBRATE = 2; // 0x2 - field public static final String EXTRA_ANSWER_COLOR = "android.answerColor"; field public static final String EXTRA_ANSWER_INTENT = "android.answerIntent"; field public static final String EXTRA_AUDIO_CONTENTS_URI = "android.audioContents"; field public static final String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri"; @@ -5599,7 +5598,6 @@ package android.app { field public static final String EXTRA_COLORIZED = "android.colorized"; field public static final String EXTRA_COMPACT_ACTIONS = "android.compactActions"; field public static final String EXTRA_CONVERSATION_TITLE = "android.conversationTitle"; - field public static final String EXTRA_DECLINE_COLOR = "android.declineColor"; field public static final String EXTRA_DECLINE_INTENT = "android.declineIntent"; field public static final String EXTRA_HANG_UP_INTENT = "android.hangUpIntent"; field public static final String EXTRA_HISTORIC_MESSAGES = "android.messages.historic"; @@ -5887,8 +5885,6 @@ package android.app { method @NonNull public static android.app.Notification.CallStyle forIncomingCall(@NonNull android.app.Person, @NonNull android.app.PendingIntent, @NonNull android.app.PendingIntent); method @NonNull public static android.app.Notification.CallStyle forOngoingCall(@NonNull android.app.Person, @NonNull android.app.PendingIntent); method @NonNull public static android.app.Notification.CallStyle forScreeningCall(@NonNull android.app.Person, @NonNull android.app.PendingIntent, @NonNull android.app.PendingIntent); - method @NonNull public android.app.Notification.CallStyle setAnswerButtonColorHint(@ColorInt int); - method @NonNull public android.app.Notification.CallStyle setDeclineButtonColorHint(@ColorInt int); method @NonNull public android.app.Notification.CallStyle setVerificationIcon(@Nullable android.graphics.drawable.Icon); method @NonNull public android.app.Notification.CallStyle setVerificationText(@Nullable CharSequence); } diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 26f525c8ccecd..525b41549695a 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1370,18 +1370,6 @@ public class Notification implements Parcelable */ public static final String EXTRA_HANG_UP_INTENT = "android.hangUpIntent"; - /** - * {@link #extras} key: the color used as a hint for the Answer action button of a - * {@link android.app.Notification.CallStyle} notification. This extra is a {@link ColorInt}. - */ - public static final String EXTRA_ANSWER_COLOR = "android.answerColor"; - - /** - * {@link #extras} key: the color used as a hint for the Decline or Hang Up action button of a - * {@link android.app.Notification.CallStyle} notification. This extra is a {@link ColorInt}. - */ - public static final String EXTRA_DECLINE_COLOR = "android.declineColor"; - /** * {@link #extras} key: whether the notification should be colorized as * supplied to {@link Builder#setColorized(boolean)}. @@ -5456,11 +5444,6 @@ public class Notification implements Parcelable return p.allowColorization && mN.isColorized(); } - private boolean isCallActionColorCustomizable(StandardTemplateParams p) { - return isColorized(p) && mContext.getResources().getBoolean( - R.bool.config_callNotificationActionColorsRequireColorized); - } - private void bindSmallIcon(RemoteViews contentView, StandardTemplateParams p) { if (mN.mSmallIcon == null && mN.icon != 0) { mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon); @@ -9058,8 +9041,6 @@ public class Notification implements Parcelable private PendingIntent mAnswerIntent; private PendingIntent mDeclineIntent; private PendingIntent mHangUpIntent; - private Integer mAnswerButtonColor; - private Integer mDeclineButtonColor; private Icon mVerificationIcon; private CharSequence mVerificationText; @@ -9169,28 +9150,6 @@ public class Notification implements Parcelable return this; } - /** - * Optional color to be used as a hint for the Answer action button's color. - * The system may change this color to ensure sufficient contrast with the background. - * The system may choose to disregard this hint if the notification is not colorized. - */ - @NonNull - public CallStyle setAnswerButtonColorHint(@ColorInt int color) { - mAnswerButtonColor = color; - return this; - } - - /** - * Optional color to be used as a hint for the Decline or Hang Up action button's color. - * The system may change this color to ensure sufficient contrast with the background. - * The system may choose to disregard this hint if the notification is not colorized. - */ - @NonNull - public CallStyle setDeclineButtonColorHint(@ColorInt int color) { - mDeclineButtonColor = color; - return this; - } - /** * @hide */ @@ -9250,47 +9209,40 @@ public class Notification implements Parcelable } @NonNull - private Action makeNegativeAction(@NonNull StandardTemplateParams p) { + private Action makeNegativeAction() { if (mDeclineIntent == null) { - return makeAction(p, R.drawable.ic_call_decline, + return makeAction(R.drawable.ic_call_decline, R.string.call_notification_hang_up_action, - mDeclineButtonColor, R.color.call_notification_decline_color, - mHangUpIntent); + R.color.call_notification_decline_color, mHangUpIntent); } else { - return makeAction(p, R.drawable.ic_call_decline, + return makeAction(R.drawable.ic_call_decline, R.string.call_notification_decline_action, - mDeclineButtonColor, R.color.call_notification_decline_color, - mDeclineIntent); + R.color.call_notification_decline_color, mDeclineIntent); } } @Nullable - private Action makeAnswerAction(@NonNull StandardTemplateParams p) { - return mAnswerIntent == null ? null : makeAction(p, R.drawable.ic_call_answer, + private Action makeAnswerAction() { + return mAnswerIntent == null ? null : makeAction(R.drawable.ic_call_answer, R.string.call_notification_answer_action, - mAnswerButtonColor, R.color.call_notification_answer_color, - mAnswerIntent); + R.color.call_notification_answer_color, mAnswerIntent); } @NonNull - private Action makeAction(@NonNull StandardTemplateParams p, - @DrawableRes int icon, @StringRes int title, - @ColorInt Integer colorInt, @ColorRes int defaultColorRes, PendingIntent intent) { - if (colorInt == null || !mBuilder.isCallActionColorCustomizable(p)) { - colorInt = mBuilder.mContext.getColor(defaultColorRes); - } + private Action makeAction(@DrawableRes int icon, @StringRes int title, + @ColorRes int colorRes, PendingIntent intent) { Action action = new Action.Builder(Icon.createWithResource("", icon), new SpannableStringBuilder().append(mBuilder.mContext.getString(title), - new ForegroundColorSpan(colorInt), + new ForegroundColorSpan(mBuilder.mContext.getColor(colorRes)), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE), intent).build(); action.getExtras().putBoolean(KEY_ACTION_PRIORITY, true); return action; } - private ArrayList makeActionsList(@NonNull StandardTemplateParams p) { - final Action negativeAction = makeNegativeAction(p); - final Action answerAction = makeAnswerAction(p); + private ArrayList makeActionsList() { + final Action negativeAction = makeNegativeAction(); + final Action answerAction = makeAnswerAction(); ArrayList actions = new ArrayList<>(MAX_ACTION_BUTTONS); final Action lastAction; @@ -9379,7 +9331,7 @@ public class Notification implements Parcelable // Create the buttons for the generated actions list. int i = 0; - for (Action action : makeActionsList(p)) { + for (Action action : makeActionsList()) { final RemoteViews button = mBuilder.generateActionButton(action, emphasizedMode, p); if (i > 0) { // Clear start margin from non-first buttons to reduce the gap between buttons. @@ -9444,12 +9396,6 @@ public class Notification implements Parcelable if (mHangUpIntent != null) { extras.putParcelable(EXTRA_HANG_UP_INTENT, mHangUpIntent); } - if (mAnswerButtonColor != null) { - extras.putInt(EXTRA_ANSWER_COLOR, mAnswerButtonColor); - } - if (mDeclineButtonColor != null) { - extras.putInt(EXTRA_DECLINE_COLOR, mDeclineButtonColor); - } fixTitleAndTextExtras(extras); } @@ -9476,10 +9422,6 @@ public class Notification implements Parcelable mAnswerIntent = extras.getParcelable(EXTRA_ANSWER_INTENT); mDeclineIntent = extras.getParcelable(EXTRA_DECLINE_INTENT); mHangUpIntent = extras.getParcelable(EXTRA_HANG_UP_INTENT); - mAnswerButtonColor = extras.containsKey(EXTRA_ANSWER_COLOR) - ? extras.getInt(EXTRA_ANSWER_COLOR) : null; - mDeclineButtonColor = extras.containsKey(EXTRA_DECLINE_COLOR) - ? extras.getInt(EXTRA_DECLINE_COLOR) : null; } /** diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 06a94a18cf9ff..59285d7940451 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1173,9 +1173,6 @@ 2875 - - true - 100 diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 0ec3343747f48..70b358fd4d77e 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2286,7 +2286,6 @@ -