use of android.text.SpannableStringBuilder in project Anki-Android by Ramblurr.
the class CompatV11 method setSubtitle.
@Override
public void setSubtitle(Activity activity, String title, boolean inverted) {
ActionBar ab = activity.getActionBar();
if (ab != null) {
if (inverted) {
CharacterStyle span = new ForegroundColorSpan(activity.getResources().getColor(inverted ? R.color.white : R.color.black));
SpannableStringBuilder ssb = new SpannableStringBuilder(title);
ssb.setSpan(span, 0, ssb.length(), 0);
ab.setSubtitle(ssb);
} else {
ab.setSubtitle(title);
}
}
}
use of android.text.SpannableStringBuilder in project Anki-Android by Ramblurr.
the class CompatV11 method setTitle.
@Override
public void setTitle(Activity activity, String title, boolean inverted) {
ActionBar ab = activity.getActionBar();
if (ab != null) {
CharacterStyle span = new ForegroundColorSpan(activity.getResources().getColor(inverted ? R.color.white : R.color.black));
SpannableStringBuilder ssb = new SpannableStringBuilder(title);
ssb.setSpan(span, 0, ssb.length(), 0);
ab.setTitle(ssb);
}
}
use of android.text.SpannableStringBuilder in project android_frameworks_base by ParanoidAndroid.
the class Activity method setDefaultKeyMode.
/**
* Select the default key handling for this activity. This controls what
* will happen to key events that are not otherwise handled. The default
* mode ({@link #DEFAULT_KEYS_DISABLE}) will simply drop them on the
* floor. Other modes allow you to launch the dialer
* ({@link #DEFAULT_KEYS_DIALER}), execute a shortcut in your options
* menu without requiring the menu key be held down
* ({@link #DEFAULT_KEYS_SHORTCUT}), or launch a search ({@link #DEFAULT_KEYS_SEARCH_LOCAL}
* and {@link #DEFAULT_KEYS_SEARCH_GLOBAL}).
*
* <p>Note that the mode selected here does not impact the default
* handling of system keys, such as the "back" and "menu" keys, and your
* activity and its views always get a first chance to receive and handle
* all application keys.
*
* @param mode The desired default key mode constant.
*
* @see #DEFAULT_KEYS_DISABLE
* @see #DEFAULT_KEYS_DIALER
* @see #DEFAULT_KEYS_SHORTCUT
* @see #DEFAULT_KEYS_SEARCH_LOCAL
* @see #DEFAULT_KEYS_SEARCH_GLOBAL
* @see #onKeyDown
*/
public final void setDefaultKeyMode(int mode) {
mDefaultKeyMode = mode;
// This list must remain in sync with the switch in onKeyDown()
switch(mode) {
case DEFAULT_KEYS_DISABLE:
case DEFAULT_KEYS_SHORTCUT:
// not used in these modes
mDefaultKeySsb = null;
break;
case DEFAULT_KEYS_DIALER:
case DEFAULT_KEYS_SEARCH_LOCAL:
case DEFAULT_KEYS_SEARCH_GLOBAL:
mDefaultKeySsb = new SpannableStringBuilder();
Selection.setSelection(mDefaultKeySsb, 0);
break;
default:
throw new IllegalArgumentException();
}
}
use of android.text.SpannableStringBuilder in project android_frameworks_base by ParanoidAndroid.
the class SmileyParser method getSpannableString.
/**
* Retrieves the parsed text as a spannable string object.
* @param context the context for fetching smiley resources.
* @return the spannable string as CharSequence.
*/
public CharSequence getSpannableString(Context context) {
SpannableStringBuilder builder = new SpannableStringBuilder();
if (getPartCount() == 0) {
return "";
}
// should have only one part since we parse smiley only
Part part = getPart(0);
ArrayList<Token> tokens = part.getTokens();
int len = tokens.size();
for (int i = 0; i < len; i++) {
Token token = tokens.get(i);
int start = builder.length();
builder.append(token.getRawText());
if (token.getType() == AbstractMessageParser.Token.Type.SMILEY) {
int resid = mRes.getSmileyRes(token.getRawText());
if (resid != -1) {
builder.setSpan(new ImageSpan(context, resid), start, builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
return builder;
}
use of android.text.SpannableStringBuilder in project Knife by mthli.
the class KnifeText method fromHtml.
public void fromHtml(String source) {
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(KnifeParser.fromHtml(source));
switchToKnifeStyle(builder, 0, builder.length());
setText(builder);
}
Aggregations