use of android.text.Annotation in project Signal-Android by WhisperSystems.
the class RecipientsEditor method contactToToken.
/*public boolean containsEmail() {
if (TextUtils.indexOf(getText(), '@') == -1)
return false;
List<String> numbers = mTokenizer.getNumbers();
for (String number : numbers) {
if (Mms.isEmailAddress(number))
return true;
}
return false;
}*/
public static CharSequence contactToToken(Recipient c) {
String name = c.getName();
String number = c.getNumber();
SpannableString s = new SpannableString(RecipientsFormatter.formatNameAndNumber(name, number));
int len = s.length();
if (len == 0) {
return s;
}
s.setSpan(new Annotation("number", c.getNumber()), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
use of android.text.Annotation in project Signal-Android by signalapp.
the class RecipientsEditor method contactToToken.
/*public boolean containsEmail() {
if (TextUtils.indexOf(getText(), '@') == -1)
return false;
List<String> numbers = mTokenizer.getNumbers();
for (String number : numbers) {
if (Mms.isEmailAddress(number))
return true;
}
return false;
}*/
public static CharSequence contactToToken(Recipient c) {
String name = c.getName();
String number = c.getAddress().serialize();
SpannableString s = new SpannableString(RecipientsFormatter.formatNameAndNumber(name, number));
int len = s.length();
if (len == 0) {
return s;
}
s.setSpan(new Annotation("number", c.getAddress().serialize()), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
use of android.text.Annotation in project android-aosp-mms by slvn.
the class RecipientsEditor method contactToToken.
public static CharSequence contactToToken(Contact c) {
SpannableString s = new SpannableString(c.getNameAndNumber());
int len = s.length();
if (len == 0) {
return s;
}
s.setSpan(new Annotation("number", c.getNumber()), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
use of android.text.Annotation in project Signal-Android by WhisperSystems.
the class RecipientsEditor method getFieldAt.
private static String getFieldAt(String field, Spanned sp, int start, int end, Context context) {
Annotation[] a = sp.getSpans(start, end, Annotation.class);
String fieldValue = getAnnotation(a, field);
if (TextUtils.isEmpty(fieldValue)) {
fieldValue = TextUtils.substring(sp, start, end);
}
return fieldValue;
}
use of android.text.Annotation in project Signal-Android by WhisperSystems.
the class RecipientsEditor method contactToToken.
/*public boolean containsEmail() {
if (TextUtils.indexOf(getText(), '@') == -1)
return false;
List<String> numbers = mTokenizer.getNumbers();
for (String number : numbers) {
if (Mms.isEmailAddress(number))
return true;
}
return false;
}*/
public static CharSequence contactToToken(@NonNull Context context, @NonNull Recipient c) {
String name = c.getDisplayName(context);
String number = c.getE164().or(c.getEmail()).or("");
SpannableString s = new SpannableString(RecipientsFormatter.formatNameAndNumber(name, number));
int len = s.length();
if (len == 0) {
return s;
}
s.setSpan(new Annotation("number", number), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
Aggregations