private java.lang.CharSequence formatUrl(java.lang.CharSequence url) { if (mUrlColor == null) { // Lazily get the URL color from the current theme. android.util.TypedValue colorValue = new android.util.TypedValue(); mContext.getTheme().resolveAttribute([email protected], colorValue, true); mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId); } android.text.SpannableString text = new android.text.SpannableString(url); text.setSpan(new android.text.style.TextAppearanceSpan(null, 0, 0, mUrlColor, null ), 0, url.Length, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); return(text); }
internal java.lang.CharSequence applyStyles(string str, int[] style, android.content.res.StringBlock .StyleIDs ids) { if (style.Length == 0) { return java.lang.CharSequenceProxy.Wrap(str); } android.text.SpannableString buffer = new android.text.SpannableString(java.lang.CharSequenceProxy.Wrap (str)); int i = 0; while (i < style.Length) { int type = style[i]; if (type == ids.boldId) { buffer.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE ); } else { if (type == ids.italicId) { buffer.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.ITALIC) , style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE ); } else { if (type == ids.underlineId) { buffer.setSpan(new android.text.style.UnderlineSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.ttId) { buffer.setSpan(new android.text.style.TypefaceSpan("monospace"), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.bigId) { buffer.setSpan(new android.text.style.RelativeSizeSpan(1.25f), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.smallId) { buffer.setSpan(new android.text.style.RelativeSizeSpan(0.8f), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.subId) { buffer.setSpan(new android.text.style.SubscriptSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.supId) { buffer.setSpan(new android.text.style.SuperscriptSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.strikeId) { buffer.setSpan(new android.text.style.StrikethroughSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.listItemId) { addParagraphSpan(buffer, new android.text.style.BulletSpan(10), style[i + 1], style [i + 2] + 1); } else { if (type == ids.marqueeId) { buffer.setSpan(android.text.TextUtils.TruncateAt.MARQUEE, style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_INCLUSIVE_INCLUSIVE); } else { string tag = nativeGetString(mNative, type); if (tag.StartsWith("font;")) { string sub; sub = subtag(tag, ";height="); if (sub != null) { int size = System.Convert.ToInt32(sub); addParagraphSpan(buffer, new android.content.res.StringBlock.Height(size), style[ i + 1], style[i + 2] + 1); } sub = subtag(tag, ";size="); if (sub != null) { int size = System.Convert.ToInt32(sub); buffer.setSpan(new android.text.style.AbsoluteSizeSpan(size, true), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } sub = subtag(tag, ";fgcolor="); if (sub != null) { int color = [email protected](sub, -1); buffer.setSpan(new android.text.style.ForegroundColorSpan(color), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } sub = subtag(tag, ";bgcolor="); if (sub != null) { int color = [email protected](sub, -1); buffer.setSpan(new android.text.style.BackgroundColorSpan(color), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { if (tag.StartsWith("a;")) { string sub; sub = subtag(tag, ";href="); if (sub != null) { buffer.setSpan(new android.text.style.URLSpan(sub), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { if (tag.StartsWith("annotation;")) { int len = tag.Length; int next; { for (int t = tag.IndexOf(';'); t < len; t = next) { int eq = tag.IndexOf('=', t); if (eq < 0) { break; } next = tag.IndexOf(';', eq); if (next < 0) { next = len; } string key = Sharpen.StringHelper.Substring(tag, t + 1, eq); string value = Sharpen.StringHelper.Substring(tag, eq + 1, next); buffer.setSpan(new android.text.Annotation(key, value), style[i + 1], style[i + 2 ] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } } } } } } } } } } } } } } } i += 3; } return new android.text.SpannedString(buffer); }
internal java.lang.CharSequence applyStyles(string str, int[] style, android.content.res.StringBlock .StyleIDs ids) { if (style.Length == 0) { return(java.lang.CharSequenceProxy.Wrap(str)); } android.text.SpannableString buffer = new android.text.SpannableString(java.lang.CharSequenceProxy.Wrap (str)); int i = 0; while (i < style.Length) { int type = style[i]; if (type == ids.boldId) { buffer.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE ); } else { if (type == ids.italicId) { buffer.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.ITALIC) , style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE ); } else { if (type == ids.underlineId) { buffer.setSpan(new android.text.style.UnderlineSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.ttId) { buffer.setSpan(new android.text.style.TypefaceSpan("monospace"), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.bigId) { buffer.setSpan(new android.text.style.RelativeSizeSpan(1.25f), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.smallId) { buffer.setSpan(new android.text.style.RelativeSizeSpan(0.8f), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.subId) { buffer.setSpan(new android.text.style.SubscriptSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.supId) { buffer.setSpan(new android.text.style.SuperscriptSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.strikeId) { buffer.setSpan(new android.text.style.StrikethroughSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.listItemId) { addParagraphSpan(buffer, new android.text.style.BulletSpan(10), style[i + 1], style [i + 2] + 1); } else { if (type == ids.marqueeId) { buffer.setSpan(android.text.TextUtils.TruncateAt.MARQUEE, style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_INCLUSIVE_INCLUSIVE); } else { string tag = nativeGetString(mNative, type); if (tag.StartsWith("font;")) { string sub; sub = subtag(tag, ";height="); if (sub != null) { int size = System.Convert.ToInt32(sub); addParagraphSpan(buffer, new android.content.res.StringBlock.Height(size), style[ i + 1], style[i + 2] + 1); } sub = subtag(tag, ";size="); if (sub != null) { int size = System.Convert.ToInt32(sub); buffer.setSpan(new android.text.style.AbsoluteSizeSpan(size, true), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } sub = subtag(tag, ";fgcolor="); if (sub != null) { int color = [email protected](sub, -1); buffer.setSpan(new android.text.style.ForegroundColorSpan(color), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } sub = subtag(tag, ";bgcolor="); if (sub != null) { int color = [email protected](sub, -1); buffer.setSpan(new android.text.style.BackgroundColorSpan(color), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { if (tag.StartsWith("a;")) { string sub; sub = subtag(tag, ";href="); if (sub != null) { buffer.setSpan(new android.text.style.URLSpan(sub), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { if (tag.StartsWith("annotation;")) { int len = tag.Length; int next; { for (int t = tag.IndexOf(';'); t < len; t = next) { int eq = tag.IndexOf('=', t); if (eq < 0) { break; } next = tag.IndexOf(';', eq); if (next < 0) { next = len; } string key = Sharpen.StringHelper.Substring(tag, t + 1, eq); string value = Sharpen.StringHelper.Substring(tag, eq + 1, next); buffer.setSpan(new android.text.Annotation(key, value), style[i + 1], style[i + 2 ] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } } } } } } } } } } } } } } } i += 3; } return(new android.text.SpannedString(buffer)); }
private java.lang.CharSequence formatUrl(java.lang.CharSequence url) { if (mUrlColor == null) { // Lazily get the URL color from the current theme. android.util.TypedValue colorValue = new android.util.TypedValue(); mContext.getTheme().resolveAttribute([email protected], colorValue, true); mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId); } android.text.SpannableString text = new android.text.SpannableString(url); text.setSpan(new android.text.style.TextAppearanceSpan(null, 0, 0, mUrlColor, null ), 0, url.Length, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); return text; }