Search in sources :

Example 46 with Spanned

use of android.text.Spanned in project Tusky by Vavassor.

the class SFragment method more.

protected void more(final Status status, View view, final AdapterItemRemover adapter, final int position) {
    final String id = status.getActionableId();
    final String accountId = status.getActionableStatus().account.id;
    final String accountUsename = status.getActionableStatus().account.username;
    final Spanned content = status.getActionableStatus().content;
    final String statusUrl = status.getActionableStatus().url;
    PopupMenu popup = new PopupMenu(getContext(), view);
    // Give a different menu depending on whether this is the user's own toot or not.
    if (loggedInAccountId == null || !loggedInAccountId.equals(accountId)) {
        popup.inflate(R.menu.status_more);
    } else {
        popup.inflate(R.menu.status_more_for_user);
    }
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch(item.getItemId()) {
                case R.id.status_share_content:
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.append(status.account.username);
                        sb.append(" - ");
                        sb.append(status.content.toString());
                        Intent sendIntent = new Intent();
                        sendIntent.setAction(Intent.ACTION_SEND);
                        sendIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
                        sendIntent.setType("text/plain");
                        startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_status_content_to)));
                        return true;
                    }
                case R.id.status_share_link:
                    {
                        Intent sendIntent = new Intent();
                        sendIntent.setAction(Intent.ACTION_SEND);
                        sendIntent.putExtra(Intent.EXTRA_TEXT, statusUrl);
                        sendIntent.setType("text/plain");
                        startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_status_link_to)));
                        return true;
                    }
                case R.id.status_mute:
                    {
                        mute(accountId);
                        return true;
                    }
                case R.id.status_block:
                    {
                        block(accountId);
                        return true;
                    }
                case R.id.status_report:
                    {
                        openReportPage(accountId, accountUsename, id, content);
                        return true;
                    }
                case R.id.status_delete:
                    {
                        delete(id);
                        adapter.removeItem(position);
                        return true;
                    }
            }
            return false;
        }
    });
    popup.show();
}
Also used : MenuItem(android.view.MenuItem) Intent(android.content.Intent) Spanned(android.text.Spanned) PopupMenu(android.support.v7.widget.PopupMenu)

Example 47 with Spanned

use of android.text.Spanned in project ToastBar by SwiftyWang.

the class Toast method setText.

public void setText(String msg) {
    if (messageTextView != null && !TextUtils.isEmpty(msg)) {
        URLImageParser p = new URLImageParser(messageTextView, getContext());
        Spanned htmlSpan = Html.fromHtml(msg, p, null);
        messageTextView.setText(htmlSpan);
    }
}
Also used : URLImageParser(com.swifty.toptoastbar.UrlImage.URLImageParser) Spanned(android.text.Spanned)

Example 48 with Spanned

use of android.text.Spanned in project android_frameworks_base by ResurrectionRemix.

the class IconMarginSpan method drawLeadingMargin.

public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
    int st = ((Spanned) text).getSpanStart(this);
    int itop = layout.getLineTop(layout.getLineForOffset(st));
    if (dir < 0)
        x -= mBitmap.getWidth();
    c.drawBitmap(mBitmap, x, itop, p);
}
Also used : Spanned(android.text.Spanned) Paint(android.graphics.Paint)

Example 49 with Spanned

use of android.text.Spanned in project android_frameworks_base by ResurrectionRemix.

the class DrawableMarginSpan method drawLeadingMargin.

public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
    int st = ((Spanned) text).getSpanStart(this);
    int ix = (int) x;
    int itop = (int) layout.getLineTop(layout.getLineForOffset(st));
    int dw = mDrawable.getIntrinsicWidth();
    int dh = mDrawable.getIntrinsicHeight();
    // XXX What to do about Paint?
    mDrawable.setBounds(ix, itop, ix + dw, itop + dh);
    mDrawable.draw(c);
}
Also used : Spanned(android.text.Spanned) Paint(android.graphics.Paint)

Example 50 with Spanned

use of android.text.Spanned in project android_frameworks_base by ResurrectionRemix.

the class TextView method removeSuggestionSpans.

/**
     * Removes the suggestion spans.
     */
CharSequence removeSuggestionSpans(CharSequence text) {
    if (text instanceof Spanned) {
        Spannable spannable;
        if (text instanceof Spannable) {
            spannable = (Spannable) text;
        } else {
            spannable = new SpannableString(text);
            text = spannable;
        }
        SuggestionSpan[] spans = spannable.getSpans(0, text.length(), SuggestionSpan.class);
        for (int i = 0; i < spans.length; i++) {
            spannable.removeSpan(spans[i]);
        }
    }
    return text;
}
Also used : SpannableString(android.text.SpannableString) SuggestionSpan(android.text.style.SuggestionSpan) Spanned(android.text.Spanned) Spannable(android.text.Spannable) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Aggregations

Spanned (android.text.Spanned)204 Paint (android.graphics.Paint)81 TextPaint (android.text.TextPaint)63 Spannable (android.text.Spannable)32 SpannableStringBuilder (android.text.SpannableStringBuilder)27 SpannableString (android.text.SpannableString)25 SuggestionSpan (android.text.style.SuggestionSpan)24 Editable (android.text.Editable)22 TextAppearanceSpan (android.text.style.TextAppearanceSpan)15 SpannedString (android.text.SpannedString)14 TypedArray (android.content.res.TypedArray)12 URLSpan (android.text.style.URLSpan)12 View (android.view.View)12 Context (android.content.Context)10 StyleSpan (android.text.style.StyleSpan)9 InputMethodManager (android.view.inputmethod.InputMethodManager)9 TextView (android.widget.TextView)9 Parcelable (android.os.Parcelable)8 WordIterator (android.text.method.WordIterator)7 CharacterStyle (android.text.style.CharacterStyle)7