diff options
-rw-r--r-- | res/layout/blocked_number_header.xml | 68 | ||||
-rw-r--r-- | res/values/colors.xml | 6 | ||||
-rw-r--r-- | res/values/dimens.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 58 | ||||
-rw-r--r-- | res/values/styles.xml | 13 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 6 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogGroupBuilder.java | 25 | ||||
-rw-r--r-- | src/com/android/dialer/list/RegularSearchFragment.java | 54 | ||||
-rw-r--r-- | tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java | 44 |
9 files changed, 221 insertions, 57 deletions
diff --git a/res/layout/blocked_number_header.xml b/res/layout/blocked_number_header.xml index fed94cc37..95880a7c0 100644 --- a/res/layout/blocked_number_header.xml +++ b/res/layout/blocked_number_header.xml @@ -14,27 +14,67 @@ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" android:layout_width="match_parent" + android:orientation="vertical" + android:layout_width="match_parent" android:layout_height="wrap_content"> - <TextView - android:id="@+id/textView" + <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/blockList" - android:paddingStart="@dimen/blocked_number_horizontal_margin" - android:paddingTop="@dimen/blocked_number_top_margin" - android:paddingBottom="@dimen/blocked_number_bottom_margin" - android:textColor="@color/blocked_number_accent_color" + android:textColor="@color/blocked_number_header_color" + android:padding="@dimen/blocked_number_container_padding" style="@android:style/TextAppearance.Material.Subhead" /> - <Button - android:id="@+id/add_number_button" + <RelativeLayout android:id="@+id/importsettings" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone"> + + <TextView android:id="@+id/import_description" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/blocked_call_settings_import_description" + android:textSize="@dimen/blocked_number_settings_description_text_size" + android:lineSpacingMultiplier="1.2" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:paddingStart="@dimen/blocked_number_container_padding" + android:paddingEnd="@dimen/blocked_number_container_padding" /> + + <Button android:id="@+id/import_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/import_description" + android:layout_alignParentEnd="true" + android:layout_marginEnd="@dimen/blocked_number_container_padding" + android:text="@string/blocked_call_settings_import_button" + style="@style/DialerFlatButtonStyle" /> + + <Button android:id="@+id/view_numbers_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/import_description" + android:layout_toLeftOf="@id/import_button" + android:text="@string/blocked_call_settings_view_numbers_button" + style="@style/DialerFlatButtonStyle" /> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_below="@id/import_button" + android:background="@color/divider_line_color" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" /> + + </RelativeLayout> + + <Button android:id="@+id/add_number_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/blockNumber" - android:layout_gravity="right" - android:textColor="@color/blocked_number_accent_color" - style="?android:attr/borderlessButtonStyle" /> + android:layout_gravity="end" + android:layout_marginEnd="@dimen/blocked_number_container_padding" + android:layout_marginTop="8dp" + android:text="@string/blockNumber" /> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/res/values/colors.xml b/res/values/colors.xml index f0765bab9..55970d9e4 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -22,6 +22,9 @@ <color name="dialer_red_highlight_color">#ff1744</color> <color name="dialer_green_highlight_color">#00c853</color> + <color name="dialer_button_text_color">#fff</color> + <color name="dialer_flat_button_text_color">@color/dialer_theme_color</color> + <!-- Color for the setting text. --> <color name="setting_primary_color">@color/dialtacts_primary_text_color</color> <!-- Color for the setting description text. --> @@ -105,6 +108,7 @@ <color name="floating_action_button_touch_tint">#80ffffff</color> <color name="call_log_action_divider">#eeeeee</color> + <color name="divider_line_color">#c7c7c7</color> <!-- Colors for blocked numbers list --> <color name="blocked_number_primary_text_color">@color/dialtacts_primary_text_color</color> @@ -113,9 +117,11 @@ <color name="blocked_number_background">#E0E0E0</color> <color name="blocked_number_accent_color">#42A5F5</color> <color name="blocked_number_block_color">#F44336</color> + <color name="blocked_number_header_color">@color/dialer_theme_color</color> <!-- Colors for onboarding flow --> <color name="onboarding_primary_text_color">#ffffff</color> <color name="onboarding_default_dialer_screen_background_color">#e06055</color> <color name="onboarding_permissions_screen_background_color">#689f38</color> + </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 093e80f0c..38e4d0e6e 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -15,6 +15,8 @@ ~ limitations under the License --> <resources> + <dimen name="button_horizontal_padding">16dp</dimen> + <!-- Drag to remove view (in dp because it is used in conjunction with a statically sized icon @@ -147,6 +149,7 @@ <dimen name="voicemail_playback_top_padding">12dp</dimen> <!-- Size of entries in blocked numbers list --> + <dimen name="blocked_number_container_padding">16dp</dimen> <dimen name="blocked_number_horizontal_margin">16dp</dimen> <dimen name="blocked_number_top_margin">16dp</dimen> <dimen name="blocked_number_bottom_margin">16dp</dimen> @@ -154,6 +157,7 @@ <dimen name="blocked_number_secondary_text_size">12sp</dimen> <dimen name="blocked_number_delete_icon_size">32dp</dimen> <dimen name="blocked_number_search_text_size">14sp</dimen> + <dimen name="blocked_number_settings_description_text_size">16sp</dimen> <dimen name="call_type_icon_size">12dp</dimen> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index b2621cd9e..3f4b9e2a6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -833,6 +833,21 @@ <!-- Label for the blocked calls settings section [CHAR LIMIT=30] --> <string name="blocked_calls_settings_label">Spam and blocked calls</string> + <!-- Text informing the user they have previously marked contacts to be sent to voicemail. + This will be followed by two buttons, 1) to view who is marked to be sent to voicemail + and 2) importing these settings to Dialer's block list. [CHAR LIMIT=NONE] --> + <string name="blocked_call_settings_import_description"> + You previously marked some callers to be automatically sent to voicemail via other apps. + </string> + + <!-- Labe for button to view numbers of contacts previous marked to be sent to voicemail. + [CHAR_LIMIT=20] --> + <string name="blocked_call_settings_view_numbers_button">View Numbers</string> + + <!-- Label for button to import settings for sending contacts to voicemail into Dialer's block + list. [CHAR_LIMIT=20] --> + <string name="blocked_call_settings_import_button">Import</string> + <!-- String describing the delete icon on a blocked number list item. When tapped, it will show a dialog confirming the unblocking of the number. [CHAR LIMIT=NONE]--> @@ -876,48 +891,51 @@ <!-- DO NOT TRANSLATE. Internal key for DTMF tone length preference. --> <string name="dtmf_tone_length_preference_key" translatable="false">button_dtmf_settings</string> - <!-- The label of the button used to turn on a single permission --> + <!-- The label of the button used to turn on a single permission [CHAR LIMIT=30]--> <string name="permission_single_turn_on">Turn on</string> - <!-- The label of the button used to turn on multiple permissions --> + <!-- The label of the button used to turn on multiple permissions [CHAR LIMIT=30]--> <string name="permission_multiple_turn_on">Set permissions</string> - <!-- Shown as a prompt to turn on the contacts permission to enable speed dial --> - <string name="permission_no_speeddial">To enable speed dial,\n turn on the Contacts permission.</string> + <!-- Shown as a prompt to turn on the contacts permission to enable speed dial [CHAR LIMIT=NONE]--> + <string name="permission_no_speeddial">To enable speed dial, turn on the Contacts permission.</string> - <!-- Shown as a prompt to turn on the phone permission to enable the call log --> - <string name="permission_no_calllog">To see your call log,\n turn on the Phone permission.</string> + <!-- Shown as a prompt to turn on the phone permission to enable the call log [CHAR LIMIT=NONE]--> + <string name="permission_no_calllog">To see your call log, turn on the Phone permission.</string> - <!-- Shown as a prompt to turn on the contacts permission to show all contacts --> - <string name="permission_no_contacts">To see your contacts,\n turn on the Contacts permission.</string> + <!-- Shown as a prompt to turn on the contacts permission to show all contacts [CHAR LIMIT=NONE]--> + <string name="permission_no_contacts">To see your contacts, turn on the Contacts permission.</string> - <!-- Shown as a prompt to turn on the phone permission to show voicemails --> - <string name="permission_no_voicemail">To access your voicemail,\n turn on the Phone permission.</string> + <!-- Shown as a prompt to turn on the phone permission to show voicemails [CHAR LIMIT=NONE]--> + <string name="permission_no_voicemail">To access your voicemail, turn on the Phone permission.</string> - <!-- Shown as a prompt to turn on contacts permissions to allow contact search --> + <!-- Shown as a prompt to turn on contacts permissions to allow contact search [CHAR LIMIT=NONE]--> <string name="permission_no_search">To search your contacts, turn on the Contacts permissions.</string> - <!-- Shown as a prompt to turn on the phone permission to allow a call to be placed --> - <string name="permission_place_call">To place a call,\n turn on the Phone permission.</string> + <!-- Shown as a prompt to turn on location permissions and/or enable location to allow nearby places search [CHAR LIMIT=NONE]--> + <string name="permission_no_location_for_search">To search nearby locations, allow Phone to access your location.</string> + + <!-- Shown as a prompt to turn on the phone permission to allow a call to be placed [CHAR LIMIT=NONE]--> + <string name="permission_place_call">To place a call, turn on the Phone permission.</string> - <!-- Shown as a message that notifies the user that the Phone app cannot write to system settings, which is why the system settings app is being launched directly instead.--> + <!-- Shown as a message that notifies the user that the Phone app cannot write to system settings, which is why the system settings app is being launched directly instead. [CHAR LIMIT=NONE]--> <string name="toast_cannot_write_system_settings">Phone app does not have permission to write to system settings.</string> - <!-- Title of the onboarding screen that asks the user to make Phone the default Phone app --> + <!-- Title of the onboarding screen that asks the user to make Phone the default Phone app [CHAR LIMIT=NONE]--> <string name="request_default_dialer_screen_title">A better way of calling is calling</string> - <!-- Content of the onboarding screen that asks the user to make Phone the default Phone app --> + <!-- Content of the onboarding screen that asks the user to make Phone the default Phone app [CHAR LIMIT=NONE]--> <string name="request_default_dialer_screen_content">Make Phone your default phone app to be able to do things like see who\'s calling you, even when they\'re not in your contacts.</string> - <!-- Title of the onboarding screen that asks the user to grant us the Contacts and Phone permissions --> + <!-- Title of the onboarding screen that asks the user to grant us the Contacts and Phone permissions [CHAR LIMIT=NONE]--> <string name="request_permissions_screen_title">Get talking to your friends and family</string> - <!-- Content of the onboarding screen that asks the user to grant us the Contacts and Phone permissions --> + <!-- Content of the onboarding screen that asks the user to grant us the Contacts and Phone permissions [CHAR LIMIT=NONE]--> <string name="request_permissions_screen_content">Phone will need to access your phone and contacts to make calls to people in your contacts.</string> - <!-- The label of the button used to skip a screen in the onboarding flow --> + <!-- The label of the button used to skip a screen in the onboarding flow [CHAR LIMIT=30]--> <string name="onboarding_skip_button">Skip</string> - <!-- The label of the button used to go to the next screen in the onboarding flow --> + <!-- The label of the button used to go to the next screen in the onboarding flow [CHAR LIMIT=30]--> <string name="onboarding_next_button">Next</string> </resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index 86c3ad47d..005fd4587 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -83,6 +83,12 @@ <item name="android:colorPrimaryDark">@color/dialer_theme_color_dark</item> <item name="dialpad_key_button_touch_tint">@color/dialer_dialpad_touch_tint</item> <item name="android:colorControlActivated">@color/dialer_theme_color</item> + <item name="android:colorButtonNormal">@color/dialer_theme_color</item> + <item name="android:textAppearanceButton">@style/DialerButtonTextStyle</item> + </style> + + <style name="DialerButtonTextStyle" parent="@android:style/TextAppearance.Material.Widget.Button"> + <item name="android:textColor">#fff</item> </style> <!-- Action bar overflow menu icon. --> @@ -278,4 +284,11 @@ <item name="android:background">@drawable/oval_ripple</item> <item name="android:padding">8dp</item> </style> + + <style name="DialerFlatButtonStyle" parent="@android:style/Widget.Material.Button"> + <item name="android:background">?android:attr/selectableItemBackground</item> + <item name="android:paddingEnd">@dimen/button_horizontal_padding</item> + <item name="android:paddingStart">@dimen/button_horizontal_padding</item> + <item name="android:textColor">@color/dialer_flat_button_text_color</item> + </style> </resources> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 455b09758..4bfd56594 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -110,6 +110,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O ListsFragment.HostInterface, SpeedDialFragment.HostInterface, SearchFragment.HostInterface, + RegularSearchFragment.HostInterface, OnDragDropListener, OnPhoneNumberPickerActionListener, PopupMenu.OnMenuItemClickListener, @@ -870,6 +871,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } } + @Override + public boolean isNearbyPlacesSearchEnabled() { + return false; + } + protected int getSearchBoxHint () { return R.string.dialer_hint_find_contact; } diff --git a/src/com/android/dialer/calllog/CallLogGroupBuilder.java b/src/com/android/dialer/calllog/CallLogGroupBuilder.java index 4cf2d07cd..5eea096b8 100644 --- a/src/com/android/dialer/calllog/CallLogGroupBuilder.java +++ b/src/com/android/dialer/calllog/CallLogGroupBuilder.java @@ -24,6 +24,7 @@ import android.text.TextUtils; import com.android.contacts.common.util.DateUtils; import com.android.contacts.common.util.PhoneNumberHelper; +import com.android.dialer.util.AppCompatConstants; import com.google.common.annotations.VisibleForTesting; @@ -145,10 +146,11 @@ public class CallLogGroupBuilder { final boolean isSameAccount = isSameAccount( groupAccountComponentName, accountComponentName, groupAccountId, accountId); - // Group with the same number and account which are not voicemail. - if (isSameNumber && isSameAccount - && (callType != Calls.VOICEMAIL_TYPE) - && (groupCallType != Calls.VOICEMAIL_TYPE)) { + // Group with the same number and account. Never group voicemails. Only group blocked + // calls with other blocked calls. + if (isSameNumber && isSameAccount && areBothNotVoicemail(callType, groupCallType) + && (areBothNotBlocked(callType, groupCallType) + || areBothBlocked(callType, groupCallType))) { // Increment the size of the group to include the current call, but do not create // the group until finding a call that does not match. groupSize++; @@ -240,4 +242,19 @@ public class CallLogGroupBuilder { return DAY_GROUP_OTHER; } } + + private boolean areBothNotVoicemail(int callType, int groupCallType) { + return callType != AppCompatConstants.CALLS_VOICEMAIL_TYPE + && groupCallType != AppCompatConstants.CALLS_VOICEMAIL_TYPE; + } + + private boolean areBothNotBlocked(int callType, int groupCallType) { + return callType != AppCompatConstants.CALLS_BLOCKED_TYPE + && groupCallType != AppCompatConstants.CALLS_BLOCKED_TYPE; + } + + private boolean areBothBlocked(int callType, int groupCallType) { + return callType == AppCompatConstants.CALLS_BLOCKED_TYPE + && groupCallType == AppCompatConstants.CALLS_BLOCKED_TYPE; + } } diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java index ec771e8ef..0b8703399 100644 --- a/src/com/android/dialer/list/RegularSearchFragment.java +++ b/src/com/android/dialer/list/RegularSearchFragment.java @@ -16,6 +16,7 @@ package com.android.dialer.list; import static android.Manifest.permission.READ_CONTACTS; +import static android.Manifest.permission.ACCESS_FINE_LOCATION; import android.app.Activity; import android.content.pm.PackageManager; @@ -36,13 +37,19 @@ import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClicked public class RegularSearchFragment extends SearchFragment implements OnEmptyViewActionButtonClickedListener { - private static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1; + private static final int PERMISSION_REQUEST_CODE = 1; private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; private static final CachedNumberLookupService mCachedNumberLookupService = ObjectFactory.newCachedNumberLookupService(); + public interface HostInterface { + public boolean isNearbyPlacesSearchEnabled(); + } + + private String mPermissionToRequest; + public RegularSearchFragment() { configureDirectorySearch(); } @@ -64,6 +71,7 @@ public class RegularSearchFragment extends SearchFragment ((PinnedHeaderListView) getListView()).setScrollToSectionOnHeaderTouch(true); } + @Override protected ContactEntryListAdapter createListAdapter() { RegularSearchListAdapter adapter = new RegularSearchListAdapter(getActivity()); adapter.setDisplayPhotos(true); @@ -84,15 +92,36 @@ public class RegularSearchFragment extends SearchFragment @Override protected void setupEmptyView() { if (mEmptyView != null && getActivity() != null) { + final int imageResource; + final int actionLabelResource; + final int descriptionResource; + final OnEmptyViewActionButtonClickedListener listener; if (!PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) { - mEmptyView.setImage(R.drawable.empty_contacts); - mEmptyView.setActionLabel(R.string.permission_single_turn_on); - mEmptyView.setDescription(R.string.permission_no_search); - mEmptyView.setActionClickedListener(this); + imageResource = R.drawable.empty_contacts; + actionLabelResource = R.string.permission_single_turn_on; + descriptionResource = R.string.permission_no_search; + listener = this; + mPermissionToRequest = READ_CONTACTS; + } else if (((HostInterface) getActivity()).isNearbyPlacesSearchEnabled() + && !PermissionsUtil.hasPermission(getActivity(), ACCESS_FINE_LOCATION)) { + imageResource = R.drawable.empty_contacts; + actionLabelResource = R.string.permission_single_turn_on; + descriptionResource = R.string.permission_no_location_for_search; + listener = this; + mPermissionToRequest = ACCESS_FINE_LOCATION; } else { - mEmptyView.setImage(EmptyContentView.NO_IMAGE); - mEmptyView.setActionLabel(EmptyContentView.NO_LABEL); - mEmptyView.setDescription(EmptyContentView.NO_LABEL); + imageResource = EmptyContentView.NO_IMAGE; + actionLabelResource = EmptyContentView.NO_LABEL; + descriptionResource = EmptyContentView.NO_LABEL; + listener = null; + mPermissionToRequest = null; + } + + mEmptyView.setImage(imageResource); + mEmptyView.setActionLabel(actionLabelResource); + mEmptyView.setDescription(descriptionResource); + if (listener != null) { + mEmptyView.setActionClickedListener(listener); } } } @@ -104,17 +133,20 @@ public class RegularSearchFragment extends SearchFragment return; } - requestPermissions(new String[] {READ_CONTACTS}, READ_CONTACTS_PERMISSION_REQUEST_CODE); + if (READ_CONTACTS.equals(mPermissionToRequest) + || ACCESS_FINE_LOCATION.equals(mPermissionToRequest)) { + requestPermissions(new String[] {mPermissionToRequest}, PERMISSION_REQUEST_CODE); + } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - if (requestCode == READ_CONTACTS_PERMISSION_REQUEST_CODE) { + if (requestCode == PERMISSION_REQUEST_CODE) { setupEmptyView(); if (grantResults != null && grantResults.length == 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) { - PermissionsUtil.notifyPermissionGranted(getActivity(), READ_CONTACTS); + PermissionsUtil.notifyPermissionGranted(getActivity(), mPermissionToRequest); } } } diff --git a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java index f5a9fe612..5d0b6bebb 100644 --- a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java @@ -95,7 +95,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase { assertGroupIs(0, 3, mFakeGroupCreator.groups.get(0)); } - public void testAddGroups_Voicemail() { + public void testGrouping_Voicemail() { // Does not group with other types of calls, include voicemail themselves. assertCallsAreNotGrouped( AppCompatConstants.CALLS_VOICEMAIL_TYPE, AppCompatConstants.CALLS_MISSED_TYPE); @@ -107,7 +107,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase { AppCompatConstants.CALLS_VOICEMAIL_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE); } - public void testAddGroups_Missed() { + public void testGrouping_Missed() { // Groups with one or more missed calls. assertCallsAreGrouped( AppCompatConstants.CALLS_MISSED_TYPE, AppCompatConstants.CALLS_MISSED_TYPE); @@ -124,7 +124,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase { AppCompatConstants.CALLS_MISSED_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE); } - public void testAddGroups_Incoming() { + public void testGrouping_Incoming() { // Groups with one or more incoming or outgoing. assertCallsAreGrouped( AppCompatConstants.CALLS_INCOMING_TYPE, AppCompatConstants.CALLS_INCOMING_TYPE); @@ -145,7 +145,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase { AppCompatConstants.CALLS_INCOMING_TYPE, AppCompatConstants.CALLS_VOICEMAIL_TYPE); } - public void testAddGroups_Outgoing() { + public void testGrouping_Outgoing() { // Groups with one or more incoming or outgoing. assertCallsAreGrouped( AppCompatConstants.CALLS_OUTGOING_TYPE, AppCompatConstants.CALLS_INCOMING_TYPE); @@ -166,20 +166,31 @@ public class CallLogGroupBuilderTest extends AndroidTestCase { AppCompatConstants.CALLS_INCOMING_TYPE, AppCompatConstants.CALLS_VOICEMAIL_TYPE); } + public void testGrouping_Blocked() { + assertCallsAreNotGrouped( + AppCompatConstants.CALLS_BLOCKED_TYPE, AppCompatConstants.CALLS_INCOMING_TYPE); + assertCallsAreNotGrouped( + AppCompatConstants.CALLS_BLOCKED_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE); + assertCallsAreNotGrouped( + AppCompatConstants.CALLS_BLOCKED_TYPE, AppCompatConstants.CALLS_MISSED_TYPE); + + } + public void testAddGroups_Mixed() { addMultipleCallLogEntries(TEST_NUMBER1, - AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 1:Stand-alone + AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 1: 0 AppCompatConstants.CALLS_INCOMING_TYPE, // Group 2: 1-4 AppCompatConstants.CALLS_OUTGOING_TYPE, AppCompatConstants.CALLS_MISSED_TYPE, AppCompatConstants.CALLS_MISSED_TYPE, - AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 3: Stand-alone - AppCompatConstants.CALLS_INCOMING_TYPE, // Group 4: Stand-alone - AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 5: Stand-alone + AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 3: 5 + AppCompatConstants.CALLS_INCOMING_TYPE, // Group 4: 6 + AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 5: 7 AppCompatConstants.CALLS_MISSED_TYPE, // Group 6: 8-10 AppCompatConstants.CALLS_MISSED_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE); mBuilder.addGroups(mCursor); + assertEquals(6, mFakeGroupCreator.groups.size()); assertGroupIs(0, 1, mFakeGroupCreator.groups.get(0)); assertGroupIs(1, 4, mFakeGroupCreator.groups.get(1)); @@ -189,6 +200,23 @@ public class CallLogGroupBuilderTest extends AndroidTestCase { assertGroupIs(8, 3, mFakeGroupCreator.groups.get(5)); } + public void testAddGroups_Blocked() { + addMultipleCallLogEntries(TEST_NUMBER1, + AppCompatConstants.CALLS_INCOMING_TYPE, // Group 1: 0-1 + AppCompatConstants.CALLS_OUTGOING_TYPE, + AppCompatConstants.CALLS_BLOCKED_TYPE, // Group 2: 2 + AppCompatConstants.CALLS_MISSED_TYPE, // Group 3: 3 + AppCompatConstants.CALLS_BLOCKED_TYPE, // Group 4: 4-5 + AppCompatConstants.CALLS_BLOCKED_TYPE); + mBuilder.addGroups(mCursor); + + assertEquals(4, mFakeGroupCreator.groups.size()); + assertGroupIs(0, 2, mFakeGroupCreator.groups.get(0)); + assertGroupIs(2, 1, mFakeGroupCreator.groups.get(1)); + assertGroupIs(3, 1, mFakeGroupCreator.groups.get(2)); + assertGroupIs(4, 2, mFakeGroupCreator.groups.get(3)); + } + public void testEqualPhoneNumbers() { // Identical. assertTrue(mBuilder.equalNumbers("6505555555", "6505555555")); |