Search in sources :

Example 21 with PhoneNumberUtil

use of com.android.i18n.phonenumbers.PhoneNumberUtil in project android_frameworks_base by DirtyUnicorns.

the class LinkSpec method gatherTelLinks.

private static final void gatherTelLinks(ArrayList<LinkSpec> links, Spannable s) {
    PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
    Iterable<PhoneNumberMatch> matches = phoneUtil.findNumbers(s.toString(), Locale.getDefault().getCountry(), Leniency.POSSIBLE, Long.MAX_VALUE);
    for (PhoneNumberMatch match : matches) {
        LinkSpec spec = new LinkSpec();
        spec.url = "tel:" + PhoneNumberUtils.normalizeNumber(match.rawString());
        spec.start = match.start();
        spec.end = match.end();
        links.add(spec);
    }
}
Also used : PhoneNumberUtil(com.android.i18n.phonenumbers.PhoneNumberUtil) PhoneNumberMatch(com.android.i18n.phonenumbers.PhoneNumberMatch)

Example 22 with PhoneNumberUtil

use of com.android.i18n.phonenumbers.PhoneNumberUtil in project android_frameworks_base by crdroidandroid.

the class LinkSpec method gatherTelLinks.

private static final void gatherTelLinks(ArrayList<LinkSpec> links, Spannable s) {
    PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
    Iterable<PhoneNumberMatch> matches = phoneUtil.findNumbers(s.toString(), Locale.getDefault().getCountry(), Leniency.POSSIBLE, Long.MAX_VALUE);
    for (PhoneNumberMatch match : matches) {
        LinkSpec spec = new LinkSpec();
        spec.url = "tel:" + PhoneNumberUtils.normalizeNumber(match.rawString());
        spec.start = match.start();
        spec.end = match.end();
        links.add(spec);
    }
}
Also used : PhoneNumberUtil(com.android.i18n.phonenumbers.PhoneNumberUtil) PhoneNumberMatch(com.android.i18n.phonenumbers.PhoneNumberMatch)

Aggregations

PhoneNumberUtil (com.android.i18n.phonenumbers.PhoneNumberUtil)22 NumberParseException (com.android.i18n.phonenumbers.NumberParseException)16 PhoneNumber (com.android.i18n.phonenumbers.Phonenumber.PhoneNumber)16 PhoneNumberMatch (com.android.i18n.phonenumbers.PhoneNumberMatch)6 PhoneNumberOfflineGeocoder (com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder)6 Locale (java.util.Locale)6 TtsSpan (android.text.style.TtsSpan)4