From 1e4ef187220295d434ad97ed54a190db67f52f77 Mon Sep 17 00:00:00 2001 From: erfanian Date: Mon, 11 Jun 2018 11:05:51 -0700 Subject: A few more interface updates. Bug: 73773964 Test: none PiperOrigin-RevId: 200079809 Change-Id: I1c505c4f63a17b34ed9fb062c9f9e1b1e16c3832 --- .../incallui/NotificationBroadcastReceiver.java | 18 +++++++++ java/com/android/incallui/StatusBarNotifier.java | 43 ++++++++++++++++++++++ java/com/android/incallui/res/values/colors.xml | 19 ++++++++++ .../android/incallui/speakeasy/Annotations.java | 4 ++ .../incallui/speakeasy/SpeakEasyComponent.java | 3 ++ .../incallui/speakeasy/StubSpeakEasyModule.java | 6 +++ 6 files changed, 93 insertions(+) create mode 100644 java/com/android/incallui/res/values/colors.xml (limited to 'java/com') diff --git a/java/com/android/incallui/NotificationBroadcastReceiver.java b/java/com/android/incallui/NotificationBroadcastReceiver.java index 602eb5c5a..241d8ed48 100644 --- a/java/com/android/incallui/NotificationBroadcastReceiver.java +++ b/java/com/android/incallui/NotificationBroadcastReceiver.java @@ -63,6 +63,8 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver { public static final String ACTION_TURN_ON_SPEAKER = "com.android.incallui.ACTION_TURN_ON_SPEAKER"; public static final String ACTION_TURN_OFF_SPEAKER = "com.android.incallui.ACTION_TURN_OFF_SPEAKER"; + public static final String ACTION_ANSWER_SPEAKEASY_CALL = + "com.android.incallui.ACTION_ANSWER_SPEAKEASY_CALL"; @RequiresApi(VERSION_CODES.N_MR1) public static final String ACTION_PULL_EXTERNAL_CALL = @@ -81,6 +83,9 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver { answerIncomingCall(VideoProfile.STATE_BIDIRECTIONAL, context); } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) { answerIncomingCall(VideoProfile.STATE_AUDIO_ONLY, context); + } else if (action.equals(ACTION_ANSWER_SPEAKEASY_CALL)) { + markIncomingCallAsSpeakeasyCall(); + answerIncomingCall(VideoProfile.STATE_AUDIO_ONLY, context); } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) { Logger.get(context) .logImpression(DialerImpression.Type.REJECT_INCOMING_CALL_FROM_NOTIFICATION); @@ -146,6 +151,19 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver { } } + private void markIncomingCallAsSpeakeasyCall() { + CallList callList = InCallPresenter.getInstance().getCallList(); + if (callList == null) { + LogUtil.e( + "NotificationBroadcastReceiver.markIncomingCallAsSpeakeasyCall", "call list is empty"); + } else { + DialerCall call = callList.getIncomingCall(); + if (call != null) { + call.setIsSpeakEasyCall(true); + } + } + } + private void answerIncomingCall(int videoState, @NonNull Context context) { CallList callList = InCallPresenter.getInstance().getCallList(); if (callList == null) { diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 6519e00ac..4026be712 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -19,6 +19,7 @@ package com.android.incallui; import static android.telecom.Call.Details.PROPERTY_HIGH_DEF_AUDIO; import static com.android.contacts.common.compat.CallCompat.Details.PROPERTY_ENTERPRISE_CALL; import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST; +import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_SPEAKEASY_CALL; import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VIDEO_INCOMING_CALL; import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VOICE_INCOMING_CALL; import static com.android.incallui.NotificationBroadcastReceiver.ACTION_DECLINE_INCOMING_CALL; @@ -57,6 +58,7 @@ import android.telecom.VideoProfile; import android.text.BidiFormatter; import android.text.Spannable; import android.text.SpannableString; +import android.text.Spanned; import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; @@ -90,7 +92,9 @@ import com.android.incallui.call.state.DialerCallState; import com.android.incallui.ringtone.DialerRingtoneManager; import com.android.incallui.ringtone.InCallTonePlayer; import com.android.incallui.ringtone.ToneGeneratorFactory; +import com.android.incallui.speakeasy.SpeakEasyComponent; import com.android.incallui.videotech.utils.SessionModificationState; +import com.google.common.base.Optional; import java.util.Objects; /** This class adds Notifications to the status bar for the in-call experience. */ @@ -451,6 +455,7 @@ public class StatusBarNotifier addVideoCallAction(builder); } else { addAnswerAction(builder); + addSpeakeasyAnswerAction(builder); } } } @@ -869,6 +874,44 @@ public class StatusBarNotifier .build()); } + private void addSpeakeasyAnswerAction(Notification.Builder builder) { + if (!ConfigProviderComponent.get(context) + .getConfigProvider() + .getBoolean("enable_speakeasy_notification_button", false)) { + return; + } + + if (!SpeakEasyComponent.get(context).speakEasyCallManager().isAvailable(context)) { + return; + } + + Optional buttonText = SpeakEasyComponent.get(context).speakEasyTextResource(); + if (!buttonText.isPresent()) { + return; + } + + LogUtil.d("StatusBarNotifier.addSpeakeasyAnswerAction", "showing button"); + PendingIntent answerVoicePendingIntent = + createNotificationPendingIntent(context, ACTION_ANSWER_SPEAKEASY_CALL); + + Spannable spannable = new SpannableString(context.getText(buttonText.get())); + // TODO(erfanian): Migrate these color values to somewhere more permanent in subsequent + // implementation. + spannable.setSpan( + new ForegroundColorSpan( + context.getColor(R.color.DO_NOT_USE_OR_I_WILL_BREAK_YOU_text_span_tertiary_button)), + 0, + spannable.length(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + builder.addAction( + new Notification.Action.Builder( + Icon.createWithResource(context, R.drawable.quantum_ic_call_white_24), + spannable, + answerVoicePendingIntent) + .build()); + } + private void addDismissAction(Notification.Builder builder) { LogUtil.d( "StatusBarNotifier.addDismissAction", diff --git a/java/com/android/incallui/res/values/colors.xml b/java/com/android/incallui/res/values/colors.xml new file mode 100644 index 000000000..d53a86b82 --- /dev/null +++ b/java/com/android/incallui/res/values/colors.xml @@ -0,0 +1,19 @@ + + + + #1A73E8 + \ No newline at end of file diff --git a/java/com/android/incallui/speakeasy/Annotations.java b/java/com/android/incallui/speakeasy/Annotations.java index 4128532c3..6d7fb4a1c 100644 --- a/java/com/android/incallui/speakeasy/Annotations.java +++ b/java/com/android/incallui/speakeasy/Annotations.java @@ -32,4 +32,8 @@ public final class Annotations { /** A Speakeasy chip */ @Qualifier public @interface SpeakEasyChipResourceId {} + + /** A Speakeasy text resource */ + @Qualifier + public @interface SpeakEasyTextResourceId {} } diff --git a/java/com/android/incallui/speakeasy/SpeakEasyComponent.java b/java/com/android/incallui/speakeasy/SpeakEasyComponent.java index 19e25edbe..d3145949e 100644 --- a/java/com/android/incallui/speakeasy/SpeakEasyComponent.java +++ b/java/com/android/incallui/speakeasy/SpeakEasyComponent.java @@ -22,6 +22,7 @@ import com.android.dialer.inject.HasRootComponent; import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsFragment; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject; +import com.android.incallui.speakeasy.Annotations.SpeakEasyTextResourceId; import com.google.common.base.Optional; import dagger.Subcomponent; @@ -38,6 +39,8 @@ public abstract class SpeakEasyComponent { public abstract @SpeakEasyChipResourceId Optional speakEasyChip(); + public abstract @SpeakEasyTextResourceId Optional speakEasyTextResource(); + public static SpeakEasyComponent get(Context context) { return ((SpeakEasyComponent.HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) diff --git a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java index 87d407d32..9bb7783bf 100644 --- a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java +++ b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java @@ -22,6 +22,7 @@ import com.android.dialer.inject.InstallIn; import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsFragment; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject; +import com.android.incallui.speakeasy.Annotations.SpeakEasyTextResourceId; import com.google.common.base.Optional; import dagger.Binds; import dagger.Module; @@ -50,4 +51,9 @@ public abstract class StubSpeakEasyModule { static @SpeakEasyChipResourceId Optional provideSpeakEasyChip() { return Optional.absent(); } + + @Provides + static @SpeakEasyTextResourceId Optional provideSpeakEasyTextResource() { + return Optional.absent(); + } } -- cgit v1.2.3