summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java22
-rw-r--r--src/com/android/dialer/DialtactsActivity.java9
-rw-r--r--src/com/android/dialer/calllog/IntentProvider.java16
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java9
-rw-r--r--src/com/android/dialer/interactions/PhoneNumberInteraction.java3
-rw-r--r--src/com/android/dialer/util/IntentUtil.java136
6 files changed, 72 insertions, 123 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 32eccc45d..984537756 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -16,32 +16,22 @@
package com.android.dialer;
-import android.app.Activity;
-import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
-import android.os.PowerManager;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.VoicemailContract.Voicemails;
-import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
-import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
-import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
-import android.util.Log;
-import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.QuickContactBadge;
import android.widget.TextView;
@@ -49,7 +39,6 @@ import android.widget.Toast;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
-import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.CallUtil;
import com.android.contacts.common.util.UriUtils;
@@ -57,17 +46,12 @@ import com.android.dialer.calllog.CallDetailHistoryAdapter;
import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener;
import com.android.dialer.calllog.CallLogAsyncTaskUtil;
import com.android.dialer.calllog.CallTypeHelper;
-import com.android.dialer.calllog.ContactInfo;
import com.android.dialer.calllog.ContactInfoHelper;
import com.android.dialer.calllog.PhoneAccountUtils;
-import com.android.dialer.calllog.PhoneNumberDisplayUtil;
-import com.android.dialer.util.DialerUtils;
-import com.android.dialer.util.IntentUtil;
+import com.android.dialer.util.IntentUtil.CallIntentBuilder;
import com.android.dialer.util.PhoneNumberUtil;
import com.android.dialer.util.TelecomUtil;
-import java.util.List;
-
/**
* Displays the details of a specific call log entry.
* <p>
@@ -252,11 +236,11 @@ public class CallDetailActivity extends AppCompatActivity
mDefaultCountryIso = GeoUtil.getCurrentCountryIso(this);
mContactPhotoManager = ContactPhotoManager.getInstance(this);
- mCallButton = (View) findViewById(R.id.call_back_button);
+ mCallButton = findViewById(R.id.call_back_button);
mCallButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- mContext.startActivity(IntentUtil.getCallIntent(mNumber));
+ mContext.startActivity(new CallIntentBuilder(mNumber).build());
}
});
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 786acab1a..a77fd8e7e 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -83,6 +83,7 @@ import com.android.dialer.list.SmartDialSearchFragment;
import com.android.dialer.list.SpeedDialFragment;
import com.android.dialer.settings.DialerSettingsActivity;
import com.android.dialer.util.IntentUtil;
+import com.android.dialer.util.IntentUtil.CallIntentBuilder;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.widget.ActionBarController;
import com.android.dialer.widget.SearchEditTextLayout;
@@ -1262,9 +1263,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
// an error message.
phoneNumber = "";
}
- Intent intent = isVideoCall ?
- IntentUtil.getVideoCallIntent(phoneNumber, (String) null) :
- IntentUtil.getCallIntent(phoneNumber, (String) null);
+
+ final Intent intent = new CallIntentBuilder(phoneNumber)
+ .setIsVideoCall(isVideoCall)
+ .build();
+
DialerUtils.startActivityWithErrorToast(this, intent);
mClearSearchOnPause = true;
}
diff --git a/src/com/android/dialer/calllog/IntentProvider.java b/src/com/android/dialer/calllog/IntentProvider.java
index a11d00bc2..79743b0b7 100644
--- a/src/com/android/dialer/calllog/IntentProvider.java
+++ b/src/com/android/dialer/calllog/IntentProvider.java
@@ -21,16 +21,15 @@ import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
-import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
import android.telecom.PhoneAccountHandle;
+import com.android.contacts.common.CallUtil;
import com.android.contacts.common.model.Contact;
import com.android.contacts.common.model.ContactLoader;
import com.android.dialer.CallDetailActivity;
-import com.android.dialer.DialtactsActivity;
-import com.android.dialer.PhoneCallDetails;
import com.android.dialer.util.IntentUtil;
+import com.android.dialer.util.IntentUtil.CallIntentBuilder;
import com.android.dialer.util.TelecomUtil;
import java.util.ArrayList;
@@ -55,7 +54,9 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return IntentUtil.getCallIntent(number, accountHandle);
+ return new CallIntentBuilder(number)
+ .setPhoneAccountHandle(accountHandle)
+ .build();
}
};
}
@@ -69,7 +70,10 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return IntentUtil.getVideoCallIntent(number, accountHandle);
+ return new CallIntentBuilder(number)
+ .setPhoneAccountHandle(accountHandle)
+ .setIsVideoCall(true)
+ .build();
}
};
}
@@ -78,7 +82,7 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return IntentUtil.getVoicemailIntent();
+ return new CallIntentBuilder(CallUtil.getVoicemailUri()).build();
}
};
}
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index c35bdea3c..eb17fefe3 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -81,7 +81,7 @@ import com.android.dialer.R;
import com.android.dialer.SpecialCharSequenceMgr;
import com.android.dialer.calllog.PhoneAccountUtils;
import com.android.dialer.util.DialerUtils;
-import com.android.dialer.util.IntentUtil;
+import com.android.dialer.util.IntentUtil.CallIntentBuilder;
import com.android.phone.common.CallLogAsync;
import com.android.phone.common.animation.AnimUtils;
import com.android.phone.common.dialpad.DialpadKeyButton;
@@ -1044,7 +1044,8 @@ public class DialpadFragment extends Fragment
}
public void callVoicemail() {
- DialerUtils.startActivityWithErrorToast(getActivity(), IntentUtil.getVoicemailIntent());
+ DialerUtils.startActivityWithErrorToast(getActivity(),
+ new CallIntentBuilder(CallUtil.getVoicemailUri()).build());
hideAndClearDialpad(false);
}
@@ -1140,7 +1141,7 @@ public class DialpadFragment extends Fragment
// Clear the digits just in case.
clearDialpad();
} else {
- final Intent intent = IntentUtil.getCallIntent(number, (String) null);
+ final Intent intent = new CallIntentBuilder(number).build();
DialerUtils.startActivityWithErrorToast(getActivity(), intent);
hideAndClearDialpad(false);
}
@@ -1665,7 +1666,7 @@ public class DialpadFragment extends Fragment
}
private Intent newFlashIntent() {
- final Intent intent = IntentUtil.getCallIntent(EMPTY_NUMBER);
+ final Intent intent = new CallIntentBuilder(EMPTY_NUMBER).build();
intent.putExtra(EXTRA_SEND_EMPTY_FLASH, true);
return intent;
}
diff --git a/src/com/android/dialer/interactions/PhoneNumberInteraction.java b/src/com/android/dialer/interactions/PhoneNumberInteraction.java
index 6e218c025..68eb80874 100644
--- a/src/com/android/dialer/interactions/PhoneNumberInteraction.java
+++ b/src/com/android/dialer/interactions/PhoneNumberInteraction.java
@@ -53,6 +53,7 @@ import com.android.dialer.R;
import com.android.dialer.TransactionSafeActivity;
import com.android.dialer.contact.ContactUpdateService;
import com.android.dialer.util.IntentUtil;
+import com.android.dialer.util.IntentUtil.CallIntentBuilder;
import com.android.dialer.util.DialerUtils;
import com.google.common.annotations.VisibleForTesting;
@@ -322,7 +323,7 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener<Cursor> {
Intent.ACTION_SENDTO, Uri.fromParts("sms", phoneNumber, null));
break;
default:
- intent = IntentUtil.getCallIntent(phoneNumber, callOrigin);
+ intent = new CallIntentBuilder(phoneNumber).build();
break;
}
DialerUtils.startActivityWithErrorToast(context, intent);
diff --git a/src/com/android/dialer/util/IntentUtil.java b/src/com/android/dialer/util/IntentUtil.java
index 2ce3bd1f8..5a4a80bb1 100644
--- a/src/com/android/dialer/util/IntentUtil.java
+++ b/src/com/android/dialer/util/IntentUtil.java
@@ -18,14 +18,13 @@ package com.android.dialer.util;
import android.content.Intent;
import android.net.Uri;
+import android.os.Bundle;
import android.provider.ContactsContract;
-import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import com.android.contacts.common.CallUtil;
-import com.android.phone.common.PhoneConstants;
/**
* Utilities for creation of intents in Dialer, such as {@link Intent#ACTION_CALL}.
@@ -36,108 +35,65 @@ public class IntentUtil {
private static final String SMS_URI_PREFIX = "sms:";
private static final int NO_PHONE_TYPE = -1;
- /**
- * Return an Intent for making a phone call. Scheme (e.g. tel, sip) will be determined
- * automatically.
- */
- public static Intent getCallIntent(String number) {
- return getCallIntent(number, null, null);
- }
-
- /**
- * Return an Intent for making a phone call. A given Uri will be used as is (without any
- * sanity check).
- */
- public static Intent getCallIntent(Uri uri) {
- return getCallIntent(uri, null, null);
- }
+ public static final String EXTRA_CALL_INITIATION_TYPE
+ = "com.android.dialer.EXTRA_CALL_INITIATION_TYPE";
- /**
- * A variant of {@link #getCallIntent(String)} but also accept a call origin.
- * For more information about call origin, see comments in Phone package (PhoneApp).
- */
- public static Intent getCallIntent(String number, String callOrigin) {
- return getCallIntent(CallUtil.getCallUri(number), callOrigin, null);
- }
+ public static class CallIntentBuilder {
+ private Uri mUri;
+ private int mCallInitiationType;
+ private PhoneAccountHandle mPhoneAccountHandle;
+ private boolean mIsVideoCall = false;
- /**
- * A variant of {@link #getCallIntent(String)} but also include {@code Account}.
- */
- public static Intent getCallIntent(String number, PhoneAccountHandle accountHandle) {
- return getCallIntent(number, null, accountHandle);
- }
-
- /**
- * A variant of {@link #getCallIntent(android.net.Uri)} but also include {@code Account}.
- */
- public static Intent getCallIntent(Uri uri, PhoneAccountHandle accountHandle) {
- return getCallIntent(uri, null, accountHandle);
- }
-
- /**
- * A variant of {@link #getCallIntent(String, String)} but also include {@code Account}.
- */
- public static Intent getCallIntent(
- String number, String callOrigin, PhoneAccountHandle accountHandle) {
- return getCallIntent(CallUtil.getCallUri(number), callOrigin, accountHandle);
- }
+ public CallIntentBuilder(Uri uri) {
+ mUri = uri;
+ }
- /**
- * A variant of {@link #getCallIntent(android.net.Uri)} but also accept a call
- * origin and {@code Account}.
- * For more information about call origin, see comments in Phone package (PhoneApp).
- */
- public static Intent getCallIntent(
- Uri uri, String callOrigin, PhoneAccountHandle accountHandle) {
- return getCallIntent(uri, callOrigin, accountHandle,
- VideoProfile.STATE_AUDIO_ONLY);
- }
+ public CallIntentBuilder(String number) {
+ this(CallUtil.getCallUri(number));
+ }
- /**
- * A variant of {@link #getCallIntent(String, String)} for starting a video call.
- */
- public static Intent getVideoCallIntent(String number, String callOrigin) {
- return getCallIntent(CallUtil.getCallUri(number), callOrigin, null,
- VideoProfile.STATE_BIDIRECTIONAL);
- }
+ public CallIntentBuilder setCallInitiationType(int initiationType) {
+ mCallInitiationType = initiationType;
+ return this;
+ }
- /**
- * A variant of {@link #getCallIntent(String, String, android.telecom.PhoneAccountHandle)} for
- * starting a video call.
- */
- public static Intent getVideoCallIntent(
- String number, String callOrigin, PhoneAccountHandle accountHandle) {
- return getCallIntent(CallUtil.getCallUri(number), callOrigin, accountHandle,
- VideoProfile.STATE_BIDIRECTIONAL);
- }
+ public CallIntentBuilder setPhoneAccountHandle(PhoneAccountHandle accountHandle) {
+ mPhoneAccountHandle = accountHandle;
+ return this;
+ }
- /**
- * A variant of {@link #getCallIntent(String, String, android.telecom.PhoneAccountHandle)} for
- * starting a video call.
- */
- public static Intent getVideoCallIntent(String number, PhoneAccountHandle accountHandle) {
- return getVideoCallIntent(number, null, accountHandle);
- }
+ public CallIntentBuilder setIsVideoCall(boolean isVideoCall) {
+ mIsVideoCall = isVideoCall;
+ return this;
+ }
- /**
- * A variant of {@link #getCallIntent(android.net.Uri)} for calling Voicemail.
- */
- public static Intent getVoicemailIntent() {
- return getCallIntent(Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null));
+ public Intent build() {
+ return getCallIntent(
+ mUri,
+ mPhoneAccountHandle,
+ mIsVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY,
+ mCallInitiationType);
+ }
}
/**
- * A variant of {@link #getCallIntent(android.net.Uri)} but also accept a call
- * origin and {@code Account} and {@code VideoCallProfile} state.
- * For more information about call origin, see comments in Phone package (PhoneApp).
+ * Create a call intent that can be used to place a call.
+ *
+ * @param uri Address to place the call to.
+ * @param accountHandle {@link PhoneAccountHandle} to place the call with.
+ * @param videoState Initial video state of the call.
+ * @param callIntiationType The UI affordance the call was initiated by.
+ * @return Call intent with provided extras and data.
*/
public static Intent getCallIntent(
- Uri uri, String callOrigin, PhoneAccountHandle accountHandle, int videoState) {
+ Uri uri, PhoneAccountHandle accountHandle, int videoState, int callIntiationType) {
final Intent intent = new Intent(CALL_ACTION, uri);
intent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState);
- if (callOrigin != null) {
- intent.putExtra(PhoneConstants.EXTRA_CALL_ORIGIN, callOrigin);
- }
+
+ final Bundle b = new Bundle();
+ b.putInt(EXTRA_CALL_INITIATION_TYPE, callIntiationType);
+ intent.putExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, b);
+
if (accountHandle != null) {
intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
}