summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/com/android/incallui/NotificationBroadcastReceiver.java18
-rw-r--r--java/com/android/incallui/StatusBarNotifier.java43
-rw-r--r--java/com/android/incallui/res/values/colors.xml19
-rw-r--r--java/com/android/incallui/speakeasy/Annotations.java4
-rw-r--r--java/com/android/incallui/speakeasy/SpeakEasyComponent.java3
-rw-r--r--java/com/android/incallui/speakeasy/StubSpeakEasyModule.java6
6 files changed, 93 insertions, 0 deletions
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<Integer> 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<resources>
+ <color name="DO_NOT_USE_OR_I_WILL_BREAK_YOU_text_span_tertiary_button">#1A73E8</color>
+</resources> \ 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<Integer> speakEasyChip();
+ public abstract @SpeakEasyTextResourceId Optional<Integer> 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<Integer> provideSpeakEasyChip() {
return Optional.absent();
}
+
+ @Provides
+ static @SpeakEasyTextResourceId Optional<Integer> provideSpeakEasyTextResource() {
+ return Optional.absent();
+ }
}