use of android.text.style.URLSpan in project J2ME-Loader by nikita36078.
the class StringItem method getItemContentView.
@Override
public View getItemContentView() {
if (textview == null) {
Context context = getOwnerForm().getParentActivity();
if (appearanceMode == BUTTON) {
textview = new AppCompatButton(context);
} else {
textview = new AppCompatTextView(context);
}
textview.setTextAppearance(context, android.R.style.TextAppearance_Small);
if (appearanceMode == HYPERLINK && text != null) {
SpannableStringBuilder s = new SpannableStringBuilder(text);
s.setSpan(new URLSpan(text), 0, s.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textview.setText(s);
} else {
textview.setText(text);
}
textview.setOnClickListener(v -> fireDefaultCommandAction());
}
return textview;
}
use of android.text.style.URLSpan in project actor-platform by actorapp.
the class ChatListProcessor method fixLinkifyCustomLinks.
private boolean fixLinkifyCustomLinks(Spannable spannable, Pattern p, boolean isMention) {
Matcher m = p.matcher(spannable.toString());
boolean res = false;
while (m.find()) {
boolean found = false;
String nick = "";
UserVM user;
int userId = 0;
if (isGroup) {
for (GroupMember member : group.getMembers().get()) {
user = users().get(member.getUid());
nick = user.getNick().get();
if (nick != null && !nick.isEmpty() && nick.equals(m.group().substring(1, m.group().length()))) {
userId = user.getId();
found = true;
break;
}
}
}
if (isMention && !found) {
return false;
}
URLSpan span = (isMention && isGroup && found) ? new MentionSpan(nick, userId, false) : new BaseUrlSpan(m.group(), false);
spannable.setSpan(span, m.start(), m.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
res = true;
}
return res;
}
use of android.text.style.URLSpan in project platform_frameworks_base by android.
the class LinkSpec method applyLink.
private static final void applyLink(String url, int start, int end, Spannable text) {
URLSpan span = new URLSpan(url);
text.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
use of android.text.style.URLSpan in project plaid by nickbutcher.
the class HtmlUtils method linkifyPlainLinks.
private static SpannableStringBuilder linkifyPlainLinks(CharSequence input, ColorStateList linkTextColor, @ColorInt int linkHighlightColor) {
// copy of input
final SpannableString plainLinks = new SpannableString(input);
// Linkify doesn't seem to work as expected on M+
// TODO: figure out why
//Linkify.addLinks(plainLinks, Linkify.WEB_URLS);
final URLSpan[] urlSpans = plainLinks.getSpans(0, plainLinks.length(), URLSpan.class);
// add any plain links to the output
final SpannableStringBuilder ssb = new SpannableStringBuilder(input);
for (URLSpan urlSpan : urlSpans) {
ssb.removeSpan(urlSpan);
ssb.setSpan(new TouchableUrlSpan(urlSpan.getURL(), linkTextColor, linkHighlightColor), plainLinks.getSpanStart(urlSpan), plainLinks.getSpanEnd(urlSpan), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return ssb;
}
use of android.text.style.URLSpan in project android_frameworks_base by ParanoidAndroid.
the class HtmlToSpannedConverter method endA.
private static void endA(SpannableStringBuilder text) {
int len = text.length();
Object obj = getLast(text, Href.class);
int where = text.getSpanStart(obj);
text.removeSpan(obj);
if (where != len) {
Href h = (Href) obj;
if (h.mHref != null) {
text.setSpan(new URLSpan(h.mHref), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
Aggregations