diff options
Diffstat (limited to 'src/com/android/dialer/PhoneCallDetailsHelper.java')
-rw-r--r-- | src/com/android/dialer/PhoneCallDetailsHelper.java | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java index 2a4a1425c..4424fcb0b 100644 --- a/src/com/android/dialer/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/PhoneCallDetailsHelper.java @@ -91,26 +91,13 @@ public class PhoneCallDetailsHelper { isHighlighted ? mCallTypeHelper.getHighlightedColor(details.callTypes[0]) : null; // The date of this call, relative to the current time. - CharSequence dateText = - DateUtils.getRelativeTimeSpanString(details.date, - getCurrentTimeMillis(), - DateUtils.MINUTE_IN_MILLIS, - DateUtils.FORMAT_ABBREV_RELATIVE); + CharSequence dateText = getCallDate(details); // Set the call count and date. setCallCountAndDate(views, callCount, dateText, highlightColor); - CharSequence numberFormattedLabel = null; - // Only show a label if the number is shown and it is not a SIP address. - if (!TextUtils.isEmpty(details.number) - && !PhoneNumberHelper.isUriNumber(details.number.toString())) { - if (details.numberLabel == ContactInfo.GEOCODE_AS_LABEL) { - numberFormattedLabel = details.geocode; - } else { - numberFormattedLabel = Phone.getTypeLabel(mResources, details.numberType, - details.numberLabel); - } - } + // Get type of call (ie mobile, home, etc) if known, or the caller's + CharSequence numberFormattedLabel = getCallTypeOrLocation(details); final CharSequence nameText; final CharSequence numberText; @@ -141,6 +128,41 @@ public class PhoneCallDetailsHelper { views.labelView.setVisibility(TextUtils.isEmpty(labelText) ? View.GONE : View.VISIBLE); } + /** + * For a call, if there is an associated contact for the caller, return the known call type + * (e.g. mobile, home, work). If there is no associated contact, attempt to use the caller's + * location if known. + * @param details Call details to use. + * @return Type of call (mobile/home) if known, or the location of the caller (if known). + */ + public CharSequence getCallTypeOrLocation(PhoneCallDetails details) { + CharSequence numberFormattedLabel = null; + // Only show a label if the number is shown and it is not a SIP address. + if (!TextUtils.isEmpty(details.number) + && !PhoneNumberHelper.isUriNumber(details.number.toString())) { + if (details.numberLabel == ContactInfo.GEOCODE_AS_LABEL) { + numberFormattedLabel = details.geocode; + } else { + numberFormattedLabel = Phone.getTypeLabel(mResources, details.numberType, + details.numberLabel); + } + } + return numberFormattedLabel; + } + + /** + * Get the call date/time of the call, relative to the current time. + * e.g. 3 minutes ago + * @param details Call details to use. + * @return String representing when the call occurred. + */ + public CharSequence getCallDate(PhoneCallDetails details) { + return DateUtils.getRelativeTimeSpanString(details.date, + getCurrentTimeMillis(), + DateUtils.MINUTE_IN_MILLIS, + DateUtils.FORMAT_ABBREV_RELATIVE); + } + /** Sets the text of the header view for the details page of a phone call. */ public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) { final CharSequence nameText; |