import androidx.appcompat.widget.SwitchCompat
import androidx.cardview.widget.CardView
+import androidx.core.content.ContextCompat.getColor
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.stoutner.privacybrowser.R
+import com.stoutner.privacybrowser.activities.DOMAINS_CUSTOM_USER_AGENT
+import com.stoutner.privacybrowser.activities.DOMAINS_SYSTEM_DEFAULT_USER_AGENT
+import com.stoutner.privacybrowser.activities.DOMAINS_WEBVIEW_DEFAULT_USER_AGENT
+import com.stoutner.privacybrowser.activities.SETTINGS_CUSTOM_USER_AGENT
+import com.stoutner.privacybrowser.activities.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT
+import com.stoutner.privacybrowser.activities.UNRECOGNIZED_USER_AGENT
import com.stoutner.privacybrowser.activities.DomainsActivity
-import com.stoutner.privacybrowser.activities.MainWebViewActivity
import com.stoutner.privacybrowser.helpers.DomainsDatabaseHelper
import java.lang.IndexOutOfBoundsException
val ultraPrivacySwitch = domainSettingsView.findViewById<SwitchCompat>(R.id.ultraprivacy_switch)
val blockAllThirdPartyRequestsImageView = domainSettingsView.findViewById<ImageView>(R.id.block_all_third_party_requests_imageview)
val blockAllThirdPartyRequestsSwitch = domainSettingsView.findViewById<SwitchCompat>(R.id.block_all_third_party_requests_switch)
+ val userAgentLinearLayout = domainSettingsView.findViewById<LinearLayout>(R.id.user_agent_linearlayout)
val userAgentSpinner = domainSettingsView.findViewById<Spinner>(R.id.user_agent_spinner)
val userAgentTextView = domainSettingsView.findViewById<TextView>(R.id.user_agent_textview)
val customUserAgentEditText = domainSettingsView.findViewById<EditText>(R.id.custom_user_agent_edittext)
+ val fontSizeLinearLayout = domainSettingsView.findViewById<LinearLayout>(R.id.font_size_linearlayout)
val fontSizeSpinner = domainSettingsView.findViewById<Spinner>(R.id.font_size_spinner)
val defaultFontSizeTextView = domainSettingsView.findViewById<TextView>(R.id.default_font_size_textview)
val customFontSizeEditText = domainSettingsView.findViewById<EditText>(R.id.custom_font_size_edittext)
+ val swipeToRefreshLinearLayout = domainSettingsView.findViewById<LinearLayout>(R.id.swipe_to_refresh_linearlayout)
val swipeToRefreshImageView = domainSettingsView.findViewById<ImageView>(R.id.swipe_to_refresh_imageview)
val swipeToRefreshSpinner = domainSettingsView.findViewById<Spinner>(R.id.swipe_to_refresh_spinner)
val swipeToRefreshTextView = domainSettingsView.findViewById<TextView>(R.id.swipe_to_refresh_textview)
val webViewThemeImageView = domainSettingsView.findViewById<ImageView>(R.id.webview_theme_imageview)
val webViewThemeSpinner = domainSettingsView.findViewById<Spinner>(R.id.webview_theme_spinner)
val webViewThemeTextView = domainSettingsView.findViewById<TextView>(R.id.webview_theme_textview)
+ val wideViewportLinearLayout = domainSettingsView.findViewById<LinearLayout>(R.id.wide_viewport_linearlayout)
val wideViewportImageView = domainSettingsView.findViewById<ImageView>(R.id.wide_viewport_imageview)
val wideViewportSpinner = domainSettingsView.findViewById<Spinner>(R.id.wide_viewport_spinner)
val wideViewportTextView = domainSettingsView.findViewById<TextView>(R.id.wide_viewport_textview)
- val displayWebpageImagesImageView = domainSettingsView.findViewById<ImageView>(R.id.display_webpage_images_imageview)
- val displayWebpageImagesSpinner = domainSettingsView.findViewById<Spinner>(R.id.display_webpage_images_spinner)
- val displayImagesTextView = domainSettingsView.findViewById<TextView>(R.id.display_webpage_images_textview)
+ val displayImagesLinearLayout = domainSettingsView.findViewById<LinearLayout>(R.id.display_images_linearlayout)
+ val displayImagesImageView = domainSettingsView.findViewById<ImageView>(R.id.display_images_imageview)
+ val displayImagesSpinner = domainSettingsView.findViewById<Spinner>(R.id.display_images_spinner)
+ val displayImagesTextView = domainSettingsView.findViewById<TextView>(R.id.display_images_textview)
val pinnedSslCertificateImageView = domainSettingsView.findViewById<ImageView>(R.id.pinned_ssl_certificate_imageview)
val pinnedSslCertificateSwitch = domainSettingsView.findViewById<SwitchCompat>(R.id.pinned_ssl_certificate_switch)
val savedSslCardView = domainSettingsView.findViewById<CardView>(R.id.saved_ssl_certificate_cardview)
swipeToRefreshSpinner.adapter = swipeToRefreshArrayAdapter
webViewThemeSpinner.adapter = webViewThemeArrayAdapter
wideViewportSpinner.adapter = wideViewportArrayAdapter
- displayWebpageImagesSpinner.adapter = displayImagesArrayAdapter
+ displayImagesSpinner.adapter = displayImagesArrayAdapter
// Create a spannable string builder for each TextView that needs multiple colors of text.
val savedSslIssuedToCNameStringBuilder = SpannableStringBuilder(cNameLabel + savedSslIssuedToCNameString)
})
// Set the switch positions.
- javaScriptSwitch.isChecked = javaScriptInt == 1
- cookiesSwitch.isChecked = cookiesInt == 1
- domStorageSwitch.isChecked = domStorageInt == 1
- formDataSwitch.isChecked = formDataInt == 1 // Form data can be removed once the minimum API >= 26.
- easyListSwitch.isChecked = easyListInt == 1
- easyPrivacySwitch.isChecked = easyPrivacyInt == 1
- fanboysAnnoyanceListSwitch.isChecked = fanboysAnnoyanceListInt == 1
- fanboysSocialBlockingListSwitch.isChecked = fanboysSocialBlockingListInt == 1
- ultraListSwitch.isChecked = ultraListInt == 1
- ultraPrivacySwitch.isChecked = ultraPrivacyInt == 1
- blockAllThirdPartyRequestsSwitch.isChecked = blockAllThirdPartyRequestsInt == 1
- pinnedSslCertificateSwitch.isChecked = pinnedSslCertificateInt == 1
- pinnedIpAddressesSwitch.isChecked = pinnedIpAddressesInt == 1
+ javaScriptSwitch.isChecked = (javaScriptInt == 1)
+ cookiesSwitch.isChecked = (cookiesInt == 1)
+ domStorageSwitch.isChecked = (domStorageInt == 1)
+ formDataSwitch.isChecked = (formDataInt == 1) // Form data can be removed once the minimum API >= 26.
+ easyListSwitch.isChecked = (easyListInt == 1)
+ easyPrivacySwitch.isChecked = (easyPrivacyInt == 1)
+ fanboysAnnoyanceListSwitch.isChecked = (fanboysAnnoyanceListInt == 1)
+ fanboysSocialBlockingListSwitch.isChecked = (fanboysSocialBlockingListInt == 1)
+ ultraListSwitch.isChecked = (ultraListInt == 1)
+ ultraPrivacySwitch.isChecked = (ultraPrivacyInt == 1)
+ blockAllThirdPartyRequestsSwitch.isChecked = (blockAllThirdPartyRequestsInt == 1)
+ pinnedSslCertificateSwitch.isChecked = (pinnedSslCertificateInt == 1)
+ pinnedIpAddressesSwitch.isChecked = (pinnedIpAddressesInt == 1)
// Set the switch icon colors.
- cookiesImageView.isSelected = cookiesInt == 1
- domStorageImageView.isSelected = domStorageInt == 1
- formDataImageView.isSelected = formDataInt == 1 // Form data can be removed once the minimum API >= 26.
- easyListImageView.isSelected = easyListInt == 1
- easyPrivacyImageView.isSelected = easyPrivacyInt == 1
- fanboysAnnoyanceListImageView.isSelected = fanboysAnnoyanceListInt == 1
- fanboysSocialBlockingListImageView.isSelected = fanboysSocialBlockingListInt == 1
- ultraListImageView.isSelected = ultraListInt == 1
- ultraPrivacyImageView.isSelected = ultraPrivacyInt == 1
- blockAllThirdPartyRequestsImageView.isSelected = blockAllThirdPartyRequestsInt == 1
- pinnedSslCertificateImageView.isSelected = pinnedSslCertificateInt == 1
- pinnedIpAddressesImageView.isSelected = pinnedIpAddressesInt == 1
+ cookiesImageView.isSelected = (cookiesInt == 1)
+ domStorageImageView.isSelected = (domStorageInt == 1)
+ formDataImageView.isSelected = (formDataInt == 1) // Form data can be removed once the minimum API >= 26.
+ easyListImageView.isSelected = (easyListInt == 1)
+ easyPrivacyImageView.isSelected = (easyPrivacyInt == 1)
+ fanboysAnnoyanceListImageView.isSelected = (fanboysAnnoyanceListInt == 1)
+ fanboysSocialBlockingListImageView.isSelected = (fanboysSocialBlockingListInt == 1)
+ ultraListImageView.isSelected = (ultraListInt == 1)
+ ultraPrivacyImageView.isSelected = (ultraPrivacyInt == 1)
+ blockAllThirdPartyRequestsImageView.isSelected = (blockAllThirdPartyRequestsInt == 1)
+ pinnedSslCertificateImageView.isSelected = (pinnedSslCertificateInt == 1)
+ pinnedIpAddressesImageView.isSelected = (pinnedIpAddressesInt == 1)
// Set the JavaScript icon.
if (javaScriptInt == 1)
// Set the Social Blocking List icon ghosted status based on the Annoyance List status.
fanboysSocialBlockingListImageView.isEnabled = (fanboysAnnoyanceListInt == 0)
+ // Open the spinners when the text view is clicked.
+ userAgentTextView.setOnClickListener { userAgentSpinner.performClick() }
+ defaultFontSizeTextView.setOnClickListener { fontSizeSpinner.performClick() }
+ swipeToRefreshTextView.setOnClickListener { swipeToRefreshSpinner.performClick() }
+ webViewThemeTextView.setOnClickListener { webViewThemeSpinner.performClick() }
+ wideViewportTextView.setOnClickListener { wideViewportSpinner.performClick() }
+ displayImagesTextView.setOnClickListener { displayImagesSpinner.performClick() }
+
// Inflated a WebView to get the default user agent.
// `@SuppressLint("InflateParams")` removes the warning about using `null` as the `ViewGroup`, which in this case makes sense because the bare WebView should not be displayed on the screen.
@SuppressLint("InflateParams") val bareWebViewLayout = inflater.inflate(R.layout.bare_webview, null, false)
// Set the user agent according to the system default.
when (defaultUserAgentArrayPosition) {
// This is probably because it was set in an older version of Privacy Browser before the switch to persistent user agent names.
- MainWebViewActivity.UNRECOGNIZED_USER_AGENT -> userAgentTextView.text = defaultUserAgentName
+ UNRECOGNIZED_USER_AGENT -> userAgentTextView.text = defaultUserAgentName
// Display the WebView default user agent.
- MainWebViewActivity.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT -> userAgentTextView.text = webViewDefaultUserAgentString
+ SETTINGS_WEBVIEW_DEFAULT_USER_AGENT -> userAgentTextView.text = webViewDefaultUserAgentString
// Display the custom user agent.
- MainWebViewActivity.SETTINGS_CUSTOM_USER_AGENT -> userAgentTextView.text = defaultCustomUserAgentString
+ SETTINGS_CUSTOM_USER_AGENT -> userAgentTextView.text = defaultCustomUserAgentString
// Get the user agent string from the user agent data array.
else -> userAgentTextView.text = userAgentDataArray[defaultUserAgentArrayPosition]
}
- } else if (userAgentArrayPosition == MainWebViewActivity.UNRECOGNIZED_USER_AGENT || currentUserAgentName == getString(R.string.custom_user_agent)) {
+
+ // Set the background color to be transparent.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
+ } else if (userAgentArrayPosition == UNRECOGNIZED_USER_AGENT || currentUserAgentName == getString(R.string.custom_user_agent)) {
// A custom user agent is stored in the current user agent name. The second check is necessary in case the user did not change the default custom text.
// Set the user agent spinner to `Custom user agent`.
- userAgentSpinner.setSelection(MainWebViewActivity.DOMAINS_CUSTOM_USER_AGENT)
+ userAgentSpinner.setSelection(DOMAINS_CUSTOM_USER_AGENT)
// Hide the user agent text view.
userAgentTextView.visibility = View.GONE
// Show the custom user agent edit text and set the current user agent name as the text.
customUserAgentEditText.visibility = View.VISIBLE
customUserAgentEditText.setText(currentUserAgentName)
+
+ // Set the background color to be blue.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
} else { // The user agent name contains one of the canonical user agents.
// Set the user agent spinner selection. The spinner has one more entry at the beginning than the user agent data array, so the position must be incremented.
userAgentSpinner.setSelection(userAgentArrayPosition + 1)
customUserAgentEditText.visibility = View.GONE
// Set the user agent text.
- if (userAgentArrayPosition == MainWebViewActivity.DOMAINS_WEBVIEW_DEFAULT_USER_AGENT) { // The WebView default user agent is selected.
+ if (userAgentArrayPosition == DOMAINS_WEBVIEW_DEFAULT_USER_AGENT) { // The WebView default user agent is selected.
// Display the WebView default user agent.
userAgentTextView.text = webViewDefaultUserAgentString
} else { // A user agent besides the default is selected.
// Get the user agent string from the user agent data array. The spinner has one more entry at the beginning than the user agent data array, so the position must be incremented.
userAgentTextView.text = userAgentDataArray[userAgentArrayPosition + 1]
}
+
+ // Set the background color to be blue.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
- // Open the user agent spinner when the text view is clicked.
- userAgentTextView.setOnClickListener { userAgentSpinner.performClick() }
// Display the font size settings.
if (fontSizeInt == 0) { // `0` is the code for system default font size.
// Set the default font size as the text of the custom font size edit text. This way, if the user switches to custom it will already be populated.
customFontSizeEditText.setText(defaultFontSizeString)
+
+ // Set the background color to be transparent.
+ fontSizeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
} else { // A custom font size is selected.
// Set the spinner to the custom font size.
fontSizeSpinner.setSelection(1)
// Set the custom font size.
customFontSizeEditText.setText(fontSizeInt.toString())
+
+ // Set the background color to be blue.
+ fontSizeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
// Initialize the default font size percentage string.
// Set the default font size text in the text view.
defaultFontSizeTextView.text = defaultFontSizePercentageString
- // Open the font size spinner when the text view is clicked.
- defaultFontSizeTextView.setOnClickListener { fontSizeSpinner.performClick() }
-
// Select the swipe-to-refresh selection in the spinner.
swipeToRefreshSpinner.setSelection(swipeToRefreshInt)
// Show the swipe-to-refresh text view.
swipeToRefreshTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ swipeToRefreshLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.ENABLED -> {
// Hide the swipe-to-refresh text view.
swipeToRefreshTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ swipeToRefreshLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DISABLED -> {
// Hide the swipe-to-refresh text view.
swipeToRefreshTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ swipeToRefreshLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
- // Open the swipe-to-refresh spinner when the text view is clicked.
- swipeToRefreshTextView.setOnClickListener { swipeToRefreshSpinner.performClick() }
-
// Get the WebView theme string arrays.
val webViewThemeStringArray = resources.getStringArray(R.array.webview_theme_array)
val webViewThemeEntryValuesStringArray = resources.getStringArray(R.array.webview_theme_entry_values)
// Show the WebView theme text view.
webViewThemeTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ webViewThemeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.LIGHT_THEME -> {
// Hide the WebView theme text view.
webViewThemeTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ webViewThemeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DARK_THEME -> {
// Hide the WebView theme text view.
webViewThemeTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ webViewThemeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
- // Open the WebView theme spinner when the text view is clicked.
- webViewThemeTextView.setOnClickListener { webViewThemeSpinner.performClick() }
-
// Select the wide viewport in the spinner.
wideViewportSpinner.setSelection(wideViewportInt)
// Set the default wide viewport text.
if (defaultWideViewport)
wideViewportTextView.text = wideViewportArrayAdapter.getItem(DomainsDatabaseHelper.ENABLED)
- else wideViewportTextView.text = wideViewportArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED)
+ else
+ wideViewportTextView.text = wideViewportArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED)
// Set the wide viewport icon and text view settings.
when (wideViewportInt) {
// Show the wide viewport text view.
wideViewportTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ wideViewportLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.ENABLED -> {
// Hide the wide viewport text view.
wideViewportTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ wideViewportLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DISABLED -> {
// Hide the wide viewport text view.
wideViewportTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ wideViewportLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
- // Open the wide viewport spinner when the text view is clicked.
- wideViewportTextView.setOnClickListener { wideViewportSpinner.performClick() }
-
// Display the website images mode in the spinner.
- displayWebpageImagesSpinner.setSelection(displayImagesInt)
+ displayImagesSpinner.setSelection(displayImagesInt)
// Set the default display images text.
if (defaultDisplayWebpageImages)
when (displayImagesInt) {
DomainsDatabaseHelper.SYSTEM_DEFAULT -> {
// Set the icon color.
- displayWebpageImagesImageView.isSelected = defaultDisplayWebpageImages
+ displayImagesImageView.isSelected = defaultDisplayWebpageImages
// Show the display images text view.
displayImagesTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ displayImagesLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.ENABLED -> {
// Set the icon color.
- displayWebpageImagesImageView.isSelected = true
+ displayImagesImageView.isSelected = true
// Hide the display images text view.
displayImagesTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ displayImagesLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DISABLED -> {
// Set the icon color.
- displayWebpageImagesImageView.isSelected = false
+ displayImagesImageView.isSelected = false
// Hide the display images text view.
displayImagesTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ displayImagesLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
- // Open the display images spinner when the text view is clicked.
- displayImagesTextView.setOnClickListener { displayWebpageImagesSpinner.performClick() }
-
// Store the current date.
val currentDate = Calendar.getInstance().time
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
// Set the new user agent.
when (position) {
- MainWebViewActivity.DOMAINS_SYSTEM_DEFAULT_USER_AGENT -> {
+ DOMAINS_SYSTEM_DEFAULT_USER_AGENT -> {
// Show the user agent text view.
userAgentTextView.visibility = View.VISIBLE
// Set the user text.
when (defaultUserAgentArrayPosition) {
// This is probably because it was set in an older version of Privacy Browser before the switch to persistent user agent names.
- MainWebViewActivity.UNRECOGNIZED_USER_AGENT -> userAgentTextView.text = defaultUserAgentName
+ UNRECOGNIZED_USER_AGENT -> userAgentTextView.text = defaultUserAgentName
// Display the `WebView` default user agent.
- MainWebViewActivity.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT -> userAgentTextView.text = webViewDefaultUserAgentString
+ SETTINGS_WEBVIEW_DEFAULT_USER_AGENT -> userAgentTextView.text = webViewDefaultUserAgentString
// Display the custom user agent.
- MainWebViewActivity.SETTINGS_CUSTOM_USER_AGENT -> userAgentTextView.text = defaultCustomUserAgentString
+ SETTINGS_CUSTOM_USER_AGENT -> userAgentTextView.text = defaultCustomUserAgentString
// Get the user agent string from the user agent data array.
else -> userAgentTextView.text = userAgentDataArray[defaultUserAgentArrayPosition]
}
+
+ // Set the background color to be transparent.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
- MainWebViewActivity.DOMAINS_WEBVIEW_DEFAULT_USER_AGENT -> {
+ DOMAINS_WEBVIEW_DEFAULT_USER_AGENT -> {
// Show the user agent text view.
userAgentTextView.visibility = View.VISIBLE
// Hide the custom user agent EditTex.
customUserAgentEditText.visibility = View.GONE
+
+ // Set the background color to be blue.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
- MainWebViewActivity.DOMAINS_CUSTOM_USER_AGENT -> {
+ DOMAINS_CUSTOM_USER_AGENT -> {
// Hide the user agent TextView.
userAgentTextView.visibility = View.GONE
// Set the current user agent name as the text.
customUserAgentEditText.setText(currentUserAgentName)
+
+ // Set the background color to be blue.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
else -> {
// Hide the custom user agent edit text.
customUserAgentEditText.visibility = View.GONE
+
+ // Set the background color to be blue.
+ userAgentLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
}
// Hide the custom font size edit text.
customFontSizeEditText.visibility = View.GONE
+
+ // Set the background color to be transparent.
+ fontSizeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
} else { // A custom font size has been selected.
// Hide the default font size text view.
defaultFontSizeTextView.visibility = View.GONE
// Show the custom font size edit text.
customFontSizeEditText.visibility = View.VISIBLE
+
+ // Set the background color to be blue.
+ fontSizeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
// Show the swipe-to-refresh text view.
swipeToRefreshTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ swipeToRefreshLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.ENABLED -> {
// Hide the swipe-to-refresh text view.
swipeToRefreshTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ swipeToRefreshLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DISABLED -> {
// Hide the swipe-to-refresh text view.
swipeToRefreshTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ swipeToRefreshLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
}
// Show the WebView theme text view.
webViewThemeTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ webViewThemeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.LIGHT_THEME -> {
// Hide the WebView theme text view.
webViewThemeTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ webViewThemeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DARK_THEME -> {
// Hide the WebView theme text view.
webViewThemeTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ webViewThemeLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
}
// Show the wide viewport text view.
wideViewportTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ wideViewportLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.ENABLED -> {
// Hide the wide viewport text view.
wideViewportTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ wideViewportLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DISABLED -> {
// Hid ethe wide viewport text view.
wideViewportTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ wideViewportLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
}
}
// Set the display webpage images spinner listener.
- displayWebpageImagesSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
+ displayImagesSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
// Update the icon and the visibility of the display images text view.
when (position) {
DomainsDatabaseHelper.SYSTEM_DEFAULT -> {
// Set the icon color.
- displayWebpageImagesImageView.isSelected = defaultDisplayWebpageImages
+ displayImagesImageView.isSelected = defaultDisplayWebpageImages
// Show the display images text view.
displayImagesTextView.visibility = View.VISIBLE
+
+ // Set the background color to be transparent.
+ displayImagesLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.transparent))
}
DomainsDatabaseHelper.ENABLED -> {
// Set the icon color.
- displayWebpageImagesImageView.isSelected = true
+ displayImagesImageView.isSelected = true
// Hide the display images text view.
displayImagesTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ displayImagesLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
DomainsDatabaseHelper.DISABLED -> {
// Set the icon color.
- displayWebpageImagesImageView.isSelected = false
+ displayImagesImageView.isSelected = false
// Hide the display images text view.
displayImagesTextView.visibility = View.GONE
+
+ // Set the background color to be blue.
+ displayImagesLinearLayout.setBackgroundColor(getColor(requireContext(), R.color.blue_background))
}
}
}