From f441c077da729e1d3d97c9efb46e8380a0730dd9 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Wed, 9 Nov 2022 15:46:54 -0700 Subject: [PATCH] Update the night mode red text color. https://redmine.stoutner.com/issues/691 --- app/src/main/assets/css/theme.css | 6 +-- .../activities/MainWebViewActivity.java | 13 +----- .../activities/ViewSourceActivity.kt | 22 ++-------- .../adapters/RequestsArrayAdapter.java | 26 +++-------- .../dialogs/PinnedMismatchDialog.kt | 6 +-- .../dialogs/SslCertificateErrorDialog.kt | 6 +-- .../dialogs/UntrustedSslCertificateDialog.kt | 6 +-- .../dialogs/ViewRequestDialog.kt | 44 +++++-------------- ...ficate_enabled.xml => ssl_certificate.xml} | 2 +- app/src/main/res/layout/add_domain_dialog.xml | 6 +-- .../res/layout/domain_settings_fragment.xml | 4 +- .../main/res/layout/ssl_certificate_error.xml | 6 +-- .../res/layout/unencrypted_website_dialog.xml | 6 +-- app/src/main/res/values-night-v27/styles.xml | 1 - app/src/main/res/values-night/colors.xml | 11 +++-- app/src/main/res/values-night/styles.xml | 1 - app/src/main/res/values-v27/styles.xml | 1 - app/src/main/res/values/attrs.xml | 6 +-- app/src/main/res/values/colors.xml | 10 +++-- app/src/main/res/values/styles.xml | 1 - 20 files changed, 63 insertions(+), 121 deletions(-) rename app/src/main/res/drawable/{ssl_certificate_enabled.xml => ssl_certificate.xml} (99%) diff --git a/app/src/main/assets/css/theme.css b/app/src/main/assets/css/theme.css index 3bdd0b90..aa6f4fdf 100644 --- a/app/src/main/assets/css/theme.css +++ b/app/src/main/assets/css/theme.css @@ -1,5 +1,5 @@ /* - * Copyright © 2017-2020,2022 Soren Stoutner . + * Copyright 2017-2020,2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -57,7 +57,7 @@ strong.red { @media (prefers-color-scheme: dark) { strong.red { - color: #930606; /* Red 1100. */ + color: #E24B4C; /* Red Night. */ } } @@ -172,4 +172,4 @@ img.center216 { margin-right: auto; height: 780; width: 360; -} \ No newline at end of file +} diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 1b34ffd8..e1a8ca78 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -3118,19 +3118,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Remove the lint warning below that the input method manager might be null. assert inputMethodManager != null; - // Initialize the gray foreground color spans for highlighting the URLs. + // Initialize the color spans for highlighting the URLs. initialGrayColorSpan = new ForegroundColorSpan(getColor(R.color.gray_500)); finalGrayColorSpan = new ForegroundColorSpan(getColor(R.color.gray_500)); - - // Get the current theme status. - int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - - // Set the red color span according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - redColorSpan = new ForegroundColorSpan(getColor(R.color.red_a700)); - } else { - redColorSpan = new ForegroundColorSpan(getColor(R.color.red_900)); - } + redColorSpan = new ForegroundColorSpan(getColor(R.color.red_text)); // Remove the formatting from the URL edit text when the user is editing the text. urlEditText.setOnFocusChangeListener((View v, boolean hasFocus) -> { diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewSourceActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewSourceActivity.kt index 3769a682..8868697a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewSourceActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewSourceActivity.kt @@ -19,7 +19,6 @@ package com.stoutner.privacybrowser.activities -import android.content.res.Configuration import android.os.Build import android.os.Bundle import android.text.SpannableStringBuilder @@ -139,23 +138,10 @@ class ViewSourceActivity: AppCompatActivity(), UntrustedSslCertificateListener { // Populate the URL text box. urlEditText.setText(currentUrl) - // Initialize the gray foreground color spans for highlighting the URLs. The deprecated `getColor()` must be used until the minimum API >= 23. - @Suppress("DEPRECATION") - initialGrayColorSpan = ForegroundColorSpan(resources.getColor(R.color.gray_500)) - @Suppress("DEPRECATION") - finalGrayColorSpan = ForegroundColorSpan(resources.getColor(R.color.gray_500)) - - // Get the current theme status. - val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK - - // Set the red color span according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23. - redColorSpan = if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - @Suppress("DEPRECATION") - ForegroundColorSpan(resources.getColor(R.color.red_a700)) - } else { - @Suppress("DEPRECATION") - ForegroundColorSpan(resources.getColor(R.color.red_900)) - } + // Initialize the gray foreground color spans for highlighting the URLs. + initialGrayColorSpan = ForegroundColorSpan(getColor(R.color.gray_500)) + finalGrayColorSpan = ForegroundColorSpan(getColor(R.color.gray_500)) + redColorSpan = ForegroundColorSpan(getColor(R.color.red_text)) // Apply text highlighting to the URL. highlightUrlText() diff --git a/app/src/main/java/com/stoutner/privacybrowser/adapters/RequestsArrayAdapter.java b/app/src/main/java/com/stoutner/privacybrowser/adapters/RequestsArrayAdapter.java index c1e2ee84..d253307d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/adapters/RequestsArrayAdapter.java +++ b/app/src/main/java/com/stoutner/privacybrowser/adapters/RequestsArrayAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018-2022 Soren Stoutner . + * Copyright 2018-2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -20,7 +20,6 @@ package com.stoutner.privacybrowser.adapters; import android.content.Context; -import android.content.res.Configuration; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -66,9 +65,6 @@ public class RequestsArrayAdapter extends ArrayAdapter { // The ID is one greater than the position because it is 0 based. int id = position + 1; - // Get the current theme status. - int currentThemeStatus = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - // Set the action text and the background color. switch (entryStringArray[0]) { case BlocklistHelper.REQUEST_DEFAULT: @@ -90,11 +86,7 @@ public class RequestsArrayAdapter extends ArrayAdapter { dispositionTextView.setText(requestAllowed); // Set the background color. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - linearLayout.setBackgroundColor(context.getColor(R.color.blue_100)); - } else { - linearLayout.setBackgroundColor(context.getColor(R.color.blue_700_50)); - } + linearLayout.setBackgroundColor(context.getColor(R.color.blue_background)); break; case BlocklistHelper.REQUEST_THIRD_PARTY: @@ -105,11 +97,7 @@ public class RequestsArrayAdapter extends ArrayAdapter { dispositionTextView.setText(requestThirdParty); // Set the background color. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - linearLayout.setBackgroundColor(context.getColor(R.color.yellow_100)); - } else { - linearLayout.setBackgroundColor(context.getColor(R.color.yellow_700_50)); - } + linearLayout.setBackgroundColor(context.getColor(R.color.yellow_background)); break; @@ -121,11 +109,7 @@ public class RequestsArrayAdapter extends ArrayAdapter { dispositionTextView.setText(requestBlocked); // Set the background color. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - linearLayout.setBackgroundColor(context.getColor(R.color.red_100)); - } else { - linearLayout.setBackgroundColor(context.getColor(R.color.red_700_40)); - } + linearLayout.setBackgroundColor(context.getColor(R.color.red_background)); break; } @@ -135,4 +119,4 @@ public class RequestsArrayAdapter extends ArrayAdapter { // Return the modified view. return view; } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.kt index 56ec5192..b3f6de21 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2017-2022 Soren Stoutner . + * Copyright 2017-2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -116,7 +116,7 @@ class PinnedMismatchDialog : DialogFragment() { // Set the favorite icon as the dialog icon if it exists. if (favoriteIconBitmap.sameAs(defaultFavoriteIconBitmap)) { // There is no website favorite icon. // Set the icon. - dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled) + dialogBuilder.setIcon(R.drawable.ssl_certificate) } else { // There is a favorite icon. // Create a drawable version of the favorite icon. val favoriteIconDrawable: Drawable = BitmapDrawable(resources, favoriteIconBitmap) @@ -220,4 +220,4 @@ class PinnedMismatchDialog : DialogFragment() { // Return the alert dialog. return alertDialog } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.kt index 1179c29e..1090bedd 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2022 Soren Stoutner . + * Copyright 2016-2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -136,7 +136,7 @@ class SslCertificateErrorDialog : DialogFragment() { val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog) // Set the icon. - dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled) + dialogBuilder.setIcon(R.drawable.ssl_certificate) // Set the title. dialogBuilder.setTitle(R.string.ssl_certificate_error) @@ -391,4 +391,4 @@ class SslCertificateErrorDialog : DialogFragment() { ipAddressesTextView.text = ipAddresses } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UntrustedSslCertificateDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UntrustedSslCertificateDialog.kt index f44710f8..97eef400 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UntrustedSslCertificateDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UntrustedSslCertificateDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2021-2022 Soren Stoutner . + * Copyright 2021-2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -56,7 +56,7 @@ class UntrustedSslCertificateDialog : DialogFragment() { val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog) // Set the icon. - dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled) + dialogBuilder.setIcon(R.drawable.ssl_certificate) // Set the title. dialogBuilder.setTitle(R.string.ssl_certificate_error) @@ -113,4 +113,4 @@ class UntrustedSslCertificateDialog : DialogFragment() { dialog!!.dismiss() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewRequestDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewRequestDialog.kt index 54e997af..55e6bb58 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewRequestDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewRequestDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2018-2022 Soren Stoutner . + * Copyright 2018-2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -22,13 +22,13 @@ package com.stoutner.privacybrowser.dialogs import android.app.Dialog import android.content.Context import android.content.DialogInterface -import android.content.res.Configuration import android.os.Bundle import android.view.View import android.view.WindowManager import android.widget.TextView import androidx.appcompat.app.AlertDialog +import androidx.core.content.ContextCompat.getColor import androidx.fragment.app.DialogFragment import androidx.preference.PreferenceManager @@ -93,9 +93,6 @@ class ViewRequestDialog : DialogFragment() { // Use an alert dialog builder to create the alert dialog. val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog) - // Get the current theme status. - val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK - // Set the icon. dialogBuilder.setIcon(R.drawable.block_ads_enabled) @@ -164,50 +161,31 @@ class ViewRequestDialog : DialogFragment() { // Set the text. requestDisposition.setText(R.string.default_allowed) - // Set the background color. The deprecated `getColor()` must be used until the minimum API >= 23. - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.transparent)) + // Set the background color to be transparent. + requestDisposition.setBackgroundColor(getColor(requireContext(), R.color.transparent)) } BlocklistHelper.REQUEST_ALLOWED -> { // Set the text. requestDisposition.setText(R.string.allowed) - // Set the background color according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.blue_100)) - } else { - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.blue_700_50)) - } + // Set the background color to be blue. + requestDisposition.setBackgroundColor(getColor(requireContext(), R.color.blue_background)) } BlocklistHelper.REQUEST_THIRD_PARTY -> { // Set the text. requestDisposition.setText(R.string.third_party_blocked) - // Set the background color according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.yellow_100)) - } else { - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.yellow_700_50)) - } + // Set the background color to be yellow. + requestDisposition.setBackgroundColor(getColor(requireContext(), R.color.yellow_background)) } BlocklistHelper.REQUEST_BLOCKED -> { // Set the text. requestDisposition.setText(R.string.blocked) - // Set the background color according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.red_100)) - } else { - @Suppress("DEPRECATION") - requestDisposition.setBackgroundColor(resources.getColor(R.color.red_700_40)) - } + // Set the background color to be red. + requestDisposition.setBackgroundColor(getColor(requireContext(), R.color.red_background)) } } @@ -259,4 +237,4 @@ class ViewRequestDialog : DialogFragment() { // Return the alert dialog. return alertDialog } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/ssl_certificate_enabled.xml b/app/src/main/res/drawable/ssl_certificate.xml similarity index 99% rename from app/src/main/res/drawable/ssl_certificate_enabled.xml rename to app/src/main/res/drawable/ssl_certificate.xml index e9d2e50e..dd6ac8c7 100644 --- a/app/src/main/res/drawable/ssl_certificate_enabled.xml +++ b/app/src/main/res/drawable/ssl_certificate.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/layout/add_domain_dialog.xml b/app/src/main/res/layout/add_domain_dialog.xml index f857fb69..557103cf 100644 --- a/app/src/main/res/layout/add_domain_dialog.xml +++ b/app/src/main/res/layout/add_domain_dialog.xml @@ -1,7 +1,7 @@ @@ -132,4 +132,4 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/unencrypted_website_dialog.xml b/app/src/main/res/layout/unencrypted_website_dialog.xml index 2e9d4fc3..9ad2b881 100644 --- a/app/src/main/res/layout/unencrypted_website_dialog.xml +++ b/app/src/main/res/layout/unencrypted_website_dialog.xml @@ -1,7 +1,7 @@ @color/gray_875 diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index e34c4998..8865e689 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -1,7 +1,7 @@ @color/violet_700 + @color/blue_700_50 @color/violet_700 @color/violet_500 @color/violet_500 @@ -29,10 +30,12 @@ @color/gray_750 @color/gray_500 @color/gray_500 + @color/dark_blue_40 @color/gray_700 @color/white - @color/dark_blue_40 - @color/red_900 + @color/red_700_40 + @color/red_night @color/gray_700 @color/black_translucent_33 - \ No newline at end of file + @color/yellow_700_50 + diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 483ab90a..513f3f2d 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -28,7 +28,6 @@ ?android:attr/colorBackground @color/violet_700 @color/violet_500 - @color/red_900 @color/gray_875 diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml index 82b618fb..f66d95fe 100644 --- a/app/src/main/res/values-v27/styles.xml +++ b/app/src/main/res/values-v27/styles.xml @@ -30,7 +30,6 @@ ?android:attr/colorBackground @color/blue_200 @color/blue_700 - @color/red_a700 @color/white diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index fa72362d..db6a6efa 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,7 +1,7 @@ + - @@ -31,4 +31,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ae185134..3b2e546f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,7 +1,7 @@ @color/blue_700 + @color/blue_100 @color/blue_600 @color/blue_800 @color/blue_700 @@ -29,12 +30,14 @@ @color/gray_300 @color/gray_400 @color/gray_600 + @color/green_200 @color/gray_425 @color/gray_925 - @color/green_200 + @color/red_100 @color/red_a700 @color/gray_300 @color/black_translucent_11 + @color/yellow_100 #66000000 @@ -110,6 +113,7 @@ #FFA21212 #FF930606 #FFD50000 + #FFE24B4C #00000000 @@ -120,4 +124,4 @@ #88FBC02D #FFF57F17 #FFFFD600 - \ No newline at end of file + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f3a7411e..2fdf9bb5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -28,7 +28,6 @@ ?android:attr/colorBackground @color/blue_200 @color/blue_700 - @color/red_a700 @color/white -- 2.43.0