From 5bcf4ca90f27512b94fb7aca4fad37b4e4774655 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Sat, 17 Jun 2017 12:05:14 -0700 Subject: [PATCH] Create a dark theme for the `AlertDialogs`. --- .../activities/MainWebViewActivity.java | 4 +- .../dialogs/AddDomainDialog.java | 16 +- .../dialogs/CreateBookmarkDialog.java | 16 +- .../dialogs/CreateBookmarkFolderDialog.java | 16 +- .../CreateHomeScreenShortcutDialog.java | 16 +- .../dialogs/DownloadFileDialog.java | 12 +- .../dialogs/DownloadImageDialog.java | 17 +- .../dialogs/EditBookmarkDialog.java | 16 +- .../dialogs/EditBookmarkFolderDialog.java | 16 +- .../dialogs/MoveToFolderDialog.java | 17 +- .../dialogs/SslCertificateErrorDialog.java | 34 +++- .../dialogs/UrlHistoryDialog.java | 12 +- .../dialogs/ViewSslCertificateDialog.java | 28 ++- .../helpers/OrbotProxyHelper.java | 19 +- .../create_home_screen_shortcut_dialog.xml | 2 +- .../main/res/layout/edit_bookmark_dialog.xml | 179 +++++++++-------- .../layout/edit_bookmark_folder_dialog.xml | 188 +++++++++--------- .../main/res/layout/ssl_certificate_error.xml | 8 +- .../main/res/layout/url_history_dialog.xml | 2 +- .../layout/url_history_item_linearlayout.xml | 4 +- .../main/res/layout/view_ssl_certificate.xml | 6 +- app/src/main/res/values/attrs.xml | 2 + app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/styles.xml | 11 +- 24 files changed, 410 insertions(+), 232 deletions(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 02f3742f..06b4c4c4 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -122,7 +122,9 @@ import java.util.Set; public class MainWebViewActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, CreateHomeScreenShortcutDialog.CreateHomeScreenSchortcutListener, SslCertificateErrorDialog.SslCertificateErrorListener, DownloadFileDialog.DownloadFileListener, DownloadImageDialog.DownloadImageListener, UrlHistoryDialog.UrlHistoryListener { - // `darkTheme` is public static so it can be accessed from `AboutActivity` and `GuideActivity`. It is also used in `onCreate()`, `applyAppSettings()`, and `applyDomainSettings()`. + // `darkTheme` is public static so it can be accessed from `AboutActivity`, `GuideActivity`, `AddDomainDialog`, `CreateBookmarkDialog`, `CreateBookmarkFolderDialog`, `DownloadFileDialog`, `DownloadImageDialog`, `EditBookmarkDialog`, + // `EditBookmarkFolderDialog`, `MoveToFolderDialog`, `SslCertificateErrorDialog`, `UrlHistoryDialog`, `ViewSslCertificateDialog`, `CreateHomeScreenShortcutDialog`, and `OrbotProxyHelper`. + // It is also used in `onCreate()`, `applyAppSettings()`, and `applyDomainSettings()`. public static boolean darkTheme; // `favoriteIconBitmap` is public static so it can be accessed from `CreateHomeScreenShortcutDialog`, `BookmarksActivity`, `CreateBookmarkDialog`, `CreateBookmarkFolderDialog`, `EditBookmarkDialog`, `EditBookmarkFolderDialog`, `ViewSslCertificateDialog`. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java index 4d99a206..9e63a940 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java @@ -63,10 +63,20 @@ public class AddDomainDialog extends AppCompatDialogFragment { @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.add_domain); - // The parent view is `null` because it will be assigned by the `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by the `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.add_domain_dialog, null)); // Set an `onClick()` listener for the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java index e6efc707..60863a9c 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java @@ -67,11 +67,21 @@ public class CreateBookmarkDialog extends AppCompatDialogFragment { // Create a drawable version of the favorite icon. Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebViewActivity.favoriteIconBitmap); - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title and icon. dialogBuilder.setTitle(R.string.create_bookmark); dialogBuilder.setIcon(favoriteIconDrawable); - // The parent view is `null` because it will be assigned by the `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by the `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.create_bookmark_dialog, null)); // Set an `onClick()` listener for the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java index d703a394..dfa2fc63 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java @@ -62,10 +62,20 @@ public class CreateBookmarkFolderDialog extends AppCompatDialogFragment { @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.create_folder); - // The parent view is `null` because it will be assigned by the `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by the `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.create_bookmark_folder_dialog, null)); // Set an `onClick()` listener for the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java index 89e27f54..dbda6c79 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java @@ -69,11 +69,21 @@ public class CreateHomeScreenShortcutDialog extends AppCompatDialogFragment { // Create a drawable version of the favorite icon. Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebViewActivity.favoriteIconBitmap); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.LightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title and icon. dialogBuilder.setTitle(R.string.create_shortcut); dialogBuilder.setIcon(favoriteIconDrawable); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(layoutInflater.inflate(R.layout.create_home_screen_shortcut_dialog, null)); // Set an `onClick` listener on the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java index a348fb90..a496eb20 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java @@ -37,6 +37,7 @@ import android.widget.EditText; import android.widget.TextView; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; import java.util.Locale; @@ -122,8 +123,15 @@ public class DownloadFileDialog extends AppCompatDialogFragment { // Get the activity's layout inflater. LayoutInflater layoutInflater = getActivity().getLayoutInflater(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.lightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } // Set the title. dialogBuilder.setTitle(R.string.save_as); diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadImageDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadImageDialog.java index 7a0aeccd..c6bcb6fb 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadImageDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadImageDialog.java @@ -36,6 +36,7 @@ import android.view.WindowManager; import android.widget.EditText; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; // `android.support.v7.app.AlertDialog` uses more of the horizontal screen real estate versus `android.app.AlertDialog's` smaller width. // We have to use `AppCompatDialogFragment` instead of `DialogFragment` or an error is produced on API <=22. @@ -99,10 +100,20 @@ public class DownloadImageDialog extends AppCompatDialogFragment { // Get the activity's layout inflater. LayoutInflater layoutInflater = getActivity().getLayoutInflater(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.lightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.save_image_as); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(layoutInflater.inflate(R.layout.download_image_dialog, null)); // Set an `onClick()` listener on the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java index 6e868ee7..117d5840 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java @@ -75,10 +75,20 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { Cursor bookmarkCursor = BookmarksActivity.bookmarksDatabaseHelper.getBookmarkCursor(selectedBookmarkDatabaseId); bookmarkCursor.moveToFirst(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.edit_bookmark); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_dialog, null)); // Set an `onClick()` listener for the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDialog.java index bccd8006..ae561354 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDialog.java @@ -75,10 +75,20 @@ public class EditBookmarkFolderDialog extends AppCompatDialogFragment { Cursor bookmarkCursor = BookmarksActivity.bookmarksDatabaseHelper.getBookmarkCursor(selectedBookmarkDatabaseId); bookmarkCursor.moveToFirst(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.edit_folder); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_folder_dialog, null)); // Set an `onClick()` listener for the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/MoveToFolderDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/MoveToFolderDialog.java index 4e5b7f36..6eb09a31 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/MoveToFolderDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/MoveToFolderDialog.java @@ -46,6 +46,7 @@ import android.widget.TextView; import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.activities.BookmarksActivity; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper; import java.io.ByteArrayOutputStream; @@ -78,10 +79,20 @@ public class MoveToFolderDialog extends AppCompatDialogFragment { @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.move_to_folder); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.move_to_folder_dialog, null)); // Set an `onClick()` listener for the negative button. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.java index 78108d0a..f0d5a69f 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.java @@ -37,6 +37,7 @@ import android.view.LayoutInflater; import android.widget.TextView; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; import java.text.DateFormat; import java.util.Date; @@ -134,10 +135,20 @@ public class SslCertificateErrorDialog extends AppCompatDialogFragment { // Get the activity's layout inflater. LayoutInflater layoutInflater = getActivity().getLayoutInflater(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.LightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.ssl_certificate_error); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(layoutInflater.inflate(R.layout.ssl_certificate_error, null)); // Set an `onClick` listener on the negative button. `null` doesn't do anything extra when the button is pressed. The `Dialog` will automatically close. @@ -196,9 +207,20 @@ public class SslCertificateErrorDialog extends AppCompatDialogFragment { SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + startDate); SpannableStringBuilder endDateStringBuilder = new SpannableStringBuilder((endDateLabel + endDate)); - // Create the `ForegroundColorSpan`. We have to use the deprecated `getColor` until API >= 23. - ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700)); - ForegroundColorSpan redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700)); + // Create a red `ForegroundColorSpan`. We have to use the deprecated `getColor` until API >= 23. + @SuppressWarnings("deprecation") ForegroundColorSpan redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700)); + + // Create a blue `ForegroundColorSpan`. + ForegroundColorSpan blueColorSpan; + + // Set `blueColorSpan` according to the theme. We have to use the deprecated `getColor()` until API >= 23. + if (MainWebViewActivity.darkTheme) { + //noinspection deprecation + blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400)); + } else { + //noinspection deprecation + blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700)); + } // 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); diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java index 3c418d39..29918032 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java @@ -41,6 +41,7 @@ import android.widget.AdapterView; import android.widget.ListView; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.adapters.HistoryArrayAdapter; import com.stoutner.privacybrowser.definitions.History; @@ -182,8 +183,15 @@ public class UrlHistoryDialog extends AppCompatDialogFragment{ // Get the activity's layout inflater. LayoutInflater layoutInflater = getActivity().getLayoutInflater(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.lightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } // Set the title. dialogBuilder.setTitle(R.string.history); diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewSslCertificateDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewSslCertificateDialog.java index 597a20f1..67395b82 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewSslCertificateDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewSslCertificateDialog.java @@ -50,8 +50,17 @@ public class ViewSslCertificateDialog extends DialogFragment { // Create a drawable version of the favorite icon. Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebViewActivity.favoriteIconBitmap); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.LightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the icon. dialogBuilder.setIcon(favoriteIconDrawable); // Set an `onClick` listener on the negative button. Using `null` closes the dialog without doing anything else. @@ -127,10 +136,21 @@ public class ViewSslCertificateDialog extends DialogFragment { SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(startDate)); SpannableStringBuilder endDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(endDate)); - // Create a blue `ForegroundColorSpan`. We have to use the deprecated `getColor` until API >= 23. - @SuppressWarnings("deprecation") ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700)); + // Create a red `ForegroundColorSpan`. We have to use the deprecated `getColor` until API >= 23. @SuppressWarnings("deprecation") ForegroundColorSpan redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700)); + // Create a blue `ForegroundColorSpan`. + ForegroundColorSpan blueColorSpan; + + // Set `blueColorSpan` according to the theme. We have to use the deprecated `getColor()` until API >= 23. + if (MainWebViewActivity.darkTheme) { + //noinspection deprecation + blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400)); + } else { + //noinspection deprecation + blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700)); + } + // Setup the spans to display the certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction. issuedToCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), issuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); issuedToONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), issuedToONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java index 2e1b22b6..ef49afe1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java @@ -95,9 +95,20 @@ public class OrbotProxyHelper { privacyBrowserContext.sendBroadcast(orbotIntent); } } catch (PackageManager.NameNotFoundException exception){ // If an exception is thrown, Orbot is not installed. - // Build an `AlertDialog`. `R.style.LightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(parentActivity, R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(parentActivity, R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(parentActivity, R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the message. dialogBuilder.setMessage(R.string.orbot_proxy_not_installed); + + // Set the positive button. dialogBuilder.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -105,8 +116,10 @@ public class OrbotProxyHelper { } }); - // Convert `dialogBuilder` to `alertDialog` and display it on the screen. + // Convert `dialogBuilder` to `alertDialog`. AlertDialog alertDialog = dialogBuilder.create(); + + // Make it so. alertDialog.show(); } } diff --git a/app/src/main/res/layout/create_home_screen_shortcut_dialog.xml b/app/src/main/res/layout/create_home_screen_shortcut_dialog.xml index 0d930951..eab00e8b 100644 --- a/app/src/main/res/layout/create_home_screen_shortcut_dialog.xml +++ b/app/src/main/res/layout/create_home_screen_shortcut_dialog.xml @@ -33,7 +33,7 @@ android:layout_marginEnd="4dp" > + `android:inputType="textUri"` disables spell check in the `EditText`. --> . --> - + android:layout_height="wrap_content" + android:layout_width="match_parent" > - + android:orientation="vertical" > - + - - - - - - - - + android:orientation="horizontal" > - + - - + + + + + + + + - - + android:layout_width="match_parent" + android:checkedButton="@+id/edit_bookmark_current_icon_radiobutton" > + + + + + + - - - - - + - - - - - - - + + + + + + + - - \ No newline at end of file + android:layout_marginTop="6dp" + android:layout_marginBottom="12dp" + android:layout_marginStart="4dp" + android:layout_marginEnd="4dp" > + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/edit_bookmark_folder_dialog.xml b/app/src/main/res/layout/edit_bookmark_folder_dialog.xml index 469cb2e3..f7d69b65 100644 --- a/app/src/main/res/layout/edit_bookmark_folder_dialog.xml +++ b/app/src/main/res/layout/edit_bookmark_folder_dialog.xml @@ -18,113 +18,119 @@ You should have received a copy of the GNU General Public License along with Privacy Browser. If not, see . --> - + android:layout_width="match_parent" > - + android:orientation="vertical" > - + - - - - - - - - - - + android:orientation="horizontal"> - + - - + + + + + + + + + + + android:checkedButton="@+id/edit_folder_current_icon_radiobutton"> + + + + + + + + - + + + + - - + android:layout_width="match_parent" + android:hint="@string/folder_name" + android:imeOptions="actionGo" + android:inputType="textUri" /> + - - - - - - - - - \ No newline at end of file + android:gravity="center_horizontal" + android:text="@string/folder_names_must_be_unique" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/ssl_certificate_error.xml b/app/src/main/res/layout/ssl_certificate_error.xml index d94e8da9..6c95fbfa 100644 --- a/app/src/main/res/layout/ssl_certificate_error.xml +++ b/app/src/main/res/layout/ssl_certificate_error.xml @@ -45,7 +45,7 @@ android:text="@string/url" android:textAllCaps="true" android:textStyle="bold" - android:textColor="@color/blue_900" /> + android:textColor="?attr/sslTitle" /> + android:textColor="?attr/sslTitle" /> + android:textColor="?attr/sslTitle"/> + android:textColor="?attr/sslTitle"/> \ No newline at end of file diff --git a/app/src/main/res/layout/url_history_item_linearlayout.xml b/app/src/main/res/layout/url_history_item_linearlayout.xml index be848173..df4a1363 100644 --- a/app/src/main/res/layout/url_history_item_linearlayout.xml +++ b/app/src/main/res/layout/url_history_item_linearlayout.xml @@ -25,7 +25,7 @@ android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" - android:background="@drawable/listview_item_background_selector" > + tools:ignore="UseCompoundDrawables" > + android:textColor="?attr/sslTitle" /> + android:textColor="?attr/sslTitle"/> + android:textColor="?attr/sslTitle"/> + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index e454aaad..e51f0471 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -47,6 +47,7 @@ #FF163317 #FFF5F5F5 + #FFEEEEEE #FFE0E0E0 #FFBDBDBD #FF9E9E9E diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8832ee83..41ddc897 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -33,6 +33,8 @@ @color/blue_700 @color/blue_800 @color/blue_700 + @color/blue_900 + @color/black -- 2.43.0