Create a dark theme for `SettingsActivity`.
[PrivacyBrowser.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / DomainSettingsFragment.java
index 5362026c8232735cf8621ef83bf0c3b1f459a021..a231391c40ab0cffdf7bc8a268519b6a87da25a7 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * Copyright © 2017 Soren Stoutner <soren@stoutner.com>.
  *
+ * Huawei spinner code fix contributed 2017 Thomas Jensen <lianergoist@vongriffen.dk>.  Copyright assigned to Soren Stoutner <soren@stoutner.com>.
+ *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
  * Privacy Browser is free software: you can redistribute it and/or modify
@@ -115,16 +117,16 @@ public class DomainSettingsFragment extends Fragment {
         ArrayAdapter<CharSequence> fontSizeEntryValuesArrayAdapter = ArrayAdapter.createFromResource(context, R.array.default_font_size_entry_values, android.R.layout.simple_spinner_item);
         final ArrayAdapter<CharSequence> displayImagesArrayAdapter = ArrayAdapter.createFromResource(context, R.array.display_website_images_array, android.R.layout.simple_spinner_item);
 
-        // Set the drop down style for the `ArrayAdapters`.
-        fontSizeArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-        displayImagesArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-
-        // Some phones running Huawei's customized Android 7.0 don't display a spinner that requires scrolling correctly with the default `simple_spinner_dropdown_item`.  The Huawei P9 Lite is known to be affected.
+        // Some phones running Huawei's customized Android 7.0 have layout problems displaying a spinner with the default `simple_spinner_dropdown_item`.  The Huawei P9 Lite is known to be affected.
         if (Build.BRAND.equals("HUAWEI") && (Build.VERSION.SDK_INT == 24)) {  // The device is manufactured by Huawei and is running Android 7.0.
-            // Use a customized `simple_spinner_dropdown_item`.
+            // Use a customized `simple_spinner_dropdown_item`.  Huawei spinner code fix contributed 2017 Thomas Jensen <lianergoist@vongriffen.dk>.  Copyright assigned to Soren Stoutner <soren@stoutner.com>.
             userAgentArrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item_huawei_fix);
+            fontSizeArrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item_huawei_fix);
+            displayImagesArrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item_huawei_fix);
         } else {  // Use the standard `android.R.layout.simple_spinner_dropdown_item` on all other devices.
             userAgentArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+            fontSizeArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+            displayImagesArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         }
 
         // Set the `ArrayAdapters` for the `Spinners`.
@@ -150,7 +152,7 @@ public class DomainSettingsFragment extends Fragment {
             firstPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_enabled));
         } else {  // First-party cookies are disabled.
             firstPartyCookiesEnabledSwitch.setChecked(false);
-            firstPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled));
+            firstPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled_light));
         }
 
         // Only display third-party cookies if SDK_INT >= 21.
@@ -163,18 +165,18 @@ public class DomainSettingsFragment extends Fragment {
                     thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_warning));
                 } else {  // First party cookies are enabled but third-party cookies are disabled.
                     thirdPartyCookiesEnabledSwitch.setChecked(false);
-                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled));
+                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled_light));
                 }
             } else {  // First-party cookies are disabled.
                 // Set the status of third-party cookies, but disable it.
                 if (thirdPartyCookiesEnabledInt == 1) {  // Third-party cookies are enabled but first-party cookies are disabled.
                     thirdPartyCookiesEnabledSwitch.setChecked(true);
                     thirdPartyCookiesEnabledSwitch.setEnabled(false);
-                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_ghosted));
+                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_ghosted_light));
                 } else {  // Both first party and third-party cookies are disabled.
                     thirdPartyCookiesEnabledSwitch.setChecked(false);
                     thirdPartyCookiesEnabledSwitch.setEnabled(false);
-                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_ghosted));
+                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_ghosted_light));
                 }
             }
         } else {  // Third-party cookies cannot be configured for API <= 21.
@@ -190,7 +192,7 @@ public class DomainSettingsFragment extends Fragment {
                 domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_enabled));
             } else {  // JavaScript is enabled but DOM storage is disabled.
                 domStorageEnabledSwitch.setChecked(false);
-                domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_disabled));
+                domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_disabled_light));
             }
         } else {  // JavaScript is disabled.
             // Set the checked status of DOM storage.
@@ -202,7 +204,7 @@ public class DomainSettingsFragment extends Fragment {
 
             // Disable `domStorageEnabledSwitch` and set the icon to be ghosted.
             domStorageEnabledSwitch.setEnabled(false);
-            domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_ghosted));
+            domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_ghosted_light));
         }
 
         // Set the form data status.  Once minimum API >= 21 we can use a selector as the tint mode instead of specifying different icons.
@@ -211,7 +213,7 @@ public class DomainSettingsFragment extends Fragment {
             formDataImageView.setImageDrawable(getResources().getDrawable(R.drawable.form_data_enabled));
         } else {  // Form data is disabled.
             formDataEnabledSwitch.setChecked(false);
-            formDataImageView.setImageDrawable(getResources().getDrawable(R.drawable.form_data_disabled));
+            formDataImageView.setImageDrawable(getResources().getDrawable(R.drawable.form_data_disabled_light));
         }
 
         // We need to inflated a `WebView` to get the default user agent.
@@ -267,18 +269,18 @@ public class DomainSettingsFragment extends Fragment {
         switch (displayImagesInt) {
             case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_SYSTEM_DEFAULT:
                 if (MainWebViewActivity.displayWebpageImagesBoolean) {
-                    displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled));
+                    displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled_light));
                 } else {
-                    displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled));
+                    displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled_light));
                 }
                 break;
 
             case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_ENABLED:
-                displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled));
+                displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled_light));
                 break;
 
             case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_DISABLED:
-                displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled));
+                displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled_light));
                 break;
         }
 
@@ -298,7 +300,7 @@ public class DomainSettingsFragment extends Fragment {
                     if (domStorageEnabledSwitch.isChecked()) {  // DOM storage is enabled.
                         domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_enabled));
                     } else {  // DOM storage is disabled.
-                        domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_disabled));
+                        domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_disabled_light));
                     }
                 } else {  // JavaScript is disabled.
                     // Update the JavaScript icon.
@@ -308,7 +310,7 @@ public class DomainSettingsFragment extends Fragment {
                     domStorageEnabledSwitch.setEnabled(false);
 
                     // Set the DOM storage icon to be ghosted.
-                    domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_ghosted));
+                    domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_ghosted_light));
                 }
             }
         });
@@ -328,17 +330,17 @@ public class DomainSettingsFragment extends Fragment {
                     if (thirdPartyCookiesEnabledSwitch.isChecked()) {  // Third-party cookies are enabled.
                         thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_warning));
                     } else {  // Third-party cookies are disabled.
-                        thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled));
+                        thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled_light));
                     }
                 } else {  // First-party cookies are disabled.
                     // Update the first-party cookies icon.
-                    firstPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled));
+                    firstPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled_light));
 
                     // Disable the third-party cookies `Switch`.
                     thirdPartyCookiesEnabledSwitch.setEnabled(false);
 
                     // Set the third-party cookies icon to be ghosted.
-                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_ghosted));
+                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_ghosted_light));
                 }
             }
         });
@@ -351,7 +353,7 @@ public class DomainSettingsFragment extends Fragment {
                 if (isChecked) {
                     thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_warning));
                 } else {
-                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled));
+                    thirdPartyCookiesImageView.setImageDrawable(getResources().getDrawable(R.drawable.cookies_disabled_light));
                 }
             }
         });
@@ -364,7 +366,7 @@ public class DomainSettingsFragment extends Fragment {
                 if (isChecked) {
                     domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_enabled));
                 } else {
-                    domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_disabled));
+                    domStorageImageView.setImageDrawable(getResources().getDrawable(R.drawable.dom_storage_disabled_light));
                 }
             }
         });
@@ -377,7 +379,7 @@ public class DomainSettingsFragment extends Fragment {
                 if (isChecked) {
                     formDataImageView.setImageDrawable(getResources().getDrawable(R.drawable.form_data_enabled));
                 } else {
-                    formDataImageView.setImageDrawable(getResources().getDrawable(R.drawable.form_data_disabled));
+                    formDataImageView.setImageDrawable(getResources().getDrawable(R.drawable.form_data_disabled_light));
                 }
             }
         });
@@ -434,18 +436,18 @@ public class DomainSettingsFragment extends Fragment {
                 switch (position) {
                     case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_SYSTEM_DEFAULT:
                         if (MainWebViewActivity.displayWebpageImagesBoolean) {
-                            displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled));
+                            displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled_light));
                         } else {
-                            displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled));
+                            displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled_light));
                         }
                         break;
 
                     case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_ENABLED:
-                        displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled));
+                        displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_enabled_light));
                         break;
 
                     case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_DISABLED:
-                        displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled));
+                        displayWebpageImagesImageView.setImageDrawable(getResources().getDrawable(R.drawable.images_disabled_light));
                         break;
                 }
             }