From e29020961c70d97a06c810aaff28ef1fd6af4ae7 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 13 Sep 2016 20:15:41 -0700 Subject: [PATCH] Remove the third-party cookies icon from the list of additional icons to display on the `AppBar`. --- .../privacybrowser/MainWebViewActivity.java | 56 +++++-------------- .../privacybrowser/SettingsFragment.java | 7 +-- app/src/main/res/drawable/cookies_enabled.xml | 2 +- app/src/main/res/drawable/cookies_ghosted.xml | 16 ------ app/src/main/res/drawable/cookies_warning.xml | 16 ------ 5 files changed, 18 insertions(+), 79 deletions(-) delete mode 100644 app/src/main/res/drawable/cookies_ghosted.xml delete mode 100644 app/src/main/res/drawable/cookies_warning.xml diff --git a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java index 4ac2ceed..4433cf38 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java @@ -529,12 +529,10 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Set the status of the additional app bar icons. The default is `false`. if (sharedPreferences.getBoolean("display_additional_app_bar_icons", false)) { toggleFirstPartyCookies.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); - toggleThirdPartyCookies.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); toggleDomStorage.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); toggleSaveFormData.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } else { //Do not display the additional icons. toggleFirstPartyCookies.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); - toggleThirdPartyCookies.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); toggleDomStorage.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); toggleSaveFormData.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } @@ -1112,62 +1110,38 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Get handles for the icons. MenuItem privacyIcon = mainMenu.findItem(R.id.toggleJavaScript); MenuItem firstPartyCookiesIcon = mainMenu.findItem(R.id.toggleFirstPartyCookies); - MenuItem thirdPartyCookiesIcon = mainMenu.findItem(R.id.toggleThirdPartyCookies); MenuItem domStorageIcon = mainMenu.findItem(R.id.toggleDomStorage); MenuItem formDataIcon = mainMenu.findItem(R.id.toggleSaveFormData); // Update `privacyIcon`. - if (javaScriptEnabled) { - // `JavaScript` is enabled. + if (javaScriptEnabled) { // JavaScript is enabled. privacyIcon.setIcon(R.drawable.javascript_enabled); - } else { - if (firstPartyCookiesEnabled) { - // `JavaScript` is disabled but cookies are enabled. - privacyIcon.setIcon(R.drawable.warning); - } else { - // All the dangerous features are disabled. - privacyIcon.setIcon(R.drawable.privacy_mode); - } + } else if (firstPartyCookiesEnabled) { // JavaScript is disabled but cookies are enabled. + privacyIcon.setIcon(R.drawable.warning); + } else { // All the dangerous features are disabled. + privacyIcon.setIcon(R.drawable.privacy_mode); } // Update `firstPartyCookiesIcon`. - if (firstPartyCookiesEnabled) { - // First-party cookies are enabled. - firstPartyCookiesIcon.setIcon(R.drawable.cookies_warning); - } else { - // First-party cookies are disabled. + if (firstPartyCookiesEnabled) { // First-party cookies are enabled. + firstPartyCookiesIcon.setIcon(R.drawable.cookies_enabled); + } else { // First-party cookies are disabled. firstPartyCookiesIcon.setIcon(R.drawable.cookies_disabled); } - // Update `thirdPartyCookiesIcon`. - if (firstPartyCookiesEnabled) { - if (thirdPartyCookiesEnabled) { - // Third-party cookies are enabled. Bad! - thirdPartyCookiesIcon.setIcon(R.drawable.cookies_critical); - } else { - // Third-party cookies are disabled. - thirdPartyCookiesIcon.setIcon(R.drawable.cookies_disabled); - } - } else { - // First-party cookies are disabled, so third-party cookies are ghosted. - thirdPartyCookiesIcon.setIcon(R.drawable.cookies_ghosted); - } - // Update `domStorageIcon`. - if (javaScriptEnabled) { - if (domStorageEnabled) { - domStorageIcon.setIcon(R.drawable.dom_storage_enabled); - } else { - domStorageIcon.setIcon(R.drawable.dom_storage_disabled); - } - } else { + if (javaScriptEnabled && domStorageEnabled) { // Both JavaScript and DOM storage is enabled. + domStorageIcon.setIcon(R.drawable.dom_storage_enabled); + } else if (javaScriptEnabled){ // JavaScript is enabled but DOM storage is disabled. + domStorageIcon.setIcon(R.drawable.dom_storage_disabled); + } else { // JavaScript is disabled, so DOM storage is ghosted. domStorageIcon.setIcon(R.drawable.dom_storage_ghosted); } // Update `formDataIcon`. - if (saveFormDataEnabled) { + if (saveFormDataEnabled) { // Form data is enabled. formDataIcon.setIcon(R.drawable.form_data_enabled); - } else { + } else { // Form data is disabled. formDataIcon.setIcon(R.drawable.form_data_disabled); } diff --git a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java index 4eef49c2..7446ce61 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java @@ -91,12 +91,12 @@ public class SettingsFragment extends PreferenceFragment { javaScriptDisabledSearchCustomURLPreference.setEnabled(javaScriptDisabledSearchString.equals("Custom URL")); - // Set the JavaScript-enabed searchURL as the summary text for the JavaScript-enabled search preference when the preference screen is loaded. + // Set the JavaScript-enabled searchURL as the summary text for the JavaScript-enabled search preference when the preference screen is loaded. // The default is "https://duckduckgo.com/?q=". final Preference javaScriptEnabledSearchPreference = findPreference("javascript_enabled_search"); String javaScriptEnabledSearchString = savedPreferences.getString("javascript_enabled_search", "https://duckduckgo.com/?q="); if (javaScriptEnabledSearchString.equals("Custom URL")) { - // If set to "Custom URL", use R.string.custom_url, which will be tgranslated, instead of the array value, which will not. + // If set to "Custom URL", use R.string.custom_url, which will be translated, instead of the array value, which will not. javaScriptEnabledSearchPreference.setSummary(R.string.custom_url); } else { // Set the array value as the summary text. @@ -173,9 +173,6 @@ public class SettingsFragment extends PreferenceFragment { if (Build.VERSION.SDK_INT >= 21) { MainWebViewActivity.cookieManager.setAcceptThirdPartyCookies(MainWebViewActivity.mainWebView, MainWebViewActivity.thirdPartyCookiesEnabled); } - - // Update the privacy icons. - MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity); break; case "dom_storage_enabled": diff --git a/app/src/main/res/drawable/cookies_enabled.xml b/app/src/main/res/drawable/cookies_enabled.xml index 2ceaf127..3d4ca673 100644 --- a/app/src/main/res/drawable/cookies_enabled.xml +++ b/app/src/main/res/drawable/cookies_enabled.xml @@ -11,6 +11,6 @@ \ No newline at end of file diff --git a/app/src/main/res/drawable/cookies_ghosted.xml b/app/src/main/res/drawable/cookies_ghosted.xml deleted file mode 100644 index d5675b3f..00000000 --- a/app/src/main/res/drawable/cookies_ghosted.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/cookies_warning.xml b/app/src/main/res/drawable/cookies_warning.xml deleted file mode 100644 index 9fc93bc3..00000000 --- a/app/src/main/res/drawable/cookies_warning.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file -- 2.43.0