Dialer: Don't show the same number twice
* There was already an attempt to hide duplicates but it operated on
the basis that the results were exactly the same
* In reality I get to choose the main number twice since it's somehow
returned with and without spaces
* Normalizing the numbers resolves that
Change-Id: Iff89a668f0473e99cf4660927b495f7c5bfb1dfb
diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
index 4d268f3..c6a6150 100644
--- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
+++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
@@ -23,6 +23,7 @@
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.support.annotation.Nullable;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.ArraySet;
import com.android.dialer.common.Assert;
@@ -129,8 +130,9 @@
Set<String> numbers = new ArraySet<>();
do {
String number = cursor.getString(NUMBER);
+ String normalizedNumber = PhoneNumberUtils.normalizeNumber(number);
// TODO(78492722): consider using lib phone number to compare numbers
- if (!numbers.add(number)) {
+ if (!numbers.add(normalizedNumber)) {
// Number is identical to an existing number, skip this number
continue;
}