diff --git a/src/net/i2p/android/router/activity/I2PWebViewClient.java b/src/net/i2p/android/router/activity/I2PWebViewClient.java index 24c73d5a9b8abf8485e1601a06d58b25cb8019b9..6ccda6d562bfcac257432b147beb7cdad3750c5e 100644 --- a/src/net/i2p/android/router/activity/I2PWebViewClient.java +++ b/src/net/i2p/android/router/activity/I2PWebViewClient.java @@ -14,6 +14,7 @@ import android.widget.Toast; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -46,6 +47,15 @@ class I2PWebViewClient extends WebViewClient { view.stopLoading(); Uri uri = Uri.parse(url); + if (CONTENT.equals(uri.getScheme())) { + try { + //reverse back to a i2p URI so we can load it here and not in ContentProvider + uri = CacheProvider.getI2PUri(uri); + url = uri.toString(); + Util.e("Reversed content uri back to " + url); + AppCache.getInstance(view.getContext()).removeCacheFile(uri); + } catch (FileNotFoundException fnfe) {} + } String s = uri.getScheme(); if (s == null) { fail(view, "Bad URL " + url); @@ -162,10 +172,17 @@ class I2PWebViewClient extends WebViewClient { String url = view.getUrl(); Uri uri = Uri.parse(url); if (CONTENT.equals(uri.getScheme())) { - // this actually only deletes the row in the provider, - // not the actual file, but it will be overwritten in the reload. - Util.e("clearing provider entry for current page " + url); - view.getContext().getContentResolver().delete(uri, null, null); + try { + //reverse back to a i2p URI so we can delete it from the AppCache + uri = CacheProvider.getI2PUri(uri); + Util.e("clearing AppCache entry for current page " + uri); + AppCache.getInstance(view.getContext()).removeCacheFile(uri); + } catch (FileNotFoundException fnfe) { + // this actually only deletes the row in the provider, + // not the actual file, but it will be overwritten in the reload. + Util.e("clearing provider entry for current page " + url); + view.getContext().getContentResolver().delete(uri, null, null); + } } } diff --git a/src/net/i2p/android/router/activity/WebActivity.java b/src/net/i2p/android/router/activity/WebActivity.java index 4818f64bbd7f02e62a78b2cccfa677e6125d93a4..43305e1f721e96867ae03e0c6b45575c95f47050 100644 --- a/src/net/i2p/android/router/activity/WebActivity.java +++ b/src/net/i2p/android/router/activity/WebActivity.java @@ -100,9 +100,16 @@ public class WebActivity extends I2PActivityBase { case R.id.menu_reload: _wvClient.cancelAll(); wv.stopLoading(); - _wvClient.deleteCurrentPageCache(wv); - // should go through the WVC instead?? - wv.reload(); + String url = wv.getUrl(); + Uri uri = Uri.parse(url); + if ("data".equals(uri.getScheme())) { + // welcome page... or just do nothing ? + wv.reload(); + } else { + // wv.reload() doesn't call shouldOverrideUrlLoading(), so do it this way + _wvClient.deleteCurrentPageCache(wv); + _wvClient.shouldOverrideUrlLoading(wv, url); + } return true; default: diff --git a/src/net/i2p/android/router/provider/CacheProvider.java b/src/net/i2p/android/router/provider/CacheProvider.java index 8e64fd575c3017e26564f87d49940ed5af7e315d..92cbe6c979ca5cbaa63571a724c9eb052b40ef87 100644 --- a/src/net/i2p/android/router/provider/CacheProvider.java +++ b/src/net/i2p/android/router/provider/CacheProvider.java @@ -137,7 +137,7 @@ public class CacheProvider extends ContentProvider { * @return non-null * @throws FNFE on error */ - private static Uri getI2PUri(Uri uri) throws FileNotFoundException { + public static Uri getI2PUri(Uri uri) throws FileNotFoundException { String resPath = uri.getEncodedPath(); if (resPath == null) throw new FileNotFoundException("Bad uri no path? " + uri); diff --git a/src/net/i2p/android/router/util/AppCache.java b/src/net/i2p/android/router/util/AppCache.java index c130613a840b658fc4de869a13ac623fff61f154..c34f1790a8ae2dd9bb606dad162b5805ef27f565 100644 --- a/src/net/i2p/android/router/util/AppCache.java +++ b/src/net/i2p/android/router/util/AppCache.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import net.i2p.android.router.provider.CacheProvider; +import net.i2p.android.router.util.Util; /** * A least recently used cache with a max number of entries @@ -286,11 +287,12 @@ public class AppCache { @Override public Object remove(Object key) { Object rv = super.remove(key); - if (rv != null && key instanceof Integer) { + if ( /* rv != null && */ key instanceof Integer) { File f = toFile(((Integer)key).intValue()); if (f.exists()) { _totalSize -= f.length(); f.delete(); + Util.e("AppCache deleted file " + f); } } return rv;