mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 12:48:26 +00:00
More shortcode fixes for Germany
// FREEBIE
This commit is contained in:
parent
ae379cd3dd
commit
058bcf1f4a
@ -27,13 +27,20 @@ public class ShortCodeUtil {
|
|||||||
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
|
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
|
||||||
Phonenumber.PhoneNumber localNumberObject = util.parse(localNumber, null);
|
Phonenumber.PhoneNumber localNumberObject = util.parse(localNumber, null);
|
||||||
String localCountryCode = util.getRegionCodeForNumber(localNumberObject);
|
String localCountryCode = util.getRegionCodeForNumber(localNumberObject);
|
||||||
|
String bareNumber = number.replaceAll("[^0-9+]", "");
|
||||||
|
|
||||||
if (number.replaceAll("[^0-9+]", "").length() <= 4 && !SHORT_COUNTRIES.contains(localCountryCode)) {
|
// libphonenumber doesn't seem to be correct for Germany
|
||||||
|
if (bareNumber.length() <= 6 && "DE".equals(localCountryCode)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
Phonenumber.PhoneNumber shortCode = util.parse(number, localCountryCode);
|
|
||||||
return ShortNumberInfo.getInstance().isPossibleShortNumberForRegion(shortCode, localCountryCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// libphonenumber seems incorrect for Russia and a few other countries with 4 digit short codes.
|
||||||
|
if (bareNumber.length() <= 4 && !SHORT_COUNTRIES.contains(localCountryCode)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Phonenumber.PhoneNumber shortCode = util.parse(number, localCountryCode);
|
||||||
|
return ShortNumberInfo.getInstance().isPossibleShortNumberForRegion(shortCode, localCountryCode);
|
||||||
} catch (NumberParseException e) {
|
} catch (NumberParseException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user