From 6c803935c7103a8996d869450bb78608b6c16758 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Thu, 30 Jun 2011 17:51:58 +0000
Subject: [PATCH] - Top-level uri fixup part 3: Set base uri when loading from
 cache - More debugging in WVC

---
 .../router/activity/I2PWebViewClient.java      | 13 +++++++++++++
 src/net/i2p/android/router/util/AppCache.java  | 18 +++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/net/i2p/android/router/activity/I2PWebViewClient.java b/src/net/i2p/android/router/activity/I2PWebViewClient.java
index cf28ca8ae..4057acae5 100644
--- a/src/net/i2p/android/router/activity/I2PWebViewClient.java
+++ b/src/net/i2p/android/router/activity/I2PWebViewClient.java
@@ -4,6 +4,7 @@ import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.AsyncTask;
 import android.view.Gravity;
@@ -149,6 +150,18 @@ class I2PWebViewClient extends WebViewClient {
         super.onReceivedError(view, errorCode, description, failingUrl);
     }
 
+    @Override
+    public void onPageStarted(WebView view, String url, Bitmap favicon) {
+        Util.e("OPS URL: " + url);
+        super.onPageStarted(view, url, favicon);
+    }
+
+    @Override
+    public void onPageFinished(WebView view, String url) {
+        Util.e("OPF URL: " + url);
+        super.onPageFinished(view, url);
+    }
+
 /******
   API 11 :(
 
diff --git a/src/net/i2p/android/router/util/AppCache.java b/src/net/i2p/android/router/util/AppCache.java
index a9cafdcb1..0fcd3dee1 100644
--- a/src/net/i2p/android/router/util/AppCache.java
+++ b/src/net/i2p/android/router/util/AppCache.java
@@ -115,14 +115,19 @@ public class AppCache {
     /**
      *  Return a content:// uri for any cached content in question.
      *  The file may or may not exist, and it may be deleted at any time.
+     *  Side effect: If exists, sets as current base
+     *
      *  @param key no fragment allowed
      */
     public Uri getCacheUri(Uri key) {
         int hash = toHash(key);
         // poke the LRU
+        Object present = null;
         synchronized(_cache) {
-            _cache.get(Integer.valueOf(hash));
+            present = _cache.get(Integer.valueOf(hash));
         }
+        if (present != null)
+            setAsCurrentBase(key);
         return CacheProvider.getContentUri(key);
     }
 
@@ -253,6 +258,17 @@ public class AppCache {
         return null;
     }
 
+    /**
+     *  Set key as current base. May be content or i2p key.
+     */
+    private static void setAsCurrentBase(Uri key) {
+        ContentValues cv = new ContentValues();
+        cv.put(CacheProvider.CURRENT_BASE, Boolean.TRUE);
+        Uri uri = CacheProvider.getContentUri(key);
+        if (uri != null)
+           _resolver.insert(uri, cv);
+    }
+
     /** ok for now but we will need to store key in the map and delete by integer */
     private static void deleteContent(Uri key) {
         Uri uri = CacheProvider.getContentUri(key);
-- 
GitLab