summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/call_detail_header.xml4
-rw-r--r--res/layout/call_detail_history_item.xml4
-rw-r--r--res/layout/call_log_list_item.xml35
-rw-r--r--res/layout/call_log_list_item_actions.xml20
-rw-r--r--res/layout/voicemail_promo_card.xml2
-rw-r--r--res/values/colors.xml14
-rw-r--r--res/values/dimens.xml12
-rw-r--r--res/values/styles.xml13
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java4
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java18
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemHelper.java5
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemViewHolder.java36
-rw-r--r--src/com/android/dialer/calllog/PhoneCallDetailsHelper.java45
-rw-r--r--tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java56
14 files changed, 168 insertions, 100 deletions
diff --git a/res/layout/call_detail_header.xml b/res/layout/call_detail_header.xml
index 5931445e4..6eceb80ee 100644
--- a/res/layout/call_detail_header.xml
+++ b/res/layout/call_detail_header.xml
@@ -59,7 +59,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size"
+ android:textSize="@dimen/call_log_detail_text_size"
android:layout_marginBottom="1dp"
android:singleLine="true" />
@@ -68,7 +68,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size"
+ android:textSize="@dimen/call_log_detail_text_size"
android:singleLine="true"
android:visibility="gone" />
diff --git a/res/layout/call_detail_history_item.xml b/res/layout/call_detail_history_item.xml
index cbe844234..10d9605a1 100644
--- a/res/layout/call_detail_history_item.xml
+++ b/res/layout/call_detail_history_item.xml
@@ -46,11 +46,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size" />
+ android:textSize="@dimen/call_log_detail_text_size" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size" />
+ android:textSize="@dimen/call_log_detail_text_size" />
</LinearLayout>
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index ec512b67f..95de2680c 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -30,8 +30,8 @@
android:layout_marginStart="@dimen/call_log_start_margin"
android:layout_marginEnd="@dimen/call_log_outer_margin"
android:fontFamily="sans-serif-medium"
- android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size"
+ android:textColor="@color/call_log_day_group_heading_color"
+ android:textSize="@dimen/call_log_day_group_heading_size"
android:paddingTop="@dimen/call_log_day_group_padding_top"
android:paddingBottom="@dimen/call_log_day_group_padding_bottom" />
@@ -83,21 +83,10 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/call_log_name_margin_bottom"
android:layout_marginEnd="@dimen/call_log_icon_margin"
- android:textColor="?attr/call_log_primary_text_color"
+ android:textColor="@color/call_log_primary_color"
android:textSize="@dimen/call_log_primary_text_size"
android:singleLine="true" />
- <TextView
- android:id="@+id/voicemail_transcription"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="@dimen/call_log_icon_margin"
- android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:visibility="gone" />
-
<LinearLayout
android:id="@+id/call_type"
android:layout_width="wrap_content"
@@ -118,8 +107,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/call_log_icon_margin"
android:layout_gravity="center_vertical"
- android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size"
+ android:textColor="@color/call_log_detail_color"
+ android:textSize="@dimen/call_log_detail_text_size"
android:singleLine="true" />
</LinearLayout>
@@ -130,10 +119,22 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/call_log_icon_margin"
android:textColor="?attr/call_log_secondary_text_color"
- android:textSize="@dimen/call_log_secondary_text_size"
+ android:textSize="@dimen/call_log_detail_text_size"
android:visibility="gone"
android:singleLine="true" />
+ <TextView
+ android:id="@+id/voicemail_transcription"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/call_log_icon_margin"
+ android:textColor="@color/call_log_voicemail_transcript_color"
+ android:textSize="@dimen/call_log_voicemail_transcription_text_size"
+ android:ellipsize="marquee"
+ android:visibility="gone"
+ android:singleLine="false"
+ android:maxLines="10"/>
+
</LinearLayout>
<ImageView
diff --git a/res/layout/call_log_list_item_actions.xml b/res/layout/call_log_list_item_actions.xml
index 16a712bcd..262a17685 100644
--- a/res/layout/call_log_list_item_actions.xml
+++ b/res/layout/call_log_list_item_actions.xml
@@ -19,6 +19,7 @@
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingBottom="@dimen/call_log_actions_bottom_padding"
android:orientation="vertical"
android:visibility="visible"
android:importantForAccessibility="1">
@@ -35,16 +36,27 @@
<LinearLayout
android:id="@+id/call_action"
+ android:paddingTop="@dimen/call_log_actions_top_padding"
style="@style/CallLogActionStyle">
<ImageView
style="@style/CallLogActionIconStyle"
android:src="@drawable/ic_call_24dp" />
- <TextView
- android:id="@+id/call_action_text"
- style="@style/CallLogActionTextStyle"
- android:text="@string/description_call_log_call_action" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:gravity="center_vertical">
+ <TextView
+ android:id="@+id/call_action_text"
+ style="@style/CallLogActionTextStyle"
+ android:text="@string/description_call_log_call_action" />
+
+ <TextView
+ android:id="@+id/call_type_or_location_text"
+ style="@style/CallLogActionSupportTextStyle"/>
+ </LinearLayout>
</LinearLayout>
diff --git a/res/layout/voicemail_promo_card.xml b/res/layout/voicemail_promo_card.xml
index 891f09693..ba4ac59a7 100644
--- a/res/layout/voicemail_promo_card.xml
+++ b/res/layout/voicemail_promo_card.xml
@@ -57,7 +57,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/background_dialer_white"
- android:textSize="@dimen/call_log_secondary_text_size"
+ android:textSize="@dimen/call_log_detail_text_size"
android:text="@string/visual_voicemail_text"
android:lineSpacingExtra="@dimen/promo_card_line_spacing"
android:singleLine="false"/>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index d0f7ed000..8b7b1502f 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -33,8 +33,20 @@
<color name="setting_background_color">#ffffff</color>
<color name="setting_button_color">#eee</color>
+ <!-- 54% black -->
+ <color name="call_log_icon_tint">#8a000000</color>
+ <!-- 87% black -->
+ <color name="call_log_primary_color">#de000000</color>
+ <!-- 54% black -->
+ <color name="call_log_detail_color">#8a000000</color>
+ <!-- 87% black -->
+ <color name="call_log_voicemail_transcript_color">#de000000</color>
<!-- 70% black -->
- <color name="call_log_icon_tint">#b3000000</color>
+ <color name="call_log_action_color">#b3000000</color>
+ <!-- 54% black -->
+ <color name="call_log_day_group_heading_color">#8a000000</color>
+ <!-- 87% black-->
+ <color name="call_log_unread_text_color">#de000000</color>
<color name="call_log_list_item_primary_action_icon_tint">@color/call_log_icon_tint</color>
<!-- Color of the text describing an unconsumed missed call. -->
<color name="call_log_missed_call_highlight_color">@color/dialer_red_highlight_color</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d3c52a313..18f33d5f2 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -108,17 +108,19 @@
<dimen name="search_list_padding_top">16dp</dimen>
<dimen name="search_box_elevation">3dp</dimen>
- <dimen name="call_log_action_height">48dp</dimen>
<dimen name="call_log_action_icon_margin_start">16dp</dimen>
<dimen name="call_log_action_icon_dimen">24dp</dimen>
<dimen name="call_log_action_horizontal_padding">24dp</dimen>
<dimen name="call_log_actions_left_padding">64dp</dimen>
- <dimen name="call_log_primary_text_size">14sp</dimen>
- <dimen name="call_log_secondary_text_size">14sp</dimen>
- <dimen name="call_log_list_item_actions_text_size">12sp</dimen>
+ <dimen name="call_log_actions_top_padding">8dp</dimen>
+ <dimen name="call_log_actions_bottom_padding">8dp</dimen>
+ <dimen name="call_log_primary_text_size">16sp</dimen>
+ <dimen name="call_log_detail_text_size">12sp</dimen>
+ <dimen name="call_log_day_group_heading_size">14sp</dimen>
+ <dimen name="call_log_voicemail_transcription_text_size">14sp</dimen>
<!-- Height of the call log actions section for each call log entry -->
- <dimen name="call_log_action_height">44dp</dimen>
+ <dimen name="call_log_action_height">48dp</dimen>
<dimen name="call_log_day_group_padding_top">15dp</dimen>
<dimen name="call_log_day_group_padding_bottom">9dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 3d8644281..7828a20f1 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -222,14 +222,19 @@
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingStart">@dimen/call_log_action_horizontal_padding</item>
<item name="android:paddingEnd">@dimen/call_log_action_horizontal_padding</item>
- <item name="android:textColor">?attr/call_log_secondary_text_color</item>
- <item name="android:textSize">@dimen/call_log_list_item_actions_text_size</item>
- <item name="android:fontFamily">"sans-serif-medium"</item>
+ <item name="android:textColor">@color/call_log_action_color</item>
+ <item name="android:textSize">@dimen/call_log_primary_text_size</item>
+ <item name="android:fontFamily">"sans-serif"</item>
<item name="android:focusable">true</item>
<item name="android:singleLine">true</item>
<item name="android:importantForAccessibility">no</item>
</style>
+ <style name="CallLogActionSupportTextStyle" parent="@style/CallLogActionTextStyle">
+ <item name="android:textSize">@dimen/call_log_detail_text_size</item>
+ <item name="android:textColor">@color/call_log_detail_color</item>
+ </style>
+
<style name="CallLogActionIconStyle">
<item name="android:layout_width">@dimen/call_log_action_icon_dimen</item>
<item name="android:layout_height">@dimen/call_log_action_icon_dimen</item>
@@ -299,7 +304,7 @@
<style name="PromoCardActionStyle" parent="TextActionStyle">
<item name="android:textColor">@color/promo_card_text</item>
- <item name="android:textSize">@dimen/call_log_list_item_actions_text_size</item>
+ <item name="android:textSize">@dimen/call_log_primary_text_size</item>
</style>
<style name="VoicemailPlaybackLayoutTextStyle">
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 703b18f8f..035317010 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -367,7 +367,7 @@ public class CallLogAdapter extends GroupingListAdapter
* TODO: This gets called 20-30 times when Dialer starts up for a single call log entry and
* should not. It invokes cross-process methods and the repeat execution can get costly.
*
- * @param ViewHolder The view corresponding to this entry.
+ * @param viewHolder The view corresponding to this entry.
* @param position The position of the entry.
*/
public void onBindViewHolder(ViewHolder viewHolder, int position) {
@@ -419,7 +419,7 @@ public class CallLogAdapter extends GroupingListAdapter
c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME),
c.getString(CallLogQuery.ACCOUNT_ID));
final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
- final ContactInfo cachedContactInfo = mContactInfoHelper.getContactInfo(c);
+ final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(c);
final boolean isVoicemailNumber =
mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index b7f068e1f..dff213bce 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -18,20 +18,14 @@ package com.android.dialer.calllog;
import static android.Manifest.permission.READ_CALL_LOG;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
import android.app.Activity;
-import android.app.DialogFragment;
import android.app.Fragment;
import android.app.KeyguardManager;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.database.Cursor;
-import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -44,28 +38,16 @@ import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.ListView;
-import android.widget.TextView;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.util.PermissionsUtil;
-import com.android.contacts.common.util.ViewUtil;
import com.android.dialer.R;
-import com.android.dialer.list.ListsFragment.HostInterface;
-import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.EmptyLoader;
import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
-import com.android.dialer.voicemail.VoicemailStatusHelper;
-import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage;
-import com.android.dialer.voicemail.VoicemailStatusHelperImpl;
import com.android.dialer.widget.EmptyContentView;
import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener;
import com.android.dialerbind.ObjectFactory;
-import java.util.List;
-
/**
* Displays a list of call log entries. To filter for a particular kind of call
* (all, missed or voicemails), specify it in the constructor.
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java
index 8e45dd36f..84d036487 100644
--- a/src/com/android/dialer/calllog/CallLogListItemHelper.java
+++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java
@@ -57,7 +57,6 @@ import com.android.dialer.R;
/**
* Sets the name, label, and number for a contact.
*
- * @param context The application context.
* @param views the views to populate
* @param details the details of a phone call needed to fill in the data
*/
@@ -76,6 +75,10 @@ import com.android.dialer.R;
// when the actions ViewStub is inflated.
views.nameOrNumber = getNameOrNumber(details);
+ // The call type or Location associated with the call. Use when setting text for a
+ // voicemail log's call button
+ views.callTypeOrLocation = mPhoneCallDetailsHelper.getCallTypeOrLocation(details);
+
// Cache country iso. Used for number filtering.
views.countryIso = details.countryIso;
}
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index 0e234e345..b70ea0751 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -162,6 +162,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
public CharSequence nameOrNumber;
/**
+ * The call type or Location associated with the call. Cached here for use when setting text
+ * for a voicemail log's call button
+ */
+ public CharSequence callTypeOrLocation;
+
+ /**
* Whether this row is for a business or not.
*/
public boolean isBusiness;
@@ -171,8 +177,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
*/
public ContactInfo info;
- private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10;
-
private final Context mContext;
private final TelecomCallLogCache mTelecomCallLogCache;
private final CallLogListItemHelper mCallLogListItemHelper;
@@ -342,8 +346,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
* Configures the action buttons in the expandable actions ViewStub. The ViewStub is not
* inflated during initial binding, so click handlers, tags and accessibility text must be set
* here, if necessary.
- *
- * @param callLogItem The call log list item view.
*/
public void inflateActionViewStub() {
ViewStub stub = (ViewStub) rootView.findViewById(R.id.call_log_entry_actions_stub);
@@ -427,6 +429,14 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
.setText(TextUtils.expandTemplate(
mContext.getString(R.string.call_log_action_call),
nameOrNumber));
+ TextView callTypeOrLocationView = ((TextView) callButtonView.findViewById(
+ R.id.call_type_or_location_text));
+ if (callType == Calls.VOICEMAIL_TYPE && !TextUtils.isEmpty(callTypeOrLocation)) {
+ callTypeOrLocationView.setText(callTypeOrLocation);
+ callTypeOrLocationView.setVisibility(View.VISIBLE);
+ } else {
+ callTypeOrLocationView.setVisibility(View.GONE);
+ }
callButtonView.setVisibility(View.VISIBLE);
} else {
callButtonView.setVisibility(View.GONE);
@@ -455,9 +465,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
voicemailPlaybackView.setVisibility(View.GONE);
}
- detailsButtonView.setVisibility(View.VISIBLE);
- detailsButtonView.setTag(
+ if (callType == Calls.VOICEMAIL_TYPE) {
+ detailsButtonView.setVisibility(View.GONE);
+ } else {
+ detailsButtonView.setVisibility(View.VISIBLE);
+ detailsButtonView.setTag(
IntentProvider.getCallDetailIntentProvider(rowId, callIds, null));
+ }
if (info != null && UriUtils.isEncodedContactUri(info.lookupUri)) {
createNewContactButtonView.setTag(IntentProvider.getAddContactIntentProvider(
@@ -495,7 +509,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
* If the action views have never been shown yet for this view, inflate the view stub.
*/
public void showActions(boolean show) {
- expandVoicemailTranscriptionView(show);
+ showOrHideVoicemailTranscriptionView(show);
if (show) {
// Inflate the view stub if necessary, and wire up the event handlers.
@@ -514,17 +528,17 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
updatePrimaryActionButton(show);
}
- public void expandVoicemailTranscriptionView(boolean isExpanded) {
+ public void showOrHideVoicemailTranscriptionView(boolean isExpanded) {
if (callType != Calls.VOICEMAIL_TYPE) {
return;
}
final TextView view = phoneCallDetailsViews.voicemailTranscriptionView;
- if (TextUtils.isEmpty(view.getText())) {
+ if (!isExpanded || TextUtils.isEmpty(view.getText())) {
+ view.setVisibility(View.GONE);
return;
}
- view.setMaxLines(isExpanded ? VOICEMAIL_TRANSCRIPTION_MAX_LINES : 1);
- view.setSingleLine(!isExpanded);
+ view.setVisibility(View.VISIBLE);
}
public void updatePhoto() {
diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
index 37920565a..b16079a9c 100644
--- a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
@@ -16,6 +16,7 @@
package com.android.dialer.calllog;
+import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import android.content.Context;
@@ -50,6 +51,9 @@ public class PhoneCallDetailsHelper {
private final Resources mResources;
/** The injected current time in milliseconds since the epoch. Used only by tests. */
private Long mCurrentTimeMillisForTest;
+
+ private CharSequence mPhoneTypeLabelForTest;
+
private final TelecomCallLogCache mTelecomCallLogCache;
/** Calendar used to construct dates */
@@ -138,12 +142,9 @@ public class PhoneCallDetailsHelper {
views.nameView.setText(nameText);
- if (isVoicemail && !TextUtils.isEmpty(details.transcription)) {
- views.voicemailTranscriptionView.setText(details.transcription);
- views.voicemailTranscriptionView.setVisibility(View.VISIBLE);
- } else {
- views.voicemailTranscriptionView.setText(null);
- views.voicemailTranscriptionView.setVisibility(View.GONE);
+ if (isVoicemail) {
+ views.voicemailTranscriptionView.setText(TextUtils.isEmpty(details.transcription) ? null
+ : details.transcription);
}
// Bold if not read
@@ -151,10 +152,14 @@ public class PhoneCallDetailsHelper {
views.nameView.setTypeface(typeface);
views.voicemailTranscriptionView.setTypeface(typeface);
views.callLocationAndDate.setTypeface(typeface);
+ views.callLocationAndDate.setTextColor(mResources.getColor(
+ details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color,
+ mContext.getTheme()));
}
/**
- * Builds a string containing the call location and date.
+ * Builds a string containing the call location and date. For voicemail logs only the call date
+ * is returned because location information is displayed in the call action button
*
* @param details The call details.
* @return The call location and date string.
@@ -162,15 +167,18 @@ public class PhoneCallDetailsHelper {
private CharSequence getCallLocationAndDate(PhoneCallDetails details) {
mDescriptionItems.clear();
- // Get type of call (ie mobile, home, etc) if known, or the caller's location.
- CharSequence callTypeOrLocation = getCallTypeOrLocation(details);
+ if (details.callTypes[0] != Calls.VOICEMAIL_TYPE) {
+ // Get type of call (ie mobile, home, etc) if known, or the caller's location.
+ CharSequence callTypeOrLocation = getCallTypeOrLocation(details);
- // Only add the call type or location if its not empty. It will be empty for unknown
- // callers.
- if (!TextUtils.isEmpty(callTypeOrLocation)) {
- mDescriptionItems.add(callTypeOrLocation);
+ // Only add the call type or location if its not empty. It will be empty for unknown
+ // callers.
+ if (!TextUtils.isEmpty(callTypeOrLocation)) {
+ mDescriptionItems.add(callTypeOrLocation);
+ }
}
- // The date of this call, relative to the current time.
+
+ // The date of this call
mDescriptionItems.add(getCallDate(details));
// Create a comma separated list from the call type or location, and call date.
@@ -197,8 +205,8 @@ public class PhoneCallDetailsHelper {
} else if (!(details.numberType == Phone.TYPE_CUSTOM
&& TextUtils.isEmpty(details.numberLabel))) {
// Get type label only if it will not be "Custom" because of an empty number label.
- numberFormattedLabel = Phone.getTypeLabel(
- mResources, details.numberType, details.numberLabel);
+ numberFormattedLabel = MoreObjects.firstNonNull(mPhoneTypeLabelForTest,
+ Phone.getTypeLabel(mResources, details.numberType, details.numberLabel));
}
}
@@ -208,6 +216,11 @@ public class PhoneCallDetailsHelper {
return numberFormattedLabel;
}
+ @NeededForTesting
+ public void setPhoneTypeLabelForTest(CharSequence phoneTypeLabel) {
+ this.mPhoneTypeLabelForTest = phoneTypeLabel;
+ }
+
/**
* Get the call date/time of the call. For the call log this is relative to the current time.
* e.g. 3 minutes ago. For voicemail, see {@link #getGranularDateTime(PhoneCallDetails)}
diff --git a/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java
index 263642c96..b255edf1b 100644
--- a/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java
@@ -116,14 +116,14 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
// Voicemail date string has 3 different formats depending on how long ago the call was placed
public void testSetVoicemailPhoneCallDetails_Today() {
setVoicemailPhoneCallDetailsWithDate(System.currentTimeMillis());
- assertDateEquals("Today at");
+ assertLocationAndDateContains("Today at");
}
public void testSetVoicemailPhoneCallDetails_WithinCurrentYear() {
mHelper.setCurrentTimeForTest(INJECTED_CURRENT_DATE);
String formattedTestDate = "Jun 3 at 1:00 PM";
setVoicemailPhoneCallDetailsWithDate(TEST_DATE);
- assertDateEquals(formattedTestDate);
+ assertLocationAndDateContains(formattedTestDate);
}
public void testSetVoicemailPhoneCallDetails_OutsideCurrentYear() {
@@ -131,7 +131,12 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
long testDate = new GregorianCalendar(2009, 5, 3, 13, 0, 0).getTimeInMillis();
String formattedTestDate = "Jun 3, 2009 at 1:00 PM";
setVoicemailPhoneCallDetailsWithDate(testDate);
- assertDateEquals(formattedTestDate);
+ assertLocationAndDateContains(formattedTestDate);
+ }
+
+ public void testVoicemailLocationNotShownWithDate() {
+ setVoicemailPhoneCallDetailsWithDate(TEST_DATE);
+ assertLocationAndDateExactEquals("Jun 3 at 1:00 PM");
}
/** Asserts that a char sequence is actually a Spanned corresponding to the expected HTML. */
@@ -150,19 +155,19 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 3, 13, 0, 0).getTimeInMillis());
- assertDateEquals("0 min. ago");
+ assertLocationAndDateContains("0 min. ago");
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 3, 12, 0, 0).getTimeInMillis());
- assertDateEquals("1 hr. ago");
+ assertLocationAndDateContains("1 hr. ago");
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 2, 13, 0, 0).getTimeInMillis());
- assertDateEquals("Yesterday");
+ assertLocationAndDateContains("Yesterday");
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 1, 13, 0, 0).getTimeInMillis());
- assertDateEquals("2 days ago");
+ assertLocationAndDateContains("2 days ago");
}
public void testSetPhoneCallDetails_CallTypeIcons() {
@@ -232,24 +237,24 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
public void testSetPhoneCallDetails_Geocode() {
setPhoneCallDetailsWithNumberAndGeocode("+14125555555", "1-412-555-5555", "Pennsylvania");
assertNameEquals("1-412-555-5555"); // The phone number is shown as the name.
- assertLabelEquals("Pennsylvania"); // The geocode is shown as the label.
+ assertLocationAndDateContains("Pennsylvania"); // The geocode is shown as the label.
}
public void testSetPhoneCallDetails_NoGeocode() {
setPhoneCallDetailsWithNumberAndGeocode("+14125555555", "1-412-555-5555", null);
assertNameEquals("1-412-555-5555"); // The phone number is shown as the name.
- assertLabelEquals(EMPTY_GEOCODE); // The empty geocode is shown as the label.
+ assertLocationAndDateContains(EMPTY_GEOCODE); // The empty geocode is shown as the label.
}
public void testSetPhoneCallDetails_EmptyGeocode() {
setPhoneCallDetailsWithNumberAndGeocode("+14125555555", "1-412-555-5555", "");
assertNameEquals("1-412-555-5555"); // The phone number is shown as the name.
- assertLabelEquals(EMPTY_GEOCODE); // The empty geocode is shown as the label.
+ assertLocationAndDateContains(EMPTY_GEOCODE); // The empty geocode is shown as the label.
}
public void testSetPhoneCallDetails_NoGeocodeForVoicemail() {
setPhoneCallDetailsWithNumberAndGeocode(TEST_VOICEMAIL_NUMBER, "", "United States");
- assertLabelEquals(EMPTY_GEOCODE); // The empty geocode is shown as the label.
+ assertLocationAndDateContains(EMPTY_GEOCODE); // The empty geocode is shown as the label.
}
public void testSetPhoneCallDetails_Highlighted() {
@@ -297,6 +302,25 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
assertEquals("John Doe", mNameView.getText().toString());
}
+ public void testGetCallTypeOrLocation_Geocode() {
+ assertEquals(TEST_GEOCODE, mHelper.getCallTypeOrLocation(getPhoneCallDetails()));
+ }
+
+ public void testGetCallTypeOrLocation_CallType() {
+ PhoneCallDetails details = getPhoneCallDetails();
+ details.geocode = null;
+ details.numberType = Calls.INCOMING_TYPE;
+ mHelper.setPhoneTypeLabelForTest("mobile");
+ assertEquals("mobile", mHelper.getCallTypeOrLocation(details));
+ }
+
+ public void testGetCallTypeOrLocation_DisplayNumber() {
+ PhoneCallDetails details = getPhoneCallDetails("", Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER);
+ details.name = "name";
+ assertEquals(TEST_FORMATTED_NUMBER, mHelper.getCallTypeOrLocation(details));
+ }
+
/** Asserts that the name text field contains the value of the given string resource. */
private void assertNameEqualsResource(int resId) {
assertNameEquals(getContext().getString(resId));
@@ -307,14 +331,14 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
assertEquals(text, mViews.nameView.getText().toString());
}
- /** Asserts that the label text field contains the given string value. */
- private void assertLabelEquals(String text) {
+ /** Asserts that the location and date text field contains the given string value. */
+ private void assertLocationAndDateContains(String text) {
assertTrue(mViews.callLocationAndDate.getText().toString().contains(text));
}
- /** Asserts that the date text field contains the given string value. */
- private void assertDateEquals(String text) {
- assertTrue(mViews.callLocationAndDate.getText().toString().contains(text));
+ /** Asserts that the location and date text field exactly equals the given string value. */
+ private void assertLocationAndDateExactEquals(String text) {
+ assertEquals(text, mViews.callLocationAndDate.getText());
}
/** Asserts that the video icon is shown. */