diff options
author | Gyanesh Mittal <gyaneshm@google.com> | 2023-06-09 00:54:04 +0000 |
---|---|---|
committer | Android Build Cherrypicker Worker <android-build-cherrypicker-worker@google.com> | 2023-06-09 00:54:04 +0000 |
commit | d3db7dca9409cb5c5601718d92f85389af032339 (patch) | |
tree | 44653ddebf86665f0901d9addf31f6e149836bf7 /src/com/android/contacts/util | |
parent | c32739b44f1c58c05bf0cb87d3e23a9c4f338d0c (diff) | |
download | Contacts-d3db7dca9409cb5c5601718d92f85389af032339.tar.gz |
Add SdnProvider to AOSP Contacts app
Bug: 285969261
Test: Manually
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:76816ec373c902359c6fd8d5967b5b6b063d2128)
Merged-In: I86aa75509ded71ed97db39c2d19ae7b3912853ea
Change-Id: I86aa75509ded71ed97db39c2d19ae7b3912853ea
Diffstat (limited to 'src/com/android/contacts/util')
-rw-r--r-- | src/com/android/contacts/util/PhoneNumberHelper.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/contacts/util/PhoneNumberHelper.java b/src/com/android/contacts/util/PhoneNumberHelper.java index eb070b217..2f1a5b0a0 100644 --- a/src/com/android/contacts/util/PhoneNumberHelper.java +++ b/src/com/android/contacts/util/PhoneNumberHelper.java @@ -16,6 +16,7 @@ package com.android.contacts.util; import android.telephony.PhoneNumberUtils; +import android.text.TextUtils; import android.util.Log; /** @@ -95,4 +96,24 @@ public class PhoneNumberHelper { } return number.substring(0, delimiterIndex); } + + /** Returns true if the given string is dialable by the user from Phone/Dialer app. */ + public static boolean isDialablePhoneNumber(String str) { + if (TextUtils.isEmpty(str)) { + return false; + } + + for (int i = 0, count = str.length(); i < count; i++) { + if (!(PhoneNumberUtils.isDialable(str.charAt(i)) + || str.charAt(i) == ' ' + || str.charAt(i) == '-' + || str.charAt(i) == '(' + || str.charAt(i) == ')' + || str.charAt(i) == '.' + || str.charAt(i) == '/')) { + return false; + } + } + return true; + } } |