From b3d8a4c69f93b20ee0500695e5f9006f8ae3cbf0 Mon Sep 17 00:00:00 2001 From: heckler01 Date: Wed, 11 Apr 2018 20:49:21 -0400 Subject: [PATCH] Let webview handle if it can go back. When navigating the links, depth would increment, but never return to 0, and then get stuck on the about page. --- .../antennapod/activity/AboutActivity.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java index e29f4f525..c97463155 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java @@ -36,8 +36,6 @@ public class AboutActivity extends AppCompatActivity { private WebView webview; private LinearLayout webviewContainer; - private int depth = 0; - private Subscription subscription; @Override @@ -60,14 +58,12 @@ public class AboutActivity extends AppCompatActivity { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if(url.startsWith("http")) { - depth++; - return false; - } else { + if (!url.startsWith("http")) { url = url.replace("file:///android_asset/", ""); loadAsset(url); return true; } + return false; } }); @@ -105,9 +101,6 @@ public class AboutActivity extends AppCompatActivity { " " + "

" + webViewData + "

"; webViewData = webViewData.replace("\n", "
"); - depth++; - } else { - depth = 0; } webViewData = String.format(webViewData, colorString); return webViewData; @@ -129,10 +122,7 @@ public class AboutActivity extends AppCompatActivity { @Override public void onBackPressed() { - Log.d(TAG, "depth: " + depth); - if(depth == 1) { - loadAsset("about.html"); - } else if(depth > 1) { + if (webview.canGoBack()) { webview.goBack(); } else { super.onBackPressed();