]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/MyWebView.java
Many fixes/hack to get a compilable version.
[Dictionary.git] / src / com / hughes / android / dictionary / MyWebView.java
index 4e1dcb3c2e17d954f3e3ba2f5231d58cd4a5db6b..abb7fdc9b6ed37b41673afd7ca9b32772266b5d3 100644 (file)
@@ -1,5 +1,8 @@
+
 package com.hughes.android.dictionary;
 
+import com.hughes.util.StringUtil;
+
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
@@ -12,32 +15,42 @@ import android.webkit.WebViewClient;
 import com.hughes.android.dictionary.engine.HtmlEntry;
 
 public class MyWebView extends WebView {
-    
+
     static final String LOG = "MyWebView";
-    
+
     HtmlDisplayActivity activity;
 
+    public static void quickdicUrlToIntent(final String url, final Intent intent) {
+        int firstColon = url.indexOf("?");
+        if (firstColon == -1)
+            return;
+        int secondColon = url.indexOf("&", firstColon + 1);
+        if (secondColon == -1)
+            return;
+        intent.putExtra(C.SEARCH_TOKEN, StringUtil.decodeFromUrl(url.substring(secondColon + 1)));
+    }
+
     public MyWebView(Context context) {
         super(context);
     }
-    
+
     public MyWebView(Context context, AttributeSet attrs) {
         super(context, attrs);
         getSettings().setSupportZoom(true);
         getSettings().setBuiltInZoomControls(true);
-        
+
         final WebViewClient webViewClient = new WebViewClient() {
             @Override
             public boolean shouldOverrideUrlLoading(WebView view, String url) {
                 if (HtmlEntry.isQuickdicUrl(url)) {
                     Log.d(LOG, "Handling Quickdic URL: " + url);
                     final Intent result = new Intent();
-                    HtmlEntry.quickdicUrlToIntent(url, result);
+                    quickdicUrlToIntent(url, result);
+                    Log.d(LOG, "SEARCH_TOKEN=" + result.getStringExtra(C.SEARCH_TOKEN));
                     activity.setResult(Activity.RESULT_OK, result);
                     activity.finish();
                     return true;
                 }
-                // TODO Auto-generated method stub
                 return super.shouldOverrideUrlLoading(view, url);
             }
         };