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);
}
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);
}
}
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;
}
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);
}
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");
}
Aggregations