import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
// bookmarksListView is 0 indexed.
int lastBookmarkDatabaseId = (int) bookmarksListView.getItemIdAtPosition(bookmarksListView.getCount() - 1);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Update the move bookmark up `MenuItem`.
+ // Update the move bookmark up menu item.
if (selectedBookmarkDatabaseId == firstBookmarkDatabaseId) { // The selected bookmark is in the first position.
- // Disable the move bookmark up `MenuItem`.
+ // Disable the move bookmark up menu item.
moveBookmarkUpMenuItem.setEnabled(false);
- // Set the move bookmark up icon to be ghosted.
+ // Set the icon.
moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_disabled);
} else { // The selected bookmark is not in the first position.
// Enable the move bookmark up menu item.
moveBookmarkUpMenuItem.setEnabled(true);
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_night);
- } else {
- moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_day);
- }
+ moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled);
}
- // Update the move bookmark down `MenuItem`.
+ // Update the move bookmark down menu item.
if (selectedBookmarkDatabaseId == lastBookmarkDatabaseId) { // The selected bookmark is in the last position.
- // Disable the move bookmark down `MenuItem`.
+ // Disable the move bookmark down menu item.
moveBookmarkDownMenuItem.setEnabled(false);
- // Set the move bookmark down icon to be ghosted.
+ // Set the icon.
moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_disabled);
} else { // The selected bookmark is not in the last position.
- // Enable the move bookmark down `MenuItem`.
+ // Enable the move bookmark down menu item.
moveBookmarkDownMenuItem.setEnabled(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_night);
- } else {
- moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_day);
- }
+ // Set the icon.
+ moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled);
}
}
// Inflate the menu.
getMenuInflater().inflate(R.menu.bookmarks_databaseview_options_menu, menu);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
// Get a handle for the sort menu item.
MenuItem sortMenuItem = menu.findItem(R.id.sort);
// Change the sort menu item icon if the listview is sorted by display order, which restores the state after a restart.
if (sortByDisplayOrder) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- sortMenuItem.setIcon(R.drawable.sort_selected_day);
- } else {
- sortMenuItem.setIcon(R.drawable.sort_selected_night);
- }
+ sortMenuItem.setIcon(R.drawable.sort_selected);
}
// Success.
// Get a handle for the bookmarks list view.
ListView bookmarksListView = findViewById(R.id.bookmarks_databaseview_listview);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
// Update the icon and display a snackbar.
if (sortByDisplayOrder) { // Sort by display order.
- // Update the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- menuItem.setIcon(R.drawable.sort_selected_day);
- } else {
- menuItem.setIcon(R.drawable.sort_selected_night);
- }
+ // Update the icon.
+ menuItem.setIcon(R.drawable.sort_selected);
// Display a Snackbar indicating the current sort type.
Snackbar.make(bookmarksListView, R.string.sorted_by_display_order, Snackbar.LENGTH_SHORT).show();
} else { // Sort by database id.
- // Update the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- menuItem.setIcon(R.drawable.sort_day);
- } else {
- menuItem.setIcon(R.drawable.sort_night);
- }
+ // Update the icon.
+ menuItem.setIcon(R.drawable.sort);
// Display a Snackbar indicating the current sort type.
Snackbar.make(bookmarksListView, R.string.sorted_by_database_id, Snackbar.LENGTH_SHORT).show();
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.os.Bundle;
// Enable the options delete menu item.
deleteMenuItem.setEnabled(true);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the delete menu item icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- deleteMenuItem.setIcon(R.drawable.delete_night);
- } else {
- deleteMenuItem.setIcon(R.drawable.delete_day);
- }
+ // Set the delete menu item icon.
+ deleteMenuItem.setIcon(R.drawable.delete_enabled);
} else { // The device in in one-paned mode.
// Display the domain settings fragment.
fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
// Enable the delete menu item.
deleteMenuItem.setEnabled(true);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the delete menu item icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- deleteMenuItem.setIcon(R.drawable.delete_night);
- } else {
- deleteMenuItem.setIcon(R.drawable.delete_day);
- }
+ // Set the delete menu item icon.
+ deleteMenuItem.setIcon(R.drawable.delete_enabled);
} else { // Single-paned mode.
// Show the delete menu item.
deleteMenuItem.setVisible(true);
// Enable the delete options menu items.
deleteMenuItem.setEnabled(true);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the delete icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- deleteMenuItem.setIcon(R.drawable.delete_night);
- } else {
- deleteMenuItem.setIcon(R.drawable.delete_day);
- }
+ // Set the delete icon.
+ deleteMenuItem.setIcon(R.drawable.delete_enabled);
} else if (twoPanedMode) { // Two-paned mode is enabled but there are no domains.
// Disable the options `MenuItems`.
deleteMenuItem.setEnabled(false);
Snackbar.make(currentWebView, getString(R.string.file_saved) + " " + fileNameString, Snackbar.LENGTH_SHORT).show();
} catch (Exception exception) {
// Display a snackbar with the exception.
- Snackbar.make(currentWebView, getString(R.string.error_saving_file) + " " + exception.toString(), Snackbar.LENGTH_INDEFINITE).show();
+ Snackbar.make(currentWebView, getString(R.string.error_saving_file) + " " + exception, Snackbar.LENGTH_INDEFINITE).show();
} finally {
// Delete the temporary MHT file.
//noinspection ResultOfMethodCallIgnored
});
} catch (IOException ioException) {
// Display a snackbar with the IO exception.
- Snackbar.make(currentWebView, getString(R.string.error_saving_file) + " " + ioException.toString(), Snackbar.LENGTH_INDEFINITE).show();
+ Snackbar.make(currentWebView, getString(R.string.error_saving_file) + " " + ioException, Snackbar.LENGTH_INDEFINITE).show();
}
}
}
// Set the title.
optionsRefreshMenuItem.setTitle(R.string.stop);
- // Set the icon if it is displayed in the app bar.
+ // Set the icon if it is displayed in the app bar. Once the minimum API is >= 26, the blue and black icons can be combined with a tint list.
if (displayAdditionalAppBarIcons) {
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the icon according to the current theme status.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- optionsRefreshMenuItem.setIcon(R.drawable.close_blue_day);
- } else {
- optionsRefreshMenuItem.setIcon(R.drawable.close_blue_night);
- }
+ optionsRefreshMenuItem.setIcon(R.drawable.close_blue);
}
}
// Initialize the formatted URL string.
String url = "";
- // Check to see if `unformattedUrlString` is a valid URL. Otherwise, convert it into a search.
+ // Check to see if the unformatted URL string is a valid URL. Otherwise, convert it into a search.
if (unformattedUrlString.startsWith("content://")) { // This is a Content URL.
// Load the entire content URL.
url = unformattedUrlString;
} else if (Patterns.WEB_URL.matcher(unformattedUrlString).matches() || unformattedUrlString.startsWith("http://") || unformattedUrlString.startsWith("https://") ||
unformattedUrlString.startsWith("file://")) { // This is a standard URL.
// Add `https://` at the beginning if there is no protocol. Otherwise the app will segfault.
- if (!unformattedUrlString.startsWith("http") && !unformattedUrlString.startsWith("file://") && !unformattedUrlString.startsWith("content://")) {
+ if (!unformattedUrlString.startsWith("http") && !unformattedUrlString.startsWith("file://")) {
unformattedUrlString = "https://" + unformattedUrlString;
}
- // Initialize `unformattedUrl`.
+ // Initialize the unformatted URL.
URL unformattedUrl = null;
- // Convert `unformattedUrlString` to a `URL`, then to a `URI`, and then back to a `String`, which sanitizes the input and adds in any missing components.
+ // Convert the unformatted URL string to a URL, then to a URI, and then back to a string, which sanitizes the input and adds in any missing components.
try {
unformattedUrl = new URL(unformattedUrlString);
} catch (MalformedURLException e) {
currentWebView.loadUrl(temporaryMhtFile.toString());
} catch (Exception exception) {
// Display a snackbar.
- Snackbar.make(currentWebView, getString(R.string.error) + " " + exception.toString(), Snackbar.LENGTH_INDEFINITE).show();
+ Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show();
}
} else { // Let the WebView handle opening of the file.
// Open the file.
break;
}
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
// Set a background on the URL relative layout to indicate that custom domain settings are being used.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.url_bar_background_light_green, null));
- } else {
- urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.url_bar_background_dark_blue, null));
- }
+ urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.domain_settings_url_background, null));
} else { // The new URL does not have custom domain settings. Load the defaults.
// Store the values from the shared preferences.
nestedScrollWebView.getSettings().setJavaScriptEnabled(sharedPreferences.getBoolean("javascript", false));
optionsPrivacyMenuItem.setIcon(R.drawable.privacy_mode);
}
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
// Update the cookies icon.
- if (currentWebView.getAcceptCookies()) { // Cookies are enabled.
+ if (currentWebView.getAcceptCookies()) {
optionsCookiesMenuItem.setIcon(R.drawable.cookies_enabled);
- } else { // Cookies are disabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- optionsCookiesMenuItem.setIcon(R.drawable.cookies_disabled_day);
- } else {
- optionsCookiesMenuItem.setIcon(R.drawable.cookies_disabled_night);
- }
+ } else {
+ optionsCookiesMenuItem.setIcon(R.drawable.cookies_disabled);
}
// Update the refresh icon.
if (optionsRefreshMenuItem.getTitle() == getString(R.string.refresh)) { // The refresh icon is displayed.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- optionsRefreshMenuItem.setIcon(R.drawable.refresh_enabled_day);
- } else {
- optionsRefreshMenuItem.setIcon(R.drawable.refresh_enabled_night);
- }
+ // Set the icon. Once the minimum API is >= 26, the blue and black icons can be combined with a tint list.
+ optionsRefreshMenuItem.setIcon(R.drawable.refresh_enabled);
} else { // The stop icon is displayed.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- optionsRefreshMenuItem.setIcon(R.drawable.close_blue_day);
- } else {
- optionsRefreshMenuItem.setIcon(R.drawable.close_blue_night);
- }
+ // Set the icon. Once the minimum API is >= 26, the blue and black icons can be combined with a tint list.
+ optionsRefreshMenuItem.setIcon(R.drawable.close_blue);
}
// `invalidateOptionsMenu()` calls `onPrepareOptionsMenu()` and redraws the icons in the app bar.
// Set the background to indicate the domain settings status.
if (currentWebView.getDomainSettingsApplied()) {
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set a green background on the URL relative layout to indicate that custom domain settings are being used.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.url_bar_background_light_green, null));
- } else {
- urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.url_bar_background_dark_blue, null));
- }
+ // Set a background on the URL relative layout to indicate that custom domain settings are being used.
+ urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.domain_settings_url_background, null));
} else {
+ // Remove any background on the URL relative layout.
urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.color.transparent, null));
}
} else { // The fragment has not been populated. Try again in 100 milliseconds.
// Get the app bar and theme preferences.
boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean(getString(R.string.display_additional_app_bar_icons_key), false);
- // If the icon is displayed in the AppBar, set it according to the theme.
+ // Set the icon if it is displayed in the AppBar. Once the minimum API is >= 26, the blue and black icons can be combined with a tint list.
if (displayAdditionalAppBarIcons) {
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the stop icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- optionsRefreshMenuItem.setIcon(R.drawable.close_blue_day);
- } else {
- optionsRefreshMenuItem.setIcon(R.drawable.close_blue_night);
- }
+ optionsRefreshMenuItem.setIcon(R.drawable.close_blue);
}
}
}
// If the icon is displayed in the app bar, reset it according to the theme.
if (displayAdditionalAppBarIcons) {
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- optionsRefreshMenuItem.setIcon(R.drawable.refresh_enabled_day);
- } else {
- optionsRefreshMenuItem.setIcon(R.drawable.refresh_enabled_night);
- }
+ // Set the icon.
+ optionsRefreshMenuItem.setIcon(R.drawable.refresh_enabled);
}
}
}
}
- // Handle SSL Certificate errors.
+ // Handle SSL Certificate errors. Suppress the lint warning that ignoring the error might be dangerous.
+ @SuppressLint("WebViewClientOnReceivedSslError")
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
// Get the current website SSL certificate.
package com.stoutner.privacybrowser.adapters
import android.content.Context
-import android.content.res.Configuration
import android.net.Uri
import android.text.SpannableStringBuilder
import android.text.Spanned
}
}
- // Define the color spans.
- val blueColorSpan: ForegroundColorSpan
- val redColorSpan: ForegroundColorSpan
-
- // Get the current theme status.
- val currentThemeStatus = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
-
- // Set the color spans according to the theme. The deprecated `resources` must be used until the minimum API >= 23.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- blueColorSpan = ForegroundColorSpan(context.getColor(R.color.blue_700))
- redColorSpan = ForegroundColorSpan(context.getColor(R.color.red_a700))
- } else {
- blueColorSpan = ForegroundColorSpan(context.getColor(R.color.violet_700))
- redColorSpan = ForegroundColorSpan(context.getColor(R.color.red_900))
- }
+ // Create the color spans.
+ val blueColorSpan = ForegroundColorSpan(context.getColor(R.color.blue_text))
+ val redColorSpan = ForegroundColorSpan(context.getColor(R.color.red_text))
// Set the domain name to be blue.
domainNameStringBuilder.setSpan(blueColorSpan, domainNameLabel.length, domainNameStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
// Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.aboutBlueIcon)
+ dialogBuilder.setIcon(R.drawable.about_blue)
// Set the title.
dialogBuilder.setTitle(R.string.about_view_source)
// Use an alert dialog builder to create the alert dialog.
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.domainsBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.domains)
// Set the title.
dialogBuilder.setTitle(R.string.add_domain)
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
// Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.fontSizeBlueIcon)
+ dialogBuilder.setIcon(R.drawable.font_size)
// Set the title.
dialogBuilder.setTitle(R.string.font_size)
import android.app.Dialog
import android.content.DialogInterface
-import android.content.res.Configuration
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.text.Spanned
// Use an alert dialog builder to create the alert dialog.
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.lockBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.lock)
// Set the title.
dialogBuilder.setTitle(R.string.http_authentication)
val hostLabel = getString(R.string.host) + " "
val hostStringBuilder = SpannableStringBuilder(hostLabel + httpAuthHost)
- // Get the current theme status.
- val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
-
- // Set the blue color span according to the theme. The deprecated `getColor()` must be used until API >= 23.
- val blueColorSpan = if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- @Suppress("DEPRECATION")
- ForegroundColorSpan(resources.getColor(R.color.blue_700))
- } else {
- @Suppress("DEPRECATION")
- ForegroundColorSpan(resources.getColor(R.color.violet_700))
- }
+ // Set the blue color span.
+ val blueColorSpan = ForegroundColorSpan(requireContext().getColor(R.color.blue_text))
// Setup the span to display the host name in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
hostStringBuilder.setSpan(blueColorSpan, hostLabel.length, hostStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
// Use an alert dialog builder to create the alert dialog.
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.moveToFolderBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.move_to_folder_blue)
// Set the title.
dialogBuilder.setTitle(R.string.move_to_folder)
// Use an alert dialog builder to create the alert dialog.
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.proxyBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.proxy_enabled)
// Set the title.
dialogBuilder.setTitle(R.string.open)
// Set the favorite icon as the dialog icon if it exists.
if (favoriteIconBitmap.sameAs(defaultFavoriteIconBitmap)) { // There is no website favorite icon.
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.sslCertificateBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled)
} else { // There is a favorite icon.
// Create a drawable version of the favorite icon.
val favoriteIconDrawable: Drawable = BitmapDrawable(resources, favoriteIconBitmap)
// Use a builder to create the alert dialog.
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.proxyBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.proxy_enabled)
// Set the title and the message according to the proxy mode.
when (proxyMode) {
// Set the title.
dialogBuilder.setTitle(R.string.save_url)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.copyBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.download)
// Set the view.
dialogBuilder.setView(R.layout.save_dialog)
import android.app.Activity
import android.app.Dialog
import android.content.DialogInterface
-import android.content.res.Configuration
import android.net.Uri
import android.net.http.SslError
import android.os.AsyncTask
// 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 according to the theme.
- dialogBuilder.setIconAttribute(R.attr.sslCertificateBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled)
// Set the title.
dialogBuilder.setTitle(R.string.ssl_certificate_error)
val endDateStringBuilder = SpannableStringBuilder(endDateLabel + endDate)
// Define the color spans.
- val blueColorSpan: ForegroundColorSpan
- val redColorSpan: ForegroundColorSpan
-
- // Set the color spans according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- @Suppress("DEPRECATION")
- blueColorSpan = ForegroundColorSpan(resources.getColor(R.color.blue_700))
- @Suppress("DEPRECATION")
- redColorSpan = ForegroundColorSpan(resources.getColor(R.color.red_a700))
- } else {
- @Suppress("DEPRECATION")
- blueColorSpan = ForegroundColorSpan(resources.getColor(R.color.violet_700))
- @Suppress("DEPRECATION")
- redColorSpan = ForegroundColorSpan(resources.getColor(R.color.red_900))
- }
+ val blueColorSpan = ForegroundColorSpan(requireContext().getColor(R.color.blue_text))
+ val redColorSpan = ForegroundColorSpan(requireContext().getColor(R.color.red_text))
// Setup the spans to display the certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
urlStringBuilder.setSpan(blueColorSpan, urlLabel.length, urlStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
}
SslError.SSL_UNTRUSTED -> {
- // Change the issued by text view text to red. The deprecated `getColor()` must be used until the minimum API >= 23.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- @Suppress("DEPRECATION")
- issuedByTextView.setTextColor(resources.getColor(R.color.red_a700))
- } else {
- @Suppress("DEPRECATION")
- issuedByTextView.setTextColor(resources.getColor(R.color.red_900))
- }
+ // Change the issued by text view text to red.
+ issuedByTextView.setTextColor(requireContext().getColor(R.color.red_text))
// Change the issued by span color to red.
issuedByCNameStringBuilder.setSpan(redColorSpan, cNameLabel.length, issuedByCNameStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
}
SslError.SSL_DATE_INVALID -> {
- // Change the valid dates text view text to red. The deprecated `getColor()` must be used until the minimum API >= 23.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- @Suppress("DEPRECATION")
- validDatesTextView.setTextColor(resources.getColor(R.color.red_a700))
- } else {
- @Suppress("DEPRECATION")
- validDatesTextView.setTextColor(resources.getColor(R.color.red_900))
- }
+ // Change the valid dates text view text to red.
+ validDatesTextView.setTextColor(requireContext().getColor(R.color.red_text))
// Change the date span colors to red.
startDateStringBuilder.setSpan(redColorSpan, startDateLabel.length, startDateStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
// Create a spannable string builder.
val ipAddressesStringBuilder = SpannableStringBuilder(ipAddressesLabel + ipAddresses)
- // Create a blue foreground color span.
- val blueColorSpan: ForegroundColorSpan
-
- // Get the current theme status.
- val currentThemeStatus = activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
-
- // Set the blue color span according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23.
- blueColorSpan = if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- @Suppress("DEPRECATION")
- ForegroundColorSpan(activity.resources.getColor(R.color.blue_700))
- } else {
- @Suppress("DEPRECATION")
- ForegroundColorSpan(activity.resources.getColor(R.color.violet_500))
- }
+ // Create a blue color span according to the theme.
+ val blueColorSpan = ForegroundColorSpan(activity.getColor(R.color.blue_text))
// Set the string builder to display the certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
ipAddressesStringBuilder.setSpan(blueColorSpan, ipAddressesLabel.length, ipAddressesStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
// Use a builder to create the alert dialog.
val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.sslCertificateBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled)
// Set the title.
dialogBuilder.setTitle(R.string.ssl_certificate_error)
// Get the current theme status.
val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
- // Set the icon according to the theme.
- dialogBuilder.setIconAttribute(R.attr.blockAdsBlueIcon)
+ // Set the icon.
+ dialogBuilder.setIcon(R.drawable.block_ads_enabled)
// Set the title.
dialogBuilder.setTitle(resources.getString(R.string.request_details) + " - " + id)
package com.stoutner.privacybrowser.dialogs
import android.app.Dialog
-import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.drawable.BitmapDrawable
val endDateStringBuilder = SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(endDate))
// Define the color spans.
- val blueColorSpan: ForegroundColorSpan
- val redColorSpan: ForegroundColorSpan
-
- // Get the current theme status.
- val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
-
- // Set the color spans according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- @Suppress("DEPRECATION")
- blueColorSpan = ForegroundColorSpan(resources.getColor(R.color.blue_700))
- @Suppress("DEPRECATION")
- redColorSpan = ForegroundColorSpan(resources.getColor(R.color.red_a700))
- } else {
- @Suppress("DEPRECATION")
- blueColorSpan = ForegroundColorSpan(resources.getColor(R.color.violet_700))
- @Suppress("DEPRECATION")
- redColorSpan = ForegroundColorSpan(resources.getColor(R.color.red_900))
- }
+ val blueColorSpan = ForegroundColorSpan(requireContext().getColor(R.color.blue_text))
+ val redColorSpan = ForegroundColorSpan(requireContext().getColor(R.color.red_text))
// Format the domain string and issued to CName colors.
if (domainString == issuedToCName) { // The domain and issued to CName match.
savedSslEndDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(savedSslEndDate));
}
- // Create the foreground color spans.
- final ForegroundColorSpan blueColorSpan;
- final ForegroundColorSpan redColorSpan;
-
- // Set the color spans according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- blueColorSpan = new ForegroundColorSpan(context.getColor(R.color.blue_700));
- redColorSpan = new ForegroundColorSpan(context.getColor(R.color.red_a700));
- } else {
- blueColorSpan = new ForegroundColorSpan(context.getColor(R.color.violet_700));
- redColorSpan = new ForegroundColorSpan(context.getColor(R.color.red_900));
- }
+ // Create the color spans.
+ final ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(context.getColor(R.color.blue_text));
+ final ForegroundColorSpan redColorSpan = new ForegroundColorSpan(context.getColor(R.color.red_text));
// Set the domain name from the the database cursor.
domainNameEditText.setText(domainNameString);
}
// Set the cookies switch status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (cookiesInt == 1) { // Cookies are enabled.
// Turn the switch on.
cookiesSwitch.setChecked(true);
// Turn the switch off
cookiesSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
- } else {
- cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
- }
+ // Set the icon.
+ cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled, null));
}
// Only enable DOM storage if JavaScript is enabled.
domStorageSwitch.setEnabled(true);
// Set the DOM storage status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (domStorageInt == 1) { // Both JavaScript and DOM storage are enabled.
domStorageSwitch.setChecked(true);
domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
// Set the DOM storage switch to off.
domStorageSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
- } else {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
- }
+ // Set the icon.
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null));
}
} else { // JavaScript is disabled.
- // Disable the DOM storage `Switch`.
+ // Disable the DOM storage switch.
domStorageSwitch.setEnabled(false);
// Set the checked status of DOM storage.
domStorageSwitch.setChecked(domStorageInt == 1);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_night, null));
- } else {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_day, null));
- }
+ // Set the icon.
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted, null));
}
// Set the form data visibility. Form data can be removed once the minimum API >= 26.
// Turn the form data switch to off.
formDataSwitch.setChecked(false);
- // Set the icon according to the theme. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_night, null));
- } else {
- formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_day, null));
- }
+ // Set the icon. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
+ formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled, null));
}
}
// Set the EasyList status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (easyListInt == 1) { // EasyList is on.
// Turn the switch on.
easyListSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
- } else {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
- }
+ // Set the icon.
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, null));
} else { // EasyList is off.
// Turn the switch off.
easyListSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
- } else {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
- }
+ // Set the icon.
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null));
}
// Set the EasyPrivacy status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (easyPrivacyInt == 1) { // EasyPrivacy is on.
// Turn the switch on.
easyPrivacySwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
- } else {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
- }
+ // Set the icon.
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, null));
} else { // EasyPrivacy is off.
// Turn the switch off.
easyPrivacySwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
- } else {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
- }
+ // Set the icon.
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, null));
}
// Set the Fanboy's Annoyance List status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (fanboysAnnoyanceListInt == 1) { // Fanboy's Annoyance List is on.
// Turn the switch on.
fanboysAnnoyanceListSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
- } else {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
- }
+ // Set the icon.
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null));
} else { // Fanboy's Annoyance List is off.
// Turn the switch off.
fanboysAnnoyanceListSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
- } else {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
- }
+ // Set the icon.
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null));
}
// Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off.
fanboysSocialBlockingListSwitch.setEnabled(true);
// Enable Fanboy's Social Blocking List. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (fanboysSocialBlockingListInt == 1) { // Fanboy's Social Blocking List is on.
// Turn on Fanboy's Social Blocking List switch.
fanboysSocialBlockingListSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
- }
+ // Set the icon.
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null));
} else { // Fanboy's Social Blocking List is off.
// Turn off Fanboy's Social Blocking List switch.
fanboysSocialBlockingListSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
- }
+ // Set the icon.
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null));
}
} else { // Fanboy's Annoyance List is on.
// Disable Fanboy's Social Blocking List switch.
// Set the status of Fanboy's Social Blocking List.
fanboysSocialBlockingListSwitch.setChecked(fanboysSocialBlockingListInt == 1);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_day, null));
- }
+ // Set the icon.
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted, null));
}
// Set the UltraList status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (ultraListInt == 1) { // UltraList is on.
// Turn the switch on.
ultraListSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
- } else {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
- }
+ // Set the icon.
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, null));
} else { // UltraList is off.
// Turn the switch off.
ultraListSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
- } else {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
- }
+ // Set the icon.
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null));
}
// Set the UltraPrivacy status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (ultraPrivacyInt == 1) { // UltraPrivacy is on.
// Turn the switch on.
ultraPrivacySwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
- } else {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
- }
+ // Set the icon.
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, null));
} else { // EasyPrivacy is off.
// Turn the switch off.
ultraPrivacySwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
- } else {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
- }
+ // Set the icon.
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, null));
}
// Set the third-party resource blocking status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
if (blockAllThirdPartyRequestsInt == 1) { // Blocking all third-party requests is on.
// Turn the switch on.
blockAllThirdPartyRequestsSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_night, null));
- } else {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_day, null));
- }
+ // Set the icon.
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled, null));
} else { // Blocking all third-party requests is off.
// Turn the switch off.
blockAllThirdPartyRequestsSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_night, null));
- } else {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_day, null));
- }
+ // Set the icon.
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled, null));
}
// Inflated a WebView to get the default user agent.
swipeToRefreshTextView.setText(swipeToRefreshArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED));
}
- // Set the swipe to refresh icon and TextView settings. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Set the swipe to refresh icon and text view settings. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
switch (swipeToRefreshInt) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT:
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
- }
- } else { // Swipe to refresh is disabled by default
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
- }
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null));
+ } else {
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null));
}
- // Show the swipe to refresh TextView.
+ // Show the swipe to refresh text view.
swipeToRefreshTextView.setVisibility(View.VISIBLE);
break;
case DomainsDatabaseHelper.ENABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
- }
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null));
- // Hide the swipe to refresh TextView.`
+ // Hide the swipe to refresh text view.
swipeToRefreshTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DISABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
- }
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null));
- // Hide the swipe to refresh TextView.
+ // Hide the swipe to refresh text view.
swipeToRefreshTextView.setVisibility(View.GONE);
break;
}
- // Open the swipe to refresh spinner when the TextView is clicked.
+ // Open the swipe to refresh spinner when the text view is clicked.
swipeToRefreshTextView.setOnClickListener((View v) -> {
// Open the swipe to refresh spinner.
swipeToRefreshSpinner.performClick();
}
// Set the WebView theme icon and text visibility. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
switch (webViewThemeInt) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT: // The domain WebView theme is system default.
// Set the icon according to the app WebView theme.
case DomainsDatabaseHelper.SYSTEM_DEFAULT: // The default WebView theme is system default.
// Set the icon according to the app theme.
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- // Set the light mode icon.
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
+ // Set the light theme icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null));
} else {
// Set the dark theme icon.
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null));
}
break;
case DomainsDatabaseHelper.LIGHT_THEME: // the default WebView theme is light.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null));
break;
case DomainsDatabaseHelper.DARK_THEME: // the default WebView theme is dark.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null)); }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null));
break;
}
break;
case DomainsDatabaseHelper.LIGHT_THEME: // The domain WebView theme is light.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null));
// Hide the WebView theme text view.
webViewThemeTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DARK_THEME: // The domain WebView theme is dark.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null));
// Hide the WebView theme text view.
webViewThemeTextView.setVisibility(View.GONE);
}
// Set the wide viewport icon and text view settings. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
switch (wideViewportInt) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+ // Set the icon.
if (defaultWideViewport) { // Wide viewport enabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
- }
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, null));
} else { // Wide viewport disabled by default.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
- }
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null));
}
// Show the wide viewport text view.
case DomainsDatabaseHelper.ENABLED:
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
- }
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, null));
// Hide the wide viewport text view.
wideViewportTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DISABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
- }
+ // Set the icon.
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null));
// Hide the wide viewport text view.
wideViewportTextView.setVisibility(View.GONE);
}
// Set the display website images icon and text view settings. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
switch (displayImagesInt) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT:
if (defaultDisplayWebpageImages) { // Display webpage images enabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, null));
} else { // Display webpage images disabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null));
}
// Show the display images text view.
break;
case DomainsDatabaseHelper.ENABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, null));
// Hide the display images text view.
displayImagesTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DISABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null));
// Hide the display images text view.
displayImagesTextView.setVisibility(View.GONE);
// Set the pinned SSL certificate icon.
if (pinnedSslCertificateInt == 1) { // Pinned SSL certificate is enabled. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
// Check the switch.
pinnedSslCertificateSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
- } else {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
- }
+ // Set the icon.
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, null));
} else { // Pinned SSL certificate is disabled.
// Uncheck the switch.
pinnedSslCertificateSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
- } else {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
- }
+ // Set the icon.
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null));
}
// Store the current date.
// Set the pinned IP addresses icon.
if (pinnedIpAddressesInt == 1) { // Pinned IP addresses is enabled. Once the minimum API >= 21 a selector can be sued as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
// Check the switch.
pinnedIpAddressesSwitch.setChecked(true);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
- } else {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
- }
+ // Set the icon.
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, null));
} else { // Pinned IP Addresses is disabled.
// Uncheck the switch.
pinnedIpAddressesSwitch.setChecked(false);
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
- } else {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
- }
+ // Set the icon.
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null));
}
// Populate the saved and current IP addresses.
if (domStorageSwitch.isChecked()) { // DOM storage is enabled.
domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
} else { // DOM storage is disabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
- } else {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
- }
+ // Set the icon.
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null));
}
} else { // JavaScript is disabled.
// Update the JavaScript icon.
javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.privacy_mode, null));
- // Disable the DOM storage `Switch`.
+ // Disable the DOM storage switch.
domStorageSwitch.setEnabled(false);
- // Set the DOM storage icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_night, null));
- } else {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_day, null));
- }
+ // Set the DOM storage icon.
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted, null));
}
});
// Set the cookies switch listener.
cookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
- if (isChecked) { // Cookies are enabled.
- // Update the cookies icon.
+ // Update the cookies icon.
+ if (isChecked) {
cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
- } else { // Cookies are disabled.
- // Update the cookies icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
- } else {
- cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
- }
+ } else {
+ cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled, null));
}
});
if (isChecked) {
domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
} else {
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
- } else {
- domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
- }
+ // Set the icon.
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null));
}
});
if (isChecked) {
formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_enabled, null));
} else {
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_night, null));
- } else {
- formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_day, null));
- }
+ // Set the icon.
+ formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled, null));
}
});
}
// Set the EasyList switch listener.
easyListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
- if (isChecked) { // EasyList is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
- } else {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
- }
- } else { // EasyList is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
- } else {
- easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
- }
+ if (isChecked) {
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, null));
+ } else {
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null));
}
});
easyPrivacySwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
if (isChecked) { // EasyPrivacy is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
- } else {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
- }
- } else { // EasyPrivacy is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
- } else {
- easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
- }
+ // Set the icon.
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, null));
+ } else {
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, null));
}
});
fanboysAnnoyanceListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon and Fanboy's Social Blocking List.
if (isChecked) { // Fanboy's Annoyance List is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
- } else {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
- }
+ // Set the icon.
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null));
// Disable the Fanboy's Social Blocking List switch.
fanboysSocialBlockingListSwitch.setEnabled(false);
- // Update the Fanboy's Social Blocking List icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_day, null));
- }
+ // Update the Fanboy's Social Blocking List icon.
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted, null));
} else { // Fanboy's Annoyance List is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
- } else {
- fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
- }
+ // Set the icon.
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null));
// Enable the Fanboy's Social Blocking List switch.
fanboysSocialBlockingListSwitch.setEnabled(true);
// Update the Fanboy's Social Blocking List icon.
- if (fanboysSocialBlockingListSwitch.isChecked()) { // Fanboy's Social Blocking List is on.
- // Update the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
- }
- } else { // Fanboy's Social Blocking List is off.
- // Update the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
- }
+ if (fanboysSocialBlockingListSwitch.isChecked()) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null));
}
}
-
});
// Set the Fanboy's Social Blocking List switch listener.
fanboysSocialBlockingListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
- if (isChecked) { // Fanboy's Social Blocking List is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
- }
- } else { // Fanboy's Social Blocking List is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
- }
+ if (isChecked) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null));
}
});
// Set the UltraList switch listener.
ultraListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
- if (isChecked) { // UltraList is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
- } else {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
- }
- } else { // UltraList is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
- } else {
- ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
- }
+ if (isChecked) {
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, null));
+ } else {
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null));
}
});
// Set the UltraPrivacy switch listener.
ultraPrivacySwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
- if (isChecked) { // UltraPrivacy is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
- } else {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
- }
- } else { // UltraPrivacy is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
- } else {
- ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
- }
+ if (isChecked) {
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, null));
+ } else {
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, null));
}
});
// Set the block all third-party requests switch listener.
blockAllThirdPartyRequestsSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
- if (isChecked) { // Blocking all third-party requests is on.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_night, null));
- } else {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_day, null));
- }
- } else { // Blocking all third-party requests is off.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_night, null));
- } else {
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_day, null));
- }
+ if (isChecked) {
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled, null));
+ } else {
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled, null));
}
});
swipeToRefreshSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- // Update the icon and the visibility of `nightModeTextView`. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Update the icon and the visibility of the night mode text view. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
switch (position) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT:
- if (defaultSwipeToRefresh) { // Swipe to refresh enabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
- }
- } else { // Swipe to refresh disabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
- }
+ if (defaultSwipeToRefresh) {
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null));
+ } else {
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null));
}
- // Show the swipe to refresh TextView.
+ // Show the swipe to refresh text view.
swipeToRefreshTextView.setVisibility(View.VISIBLE);
break;
case DomainsDatabaseHelper.ENABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
- }
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null));
- // Hide the swipe to refresh TextView.
+ // Hide the swipe to refresh text view.
swipeToRefreshTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DISABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
- } else {
- swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
- }
+ // Set the icon.
+ swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null));
- // Hide the swipe to refresh TextView.
+ // Hide the swipe to refresh text view.
swipeToRefreshTextView.setVisibility(View.GONE);
}
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// Update the icon and the visibility of the WebView theme text view. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Doing this makes no sense until it can also be done with the preferences.
switch (position) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT: // the domain WebView theme is system default.
// Set the icon according to the app WebView theme.
case DomainsDatabaseHelper.SYSTEM_DEFAULT: // The default WebView theme is system default.
// Set the icon according to the app theme.
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- // Set the light mode icon.
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
+ // Set the light theme icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null));
} else {
// Set the dark theme icon.
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null));
}
break;
case DomainsDatabaseHelper.LIGHT_THEME: // The default WebView theme is light.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null));
break;
case DomainsDatabaseHelper.DARK_THEME: // The default WebView theme is dark.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null));
break;
}
break;
case DomainsDatabaseHelper.LIGHT_THEME: // The domain WebView theme is light.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null));
// Hide the WebView theme text view.
webViewThemeTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DARK_THEME: // The domain WebView theme is dark.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
- } else {
- webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
- }
+ // Set the icon.
+ webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null));
// Hide the WebView theme text view.
webViewThemeTextView.setVisibility(View.GONE);
// Update the icon and the visibility of the wide viewport text view.
switch (position) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+ // Set the icon.
if (defaultWideViewport) { // Wide viewport is enabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
- }
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, null));
} else { // Wide viewport is disabled by default.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
- }
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null));
}
// Show the wide viewport text view.
case DomainsDatabaseHelper.ENABLED:
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
- }
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, null));
// Hide the wide viewport text view.
wideViewportTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DISABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
- } else {
- wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
- }
+ // Set the icon.
+ wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null));
// Hid ethe wide viewport text view.
wideViewportTextView.setVisibility(View.GONE);
switch (position) {
case DomainsDatabaseHelper.SYSTEM_DEFAULT:
if (defaultDisplayWebpageImages) { // Display webpage images is enabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, null));
} else { // Display webpage images is disabled by default.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null));
}
// Show the display images text view.
break;
case DomainsDatabaseHelper.ENABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, null));
// Hide the display images text view.
displayImagesTextView.setVisibility(View.GONE);
break;
case DomainsDatabaseHelper.DISABLED:
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
- } else {
- displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
- }
+ // Set the icon.
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null));
// Hide the display images text view.
displayImagesTextView.setVisibility(View.GONE);
pinnedSslCertificateSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
if (isChecked) { // SSL certificate pinning is enabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
- } else {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
- }
+ // Set the icon.
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, null));
// Update the visibility of the saved SSL certificate.
if (savedSslIssuedToCNameString == null) {
noCurrentWebsiteCertificateTextView.getParent().requestChildFocus(noCurrentWebsiteCertificateTextView, noCurrentWebsiteCertificateTextView);
}
} else { // SSL certificate pinning is disabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
- } else {
- pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
- }
+ // Set the icon.
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null));
// Hide the SSl certificates and instructions.
savedSslCardView.setVisibility(View.GONE);
pinnedIpAddressesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
// Update the icon.
if (isChecked) { // IP addresses pinning is enabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
- } else {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
- }
+ // Set the icon.
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, null));
// Update the visibility of the saved IP addresses card view.
if (savedIpAddresses == null) { // There are no saved IP addresses.
// Scroll to the bottom of the card views.
currentIpAddressesCardView.getParent().requestChildFocus(currentIpAddressesCardView, currentIpAddressesCardView);
} else { // IP addresses pinning is disabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
- } else {
- pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
- }
+ // Set the icon.
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null));
// Hide the IP addresses card views.
savedIpAddressesCardView.setVisibility(View.GONE);
package com.stoutner.privacybrowser.fragments;
import android.content.Context;
-import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
// Enable the delete menu item.
DomainsActivity.deleteMenuItem.setEnabled(true);
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the delete icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- DomainsActivity.deleteMenuItem.setIcon(R.drawable.delete_night);
- } else {
- DomainsActivity.deleteMenuItem.setIcon(R.drawable.delete_day);
- }
+ // Set the delete icon.
+ DomainsActivity.deleteMenuItem.setIcon(R.drawable.delete_enabled);
}
// Display the domain settings fragment.
import com.stoutner.privacybrowser.activities.MainWebViewActivity;
import com.stoutner.privacybrowser.helpers.ProxyHelper;
+import java.util.Objects;
+
public class SettingsFragment extends PreferenceFragmentCompat {
// Declare the class variables.
private int currentThemeStatus;
// Get a handle for the shared preferences.
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+ // Remove the incorrect warning below that the shared preferences might be null.
+ assert sharedPreferences != null;
+
// Get handles for the preferences.
javaScriptPreference = findPreference("javascript");
cookiesPreference = findPreference(getString(R.string.cookies_key));
customUserAgentPreference.setSummary(sharedPreferences.getString("custom_user_agent", getString(R.string.custom_user_agent_default_value)));
// Only enable the custom user agent preference if the user agent is set to `Custom`.
- customUserAgentPreference.setEnabled(userAgentPreference.getSummary().equals(getString(R.string.custom_user_agent)));
-
+ customUserAgentPreference.setEnabled(Objects.equals(userAgentPreference.getSummary(), getString(R.string.custom_user_agent)));
// Set the search URL as the summary text for the search preference when the preference screen is loaded.
if (searchString.equals("Custom URL")) {
if (sharedPreferences.getBoolean(getString(R.string.cookies_key), false)) {
cookiesPreference.setIcon(R.drawable.cookies_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- cookiesPreference.setIcon(R.drawable.cookies_disabled_day);
- } else {
- cookiesPreference.setIcon(R.drawable.cookies_disabled_night);
- }
+ cookiesPreference.setIcon(R.drawable.cookies_disabled);
}
// Set the DOM storage icon.
if (sharedPreferences.getBoolean("dom_storage", false)) { // DOM storage is enabled.
domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
} else { // DOM storage is disabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- domStoragePreference.setIcon(R.drawable.dom_storage_disabled_day);
- } else {
- domStoragePreference.setIcon(R.drawable.dom_storage_disabled_night);
- }
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled);
}
} else { // The preference is disabled. The icon should be ghosted.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_day);
- } else {
- domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_night);
- }
+ domStoragePreference.setIcon(R.drawable.dom_storage_ghosted);
}
// Set the save form data icon if API < 26. Save form data has no effect on API >= 26.
if (sharedPreferences.getBoolean("save_form_data", false)) {
formDataPreference.setIcon(R.drawable.form_data_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- formDataPreference.setIcon(R.drawable.form_data_disabled_day);
- } else {
- formDataPreference.setIcon(R.drawable.form_data_disabled_night);
- }
+ formDataPreference.setIcon(R.drawable.form_data_disabled);
}
}
// Set the custom user agent icon.
if (customUserAgentPreference.isEnabled()) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled_day);
- } else {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled_night);
- }
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_day);
- } else {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_night);
- }
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted);
}
// Set the incognito mode icon.
if (sharedPreferences.getBoolean("incognito_mode", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled_night);
- } else {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled_day);
- }
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled_night);
- } else {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled_day);
- }
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled);
}
// Set the allow screenshots icon.
if (sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_day);
- } else {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_night);
- }
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_day);
- } else {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_night);
- }
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled);
}
// Set the EasyList icon.
if (sharedPreferences.getBoolean("easylist", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListPreference.setIcon(R.drawable.block_ads_enabled_night);
- } else {
- easyListPreference.setIcon(R.drawable.block_ads_enabled_day);
- }
+ easyListPreference.setIcon(R.drawable.block_ads_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListPreference.setIcon(R.drawable.block_ads_disabled_night);
- } else {
- easyListPreference.setIcon(R.drawable.block_ads_disabled_day);
- }
+ easyListPreference.setIcon(R.drawable.block_ads_disabled);
}
// Set the EasyPrivacy icon.
if (sharedPreferences.getBoolean("easyprivacy", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_night);
- } else {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_day);
- }
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_night);
- } else {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_day);
- }
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled);
}
// Set the Fanboy lists icons.
if (fanboyAnnoyanceListEnabled) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- // Set the Fanboy annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled_night);
+ // Set the Fanboy annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled);
- // Set the Fanboy social blocking list icon.
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted_night);
- } else {
- // Set the Fanboy annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled_day);
-
- // Set the Fanboy social blocking list icon.
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted_day);
- }
+ // Set the Fanboy social blocking list icon.
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- // Set the Fanboy annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled_night);
+ // Set the Fanboy annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled);
- // Set the Fanboy social blocking list icon.
- if (fanboySocialBlockingEnabled) {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_night);
- } else {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_night);
- }
+ // Set the Fanboy social blocking list icon.
+ if (fanboySocialBlockingEnabled) {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled);
} else {
- // Set the Fanboy annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.block_ads_disabled_day);
-
- // Set the Fanboy social blocking list icon.
- if (fanboySocialBlockingEnabled) {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_day);
- } else {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_day);
- }
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled);
}
}
// Set the UltraList icon.
if (sharedPreferences.getBoolean("ultralist", true)){
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListPreference.setIcon(R.drawable.block_ads_enabled_night);
- } else {
- ultraListPreference.setIcon(R.drawable.block_ads_enabled_day);
- }
+ ultraListPreference.setIcon(R.drawable.block_ads_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListPreference.setIcon(R.drawable.block_ads_disabled_night);
- } else {
- ultraListPreference.setIcon(R.drawable.block_ads_disabled_day);
- }
+ ultraListPreference.setIcon(R.drawable.block_ads_disabled);
}
// Set the UltraPrivacy icon.
if (sharedPreferences.getBoolean("ultraprivacy", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_night);
- } else {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_day);
- }
+ ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_night);
- } else {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_day);
- }
+ ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled);
}
// Set the block all third-party requests icon.
if (sharedPreferences.getBoolean("block_all_third_party_requests", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled_night);
- } else {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled_day);
- }
+ blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled_night);
- } else {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled_day);
- }
+ blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled);
}
- // Set the Google Analytics icon according to the theme.
+ // Set the Google Analytics icon.
if (sharedPreferences.getBoolean("google_analytics", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_enabled_night);
- } else {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_enabled_day);
- }
+ googleAnalyticsPreference.setIcon(R.drawable.modify_url_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_disabled_night);
- } else {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_disabled_day);
- }
+ googleAnalyticsPreference.setIcon(R.drawable.modify_url_disabled);
}
- // Set the Facebook Click IDs icon according to the theme.
+ // Set the Facebook Click IDs icon.
if (sharedPreferences.getBoolean("facebook_click_ids", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_enabled_night);
- } else {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_enabled_day);
- }
+ facebookClickIdsPreference.setIcon(R.drawable.modify_url_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_disabled_night);
- } else {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_disabled_day);
- }
+ facebookClickIdsPreference.setIcon(R.drawable.modify_url_disabled);
}
- // Set the Twitter AMP redirects icon according to the theme.
+ // Set the Twitter AMP redirects icon.
if (sharedPreferences.getBoolean("twitter_amp_redirects", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_night);
- } else {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_day);
- }
+ twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_night);
- } else {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_day);
- }
+ twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled);
}
// Set the search custom URL icon.
if (searchCustomURLPreference.isEnabled()) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_night);
- } else {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_day);
- }
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_night);
- } else {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_day);
- }
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_ghosted);
}
// Set the Proxy icons according to the theme and status.
if (proxyString.equals(ProxyHelper.NONE)) { // Proxying is disabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme.
- // Set the main proxy icon to be disabled.
- proxyPreference.setIcon(R.drawable.proxy_disabled_night);
-
- // Set the custom proxy URL icon to be ghosted.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_night);
- } else { // Light theme.
- // Set the main proxy icon to be disabled.
- proxyPreference.setIcon(R.drawable.proxy_disabled_day);
-
- // Set the custom proxy URL icon to be ghosted.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_day);
- }
+ // Set the main proxy icon to be disabled.
+ proxyPreference.setIcon(R.drawable.proxy_disabled);
+
+ // Set the custom proxy URL icon to be ghosted.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted);
} else { // Proxying is enabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme.
- // Set the main proxy icon to be enabled.
- proxyPreference.setIcon(R.drawable.proxy_enabled_night);
-
- // Set the custom proxy URL icon according to its status.
- if (proxyCustomUrlPreference.isEnabled()) { // Custom proxy is enabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled_night);
- } else { // Custom proxy is disabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_night);
- }
- } else { // Light theme.
- // Set the main proxy icon to be enabled.
- proxyPreference.setIcon(R.drawable.proxy_enabled_day);
-
- // Set the custom proxy URL icon according to its status.
- if (proxyCustomUrlPreference.isEnabled()) { // Custom proxy is enabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled_day);
- } else { // Custom proxy is disabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_day);
- }
+ // Set the main proxy icon to be enabled.
+ proxyPreference.setIcon(R.drawable.proxy_enabled);
+
+ // Set the custom proxy URL icon according to its status.
+ if (proxyCustomUrlPreference.isEnabled()) {
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled);
+ } else {
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted);
}
}
// Set the full screen browsing mode icons.
if (fullScreenBrowsingMode) { // Full screen browsing mode is enabled.
- // Set the `fullScreenBrowsingModePreference` icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled_night);
- } else {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled_day);
- }
+ // Set the full screen browsing mode preference icon.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled);
// Set the hide app bar icon.
- if (sharedPreferences.getBoolean("hide_app_bar", true)) { // Hide app bar is enabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- hideAppBarPreference.setIcon(R.drawable.app_bar_enabled_night);
- } else {
- hideAppBarPreference.setIcon(R.drawable.app_bar_enabled_day);
- }
- } else { // Hide app bar is disabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- hideAppBarPreference.setIcon(R.drawable.app_bar_disabled_night);
- } else {
- hideAppBarPreference.setIcon(R.drawable.app_bar_disabled_day);
- }
- }
- } else { // Full screen browsing mode is disabled.
- // Set the icons according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled_night);
- hideAppBarPreference.setIcon(R.drawable.app_bar_ghosted_night);
+ if (sharedPreferences.getBoolean("hide_app_bar", true)) {
+ hideAppBarPreference.setIcon(R.drawable.app_bar_enabled);
} else {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled_day);
- hideAppBarPreference.setIcon(R.drawable.app_bar_ghosted_day);
+ hideAppBarPreference.setIcon(R.drawable.app_bar_disabled);
}
+ } else { // Full screen browsing mode is disabled.
+ // Set the icons.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled);
+ hideAppBarPreference.setIcon(R.drawable.app_bar_ghosted);
}
// Set the clear everything preference icon.
if (clearEverything) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_day);
- } else {
- clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_night);
- }
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled);
} else {
clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled);
}
// Set the clear cookies preference icon.
if (clearEverything || sharedPreferences.getBoolean("clear_cookies", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearCookiesPreference.setIcon(R.drawable.cookies_cleared_day);
- } else {
- clearCookiesPreference.setIcon(R.drawable.cookies_cleared_night);
- }
+ clearCookiesPreference.setIcon(R.drawable.clear_cookies_enabled);
} else {
- clearCookiesPreference.setIcon(R.drawable.cookies_warning);
+ clearCookiesPreference.setIcon(R.drawable.clear_cookies_disabled);
}
// Set the clear DOM storage preference icon.
if (clearEverything || sharedPreferences.getBoolean("clear_dom_storage", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_night);
- } else {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_day);
- }
+ clearDomStoragePreference.setIcon(R.drawable.clear_dom_storage_enabled);
} else {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning);
+ clearDomStoragePreference.setIcon(R.drawable.clear_dom_storage_disabled);
}
// Set the clear form data preference icon if the API < 26. It has no effect on newer versions of Android.
if (Build.VERSION.SDK_INT < 26) {
if (clearEverything || sharedPreferences.getBoolean("clear_form_data", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- clearFormDataPreference.setIcon(R.drawable.form_data_cleared_night);
- } else {
- clearFormDataPreference.setIcon(R.drawable.form_data_cleared_day);
- }
+ clearFormDataPreference.setIcon(R.drawable.clear_form_data_enabled);
} else {
- clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ clearFormDataPreference.setIcon(R.drawable.clear_form_data_disabled);
}
}
// Set the clear logcat preference icon.
if (clearEverything || sharedPreferences.getBoolean(getString(R.string.clear_logcat_key), true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
- } else {
- clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
- }
+ clearLogcatPreference.setIcon(R.drawable.clear_logcat_enabled);
} else {
- clearLogcatPreference.setIcon(R.drawable.bug_warning);
+ clearLogcatPreference.setIcon(R.drawable.clear_logcat_disabled);
}
// Set the clear cache preference icon.
if (clearEverything || sharedPreferences.getBoolean("clear_cache", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- clearCachePreference.setIcon(R.drawable.cache_cleared_night);
- } else {
- clearCachePreference.setIcon(R.drawable.cache_cleared_day);
- }
+ clearCachePreference.setIcon(R.drawable.clear_cache_enabled);
} else {
- clearCachePreference.setIcon(R.drawable.cache_warning);
+ clearCachePreference.setIcon(R.drawable.clear_cache_disabled);
}
// Set the open intents in new tab preference icon.
if (sharedPreferences.getBoolean("open_intents_in_new_tab", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled_night);
- } else {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled_day);
- }
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled_night);
- } else {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled_day);
- }
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled);
}
// Set the swipe to refresh preference icon.
if (sharedPreferences.getBoolean("swipe_to_refresh", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled_day);
- } else {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled_night);
- }
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled_day);
- } else {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled_night);
- }
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled);
}
// Set the download with external app preference icon.
if (sharedPreferences.getBoolean(getString(R.string.download_with_external_app_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_enabled_day);
- } else {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_enabled_night);
- }
+ downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_disabled_day);
- } else {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_disabled_night);
- }
+ downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_disabled);
}
// Set the scroll app bar preference icon.
if (sharedPreferences.getBoolean(getString(R.string.scroll_app_bar_key), true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_day);
- } else {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_night);
- }
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled_day);
- } else {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled_night);
- }
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled);
}
// Set the bottom app bar preference icon.
if (sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_enabled_day);
- } else {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_enabled_night);
- }
+ bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_disabled_day);
- } else {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_disabled_night);
- }
+ bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_disabled);
}
// Set the display additional app bar icons preference icon.
if (sharedPreferences.getBoolean(getString(R.string.display_additional_app_bar_icons_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled_day);
- } else {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled_night);
- }
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled_day);
- } else {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled_night);
- }
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled);
}
// Set the WebView theme preference icon.
case 0: // The system default WebView theme is selected.
// Set the icon according to the app theme.
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
+ webViewThemePreference.setIcon(R.drawable.webview_light_theme);
} else {
- webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
+ webViewThemePreference.setIcon(R.drawable.webview_dark_theme);
}
break;
case 1: // The light WebView theme is selected.
- // Set the icon according to the app theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
- } else {
- webViewThemePreference.setIcon(R.drawable.webview_light_theme_night);
- }
+ // Set the icon.
+ webViewThemePreference.setIcon(R.drawable.webview_light_theme);
break;
case 2: // The dark WebView theme is selected.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemePreference.setIcon(R.drawable.webview_dark_theme_day);
- } else {
- webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
- }
+ // Set the icon.
+ webViewThemePreference.setIcon(R.drawable.webview_dark_theme);
break;
}
// Set the wide viewport preference icon.
if (sharedPreferences.getBoolean("wide_viewport", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_enabled_night);
- } else {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_enabled_day);
- }
+ wideViewportPreference.setIcon(R.drawable.wide_viewport_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_disabled_night);
- } else {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_disabled_day);
- }
+ wideViewportPreference.setIcon(R.drawable.wide_viewport_disabled);
}
// Set the display webpage images preference icon.
if (sharedPreferences.getBoolean("display_webpage_images", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesPreference.setIcon(R.drawable.images_enabled_night);
- } else {
- displayWebpageImagesPreference.setIcon(R.drawable.images_enabled_day);
- }
+ displayWebpageImagesPreference.setIcon(R.drawable.images_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesPreference.setIcon(R.drawable.images_disabled_night);
- } else {
- displayWebpageImagesPreference.setIcon(R.drawable.images_disabled_day);
- }
+ displayWebpageImagesPreference.setIcon(R.drawable.images_disabled);
}
}
// Get a handle for the shared preferences.
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+ // Remove the incorrect lint warning below that the shared preferences might be null.
+ assert sharedPreferences != null;
+
// Unregister the shared preference listener.
sharedPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
}
// Get a handle for the shared preferences.
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+ // Remove the incorrect lint warning below that the shared preferences might be null.
+ assert sharedPreferences != null;
+
// Re-register the shared preference listener.
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
}
if (sharedPreferences.getBoolean("dom_storage", false)) {
domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- domStoragePreference.setIcon(R.drawable.dom_storage_disabled_day);
- } else {
- domStoragePreference.setIcon(R.drawable.dom_storage_disabled_night);
- }
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled);
}
} else { // The JavaScript preference is disabled.
// Update the icon for the JavaScript preference.
domStoragePreference.setEnabled(false);
// Set the icon for DOM storage preference to be ghosted.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_day);
- } else {
- domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_night);
- }
+ domStoragePreference.setIcon(R.drawable.dom_storage_ghosted);
}
break;
if (sharedPreferences.getBoolean(context.getString(R.string.cookies_key), false)) {
cookiesPreference.setIcon(R.drawable.cookies_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- cookiesPreference.setIcon(R.drawable.cookies_disabled_day);
- } else {
- cookiesPreference.setIcon(R.drawable.cookies_disabled_night);
- }
+ cookiesPreference.setIcon(R.drawable.cookies_disabled);
}
break;
if (sharedPreferences.getBoolean("dom_storage", false)) {
domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- domStoragePreference.setIcon(R.drawable.dom_storage_disabled_day);
- } else {
- domStoragePreference.setIcon(R.drawable.dom_storage_disabled_night);
- }
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled);
}
break;
if (sharedPreferences.getBoolean("save_form_data", false)) {
formDataPreference.setIcon(R.drawable.form_data_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- formDataPreference.setIcon(R.drawable.form_data_disabled_day);
- } else {
- formDataPreference.setIcon(R.drawable.form_data_disabled_night);
- }
+ formDataPreference.setIcon(R.drawable.form_data_disabled);
}
break;
// Disable the custom user agent preference.
customUserAgentPreference.setEnabled(false);
- // Set the custom user agent preference icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_night);
- } else {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_day);
- }
+ // Set the custom user agent preference icon.
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted);
break;
case MainWebViewActivity.SETTINGS_CUSTOM_USER_AGENT:
// Enable the custom user agent preference.
customUserAgentPreference.setEnabled(true);
- // Set the custom user agent preference icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled_night);
- } else {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled_day);
- }
+ // Set the custom user agent preference icon.
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled);
break;
default:
// Disable the custom user agent preference.
customUserAgentPreference.setEnabled(false);
- // Set the custom user agent preference icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_night);
- } else {
- customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_day);
- }
+ // Set the custom user agent preference icon.
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted);
}
break;
case "incognito_mode":
// Update the icon.
if (sharedPreferences.getBoolean("incognito_mode", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled_night);
- } else {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled_day);
- }
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled_night);
- } else {
- incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled_day);
- }
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled);
}
break;
case "allow_screenshots":
// Update the icon.
if (sharedPreferences.getBoolean(context.getString(R.string.allow_screenshots_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_day);
- } else {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_night);
- }
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_day);
- } else {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_night);
- }
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled);
}
// Restart Privacy Browser.
case "easylist":
// Update the icon.
if (sharedPreferences.getBoolean("easylist", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListPreference.setIcon(R.drawable.block_ads_enabled_night);
- } else {
- easyListPreference.setIcon(R.drawable.block_ads_enabled_day);
- }
+ easyListPreference.setIcon(R.drawable.block_ads_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyListPreference.setIcon(R.drawable.block_ads_disabled_night);
- } else {
- easyListPreference.setIcon(R.drawable.block_ads_disabled_day);
- }
+ easyListPreference.setIcon(R.drawable.block_ads_disabled);
}
break;
case "easyprivacy":
// Update the icon.
if (sharedPreferences.getBoolean("easyprivacy", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_night);
- } else {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_day);
- }
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_night);
- } else {
- easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_day);
- }
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled);
}
break;
// Update the Fanboy icons.
if (currentFanboyAnnoyanceList) { // Fanboy's annoyance list is enabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- // Update the Fanboy's annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled_night);
+ // Update the Fanboy's annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled);
- // Update the Fanboy's social blocking list icon.
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted_night);
- } else {
- // Update the Fanboy's annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled_day);
-
- // Update the Fanboy's social blocking list icon.
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted_day);
- }
+ // Update the Fanboy's social blocking list icon.
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted);
} else { // Fanboy's annoyance list is disabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- // Update the Fanboy's annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled_night);
+ // Update the Fanboy's annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled);
- // Update the Fanboy's social blocking list icon.
- if (currentFanboySocialBlockingList) {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_night);
- } else {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_night);
- }
+ // Update the Fanboy's social blocking list icon.
+ if (currentFanboySocialBlockingList) {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled);
} else {
- // Update the Fanboy's annoyance list icon.
- fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled_day);
-
- // Update the Fanboy's social blocking list icon.
- if (currentFanboySocialBlockingList) {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_day);
- } else {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_day);
- }
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled);
}
}
case "fanboys_social_blocking_list":
// Update the icon.
if (sharedPreferences.getBoolean("fanboys_social_blocking_list", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_night);
- } else {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_day);
- }
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_night);
- } else {
- fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_day);
- }
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled);
}
break;
case "ultralist":
// Update the icon.
if (sharedPreferences.getBoolean("ultralist", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListPreference.setIcon(R.drawable.block_ads_enabled_night);
- } else {
- ultraListPreference.setIcon(R.drawable.block_ads_enabled_day);
- }
+ ultraListPreference.setIcon(R.drawable.block_ads_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraListPreference.setIcon(R.drawable.block_ads_disabled_night);
- } else {
- ultraListPreference.setIcon(R.drawable.block_ads_disabled_day);
- }
+ ultraListPreference.setIcon(R.drawable.block_ads_disabled);
}
break;
case "ultraprivacy":
// Update the icon.
if (sharedPreferences.getBoolean("ultraprivacy", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_night);
- } else {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_day);
- }
+ ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_night);
- } else {
- ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_day);
- }
+ ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled);
}
break;
case "block_all_third_party_requests":
// Update the icon.
if (sharedPreferences.getBoolean("block_all_third_party_requests", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled_night);
- } else {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled_day);
- }
+ blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled_night);
- } else {
- blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled_day);
- }
+ blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled);
}
break;
case "google_analytics":
// Update the icon.
if (sharedPreferences.getBoolean("google_analytics", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_enabled_night);
- } else {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_enabled_day);
- }
+ googleAnalyticsPreference.setIcon(R.drawable.modify_url_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_disabled_night);
- } else {
- googleAnalyticsPreference.setIcon(R.drawable.modify_url_disabled_day);
- }
+ googleAnalyticsPreference.setIcon(R.drawable.modify_url_disabled);
}
break;
case "facebook_click_ids":
// Update the icon.
if (sharedPreferences.getBoolean("facebook_click_ids", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_enabled_night);
- } else {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_enabled_day);
- }
+ facebookClickIdsPreference.setIcon(R.drawable.modify_url_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_disabled_night);
- } else {
- facebookClickIdsPreference.setIcon(R.drawable.modify_url_disabled_day);
- }
+ facebookClickIdsPreference.setIcon(R.drawable.modify_url_disabled);
}
break;
case "twitter_amp_redirects":
// Update the icon.
if (sharedPreferences.getBoolean("twitter_amp_redirects", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_night);
- } else {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled_day);
- }
+ twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_night);
- } else {
- twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled_day);
- }
+ twitterAmpRedirectsPreference.setIcon(R.drawable.modify_url_disabled);
}
break;
// Set the summary text to `R.string.custom_url`, which is translated.
searchPreference.setSummary(R.string.custom_url);
- // Enable `searchCustomURLPreference`.
+ // Enable the search custom URL preference.
searchCustomURLPreference.setEnabled(true);
- // Set the `searchCustomURLPreference` according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_night);
- } else {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_day);
- }
+ // Set the search custom URL preference icon.
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_enabled);
} else { // `Custom URL` is not selected.
// Set the summary text to `newSearchString`.
searchPreference.setSummary(newSearchString);
// Disable `searchCustomURLPreference`.
searchCustomURLPreference.setEnabled(false);
- // Set the `searchCustomURLPreference` according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_night);
- } else {
- searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_day);
- }
+ // Set the search custom URL preference icon.
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_ghosted);
}
break;
// Update the icons.
if (currentProxyString.equals(ProxyHelper.NONE)) { // Proxying is disabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme.
- // Set the main proxy icon to be disabled
- proxyPreference.setIcon(R.drawable.proxy_disabled_night);
-
- // Set the custom proxy URL icon to be ghosted.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_night);
- } else { // Light theme.
- // Set the main proxy icon to be disabled.
- proxyPreference.setIcon(R.drawable.proxy_disabled_day);
-
- // Set the custom proxy URL icon to be ghosted.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_day);
- }
+ // Set the main proxy icon to be disabled
+ proxyPreference.setIcon(R.drawable.proxy_disabled);
+
+ // Set the custom proxy URL icon to be ghosted.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted);
} else { // Proxying is enabled.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme.
- // Set the main proxy icon to be enabled.
- proxyPreference.setIcon(R.drawable.proxy_enabled_night);
-
- /// Set the custom proxy URL icon according to its status.
- if (proxyCustomUrlPreference.isEnabled()) { // Custom proxy is enabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled_night);
- } else { // Custom proxy is disabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_night);
- }
- } else { // Light theme.
- // Set the main proxy icon to be enabled.
- proxyPreference.setIcon(R.drawable.proxy_enabled_day);
-
- // Set the custom proxy URL icon according to its status.
- if (proxyCustomUrlPreference.isEnabled()) { // Custom proxy is enabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled_day);
- } else { // Custom proxy is disabled.
- proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_day);
- }
+ // Set the main proxy icon to be enabled.
+ proxyPreference.setIcon(R.drawable.proxy_enabled);
+
+ /// Set the custom proxy URL icon according to its status.
+ if (proxyCustomUrlPreference.isEnabled()) {
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled);
+ } else {
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted);
}
}
break;
case "full_screen_browsing_mode":
if (sharedPreferences.getBoolean("full_screen_browsing_mode", false)) { // Full screen browsing is enabled.
- // Set the full screen browsing mode preference icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled_night);
- } else {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled_day);
- }
+ // Set the full screen browsing mode preference icon.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled);
// Set the hide app bar preference icon.
- if (sharedPreferences.getBoolean("hide_app_bar", true)) { // Hide app bar is enabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- hideAppBarPreference.setIcon(R.drawable.app_bar_enabled_night);
- } else {
- hideAppBarPreference.setIcon(R.drawable.app_bar_enabled_day);
- }
- } else { // Hide app bar is disabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- hideAppBarPreference.setIcon(R.drawable.app_bar_disabled_night);
- } else {
- hideAppBarPreference.setIcon(R.drawable.app_bar_disabled_day);
- }
- }
- } else { // Full screen browsing is disabled.
- // Update the icons according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled_night);
- hideAppBarPreference.setIcon(R.drawable.app_bar_ghosted_night);
+ if (sharedPreferences.getBoolean("hide_app_bar", true)) {
+ hideAppBarPreference.setIcon(R.drawable.app_bar_enabled);
} else {
- fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled_day);
- hideAppBarPreference.setIcon(R.drawable.app_bar_ghosted_day);
+ hideAppBarPreference.setIcon(R.drawable.app_bar_disabled);
}
+ } else { // Full screen browsing is disabled.
+ // Update the icons.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled);
+ hideAppBarPreference.setIcon(R.drawable.app_bar_ghosted);
}
break;
case "hide_app_bar":
// Update the icon.
- if (sharedPreferences.getBoolean("hide_app_bar", true)) { // Hide app bar is enabled.
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- hideAppBarPreference.setIcon(R.drawable.app_bar_enabled_night);
- } else {
- hideAppBarPreference.setIcon(R.drawable.app_bar_enabled_day);
- }
+ if (sharedPreferences.getBoolean("hide_app_bar", true)) {
+ hideAppBarPreference.setIcon(R.drawable.app_bar_enabled);
} else { // Hide app bar is disabled.
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- hideAppBarPreference.setIcon(R.drawable.app_bar_disabled_night);
- } else {
- hideAppBarPreference.setIcon(R.drawable.app_bar_disabled_day);
- }
+ hideAppBarPreference.setIcon(R.drawable.app_bar_disabled);
}
break;
// Update the clear everything preference icon.
if (newClearEverythingBoolean) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_day);
- } else {
- clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_night);
- }
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled);
} else {
clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled);
}
// Update the clear cookies preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cookies", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearCookiesPreference.setIcon(R.drawable.cookies_cleared_day);
- } else {
- clearCookiesPreference.setIcon(R.drawable.cookies_cleared_night);
- }
+ clearCookiesPreference.setIcon(R.drawable.clear_cookies_enabled);
} else {
- clearCookiesPreference.setIcon(R.drawable.cookies_warning);
+ clearCookiesPreference.setIcon(R.drawable.clear_cookies_disabled);
}
// Update the clear dom storage preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_dom_storage", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_day);
- } else {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_night);
- }
+ clearDomStoragePreference.setIcon(R.drawable.clear_dom_storage_enabled);
} else {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning);
+ clearDomStoragePreference.setIcon(R.drawable.clear_dom_storage_disabled);
}
// Update the clear form data preference icon if the API < 26.
if (Build.VERSION.SDK_INT < 26) {
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_form_data", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearFormDataPreference.setIcon(R.drawable.form_data_cleared_day);
- } else {
- clearFormDataPreference.setIcon(R.drawable.form_data_cleared_night);
- }
+ clearFormDataPreference.setIcon(R.drawable.clear_form_data_enabled);
} else {
- clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ clearFormDataPreference.setIcon(R.drawable.clear_form_data_disabled);
}
}
// Update the clear logcat preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean(context.getString(R.string.clear_logcat_key), true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
- } else {
- clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
- }
+ clearLogcatPreference.setIcon(R.drawable.clear_logcat_enabled);
} else {
- clearLogcatPreference.setIcon(R.drawable.cache_warning);
+ clearLogcatPreference.setIcon(R.drawable.clear_cache_disabled);
}
// Update the clear cache preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cache", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearCachePreference.setIcon(R.drawable.cache_cleared_day);
- } else {
- clearCachePreference.setIcon(R.drawable.cache_cleared_night);
- }
+ clearCachePreference.setIcon(R.drawable.clear_cache_enabled);
} else {
- clearCachePreference.setIcon(R.drawable.cache_warning);
+ clearCachePreference.setIcon(R.drawable.clear_cache_disabled);
}
break;
case "clear_cookies":
// Update the icon.
if (sharedPreferences.getBoolean("clear_cookies", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearCookiesPreference.setIcon(R.drawable.cookies_cleared_day);
- } else {
- clearCookiesPreference.setIcon(R.drawable.cookies_cleared_night);
- }
+ clearCookiesPreference.setIcon(R.drawable.clear_cookies_enabled);
} else {
- clearCookiesPreference.setIcon(R.drawable.cookies_warning);
+ clearCookiesPreference.setIcon(R.drawable.clear_cookies_disabled);
}
break;
case "clear_dom_storage":
// Update the icon.
if (sharedPreferences.getBoolean("clear_dom_storage", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_day);
- } else {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_night);
- }
+ clearDomStoragePreference.setIcon(R.drawable.clear_dom_storage_enabled);
} else {
- clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning);
+ clearDomStoragePreference.setIcon(R.drawable.clear_dom_storage_disabled);
}
break;
case "clear_form_data":
// Update the icon.
if (sharedPreferences.getBoolean("clear_form_data", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearFormDataPreference.setIcon(R.drawable.form_data_cleared_day);
- } else {
- clearFormDataPreference.setIcon(R.drawable.form_data_cleared_night);
- }
+ clearFormDataPreference.setIcon(R.drawable.clear_form_data_enabled);
} else {
- clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ clearFormDataPreference.setIcon(R.drawable.clear_form_data_disabled);
}
break;
case "clear_logcat":
// Update the icon.
if (sharedPreferences.getBoolean(context.getString(R.string.clear_logcat_key), true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
- } else {
- clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
- }
+ clearLogcatPreference.setIcon(R.drawable.clear_logcat_enabled);
} else {
- clearLogcatPreference.setIcon(R.drawable.bug_warning);
+ clearLogcatPreference.setIcon(R.drawable.clear_logcat_disabled);
}
break;
case "clear_cache":
// Update the icon.
if (sharedPreferences.getBoolean("clear_cache", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- clearCachePreference.setIcon(R.drawable.cache_cleared_day);
- } else {
- clearCachePreference.setIcon(R.drawable.cache_cleared_night);
- }
+ clearCachePreference.setIcon(R.drawable.clear_cache_enabled);
} else {
- clearCachePreference.setIcon(R.drawable.cache_warning);
+ clearCachePreference.setIcon(R.drawable.clear_cache_disabled);
}
break;
case "open_intents_in_new_tab":
// Update the icon.
if (sharedPreferences.getBoolean("open_intents_in_new_tab", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled_day);
- } else {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled_night);
- }
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled_day);
- } else {
- openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled_night);
- }
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled);
}
break;
case "swipe_to_refresh":
// Update the icon.
if (sharedPreferences.getBoolean("swipe_to_refresh", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled_day);
- } else {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled_night);
- }
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled_day);
- } else {
- swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled_night);
- }
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled);
}
break;
case "download_with_external_app":
// Update the icon.
if (sharedPreferences.getBoolean(context.getString(R.string.download_with_external_app_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_enabled_day);
- } else {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_enabled_night);
- }
+ downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_disabled_day);
- } else {
- downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_disabled_night);
- }
+ downloadWithExternalAppPreference.setIcon(R.drawable.download_with_external_app_disabled);
}
break;
case "scroll_app_bar":
// Update the icon.
if (sharedPreferences.getBoolean(context.getString(R.string.scroll_app_bar_key), true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_day);
- } else {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_night);
- }
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled_day);
- } else {
- scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled_night);
- }
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled);
}
break;
case "bottom_app_bar":
// Update the icon.
if (sharedPreferences.getBoolean(context.getString(R.string.bottom_app_bar_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_enabled_day);
- } else {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_enabled_night);
- }
+ bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_disabled_day);
- } else {
- bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_disabled_night);
- }
+ bottomAppBarPreference.setIcon(R.drawable.bottom_app_bar_disabled);
}
// Restart Privacy Browser.
case "display_additional_app_bar_icons":
// Update the icon.
if (sharedPreferences.getBoolean(context.getString(R.string.display_additional_app_bar_icons_key), false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled_day);
- } else {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled_night);
- }
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled_day);
- } else {
- displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled_night);
- }
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled);
}
break;
// Get the new theme.
String newAppTheme = sharedPreferences.getString("app_theme", context.getString(R.string.app_theme_default_value));
- // Update the system according to the new theme. A switch statement cannot be used because the theme entry values string array is not a compile time constant.
+ // Update the system according to the new theme. A switch statement cannot be used because the theme entry values string array is not a compile-time constant.
if (newAppTheme.equals(appThemeEntryValuesStringArray[1])) { // The light theme is selected.
// Update the theme preference summary text.
appThemePreference.setSummary(appThemeEntriesStringArray[1]);
// Update the icon.
switch (newWebViewThemeEntryNumber) {
case 0: // The system default WebView theme is selected.
- // Set the icon according to the app theme.
+ // Set the icon.
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
+ webViewThemePreference.setIcon(R.drawable.webview_light_theme);
} else {
- webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
+ webViewThemePreference.setIcon(R.drawable.webview_dark_theme);
}
break;
- case 1: // The system default WebView theme is selected.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
- } else {
- webViewThemePreference.setIcon(R.drawable.webview_light_theme_night);
- }
+ case 1: // The light theme is selected.
+ // Set the icon.
+ webViewThemePreference.setIcon(R.drawable.webview_light_theme);
break;
- case 2: // The system default WebView theme is selected.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- webViewThemePreference.setIcon(R.drawable.webview_dark_theme_day);
- } else {
- webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
- }
+ case 2: // The dark theme is selected.
+ // Set the icon.
+ webViewThemePreference.setIcon(R.drawable.webview_dark_theme);
break;
}
case "wide_viewport":
// Update the icon.
if (sharedPreferences.getBoolean("wide_viewport", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_enabled_night);
- } else {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_enabled_day);
- }
+ wideViewportPreference.setIcon(R.drawable.wide_viewport_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_disabled_night);
- } else {
- wideViewportPreference.setIcon(R.drawable.wide_viewport_disabled_day);
- }
+ wideViewportPreference.setIcon(R.drawable.wide_viewport_disabled);
}
break;
case "display_webpage_images":
// Update the icon.
if (sharedPreferences.getBoolean("display_webpage_images", true)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesPreference.setIcon(R.drawable.images_enabled_night);
- } else {
- displayWebpageImagesPreference.setIcon(R.drawable.images_enabled_day);
- }
+ displayWebpageImagesPreference.setIcon(R.drawable.images_enabled);
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- displayWebpageImagesPreference.setIcon(R.drawable.images_disabled_night);
- } else {
- displayWebpageImagesPreference.setIcon(R.drawable.images_disabled_day);
- }
+ displayWebpageImagesPreference.setIcon(R.drawable.images_disabled);
}
break;
}
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `info_outline`. 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.0"
+ android:viewportWidth="24.0" >
+
+ <path
+ android:fillColor="@color/icon"
+ android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `info_outline`. 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.0"
+ android:viewportWidth="24.0" >
+
+ <path
+ android:fillColor="@color/blue_icon"
+ android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
+</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `info_outline`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/blue_800"
- android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
-</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `info_outline`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/violet_500"
- android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
-</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `info_outline`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/black"
- android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
-</vector>
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `info_outline`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/white"
- android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
-</vector>
android:viewportWidth="24.0" >
<path
- android:fillColor="@color/white"
+ android:fillColor="@color/icon"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `camera_enhance`. 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.0"
+ android:viewportWidth="24.0" >
+
+ <path
+ android:fillColor="@color/disabled_icon"
+ android:pathData="M9,3L7.17,5L4,5c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3L9,3zM12,18c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,17l1.25,-2.75L16,13l-2.75,-1.25L12,9l-1.25,2.75L8,13l2.75,1.25z"/>
+</vector>
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `camera_enhance`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/gray_600"
- android:pathData="M9,3L7.17,5L4,5c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3L9,3zM12,18c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,17l1.25,-2.75L16,13l-2.75,-1.25L12,9l-1.25,2.75L8,13l2.75,1.25z"/>
-</vector>
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `camera_enhance`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/gray_500"
- android:pathData="M9,3L7.17,5L4,5c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3L9,3zM12,18c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,17l1.25,-2.75L16,13l-2.75,-1.25L12,9l-1.25,2.75L8,13l2.75,1.25z"/>
-</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `camera_enhance`. 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.0"
+ android:viewportWidth="24.0" >
+
+ <path
+ android:fillColor="@color/blue_icon"
+ android:pathData="M9,3L7.17,5L4,5c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3L9,3zM12,18c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,17l1.25,-2.75L16,13l-2.75,-1.25L12,9l-1.25,2.75L8,13l2.75,1.25z"/>
+</vector>
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `camera_enhance`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/blue_800"
- android:pathData="M9,3L7.17,5L4,5c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3L9,3zM12,18c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,17l1.25,-2.75L16,13l-2.75,-1.25L12,9l-1.25,2.75L8,13l2.75,1.25z"/>
-</vector>
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `camera_enhance`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/violet_500"
- android:pathData="M9,3L7.17,5L4,5c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3L9,3zM12,18c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,17l1.25,-2.75L16,13l-2.75,-1.25L12,9l-1.25,2.75L8,13l2.75,1.25z"/>
-</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
+ android:viewportWidth="24.0" >
+
+ <path
+ android:fillColor="@color/disabled_icon"
+ android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
+</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/gray_600"
- android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
-</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/gray_500"
- android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
-</vector>
\ No newline at end of file
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
+ android:viewportWidth="24.0" >
+
+ <path
+ android:fillColor="@color/blue_icon"
+ android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
+</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/blue_800"
- android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
-</vector>
\ No newline at end of file
+++ /dev/null
-<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="@color/violet_500"
- android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
-</vector>
\ No newline at end of file
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `payment`. 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.0"
+ androi