1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

updated ChangeLog; obsolete fix has been removed

This commit is contained in:
Nikolay Pultsin 2012-10-30 00:51:42 +04:00
parent 696ed77046
commit 3c6fb84a0f
2 changed files with 2 additions and 26 deletions

View file

@ -1,5 +1,7 @@
===== 1.6.4 (Nov ??, 2012) ===== ===== 1.6.4 (Nov ??, 2012) =====
* Supported encoding & language detection for *.doc (ms-word) files * Supported encoding & language detection for *.doc (ms-word) files
* Fixed crash in book info dialogs on some epubs (on Jelly Bean devices), code taken from https://gist.github.com/3424004
* Fixed some problems in interaction with TTS+ plugin (by Greg Kochaniak)
===== 1.6.3 (Oct 22, 2012) ===== ===== 1.6.3 (Oct 22, 2012) =====
* FBReader stores text position after setPageStart API method (useful for TTS plugin, code by Greg Kochaniak) * FBReader stores text position after setPageStart API method (useful for TTS plugin, code by Greg Kochaniak)

View file

@ -20,38 +20,12 @@
package org.geometerplus.fbreader.network; package org.geometerplus.fbreader.network;
import java.util.HashMap; import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.text.*; import android.text.*;
import android.text.style.URLSpan; import android.text.style.URLSpan;
public abstract class HtmlUtil { public abstract class HtmlUtil {
private static final HashMap<String,Pattern> ourTagPatterns = new HashMap<String,Pattern>();
private static String removeNestedTags(String text, String tag) {
Pattern pattern = ourTagPatterns.get(tag);
if (pattern == null) {
pattern = Pattern.compile("(<" + tag + ">.*)</*" + tag + ">(.*</" + tag + ">)");
}
final Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
text = matcher.replaceAll("$1 $2");
matcher.reset(text);
}
return text;
}
private static String removeNestedTags(String text, String[] tags) {
for (String t : tags) {
text = removeNestedTags(text, t);
}
return text;
}
public static CharSequence getHtmlText(String text) { public static CharSequence getHtmlText(String text) {
// fixes an android bug (?): text layout fails on text with nested style tags
text = removeNestedTags(text, new String[] { "i", "b", "strong" });
final Spanned htmlText = Html.fromHtml(text); final Spanned htmlText = Html.fromHtml(text);
if (htmlText.getSpans(0, htmlText.length(), URLSpan.class).length == 0) { if (htmlText.getSpans(0, htmlText.length(), URLSpan.class).length == 0) {
return htmlText; return htmlText;