From: Soren Stoutner Date: Thu, 7 Dec 2017 13:01:45 +0000 (-0700) Subject: Create a Clear Data submenu in the options menu. https://redmine.stoutner.com/issues... X-Git-Tag: v2.8~8 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=cf0d84aa44fee990bab271c6b4c4fc0346ac18dc;p=PrivacyBrowserAndroid.git Create a Clear Data submenu in the options menu. https://redmine.stoutner.com/issues/229. --- diff --git a/COPYING b/COPYING index 06adff4c..94bb603c 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Privacy Browser copyright © 2016-2017 Soren Stoutner . +Privacy Browser copyright © 2015-2017 Soren Stoutner . This file is part of Privacy Browser . 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 8aad8721..8e2f6e5d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -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"); diff --git a/app/src/main/res/menu/webview_options_menu.xml b/app/src/main/res/menu/webview_options_menu.xml index b6af5e02..e07807b1 100644 --- a/app/src/main/res/menu/webview_options_menu.xml +++ b/app/src/main/res/menu/webview_options_menu.xml @@ -65,22 +65,31 @@ app:showAsAction="never" /> - - + app:showAsAction="never" > - + + + + + + + + Third-Party Cookies DOM Storage Form Data + Clear Data Clear Cookies Clear DOM Storage Clear Form Data