Add account label to call details if appropriate
We will be adding the account label field to call details if there is
more than one account to disambiguate. Otherwise this field will be
hidden.
Bug: 16488229
Change-Id: Idb03d09d63372655504a5f9178e6f2e408aefb88
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index cd5fb3b..e44ff83 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -115,6 +115,7 @@
private QuickContactBadge mQuickContactBadge;
private TextView mCallerName;
private TextView mCallerNumber;
+ private TextView mAccountLabel;
private AsyncTaskExecutor mAsyncTaskExecutor;
private ContactInfoHelper mContactInfoHelper;
@@ -246,6 +247,7 @@
mQuickContactBadge.setOverlay(null);
mCallerName = (TextView) findViewById(R.id.caller_name);
mCallerNumber = (TextView) findViewById(R.id.caller_number);
+ mAccountLabel = (TextView) findViewById(R.id.phone_account_label);
mDefaultCountryIso = GeoUtil.getCurrentCountryIso(this);
mContactPhotoManager = ContactPhotoManager.getInstance(this);
mProximitySensorManager = new ProximitySensorManager(this, mProximitySensorListener);
@@ -438,6 +440,13 @@
}
+ if (!TextUtils.isEmpty(firstDetails.accountLabel)) {
+ mAccountLabel.setText(firstDetails.accountLabel);
+ mAccountLabel.setVisibility(View.VISIBLE);
+ } else {
+ mAccountLabel.setVisibility(View.GONE);
+ }
+
mHasEditNumberBeforeCallOption =
canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
mHasTrashOption = hasVoicemail();
@@ -520,7 +529,7 @@
final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);
final String transcription = callCursor.getString(TRANSCRIPTION_COLUMN_INDEX);
- final Drawable accountIcon = PhoneAccountUtils.getAccountIcon(this,
+ final String accountLabel = PhoneAccountUtils.getAccountLabel(this,
PhoneAccountUtils.getAccount(
callCursor.getString(ACCOUNT_COMPONENT_NAME),
callCursor.getString(ACCOUNT_ID)));
@@ -571,7 +580,7 @@
formattedNumber, countryIso, geocode,
new int[]{ callType }, date, duration,
nameText, numberType, numberLabel, lookupUri, photoUri, sourceType,
- accountIcon, features, dataUsage, transcription);
+ accountLabel, null, features, dataUsage, transcription);
} finally {
if (callCursor != null) {
callCursor.close();
diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java
index 8692036..f6f9eda 100644
--- a/src/com/android/dialer/PhoneCallDetails.java
+++ b/src/com/android/dialer/PhoneCallDetails.java
@@ -67,7 +67,11 @@
*/
public final int sourceType;
/**
- * The unique identifier for the provider associated with the call.
+ * The unique identifier for the account associated with the call.
+ */
+ public final String accountLabel;
+ /**
+ * The icon for the account associated with the call.
*/
public final Drawable accountIcon;
/**
@@ -92,18 +96,18 @@
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, Calls.FEATURES_NONE,
+ callTypes, date, duration, "", 0, "", null, null, 0, null, null, Calls.FEATURES_NONE,
null, null);
}
/** Create the details for a call with a number not associated with a contact. */
public PhoneCallDetails(CharSequence number, int numberPresentation,
CharSequence formattedNumber, String countryIso, String geocode,
- int[] callTypes, long date, long duration, Drawable accountIcon, int features,
- Long dataUsage, String transcription) {
+ int[] callTypes, long date, long duration, String accountLabel, Drawable accountIcon,
+ int features, Long dataUsage, String transcription) {
this(number, numberPresentation, formattedNumber, countryIso, geocode,
- callTypes, date, duration, "", 0, "", null, null, 0, accountIcon, features,
- dataUsage, transcription);
+ callTypes, date, duration, "", 0, "", null, null, 0, accountLabel, accountIcon,
+ features, dataUsage, transcription);
}
/** Create the details for a call with a number associated with a contact. */
@@ -111,8 +115,8 @@
CharSequence formattedNumber, String countryIso, String geocode,
int[] callTypes, long date, long duration, CharSequence name,
int numberType, CharSequence numberLabel, Uri contactUri,
- Uri photoUri, int sourceType, Drawable accountIcon, int features, Long dataUsage,
- String transcription) {
+ Uri photoUri, int sourceType, String accountLabel, Drawable accountIcon, int features,
+ Long dataUsage, String transcription) {
this.number = number;
this.numberPresentation = numberPresentation;
this.formattedNumber = formattedNumber;
@@ -127,6 +131,7 @@
this.contactUri = contactUri;
this.photoUri = photoUri;
this.sourceType = sourceType;
+ this.accountLabel = accountLabel;
this.accountIcon = accountIcon;
this.features = features;
this.dataUsage = dataUsage;
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index 3846b6f..a432daf 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -48,7 +48,6 @@
/** The injected current time in milliseconds since the epoch. Used only by tests. */
private Long mCurrentTimeMillisForTest;
// Helper classes.
- private final CallTypeHelper mCallTypeHelper;
private final PhoneNumberDisplayHelper mPhoneNumberHelper;
private final PhoneNumberUtilsWrapper mPhoneNumberUtilsWrapper;
@@ -67,7 +66,6 @@
public PhoneCallDetailsHelper(Resources resources, CallTypeHelper callTypeHelper,
PhoneNumberUtilsWrapper phoneUtils) {
mResources = resources;
- mCallTypeHelper = callTypeHelper;
mPhoneNumberUtilsWrapper = phoneUtils;
mPhoneNumberHelper = new PhoneNumberDisplayHelper(mPhoneNumberUtilsWrapper, resources);
}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 630cf3f..a8c20fe 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -774,12 +774,12 @@
if (TextUtils.isEmpty(name)) {
details = new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode, callTypes, date,
- duration, accountIcon, features, dataUsage, transcription);
+ duration, null, accountIcon, features, dataUsage, transcription);
} else {
details = new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode, callTypes, date,
duration, name, ntype, label, lookupUri, photoUri, sourceType,
- accountIcon, features, dataUsage, transcription);
+ null, accountIcon, features, dataUsage, transcription);
}
mCallLogViewsHelper.setPhoneCallDetails(views, details);
diff --git a/src/com/android/dialer/calllog/PhoneAccountUtils.java b/src/com/android/dialer/calllog/PhoneAccountUtils.java
index 326ffa6..dc838fb 100644
--- a/src/com/android/dialer/calllog/PhoneAccountUtils.java
+++ b/src/com/android/dialer/calllog/PhoneAccountUtils.java
@@ -54,12 +54,12 @@
/**
* Generate account label from data in Telecomm database
*/
- public static CharSequence getAccountLabel(Context context, PhoneAccountHandle phoneAccount) {
+ public static String getAccountLabel(Context context, PhoneAccountHandle phoneAccount) {
final PhoneAccount account = getAccountOrNull(context, phoneAccount);
if (account == null) {
return null;
}
- return account.getLabel();
+ return account.getLabel().toString();
}
/**
@@ -75,4 +75,5 @@
}
return account;
}
+
}