summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/historyitemactions
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-04-18 15:57:00 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-18 16:49:41 -0700
commit136a888ef24d7168ca9cf5a2a512429f5f9408f6 (patch)
treed729e3560e0cdd3d33436b56ba8f79b146dae656 /java/com/android/dialer/historyitemactions
parent6ceb0dd5d694740672a4f983b0e639afcb1cb55f (diff)
Reduce the number of parameters when building bottom sheet options for telecom/Duo calls.
Bug: 70988691 Test: ModulesTest, DuoCallModuleTest PiperOrigin-RevId: 193431749 Change-Id: I2af9979504b99175513cb753a030244f735828be
Diffstat (limited to 'java/com/android/dialer/historyitemactions')
-rw-r--r--java/com/android/dialer/historyitemactions/DuoCallModule.java28
-rw-r--r--java/com/android/dialer/historyitemactions/IntentModule.java46
2 files changed, 15 insertions, 59 deletions
diff --git a/java/com/android/dialer/historyitemactions/DuoCallModule.java b/java/com/android/dialer/historyitemactions/DuoCallModule.java
index b0d6a11fc..e6f31e293 100644
--- a/java/com/android/dialer/historyitemactions/DuoCallModule.java
+++ b/java/com/android/dialer/historyitemactions/DuoCallModule.java
@@ -19,30 +19,22 @@ package com.android.dialer.historyitemactions;
import android.Manifest.permission;
import android.content.Context;
import android.support.annotation.RequiresPermission;
-import com.android.dialer.callintent.CallInitiationType;
-import com.android.dialer.callintent.CallIntentBuilder;
-import com.android.dialer.duo.Duo;
-import com.android.dialer.duo.DuoComponent;
import com.android.dialer.duo.PlaceDuoCallNotifier;
-import com.android.dialer.precall.PreCall;
/** {@link HistoryItemActionModule} for making a Duo call. */
public class DuoCallModule implements HistoryItemActionModule {
private final Context context;
private final String phoneNumber;
- private final CallInitiationType.Type callInitiationType;
/**
* Creates a module for making a Duo call.
*
* @param phoneNumber The number to start a Duo call. It can be of any format.
*/
- public DuoCallModule(
- Context context, String phoneNumber, CallInitiationType.Type callInitiationType) {
+ public DuoCallModule(Context context, String phoneNumber) {
this.context = context;
this.phoneNumber = phoneNumber;
- this.callInitiationType = callInitiationType;
}
@Override
@@ -58,23 +50,7 @@ public class DuoCallModule implements HistoryItemActionModule {
@Override
@RequiresPermission(permission.READ_PHONE_STATE)
public boolean onClick() {
- if (canPlaceDuoCall(context, phoneNumber)) {
- PlaceDuoCallNotifier.notify(context, phoneNumber);
- } else {
- // If a Duo call can't be placed, fall back to an IMS video call.
- PreCall.start(
- context, new CallIntentBuilder(phoneNumber, callInitiationType).setIsVideoCall(true));
- }
-
+ PlaceDuoCallNotifier.notify(context, phoneNumber);
return true; // Close the bottom sheet.
}
-
- private boolean canPlaceDuoCall(Context context, String phoneNumber) {
- Duo duo = DuoComponent.get(context).getDuo();
-
- return duo.isInstalled(context)
- && duo.isEnabled(context)
- && duo.isActivated(context)
- && duo.isReachable(context, phoneNumber);
- }
}
diff --git a/java/com/android/dialer/historyitemactions/IntentModule.java b/java/com/android/dialer/historyitemactions/IntentModule.java
index a5236c57a..f73d4c951 100644
--- a/java/com/android/dialer/historyitemactions/IntentModule.java
+++ b/java/com/android/dialer/historyitemactions/IntentModule.java
@@ -19,10 +19,7 @@ package com.android.dialer.historyitemactions;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.DrawableRes;
-import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
-import android.telecom.PhoneAccountHandle;
-import com.android.dialer.callintent.CallInitiationType.Type;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.precall.PreCall;
import com.android.dialer.util.DialerUtils;
@@ -61,36 +58,19 @@ public class IntentModule implements HistoryItemActionModule {
return true;
}
- public static IntentModule newCallModule(
- Context context,
- String number,
- @Nullable PhoneAccountHandle phoneAccountHandle,
- Type initiationType) {
- // TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
- return new IntentModule(
- context,
- PreCall.getIntent(
- context,
- new CallIntentBuilder(number, initiationType)
- .setPhoneAccountHandle(phoneAccountHandle)),
- R.string.voice_call,
- R.drawable.quantum_ic_call_white_24);
- }
+ /** Creates a module for starting an outgoing call with a {@link CallIntentBuilder}. */
+ public static IntentModule newCallModule(Context context, CallIntentBuilder callIntentBuilder) {
+ @StringRes int text;
+ @DrawableRes int image;
+
+ if (callIntentBuilder.isVideoCall()) {
+ text = R.string.video_call;
+ image = R.drawable.quantum_ic_videocam_vd_white_24;
+ } else {
+ text = R.string.voice_call;
+ image = R.drawable.quantum_ic_call_white_24;
+ }
- public static IntentModule newCarrierVideoCallModule(
- Context context,
- String number,
- @Nullable PhoneAccountHandle phoneAccountHandle,
- Type initiationType) {
- // TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
- return new IntentModule(
- context,
- PreCall.getIntent(
- context,
- new CallIntentBuilder(number, initiationType)
- .setPhoneAccountHandle(phoneAccountHandle)
- .setIsVideoCall(true)),
- R.string.video_call,
- R.drawable.quantum_ic_videocam_vd_white_24);
+ return new IntentModule(context, PreCall.getIntent(context, callIntentBuilder), text, image);
}
}