From: Soren Stoutner Date: Wed, 19 Apr 2023 22:43:59 +0000 (-0700) Subject: Highlight the background of non-default domain settings. https://redmine.stoutner... X-Git-Tag: v3.14~3 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=be1d361c9ca97f21ca9298d72b07e4a57788fe56;p=PrivacyBrowserAndroid.git Highlight the background of non-default domain settings. https://redmine.stoutner.com/issues/886 --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt index 1895c6eb..1866a66d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt @@ -647,7 +647,7 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI } } - override fun onAddDomain(dialogFragment: DialogFragment) { + override fun addDomain(dialogFragment: DialogFragment) { // Dismiss the undo delete snackbar if it is currently displayed. if (undoDeleteSnackbar != null && undoDeleteSnackbar!!.isShown) undoDeleteSnackbar!!.dismiss() @@ -710,7 +710,7 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI val swipeToRefreshSpinner = view.findViewById(R.id.swipe_to_refresh_spinner) val webViewThemeSpinner = view.findViewById(R.id.webview_theme_spinner) val wideViewportSpinner = view.findViewById(R.id.wide_viewport_spinner) - val displayWebpageImagesSpinner = view.findViewById(R.id.display_webpage_images_spinner) + val displayWebpageImagesSpinner = view.findViewById(R.id.display_images_spinner) val pinnedSslCertificateSwitch = view.findViewById(R.id.pinned_ssl_certificate_switch) val currentWebsiteCertificateRadioButton = view.findViewById(R.id.current_website_certificate_radiobutton) val pinnedIpAddressesSwitch = view.findViewById(R.id.pinned_ip_addresses_switch) diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.kt index f1cc8cb3..00d281af 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2017-2022 Soren Stoutner . + * Copyright © 2017-2023 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -48,7 +48,7 @@ class AddDomainDialog : DialogFragment() { // The public interface is used to send information back to the parent activity. interface AddDomainListener { - fun onAddDomain(dialogFragment: DialogFragment) + fun addDomain(dialogFragment: DialogFragment) } override fun onAttach(context: Context) { @@ -103,7 +103,7 @@ class AddDomainDialog : DialogFragment() { // Set the add button listener. dialogBuilder.setPositiveButton(R.string.add) { _: DialogInterface, _: Int -> // Return the dialog fragment to the parent activity on add. - addDomainListener.onAddDomain(this) + addDomainListener.addDomain(this) } // Create an alert dialog from the builder. @@ -169,7 +169,7 @@ class AddDomainDialog : DialogFragment() { // Check the key code and event. if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_DOWN) { // The event is a key-down on the enter key. // Trigger the add domain listener and return the dialog fragment to the parent activity. - addDomainListener.onAddDomain(this) + addDomainListener.addDomain(this) // Manually dismiss the alert dialog. alertDialog.dismiss() diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt index 23fce5d8..1576c185 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt @@ -131,13 +131,15 @@ class DomainSettingsFragment : Fragment() { val ultraPrivacySwitch = domainSettingsView.findViewById(R.id.ultraprivacy_switch) val blockAllThirdPartyRequestsImageView = domainSettingsView.findViewById(R.id.block_all_third_party_requests_imageview) val blockAllThirdPartyRequestsSwitch = domainSettingsView.findViewById(R.id.block_all_third_party_requests_switch) - val userAgentLinearLayout = domainSettingsView.findViewById(R.id.user_agent_linear_layout) + val userAgentLinearLayout = domainSettingsView.findViewById(R.id.user_agent_linearlayout) val userAgentSpinner = domainSettingsView.findViewById(R.id.user_agent_spinner) val userAgentTextView = domainSettingsView.findViewById(R.id.user_agent_textview) val customUserAgentEditText = domainSettingsView.findViewById(R.id.custom_user_agent_edittext) + val fontSizeLinearLayout = domainSettingsView.findViewById(R.id.font_size_linearlayout) val fontSizeSpinner = domainSettingsView.findViewById(R.id.font_size_spinner) val defaultFontSizeTextView = domainSettingsView.findViewById(R.id.default_font_size_textview) val customFontSizeEditText = domainSettingsView.findViewById(R.id.custom_font_size_edittext) + val swipeToRefreshLinearLayout = domainSettingsView.findViewById(R.id.swipe_to_refresh_linearlayout) val swipeToRefreshImageView = domainSettingsView.findViewById(R.id.swipe_to_refresh_imageview) val swipeToRefreshSpinner = domainSettingsView.findViewById(R.id.swipe_to_refresh_spinner) val swipeToRefreshTextView = domainSettingsView.findViewById(R.id.swipe_to_refresh_textview) @@ -145,12 +147,14 @@ class DomainSettingsFragment : Fragment() { val webViewThemeImageView = domainSettingsView.findViewById(R.id.webview_theme_imageview) val webViewThemeSpinner = domainSettingsView.findViewById(R.id.webview_theme_spinner) val webViewThemeTextView = domainSettingsView.findViewById(R.id.webview_theme_textview) + val wideViewportLinearLayout = domainSettingsView.findViewById(R.id.wide_viewport_linearlayout) val wideViewportImageView = domainSettingsView.findViewById(R.id.wide_viewport_imageview) val wideViewportSpinner = domainSettingsView.findViewById(R.id.wide_viewport_spinner) val wideViewportTextView = domainSettingsView.findViewById(R.id.wide_viewport_textview) - val displayWebpageImagesImageView = domainSettingsView.findViewById(R.id.display_webpage_images_imageview) - val displayWebpageImagesSpinner = domainSettingsView.findViewById(R.id.display_webpage_images_spinner) - val displayImagesTextView = domainSettingsView.findViewById(R.id.display_webpage_images_textview) + val displayImagesLinearLayout = domainSettingsView.findViewById(R.id.display_images_linearlayout) + val displayImagesImageView = domainSettingsView.findViewById(R.id.display_images_imageview) + val displayImagesSpinner = domainSettingsView.findViewById(R.id.display_images_spinner) + val displayImagesTextView = domainSettingsView.findViewById(R.id.display_images_textview) val pinnedSslCertificateImageView = domainSettingsView.findViewById(R.id.pinned_ssl_certificate_imageview) val pinnedSslCertificateSwitch = domainSettingsView.findViewById(R.id.pinned_ssl_certificate_switch) val savedSslCardView = domainSettingsView.findViewById(R.id.saved_ssl_certificate_cardview) @@ -272,7 +276,7 @@ class DomainSettingsFragment : Fragment() { 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) @@ -411,7 +415,7 @@ class DomainSettingsFragment : Fragment() { swipeToRefreshTextView.setOnClickListener { swipeToRefreshSpinner.performClick() } webViewThemeTextView.setOnClickListener { webViewThemeSpinner.performClick() } wideViewportTextView.setOnClickListener { wideViewportSpinner.performClick() } - displayImagesTextView.setOnClickListener { displayWebpageImagesSpinner.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. @@ -499,6 +503,9 @@ class DomainSettingsFragment : Fragment() { // 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) @@ -511,6 +518,9 @@ class DomainSettingsFragment : Fragment() { // 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. @@ -536,6 +546,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -544,6 +557,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -552,6 +568,9 @@ class DomainSettingsFragment : Fragment() { // 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)) } } @@ -593,6 +612,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -601,6 +623,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -609,6 +634,9 @@ class DomainSettingsFragment : Fragment() { // 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)) } } @@ -618,7 +646,8 @@ class DomainSettingsFragment : Fragment() { // 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) { @@ -628,6 +657,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -636,6 +668,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -644,11 +679,14 @@ class DomainSettingsFragment : Fragment() { // 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)) } } // Display the website images mode in the spinner. - displayWebpageImagesSpinner.setSelection(displayImagesInt) + displayImagesSpinner.setSelection(displayImagesInt) // Set the default display images text. if (defaultDisplayWebpageImages) @@ -660,26 +698,35 @@ class DomainSettingsFragment : Fragment() { 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)) } } @@ -1050,12 +1097,18 @@ class DomainSettingsFragment : Fragment() { // 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)) } } @@ -1075,6 +1128,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -1083,6 +1139,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -1091,6 +1150,9 @@ class DomainSettingsFragment : Fragment() { // 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)) } } } @@ -1115,6 +1177,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -1123,6 +1188,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -1131,6 +1199,9 @@ class DomainSettingsFragment : Fragment() { // 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)) } } } @@ -1151,6 +1222,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -1159,6 +1233,9 @@ class DomainSettingsFragment : Fragment() { // 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 -> { @@ -1167,6 +1244,9 @@ class DomainSettingsFragment : Fragment() { // 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)) } } } @@ -1177,32 +1257,41 @@ class DomainSettingsFragment : Fragment() { } // 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)) } } } diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.kt b/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.kt index 00ffcb4a..194310b7 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2017-2022 Soren Stoutner . + * Copyright © 2017-2023 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -345,7 +345,7 @@ class DomainsDatabaseHelper(private val appContext: Context) : SQLiteOpenHelper( domainContentValues.put(ULTRALIST, ultraList) domainContentValues.put(ENABLE_ULTRAPRIVACY, ultraPrivacy) domainContentValues.put(BLOCK_ALL_THIRD_PARTY_REQUESTS, blockAllThirdPartyRequests) - domainContentValues.put(USER_AGENT, appContext.getString(R.string.user_agent_default_value)) + domainContentValues.put(USER_AGENT, appContext.getString(R.string.system_default_user_agent)) domainContentValues.put(FONT_SIZE, 0) domainContentValues.put(SWIPE_TO_REFRESH, 0) domainContentValues.put(WEBVIEW_THEME, 0) diff --git a/app/src/main/res/layout/domain_settings_fragment.xml b/app/src/main/res/layout/domain_settings_fragment.xml index 1e19683d..aaa5ecfd 100644 --- a/app/src/main/res/layout/domain_settings_fragment.xml +++ b/app/src/main/res/layout/domain_settings_fragment.xml @@ -20,18 +20,17 @@ + android:descendantFocusability="beforeDescendants" > @@ -39,7 +38,10 @@ + android:orientation="vertical" + android:layout_marginTop="12dp" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:orientation="horizontal" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" > + android:padding="12dp" > + + + android:padding="12dp" > + + + android:padding="12dp" > + + + android:padding="12dp" > + + + android:padding="12dp" > + + + android:padding="12dp" > + + + android:layout_marginBottom="18dp" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" + tools:ignore="TooManyViews" > + android:textSize="18sp" /> @@ -712,7 +766,8 @@ android:textSize="17sp" android:textAllCaps="true" android:textStyle="bold" - android:textColor="?android:textColorPrimary" /> + android:textColor="?android:textColorPrimary" + tools:ignore="TooManyViews" /> + android:layout_marginBottom="18dp" + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" >