Dedup NANPA numbers
Bug:7519057
Change-Id: Ia1b1e2632771f718b6e89f9d67834a7b646c45fa
diff --git a/src/com/android/contacts/ContactsUtils.java b/src/com/android/contacts/ContactsUtils.java
index b68109e..6b7114c 100644
--- a/src/com/android/contacts/ContactsUtils.java
+++ b/src/com/android/contacts/ContactsUtils.java
@@ -32,7 +32,6 @@
public class ContactsUtils {
private static final String TAG = "ContactsUtils";
- private static final String WAIT_SYMBOL_AS_STRING = String.valueOf(PhoneNumberUtils.WAIT);
private static int sThumbnailSize = -1;
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index ba502c7..c07ce6b 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -1311,12 +1311,7 @@
}
@Override
- public boolean collapseWith(DetailViewEntry entry) {
- // assert equal collapse keys
- if (!shouldCollapseWith(entry)) {
- return false;
- }
-
+ public void collapseWith(DetailViewEntry entry) {
// Choose the label associated with the highest type precedence.
if (TypePrecedence.getTypePrecedence(mimetype, type)
> TypePrecedence.getTypePrecedence(entry.mimetype, entry.type)) {
@@ -1342,7 +1337,6 @@
// Keep track of all the ids that have been collapsed with this one.
ids.add(entry.getId());
collapseCount++;
- return true;
}
@Override
diff --git a/src/com/android/contacts/quickcontact/DataAction.java b/src/com/android/contacts/quickcontact/DataAction.java
index 1bf332e..0750a1d 100644
--- a/src/com/android/contacts/quickcontact/DataAction.java
+++ b/src/com/android/contacts/quickcontact/DataAction.java
@@ -293,11 +293,8 @@
}
@Override
- public boolean collapseWith(Action other) {
- if (!shouldCollapseWith(other)) {
- return false;
- }
- return true;
+ public void collapseWith(Action other) {
+ // No-op
}
@Override
diff --git a/tests/src/com/android/contacts/ContactsUtilsTests.java b/tests/src/com/android/contacts/ContactsUtilsTests.java
index 49e9ddd..b3910c9 100644
--- a/tests/src/com/android/contacts/ContactsUtilsTests.java
+++ b/tests/src/com/android/contacts/ContactsUtilsTests.java
@@ -135,6 +135,22 @@
Phone.CONTENT_ITEM_TYPE, "+49 (89) 12345678",
Phone.CONTENT_ITEM_TYPE, "+49 (89) 12345679");
+ // test special handling of collapsing country code for NANP region only
+ // This is non symmetrical, because we prefer the number with the +1.
+ assertEquals("75", true,
+ MoreContactUtils.shouldCollapse
+ (Phone.CONTENT_ITEM_TYPE, "+1 (415) 555-1212",
+ Phone.CONTENT_ITEM_TYPE, "(415) 555-1212"));
+ assertEquals("76", false,
+ MoreContactUtils.shouldCollapse
+ (Phone.CONTENT_ITEM_TYPE, "(415) 555-1212",
+ Phone.CONTENT_ITEM_TYPE, "+1 (415) 555-1212"));
+ // Require explicit +1 country code declaration to collapse
+ assertEquals("77", false,
+ MoreContactUtils.shouldCollapse
+ (Phone.CONTENT_ITEM_TYPE, "1-415-555-1212",
+ Phone.CONTENT_ITEM_TYPE, "415-555-1212"));
+
// test some numbers with wait symbol and area code
assertCollapses("80", true,
Phone.CONTENT_ITEM_TYPE, "+49 (8092) 1234;89321",
@@ -165,19 +181,26 @@
Phone.CONTENT_ITEM_TYPE, "---",
Phone.CONTENT_ITEM_TYPE, "---");
- assertCollapses("90", true,
+ assertCollapses("90", false,
Phone.CONTENT_ITEM_TYPE, "1-/().",
Phone.CONTENT_ITEM_TYPE, "--$%1");
- assertCollapses("91", true,
- Phone.CONTENT_ITEM_TYPE, "abcdefghijklmnopqrstuvwxyz",
- Phone.CONTENT_ITEM_TYPE, "22233344455566677778889999");
+ // Test numbers using keypad letters. This is non-symmetrical, because we prefer
+ // the version with letters.
+ assertEquals("91", true,
+ MoreContactUtils.shouldCollapse
+ (Phone.CONTENT_ITEM_TYPE, "abcdefghijklmnopqrstuvwxyz",
+ Phone.CONTENT_ITEM_TYPE, "22233344455566677778889999"));
+ assertEquals("92", false,
+ MoreContactUtils.shouldCollapse
+ (Phone.CONTENT_ITEM_TYPE, "22233344455566677778889999",
+ Phone.CONTENT_ITEM_TYPE, "abcdefghijklmnopqrstuvwxyz"));
- assertCollapses("92", false,
+ assertCollapses("93", false,
Phone.CONTENT_ITEM_TYPE, "1;2",
Phone.CONTENT_ITEM_TYPE, "12");
- assertCollapses("93", false,
+ assertCollapses("94", false,
Phone.CONTENT_ITEM_TYPE, "1,2",
Phone.CONTENT_ITEM_TYPE, "12");
}