Search in sources :

Example 61 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project actor-platform by actorapp.

the class ActorBinder method bind.

public void bind(final TextView textView, final View titleContainer, final GroupVM value) {
    bind(value.getPresence(), value.getMembersCount(), value.isMember(), (online, onlineModel, membersCount, membersModel, isMember, isMemberModel) -> {
        if (isMember) {
            titleContainer.setVisibility(View.VISIBLE);
            if (online <= 0) {
                SpannableStringBuilder builder = new SpannableStringBuilder(messenger().getFormatter().formatGroupMembers(membersCount));
                builder.setSpan(new ForegroundColorSpan(0xB7ffffff), 0, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                textView.setText(builder);
            } else {
                SpannableStringBuilder builder = new SpannableStringBuilder(messenger().getFormatter().formatGroupMembers(membersCount) + ", ");
                builder.setSpan(new ForegroundColorSpan(0xB7ffffff), 0, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                builder.append(messenger().getFormatter().formatGroupOnline(online));
                textView.setText(builder);
            }
        } else {
            titleContainer.setVisibility(View.GONE);
        }
    });
}
Also used : ForegroundColorSpan(android.text.style.ForegroundColorSpan) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 62 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project actor-platform by actorapp.

the class MessageHolder method setTimeAndReactions.

protected void setTimeAndReactions(TextView time) {
    Spannable timeWithReactions = null;
    if (reactions != null) {
        SpannableStringBuilder builder = new SpannableStringBuilder(reactions);
        timeWithReactions = builder.append(DateFormatting.formatTime(currentMessage.getDate()));
    }
    time.setText(timeWithReactions != null ? timeWithReactions : DateFormatting.formatTime(currentMessage.getDate()));
    time.setMovementMethod(LinkMovementMethod.getInstance());
}
Also used : Spannable(android.text.Spannable) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 63 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project actor-platform by actorapp.

the class AndroidNotifications method getNotificationTextFull.

private CharSequence getNotificationTextFull(Notification notification, Messenger messenger) {
    SpannableStringBuilder res = new SpannableStringBuilder();
    if (!messenger.getFormatter().isLargeDialogMessage(notification.getContentDescription().getContentType())) {
        res.append(getNotificationSender(notification));
        res.append(": ");
        res.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, res.length(), 0);
    }
    res.append(messenger.getFormatter().formatNotificationText(notification));
    return res;
}
Also used : StyleSpan(android.text.style.StyleSpan) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 64 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project actor-platform by actorapp.

the class AndroidMarkdown method processText.

private static Spannable processText(String markdown, int mode) {
    MDDocument doc = new MarkdownParser(mode).processDocument(markdown);
    SpannableStringBuilder builder = new SpannableStringBuilder();
    boolean isFirst = true;
    for (MDSection s : doc.getSections()) {
        if (isFirst) {
            isFirst = false;
        } else {
            builder.append("\n");
        }
        if (s.getType() == MDSection.TYPE_CODE) {
            int start = builder.length();
            builder.append("View Source Code");
            final String text = s.getCode().getCode();
            builder.setSpan(new RelativeSizeSpan(1.1f), start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            builder.setSpan(new ForegroundColorSpan(Color.RED), start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            builder.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    AndroidContext.getContext().startActivity(new Intent(AndroidContext.getContext(), CodePreviewActivity.class).putExtra("source_code", text).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                }
            }, start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else if (s.getType() == MDSection.TYPE_TEXT) {
            writeText(s.getText(), builder);
        } else {
            throw new RuntimeException("Unknown section type: " + s.getType());
        }
    }
    return builder;
}
Also used : MDSection(im.actor.runtime.markdown.MDSection) ForegroundColorSpan(android.text.style.ForegroundColorSpan) MDDocument(im.actor.runtime.markdown.MDDocument) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RelativeSizeSpan(android.text.style.RelativeSizeSpan) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View) MarkdownParser(im.actor.runtime.markdown.MarkdownParser) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 65 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project actor-platform by actorapp.

the class SearchViewHacker method setHint.

public static void setHint(SearchView searchView, String hint, int resId, int color, Resources resources) {
    AutoCompleteTextView autoComplete = (AutoCompleteTextView) findView(searchView, "mQueryTextView");
    SpannableStringBuilder stopHint = new SpannableStringBuilder("");
    stopHint.append(hint);
    autoComplete.setHint(stopHint);
    autoComplete.setHintTextColor(color);
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Aggregations

SpannableStringBuilder (android.text.SpannableStringBuilder)336 ForegroundColorSpan (android.text.style.ForegroundColorSpan)56 ImageSpan (android.text.style.ImageSpan)53 TextView (android.widget.TextView)40 View (android.view.View)38 StyleSpan (android.text.style.StyleSpan)35 Spanned (android.text.Spanned)28 Drawable (android.graphics.drawable.Drawable)27 Spannable (android.text.Spannable)25 SpannableString (android.text.SpannableString)21 Test (org.junit.Test)21 CharacterStyle (android.text.style.CharacterStyle)18 TextPaint (android.text.TextPaint)17 RelativeSizeSpan (android.text.style.RelativeSizeSpan)17 Paint (android.graphics.Paint)16 Context (android.content.Context)15 TextAppearanceSpan (android.text.style.TextAppearanceSpan)15 ImageView (android.widget.ImageView)15 Intent (android.content.Intent)13 Editable (android.text.Editable)13