Search in sources :

Example 1 with Spanned

use of android.text.Spanned in project android_frameworks_base by ParanoidAndroid.

the class DrawableMarginSpan method drawLeadingMargin.

public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
    int st = ((Spanned) text).getSpanStart(this);
    int ix = (int) x;
    int itop = (int) layout.getLineTop(layout.getLineForOffset(st));
    int dw = mDrawable.getIntrinsicWidth();
    int dh = mDrawable.getIntrinsicHeight();
    // XXX What to do about Paint?
    mDrawable.setBounds(ix, itop, ix + dw, itop + dh);
    mDrawable.draw(c);
}
Also used : Spanned(android.text.Spanned) Paint(android.graphics.Paint)

Example 2 with Spanned

use of android.text.Spanned in project android_frameworks_base by ParanoidAndroid.

the class IconMarginSpan method drawLeadingMargin.

public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
    int st = ((Spanned) text).getSpanStart(this);
    int itop = layout.getLineTop(layout.getLineForOffset(st));
    if (dir < 0)
        x -= mBitmap.getWidth();
    c.drawBitmap(mBitmap, x, itop, p);
}
Also used : Spanned(android.text.Spanned) Paint(android.graphics.Paint)

Example 3 with Spanned

use of android.text.Spanned in project android_frameworks_base by ParanoidAndroid.

the class MetaKeyKeyListener method getActive.

private static int getActive(CharSequence text, Object meta, int on, int lock) {
    if (!(text instanceof Spanned)) {
        return 0;
    }
    Spanned sp = (Spanned) text;
    int flag = sp.getSpanFlags(meta);
    if (flag == LOCKED) {
        return lock;
    } else if (flag != 0) {
        return on;
    } else {
        return 0;
    }
}
Also used : Spanned(android.text.Spanned)

Example 4 with Spanned

use of android.text.Spanned in project android_frameworks_base by ParanoidAndroid.

the class TextView method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();
    // Save state if we are forced to
    boolean save = mFreezesText;
    int start = 0;
    int end = 0;
    if (mText != null) {
        start = getSelectionStart();
        end = getSelectionEnd();
        if (start >= 0 || end >= 0) {
            // Or save state if there is a selection
            save = true;
        }
    }
    if (save) {
        SavedState ss = new SavedState(superState);
        // XXX Should also save the current scroll position!
        ss.selStart = start;
        ss.selEnd = end;
        if (mText instanceof Spanned) {
            /*
                 * Calling setText() strips off any ChangeWatchers;
                 * strip them now to avoid leaking references.
                 * But do it to a copy so that if there are any
                 * further changes to the text of this view, it
                 * won't get into an inconsistent state.
                 */
            Spannable sp = new SpannableString(mText);
            for (ChangeWatcher cw : sp.getSpans(0, sp.length(), ChangeWatcher.class)) {
                sp.removeSpan(cw);
            }
            if (mEditor != null) {
                removeMisspelledSpans(sp);
                sp.removeSpan(mEditor.mSuggestionRangeSpan);
            }
            ss.text = sp;
        } else {
            ss.text = mText.toString();
        }
        if (isFocused() && start >= 0 && end >= 0) {
            ss.frozenWithFocus = true;
        }
        ss.error = getError();
        return ss;
    }
    return superState;
}
Also used : SpannableString(android.text.SpannableString) Parcelable(android.os.Parcelable) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) Spannable(android.text.Spannable)

Example 5 with Spanned

use of android.text.Spanned in project android_frameworks_base by ParanoidAndroid.

the class EditableInputConnection method commitText.

@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
    if (mTextView == null) {
        return super.commitText(text, newCursorPosition);
    }
    if (text instanceof Spanned) {
        Spanned spanned = ((Spanned) text);
        SuggestionSpan[] spans = spanned.getSpans(0, text.length(), SuggestionSpan.class);
        mIMM.registerSuggestionSpansForNotification(spans);
    }
    mTextView.resetErrorChangedFlag();
    boolean success = super.commitText(text, newCursorPosition);
    mTextView.hideErrorIfUnchanged();
    return success;
}
Also used : SuggestionSpan(android.text.style.SuggestionSpan) Spanned(android.text.Spanned)

Aggregations

Spanned (android.text.Spanned)200 Paint (android.graphics.Paint)81 TextPaint (android.text.TextPaint)63 Spannable (android.text.Spannable)32 SpannableStringBuilder (android.text.SpannableStringBuilder)26 SuggestionSpan (android.text.style.SuggestionSpan)24 SpannableString (android.text.SpannableString)23 Editable (android.text.Editable)22 TextAppearanceSpan (android.text.style.TextAppearanceSpan)15 SpannedString (android.text.SpannedString)14 TypedArray (android.content.res.TypedArray)12 URLSpan (android.text.style.URLSpan)12 View (android.view.View)11 Context (android.content.Context)9 StyleSpan (android.text.style.StyleSpan)9 InputMethodManager (android.view.inputmethod.InputMethodManager)9 Parcelable (android.os.Parcelable)8 TextView (android.widget.TextView)8 WordIterator (android.text.method.WordIterator)7 CharacterStyle (android.text.style.CharacterStyle)7