Search in sources :

Example 11 with TextStyleSpan

use of org.telegram.ui.Components.TextStyleSpan in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatActivity method fillActionModeMenu.

public void fillActionModeMenu(Menu menu) {
    if (menu.findItem(R.id.menu_bold) != null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= 23) {
        menu.removeItem(android.R.id.shareText);
    }
    int order = 6;
    menu.add(R.id.menu_groupbolditalic, R.id.menu_spoiler, order++, LocaleController.getString("Spoiler", R.string.Spoiler));
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(LocaleController.getString("Bold", R.string.Bold));
    stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), 0, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    menu.add(R.id.menu_groupbolditalic, R.id.menu_bold, order++, stringBuilder);
    stringBuilder = new SpannableStringBuilder(LocaleController.getString("Italic", R.string.Italic));
    stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/ritalic.ttf")), 0, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    menu.add(R.id.menu_groupbolditalic, R.id.menu_italic, order++, stringBuilder);
    stringBuilder = new SpannableStringBuilder(LocaleController.getString("Mono", R.string.Mono));
    stringBuilder.setSpan(new TypefaceSpan(Typeface.MONOSPACE), 0, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    menu.add(R.id.menu_groupbolditalic, R.id.menu_mono, order++, stringBuilder);
    if (currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 101) {
        stringBuilder = new SpannableStringBuilder(LocaleController.getString("Strike", R.string.Strike));
        TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun();
        run.flags |= TextStyleSpan.FLAG_STYLE_STRIKE;
        stringBuilder.setSpan(new TextStyleSpan(run), 0, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        menu.add(R.id.menu_groupbolditalic, R.id.menu_strike, order++, stringBuilder);
        stringBuilder = new SpannableStringBuilder(LocaleController.getString("Underline", R.string.Underline));
        run = new TextStyleSpan.TextStyleRun();
        run.flags |= TextStyleSpan.FLAG_STYLE_UNDERLINE;
        stringBuilder.setSpan(new TextStyleSpan(run), 0, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        menu.add(R.id.menu_groupbolditalic, R.id.menu_underline, order++, stringBuilder);
    }
    menu.add(R.id.menu_groupbolditalic, R.id.menu_link, order++, LocaleController.getString("CreateLink", R.string.CreateLink));
    menu.add(R.id.menu_groupbolditalic, R.id.menu_regular, order++, LocaleController.getString("Regular", R.string.Regular));
}
Also used : TextStyleSpan(org.telegram.ui.Components.TextStyleSpan) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) SpannableStringBuilder(android.text.SpannableStringBuilder) TypefaceSpan(org.telegram.ui.Components.TypefaceSpan)

Aggregations

TextStyleSpan (org.telegram.ui.Components.TextStyleSpan)11 Paint (android.graphics.Paint)10 TextPaint (android.text.TextPaint)9 SuppressLint (android.annotation.SuppressLint)8 SpannableStringBuilder (android.text.SpannableStringBuilder)8 Spannable (android.text.Spannable)6 TLRPC (org.telegram.tgnet.TLRPC)6 StaticLayout (android.text.StaticLayout)5 URLSpanReplacement (org.telegram.ui.Components.URLSpanReplacement)5 ArrayList (java.util.ArrayList)4 URLSpanUserMention (org.telegram.ui.Components.URLSpanUserMention)4 Canvas (android.graphics.Canvas)3 PorterDuffXfermode (android.graphics.PorterDuffXfermode)3 RectF (android.graphics.RectF)3 SpannableString (android.text.SpannableString)3 CharacterStyle (android.text.style.CharacterStyle)3 URLSpan (android.text.style.URLSpan)3 Activity (android.app.Activity)2 Context (android.content.Context)2 Rect (android.graphics.Rect)2