/*
- * Copyright © 2017-2020,2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2017-2020,2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
@media (prefers-color-scheme: dark) {
strong.red {
- color: #930606; /* Red 1100. */
+ color: #E24B4C; /* Red Night. */
}
}
margin-right: auto;
height: 780;
width: 360;
-}
\ No newline at end of file
+}
// 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) -> {
package com.stoutner.privacybrowser.activities
-import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.text.SpannableStringBuilder
// 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()
/*
- * Copyright © 2018-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2018-2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
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;
// 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:
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:
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;
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;
}
// Return the modified view.
return view;
}
-}
\ No newline at end of file
+}
/*
- * Copyright © 2017-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2017-2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
// 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)
// Return the alert dialog.
return alertDialog
}
-}
\ No newline at end of file
+}
/*
- * Copyright © 2016-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2016-2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
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)
ipAddressesTextView.text = ipAddresses
}
}
-}
\ No newline at end of file
+}
/*
- * Copyright © 2021-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2021-2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
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)
dialog!!.dismiss()
}
}
-}
\ No newline at end of file
+}
/*
- * Copyright © 2018-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2018-2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
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
// 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)
// 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))
}
}
// Return the alert dialog.
return alertDialog
}
-}
\ No newline at end of file
+}
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `vpn_lock`. It is released under the Apache License 2.0. -->
+
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true" >
+
+ <path
+ android:fillColor="@color/blue_icon"
+ android:pathData="M22,4v-0.5C22,2.12 20.88,1 19.5,1S17,2.12 17,3.5L17,4c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1h5c0.55,0 1,-0.45 1,-1L23,5c0,-0.55 -0.45,-1 -1,-1zM21.2,4h-3.4v-0.5c0,-0.94 0.76,-1.7 1.7,-1.7s1.7,0.76 1.7,1.7L21.2,4zM18.92,12c0.04,0.33 0.08,0.66 0.08,1 0,2.08 -0.8,3.97 -2.1,5.39 -0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L7,13v-2h2c0.55,0 1,-0.45 1,-1L10,8h2c1.1,0 2,-0.9 2,-2L14,3.46c-0.95,-0.3 -1.95,-0.46 -3,-0.46C5.48,3 1,7.48 1,13s4.48,10 10,10 10,-4.48 10,-10c0,-0.34 -0.02,-0.67 -0.05,-1h-2.03zM10,20.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L8,16v1c0,1.1 0.9,2 2,2v1.93z" />
+</vector>
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `vpn_lock`. It is released under the Apache License 2.0. -->
-
-<vector
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:height="24dp"
- android:width="24dp"
- android:viewportHeight="24"
- android:viewportWidth="24"
- android:autoMirrored="true" >
-
- <path
- android:fillColor="@color/blue_icon"
- android:pathData="M22,4v-0.5C22,2.12 20.88,1 19.5,1S17,2.12 17,3.5L17,4c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1h5c0.55,0 1,-0.45 1,-1L23,5c0,-0.55 -0.45,-1 -1,-1zM21.2,4h-3.4v-0.5c0,-0.94 0.76,-1.7 1.7,-1.7s1.7,0.76 1.7,1.7L21.2,4zM18.92,12c0.04,0.33 0.08,0.66 0.08,1 0,2.08 -0.8,3.97 -2.1,5.39 -0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L7,13v-2h2c0.55,0 1,-0.45 1,-1L10,8h2c1.1,0 2,-0.9 2,-2L14,3.46c-0.95,-0.3 -1.95,-0.46 -3,-0.46C5.48,3 1,7.48 1,13s4.48,10 10,10 10,-4.48 10,-10c0,-0.34 -0.02,-0.67 -0.05,-1h-2.03zM10,20.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L8,16v1c0,1.1 0.9,2 2,2v1.93z" />
-</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2017,2019-2020,2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2017,2019-2020,2022 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/domain_name_already_exists"
- android:textColor="?attr/redTextColor"
+ android:textColor="@color/red_text"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
android:layout_marginTop="1dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
- android:src="@drawable/ssl_certificate_enabled"
+ android:src="@drawable/ssl_certificate"
app:tint="@color/blue_icon_selector"
tools:ignore="contentDescription" />
android:layout_marginTop="1dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
- android:src="@drawable/ssl_certificate_enabled"
+ android:src="@drawable/ssl_certificate"
app:tint="@color/blue_icon_selector"
tools:ignore="contentDescription" />
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2016-2017,2019-2020,2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017,2019-2020,2022 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
- android:textColor="?attr/redTextColor"
+ android:textColor="@color/red_text"
android:textStyle="bold"/>
<!-- URL. -->
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</LinearLayout>
-</ScrollView>
\ No newline at end of file
+</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2016-2017,2020,2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017,2020,2022 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
android:layout_height="match_parent"
android:layout_width="match_parent"
android:padding="15dp"
- android:textColor="?attr/redTextColor"
- android:text="@string/no_ssl_certificate" />
\ No newline at end of file
+ android:textColor="@color/red_text"
+ android:text="@string/no_ssl_certificate" />
<item name="android:actionModeBackground">?android:attr/colorBackground</item>
<item name="android:textColorHighlight">@color/violet_700</item>
<item name="colorAccent">@color/violet_500</item>
- <item name="redTextColor">@color/red_900</item>
<!-- Tints. -->
<item name="fabIconTintColor">@color/gray_875</item>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2016-2017,2020,2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017,2020,2022 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
<resources>
<!-- Nicknamed colors. -->
<color name="alt_blue_text">@color/violet_700</color>
+ <color name="blue_background">@color/blue_700_50</color>
<color name="blue_button">@color/violet_700</color>
<color name="blue_icon">@color/violet_500</color>
<color name="blue_text">@color/violet_500</color>
<color name="disabled_button">@color/gray_750</color>
<color name="disabled_button_text">@color/gray_500</color>
<color name="disabled_icon">@color/gray_500</color>
+ <color name="domain_settings_url_background">@color/dark_blue_40</color>
<color name="ghosted_icon">@color/gray_700</color>
<color name="icon">@color/white</color>
- <color name="domain_settings_url_background">@color/dark_blue_40</color>
- <color name="red_text">@color/red_900</color>
+ <color name="red_background">@color/red_700_40</color>
+ <color name="red_text">@color/red_night</color>
<color name="selected_icon_background">@color/gray_700</color>
<color name="translucent_background">@color/black_translucent_33</color>
-</resources>
\ No newline at end of file
+ <color name="yellow_background">@color/yellow_700_50</color>
+</resources>
<item name="android:actionModeBackground">?android:attr/colorBackground</item>
<item name="android:textColorHighlight">@color/violet_700</item>
<item name="colorAccent">@color/violet_500</item>
- <item name="redTextColor">@color/red_900</item>
<!-- Tints. -->
<item name="fabIconTintColor">@color/gray_875</item>
<item name="android:actionModeBackground">?android:attr/colorBackground</item>
<item name="android:textColorHighlight">@color/blue_200</item>
<item name="colorAccent">@color/blue_700</item>
- <item name="redTextColor">@color/red_a700</item>
<!-- Tints. -->
<item name="fabIconTintColor">@color/white</item>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2017-2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2017-2022 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
You should have received a copy of the GNU General Public License
along with Privacy Browser Android. If not, see <http://www.gnu.org/licenses/>. -->
+
<resources>
<!-- Colors. -->
<attr name="aboutBackground" format="color" />
<attr name="activatedListViewItemBackground" format="color" />
- <attr name="redTextColor" format="color" />
<!-- Tint Colors. -->
<attr name="fabIconTintColor" format="color" />
<!-- Drawables. -->
<attr name="listSelectorDrawable" format="reference" />
-</resources>
\ No newline at end of file
+</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2016-2017,2020,2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017,2020,2022 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
<resources>
<!-- Nicknamed colors. -->
<color name="alt_blue_text">@color/blue_700</color>
+ <color name="blue_background">@color/blue_100</color>
<color name="blue_button">@color/blue_600</color>
<color name="blue_icon">@color/blue_800</color>
<color name="blue_text">@color/blue_700</color>
<color name="disabled_button">@color/gray_300</color>
<color name="disabled_button_text">@color/gray_400</color>
<color name="disabled_icon">@color/gray_600</color>
+ <color name="domain_settings_url_background">@color/green_200</color>
<color name="ghosted_icon">@color/gray_425</color>
<color name="icon">@color/gray_925</color>
- <color name="domain_settings_url_background">@color/green_200</color>
+ <color name="red_background">@color/red_100</color>
<color name="red_text">@color/red_a700</color>
<color name="selected_icon_background">@color/gray_300</color>
<color name="translucent_background">@color/black_translucent_11</color>
+ <color name="yellow_background">@color/yellow_100</color>
<!-- Raw colors. -->
<color name="semi_transparent_black">#66000000</color>
<color name="red_1000">#FFA21212</color>
<color name="red_1100">#FF930606</color>
<color name="red_a700">#FFD50000</color>
+ <color name="red_night">#FFE24B4C</color>
<color name="transparent">#00000000</color>
<color name="yellow_700_50">#88FBC02D</color>
<color name="yellow_900">#FFF57F17</color>
<color name="yellow_a700">#FFFFD600</color>
-</resources>
\ No newline at end of file
+</resources>
<item name="android:actionModeBackground">?android:attr/colorBackground</item>
<item name="android:textColorHighlight">@color/blue_200</item>
<item name="colorAccent">@color/blue_700</item>
- <item name="redTextColor">@color/red_a700</item>
<!-- Tints. -->
<item name="fabIconTintColor">@color/white</item>