]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
Fix custom headers not being loaded for links initialed from the WebView. https...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / DomainSettingsFragment.java
index 1af803a55c8b3803ec136cd5e3c0f4b47ca2ba88..10fb6637197cffb8c3821db0ddf575f32a2db622 100644 (file)
@@ -295,16 +295,16 @@ public class DomainSettingsFragment extends Fragment {
             savedSslEndDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(savedSslEndDate));
         }
 
-        // Create a red foreground color span.  The deprecated `resources.getColor` must be used until the minimum API >= 23.
-        final ForegroundColorSpan redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_a700));
-
-        // Create a blue foreground color span.
+        // Create the foreground color spans.
+        final ForegroundColorSpan redColorSpan;
         final ForegroundColorSpan blueColorSpan;
 
-        // Set the blue color span according to the theme.  The deprecated `resources` must be used until the minimum API >= 23.
+        // Set the color spans according to the theme.  The deprecated `resources` must be used until the minimum API >= 23.
         if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-            blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_400));
+            redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_900));
+            blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.violet_500));
         } else {
+            redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_a700));
             blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_700));
         }
 
@@ -410,9 +410,13 @@ public class DomainSettingsFragment extends Fragment {
             if (firstPartyCookiesInt == 1) {  // First-party cookies are enabled.
                 // Set the third-party cookies status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
                 if (thirdPartyCookiesInt == 1) {  // Both first-party and third-party cookies are enabled.
+                    // Set the third-party cookies switch to be checked.
                     thirdPartyCookiesSwitch.setChecked(true);
+
+                    // Set the icon to be red.
                     thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning));
                 } else {  // First party cookies are enabled but third-party cookies are disabled.
+                    // Set the third-party cookies switch to be checked.
                     thirdPartyCookiesSwitch.setChecked(false);
 
                     // Set the icon according to the theme.
@@ -576,10 +580,12 @@ public class DomainSettingsFragment extends Fragment {
 
         // Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off.
         if (fanboysAnnoyanceListInt == 0) {  // Fanboy's Annoyance List is on.
+            // Enable Fanboy's Social Blocking List switch.
+            fanboysSocialBlockingListSwitch.setEnabled(true);
+
             // Enable Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
             if (fanboysSocialBlockingListInt == 1) {  // Fanboy's Social Blocking List is on.
-                // Enable the switch and turn it on.
-                fanboysSocialBlockingListSwitch.setEnabled(true);
+                // Turn on Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(true);
 
                 // Set the icon according to the theme.
@@ -589,8 +595,7 @@ public class DomainSettingsFragment extends Fragment {
                     fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day));
                 }
             } else {  // Fanboy's Social Blocking List is off.
-                // Enable the switch but turn it off.
-                fanboysSocialBlockingListSwitch.setEnabled(true);
+                // Turn off Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(false);
 
                 // Set the icon according to the theme.
@@ -601,14 +606,15 @@ public class DomainSettingsFragment extends Fragment {
                 }
             }
         } else {  // Fanboy's Annoyance List is on.
-            // Disable Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+            // Disable Fanboy's Social Blocking List switch.
+            fanboysSocialBlockingListSwitch.setEnabled(false);
+
+            // Handle the status of Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
             if (fanboysSocialBlockingListInt == 1) {  // Fanboy's Social Blocking List is on.
-                // Disable the switch but turn it on.
-                fanboysSocialBlockingListSwitch.setEnabled(false);
+                // Turn on Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(true);
             } else {  // Fanboy's Social Blocking List is off.
-                // Disable the switch and turn it off.
-                fanboysSocialBlockingListSwitch.setEnabled(false);
+                // Turn off Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(false);
             }
 
@@ -882,16 +888,16 @@ public class DomainSettingsFragment extends Fragment {
                 if (defaultNightMode) {  // Night mode enabled by default.
                     // Set the icon according to the theme.
                     if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                     } else {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                     }
                 } else {  // Night mode disabled by default.
                     // Set the icon according to the theme.
                     if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                     } else {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                     }
                 }
 
@@ -902,9 +908,9 @@ public class DomainSettingsFragment extends Fragment {
             case DomainsDatabaseHelper.ENABLED:
                 // Set the icon according to the theme.
                 if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                 } else {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                 }
 
                 // Hide the night mode TextView.
@@ -914,9 +920,9 @@ public class DomainSettingsFragment extends Fragment {
             case DomainsDatabaseHelper.DISABLED:
                 // Set the icon according to the theme.
                 if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                 } else {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                 }
 
                 // Hide the night mode TextView.
@@ -1362,6 +1368,7 @@ public class DomainSettingsFragment extends Fragment {
 
                 // Update the third-party cookies icon.
                 if (thirdPartyCookiesSwitch.isChecked()) {  // Third-party cookies are enabled.
+                    // Set the third-party cookies icon to be red.
                     thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning));
                 } else {  // Third-party cookies are disabled.
                     // Set the third-party cookies icon according to the theme.
@@ -1395,6 +1402,7 @@ public class DomainSettingsFragment extends Fragment {
         thirdPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
             // Update the icon.
             if (isChecked) {
+                // Set the third-party cookies icon to be red.
                 thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning));
             } else {
                 // Update the third-party cookies icon according to the theme.
@@ -1773,16 +1781,16 @@ public class DomainSettingsFragment extends Fragment {
                         if (defaultNightMode) {  // Night mode enabled by default.
                             // Set the icon according to the theme.
                             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                             } else {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                             }
                         } else {  // Night mode disabled by default.
                             // Set the icon according to the theme.
                             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                             } else {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                             }
                         }
 
@@ -1793,9 +1801,9 @@ public class DomainSettingsFragment extends Fragment {
                     case DomainsDatabaseHelper.ENABLED:
                         // Set the icon according to the theme.
                         if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                         } else {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                         }
 
                         // Hide `nightModeTextView`.
@@ -1805,9 +1813,9 @@ public class DomainSettingsFragment extends Fragment {
                     case DomainsDatabaseHelper.DISABLED:
                         // Set the icon according to the theme.
                         if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                         } else {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                         }
 
                         // Hide `nightModeTextView`.