]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Delete the entire private `cache` folder on `Clear and Exit`.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index a6d935df1f0b36bb50af2eda0e1a8ba15fe8beac..292292fa0f3565a1c3f92ca2d698d8f7ed58716b 100644 (file)
@@ -1379,13 +1379,17 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 // Destroy the internal state of `mainWebView`.
                 mainWebView.destroy();
 
-                // Manually delete the `app_webview` folder, which contains an additional `WebView` cache.  See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`.
+                // Manually delete folders.
                 Runtime runtime = Runtime.getRuntime();
                 String dataDirString = getApplicationInfo().dataDir;  // `dataDir` will vary, but will be something like `/data/user/0/com.stoutner.privacybrowser.standard`, which links to `/data/data/com.stoutner.privacybrowser.standard`.
                 try {
+                    // Delete the main `cache` folder.
+                    runtime.exec("rm -rf " + dataDirString + "/cache");
+
+                    // Delete the `app_webview` folder, which contains an additional `WebView` cache.  See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`.
                     runtime.exec("rm -rf " + dataDirString + "/app_webview");
                 } catch (IOException e) {
-                    // Do nothing if the files do not exist.
+                    // Do nothing if an error is thrown.
                 }
 
                 // Close Privacy Browser.  `finishAndRemoveTask` also removes Privacy Browser from the recent app list.
@@ -1828,9 +1832,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         // Get the text from urlTextBox and convert it to a string.  trim() removes white spaces from the beginning and end of the string.
         String unformattedUrlString = urlTextBox.getText().toString().trim();
 
-        // Check to see if unformattedUrlString is a valid URL.  Otherwise, convert it into a Duck Duck Go search.
-        if (Patterns.WEB_URL.matcher(unformattedUrlString).matches()) {
-            // Add http:// at the beginning if it is missing.  Otherwise the app will segfault.
+        // Check to see if `unformattedUrlString` is a valid URL.  Otherwise, convert it into a search.
+        if ((Patterns.WEB_URL.matcher(unformattedUrlString).matches()) || (unformattedUrlString.contains("localhost"))) {
+            // Add `http://` at the beginning if it is missing.  Otherwise the app will segfault.
             if (!unformattedUrlString.startsWith("http")) {
                 unformattedUrlString = "http://" + unformattedUrlString;
             }
@@ -1838,7 +1842,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             // Initialize `unformattedUrl`.
             URL unformattedUrl = null;
 
-            // Convert unformattedUrlString to a URL, then to a URI, and then back to a string, which sanitizes the input and adds in any missing components.
+            // Convert `unformattedUrlString` to a `URL`, then to a `URI`, and then back to a `String`, which sanitizes the input and adds in any missing components.
             try {
                 unformattedUrl = new URL(unformattedUrlString);
             } catch (MalformedURLException e) {