]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Create a Clear Data submenu in the options menu. https://redmine.stoutner.com/issues...
authorSoren Stoutner <soren@stoutner.com>
Thu, 7 Dec 2017 13:01:45 +0000 (06:01 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 7 Dec 2017 13:01:45 +0000 (06:01 -0700)
COPYING
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/menu/webview_options_menu.xml
app/src/main/res/values/strings.xml

diff --git a/COPYING b/COPYING
index 06adff4c718b13728e83bd82d6a07b9a2306ca67..94bb603c44f9f95124cd11297d1c6755f975c4c5 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,4 @@
-Privacy Browser copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
+Privacy Browser copyright © 2015-2017 Soren Stoutner <soren@stoutner.com>.
 
 This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
 
index 8aad8721b596501867e0a30f4fa9c759fabfa3cd..8e2f6e5d3bab3c205c565e112ba96836b077be22 100644 (file)
@@ -1456,6 +1456,7 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD
         MenuItem toggleThirdPartyCookiesMenuItem = menu.findItem(R.id.toggle_third_party_cookies);
         MenuItem toggleDomStorageMenuItem = menu.findItem(R.id.toggle_dom_storage);
         MenuItem toggleSaveFormDataMenuItem = menu.findItem(R.id.toggle_save_form_data);
+        MenuItem clearDataMenuItem = menu.findItem(R.id.clear_data);
         MenuItem clearCookiesMenuItem = menu.findItem(R.id.clear_cookies);
         MenuItem clearDOMStorageMenuItem = menu.findItem(R.id.clear_dom_storage);
         MenuItem clearFormDataMenuItem = menu.findItem(R.id.clear_form_data);
@@ -1507,6 +1508,9 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD
         WebViewDatabase mainWebViewDatabase = WebViewDatabase.getInstance(this);
         clearFormDataMenuItem.setEnabled(mainWebViewDatabase.hasFormData());
 
+        // Enable `Clear Data` if any of the submenu items are enabled.
+        clearDataMenuItem.setEnabled(clearCookiesMenuItem.isEnabled() || clearDOMStorageMenuItem.isEnabled() || clearFormDataMenuItem.isEnabled());
+
         // Initialize font size variables.
         int fontSize = mainWebView.getSettings().getTextZoom();
         String fontSizeTitle;
@@ -1774,9 +1778,16 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD
                                         WebStorage webStorage = WebStorage.getInstance();
                                         webStorage.deleteAllData();
 
-                                        // Manually remove `IndexedDB` if it exists.
+                                        // Manually delete the DOM storage files and directories.
                                         try {
+                                            // A `String[]` must be used because the directory contains a space and `Runtime.exec` will otherwise not escape the string correctly.
+                                            privacyBrowserRuntime.exec(new String[] {"rm", "-rf", privateDataDirectoryString + "/app_webview/Local Storage/"});
+
+                                            // Multiple commands must be used because `Runtime.exec()` does not like `*`.
                                             privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview/IndexedDB");
+                                            privacyBrowserRuntime.exec("rm -f " + privateDataDirectoryString + "/app_webview/QuotaManager");
+                                            privacyBrowserRuntime.exec("rm -f " + privateDataDirectoryString + "/app_webview/QuotaManager-journal");
+                                            privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview/databases");
                                         } catch (IOException e) {
                                             // Do nothing if an error is thrown.
                                         }
@@ -2033,10 +2044,10 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD
 
                     // Manually delete the DOM storage files and directories, as `WebStorage` sometimes will not flush its changes to disk before `System.exit(0)` is run.
                     try {
-                        // We have to use a `String[]` because the directory contains a space and `Runtime.exec` will not escape the string correctly otherwise.
+                        // A `String[]` must be used because the directory contains a space and `Runtime.exec` will otherwise not escape the string correctly.
                         privacyBrowserRuntime.exec(new String[] {"rm", "-rf", privateDataDirectoryString + "/app_webview/Local Storage/"});
 
-                        // We have to use multiple commands because `Runtime.exec()` does not like `*`.
+                        // Multiple commands must be used because `Runtime.exec()` does not like `*`.
                         privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview/IndexedDB");
                         privacyBrowserRuntime.exec("rm -f " + privateDataDirectoryString + "/app_webview/QuotaManager");
                         privacyBrowserRuntime.exec("rm -f " + privateDataDirectoryString + "/app_webview/QuotaManager-journal");
index b6af5e02181dda8266a8475f25748d4a1234e978..e07807b166177cae5c797d0f5bf4f05fd0efdd32 100644 (file)
         app:showAsAction="never" />
 
     <item
-        android:id="@+id/clear_cookies"
-        android:title="@string/clear_cookies"
+        android:id="@+id/clear_data"
+        android:title="@string/clear_data"
         android:orderInCategory="70"
-        app:showAsAction="never" />
-
-    <item
-        android:id="@+id/clear_dom_storage"
-        android:title="@string/clear_dom_storage"
-        android:orderInCategory="80"
-        app:showAsAction="never" />
+        app:showAsAction="never" >
 
-    <item
-        android:id="@+id/clear_form_data"
-        android:title="@string/clear_form_data"
-        android:orderInCategory="90"
-        app:showAsAction="never" />
+        <menu>
+            <item
+                android:id="@+id/clear_cookies"
+                android:title="@string/clear_cookies"
+                android:orderInCategory="70"
+                app:showAsAction="never" />
+
+            <item
+                android:id="@+id/clear_dom_storage"
+                android:title="@string/clear_dom_storage"
+                android:orderInCategory="80"
+                app:showAsAction="never" />
+
+            <item
+                android:id="@+id/clear_form_data"
+                android:title="@string/clear_form_data"
+                android:orderInCategory="90"
+                app:showAsAction="never" />
+        </menu>
+    </item>
 
     <item
         android:id="@+id/font_size"
index 782677751374378066e2e9abcfb240d751940a80..c3dfe0d98af7cf4b1790c3269f8508e47b113708 100644 (file)
     <string name="third_party_cookies">Third-Party Cookies</string>
     <string name="dom_storage">DOM Storage</string>
     <string name="form_data">Form Data</string>
+    <string name="clear_data">Clear Data</string>
     <string name="clear_cookies">Clear Cookies</string>
     <string name="clear_dom_storage">Clear DOM Storage</string>
     <string name="clear_form_data">Clear Form Data</string>