diff options
author | Tyler Gunn <tgunn@google.com> | 2014-05-12 10:52:32 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2014-05-12 10:52:32 -0700 |
commit | d0715acdfc1aee0c20950741dc15d30abd18d2f2 (patch) | |
tree | 57b790a13a5242850c6e464aa866689486d87d33 | |
parent | 861fd2a2737051843582c4261567342016853868 (diff) |
Removing highlighting of missed calls and voicemails in the call log.
Also fixing some broken unit tests.
Bug: 13962594
Change-Id: I3ca2d72b3013b6324da19717dbc984f3e7e576e2
7 files changed, 53 insertions, 69 deletions
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java index edd083117..ab599725e 100644 --- a/src/com/android/dialer/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/PhoneCallDetailsHelper.java @@ -75,8 +75,7 @@ public class PhoneCallDetailsHelper { } /** Fills the call details views with content. */ - public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details, - boolean isHighlighted) { + public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) { // Display up to a given number of icons. views.callTypeIcons.clear(); int count = details.callTypes.length; @@ -93,14 +92,11 @@ public class PhoneCallDetailsHelper { } else { callCount = null; } - // The color to highlight the count and date in, if any. This is based on the first call. - Integer highlightColor = - isHighlighted ? mCallTypeHelper.getHighlightedColor(details.callTypes[0]) : null; CharSequence callLocationAndDate = getCallLocationAndDate(details); // Set the call count, location and date. - setCallCountAndDate(views, callCount, callLocationAndDate, highlightColor); + setCallCountAndDate(views, callCount, callLocationAndDate); final CharSequence nameText; final CharSequence displayNumber = @@ -224,7 +220,7 @@ public class PhoneCallDetailsHelper { /** Sets the call count and date. */ private void setCallCountAndDate(PhoneCallDetailsViews views, Integer callCount, - CharSequence dateText, Integer highlightColor) { + CharSequence dateText) { // Combine the count (if present) and the date. final CharSequence text; if (callCount != null) { @@ -234,23 +230,6 @@ public class PhoneCallDetailsHelper { text = dateText; } - // Apply the highlight color if present. - final CharSequence formattedText; - if (highlightColor != null) { - formattedText = addBoldAndColor(text, highlightColor); - } else { - formattedText = text; - } - - views.callLocationAndDate.setText(formattedText); - } - - /** Creates a SpannableString for the given text which is bold and in the given color. */ - private CharSequence addBoldAndColor(CharSequence text, int color) { - int flags = Spanned.SPAN_INCLUSIVE_INCLUSIVE; - SpannableString result = new SpannableString(text); - result.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), flags); - result.setSpan(new ForegroundColorSpan(color), 0, text.length(), flags); - return result; + views.callLocationAndDate.setText(text); } } diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index a8cd72a39..44fad2225 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -28,7 +28,6 @@ import android.os.Message; import android.provider.CallLog.Calls; import android.provider.ContactsContract.PhoneLookup; import android.text.TextUtils; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -42,7 +41,6 @@ import com.android.common.widget.GroupingListAdapter; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.util.UriUtils; -import com.android.dialer.CallDetailActivity; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; @@ -55,7 +53,6 @@ import com.google.common.base.Objects; import java.util.HashMap; import java.util.LinkedList; -import java.util.Map; /** * Adapter class to fill in data for the Call Log. @@ -686,10 +683,7 @@ public class CallLogAdapter extends GroupingListAdapter duration, name, ntype, label, lookupUri, photoUri, sourceType); } - final boolean isNew = c.getInt(CallLogQuery.IS_READ) == 0; - // New items also use the highlighted version of the text. - final boolean isHighlighted = isNew; - mCallLogViewsHelper.setPhoneCallDetails(views, details, isHighlighted); + mCallLogViewsHelper.setPhoneCallDetails(views, details); int contactType = ContactPhotoManager.TYPE_DEFAULT; @@ -1080,6 +1074,19 @@ public class CallLogAdapter extends GroupingListAdapter false /* darkTheme */, true /* isCircular */, request); } + /** + * Bind a call log entry view for testing purposes. Also inflates the action view stub so + * unit tests can access the buttons contained within. + * + * @param view The current call log row. + * @param context The current context. + * @param cursor The cursor to bind from. + */ + @VisibleForTesting + void bindViewForTest(View view, Context context, Cursor cursor) { + bindStandAloneView(view, context, cursor); + inflateActionViewStub(view); + } /** * Sets whether processing of requests for contact details should be enabled. diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java index 81d1a2711..976726d28 100644 --- a/src/com/android/dialer/calllog/CallLogListItemHelper.java +++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java @@ -17,15 +17,12 @@ package com.android.dialer.calllog; import android.content.res.Resources; -import android.provider.CallLog; import android.provider.CallLog.Calls; import android.text.TextUtils; -import android.view.View; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; -import com.android.internal.util.CharSequences; /** * Helper class to fill in the views of a call log entry. @@ -56,12 +53,9 @@ import com.android.internal.util.CharSequences; * * @param views the views to populate * @param details the details of a phone call needed to fill in the data - * @param isHighlighted whether to use the highlight text for the call */ - public void setPhoneCallDetails(CallLogListItemViews views, PhoneCallDetails details, - boolean isHighlighted) { - mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details, - isHighlighted); + public void setPhoneCallDetails(CallLogListItemViews views, PhoneCallDetails details) { + mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details); // Set the accessibility text for the contact badge views.quickContactView.setContentDescription(getContactBadgeDescription(details)); diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index 879647f15..333769d7e 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -109,10 +109,15 @@ public final class CallLogListItemViews { @NeededForTesting public static CallLogListItemViews createForTest(Context context) { - return new CallLogListItemViews( + CallLogListItemViews views = new CallLogListItemViews( new QuickContactBadge(context), new View(context), PhoneCallDetailsViews.createForTest(context), new TextView(context)); + views.callBackButtonView = new TextView(context); + views.deleteButtonView = new TextView(context); + views.voicemailButtonView = new TextView(context); + views.actionsView = new View(context); + return views; } } diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java index 626ff1686..30fd0e2a7 100644 --- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java @@ -22,7 +22,6 @@ import android.provider.CallLog.Calls; import android.test.AndroidTestCase; import android.text.Html; import android.text.Spanned; -import android.util.Log; import android.view.View; import android.widget.TextView; @@ -293,8 +292,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, new PhoneCallDetails(number, presentation, formattedNumber, TEST_COUNTRY_ISO, TEST_GEOCODE, - new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION), - true); + new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION) + ); } /** Sets the phone call details with default values and the given number. */ @@ -303,8 +302,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, new PhoneCallDetails(number, Calls.PRESENTATION_ALLOWED, formattedNumber, TEST_COUNTRY_ISO, geocodedLocation, - new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION), - true); + new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION) + ); } /** Sets the phone call details with default values and the given date. */ @@ -312,8 +311,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { 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), - false); + new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION) + ); } /** Sets the phone call details with default values and the given call types using icons. */ @@ -321,8 +320,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, - callTypes, TEST_DATE, TEST_DURATION), - false); + callTypes, TEST_DATE, TEST_DURATION) + ); } private void setCallDetailsHeaderWithNumber(String number, int presentation) { diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java index a423cde21..2c0fe0e23 100644 --- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java @@ -182,7 +182,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insertPrivate(NOW, 0); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); } @MediumTest @@ -198,7 +198,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, TEST_NUMBER); @@ -212,7 +212,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme values[CallLogQuery.CACHED_FORMATTED_NUMBER] = TEST_FORMATTED_NUMBER; insertValues(values); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, TEST_FORMATTED_NUMBER); @@ -226,7 +226,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -239,7 +239,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues("sip:johndoe@gmail.com", NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -254,7 +254,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -269,7 +269,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_WORK, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -283,7 +283,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_CUSTOM, numberLabel); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -296,7 +296,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, ""); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertTrue(views.quickContactView.isEnabled()); @@ -307,7 +307,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertFalse(views.quickContactView.isEnabled()); @@ -318,7 +318,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); @@ -339,7 +339,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insertVoicemail(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindStandAloneView(view, getActivity(), mCursor); + mAdapter.bindViewForTest(view, getActivity(), mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); IntentProvider intentProvider = (IntentProvider) views.voicemailButtonView.getTag(); @@ -439,7 +439,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme if (null == mList[i]) { mList[i] = mAdapter.newStandAloneView(mActivity, mParentView); } - mAdapter.bindStandAloneView(mList[i], mActivity, mCursor); + mAdapter.bindViewForTest(mList[i], mActivity, mCursor); mCursor.moveToPrevious(); i++; } diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java index 15c16767c..96eefbc5d 100644 --- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java @@ -333,8 +333,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, new PhoneCallDetails(number, presentation, formattedNumber, TEST_COUNTRY_ISO, TEST_GEOCODE, - new int[]{ callType }, TEST_DATE, TEST_DURATION), - false); + new int[]{ callType }, TEST_DATE, TEST_DURATION) + ); } /** Sets the details of a phone call using the specified call type. */ @@ -342,8 +342,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, - types, TEST_DATE, TEST_DURATION), - false); + types, TEST_DATE, TEST_DURATION) + ); } /** Sets the details of an unread phone call using the specified call type. */ @@ -351,7 +351,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, - types, TEST_DATE, TEST_DURATION), - true); + types, TEST_DATE, TEST_DURATION) + ); } } |