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