Search in sources :

Example 1 with Annotation

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;
}
Also used : SpannableString(android.text.SpannableString) SpannableString(android.text.SpannableString) Annotation(android.text.Annotation)

Example 2 with Annotation

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;
}
Also used : SpannableString(android.text.SpannableString) SpannableString(android.text.SpannableString) Annotation(android.text.Annotation)

Example 3 with Annotation

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;
}
Also used : SpannableString(android.text.SpannableString) Annotation(android.text.Annotation)

Example 4 with Annotation

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;
}
Also used : SpannableString(android.text.SpannableString) Annotation(android.text.Annotation)

Example 5 with Annotation

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;
}
Also used : SpannableString(android.text.SpannableString) SpannableString(android.text.SpannableString) Annotation(android.text.Annotation)

Aggregations

Annotation (android.text.Annotation)16 SpannableString (android.text.SpannableString)11 SpannableStringBuilder (android.text.SpannableStringBuilder)3 Spanned (android.text.Spanned)3 MentionAnnotation (org.thoughtcrime.securesms.components.mention.MentionAnnotation)3 TextPaint (android.text.TextPaint)2 ValueAnimator (android.animation.ValueAnimator)1 SuppressLint (android.annotation.SuppressLint)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Color (android.graphics.Color)1 PorterDuff (android.graphics.PorterDuff)1 Rect (android.graphics.Rect)1 Typeface (android.graphics.Typeface)1 Uri (android.net.Uri)1 Spannable (android.text.Spannable)1 BackgroundColorSpan (android.text.style.BackgroundColorSpan)1 CharacterStyle (android.text.style.CharacterStyle)1 ClickableSpan (android.text.style.ClickableSpan)1