summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-05-19 12:17:26 -0700
committerAndrew Lee <anwlee@google.com>2015-05-19 18:14:53 -0700
commit49efd91e50a11dc7bdef8382a0ceac01bc060f77 (patch)
tree1968b01c927c95d5359022af481c56fea2a22f78
parentd9602d00913bfc8e93444ac70645bc82cff7db69 (diff)
Performance improvements to call log scrolling.
- Remove call to CallUtil to check if video is enabled. It seems like it's fine to include the content description of what the call was, if it was a video call, even if there is not a video-enabled call account. - Factor out PhoneNumberDisplayHelper so it doesn't need to be an instance. This reduces some extra calls to getDisplayNameHelper. Probably a marginal difference, performance-wise, but it probably helps a smidgen and also simplifies the need for creating and passing or recalculating various instances of things. TODO: It'd be much better if PhoneCallDetails had a builder. It's terribly painful to fix all the tests when adding fields... Change-Id: I6da13dc8b6b047043aba871796a8ed13b112a227
-rw-r--r--src/com/android/dialer/CallDetailActivity.java65
-rw-r--r--src/com/android/dialer/PhoneCallDetails.java41
-rw-r--r--src/com/android/dialer/PhoneCallDetailsHelper.java16
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java27
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemHelper.java16
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemViewHolder.java5
-rw-r--r--src/com/android/dialer/calllog/DefaultVoicemailNotifier.java25
-rw-r--r--src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java (renamed from src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java)67
-rw-r--r--tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java134
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java259
10 files changed, 403 insertions, 252 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 2401c4767..18cf753ec 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -60,7 +60,7 @@ 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.PhoneNumberDisplayHelper;
+import com.android.dialer.calllog.PhoneNumberDisplayUtil;
import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
import com.android.dialer.util.AsyncTaskExecutor;
import com.android.dialer.util.AsyncTaskExecutors;
@@ -106,7 +106,6 @@ public class CallDetailActivity extends Activity {
public static final String VOICEMAIL_FRAGMENT_TAG = "voicemail_fragment";
private CallTypeHelper mCallTypeHelper;
- private PhoneNumberDisplayHelper mPhoneNumberHelper;
private QuickContactBadge mQuickContactBadge;
private TextView mCallerName;
private TextView mCallerNumber;
@@ -173,7 +172,6 @@ public class CallDetailActivity extends Activity {
mResources = getResources();
mCallTypeHelper = new CallTypeHelper(getResources());
- mPhoneNumberHelper = new PhoneNumberDisplayHelper(this, mResources);
mVoicemailUri = getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
@@ -344,12 +342,7 @@ public class CallDetailActivity extends Activity {
final CharSequence callLocationOrType = getNumberTypeOrLocation(firstDetails);
- final CharSequence displayNumber =
- mPhoneNumberHelper.getDisplayNumber(
- firstDetails.accountHandle,
- firstDetails.number,
- firstDetails.numberPresentation,
- firstDetails.formattedNumber);
+ final CharSequence displayNumber = firstDetails.displayNumber;
final String displayNumberStr = mBidiFormatter.unicodeWrap(
displayNumber.toString(), TextDirectionHeuristics.LTR);
@@ -396,11 +389,7 @@ public class CallDetailActivity extends Activity {
String nameForDefaultImage;
if (TextUtils.isEmpty(firstDetails.name)) {
- nameForDefaultImage = mPhoneNumberHelper.getDisplayNumber(
- firstDetails.accountHandle,
- firstDetails.number,
- firstDetails.numberPresentation,
- firstDetails.formattedNumber).toString();
+ nameForDefaultImage = firstDetails.displayNumber.toString();
} else {
nameForDefaultImage = firstDetails.name.toString();
}
@@ -459,47 +448,37 @@ public class CallDetailActivity extends Activity {
// Formatted phone number.
final CharSequence formattedNumber;
- // Read contact specifics.
- final CharSequence nameText;
- final int numberType;
- final CharSequence numberLabel;
- final Uri photoUri;
- final Uri lookupUri;
- int sourceType;
+
// If this is not a regular number, there is no point in looking it up in the contacts.
- ContactInfo info =
- PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation)
- && !new PhoneNumberUtilsWrapper(this).isVoicemailNumber(accountHandle, number)
- ? mContactInfoHelper.lookupNumber(number, countryIso)
- : null;
+ ContactInfo info = ContactInfo.EMPTY;
+ final boolean isVoicemail = new PhoneNumberUtilsWrapper(this)
+ .isVoicemailNumber(accountHandle, number);
+ if (PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation)
+ && !isVoicemail) {
+ mContactInfoHelper.lookupNumber(number, countryIso);
+ }
if (info == null) {
- formattedNumber = mPhoneNumberHelper.getDisplayNumber(accountHandle, number,
- numberPresentation, null);
- nameText = "";
- numberType = 0;
- numberLabel = "";
- photoUri = null;
- lookupUri = null;
- sourceType = 0;
+ formattedNumber = PhoneNumberDisplayUtil.getDisplayNumber(
+ this,
+ accountHandle,
+ number,
+ numberPresentation,
+ null /* formattedNumber */,
+ isVoicemail);
} else {
formattedNumber = info.formattedNumber;
- nameText = info.name;
- numberType = info.type;
- numberLabel = info.label;
- photoUri = info.photoUri;
- lookupUri = info.lookupUri;
- sourceType = info.sourceType;
}
final int features = callCursor.getInt(FEATURES);
Long dataUsage = null;
if (!callCursor.isNull(DATA_USAGE)) {
dataUsage = callCursor.getLong(DATA_USAGE);
}
- return new PhoneCallDetails(number, numberPresentation,
+ return new PhoneCallDetails(this, number, numberPresentation,
formattedNumber, countryIso, geocode,
new int[]{ callType }, date, duration,
- nameText, numberType, numberLabel, lookupUri, photoUri, sourceType,
- accountHandle, features, dataUsage, transcription);
+ info.name, info.type, info.label, info.lookupUri, info.photoUri,
+ info.sourceType, accountHandle, features, dataUsage, transcription,
+ isVoicemail);
} finally {
if (callCursor != null) {
callCursor.close();
diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java
index ec9657ed8..843e19352 100644
--- a/src/com/android/dialer/PhoneCallDetails.java
+++ b/src/com/android/dialer/PhoneCallDetails.java
@@ -17,15 +17,20 @@
package com.android.dialer;
import com.google.common.annotations.VisibleForTesting;
+import com.android.dialer.calllog.PhoneNumberDisplayUtil;
+import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telecom.PhoneAccountHandle;
+import android.text.TextUtils;
/**
* The details of a phone call to be shown in the UI.
+ *
+ * TODO: Create a builder, to make it easier to construct an instance.
*/
public class PhoneCallDetails {
/** The number of the other party involved in the call. */
@@ -85,35 +90,40 @@ public class PhoneCallDetails {
*/
public final String transcription;
+ public final String displayNumber;
+ public final boolean isVoicemail;
+
/**
* Create the details for a call, with empty defaults specified for extra fields that are
* not necessary for testing.
*/
@VisibleForTesting
- public PhoneCallDetails(CharSequence number, int numberPresentation,
+ public PhoneCallDetails(Context context, CharSequence number, int numberPresentation,
CharSequence formattedNumber, String countryIso, String geocode,
- int[] callTypes, long date, long duration) {
- this (number, numberPresentation, formattedNumber, countryIso, geocode,
- callTypes, date, duration, "", 0, "", null, null, 0, null, 0, null, null);
+ int[] callTypes, long date, long duration, boolean isVoicemail) {
+ this(context, number, numberPresentation, formattedNumber, countryIso, geocode,
+ callTypes, date, duration, "", 0, "", null, null, 0, null, 0, null, null,
+ isVoicemail);
}
/** Create the details for a call with a number not associated with a contact. */
- public PhoneCallDetails(CharSequence number, int numberPresentation,
+ public PhoneCallDetails(Context context, CharSequence number, int numberPresentation,
CharSequence formattedNumber, String countryIso, String geocode,
int[] callTypes, long date, long duration,
- PhoneAccountHandle accountHandle, int features, Long dataUsage, String transcription) {
- this(number, numberPresentation, formattedNumber, countryIso, geocode, callTypes, date,
- duration, "", 0, "", null, null, 0, accountHandle, features, dataUsage,
- transcription);
+ PhoneAccountHandle accountHandle, int features, Long dataUsage, String transcription,
+ boolean isVoicemail) {
+ this(context, number, numberPresentation, formattedNumber, countryIso, geocode,
+ callTypes, date, duration, "", 0, "", null, null, 0, accountHandle, features,
+ dataUsage, transcription, isVoicemail);
}
/** Create the details for a call with a number associated with a contact. */
- public PhoneCallDetails(CharSequence number, int numberPresentation,
+ public PhoneCallDetails(Context context, CharSequence number, int numberPresentation,
CharSequence formattedNumber, String countryIso, String geocode,
int[] callTypes, long date, long duration, CharSequence name,
int numberType, CharSequence numberLabel, Uri contactUri, Uri photoUri,
int sourceType, PhoneAccountHandle accountHandle, int features, Long dataUsage,
- String transcription) {
+ String transcription, boolean isVoicemail) {
this.number = number;
this.numberPresentation = numberPresentation;
this.formattedNumber = formattedNumber;
@@ -132,5 +142,14 @@ public class PhoneCallDetails {
this.features = features;
this.dataUsage = dataUsage;
this.transcription = transcription;
+ this.isVoicemail = isVoicemail;
+
+ this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
+ context,
+ this.accountHandle,
+ this.number,
+ this.numberPresentation,
+ this.formattedNumber,
+ this.isVoicemail).toString();
}
}
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index 7855a1d13..db37bb3f3 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -32,7 +32,6 @@ import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.dialer.calllog.ContactInfo;
import com.android.dialer.calllog.PhoneAccountUtils;
-import com.android.dialer.calllog.PhoneNumberDisplayHelper;
import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
import com.android.dialer.util.DialerUtils;
@@ -52,7 +51,6 @@ public class PhoneCallDetailsHelper {
/** The injected current time in milliseconds since the epoch. Used only by tests. */
private Long mCurrentTimeMillisForTest;
// Helper classes.
- private final PhoneNumberDisplayHelper mPhoneNumberHelper;
private final PhoneNumberUtilsWrapper mPhoneNumberUtilsWrapper;
/**
@@ -72,7 +70,6 @@ public class PhoneCallDetailsHelper {
mContext = context;
mResources = resources;
mPhoneNumberUtilsWrapper = phoneUtils;
- mPhoneNumberHelper = new PhoneNumberDisplayHelper(context, resources, phoneUtils);
}
/** Fills the call details views with content. */
@@ -125,9 +122,7 @@ public class PhoneCallDetailsHelper {
}
final CharSequence nameText;
- final CharSequence displayNumber =
- mPhoneNumberHelper.getDisplayNumber(details.accountHandle, details.number,
- details.numberPresentation, details.formattedNumber);
+ final CharSequence displayNumber = details.displayNumber;
if (TextUtils.isEmpty(details.name)) {
nameText = displayNumber;
// We have a real phone number as "nameView" so make it always LTR
@@ -195,8 +190,7 @@ public class PhoneCallDetailsHelper {
}
if (!TextUtils.isEmpty(details.name) && TextUtils.isEmpty(numberFormattedLabel)) {
- numberFormattedLabel = mPhoneNumberHelper.getDisplayNumber(details.accountHandle,
- details.number, details.numberPresentation, details.formattedNumber);
+ numberFormattedLabel = details.displayNumber;
}
return numberFormattedLabel;
}
@@ -218,12 +212,8 @@ public class PhoneCallDetailsHelper {
@NeededForTesting
public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) {
final CharSequence nameText;
- final CharSequence displayNumber =
- mPhoneNumberHelper.getDisplayNumber(details.accountHandle, details.number,
- details.numberPresentation,
- mResources.getString(R.string.recentCalls_addToContact));
if (TextUtils.isEmpty(details.name)) {
- nameText = displayNumber;
+ nameText = mResources.getString(R.string.recentCalls_addToContact);
} else {
nameText = details.name;
}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index b4fed867f..608475e0b 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -22,6 +22,7 @@ import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
+import android.os.Trace;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
@@ -98,8 +99,6 @@ public class CallLogAdapter extends GroupingListAdapter
/** Instance of helper class for managing views. */
private final CallLogListItemHelper mCallLogViewsHelper;
- /** Helper to parse and process phone numbers. */
- private PhoneNumberDisplayHelper mPhoneNumberHelper;
/** Helper to access Telephony phone number utils class */
protected final PhoneNumberUtilsWrapper mPhoneNumberUtilsWrapper;
/** Helper to group call log entries. */
@@ -210,12 +209,10 @@ public class CallLogAdapter extends GroupingListAdapter
Resources resources = mContext.getResources();
CallTypeHelper callTypeHelper = new CallTypeHelper(resources);
- mPhoneNumberHelper = new PhoneNumberDisplayHelper(mContext, resources);
mPhoneNumberUtilsWrapper = new PhoneNumberUtilsWrapper(mContext);
PhoneCallDetailsHelper phoneCallDetailsHelper =
new PhoneCallDetailsHelper(mContext, resources, mPhoneNumberUtilsWrapper);
- mCallLogViewsHelper =
- new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberHelper, resources);
+ mCallLogViewsHelper = new CallLogListItemHelper(phoneCallDetailsHelper, resources);
mCallLogGroupBuilder = new CallLogGroupBuilder(this);
}
@@ -312,9 +309,10 @@ public class CallLogAdapter extends GroupingListAdapter
if (getItemViewType(position) == VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM) {
return;
}
-
+ Trace.beginSection("onBindViewHolder: " + position);
Cursor c = (Cursor) getItem(position);
if (c == null) {
+ Trace.endSection();
return;
}
int count = getGroupSize(position);
@@ -408,21 +406,21 @@ public class CallLogAdapter extends GroupingListAdapter
views.showActions(mCurrentlyExpandedPosition == position, mOnReportButtonClickListener);
if (TextUtils.isEmpty(name)) {
- details = new PhoneCallDetails(number, numberPresentation, formattedNumber, countryIso,
- geocode, callTypes, date, duration, accountHandle, features, dataUsage,
- transcription);
+ details = new PhoneCallDetails(mContext, number, numberPresentation, formattedNumber,
+ countryIso, geocode, callTypes, date, duration, accountHandle, features,
+ dataUsage, transcription, isVoicemailNumber);
} else {
- details = new PhoneCallDetails(number, numberPresentation, formattedNumber, countryIso,
- geocode, callTypes, date, duration, name, ntype, label, lookupUri, photoUri,
- sourceType, accountHandle, features, dataUsage, transcription);
+ details = new PhoneCallDetails(mContext, number, numberPresentation, formattedNumber,
+ countryIso, geocode, callTypes, date, duration, name, ntype, label, lookupUri,
+ photoUri, sourceType, accountHandle, features, dataUsage, transcription,
+ isVoicemailNumber);
}
mCallLogViewsHelper.setPhoneCallDetails(mContext, views, details);
String nameForDefaultImage = null;
if (TextUtils.isEmpty(name)) {
- nameForDefaultImage = mPhoneNumberHelper.getDisplayNumber(details.accountHandle,
- details.number, details.numberPresentation, details.formattedNumber).toString();
+ nameForDefaultImage = details.displayNumber;
} else {
nameForDefaultImage = name;
}
@@ -437,6 +435,7 @@ public class CallLogAdapter extends GroupingListAdapter
mViewTreeObserver = views.rootView.getViewTreeObserver();
mViewTreeObserver.addOnPreDrawListener(this);
}
+ Trace.endSection();
}
@Override
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java
index 7ec6752e4..147a192e3 100644
--- a/src/com/android/dialer/calllog/CallLogListItemHelper.java
+++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java
@@ -23,7 +23,6 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.Log;
-import com.android.contacts.common.CallUtil;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.PhoneCallDetailsHelper;
import com.android.dialer.R;
@@ -36,8 +35,6 @@ import com.android.dialer.R;
/** Helper for populating the details of a phone call. */
private final PhoneCallDetailsHelper mPhoneCallDetailsHelper;
- /** Helper for handling phone numbers. */
- private final PhoneNumberDisplayHelper mPhoneNumberHelper;
/** Resources to look up strings. */
private final Resources mResources;
@@ -47,10 +44,9 @@ import com.android.dialer.R;
* @param phoneCallDetailsHelper used to set the details of a phone call
* @param phoneNumberHelper used to process phone number
*/
- public CallLogListItemHelper(PhoneCallDetailsHelper phoneCallDetailsHelper,
- PhoneNumberDisplayHelper phoneNumberHelper, Resources resources) {
+ public CallLogListItemHelper(
+ PhoneCallDetailsHelper phoneCallDetailsHelper, Resources resources) {
mPhoneCallDetailsHelper = phoneCallDetailsHelper;
- mPhoneNumberHelper = phoneNumberHelper;
mResources = resources;
}
@@ -73,7 +69,7 @@ import com.android.dialer.R;
// Cache name or number of caller. Used when setting the content descriptions of buttons
// when the actions ViewStub is inflated.
- views.nameOrNumber = this.getNameOrNumber(details);
+ views.nameOrNumber = getNameOrNumber(details);
}
/**
@@ -190,8 +186,7 @@ import com.android.dialer.R;
}
// If call had video capabilities, add the "Video Call" string.
- if ((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO &&
- CallUtil.isVideoEnabled(context)) {
+ if ((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) {
callDescription.append(mResources.getString(R.string.description_video_call));
}
@@ -264,8 +259,7 @@ import com.android.dialer.R;
if (!TextUtils.isEmpty(details.name)) {
recipient = details.name;
} else {
- recipient = mPhoneNumberHelper.getDisplayNumber(details.accountHandle,
- details.number, details.numberPresentation, details.formattedNumber);
+ recipient = details.displayNumber;
}
return recipient;
}
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index a7dd6aff8..ccd480ec6 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -411,8 +411,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder {
@NeededForTesting
public static CallLogListItemViewHolder createForTest(Context context) {
Resources resources = context.getResources();
- PhoneNumberDisplayHelper phoneNumberHelper =
- new PhoneNumberDisplayHelper(context, resources);
PhoneNumberUtilsWrapper phoneNumberUtilsWrapper = new PhoneNumberUtilsWrapper(context);
PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(
context, resources, phoneNumberUtilsWrapper);
@@ -421,8 +419,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder {
context,
null /* actionListener */,
phoneNumberUtilsWrapper,
- new CallLogListItemHelper(
- phoneCallDetailsHelper, phoneNumberHelper, resources),
+ new CallLogListItemHelper(phoneCallDetailsHelper, resources),
new View(context),
new QuickContactBadge(context),
new View(context),
diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
index 99ca8db10..7c2a96638 100644
--- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
+++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
@@ -58,7 +58,6 @@ public class DefaultVoicemailNotifier {
private final NotificationManager mNotificationManager;
private final NewCallsQuery mNewCallsQuery;
private final NameLookupQuery mNameLookupQuery;
- private final PhoneNumberDisplayHelper mPhoneNumberHelper;
/** Returns the singleton instance of the {@link DefaultVoicemailNotifier}. */
public static synchronized DefaultVoicemailNotifier getInstance(Context context) {
@@ -68,20 +67,18 @@ public class DefaultVoicemailNotifier {
ContentResolver contentResolver = context.getContentResolver();
sInstance = new DefaultVoicemailNotifier(context, notificationManager,
createNewCallsQuery(contentResolver),
- createNameLookupQuery(contentResolver),
- createPhoneNumberHelper(context));
+ createNameLookupQuery(contentResolver));
}
return sInstance;
}
private DefaultVoicemailNotifier(Context context,
NotificationManager notificationManager, NewCallsQuery newCallsQuery,
- NameLookupQuery nameLookupQuery, PhoneNumberDisplayHelper phoneNumberHelper) {
+ NameLookupQuery nameLookupQuery) {
mContext = context;
mNotificationManager = notificationManager;
mNewCallsQuery = newCallsQuery;
mNameLookupQuery = nameLookupQuery;
- mPhoneNumberHelper = phoneNumberHelper;
}
/**
@@ -128,8 +125,12 @@ public class DefaultVoicemailNotifier {
PhoneAccountHandle accountHandle = PhoneAccountUtils.getAccount(
newCall.accountComponentName,
newCall.accountId);
- name = mPhoneNumberHelper.getDisplayName(accountHandle, newCall.number,
- newCall.numberPresentation).toString();
+ name = PhoneNumberDisplayUtil.getDisplayName(
+ mContext,
+ accountHandle,
+ newCall.number,
+ newCall.numberPresentation,
+ /* isVoicemail */ false).toString();
// If we cannot lookup the contact, use the number instead.
if (TextUtils.isEmpty(name)) {
// Look it up in the database.
@@ -338,14 +339,4 @@ public class DefaultVoicemailNotifier {
}
}
}
-
- /**
- * Create a new PhoneNumberHelper.
- * <p>
- * This will cause some Disk I/O, at least the first time it is created, so it should not be
- * called from the main thread.
- */
- public static PhoneNumberDisplayHelper createPhoneNumberHelper(Context context) {
- return new PhoneNumberDisplayHelper(context, context.getResources());
- }
}
diff --git a/src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
index c1a5abfe1..e7fcde263 100644
--- a/src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java
+++ b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
@@ -28,40 +28,31 @@ import com.android.dialer.R;
/**
* Helper for formatting and managing the display of phone numbers.
*/
-public class PhoneNumberDisplayHelper {
- private final Context mContext;
- private final Resources mResources;
- private final PhoneNumberUtilsWrapper mPhoneNumberUtilsWrapper;
+public class PhoneNumberDisplayUtil {
- public PhoneNumberDisplayHelper(Context context, Resources resources) {
- mContext = context;
- mResources = resources;
- mPhoneNumberUtilsWrapper = new PhoneNumberUtilsWrapper(context);
- }
-
- public PhoneNumberDisplayHelper(Context context, Resources resources,
- PhoneNumberUtilsWrapper phoneNumberUtils) {
- mContext = context;
- mResources = resources;
- mPhoneNumberUtilsWrapper = phoneNumberUtils;
- }
-
- /* package */ CharSequence getDisplayName(PhoneAccountHandle accountHandle, CharSequence number,
- int presentation) {
+ /**
+ * Returns the string to display for the given phone number if there is no matching contact.
+ */
+ /* package */ static CharSequence getDisplayName(
+ Context context,
+ PhoneAccountHandle accountHandle,
+ CharSequence number,
+ int presentation,
+ boolean isVoicemail) {
if (presentation == Calls.PRESENTATION_UNKNOWN) {
- return mResources.getString(R.string.unknown);
+ return context.getResources().getString(R.string.unknown);
}
if (presentation == Calls.PRESENTATION_RESTRICTED) {
- return mResources.getString(R.string.private_num);
+ return context.getResources().getString(R.string.private_num);
}
if (presentation == Calls.PRESENTATION_PAYPHONE) {
- return mResources.getString(R.string.payphone);
+ return context.getResources().getString(R.string.payphone);
}
- if (mPhoneNumberUtilsWrapper.isVoicemailNumber(accountHandle, number)) {
- return mResources.getString(R.string.voicemail);
+ if (isVoicemail) {
+ return context.getResources().getString(R.string.voicemail);
}
if (PhoneNumberUtilsWrapper.isLegacyUnknownNumbers(number)) {
- return mResources.getString(R.string.unknown);
+ return context.getResources().getString(R.string.unknown);
}
return "";
}
@@ -73,21 +64,25 @@ public class PhoneNumberDisplayHelper {
* @param number the number to display
* @param formattedNumber the formatted number if available, may be null
*/
- public CharSequence getDisplayNumber(PhoneAccountHandle accountHandle, CharSequence number,
- int presentation, CharSequence formattedNumber) {
- final CharSequence displayName = getDisplayName(accountHandle, number, presentation);
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
-
- if (TextUtils.isEmpty(number)) {
- return "";
+ public static CharSequence getDisplayNumber(
+ Context context,
+ PhoneAccountHandle accountHandle,
+ CharSequence number,
+ int presentation,
+ CharSequence formattedNumber,
+ boolean isVoicemail) {
+ if (!TextUtils.isEmpty(formattedNumber)) {
+ return formattedNumber;
}
- if (TextUtils.isEmpty(formattedNumber)) {
+ final CharSequence displayName =
+ getDisplayName(context, accountHandle, number, presentation, isVoicemail);
+ if (!TextUtils.isEmpty(displayName)) {
+ return displayName;
+ } else if (!TextUtils.isEmpty(number)) {
return number;
} else {
- return formattedNumber;
+ return "";
}
}
}
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
index df4247b8e..701a06ed9 100644
--- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
@@ -61,20 +61,22 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
private LocaleTestUtils mLocaleTestUtils;
private TestPhoneNumberUtilsWrapper mPhoneUtils;
+ private Context mContext;
+
@Override
protected void setUp() throws Exception {
super.setUp();
- Context context = getContext();
- Resources resources = context.getResources();
- mPhoneUtils = new TestPhoneNumberUtilsWrapper(context, TEST_VOICEMAIL_NUMBER);
+ mContext = getContext();
+ Resources resources = mContext.getResources();
+ mPhoneUtils = new TestPhoneNumberUtilsWrapper(mContext, TEST_VOICEMAIL_NUMBER);
final TestPhoneNumberUtilsWrapper phoneUtils = new TestPhoneNumberUtilsWrapper(
- context, TEST_VOICEMAIL_NUMBER);
- mHelper = new PhoneCallDetailsHelper(context, resources, phoneUtils);
+ mContext, TEST_VOICEMAIL_NUMBER);
+ mHelper = new PhoneCallDetailsHelper(mContext, resources, phoneUtils);
mHelper.setCurrentTimeForTest(
new GregorianCalendar(2011, 5, 4, 13, 0, 0).getTimeInMillis());
- mViews = PhoneCallDetailsViews.createForTest(context);
- mNameView = new TextView(context);
- mLocaleTestUtils = new LocaleTestUtils(getContext());
+ mViews = PhoneCallDetailsViews.createForTest(mContext);
+ mNameView = new TextView(mContext);
+ mLocaleTestUtils = new LocaleTestUtils(mContext);
mLocaleTestUtils.setLocale(Locale.US);
}
@@ -309,38 +311,66 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
private void setPhoneCallDetailsWithNumber(String number, int presentation,
String formattedNumber) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, presentation, formattedNumber,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION)
- );
+ new PhoneCallDetails(
+ mContext,
+ number,
+ presentation,
+ formattedNumber,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{ Calls.VOICEMAIL_TYPE },
+ TEST_DATE,
+ TEST_DURATION,
+ isVoicemail(number)));
}
/** Sets the phone call details with default values and the given number. */
private void setPhoneCallDetailsWithNumberAndGeocode(String number, String formattedNumber,
String geocodedLocation) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, Calls.PRESENTATION_ALLOWED,
- formattedNumber, TEST_COUNTRY_ISO, geocodedLocation,
- new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION)
- );
+ new PhoneCallDetails(
+ mContext,
+ number,
+ Calls.PRESENTATION_ALLOWED,
+ formattedNumber,
+ TEST_COUNTRY_ISO,
+ geocodedLocation,
+ new int[]{ Calls.VOICEMAIL_TYPE },
+ TEST_DATE,
+ TEST_DURATION,
+ isVoicemail(number)));
}
/** Sets the phone call details with default values and the given date. */
private void setPhoneCallDetailsWithDate(long date) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION)
- );
+ new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE },
+ date,
+ TEST_DURATION,
+ false /* isVoicemail */));
}
/** Sets the phone call details with default values and the given call types using icons. */
private void setPhoneCallDetailsWithCallTypeIcons(int... callTypes) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- callTypes, TEST_DATE, TEST_DURATION)
- );
+ new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ callTypes,
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */));
}
/**
@@ -348,26 +378,58 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
*/
private void setPhoneCallDetailsWithFeatures(int features) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION, null,
- features, null, null)
+ new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE },
+ TEST_DATE,
+ TEST_DURATION,
+ null,
+ features,
+ null,
+ null,
+ false /* isVoicemail */)
);
}
private void setCallDetailsHeaderWithNumber(String number, int presentation) {
mHelper.setCallDetailsHeader(mNameView,
- new PhoneCallDetails(number, presentation,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION, null,
- 0, null, null));
+ new PhoneCallDetails(
+ mContext,
+ number,
+ presentation,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE },
+ TEST_DATE,
+ TEST_DURATION,
+ null, 0, null, null,
+ false /* isVoicemail */));
}
private void setCallDetailsHeader(String name) {
mHelper.setCallDetailsHeader(mNameView,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION,
- name, 0, "", null, null, 0, null, 0, null, null));
+ new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE },
+ TEST_DATE,
+ TEST_DURATION,
+ name,
+ 0, "", null, null, 0, null, 0, null, null,
+ false /* isVoicemail */));
+ }
+
+ private boolean isVoicemail(String number) {
+ return number.equals(TEST_VOICEMAIL_NUMBER);
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
index 0f4974bfd..085ec9bb6 100644
--- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
@@ -51,24 +51,21 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
/** The views used in the tests. */
private CallLogListItemViewHolder mViewHolder;
- private PhoneNumberDisplayHelper mPhoneNumberHelper;
- private PhoneNumberDisplayHelper mPhoneNumberDisplayHelper;
+ private Context mContext;
private Resources mResources;
@Override
protected void setUp() throws Exception {
super.setUp();
- Context context = getContext();
- mResources = context.getResources();
+ mContext = getContext();
+ mResources = mContext.getResources();
final TestPhoneNumberUtilsWrapper phoneUtils =
- new TestPhoneNumberUtilsWrapper(context, TEST_VOICEMAIL_NUMBER);
+ new TestPhoneNumberUtilsWrapper(mContext, TEST_VOICEMAIL_NUMBER);
PhoneCallDetailsHelper phoneCallDetailsHelper =
- new PhoneCallDetailsHelper(context, mResources, phoneUtils);
- mPhoneNumberDisplayHelper = new PhoneNumberDisplayHelper(context, mResources, phoneUtils);
- mHelper = new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberDisplayHelper,
- mResources);
- mViewHolder = CallLogListItemViewHolder.createForTest(getContext());
+ new PhoneCallDetailsHelper(mContext, mResources, phoneUtils);
+ mHelper = new CallLogListItemHelper(phoneCallDetailsHelper, mResources);
+ mViewHolder = CallLogListItemViewHolder.createForTest(mContext);
}
@Override
@@ -126,9 +123,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test case where an answered unknown call is received.
*/
public void testGetCallDescriptionID_UnknownAnswered() {
- PhoneCallDetails details = new PhoneCallDetails("", Calls.PRESENTATION_UNKNOWN, "",
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION);
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ "",
+ Calls.PRESENTATION_UNKNOWN,
+ "",
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.INCOMING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_incoming_answered_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -138,9 +143,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test case where an missed unknown call is received.
*/
public void testGetCallDescriptionID_UnknownMissed() {
- PhoneCallDetails details = new PhoneCallDetails("", Calls.PRESENTATION_UNKNOWN, "",
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.MISSED_TYPE}, TEST_DATE, TEST_DURATION);
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ "",
+ Calls.PRESENTATION_UNKNOWN,
+ "",
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.MISSED_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -150,9 +163,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test case where an missed unknown call is received and a voicemail was left.
*/
public void testGetCallDescriptionID_UnknownVoicemail() {
- PhoneCallDetails details = new PhoneCallDetails("", Calls.PRESENTATION_UNKNOWN, "",
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.VOICEMAIL_TYPE}, TEST_DATE, TEST_DURATION);
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ "",
+ Calls.PRESENTATION_UNKNOWN,
+ "",
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.VOICEMAIL_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -162,10 +183,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test case where an answered call from a known caller is received.
*/
public void testGetCallDescriptionID_KnownAnswered() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.INCOMING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_incoming_answered_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -175,10 +203,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test case where a missed call from a known caller is received.
*/
public void testGetCallDescriptionID_KnownMissed() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.MISSED_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.MISSED_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -188,10 +223,16 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test case where a missed call from a known caller is received and a voicemail was left.
*/
public void testGetCallDescriptionID_KnownVoicemail() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.VOICEMAIL_TYPE}, TEST_DATE, TEST_DURATION);
+ new int[]{Calls.VOICEMAIL_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -202,10 +243,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* only a single call for this caller.
*/
public void testGetCallDescriptionID_OutgoingSingle() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.OUTGOING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_outgoing_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -216,10 +264,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* many calls for this caller.
*/
public void testGetCallDescriptionID_OutgoingMultiple() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
assertEquals(R.string.description_outgoing_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -229,10 +284,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* For outgoing calls, we should NOT have "New Voicemail" in the description.
*/
public void testGetCallDescription_NoVoicemailOutgoing() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
assertFalse(description.toString()
.contains(this.mResources.getString(R.string.description_new_voicemail)));
@@ -243,10 +305,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* For regular incoming calls, we should NOT have "New Voicemail" in the description.
*/
public void testGetCallDescription_NoVoicemailIncoming() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
assertFalse(description.toString()
.contains(this.mResources.getString(R.string.description_new_voicemail)));
@@ -257,10 +326,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* For regular missed calls, we should NOT have "New Voicemail" in the description.
*/
public void testGetCallDescription_NoVoicemailMissed() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.MISSED_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.MISSED_TYPE, Calls.OUTGOING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
assertFalse(description.toString()
.contains(this.mResources.getString(R.string.description_new_voicemail)));
@@ -271,10 +347,17 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* For voicemail calls, we should have "New Voicemail" in the description.
*/
public void testGetCallDescription_Voicemail() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.VOICEMAIL_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.VOICEMAIL_TYPE, Calls.OUTGOING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
assertTrue(description.toString()
.contains(this.mResources.getString(R.string.description_new_voicemail)));
@@ -285,10 +368,16 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test that the "X calls" message is not present if there is only a single call.
*/
public void testGetCallDescription_NumCallsSingle() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.VOICEMAIL_TYPE}, TEST_DATE, TEST_DURATION);
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{Calls.VOICEMAIL_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
// Rather than hard coding the "X calls" string message, we'll generate it with an empty
@@ -304,10 +393,15 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test that the "X calls" message is present if there are many calls.
*/
public void testGetCallDescription_NumCallsMultiple() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.VOICEMAIL_TYPE, Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION);
+ new int[]{Calls.VOICEMAIL_TYPE, Calls.INCOMING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
assertTrue(description.toString()
.contains(this.mResources.getString(R.string.description_num_calls, 2)));
@@ -318,10 +412,20 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
* Test that the "Video call." message is present if the call had video capability.
*/
public void testGetCallDescription_Video() {
- PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{Calls.INCOMING_TYPE, Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION,
- null, Calls.FEATURES_VIDEO, null, null);
+ PhoneCallDetails details = new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO, TEST_GEOCODE,
+ new int[]{Calls.INCOMING_TYPE, Calls.INCOMING_TYPE},
+ TEST_DATE,
+ TEST_DURATION,
+ null,
+ Calls.FEATURES_VIDEO,
+ null,
+ null,
+ false /* isVoicemail */);
CharSequence description = mHelper.getCallDescription(getContext(), details);
final boolean isVideoEnabled = CallUtil.isVideoEnabled(getContext());
@@ -350,28 +454,49 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
/** Sets the details of a phone call using the specified phone number. */
private void setPhoneCallDetailsWithNumberAndType(String number,
int presentation, String formattedNumber, int callType) {
- mHelper.setPhoneCallDetails(getContext(), mViewHolder,
- new PhoneCallDetails(number, presentation, formattedNumber,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ callType }, TEST_DATE, TEST_DURATION)
- );
+ mHelper.setPhoneCallDetails(mContext, mViewHolder,
+ new PhoneCallDetails(
+ mContext,
+ number,
+ presentation,
+ formattedNumber,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ new int[]{ callType },
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */));
}
/** Sets the details of a phone call using the specified call type. */
private void setPhoneCallDetailsWithTypes(int... types) {
mHelper.setPhoneCallDetails(getContext() ,mViewHolder,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- types, TEST_DATE, TEST_DURATION)
- );
+ new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ types,
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */));
}
/** Sets the details of an unread phone call using the specified call type. */
private void setUnreadPhoneCallDetailsWithTypes(int... types) {
mHelper.setPhoneCallDetails(getContext(), mViewHolder,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- types, TEST_DATE, TEST_DURATION)
- );
+ new PhoneCallDetails(
+ mContext,
+ TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER,
+ TEST_COUNTRY_ISO,
+ TEST_GEOCODE,
+ types,
+ TEST_DATE,
+ TEST_DURATION,
+ false /* isVoicemail */));
}
}