Add option to remove Twitter AMP redirects. https://redmine.stoutner.com/issues/417
[PrivacyBrowser.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / SettingsFragment.java
index 51962b6bbb92904a988969ee34bda5029e22312c..73ad08bad1eccb8df00d8b8058b625e1471c7fdd 100644 (file)
@@ -74,6 +74,7 @@ public class SettingsFragment extends PreferenceFragment {
         Preference blockAllThirdPartyRequestsPreference = findPreference("block_all_third_party_requests");
         Preference googleAnalyticsPreference = findPreference("google_analytics");
         Preference facebookClickIdsPreference = findPreference("facebook_click_ids");
+        Preference twitterAmpRedirectsPreference = findPreference("twitter_amp_redirects");
         Preference proxyThroughOrbotPreference = findPreference("proxy_through_orbot");
         Preference torHomepagePreference = findPreference("tor_homepage");
         Preference torSearchPreference = findPreference("tor_search");
@@ -489,6 +490,21 @@ public class SettingsFragment extends PreferenceFragment {
             }
         }
 
+        // Set the Twitter AMP redirects icon according to the theme.
+        if (savedPreferences.getBoolean("twitter_amp_redirects", true)) {
+            if (darkTheme) {
+                twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_dark);
+            } else {
+                twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_light);
+            }
+        } else {
+            if (darkTheme) {
+                twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_dark);
+            } else {
+                twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_light);
+            }
+        }
+
         // Set the Tor icons according to the theme.
         if (proxyThroughOrbot) {  // Proxying is enabled.
             if (darkTheme) {
@@ -1176,6 +1192,23 @@ public class SettingsFragment extends PreferenceFragment {
                     }
                     break;
 
+                case "twitter_amp_redirects":
+                    // Update the icon.
+                    if (sharedPreferences.getBoolean("twitter_amp_redirects", true)) {
+                        if (darkTheme) {
+                            twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_dark);
+                        } else {
+                            twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_light);
+                        }
+                    } else {
+                        if (darkTheme) {
+                            twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_dark);
+                        } else {
+                            twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_light);
+                        }
+                    }
+                    break;
+
                 case "proxy_through_orbot":
                     // Get current settings.
                     boolean currentProxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);