mirror of
https://github.com/DrKLO/Telegram.git
synced 2025-03-24 15:49:21 +01:00
Added fix for local calling codes:
replace leading 0 with default calling code
This commit is contained in:
parent
ff85d74b85
commit
dffcdbeade
2 changed files with 16 additions and 0 deletions
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
package org.telegram.PhoneFormat;
|
package org.telegram.PhoneFormat;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.telegram.ui.ApplicationLoader;
|
import org.telegram.ui.ApplicationLoader;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -371,4 +373,16 @@ public class PhoneFormat {
|
||||||
callingCodeInfo(defaultCallingCode);
|
callingCodeInfo(defaultCallingCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If phone number starts with local calling code 0,
|
||||||
|
* replace with defaultCallingCode
|
||||||
|
* @return number with default code
|
||||||
|
*/
|
||||||
|
public String fixLocalCallingCodes(String number) {
|
||||||
|
if(number.startsWith("0")) {
|
||||||
|
return defaultCallingCode() + number.substring(1);
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import org.telegram.PhoneFormat.PhoneFormat;
|
import org.telegram.PhoneFormat.PhoneFormat;
|
||||||
|
@ -194,6 +195,7 @@ public class ContactsController {
|
||||||
if (number == null || number.length() == 0) {
|
if (number == null || number.length() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
number = PhoneFormat.Instance.fixLocalCallingCodes(number);
|
||||||
number = PhoneFormat.stripExceptNumbers(number);
|
number = PhoneFormat.stripExceptNumbers(number);
|
||||||
if (number.length() == 0) {
|
if (number.length() == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue