Check whether dialable only am: dbc43316cf am: 45741a4489 am: f1f488257c am: 395876eb17
Change-Id: Icaa4d5dc510c1ff34a48344634158842c1398cf7
This commit is contained in:
@@ -700,7 +700,7 @@ public class ConversationData extends BindableData {
|
|||||||
final ParticipantData participant = this.getOtherParticipant();
|
final ParticipantData participant = this.getOtherParticipant();
|
||||||
if (participant != null) {
|
if (participant != null) {
|
||||||
final String phoneNumber = participant.getSendDestination();
|
final String phoneNumber = participant.getSendDestination();
|
||||||
if (!TextUtils.isEmpty(phoneNumber) && MmsSmsUtils.isPhoneNumber(phoneNumber)) {
|
if (!TextUtils.isEmpty(phoneNumber) && MmsSmsUtils.isDialable(phoneNumber)) {
|
||||||
return phoneNumber;
|
return phoneNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,19 +100,27 @@ public class MmsSmsUtils {
|
|||||||
return match.matches();
|
return match.matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** True if c is ISO-LATIN characters 0-9, *, # , + */
|
||||||
* Returns true if the number is a Phone number
|
public static final boolean isDialable(char c) {
|
||||||
*
|
return (c >= '0' && c <= '9') || c == '*' || c == '#' || c == '+';
|
||||||
* @param number the input number to be tested
|
|
||||||
* @return true if number is a Phone number
|
|
||||||
*/
|
|
||||||
public static boolean isPhoneNumber(final String number) {
|
|
||||||
if (TextUtils.isEmpty(number)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Matcher match = Patterns.PHONE.matcher(number);
|
/**
|
||||||
return match.matches();
|
* Returns true if the address is a dialable phone number.
|
||||||
|
*
|
||||||
|
* @param address the input address to be tested
|
||||||
|
* @return true if address is a dialable phone number
|
||||||
|
*/
|
||||||
|
public static boolean isDialable(final String address) {
|
||||||
|
if (TextUtils.isEmpty(address)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0, count = address.length(); i < count; i++) {
|
||||||
|
if (!isDialable(address.charAt(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user