Update ContactsController.java

Check if the number has a country code, if not, prepend to the number the country code of the android user based on Locale. 

TOTALLY UNTESTED, just a quick idea.
This commit is contained in:
Gabriele Carrettoni 2014-02-20 23:31:09 +01:00
parent ff85d74b85
commit c3e5f11cc9

View file

@ -185,12 +185,19 @@ public class ContactsController {
HashMap<Integer, Contact> contactsMap = new HashMap<Integer, Contact>();
try {
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
Locale locale = Locale.getDefault();
String country = locale.getCountry();
String ids = "";
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projectioPhones, null, null, null);
if (pCur != null) {
if (pCur.getCount() > 0) {
while (pCur.moveToNext()) {
String number = pCur.getString(1);
if !(number.startsWith("+")) {
number = country + number;
}
if (number == null || number.length() == 0) {
continue;
}