diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2012-06-04 22:35:49 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2012-06-04 22:35:49 +0200 |
| commit | db914faa3460d4b2f687c582f9a65c7cf0d5229e (patch) | |
| tree | bcd7b82ae611241f68a1f23a960192c32b735772 | |
| parent | 5bb3aceed95693c467c2777f93d0ac320e87d923 (diff) | |
| download | cgeo-db914faa3460d4b2f687c582f9a65c7cf0d5229e.zip cgeo-db914faa3460d4b2f687c582f9a65c7cf0d5229e.tar.gz cgeo-db914faa3460d4b2f687c582f9a65c7cf0d5229e.tar.bz2 | |
Warn the user if the description contains a <pre/> tag
The content of a <pre/> tag is not rendered correctly by a TextView.
The user will receive the same warning as the one presented when a
<table/> tag is present.
See #1719 for an example of a problematic description.
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/utils/UnknownTagsHandler.java | 14 |
2 files changed, 12 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index b5a22c0..d3bb28a 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -2018,8 +2018,10 @@ public class CacheDetailActivity extends AbstractActivity { publishProgress(); } - // if description has HTML table, add a note at the end of the long description - if (unknownTagsHandler.isTableDetected() && descriptionView == view.findViewById(R.id.longdesc)) { + // If description has an HTML construct which may be problematic to render, add a note at the end of the long description. + // Technically, it may not be a table, but a pre, which has the same problems as a table, so the message is ok even though + // sometimes technically incorrect. + if (unknownTagsHandler.isProblematicDetected() && descriptionView == view.findViewById(R.id.longdesc)) { final int startPos = description.length(); ((Editable) description).append("\n\n").append(res.getString(R.string.cache_description_table_note)); ((Editable) description).setSpan(new StyleSpan(Typeface.ITALIC), startPos, description.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); diff --git a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java index 149605d..68bdb1f 100644 --- a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java +++ b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java @@ -12,7 +12,7 @@ public class UnknownTagsHandler implements TagHandler { private static final int UNDEFINED_POSITION = -1; private static int countCells = 0; int strikePos = UNDEFINED_POSITION; - private boolean tableDetected = false; + private boolean problematicDetected = false; @Override public void handleTag(boolean opening, String tag, Editable output, @@ -20,11 +20,13 @@ public class UnknownTagsHandler implements TagHandler { if (tag.equalsIgnoreCase("strike") || tag.equals("s")) { handleStrike(opening, output); } else if (tag.equalsIgnoreCase("table")) { - handleTable(); + handleProblematic(); } else if (tag.equalsIgnoreCase("td")) { handleTd(opening, output); } else if (tag.equalsIgnoreCase("tr")) { handleTr(opening, output); + } else if (tag.equalsIgnoreCase("pre")) { + handleProblematic(); } } @@ -40,12 +42,12 @@ public class UnknownTagsHandler implements TagHandler { } } - public boolean isTableDetected() { - return tableDetected; + public boolean isProblematicDetected() { + return problematicDetected; } - private void handleTable() { - tableDetected = true; + private void handleProblematic() { + problematicDetected = true; } private static void handleTd(boolean opening, Editable output) { |
