X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=772196d4b94184335c722b9dee92dd243eeb8169;hp=cf19d3a18480c1963f87ecf20c0a0ca528fa40ac;hb=7c08413564ba6a9eb15e86f6ed1860c55cbdf9b2;hpb=173084fe307c5df2e004dc471342097e56647110 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index cf19d3a1..772196d4 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -874,6 +874,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook MenuItem selectedFontSizeMenuItem; // Prepare the font size title and current size menu item. + //noinspection DuplicateBranchesInSwitch switch (fontSize) { case 25: fontSizeTitle = getString(R.string.font_size) + " - " + getString(R.string.twenty_five_percent); @@ -1811,9 +1812,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the previous entry URL. String previousUrl = webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1).getUrl(); - // Reset the current domain name so that navigation works if third-party requests are blocked. - currentWebView.resetCurrentDomainName(); - // Apply the domain settings. applyDomainSettings(currentWebView, previousUrl, false, false); @@ -1830,9 +1828,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the next entry URL. String nextUrl = webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() + 1).getUrl(); - // Reset the current domain name so that navigation works if third-party requests are blocked. - currentWebView.resetCurrentDomainName(); - // Apply the domain settings. applyDomainSettings(currentWebView, nextUrl, false, false); @@ -2861,9 +2856,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the previous entry URL. String previousUrl = webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1).getUrl(); - // Reset the current domain name so that navigation works if third-party requests are blocked. - currentWebView.resetCurrentDomainName(); - // Apply the domain settings. applyDomainSettings(currentWebView, previousUrl, false, false); @@ -2873,8 +2865,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Close the current tab. closeCurrentTab(); } else { // There isn't anything to do in Privacy Browser. - // Run the default commands. - super.onBackPressed(); + // Close Privacy Browser. `finishAndRemoveTask()` also removes Privacy Browser from the recent app list. + if (Build.VERSION.SDK_INT >= 21) { + finishAndRemoveTask(); + } else { + finish(); + } // Manually kill Privacy Browser. Otherwise, it is glitchy when restarted. System.exit(0); @@ -2911,11 +2907,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Instantiate the file name helper. FileNameHelper fileNameHelper = new FileNameHelper(); - // Convert the file name URI to a file name path. - String fileNamePath = fileNameHelper.convertUriToFileNamePath(data.getData()); + // Get the file path if it isn't null. + if (data.getData() != null) { + // Convert the file name URI to a file name path. + String fileNamePath = fileNameHelper.convertUriToFileNamePath(data.getData()); - // Set the file name path as the text of the file name edit text. - fileNameEditText.setText(fileNamePath); + // Set the file name path as the text of the file name edit text. + fileNameEditText.setText(fileNamePath); + } } } break; @@ -3687,9 +3686,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook @Override public void navigateHistory(String url, int steps) { - // Reset the current domain name so that navigation works if third-party requests are blocked. - currentWebView.resetCurrentDomainName(); - // Apply the domain settings. applyDomainSettings(currentWebView, url, false, false); @@ -3705,9 +3701,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the previous entry URL. String previousUrl = webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1).getUrl(); - // Reset the current domain name so that navigation works if third-party requests are blocked. - currentWebView.resetCurrentDomainName(); - // Apply the domain settings. applyDomainSettings(currentWebView, previousUrl, false, false);