Use simple TextView for call details header.
Instead of the using the more complex call_log_phone_call_details
layout, use just a text view, since all we want to show is the name (or
number) of the person who called.
Bug: 5099652
Change-Id: I408b5ffaeea09c0efe2631bd317d1ea640be294f
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index a4de03f..441cc6c 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -77,7 +77,8 @@
android:layout_alignTop="@id/photo_text_bar"
android:layout_marginRight="@dimen/call_log_outer_margin"
/>
- <RelativeLayout
+ <TextView
+ android:id="@+id/header_text"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_alignLeft="@id/photo_text_bar"
@@ -86,9 +87,10 @@
android:layout_alignBottom="@id/photo_text_bar"
android:layout_marginRight="@dimen/call_log_inner_margin"
android:layout_marginLeft="@dimen/call_detail_contact_name_margin"
- >
- <include layout="@layout/call_log_phone_call_details" />
- </RelativeLayout>
+ android:textColor="?attr/call_log_primary_text_color"
+ android:textSize="18sp"
+ android:singleLine="true"
+ />
<ImageButton
android:id="@+id/main_action_push_layer"
android:layout_width="match_parent"
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index d093453..cd5ba14 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -77,11 +77,10 @@
/** If we should immediately start playback of the voicemail, this extra will be set to true. */
public static final String EXTRA_VOICEMAIL_START_PLAYBACK = "EXTRA_VOICEMAIL_START_PLAYBACK";
- /** The views representing the details of a phone call. */
- private PhoneCallDetailsViews mPhoneCallDetailsViews;
private CallTypeHelper mCallTypeHelper;
private PhoneNumberHelper mPhoneNumberHelper;
private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
+ private TextView mHeaderTextView;
private ImageView mMainActionView;
private ImageButton mMainActionPushLayerView;
private ImageView mContactBackgroundView;
@@ -145,13 +144,13 @@
mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
mResources = getResources();
- mPhoneCallDetailsViews = PhoneCallDetailsViews.fromView(getWindow().getDecorView());
mCallTypeHelper = new CallTypeHelper(getResources());
mPhoneNumberHelper = new PhoneNumberHelper(mResources, getVoicemailNumber());
mPhoneCallDetailsHelper = new PhoneCallDetailsHelper(mResources, mCallTypeHelper,
mPhoneNumberHelper);
mVoicemailStatusHelper = new VoicemailStatusHelperImpl();
mAsyncQueryHandler = new CallDetailActivityQueryHandler(this);
+ mHeaderTextView = (TextView) findViewById(R.id.header_text);
mStatusMessageView = findViewById(R.id.voicemail_status);
mStatusMessageText = (TextView) findViewById(R.id.voicemail_status_message);
mStatusMessageAction = (TextView) findViewById(R.id.voicemail_status_action);
@@ -276,8 +275,7 @@
final Uri photoUri = details[0].photoUri;
// Set the details header, based on the first phone call.
- mPhoneCallDetailsHelper.setPhoneCallDetails(mPhoneCallDetailsViews,
- details[0], false, false, true);
+ mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, details[0]);
// Cache the details about the phone number.
final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
diff --git a/src/com/android/contacts/PhoneCallDetailsHelper.java b/src/com/android/contacts/PhoneCallDetailsHelper.java
index 8cdd0d0..08e6a56 100644
--- a/src/com/android/contacts/PhoneCallDetailsHelper.java
+++ b/src/com/android/contacts/PhoneCallDetailsHelper.java
@@ -28,6 +28,7 @@
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.View;
+import android.widget.TextView;
/**
* Helper class to fill in the views in {@link PhoneCallDetailsViews}.
@@ -59,7 +60,7 @@
/** Fills the call details views with content. */
public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details,
- boolean useIcons, boolean isHighlighted, boolean nameOnly) {
+ boolean useIcons, boolean isHighlighted) {
if (useIcons) {
views.callTypeIcons.clear();
int count = details.callTypes.length;
@@ -130,21 +131,22 @@
}
views.dateView.setText(shortDateText);
- views.dateView.setVisibility(View.VISIBLE);
views.nameView.setText(nameText);
- views.nameView.setVisibility(View.VISIBLE);
- // Do not show the number if it is not available. This happens if we have only the number,
- // in which case the number is shown in the name field instead.
- if (!TextUtils.isEmpty(numberText)) {
- views.numberView.setText(numberText);
- views.numberView.setVisibility(View.VISIBLE);
+ views.numberView.setText(numberText);
+ }
+
+ /** Sets the name in the text view for the given phone call. */
+ public void setPhoneCallName(TextView nameView, PhoneCallDetails details) {
+ final CharSequence nameText;
+ final CharSequence displayNumber =
+ mPhoneNumberHelper.getDisplayNumber(details.number, details.formattedNumber);
+ if (TextUtils.isEmpty(details.name)) {
+ nameText = displayNumber;
} else {
- views.numberView.setVisibility(View.GONE);
+ nameText = details.name;
}
- // Hide the rest if not visible.
- views.callTypeView.setVisibility(nameOnly ? View.GONE : View.VISIBLE);
- views.numberView.setVisibility(nameOnly ? View.GONE : View.VISIBLE);
+ nameView.setText(nameText);
}
public void setCurrentTimeForTest(long currentTimeMillis) {
diff --git a/src/com/android/contacts/calllog/CallLogListItemHelper.java b/src/com/android/contacts/calllog/CallLogListItemHelper.java
index d8184d2..a448399 100644
--- a/src/com/android/contacts/calllog/CallLogListItemHelper.java
+++ b/src/com/android/contacts/calllog/CallLogListItemHelper.java
@@ -54,7 +54,7 @@
public void setPhoneCallDetails(CallLogListItemViews views, PhoneCallDetails details,
boolean useIcons, boolean isHighlighted) {
mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details, useIcons,
- isHighlighted, false);
+ isHighlighted);
boolean canCall = mPhoneNumberHelper.canPlaceCallsTo(details.number);
boolean canPlay = details.callTypes[0] == Calls.VOICEMAIL_TYPE;
diff --git a/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java b/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java
index 0d371d8..21b9a6f 100644
--- a/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java
@@ -26,6 +26,7 @@
import android.provider.CallLog.Calls;
import android.test.AndroidTestCase;
import android.view.View;
+import android.widget.TextView;
import java.util.GregorianCalendar;
import java.util.Locale;
@@ -51,6 +52,7 @@
private PhoneCallDetailsHelper mHelper;
/** The views to fill. */
private PhoneCallDetailsViews mViews;
+ private TextView mNameView;
private PhoneNumberHelper mPhoneNumberHelper;
@Override
@@ -62,6 +64,7 @@
mPhoneNumberHelper = new PhoneNumberHelper(resources, TEST_VOICEMAIL_NUMBER);
mHelper = new PhoneCallDetailsHelper(resources, callTypeHelper, mPhoneNumberHelper);
mViews = PhoneCallDetailsViews.createForTest(context);
+ mNameView = new TextView(context);
}
@Override
@@ -197,12 +200,17 @@
}
}
- public void testSetPhoneCallDetails_NameOnly() {
- setPhoneCallDetailsNameOnly();
- assertEquals(View.VISIBLE, mViews.nameView.getVisibility());
- assertEquals(View.GONE, mViews.numberView.getVisibility());
- assertEquals(View.GONE, mViews.callTypeView.getVisibility());
- }
+ public void testSetPhoneName_NumberOnly() {
+ setPhoneCallNameWithNumberOnly();
+ assertEquals(View.VISIBLE, mNameView.getVisibility());
+ assertEquals(TEST_FORMATTED_NUMBER, mNameView.getText().toString());
+ }
+
+ public void testSetPhoneName() {
+ setPhoneCallName("John Doe");
+ assertEquals(View.VISIBLE, mNameView.getVisibility());
+ assertEquals("John Doe", mNameView.getText().toString());
+ }
/** Asserts that the name text field contains the value of the given string resource. */
private void assertNameEqualsResource(int resId) {
@@ -265,7 +273,7 @@
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(number, formattedNumber, TEST_COUNTRY_ISO,
new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION),
- false, false, false);
+ false, false);
}
/** Sets the phone call details with default values and the given date. */
@@ -273,7 +281,7 @@
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION),
- false, false, false);
+ false, false);
}
/** Sets the phone call details with default values and the given call types using icons. */
@@ -290,13 +298,19 @@
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
callTypes, TEST_DATE, TEST_DURATION),
- useIcons, false, false);
+ useIcons, false);
}
- private void setPhoneCallDetailsNameOnly() {
- mHelper.setPhoneCallDetails(mViews,
+ private void setPhoneCallNameWithNumberOnly() {
+ mHelper.setPhoneCallName(mNameView,
new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION),
- true, false, true);
+ new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION));
+ }
+
+ private void setPhoneCallName(String name) {
+ mHelper.setPhoneCallName(mNameView,
+ new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
+ new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION,
+ name, 0, "", 1, null));
}
}