Java Code Examples for android.text.TextUtils#htmlEncode()
The following examples show how to use
android.text.TextUtils#htmlEncode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateFeedParser.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
public UpdateInfo parse(String content) throws UpdateFeedParseException { try { if (!StringUtils.mayBeJson(content)) return null; JSONObject json = new JSONObject(content); int versionCode = getVersionCode(json); String versionName = getVersionName(json); DownloadLink[] downloadLinks = getDownloadLinks(json); UpdateInfo updateInfo = new UpdateInfo(versionCode, versionName); updateInfo.addDownloadLinks(downloadLinks); return updateInfo; } catch (JSONException ex) { Timber.w("parse(): Error while parsing JSON response"); throw new UpdateFeedParseException("Cannot parse update feed: `" + TextUtils.htmlEncode(content) + "`", ex); } }
Example 2
Source File: UtilsHtml.java From thermalprinterhelper with Apache License 2.0 | 5 votes |
public static String HtmlDecode(String oldStr){ if(oldStr == null || oldStr.isEmpty()) return ""; String result = oldStr; result = result.replace("#015;",""); result = result.replace("#012;",""); result = result.replace("&","&"); result = result.replace("&","{AND}"); result = TextUtils.htmlEncode(result); result = result.replace("{AND}","&"); return result; }
Example 3
Source File: ConverterTextToHtml.java From memoir with Apache License 2.0 | 5 votes |
public static String convert(String text) { // Escape the entities and add newlines. String htmlified = text == null ? "" : TextUtils.htmlEncode(text); // Linkify the message. StringBuffer linkified = new StringBuffer(htmlified.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH); linkifyText(htmlified, linkified); // For some reason, TextUtils.htmlEncode escapes ' into ', which is technically part of the XHTML 1.0 // standard, but Gmail doesn't recognize it as an HTML entity. We unescape that here. String result = linkified.toString().replace("\n", "<br>\n").replace("'", "'"); return result; }
Example 4
Source File: ConverterTextToHtml.java From memoir with Apache License 2.0 | 5 votes |
public static String convert(String text) { // Escape the entities and add newlines. String htmlified = text == null ? "" : TextUtils.htmlEncode(text); // Linkify the message. StringBuffer linkified = new StringBuffer(htmlified.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH); linkifyText(htmlified, linkified); // For some reason, TextUtils.htmlEncode escapes ' into ', which is technically part of the XHTML 1.0 // standard, but Gmail doesn't recognize it as an HTML entity. We unescape that here. String result = linkified.toString().replace("\n", "<br>\n").replace("'", "'"); return result; }
Example 5
Source File: ChangelogFeedParser.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public ChangelogInfo parse(String content) throws ChangelogFeedParseException { try { if (!StringUtils.mayBeJson(content)) return new ChangelogInfo(); JSONObject json = new JSONObject(content); List<ChangelogEntry> entries = getEntries(json); ChangelogInfo changelog = new ChangelogInfo(); changelog.addEntries(entries); return changelog; } catch (JSONException ex) { Timber.w("parse(): Error while parsing JSON content"); throw new ChangelogFeedParseException("Cannot parse changelog feed: `" + TextUtils.htmlEncode(content) + "`", ex); } }
Example 6
Source File: ConverterTextToHtml.java From Android-RTEditor with Apache License 2.0 | 5 votes |
public static String convert(String text) { // Escape the entities and add newlines. String htmlified = text == null ? "" : TextUtils.htmlEncode(text); // Linkify the message. StringBuffer linkified = new StringBuffer(htmlified.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH); linkifyText(htmlified, linkified); // For some reason, TextUtils.htmlEncode escapes ' into ', which is technically part of the XHTML 1.0 // standard, but Gmail doesn't recognize it as an HTML entity. We unescape that here. String result = linkified.toString().replace("\n", "<br>\n").replace("'", "'"); return result; }
Example 7
Source File: ApiUtils.java From ForPDA with GNU General Public License v3.0 | 4 votes |
public static String htmlEncode(String s) { if (s == null) return null; return TextUtils.htmlEncode(s); }
Example 8
Source File: CodeActivity.java From WeGit with Apache License 2.0 | 4 votes |
@JavascriptInterface public String getCode() { return TextUtils.htmlEncode(content.replace("\t", " ")); }
Example 9
Source File: ThreadPageRequest.java From something.apk with MIT License | 4 votes |
public static ThreadPage processThreadPage(Document document, boolean showImages, boolean showAvatars, boolean hidePreviouslyReadImages, long jumpToPost, String redirectedUrl){ ArrayList<HashMap<String, String>> posts = new ArrayList<HashMap<String, String>>(); int currentPage, maxPage = 1, threadId, forumId, unread; String jumpToId = jumpToPost > 0 ? "#post"+jumpToPost : null; String ptiFragment = null; if(!TextUtils.isEmpty(redirectedUrl)){ Uri url = Uri.parse(redirectedUrl); ptiFragment = url.getFragment(); if("lastpost".matches(ptiFragment)){ ptiFragment = null; jumpToId = "#lastpost"; } } Element pages = document.getElementsByClass("pages").first(); currentPage = FastUtils.safeParseInt(pages.getElementsByAttribute("selected").attr("value"), 1); Element lastPage = pages.getElementsByTag("option").last(); if(lastPage != null){ maxPage = FastUtils.safeParseInt(lastPage.attr("value"), 1); } boolean bookmarked = document.getElementsByClass("unbookmark").size() > 0; String threadTitle = TextUtils.htmlEncode(document.getElementsByClass("bclast").first().text()); Element body = document.body(); forumId = Integer.parseInt(body.attr("data-forum")); threadId = Integer.parseInt(body.attr("data-thread")); Elements threadbars = document.getElementsByClass("threadbar"); boolean canReply = !Constants.isArchiveForum(forumId) && threadbars.first().getElementsByAttributeValueContaining("src", "images/forum-closed.gif").size() == 0; unread = parsePosts(document, posts, showImages, showAvatars, hidePreviouslyReadImages, ptiFragment, canReply, currentPage == maxPage, forumId); StringBuilder builder = new StringBuilder(2048); int previouslyRead = posts.size()-unread; HashMap<String, String> headerArgs = new HashMap<String, String>(); headerArgs.put("jumpToPostId", jumpToId); headerArgs.put("fontSize", SomePreferences.fontSize); headerArgs.put("theme", getTheme(forumId)); headerArgs.put("previouslyRead", previouslyRead > 0 && unread > 0 ? previouslyRead+" Previous Post"+(previouslyRead > 1 ? "s":"") : null); MustCache.applyHeaderTemplate(builder, headerArgs); for(HashMap<String, String> post : posts){ MustCache.applyPostTemplate(builder, post); } MustCache.applyFooterTemplate(builder, null); ThreadItem cachedThread = ThreadManager.getThread(threadId); if(cachedThread != null){ cachedThread.updateUnreadCount(currentPage, maxPage, SomePreferences.threadPostPerPage); } return new ThreadPage(builder.toString(), currentPage, maxPage, threadId, forumId, threadTitle, -unread, bookmarked, canReply); }