]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Change qd URL format, update FR wiki format a bit.
authorThad Hughes <thadh@google.com>
Sun, 30 Dec 2012 06:35:03 +0000 (22:35 -0800)
committerThad Hughes <thadh@google.com>
Sun, 30 Dec 2012 06:35:03 +0000 (22:35 -0800)
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/MyWebView.java
src/com/hughes/android/dictionary/engine/HtmlEntry.java

index b008ea9677ae88d5088632e41e83120c058a16be..4c3d379e5d7e7b09b54d1fd988597bcb142a75ab 100644 (file)
@@ -1296,7 +1296,8 @@ public class DictionaryActivity extends ListActivity {
                 textView.setOnClickListener(new OnClickListener() {
                     @Override
                     public void onClick(View v) {
-                        final String html = HtmlEntry.htmlBody(htmlEntries, index.shortName);
+                        String html = HtmlEntry.htmlBody(htmlEntries, index.shortName);
+                        Log.d(LOG, "html=" + html);
                         startActivityForResult(
                                 HtmlDisplayActivity.getHtmlIntent(String.format(
                                         "<html><head></head><body>%s</body></html>", html),
index 17dc974a6c778ca98e537a412a2f8661a9fbf869..4e1dcb3c2e17d954f3e3ba2f5231d58cd4a5db6b 100644 (file)
@@ -44,13 +44,9 @@ public class MyWebView extends WebView {
         setWebViewClient(webViewClient);
     }
 
-
     @Override
     public void onCreateContextMenu(ContextMenu menu) {
         super.onCreateContextMenu(menu);
     }
 
-    
-    
-
 }
index 06101860c3393a4bf65bd2848b12269c45ba9a7c..08307c171240bc822a73849f5b5cfdbb7cef987b 100644 (file)
@@ -14,6 +14,7 @@ import java.io.PrintStream;
 import java.io.RandomAccessFile;
 import java.io.UnsupportedEncodingException;
 import java.lang.ref.SoftReference;
+import java.net.URL;
 import java.net.URLEncoder;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -160,7 +161,7 @@ public class HtmlEntry extends AbstractEntry implements RAFSerializable<HtmlEntr
     public static String htmlBody(final List<HtmlEntry> htmlEntries, final String indexShortName) {
         final StringBuilder result = new StringBuilder();
         for (final HtmlEntry htmlEntry : htmlEntries) {
-            final String titleEscaped = StringUtil.escapeToPureHtmlUnicode(htmlEntry.title);
+            final String titleEscaped = StringUtil.escapeUnicodeToPureHtml(htmlEntry.title);
             result.append(String.format("<h1><a href=\"%s\">%s</a></h1>\n<p>%s\n", 
                     formatQuickdicUrl(indexShortName, titleEscaped), titleEscaped,
                     htmlEntry.getHtml()));
@@ -171,23 +172,19 @@ public class HtmlEntry extends AbstractEntry implements RAFSerializable<HtmlEntr
     public static String formatQuickdicUrl(final String indexShortName, final String text) {
         assert !indexShortName.contains(":");
         assert text.length() > 0;
-        try {
-            return String.format("qd:%s:%s", indexShortName, URLEncoder.encode(text, "UTF-8"));
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e);
-        }
+        return String.format("q://d?%s&%s", indexShortName, StringUtil.encodeForUrl(text));
     }
-
+    
     public static boolean isQuickdicUrl(String url) {
-        return url.startsWith("qd:");
+        return url.startsWith("q://d?");
     }
     
     public static void quickdicUrlToIntent(final String url, final Intent intent) {
-        int firstColon = url.indexOf(":");
+        int firstColon = url.indexOf("?");
         if (firstColon == -1) return;
-        int secondColon = url.indexOf(":", firstColon + 1);
+        int secondColon = url.indexOf("&", firstColon + 1);
         if (secondColon == -1) return;
-        intent.putExtra(C.SEARCH_TOKEN, Uri.decode(url.substring(secondColon + 1)));
+        intent.putExtra(C.SEARCH_TOKEN, StringUtil.decodeFromUrl(url.substring(secondColon + 1)));
     }
     
     // --------------------------------------------------------------------