Search in sources :

Example 36 with ImageSpan

use of android.text.style.ImageSpan in project android_frameworks_base by AOSPA.

the class RestrictedLockUtils method setTextViewPadlock.

public static void setTextViewPadlock(Context context, TextView textView, boolean showPadlock) {
    final SpannableStringBuilder sb = new SpannableStringBuilder(textView.getText());
    removeExistingRestrictedSpans(sb);
    if (showPadlock) {
        final ImageSpan image = new RestrictedLockImageSpan(context);
        sb.append(" ", image, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    textView.setText(sb);
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 37 with ImageSpan

use of android.text.style.ImageSpan in project android_frameworks_base by AOSPA.

the class RestrictedLockUtils method removeExistingRestrictedSpans.

private static void removeExistingRestrictedSpans(SpannableStringBuilder sb) {
    final int length = sb.length();
    RestrictedLockImageSpan[] imageSpans = sb.getSpans(length - 1, length, RestrictedLockImageSpan.class);
    for (ImageSpan span : imageSpans) {
        final int start = sb.getSpanStart(span);
        final int end = sb.getSpanEnd(span);
        sb.removeSpan(span);
        sb.delete(start, end);
    }
    ForegroundColorSpan[] colorSpans = sb.getSpans(0, length, ForegroundColorSpan.class);
    for (ForegroundColorSpan span : colorSpans) {
        sb.removeSpan(span);
    }
}
Also used : ForegroundColorSpan(android.text.style.ForegroundColorSpan) ImageSpan(android.text.style.ImageSpan)

Example 38 with ImageSpan

use of android.text.style.ImageSpan in project Ushahidi_Android by ushahidi.

the class SearchView method getDecoratedHint.

private CharSequence getDecoratedHint(CharSequence hintText) {
    // If the field is always expanded, then don't add the search icon to the hint
    if (!mIconifiedByDefault)
        return hintText;
    // for the icon
    SpannableStringBuilder ssb = new SpannableStringBuilder("   ");
    ssb.append(hintText);
    Drawable searchIcon = getContext().getResources().getDrawable(getSearchIconId());
    int textSize = (int) (mQueryTextView.getTextSize() * 1.25);
    searchIcon.setBounds(0, 0, textSize, textSize);
    ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ssb;
}
Also used : Drawable(android.graphics.drawable.Drawable) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 39 with ImageSpan

use of android.text.style.ImageSpan in project android_frameworks_base by crdroidandroid.

the class RecentsCreateFragment method appendDrawable.

private static void appendDrawable(SpannableStringBuilder b, Drawable d) {
    final int length = b.length();
    b.append("〉");
    b.setSpan(new ImageSpan(d), length, b.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
Also used : ImageSpan(android.text.style.ImageSpan)

Example 40 with ImageSpan

use of android.text.style.ImageSpan in project SmoothEmotionKeyBoard by cpoopc.

the class EmotionEditText method onEmotionInput.

@Override
public void onEmotionInput(EmotionEntity emotionEntity) {
    DebugLog.e("emotion " + emotionEntity);
    int selectionStart = getSelectionStart();
    int selectionEnd = getSelectionEnd();
    mDealingText = emotionEntity.getCode();
    EmotionManager.getImageSpan(emotionEntity);
    Editable text = getText();
    ImageSpan imageSpan = EmotionManager.getImageSpan(emotionEntity);
    if (selectionStart != selectionEnd) {
        DebugLog.e("----11");
        text.replace(selectionStart, selectionEnd, emotionEntity.getCode());
        text.setSpan(imageSpan, selectionStart, selectionStart + emotionEntity.getCode().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        DebugLog.e("----12");
        text.insert(selectionStart, emotionEntity.getCode());
        text.setSpan(imageSpan, selectionStart, selectionStart + emotionEntity.getCode().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    mDealingText = null;
    DebugLog.e("----2");
}
Also used : Editable(android.text.Editable) ImageSpan(android.text.style.ImageSpan)

Aggregations

ImageSpan (android.text.style.ImageSpan)98 SpannableStringBuilder (android.text.SpannableStringBuilder)53 Drawable (android.graphics.drawable.Drawable)29 ForegroundColorSpan (android.text.style.ForegroundColorSpan)23 BackgroundColorSpan (android.text.style.BackgroundColorSpan)14 TextView (android.widget.TextView)14 SpannableString (android.text.SpannableString)12 View (android.view.View)11 UnderlineSpan (android.text.style.UnderlineSpan)10 RelativeSizeSpan (android.text.style.RelativeSizeSpan)7 StyleSpan (android.text.style.StyleSpan)7 Bitmap (android.graphics.Bitmap)6 LinearLayout (android.widget.LinearLayout)6 Application (android.app.Application)5 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)5 CharacterStyle (android.text.style.CharacterStyle)5 SuggestionSpan (android.text.style.SuggestionSpan)5 URLSpan (android.text.style.URLSpan)5 MenuItem (android.view.MenuItem)5 Button (android.widget.Button)5