From f3c0dac014f019299742aab580702d47fffd1bfc Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Thu, 8 Apr 2021 20:39:58 -0400 Subject: [PATCH] Add CallStyle.setIsVideo(boolean) Fixes: 184869759 Test: cts Change-Id: Ie798a5d67db0e5fb689166340dc648bda1cc6571 --- core/api/current.txt | 2 ++ core/java/android/app/Notification.java | 25 +++++++++++++++-- .../res/res/drawable/ic_call_answer_video.xml | 27 +++++++++++++++++++ core/res/res/values/strings.xml | 2 ++ core/res/res/values/symbols.xml | 2 ++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 core/res/res/drawable/ic_call_answer_video.xml diff --git a/core/api/current.txt b/core/api/current.txt index c30e93016b4ed..3384c4876277f 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -5664,6 +5664,7 @@ package android.app { field public static final String EXTRA_AUDIO_CONTENTS_URI = "android.audioContents"; field public static final String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri"; field public static final String EXTRA_BIG_TEXT = "android.bigText"; + field public static final String EXTRA_CALL_IS_VIDEO = "android.callIsVideo"; field public static final String EXTRA_CALL_PERSON = "android.callPerson"; field public static final String EXTRA_CHANNEL_GROUP_ID = "android.intent.extra.CHANNEL_GROUP_ID"; field public static final String EXTRA_CHANNEL_ID = "android.intent.extra.CHANNEL_ID"; @@ -5970,6 +5971,7 @@ package android.app { 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 setIsVideo(boolean); 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 3de78f6e3cab8..22a25210aef76 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1387,6 +1387,12 @@ public class Notification implements Parcelable */ public static final String EXTRA_CALL_TYPE = "android.callType"; + /** + * {@link #extras} key: whether the {@link android.app.Notification.CallStyle} notification + * is for a call that will activate video when answered. This extra is a boolean. + */ + public static final String EXTRA_CALL_IS_VIDEO = "android.callIsVideo"; + /** * {@link #extras} key: the person to be displayed as calling for the * {@link android.app.Notification.CallStyle} notification. This extra is a {@link Person}. @@ -9167,6 +9173,7 @@ public class Notification implements Parcelable private PendingIntent mAnswerIntent; private PendingIntent mDeclineIntent; private PendingIntent mHangUpIntent; + private boolean mIsVideo; private Integer mAnswerButtonColor; private Integer mDeclineButtonColor; private Icon mVerificationIcon; @@ -9258,6 +9265,16 @@ public class Notification implements Parcelable mHangUpIntent = hangUpIntent; } + /** + * Sets whether the call is a video call, which may affect the icons or text used on the + * required action buttons. + */ + @NonNull + public CallStyle setIsVideo(boolean isVideo) { + mIsVideo = isVideo; + return this; + } + /** * Optional icon to be displayed with {@link #setVerificationText(CharSequence) text} * as a verification status of the caller. @@ -9386,8 +9403,10 @@ public class Notification implements Parcelable @Nullable private Action makeAnswerAction() { - return mAnswerIntent == null ? null : makeAction(R.drawable.ic_call_answer, - R.string.call_notification_answer_action, + return mAnswerIntent == null ? null : makeAction( + mIsVideo ? R.drawable.ic_call_answer_video : R.drawable.ic_call_answer, + mIsVideo ? R.string.call_notification_answer_video_action + : R.string.call_notification_answer_action, mAnswerButtonColor, R.color.call_notification_answer_color, mAnswerIntent); } @@ -9566,6 +9585,7 @@ public class Notification implements Parcelable public void addExtras(Bundle extras) { super.addExtras(extras); extras.putInt(EXTRA_CALL_TYPE, mCallType); + extras.putBoolean(EXTRA_CALL_IS_VIDEO, mIsVideo); extras.putParcelable(EXTRA_CALL_PERSON, mPerson); if (mVerificationIcon != null) { extras.putParcelable(EXTRA_VERIFICATION_ICON, mVerificationIcon); @@ -9608,6 +9628,7 @@ public class Notification implements Parcelable protected void restoreFromExtras(Bundle extras) { super.restoreFromExtras(extras); mCallType = extras.getInt(EXTRA_CALL_TYPE); + mIsVideo = extras.getBoolean(EXTRA_CALL_IS_VIDEO); mPerson = extras.getParcelable(EXTRA_CALL_PERSON); mVerificationIcon = extras.getParcelable(EXTRA_VERIFICATION_ICON); mVerificationText = extras.getCharSequence(EXTRA_VERIFICATION_TEXT); diff --git a/core/res/res/drawable/ic_call_answer_video.xml b/core/res/res/drawable/ic_call_answer_video.xml new file mode 100644 index 0000000000000..77c889234dd0a --- /dev/null +++ b/core/res/res/drawable/ic_call_answer_video.xml @@ -0,0 +1,27 @@ + + + + \ No newline at end of file diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 61e766e36de5a..7cf8001010cb1 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -5147,6 +5147,8 @@ Answer + + Video Decline diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index eb1fe1dd367d8..ae48ad5c5e704 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3111,6 +3111,7 @@ + @@ -3120,6 +3121,7 @@ +