Switch to the new Day/Night theme. https://redmine.stoutner.com/issues/522
authorSoren Stoutner <soren@stoutner.com>
Mon, 25 May 2020 23:39:53 +0000 (16:39 -0700)
committerSoren Stoutner <soren@stoutner.com>
Mon, 25 May 2020 23:39:53 +0000 (16:39 -0700)
469 files changed:
.idea/dictionaries/soren.xml
app/src/free/java/com/stoutner/privacybrowser/dialogs/AdConsentDialog.java
app/src/free/res/drawable/privacy_browser_foreground.xml
app/src/main/AndroidManifest.xml
app/src/main/assets/de/about_licenses_dark.html
app/src/main/assets/de/about_licenses_light.html
app/src/main/assets/en/about_licenses_dark.html
app/src/main/assets/en/about_licenses_light.html
app/src/main/assets/es/about_licenses_dark.html
app/src/main/assets/es/about_licenses_light.html
app/src/main/assets/fr/about_licenses_dark.html
app/src/main/assets/fr/about_licenses_light.html
app/src/main/assets/it/about_licenses_dark.html
app/src/main/assets/it/about_licenses_light.html
app/src/main/assets/ru/about_licenses_dark.html
app/src/main/assets/ru/about_licenses_light.html
app/src/main/assets/tr/about_licenses_dark.html
app/src/main/assets/tr/about_licenses_light.html
app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/GuideActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/RequestsActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/SettingsActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/ViewSourceActivity.java
app/src/main/java/com/stoutner/privacybrowser/adapters/RequestsArrayAdapter.java
app/src/main/java/com/stoutner/privacybrowser/asynctasks/GetUrlSize.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/AboutViewSourceDialog.kt
app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.kt
app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.kt
app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt
app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.kt
app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDatabaseViewDialog.kt
app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDatabaseViewDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/FontSizeDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/HttpAuthenticationDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/MoveToFolderDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/OpenDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/ProxyNotInstalledDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/SaveDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/SaveLogcatDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/SslCertificateErrorDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/StoragePermissionDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewRequestDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/ViewSslCertificateDialog.java
app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.java
app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java
app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
app/src/main/java/com/stoutner/privacybrowser/fragments/DomainsListFragment.java
app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java
app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java
app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.java
app/src/main/res/color/appbar_spinner_color_selector_dark.xml [deleted file]
app/src/main/res/color/appbar_spinner_color_selector_light.xml [deleted file]
app/src/main/res/color/button_background_color_selector_dark.xml [deleted file]
app/src/main/res/color/button_background_color_selector_day.xml [new file with mode: 0644]
app/src/main/res/color/button_background_color_selector_light.xml [deleted file]
app/src/main/res/color/button_background_color_selector_night.xml [new file with mode: 0644]
app/src/main/res/color/button_text_color_selector_dark.xml [deleted file]
app/src/main/res/color/button_text_color_selector_day.xml [new file with mode: 0644]
app/src/main/res/color/button_text_color_selector_light.xml [deleted file]
app/src/main/res/color/button_text_color_selector_night.xml [new file with mode: 0644]
app/src/main/res/color/checked_text_color_selector.xml [new file with mode: 0644]
app/src/main/res/drawable/about_dark.xml [deleted file]
app/src/main/res/drawable/about_day.xml [new file with mode: 0644]
app/src/main/res/drawable/about_light.xml [deleted file]
app/src/main/res/drawable/about_night.xml [new file with mode: 0644]
app/src/main/res/drawable/add_dark.xml [deleted file]
app/src/main/res/drawable/add_day.xml [new file with mode: 0644]
app/src/main/res/drawable/add_light.xml [deleted file]
app/src/main/res/drawable/add_night.xml [new file with mode: 0644]
app/src/main/res/drawable/allow_screenshots_disabled_dark.xml [deleted file]
app/src/main/res/drawable/allow_screenshots_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/allow_screenshots_disabled_light.xml [deleted file]
app/src/main/res/drawable/allow_screenshots_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/allow_screenshots_enabled_dark.xml [deleted file]
app/src/main/res/drawable/allow_screenshots_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/allow_screenshots_enabled_light.xml [deleted file]
app/src/main/res/drawable/allow_screenshots_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/app_bar_disabled_dark.xml [deleted file]
app/src/main/res/drawable/app_bar_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/app_bar_disabled_light.xml [deleted file]
app/src/main/res/drawable/app_bar_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/app_bar_enabled_dark.xml [deleted file]
app/src/main/res/drawable/app_bar_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/app_bar_enabled_light.xml [deleted file]
app/src/main/res/drawable/app_bar_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/app_bar_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/app_bar_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/app_bar_ghosted_light.xml [deleted file]
app/src/main/res/drawable/app_bar_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/back.xml
app/src/main/res/drawable/block_ads_disabled_dark.xml [deleted file]
app/src/main/res/drawable/block_ads_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/block_ads_disabled_light.xml [deleted file]
app/src/main/res/drawable/block_ads_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/block_ads_enabled_dark.xml [deleted file]
app/src/main/res/drawable/block_ads_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/block_ads_enabled_light.xml [deleted file]
app/src/main/res/drawable/block_ads_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/block_all_third_party_requests_disabled_dark.xml [deleted file]
app/src/main/res/drawable/block_all_third_party_requests_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/block_all_third_party_requests_disabled_light.xml [deleted file]
app/src/main/res/drawable/block_all_third_party_requests_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/block_all_third_party_requests_enabled_dark.xml [deleted file]
app/src/main/res/drawable/block_all_third_party_requests_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/block_all_third_party_requests_enabled_light.xml [deleted file]
app/src/main/res/drawable/block_all_third_party_requests_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/block_tracking_disabled_dark.xml [deleted file]
app/src/main/res/drawable/block_tracking_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/block_tracking_disabled_light.xml [deleted file]
app/src/main/res/drawable/block_tracking_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/block_tracking_enabled_dark.xml [deleted file]
app/src/main/res/drawable/block_tracking_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/block_tracking_enabled_light.xml [deleted file]
app/src/main/res/drawable/block_tracking_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/bookmarks_dark.xml [deleted file]
app/src/main/res/drawable/bookmarks_day.xml [new file with mode: 0644]
app/src/main/res/drawable/bookmarks_light.xml [deleted file]
app/src/main/res/drawable/bookmarks_night.xml [new file with mode: 0644]
app/src/main/res/drawable/bug.xml
app/src/main/res/drawable/cache_cleared_dark.xml [deleted file]
app/src/main/res/drawable/cache_cleared_day.xml [new file with mode: 0644]
app/src/main/res/drawable/cache_cleared_light.xml [deleted file]
app/src/main/res/drawable/cache_cleared_night.xml [new file with mode: 0644]
app/src/main/res/drawable/cache_warning.xml
app/src/main/res/drawable/clear_and_exit.xml
app/src/main/res/drawable/clear_dark.xml [deleted file]
app/src/main/res/drawable/clear_day.xml [new file with mode: 0644]
app/src/main/res/drawable/clear_everything_disabled.xml
app/src/main/res/drawable/clear_everything_enabled_dark.xml [deleted file]
app/src/main/res/drawable/clear_everything_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/clear_everything_enabled_light.xml [deleted file]
app/src/main/res/drawable/clear_everything_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/clear_light.xml [deleted file]
app/src/main/res/drawable/clear_night.xml [new file with mode: 0644]
app/src/main/res/drawable/close_dark.xml [deleted file]
app/src/main/res/drawable/close_day.xml [new file with mode: 0644]
app/src/main/res/drawable/close_light.xml [deleted file]
app/src/main/res/drawable/close_night.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_cleared_dark.xml [deleted file]
app/src/main/res/drawable/cookies_cleared_day.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_cleared_light.xml [deleted file]
app/src/main/res/drawable/cookies_cleared_night.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_disabled_dark.xml [deleted file]
app/src/main/res/drawable/cookies_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_disabled_light.xml [deleted file]
app/src/main/res/drawable/cookies_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_enabled.xml
app/src/main/res/drawable/cookies_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/cookies_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_ghosted_light.xml [deleted file]
app/src/main/res/drawable/cookies_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/cookies_warning.xml
app/src/main/res/drawable/copy_dark.xml [deleted file]
app/src/main/res/drawable/copy_day.xml [new file with mode: 0644]
app/src/main/res/drawable/copy_enabled_dark.xml [deleted file]
app/src/main/res/drawable/copy_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/copy_enabled_light.xml [deleted file]
app/src/main/res/drawable/copy_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/copy_light.xml [deleted file]
app/src/main/res/drawable/copy_night.xml [new file with mode: 0644]
app/src/main/res/drawable/create_bookmark_dark.xml [deleted file]
app/src/main/res/drawable/create_bookmark_day.xml [new file with mode: 0644]
app/src/main/res/drawable/create_bookmark_light.xml [deleted file]
app/src/main/res/drawable/create_bookmark_night.xml [new file with mode: 0644]
app/src/main/res/drawable/create_folder_dark.xml [deleted file]
app/src/main/res/drawable/create_folder_day.xml [new file with mode: 0644]
app/src/main/res/drawable/create_folder_light.xml [deleted file]
app/src/main/res/drawable/create_folder_night.xml [new file with mode: 0644]
app/src/main/res/drawable/custom_user_agent_enabled_dark.xml [deleted file]
app/src/main/res/drawable/custom_user_agent_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/custom_user_agent_enabled_light.xml [deleted file]
app/src/main/res/drawable/custom_user_agent_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/custom_user_agent_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/custom_user_agent_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/custom_user_agent_ghosted_light.xml [deleted file]
app/src/main/res/drawable/custom_user_agent_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/delete_blue.xml [deleted file]
app/src/main/res/drawable/delete_dark.xml [deleted file]
app/src/main/res/drawable/delete_day.xml [new file with mode: 0644]
app/src/main/res/drawable/delete_disabled.xml [new file with mode: 0644]
app/src/main/res/drawable/delete_light.xml [deleted file]
app/src/main/res/drawable/delete_night.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_cleared_dark.xml [deleted file]
app/src/main/res/drawable/dom_storage_cleared_day.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_cleared_light.xml [deleted file]
app/src/main/res/drawable/dom_storage_cleared_night.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_disabled_dark.xml [deleted file]
app/src/main/res/drawable/dom_storage_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_disabled_light.xml [deleted file]
app/src/main/res/drawable/dom_storage_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_enabled.xml
app/src/main/res/drawable/dom_storage_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/dom_storage_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_ghosted_light.xml [deleted file]
app/src/main/res/drawable/dom_storage_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/dom_storage_warning.xml
app/src/main/res/drawable/domains_dark.xml [deleted file]
app/src/main/res/drawable/domains_light.xml
app/src/main/res/drawable/domains_night.xml [new file with mode: 0644]
app/src/main/res/drawable/downloads_enabled_dark.xml [deleted file]
app/src/main/res/drawable/downloads_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/downloads_enabled_light.xml [deleted file]
app/src/main/res/drawable/downloads_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/downloads_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/downloads_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/downloads_ghosted_light.xml [deleted file]
app/src/main/res/drawable/downloads_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/edit_dark.xml [deleted file]
app/src/main/res/drawable/edit_day.xml [new file with mode: 0644]
app/src/main/res/drawable/edit_light.xml [deleted file]
app/src/main/res/drawable/edit_night.xml [new file with mode: 0644]
app/src/main/res/drawable/folder_dark_blue.xml
app/src/main/res/drawable/folder_gray.xml
app/src/main/res/drawable/font_size_dark.xml [deleted file]
app/src/main/res/drawable/font_size_day.xml [new file with mode: 0644]
app/src/main/res/drawable/font_size_light.xml [deleted file]
app/src/main/res/drawable/font_size_night.xml [new file with mode: 0644]
app/src/main/res/drawable/form_data_cleared_dark.xml [deleted file]
app/src/main/res/drawable/form_data_cleared_day.xml [new file with mode: 0644]
app/src/main/res/drawable/form_data_cleared_light.xml [deleted file]
app/src/main/res/drawable/form_data_cleared_night.xml [new file with mode: 0644]
app/src/main/res/drawable/form_data_disabled_dark.xml [deleted file]
app/src/main/res/drawable/form_data_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/form_data_disabled_light.xml [deleted file]
app/src/main/res/drawable/form_data_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/form_data_enabled.xml
app/src/main/res/drawable/form_data_warning.xml
app/src/main/res/drawable/forward.xml
app/src/main/res/drawable/full_screen_disabled_dark.xml [deleted file]
app/src/main/res/drawable/full_screen_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/full_screen_disabled_light.xml [deleted file]
app/src/main/res/drawable/full_screen_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/full_screen_enabled_dark.xml [deleted file]
app/src/main/res/drawable/full_screen_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/full_screen_enabled_light.xml [deleted file]
app/src/main/res/drawable/full_screen_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/guide.xml
app/src/main/res/drawable/history.xml
app/src/main/res/drawable/home_enabled_dark.xml [deleted file]
app/src/main/res/drawable/home_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/home_enabled_light.xml [deleted file]
app/src/main/res/drawable/home_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/images_disabled_dark.xml [deleted file]
app/src/main/res/drawable/images_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/images_disabled_light.xml [deleted file]
app/src/main/res/drawable/images_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/images_enabled_dark.xml [deleted file]
app/src/main/res/drawable/images_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/images_enabled_light.xml [deleted file]
app/src/main/res/drawable/images_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/import_export_dark.xml [deleted file]
app/src/main/res/drawable/import_export_day.xml [new file with mode: 0644]
app/src/main/res/drawable/import_export_light.xml [deleted file]
app/src/main/res/drawable/import_export_night.xml [new file with mode: 0644]
app/src/main/res/drawable/incognito_mode_disabled_dark.xml [deleted file]
app/src/main/res/drawable/incognito_mode_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/incognito_mode_disabled_light.xml [deleted file]
app/src/main/res/drawable/incognito_mode_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/incognito_mode_enabled_dark.xml [deleted file]
app/src/main/res/drawable/incognito_mode_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/incognito_mode_enabled_light.xml [deleted file]
app/src/main/res/drawable/incognito_mode_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/javascript_enabled.xml
app/src/main/res/drawable/list_selector_dark.xml [deleted file]
app/src/main/res/drawable/list_selector_day.xml [new file with mode: 0644]
app/src/main/res/drawable/list_selector_light.xml [deleted file]
app/src/main/res/drawable/list_selector_night.xml [new file with mode: 0644]
app/src/main/res/drawable/lock_dark.xml [deleted file]
app/src/main/res/drawable/lock_day.xml [new file with mode: 0644]
app/src/main/res/drawable/lock_light.xml [deleted file]
app/src/main/res/drawable/lock_night.xml [new file with mode: 0644]
app/src/main/res/drawable/modify_url_disabled_dark.xml [deleted file]
app/src/main/res/drawable/modify_url_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/modify_url_disabled_light.xml [deleted file]
app/src/main/res/drawable/modify_url_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/modify_url_enabled_dark.xml [deleted file]
app/src/main/res/drawable/modify_url_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/modify_url_enabled_light.xml [deleted file]
app/src/main/res/drawable/modify_url_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/more_disabled_dark.xml [deleted file]
app/src/main/res/drawable/more_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/more_disabled_light.xml [deleted file]
app/src/main/res/drawable/more_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/more_enabled_dark.xml [deleted file]
app/src/main/res/drawable/more_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/more_enabled_light.xml [deleted file]
app/src/main/res/drawable/more_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/move_down_disabled.xml
app/src/main/res/drawable/move_down_enabled_dark.xml [deleted file]
app/src/main/res/drawable/move_down_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/move_down_enabled_light.xml [deleted file]
app/src/main/res/drawable/move_down_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/move_to_folder_dark.xml [deleted file]
app/src/main/res/drawable/move_to_folder_day.xml [new file with mode: 0644]
app/src/main/res/drawable/move_to_folder_light.xml [deleted file]
app/src/main/res/drawable/move_to_folder_night.xml [new file with mode: 0644]
app/src/main/res/drawable/move_up_disabled.xml
app/src/main/res/drawable/move_up_enabled_dark.xml [deleted file]
app/src/main/res/drawable/move_up_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/move_up_enabled_light.xml [deleted file]
app/src/main/res/drawable/move_up_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/next.xml
app/src/main/res/drawable/night_mode_disabled_dark.xml [deleted file]
app/src/main/res/drawable/night_mode_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/night_mode_disabled_light.xml [deleted file]
app/src/main/res/drawable/night_mode_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/night_mode_enabled_dark.xml [deleted file]
app/src/main/res/drawable/night_mode_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/night_mode_enabled_light.xml [deleted file]
app/src/main/res/drawable/night_mode_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/previous.xml
app/src/main/res/drawable/privacy_browser_foreground.xml
app/src/main/res/drawable/privacy_mode.xml
app/src/main/res/drawable/proxy_disabled_dark.xml [deleted file]
app/src/main/res/drawable/proxy_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/proxy_disabled_light.xml [deleted file]
app/src/main/res/drawable/proxy_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/proxy_enabled_dark.xml [deleted file]
app/src/main/res/drawable/proxy_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/proxy_enabled_light.xml [deleted file]
app/src/main/res/drawable/proxy_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/proxy_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/proxy_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/proxy_ghosted_light.xml [deleted file]
app/src/main/res/drawable/proxy_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/refresh_disabled_dark.xml [deleted file]
app/src/main/res/drawable/refresh_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/refresh_disabled_light.xml [deleted file]
app/src/main/res/drawable/refresh_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/refresh_enabled_dark.xml [deleted file]
app/src/main/res/drawable/refresh_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/refresh_enabled_light.xml [deleted file]
app/src/main/res/drawable/refresh_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/save_dark.xml [deleted file]
app/src/main/res/drawable/save_day.xml [new file with mode: 0644]
app/src/main/res/drawable/save_dialog_dark.xml [deleted file]
app/src/main/res/drawable/save_dialog_day.xml [new file with mode: 0644]
app/src/main/res/drawable/save_dialog_light.xml [deleted file]
app/src/main/res/drawable/save_dialog_night.xml [new file with mode: 0644]
app/src/main/res/drawable/save_light.xml [deleted file]
app/src/main/res/drawable/save_night.xml [new file with mode: 0644]
app/src/main/res/drawable/search_custom_url_enabled_dark.xml [deleted file]
app/src/main/res/drawable/search_custom_url_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/search_custom_url_enabled_light.xml [deleted file]
app/src/main/res/drawable/search_custom_url_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/search_custom_url_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/search_custom_url_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/search_custom_url_ghosted_light.xml [deleted file]
app/src/main/res/drawable/search_custom_url_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/search_enabled_dark.xml [deleted file]
app/src/main/res/drawable/search_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/search_enabled_light.xml [deleted file]
app/src/main/res/drawable/search_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/select_all_dark.xml [deleted file]
app/src/main/res/drawable/select_all_day.xml [new file with mode: 0644]
app/src/main/res/drawable/select_all_light.xml [deleted file]
app/src/main/res/drawable/select_all_night.xml [new file with mode: 0644]
app/src/main/res/drawable/settings.xml
app/src/main/res/drawable/social_media_disabled_dark.xml [deleted file]
app/src/main/res/drawable/social_media_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/social_media_disabled_light.xml [deleted file]
app/src/main/res/drawable/social_media_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/social_media_enabled_dark.xml [deleted file]
app/src/main/res/drawable/social_media_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/social_media_enabled_light.xml [deleted file]
app/src/main/res/drawable/social_media_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/social_media_ghosted_dark.xml [deleted file]
app/src/main/res/drawable/social_media_ghosted_day.xml [new file with mode: 0644]
app/src/main/res/drawable/social_media_ghosted_light.xml [deleted file]
app/src/main/res/drawable/social_media_ghosted_night.xml [new file with mode: 0644]
app/src/main/res/drawable/sort_dark.xml [deleted file]
app/src/main/res/drawable/sort_day.xml [new file with mode: 0644]
app/src/main/res/drawable/sort_light.xml [deleted file]
app/src/main/res/drawable/sort_night.xml [new file with mode: 0644]
app/src/main/res/drawable/sort_selected_dark.xml [deleted file]
app/src/main/res/drawable/sort_selected_day.xml [new file with mode: 0644]
app/src/main/res/drawable/sort_selected_light.xml [deleted file]
app/src/main/res/drawable/sort_selected_night.xml [new file with mode: 0644]
app/src/main/res/drawable/ssl_certificate_disabled_dark.xml [deleted file]
app/src/main/res/drawable/ssl_certificate_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/ssl_certificate_disabled_light.xml [deleted file]
app/src/main/res/drawable/ssl_certificate_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/ssl_certificate_enabled_dark.xml [deleted file]
app/src/main/res/drawable/ssl_certificate_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/ssl_certificate_enabled_light.xml [deleted file]
app/src/main/res/drawable/ssl_certificate_enabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/tab_disabled_dark.xml
app/src/main/res/drawable/tab_disabled_light.xml
app/src/main/res/drawable/tab_enabled_dark.xml
app/src/main/res/drawable/tab_enabled_light.xml
app/src/main/res/drawable/theme_dark.xml [deleted file]
app/src/main/res/drawable/theme_day.xml [new file with mode: 0644]
app/src/main/res/drawable/theme_light.xml [deleted file]
app/src/main/res/drawable/theme_night.xml [new file with mode: 0644]
app/src/main/res/drawable/user_agent_dark.xml [deleted file]
app/src/main/res/drawable/user_agent_day.xml [new file with mode: 0644]
app/src/main/res/drawable/user_agent_light.xml [deleted file]
app/src/main/res/drawable/user_agent_night.xml [new file with mode: 0644]
app/src/main/res/drawable/warning.xml
app/src/main/res/drawable/wide_viewport_disabled_dark.xml [deleted file]
app/src/main/res/drawable/wide_viewport_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/wide_viewport_disabled_light.xml [deleted file]
app/src/main/res/drawable/wide_viewport_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/wide_viewport_enabled_dark.xml [deleted file]
app/src/main/res/drawable/wide_viewport_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/wide_viewport_enabled_light.xml [deleted file]
app/src/main/res/drawable/wide_viewport_enabled_night.xml [new file with mode: 0644]
app/src/main/res/layout-w900dp/bookmarks_drawer.xml
app/src/main/res/layout/about_coordinatorlayout.xml
app/src/main/res/layout/about_tab_version.xml
app/src/main/res/layout/appbar_spinner_dropdown_item.xml
app/src/main/res/layout/appbar_spinner_item.xml
app/src/main/res/layout/bookmarks_activity_item_linearlayout.xml
app/src/main/res/layout/bookmarks_coordinatorlayout.xml
app/src/main/res/layout/bookmarks_databaseview_coordinatorlayout.xml
app/src/main/res/layout/bookmarks_drawer.xml
app/src/main/res/layout/bookmarks_drawer_item_linearlayout.xml
app/src/main/res/layout/create_home_screen_shortcut_dialog.xml
app/src/main/res/layout/domain_name_linearlayout.xml
app/src/main/res/layout/domain_settings_fragment.xml
app/src/main/res/layout/domains_coordinatorlayout.xml
app/src/main/res/layout/guide_coordinatorlayout.xml
app/src/main/res/layout/import_export_coordinatorlayout.xml
app/src/main/res/layout/logcat_coordinatorlayout.xml
app/src/main/res/layout/main_framelayout.xml
app/src/main/res/layout/navigation_header.xml [deleted file]
app/src/main/res/layout/open_dialog.xml
app/src/main/res/layout/pinned_mismatch_linearlayout.xml
app/src/main/res/layout/requests_appbar_spinner_dropdown_item.xml
app/src/main/res/layout/requests_appbar_spinner_item.xml
app/src/main/res/layout/requests_coordinatorlayout.xml
app/src/main/res/layout/requests_item_linearlayout.xml
app/src/main/res/layout/save_dialog.xml
app/src/main/res/layout/save_logcat_dialog.xml
app/src/main/res/layout/ssl_certificate_error.xml
app/src/main/res/layout/tab_custom_view.xml
app/src/main/res/layout/unencrypted_website_dialog.xml
app/src/main/res/layout/url_history_item_linearlayout.xml
app/src/main/res/layout/view_source_app_bar.xml
app/src/main/res/layout/view_source_coordinatorlayout.xml
app/src/main/res/layout/webview_framelayout.xml
app/src/main/res/menu/webview_navigation_menu.xml
app/src/main/res/menu/webview_options_menu.xml
app/src/main/res/values-de/strings.xml
app/src/main/res/values-es/strings.xml
app/src/main/res/values-fr/strings.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values-night-v23/styles.xml [new file with mode: 0644]
app/src/main/res/values-night-v27/styles.xml [new file with mode: 0644]
app/src/main/res/values-night/styles.xml [new file with mode: 0644]
app/src/main/res/values-ru/strings.xml
app/src/main/res/values-tr/strings.xml
app/src/main/res/values-v23/styles.xml [new file with mode: 0644]
app/src/main/res/values-v27/styles.xml [new file with mode: 0644]
app/src/main/res/values/attrs.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
app/src/main/res/xml/network_security_config.xml
app/src/main/res/xml/preferences.xml

index c71e3926db29e87e865e7435a434ffde4f5bf35c..1cefe92843f92b3437b60aadb6717135975b4501 100644 (file)
@@ -83,6 +83,7 @@
       <w>glitchy</w>
       <w>googleplay</w>
       <w>homescreen</w>
+      <w>hsts</w>
       <w>huawei</w>
       <w>imageview</w>
       <w>inet</w>
index bce865f224443ddd18559ff83f09c90b764a0f31..60d507b0e8cd6bae2b18d4f387d908535825598d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2018-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2018-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
 
 package com.stoutner.privacybrowser.dialogs;
 
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Build;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.view.WindowManager;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.fragment.app.DialogFragment;
 
 import com.stoutner.privacybrowser.R;
@@ -39,23 +40,17 @@ public class AdConsentDialog extends DialogFragment {
     @NonNull
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
         // Use a builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
+
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-        // Set the style and the icon according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
-            dialogBuilder.setIcon(R.drawable.block_ads_enabled_dark);
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.block_ads_enabled_night);
         } else {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-            dialogBuilder.setIcon(R.drawable.block_ads_enabled_light);
+            dialogBuilder.setIcon(R.drawable.block_ads_enabled_day);
         }
 
         // Remove the incorrect lint warning below that `getApplicationContext()` might be null.
@@ -99,6 +94,12 @@ public class AdConsentDialog extends DialogFragment {
         // Create an alert dialog from the alert dialog builder.
         AlertDialog alertDialog = dialogBuilder.create();
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             // Remove the warning below that `getWindow()` might be null.
@@ -114,7 +115,7 @@ public class AdConsentDialog extends DialogFragment {
 
     // Close Privacy Browser Free if the dialog is cancelled without selecting a button (by tapping on the background).
     @Override
-    public void onCancel(DialogInterface dialogInterface) {
+    public void onCancel(@NonNull DialogInterface dialogInterface) {
         // Remove the incorrect lint warning below that `getApplicationContext()` might be null.
         assert getActivity() != null;
 
@@ -125,7 +126,7 @@ public class AdConsentDialog extends DialogFragment {
         // Update the ad consent database.
         adConsentDatabaseHelper.updateAdConsent(false);
 
-        // Close the browser.  `finishAndRemoveTask` also removes Privacy Browser from the recent app list.
+        // Close the browser.  `finishAndRemoveTask()` also removes Privacy Browser from the recent app list.
         if (Build.VERSION.SDK_INT >= 21) {
             getActivity().finishAndRemoveTask();
         } else {
index d723a60ff33fe05d45631dbdf44074f7a92a259e..cb1baa1ddd36d0d5e241d19333f5c0c75a8e4e1e 100644 (file)
@@ -1,78 +1,87 @@
-<!-- `privacy_browser_foreground.xml` is derived from `security` and `language`, which are part of the Android Material icon set.  They are released under the Apache License 2.0.
+<!-- This file is derived from `security` and `language`, which are part of the Android Material icon set.  They are released under the Apache License 2.0.
     Modifications copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
 <vector
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="108dp"
     android:height="108dp"
-    android:viewportWidth="523.63635"
-    android:viewportHeight="523.63635" >
+    android:width="108dp"
+    android:viewportHeight="523.63635"
+    android:viewportWidth="523.63635" >
 
-    <group android:translateX="133.81818"
-            android:translateY="133.81818" >
+    <group
+        android:translateX="133.81818"
+        android:translateY="133.81818" >
 
-      <path
-          android:pathData="m128,12.8 l-94.255,41.891v62.836c0,58.124 40.215,112.477 94.255,125.673 54.039,-13.196 94.255,-67.549 94.255,-125.673v-62.836z"
-          android:fillColor="#0d4781"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="m128,12.8 l-94.255,41.891v62.836c0,58.124 40.215,112.477 94.255,125.673 54.039,-13.196 94.255,-67.549 94.255,-125.673v-62.836z"
+            android:fillColor="#0d4781"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1" />
 
-      <path
-          android:pathData="m128,0 l-104.727,46.545v69.818C23.273,180.945 67.956,241.338 128,256 188.044,241.338 232.727,180.945 232.727,116.364v-69.818zM128,127.884h81.455C203.287,175.825 171.287,218.531 128,231.913L128,128L46.545,128L46.545,61.673L128,25.484Z"
-          android:fillColor="#1976d2"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="m128,0 l-104.727,46.545v69.818C23.273,180.945 67.956,241.338 128,256 188.044,241.338 232.727,180.945 232.727,116.364v-69.818zM128,127.884h81.455C203.287,175.825 171.287,218.531 128,231.913L128,128L46.545,128L46.545,61.673L128,25.484Z"
+            android:fillColor="#1976d2"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1" />
 
-      <path
-          android:pathData="m127.92,48.214c-44.042,0 -79.706,35.744 -79.706,79.786 0,44.042 35.664,79.786 79.706,79.786 44.121,0 79.865,-35.744 79.865,-79.786 0,-44.042 -35.744,-79.786 -79.865,-79.786zM183.212,96.086h-23.537c-2.553,-9.973 -6.223,-19.547 -11.01,-28.404 14.681,5.026 26.888,15.239 34.547,28.404zM128,64.491c6.622,9.574 11.808,20.186 15.239,31.595h-30.478c3.431,-11.409 8.617,-22.021 15.239,-31.595zM66.246,143.957C64.969,138.851 64.172,133.505 64.172,128c0,-5.505 0.798,-10.851 2.074,-15.957h26.968c-0.638,5.266 -1.117,10.532 -1.117,15.957 0,5.425 0.479,10.691 1.117,15.957zM72.788,159.914L96.325,159.914c2.553,9.973 6.223,19.547 11.01,28.404C92.655,183.291 80.448,173.159 72.788,159.914ZM96.325,96.086L72.788,96.086c7.659,-13.244 19.867,-23.377 34.547,-28.404 -4.787,8.856 -8.457,18.43 -11.01,28.404zM128,191.509c-6.622,-9.574 -11.808,-20.186 -15.239,-31.595h30.478C139.808,171.324 134.622,181.935 128,191.509ZM146.67,143.957h-37.34c-0.718,-5.266 -1.277,-10.532 -1.277,-15.957 0,-5.425 0.559,-10.771 1.277,-15.957h37.34c0.718,5.186 1.277,10.532 1.277,15.957 0,5.425 -0.558,10.691 -1.277,15.957zM148.664,188.318c4.787,-8.856 8.457,-18.43 11.01,-28.404h23.537c-7.659,13.165 -19.867,23.377 -34.547,28.404zM162.786,143.957c0.638,-5.266 1.117,-10.532 1.117,-15.957 0,-5.425 -0.479,-10.691 -1.117,-15.957h26.968c1.277,5.106 2.074,10.452 2.074,15.957 0,5.505 -0.798,10.851 -2.074,15.957z"
-          android:fillColor="#ffffff"
-          android:fillAlpha="1" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="m127.92,48.214c-44.042,0 -79.706,35.744 -79.706,79.786 0,44.042 35.664,79.786 79.706,79.786 44.121,0 79.865,-35.744 79.865,-79.786 0,-44.042 -35.744,-79.786 -79.865,-79.786zM183.212,96.086h-23.537c-2.553,-9.973 -6.223,-19.547 -11.01,-28.404 14.681,5.026 26.888,15.239 34.547,28.404zM128,64.491c6.622,9.574 11.808,20.186 15.239,31.595h-30.478c3.431,-11.409 8.617,-22.021 15.239,-31.595zM66.246,143.957C64.969,138.851 64.172,133.505 64.172,128c0,-5.505 0.798,-10.851 2.074,-15.957h26.968c-0.638,5.266 -1.117,10.532 -1.117,15.957 0,5.425 0.479,10.691 1.117,15.957zM72.788,159.914L96.325,159.914c2.553,9.973 6.223,19.547 11.01,28.404C92.655,183.291 80.448,173.159 72.788,159.914ZM96.325,96.086L72.788,96.086c7.659,-13.244 19.867,-23.377 34.547,-28.404 -4.787,8.856 -8.457,18.43 -11.01,28.404zM128,191.509c-6.622,-9.574 -11.808,-20.186 -15.239,-31.595h30.478C139.808,171.324 134.622,181.935 128,191.509ZM146.67,143.957h-37.34c-0.718,-5.266 -1.277,-10.532 -1.277,-15.957 0,-5.425 0.559,-10.771 1.277,-15.957h37.34c0.718,5.186 1.277,10.532 1.277,15.957 0,5.425 -0.558,10.691 -1.277,15.957zM148.664,188.318c4.787,-8.856 8.457,-18.43 11.01,-28.404h23.537c-7.659,13.165 -19.867,23.377 -34.547,28.404zM162.786,143.957c0.638,-5.266 1.117,-10.532 1.117,-15.957 0,-5.425 -0.479,-10.691 -1.117,-15.957h26.968c1.277,5.106 2.074,10.452 2.074,15.957 0,5.505 -0.798,10.851 -2.074,15.957z"
+            android:fillColor="#ffffff"
+            android:fillAlpha="1" />
 
-      <path
-          android:pathData="M50.491,201.267h155.02v54.763h-155.02z"
-          android:strokeAlpha="1"
-          android:strokeWidth="0.74080104"
-          android:fillColor="#b71c1c"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="M50.491,201.267h155.02v54.763h-155.02z"
+            android:strokeAlpha="1"
+            android:strokeWidth="0.74080104"
+            android:fillColor="#b71c1c"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1" />
 
-      <path
-          android:pathData="m65.675,212.543h24.609v6.921L75.672,219.465v5.625h12.48v6.504L75.672,231.593L75.672,244.755h-9.998z"
-          android:strokeAlpha="1"
-          android:strokeLineJoin="miter"
-          android:strokeWidth="1"
-          android:fillColor="#ffffff"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1"
-          android:strokeLineCap="butt" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="m65.675,212.543h24.609v6.921L75.672,219.465v5.625h12.48v6.504L75.672,231.593L75.672,244.755h-9.998z"
+            android:strokeAlpha="1"
+            android:strokeLineJoin="miter"
+            android:strokeWidth="1"
+            android:fillColor="#ffffff"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1"
+            android:strokeLineCap="butt" />
 
-      <path
-          android:pathData="M95.821,244.755L95.821,212.543L112.41,212.543q4.614,0 7.053,0.791 2.439,0.791 3.933,2.944 1.494,2.131 1.494,5.208 0,2.681 -1.143,4.636 -1.143,1.934 -3.142,3.142 -1.274,0.769 -3.494,1.274 1.78,0.593 2.593,1.187 0.549,0.396 1.582,1.692 1.055,1.296 1.406,2l4.812,9.338h-11.25l-5.317,-9.844q-1.011,-1.912 -1.802,-2.483 -1.077,-0.747 -2.439,-0.747L105.819,231.681L105.819,244.755ZM105.819,225.595h4.197q0.681,0 2.637,-0.439 0.989,-0.198 1.604,-1.011 0.637,-0.813 0.637,-1.868 0,-1.56 -0.989,-2.395 -0.989,-0.835 -3.713,-0.835h-4.373z"
-          android:strokeAlpha="1"
-          android:strokeLineJoin="miter"
-          android:strokeWidth="1"
-          android:fillColor="#ffffff"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1"
-          android:strokeLineCap="butt" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="M95.821,244.755L95.821,212.543L112.41,212.543q4.614,0 7.053,0.791 2.439,0.791 3.933,2.944 1.494,2.131 1.494,5.208 0,2.681 -1.143,4.636 -1.143,1.934 -3.142,3.142 -1.274,0.769 -3.494,1.274 1.78,0.593 2.593,1.187 0.549,0.396 1.582,1.692 1.055,1.296 1.406,2l4.812,9.338h-11.25l-5.317,-9.844q-1.011,-1.912 -1.802,-2.483 -1.077,-0.747 -2.439,-0.747L105.819,231.681L105.819,244.755ZM105.819,225.595h4.197q0.681,0 2.637,-0.439 0.989,-0.198 1.604,-1.011 0.637,-0.813 0.637,-1.868 0,-1.56 -0.989,-2.395 -0.989,-0.835 -3.713,-0.835h-4.373z"
+            android:strokeAlpha="1"
+            android:strokeLineJoin="miter"
+            android:strokeWidth="1"
+            android:fillColor="#ffffff"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1"
+            android:strokeLineCap="butt" />
 
-      <path
-          android:pathData="m130.648,212.543h26.675v6.877h-16.699v5.12h15.491v6.57L140.623,231.11L140.623,237.46h17.183v7.295h-27.158z"
-          android:strokeAlpha="1"
-          android:strokeLineJoin="miter"
-          android:strokeWidth="1"
-          android:fillColor="#ffffff"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1"
-          android:strokeLineCap="butt" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="m130.648,212.543h26.675v6.877h-16.699v5.12h15.491v6.57L140.623,231.11L140.623,237.46h17.183v7.295h-27.158z"
+            android:strokeAlpha="1"
+            android:strokeLineJoin="miter"
+            android:strokeWidth="1"
+            android:fillColor="#ffffff"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1"
+            android:strokeLineCap="butt" />
 
-      <path
-          android:pathData="m163.167,212.543h26.675v6.877h-16.699v5.12h15.491v6.57L173.143,231.11L173.143,237.46h17.183v7.295h-27.158z"
-          android:strokeAlpha="1"
-          android:strokeLineJoin="miter"
-          android:strokeWidth="1"
-          android:fillColor="#ffffff"
-          android:strokeColor="#00000000"
-          android:fillAlpha="1"
-          android:strokeLineCap="butt" />
+        <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+        <path
+            android:pathData="m163.167,212.543h26.675v6.877h-16.699v5.12h15.491v6.57L173.143,231.11L173.143,237.46h17.183v7.295h-27.158z"
+            android:strokeAlpha="1"
+            android:strokeLineJoin="miter"
+            android:strokeWidth="1"
+            android:fillColor="#ffffff"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1"
+            android:strokeLineCap="butt" />
     </group>
 </vector>
index dedd5b1a17f8d14bbe6166ce4ccd6dd2c11669f7..b4998dd31d0b036e84e6bb5096aeb68cec582653 100644 (file)
@@ -99,7 +99,7 @@
         <activity
             android:name=".activities.MainWebViewActivity"
             android:label="@string/short_name"
-            android:theme="@style/PrivacyBrowserLight"
+            android:theme="@style/PrivacyBrowser"
             android:configChanges="orientation|screenSize|screenLayout|keyboard|keyboardHidden"
             android:launchMode="singleTask"
             android:screenOrientation="fullUser"
index 6f8b1a3d62aea95bf818208365410dee28eca316..cec281d89fdf13a7b29791e7891f6297e9590dbe 100644 (file)
@@ -46,7 +46,8 @@
         <p>More information about the blocklists can be found on the <a href="https://easylist.to/">EasyList website</a>.</p>
 
         <h3>Libraries</h3>
-        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>
+        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             and code from the <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
             which are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
 
index b7334fb95711564fd4f74771e112b4f1b123fda5..2aaa701ac242282c6b06813afcf19c6aa2cf80b8 100644 (file)
@@ -45,7 +45,8 @@
         <p>More information about the blocklists can be found on the <a href="https://easylist.to/">EasyList website</a>.</p>
 
         <h3>Libraries</h3>
-        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>
+        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             and code from the <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
             which are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
 
index d35e89267608a803a3840afbdab84357b4b8bb98..3591332e5ac6260d070027be98c8a462584e715e 100644 (file)
@@ -44,7 +44,8 @@
         <p>More information about the blocklists can be found on the <a href="https://easylist.to/">EasyList website</a>.</p>
 
         <h3>Libraries</h3>
-        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>
+        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             and code from the <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
             which are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
 
index 94fc96b7cc586ebbff6c6ec895d31a7a5307ac0f..0ca5a6298b0bd47787f9931a3799f8a864473594 100644 (file)
@@ -44,7 +44,8 @@
         <p>More information about the blocklists can be found on the <a href="https://easylist.to/">EasyList website</a>.</p>
 
         <h3>Libraries</h3>
-        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>
+        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             and code from the <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
             which are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
 
index 1efd9fab7b2b6a53c8d9416cc359a18554ce1ef9..3fdf16b1e62461b6225b55b8eef986d394107aa5 100644 (file)
@@ -46,7 +46,8 @@
         <p>Más información sobre las listas de bloqueo puede encontrarse en la <a href="https://easylist.to/">página web de EasyList</a>.</p>
 
         <h3>Librerías</h3>
-        <p>Navegador Privado está construido con las <a href="https://developer.android.com/jetpack/androidx/">librerías de AndroidX</a>
+        <p>Navegador Privado está construido con las <a href="https://developer.android.com/jetpack/androidx/">librerías de AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             y código del <a href="https://mvnrepository.com/artifact/com.google.android.material/material">repositorio de Google Material Maven</a>,
             que se publican bajo la <a href="https://www.apache.org/licenses/LICENSE-2.0">Licencia Apache 2.0</a>.</p>
 
index c365df02b05774b6eb2d1c1294e1043cb84dc5a2..8a9525e22cc4536b507aec282696a9126a4e93f9 100644 (file)
@@ -46,7 +46,8 @@
         <p>Más información sobre las listas de bloqueo puede encontrarse en la <a href="https://easylist.to/">página web de EasyList</a>.</p>
 
         <h3>Librerías</h3>
-        <p>Navegador Privado está construido con las <a href="https://developer.android.com/jetpack/androidx/">librerías de AndroidX</a>
+        <p>Navegador Privado está construido con las <a href="https://developer.android.com/jetpack/androidx/">librerías de AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             y código del <a href="https://mvnrepository.com/artifact/com.google.android.material/material">repositorio de Google Material Maven</a>,
             que se publican bajo la <a href="https://www.apache.org/licenses/LICENSE-2.0">Licencia Apache 2.0</a>.</p>
 
index 9fd954e14235e8c254378257181b5627023cd7b5..46d16e1a573409b6354e858144878e63e155a6e5 100644 (file)
@@ -46,7 +46,8 @@
         <p>Pour plus d'informations sur les listes de blocage, consultez le <a href="https://easylist.to/">site web EasyList</a>.</p>
 
         <h3>Librairies</h3>
-        <p>Privacy Browser est construit avec les <a href="https://developer.android.com/jetpack/androidx/">librairies AndroidX</a>
+        <p>Privacy Browser est construit avec les <a href="https://developer.android.com/jetpack/androidx/">librairies AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             et le code du <a href="https://mvnrepository.com/artifact/com.google.android.material/material">référentiel Google Material Maven</a>,
             publiées sous la <a href="https://www.apache.org/licenses/LICENSE-2.0">Licence Apache 2.0</a>.</p>
 
index c70af653a8af0c290222ef476ee44d86d0d6b776..3c23d5df9953bfc51d16f351846e4f36160818ff 100644 (file)
@@ -46,7 +46,8 @@
         <p>Pour plus d'informations sur les listes de blocage, consultez le <a href="https://easylist.to/">site web EasyList</a>.</p>
 
         <h3>Librairies</h3>
-        <p>Privacy Browser est construit avec les <a href="https://developer.android.com/jetpack/androidx/">librairies AndroidX</a>
+        <p>Privacy Browser est construit avec les <a href="https://developer.android.com/jetpack/androidx/">librairies AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             et le code du <a href="https://mvnrepository.com/artifact/com.google.android.material/material">référentiel Google Material Maven</a>,
             publiées sous la <a href="https://www.apache.org/licenses/LICENSE-2.0">Licence Apache 2.0</a>.</p>
 
index c117f94c98c434075b1ed6abddcf873e1b69fe02..e752e95e82840a0633b7167b56853a09529dff48 100644 (file)
@@ -49,7 +49,8 @@
         <p>E' possibile reperire maggiori informazioni sulle block list sul <a href="https://easylist.to/">sito web EasyList</a>.</p>
 
         <h3>Librerie</h3>
-        <p>Privacy Browser è compilato utilizzando le <a href="https://developer.android.com/jetpack/androidx/">Librerie AndroidX</a>
+        <p>Privacy Browser è compilato utilizzando le <a href="https://developer.android.com/jetpack/androidx/">Librerie AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             e il codice disponibile nella <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
             entrambi rilasciati con <a href="https://www.apache.org/licenses/LICENSE-2.0">Licenza Apache 2.0</a>.</p>
 
index bb3f7d6efbd958221a95fc73c632c467b4ba2827..58ed90db84018e99c3e0af204dc1e285d2266e4b 100644 (file)
@@ -49,7 +49,8 @@
         <p>E' possibile reperire maggiori informazioni sulle block list sul <a href="https://easylist.to/">sito web EasyList</a>.</p>
 
         <h3>Librerie</h3>
-        <p>Privacy Browser è compilato utilizzando le <a href="https://developer.android.com/jetpack/androidx/">Librerie AndroidX</a>
+        <p>Privacy Browser è compilato utilizzando le <a href="https://developer.android.com/jetpack/androidx/">Librerie AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             e il codice disponibile nella <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
             entrambi rilasciati con <a href="https://www.apache.org/licenses/LICENSE-2.0">Licenza Apache 2.0</a>.</p>
 
index 8a6a0532a4295675fac325c6f8d320747b6b0636..7e79ef5217abe6480e111a10a0e949712254370b 100644 (file)
@@ -44,7 +44,8 @@
         <p>Более подробную информацию о списках блокировки можно найти на <a href="https://easylist.to/">веб-сайте EasyList</a>.</p>
 
         <h3>Библиотеки</h3>
-        <p>Privacy Browser создан на базе библиотек <a href="https://developer.android.com/jetpack/androidx/">AndroidX</a>
+        <p>Privacy Browser создан на базе библиотек <a href="https://developer.android.com/jetpack/androidx/">AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             и кодовой базы из репозитория <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven</a>,
             которые выпущены под лицензией <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>.</p>
 
index a9d95e890e6e7b1ad3c4d92c55caedee4334dff6..c71850bb6a41a63404fa4b11ee0aa6d72156fdc1 100644 (file)
@@ -44,7 +44,8 @@
         <p>Более подробную информацию о списках блокировки можно найти на <a href="https://easylist.to/">веб-сайте EasyList</a>.</p>
 
         <h3>Библиотеки</h3>
-        <p>Privacy Browser создан на базе библиотек <a href="https://developer.android.com/jetpack/androidx/">AndroidX</a>
+        <p>Privacy Browser создан на базе библиотек <a href="https://developer.android.com/jetpack/androidx/">AndroidX</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
             и кодовой базы из репозитория <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven</a>,
             которые выпущены под лицензией <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>.</p>
 
index f591801015b1a0436a13750520e3317c15a84b10..453ebde1862010cbbc381483c46f1a984b015ed7 100644 (file)
         <p>Engel listeleri hakkında daha fazla bilgiyi <a href="https://easylist.to/">EasyList</a> adresinde bulabilirsiniz.</p>
 
         <h3>Kütüphaneler</h3>
-        <p>Privacy Browser <a href="https://developer.android.com/jetpack/androidx/">AndroidX Kütüphaneleri</a> ile ve
-            <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a> altında yayınlanan
-            <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven</a> veri havuzundaki kodlardan oluşturulmuştur.</p>
+        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
+            and code from the <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
+            which are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
 
         <p>Privacy Browser ücretsiz versiyonu <a href="https://developer.android.com/studio/terms">Android Software Development Kit</a> lisansı altında yayınlanan
             <a href="https://mvnrepository.com/artifact/com.google.firebase/firebase-ads">Firebase Ads</a> ile oluşturulmuştur.</p>
index 4fe9764a13552a4fbb39df304615ed837fb648a7..d8031280b0077917c5d9fd3da247a5d5909be7a7 100644 (file)
         <p>Engel listeleri hakkında daha fazla bilgiyi <a href="https://easylist.to/">EasyList</a> adresinde bulabilirsiniz.</p>
 
         <h3>Kütüphaneler</h3>
-        <p>Privacy Browser <a href="https://developer.android.com/jetpack/androidx/">AndroidX Kütüphaneleri</a> ile ve
-            <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a> altında yayınlanan
-            <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven</a> veri havuzundaki kodlardan oluşturulmuştur.</p>
+        <p>Privacy Browser is built with the <a href="https://developer.android.com/jetpack/androidx/">AndroidX Libraries</a>,
+            the <a href="https://github.com/JetBrains/kotlin/tree/master/license">Kotlin libraries</a>,
+            and code from the <a href="https://mvnrepository.com/artifact/com.google.android.material/material">Google Material Maven repository</a>,
+            which are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
 
         <p>Privacy Browser ücretsiz versiyonu <a href="https://developer.android.com/studio/terms">Android Software Development Kit</a> lisansı altında yayınlanan
             <a href="https://mvnrepository.com/artifact/com.google.firebase/firebase-ads">Firebase Ads</a> ile oluşturulmuştur.</p>
index 6ce5b431fa641b21d494a3b0238079bc9ad13235..3d5170dfc97d9e60410f3ade3a22942f58e8317d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -41,8 +41,7 @@ public class AboutActivity extends AppCompatActivity {
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -51,11 +50,7 @@ public class AboutActivity extends AppCompatActivity {
         }
 
         // Set the theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
index 67cff69d917672d1a2c2fe360341fb6240b9b8be..3a96929f897263bf1590279083faf4314a5b409a 100644 (file)
@@ -25,6 +25,7 @@ import android.app.Dialog;
 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;
@@ -128,8 +129,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -137,12 +137,8 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
@@ -991,12 +987,6 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
     }
 
     private void updateMoveIcons() {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Get a long array of the selected bookmarks.
         long[] selectedBookmarksLongArray = bookmarksListView.getCheckedItemIds();
 
@@ -1006,6 +996,9 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
         // 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`.
         if (selectedBookmarkDatabaseId == firstBookmarkDatabaseId) {  // The selected bookmark is in the first position.
             // Disable the move bookmark up `MenuItem`.
@@ -1014,14 +1007,14 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
             //  Set the move bookmark up icon to be ghosted.
             moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_disabled);
         } else {  // The selected bookmark is not in the first position.
-            // Enable the move bookmark up `MenuItem`.
+            // Enable the move bookmark up menu item.
             moveBookmarkUpMenuItem.setEnabled(true);
 
             // Set the icon according to the theme.
-            if (darkTheme) {
-                moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_dark);
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_night);
             } else {
-                moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_light);
+                moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_day);
             }
         }
 
@@ -1037,10 +1030,10 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
             moveBookmarkDownMenuItem.setEnabled(true);
 
             // Set the icon according to the theme.
-            if (darkTheme) {
-                moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_dark);
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_night);
             } else {
-                moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_light);
+                moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_day);
             }
         }
     }
index 9844f184ed188613001501cbd7c2adeba16f1164..c4b97517f12b4624ebd5b4985586c8c710de333d 100644 (file)
@@ -24,6 +24,7 @@ import android.app.Dialog;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.database.Cursor;
 import android.database.MatrixCursor;
 import android.database.MergeCursor;
@@ -107,8 +108,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -117,11 +117,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
         }
 
         // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
@@ -334,8 +330,12 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
                     parentFolderImageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.folder_dark_blue));
                     bookmarkParentFolderTextView.setText(bookmarkParentFolder);
 
+                    // Get the current theme status.
+                    int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
                     // Set the text color according to the theme.
-                    if (darkTheme) {
+                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                        // This color is a little darker than the default night mode text.  But the effect is rather nice.
                         bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.gray_300));
                     } else {
                         bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
@@ -590,12 +590,6 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
 
     @Override
     public boolean onOptionsItemSelected(MenuItem menuItem) {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-        // Get the theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Get the ID of the menu item that was selected.
         int menuItemId = menuItem.getItemId();
 
@@ -610,26 +604,29 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
                 // Update the sort by display order tracker.
                 sortByDisplayOrder = !sortByDisplayOrder;
 
-                // Get a handle for the bookmarks `ListView`.
+                // 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 (darkTheme) {
-                        menuItem.setIcon(R.drawable.sort_selected_dark);
+                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                        menuItem.setIcon(R.drawable.sort_selected_night);
                     } else {
-                        menuItem.setIcon(R.drawable.sort_selected_light);
+                        menuItem.setIcon(R.drawable.sort_selected_day);
                     }
 
                     // 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 (darkTheme) {
-                        menuItem.setIcon(R.drawable.sort_dark);
+                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                        menuItem.setIcon(R.drawable.sort_night);
                     } else {
-                        menuItem.setIcon(R.drawable.sort_light);
+                        menuItem.setIcon(R.drawable.sort_day);
                     }
 
                     // Display a Snackbar indicating the current sort type.
index 708e622b2e0568e74187224406122cd841c488df..6c07a121cd5762c8df94fefcf1993a7d18cd944b 100644 (file)
@@ -23,6 +23,7 @@ import android.app.Activity;
 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;
@@ -129,8 +130,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -138,12 +138,8 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
@@ -396,7 +392,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
 
                     // Disable the options `MenuItems`.
                     deleteMenuItem.setEnabled(false);
-                    deleteMenuItem.setIcon(R.drawable.delete_blue);
+                    deleteMenuItem.setIcon(R.drawable.delete_disabled);
 
                     // Remove the domain settings fragment.
                     fragmentManager.beginTransaction().remove(Objects.requireNonNull(fragmentManager.findFragmentById(R.id.domain_settings_fragment_container))).commit();
@@ -442,7 +438,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
                 // Get a handle for the activity.
                 Activity activity = this;
 
-                // Display a `Snackbar`.
+                // Display a snackbar.
                 undoDeleteSnackbar = Snackbar.make(domainsListView, R.string.domain_deleted, Snackbar.LENGTH_LONG)
                         .setAction(R.string.undo, (View v) -> {
                             // Do nothing because everything will be handled by `onDismissed()` below.
@@ -482,17 +478,27 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
                                             }
                                         };
 
-                                        // Update the `ListView`.
+                                        // Update the domains list view.
                                         domainsListView.setAdapter(undoDeleteDomainsCursorAdapter);
-                                        // Select the previously deleted domain in `domainsListView`.
+
+                                        // Select the previously deleted domain in the list view.
                                         domainsListView.setItemChecked(deletedDomainPosition, true);
 
-                                        // Display `domainSettingsFragment`.
+                                        // Display the domain settings fragment.
                                         fragmentManager.beginTransaction().replace(R.id.domain_settings_fragment_container, domainSettingsFragment).commit();
 
-                                        // Enable the options `MenuItems`.
+                                        // Enable the options delete menu item.
                                         deleteMenuItem.setEnabled(true);
-                                        deleteMenuItem.setIcon(R.drawable.delete_light);
+
+                                        // 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);
+                                        }
                                     } else {  // The device in in one-paned mode.
                                         // Display `domainSettingsFragment`.
                                         fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
@@ -514,29 +520,26 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
                                     if (dismissingSnackbar) {
                                         // Create a `Runnable` to enable the delete menu item.
                                         Runnable enableDeleteMenuItemRunnable = () -> {
-                                            // Enable `deleteMenuItem` according to the display mode.
+                                            // Enable the delete menu item according to the display mode.
                                             if (twoPanedMode) {  // Two-paned mode.
                                                 // Enable the delete menu item.
                                                 deleteMenuItem.setEnabled(true);
 
-                                                // Get a handle for the shared preferences.
-                                                SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-
-                                                // Get the theme preferences.
-                                                boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+                                                // Get the current theme status.
+                                                int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-                                                // Set the delete icon according to the theme.
-                                                if (darkTheme) {
-                                                    deleteMenuItem.setIcon(R.drawable.delete_dark);
+                                                // 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_light);
+                                                    deleteMenuItem.setIcon(R.drawable.delete_day);
                                                 }
                                             } else {  // Single-paned mode.
-                                                // Show `deleteMenuItem`.
+                                                // Show the delete menu item.
                                                 deleteMenuItem.setVisible(true);
                                             }
 
-                                            // Reset `dismissingSnackbar`.
+                                            // Reset the dismissing snackbar tracker.
                                             dismissingSnackbar = false;
                                         };
 
@@ -853,22 +856,19 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
             // Enable the delete options menu items.
             deleteMenuItem.setEnabled(true);
 
-            // Get a handle for the shared preferences.
-            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-            // Get the theme and screenshot preferences.
-            boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+            // Get the current theme status.
+            int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
             // Set the delete icon according to the theme.
-            if (darkTheme) {
-                deleteMenuItem.setIcon(R.drawable.delete_dark);
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                deleteMenuItem.setIcon(R.drawable.delete_night);
             } else {
-                deleteMenuItem.setIcon(R.drawable.delete_light);
+                deleteMenuItem.setIcon(R.drawable.delete_day);
             }
         } else if (twoPanedMode) {  // Two-paned mode is enabled but there are no domains.
             // Disable the options `MenuItems`.
             deleteMenuItem.setEnabled(false);
-            deleteMenuItem.setIcon(R.drawable.delete_blue);
+            deleteMenuItem.setIcon(R.drawable.delete_disabled);
         }
     }
 
index d6809e57f6923b2f2b90462b33ae7471e2c616b6..7fcf2d3cfb0874338a5df77a697a92839fcaff1c 100644 (file)
@@ -40,8 +40,7 @@ public class GuideActivity extends AppCompatActivity {
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -50,11 +49,7 @@ public class GuideActivity extends AppCompatActivity {
         }
 
         // Set the theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
index 3481f312dd555cd3b98054e9b7ab51c55bee1b5a..cc9363f9ad155b74be6cd341bad82094052db3c4 100644 (file)
@@ -96,8 +96,7 @@ public class ImportExportActivity extends AppCompatActivity implements StoragePe
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -105,12 +104,8 @@ public class ImportExportActivity extends AppCompatActivity implements StoragePe
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
index 9f433632419b622ba129178ded8f3f2429c7ca44..de0b873d8afa276757553de795f286c3bf3ed16c 100644 (file)
@@ -27,11 +27,13 @@ import android.content.ClipboardManager;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.content.res.Configuration;
 import android.media.MediaScannerConnection;
 import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
+import android.util.TypedValue;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -75,8 +77,7 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
         // Disable screenshots if not allowed.
@@ -84,12 +85,8 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
@@ -97,7 +94,7 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo
         // Set the content view.
         setContentView(R.layout.logcat_coordinatorlayout);
 
-        // The AndroidX toolbar must be used until the minimum API is >= 21.
+        // Set the toolbar as the action bar.
         Toolbar toolbar = findViewById(R.id.logcat_toolbar);
         setSupportActionBar(toolbar);
 
@@ -117,14 +114,28 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo
             new GetLogcat(this).execute();
         });
 
-        // Set the swipe to refresh color according to the theme.
-        if (darkTheme) {
-            swipeRefreshLayout.setColorSchemeResources(R.color.blue_600);
-            swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.gray_800);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+        // Set the refresh color scheme according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            swipeRefreshLayout.setColorSchemeResources(R.color.blue_500);
         } else {
             swipeRefreshLayout.setColorSchemeResources(R.color.blue_700);
         }
 
+        // Initialize a color background typed value.
+        TypedValue colorBackgroundTypedValue = new TypedValue();
+
+        // Get the color background from the theme.
+        getTheme().resolveAttribute(android.R.attr.colorBackground, colorBackgroundTypedValue, true);
+
+        // Get the color background int from the typed value.
+        int colorBackgroundInt = colorBackgroundTypedValue.data;
+
+        // Set the swipe refresh background color.
+        swipeRefreshLayout.setProgressBackgroundColorSchemeColor(colorBackgroundInt);
+
         // Get the logcat.
         new GetLogcat(this).execute();
     }
index 267e59bf769564b92f2d851217e55435bbcf0b3a..becbd5ac8ab5fd55ed65b6305196082fd87518f4 100644 (file)
@@ -58,6 +58,7 @@ import android.text.Spanned;
 import android.text.TextWatcher;
 import android.text.style.ForegroundColorSpan;
 import android.util.Patterns;
+import android.util.TypedValue;
 import android.view.ContextMenu;
 import android.view.GestureDetector;
 import android.view.KeyEvent;
@@ -96,6 +97,7 @@ import androidx.annotation.NonNull;
 import androidx.appcompat.app.ActionBar;
 import androidx.appcompat.app.ActionBarDrawerToggle;
 import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
 import androidx.appcompat.widget.Toolbar;
 import androidx.coordinatorlayout.widget.CoordinatorLayout;
 import androidx.core.app.ActivityCompat;
@@ -124,7 +126,6 @@ import com.stoutner.privacybrowser.dialogs.AdConsentDialog;
 import com.stoutner.privacybrowser.dialogs.CreateBookmarkDialog;
 import com.stoutner.privacybrowser.dialogs.CreateBookmarkFolderDialog;
 import com.stoutner.privacybrowser.dialogs.CreateHomeScreenShortcutDialog;
-import com.stoutner.privacybrowser.dialogs.EditBookmarkDialog;
 import com.stoutner.privacybrowser.dialogs.EditBookmarkFolderDialog;
 import com.stoutner.privacybrowser.dialogs.FontSizeDialog;
 import com.stoutner.privacybrowser.dialogs.HttpAuthenticationDialog;
@@ -167,9 +168,9 @@ import java.util.Objects;
 import java.util.Set;
 
 public class MainWebViewActivity extends AppCompatActivity implements CreateBookmarkDialog.CreateBookmarkListener, CreateBookmarkFolderDialog.CreateBookmarkFolderListener,
-        EditBookmarkDialog.EditBookmarkListener, EditBookmarkFolderDialog.EditBookmarkFolderListener, FontSizeDialog.UpdateFontSizeListener, NavigationView.OnNavigationItemSelectedListener,
-        OpenDialog.OpenListener, PinnedMismatchDialog.PinnedMismatchListener, PopulateBlocklists.PopulateBlocklistsListener, SaveDialog.SaveWebpageListener,
-        StoragePermissionDialog.StoragePermissionDialogListener, UrlHistoryDialog.NavigateHistoryListener, WebViewTabFragment.NewTabListener {
+        EditBookmarkFolderDialog.EditBookmarkFolderListener, FontSizeDialog.UpdateFontSizeListener, NavigationView.OnNavigationItemSelectedListener, OpenDialog.OpenListener,
+        PinnedMismatchDialog.PinnedMismatchListener, PopulateBlocklists.PopulateBlocklistsListener, SaveDialog.SaveWebpageListener, StoragePermissionDialog.StoragePermissionDialogListener,
+        UrlHistoryDialog.NavigateHistoryListener, WebViewTabFragment.NewTabListener {
 
     // `orbotStatus` is public static so it can be accessed from `OrbotProxyHelper`.  It is also used in `onCreate()`, `onResume()`, and `applyProxy()`.
     public static String orbotStatus = "unknown";
@@ -276,11 +277,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
     private ForegroundColorSpan initialGrayColorSpan;
     private ForegroundColorSpan finalGrayColorSpan;
 
-    // The drawer header padding variables are used in `onCreate()` and `onConfigurationChanged()`.
-    private int drawerHeaderPaddingLeftAndRight;
-    private int drawerHeaderPaddingTop;
-    private int drawerHeaderPaddingBottom;
-
     // `bookmarksDatabaseHelper` is used in `onCreate()`, `onDestroy`, `onOptionsItemSelected()`, `onCreateBookmark()`, `onCreateBookmarkFolder()`, `onSaveEditBookmark()`, `onSaveEditBookmarkFolder()`,
     // and `loadBookmarksFolder()`.
     private BookmarksDatabaseHelper bookmarksDatabaseHelper;
@@ -298,12 +294,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
     private ValueCallback<Uri[]> fileChooserCallback;
 
     // The default progress view offsets are set in `onCreate()` and used in `initializeWebView()`.
+    private int appBarHeight;
     private int defaultProgressViewStartOffset;
     private int defaultProgressViewEndOffset;
 
-    // The swipe refresh layout top padding is used when exiting full screen browsing mode.  It is used in an inner class in `initializeWebView()`.
-    private int swipeRefreshLayoutPaddingTop;
-
     // The URL sanitizers are set in `applyAppSettings()` and used in `sanitizeUrl()`.
     private boolean sanitizeGoogleAnalytics;
     private boolean sanitizeFacebookClickIds;
@@ -318,10 +312,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
     // Remove the warning about needing to override `performClick()` when using an `OnTouchListener` with `WebView`.
     @SuppressLint("ClickableViewAccessibility")
     protected void onCreate(Bundle savedInstanceState) {
-        // Enable the drawing of the entire webpage.  This makes it possible to save a website image.  This must be done before anything else happens with the WebView.
-        if (Build.VERSION.SDK_INT >= 21) {
-            WebView.enableSlowWholeDocumentDraw();
-        }
+        // Run the default commands.
+        super.onCreate(savedInstanceState);
 
         // Initialize the default preference values the first time the program is run.  `false` keeps this command from resetting any current preferences back to default.
         PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
@@ -329,24 +321,42 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // Get the theme and screenshot preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        // Get the screenshot preference.
+        String appTheme = sharedPreferences.getString("app_theme", getString(R.string.app_theme_default_value));
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
 
+        // Get the theme entry values string array.
+        String[] appThemeEntryValuesStringArray = getResources().getStringArray(R.array.app_theme_entry_values);
+
+        // Set the app theme according to the preference.  A switch statement cannot be used because the theme entry values string array is not a compile time constant.
+        if (appTheme.equals(appThemeEntryValuesStringArray[1])) {  // The light theme is selected.
+            // Apply the light theme.
+            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
+        } else if (appTheme.equals(appThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+            // Apply the dark theme.
+            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
+        } else {  // The system default theme is selected.
+            if (Build.VERSION.SDK_INT >= 28) {  // The system default theme is supported.
+                // Follow the system default theme.
+                AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
+            } else {  // The system default theme is not supported.
+                // Follow the battery saver mode.
+                AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
+            }
+        }
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight);
+        // Enable the drawing of the entire webpage.  This makes it possible to save a website image.  This must be done before anything else happens with the WebView.
+        if (Build.VERSION.SDK_INT >= 21) {
+            WebView.enableSlowWholeDocumentDraw();
         }
 
-        // Run the default commands.
-        super.onCreate(savedInstanceState);
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowser);
 
         // Set the content view.
         setContentView(R.layout.main_framelayout);
@@ -356,11 +366,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         Toolbar toolbar = findViewById(R.id.toolbar);
         ViewPager webViewPager = findViewById(R.id.webviewpager);
 
-        // Set the action bar.  `SupportActionBar` must be used until the minimum API is >= 21.
-        setSupportActionBar(toolbar);
+        // Get a handle for the app compat delegate.
+        AppCompatDelegate appCompatDelegate = getDelegate();
+
+        // Set the support action bar.
+        appCompatDelegate.setSupportActionBar(toolbar);
 
         // Get a handle for the action bar.
-        ActionBar actionBar = getSupportActionBar();
+        ActionBar actionBar = appCompatDelegate.getSupportActionBar();
 
         // This is needed to get rid of the Android Studio warning that the action bar might be null.
         assert actionBar != null;
@@ -369,12 +382,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         actionBar.setCustomView(R.layout.url_app_bar);
         actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
 
-        // Initially disable the sliding drawers.  They will be enabled once the blocklists are loaded.
-        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
-
         // Create the hamburger icon at the start of the AppBar.
         actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_navigation_drawer, R.string.close_navigation_drawer);
 
+        // Initially disable the sliding drawers.  They will be enabled once the blocklists are loaded.
+        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+
         // Initialize the web view pager adapter.
         webViewPagerAdapter = new WebViewPagerAdapter(getSupportFragmentManager());
 
@@ -568,9 +581,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             // Get a handle for the root frame layouts.
             FrameLayout rootFrameLayout = findViewById(R.id.root_framelayout);
 
-            // Remove the translucent status flag.  This is necessary so the root frame layout can fill the entire screen.
-            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-
             /* Hide the system bars.
              * SYSTEM_UI_FLAG_FULLSCREEN hides the status bar at the top of the screen.
              * SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the root frame layout fill the area that is normally reserved for the status bar.
@@ -619,12 +629,20 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
     @Override
     public void onDestroy() {
-        // Unregister the orbot status broadcast receiver.
-        this.unregisterReceiver(orbotStatusBroadcastReceiver);
+        // Unregister the orbot status broadcast receiver if it exists.
+        if (orbotStatusBroadcastReceiver != null) {
+            this.unregisterReceiver(orbotStatusBroadcastReceiver);
+        }
 
-        // Close the bookmarks cursor and database.
-        bookmarksCursor.close();
-        bookmarksDatabaseHelper.close();
+        // Close the bookmarks cursor if it exists.
+        if (bookmarksCursor != null) {
+            bookmarksCursor.close();
+        }
+
+        // Close the bookmarks database if it exists.
+        if (bookmarksDatabaseHelper != null) {
+            bookmarksDatabaseHelper.close();
+        }
 
         // Run the default commands.
         super.onDestroy();
@@ -668,7 +686,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
         // Get the dark theme and app bar preferences..
         boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean("display_additional_app_bar_icons", false);
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
 
         // Set the status of the additional app bar icons.  Setting the refresh menu item to `SHOW_AS_ACTION_ALWAYS` makes it appear even on small devices like phones.
         if (displayAdditionalAppBarIcons) {
@@ -686,12 +703,18 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             // Set the title.
             refreshMenuItem.setTitle(R.string.stop);
 
-            // If the icon is displayed in the AppBar, set it according to the theme.
+            // Set the icon if it is displayed in the app bar.
             if (displayAdditionalAppBarIcons) {
-                if (darkTheme) {
-                    refreshMenuItem.setIcon(R.drawable.close_dark);
+                // 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_YES) {
+                    // Set the dark stop icon.
+                    refreshMenuItem.setIcon(R.drawable.close_night);
                 } else {
-                    refreshMenuItem.setIcon(R.drawable.close_light);
+                    // Set the light stop icon.
+                    refreshMenuItem.setIcon(R.drawable.close_day);
                 }
             }
         }
@@ -2017,18 +2040,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Run the default commands.
         super.onConfigurationChanged(newConfig);
 
-        // Get the status bar pixel size.
-        int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
-        int statusBarPixelSize = getResources().getDimensionPixelSize(statusBarResourceId);
-
-        // Get the resource density.
-        float screenDensity = getResources().getDisplayMetrics().density;
-
-        // Recalculate the drawer header padding.
-        drawerHeaderPaddingLeftAndRight = (int) (15 * screenDensity);
-        drawerHeaderPaddingTop = statusBarPixelSize + (int) (4 * screenDensity);
-        drawerHeaderPaddingBottom = (int) (8 * screenDensity);
-
         // Reload the ad for the free flavor if not in full screen mode.
         if (BuildConfig.FLAVOR.contentEquals("free") && !inFullScreenBrowsingMode) {
             // Reload the ad.  The AdView is destroyed and recreated, which changes the ID, every time it is reloaded to handle possible rotations.
@@ -2457,47 +2468,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         bookmarksListView.setSelection(0);
     }
 
-    @Override
-    public void onSaveBookmark(DialogFragment dialogFragment, int selectedBookmarkDatabaseId, Bitmap favoriteIconBitmap) {
-        // Get the dialog.
-        Dialog dialog = dialogFragment.getDialog();
-
-        // Remove the incorrect lint warning below that the dialog might be null.
-        assert dialog != null;
-
-        // Get handles for the views from the dialog.
-        EditText editBookmarkNameEditText = dialog.findViewById(R.id.edit_bookmark_name_edittext);
-        EditText editBookmarkUrlEditText = dialog.findViewById(R.id.edit_bookmark_url_edittext);
-        RadioButton currentBookmarkIconRadioButton = dialog.findViewById(R.id.edit_bookmark_current_icon_radiobutton);
-
-        // Store the bookmark strings.
-        String bookmarkNameString = editBookmarkNameEditText.getText().toString();
-        String bookmarkUrlString = editBookmarkUrlEditText.getText().toString();
-
-        // Update the bookmark.
-        if (currentBookmarkIconRadioButton.isChecked()) {  // Update the bookmark without changing the favorite icon.
-            bookmarksDatabaseHelper.updateBookmark(selectedBookmarkDatabaseId, bookmarkNameString, bookmarkUrlString);
-        } else {  // Update the bookmark using the `WebView` favorite icon.
-            // Create a favorite icon byte array output stream.
-            ByteArrayOutputStream newFavoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
-
-            // Convert the favorite icon bitmap to a byte array.  `0` is for lossless compression (the only option for a PNG).
-            favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, newFavoriteIconByteArrayOutputStream);
-
-            // Convert the favorite icon byte array stream to a byte array.
-            byte[] newFavoriteIconByteArray = newFavoriteIconByteArrayOutputStream.toByteArray();
-
-            //  Update the bookmark and the favorite icon.
-            bookmarksDatabaseHelper.updateBookmark(selectedBookmarkDatabaseId, bookmarkNameString, bookmarkUrlString, newFavoriteIconByteArray);
-        }
-
-        // Update the bookmarks cursor with the current contents of this folder.
-        bookmarksCursor = bookmarksDatabaseHelper.getBookmarksByDisplayOrder(currentBookmarksFolder);
-
-        // Update the list view.
-        bookmarksCursorAdapter.changeCursor(bookmarksCursor);
-    }
-
     @Override
     public void onSaveBookmarkFolder(DialogFragment dialogFragment, int selectedFolderDatabaseId, Bitmap favoriteIconBitmap) {
         // Get the dialog.
@@ -2633,30 +2603,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             // Apply the appropriate full screen mode flags.
             if (fullScreenBrowsingModeEnabled && inFullScreenBrowsingMode) {  // Privacy Browser is currently in full screen browsing mode.
-                // Hide the app bar if specified.
-                if (hideAppBar) {
-                    // Get handles for the views.
-                    LinearLayout tabsLinearLayout = findViewById(R.id.tabs_linearlayout);
-                    ActionBar actionBar = getSupportActionBar();
-
-                    // Remove the incorrect lint warning below that the action bar might be null.
-                    assert actionBar != null;
-
-                    // Hide the tab linear layout.
-                    tabsLinearLayout.setVisibility(View.GONE);
-
-                    // Hide the action bar.
-                    actionBar.hide();
-                }
-
                 // Hide the banner ad in the free flavor.
                 if (BuildConfig.FLAVOR.contentEquals("free")) {
                     AdHelper.hideAd(findViewById(R.id.adview));
                 }
 
-                // Remove the translucent status flag.  This is necessary so the root frame layout can fill the entire screen.
-                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-
                 /* Hide the system bars.
                  * SYSTEM_UI_FLAG_FULLSCREEN hides the status bar at the top of the screen.
                  * SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the root frame layout fill the area that is normally reserved for the status bar.
@@ -2665,12 +2616,15 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                  */
                 rootFrameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                         View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+
+                // Reload the website if the app bar is hidden.  Otherwise, there is some bug in Android that causes the WebView to be entirely black.
+                if (hideAppBar) {
+                    // Reload the WebView.
+                    currentWebView.reload();
+                }
             } else {  // Switch to normal viewing mode.
                 // Remove the `SYSTEM_UI` flags from the root frame layout.
                 rootFrameLayout.setSystemUiVisibility(0);
-
-                // Add the translucent status flag.
-                getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
             }
 
             // Reload the ad for the free flavor if not in full screen mode.
@@ -3205,10 +3159,13 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             searchURL = searchString;
         }
 
+        // Get a handle for the app compat delegate.
+        AppCompatDelegate appCompatDelegate = getDelegate();
+
         // Get handles for the views that need to be modified.
         FrameLayout rootFrameLayout = findViewById(R.id.root_framelayout);
         AppBarLayout appBarLayout = findViewById(R.id.appbar_layout);
-        ActionBar actionBar = getSupportActionBar();
+        ActionBar actionBar = appCompatDelegate.getSupportActionBar();
         Toolbar toolbar = findViewById(R.id.toolbar);
         LinearLayout findOnPageLinearLayout = findViewById(R.id.find_on_page_linearlayout);
         LinearLayout tabsLinearLayout = findViewById(R.id.tabs_linearlayout);
@@ -3297,9 +3254,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 AdHelper.hideAd(findViewById(R.id.adview));
             }
 
-            // Remove the translucent status flag.  This is necessary so the root frame layout can fill the entire screen.
-            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-
             /* Hide the system bars.
              * SYSTEM_UI_FLAG_FULLSCREEN hides the status bar at the top of the screen.
              * SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the root frame layout fill the area that is normally reserved for the status bar.
@@ -3326,19 +3280,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             // Remove the `SYSTEM_UI` flags from the root frame layout.
             rootFrameLayout.setSystemUiVisibility(0);
-
-            // Add the translucent status flag.
-            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
         }
     }
 
     private void initializeApp() {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-        // Get the theme preference.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Get a handle for the input method.
         InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
 
@@ -3528,20 +3473,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             }
         });
 
-        // Set the bookmarks drawer resources according to the theme.  This can't be done in the layout due to compatibility issues with the `DrawerLayout` support widget.
-        // The deprecated `getResources().getDrawable()` must be used until the minimum API >= 21 and and `getResources().getColor()` must be used until the minimum API >= 23.
-        if (darkTheme) {
-            launchBookmarksActivityFab.setImageDrawable(getResources().getDrawable(R.drawable.bookmarks_dark));
-            createBookmarkFolderFab.setImageDrawable(getResources().getDrawable(R.drawable.create_folder_dark));
-            createBookmarkFab.setImageDrawable(getResources().getDrawable(R.drawable.create_bookmark_dark));
-            bookmarksListView.setBackgroundColor(getResources().getColor(R.color.gray_850));
-        } else {
-            launchBookmarksActivityFab.setImageDrawable(getResources().getDrawable(R.drawable.bookmarks_light));
-            createBookmarkFolderFab.setImageDrawable(getResources().getDrawable(R.drawable.create_folder_light));
-            createBookmarkFab.setImageDrawable(getResources().getDrawable(R.drawable.create_bookmark_light));
-            bookmarksListView.setBackgroundColor(getResources().getColor(R.color.white));
-        }
-
         // Set the launch bookmarks activity FAB to launch the bookmarks activity.
         launchBookmarksActivityFab.setOnClickListener(v -> {
             // Get a copy of the favorite icon bitmap.
@@ -3629,15 +3560,29 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         defaultProgressViewStartOffset = swipeRefreshLayout.getProgressViewStartOffset();
         defaultProgressViewEndOffset = swipeRefreshLayout.getProgressViewEndOffset();
 
-        // Set the swipe to refresh color according to the theme.
-        if (darkTheme) {
-            swipeRefreshLayout.setColorSchemeResources(R.color.blue_800);
-            swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.gray_850);
-        } else {
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+        // Set the refresh color scheme according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
             swipeRefreshLayout.setColorSchemeResources(R.color.blue_500);
+        } else {
+            swipeRefreshLayout.setColorSchemeResources(R.color.blue_700);
         }
 
-        // `DrawerTitle` identifies the `DrawerLayouts` in accessibility mode.
+        // Initialize a color background typed value.
+        TypedValue colorBackgroundTypedValue = new TypedValue();
+
+        // Get the color background from the theme.
+        getTheme().resolveAttribute(android.R.attr.colorBackground, colorBackgroundTypedValue, true);
+
+        // Get the color background int from the typed value.
+        int colorBackgroundInt = colorBackgroundTypedValue.data;
+
+        // Set the swipe refresh background color.
+        swipeRefreshLayout.setProgressBackgroundColorSchemeColor(colorBackgroundInt);
+
+        // The drawer titles identify the drawer layouts in accessibility mode.
         drawerLayout.setDrawerTitle(GravityCompat.START, getString(R.string.navigation_drawer));
         drawerLayout.setDrawerTitle(GravityCompat.END, getString(R.string.bookmarks));
 
@@ -3710,18 +3655,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             return true;
         });
 
-        // Get the status bar pixel size.
-        int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
-        int statusBarPixelSize = getResources().getDimensionPixelSize(statusBarResourceId);
-
-        // Get the resource density.
-        float screenDensity = getResources().getDisplayMetrics().density;
-
-        // Calculate the drawer header padding.  This is used to move the text in the drawer headers below any cutouts.
-        drawerHeaderPaddingLeftAndRight = (int) (15 * screenDensity);
-        drawerHeaderPaddingTop = statusBarPixelSize + (int) (4 * screenDensity);
-        drawerHeaderPaddingBottom = (int) (8 * screenDensity);
-
         // The drawer listener is used to update the navigation menu.
         drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
             @Override
@@ -3739,20 +3672,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             @Override
             public void onDrawerStateChanged(int newState) {
                 if ((newState == DrawerLayout.STATE_SETTLING) || (newState == DrawerLayout.STATE_DRAGGING)) {  // A drawer is opening or closing.
-                    // Get handles for the drawer headers.
-                    TextView navigationHeaderTextView = findViewById(R.id.navigationText);
-                    TextView bookmarksHeaderTextView = findViewById(R.id.bookmarks_title_textview);
-
-                    // Apply the navigation header paddings if the view is not null (sometimes it is null if another activity has already started).  This moves the text in the header below any cutouts.
-                    if (navigationHeaderTextView != null) {
-                        navigationHeaderTextView.setPadding(drawerHeaderPaddingLeftAndRight, drawerHeaderPaddingTop, drawerHeaderPaddingLeftAndRight, drawerHeaderPaddingBottom);
-                    }
-
-                    // Apply the bookmarks header paddings if the view is not null (sometimes it is null if another activity has already started).  This moves the text in the header below any cutouts.
-                    if (bookmarksHeaderTextView != null) {
-                        bookmarksHeaderTextView.setPadding(drawerHeaderPaddingLeftAndRight, drawerHeaderPaddingTop, drawerHeaderPaddingLeftAndRight, drawerHeaderPaddingBottom);
-                    }
-
                     // Update the navigation menu items if the WebView is not null.
                     if (currentWebView != null) {
                         navigationBackMenuItem.setEnabled(currentWebView.canGoBack());
@@ -3938,7 +3857,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             String defaultFontSizeString = sharedPreferences.getString("font_size", getString(R.string.font_size_default_value));
             String defaultUserAgentName = sharedPreferences.getString("user_agent", getString(R.string.user_agent_default_value));
             boolean defaultSwipeToRefresh = sharedPreferences.getBoolean("swipe_to_refresh", true);
-            boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
             boolean wideViewport = sharedPreferences.getBoolean("wide_viewport", true);
             boolean displayWebpageImages = sharedPreferences.getBoolean("display_webpage_images", true);
 
@@ -4182,8 +4100,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                         break;
                 }
 
-                // Set a green background on the URL relative layout to indicate that custom domain settings are being used. The deprecated `.getDrawable()` must be used until the minimum API >= 21.
-                if (darkTheme) {
+                // 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. The deprecated `.getDrawable()` must be used until the minimum API >= 21.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     urlRelativeLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_dark_blue));
                 } else {
                     urlRelativeLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_light_green));
@@ -4296,12 +4217,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
     }
 
     private void applyProxy(boolean reloadWebViews) {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-        // Get the theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Get a handle for the app bar layout.
         AppBarLayout appBarLayout = findViewById(R.id.appbar_layout);
 
@@ -4311,20 +4226,28 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Reset the waiting for proxy tracker.
         waitingForProxy = false;
 
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
         // Update the user interface and reload the WebViews if requested.
         switch (proxyMode) {
             case ProxyHelper.NONE:
+                // Initialize a color background typed value.
+                TypedValue colorBackgroundTypedValue = new TypedValue();
+
+                // Get the color background from the theme.
+                getTheme().resolveAttribute(android.R.attr.colorBackground, colorBackgroundTypedValue, true);
+
+                // Get the color background int from the typed value.
+                int colorBackgroundInt = colorBackgroundTypedValue.data;
+
                 // Set the default app bar layout background.
-                if (darkTheme) {
-                    appBarLayout.setBackgroundResource(R.color.gray_900);
-                } else {
-                    appBarLayout.setBackgroundResource(R.color.gray_100);
-                }
+                appBarLayout.setBackgroundColor(colorBackgroundInt);
                 break;
 
             case ProxyHelper.TOR:
                 // Set the app bar background to indicate proxying through Orbot is enabled.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     appBarLayout.setBackgroundResource(R.color.dark_blue_30);
                 } else {
                     appBarLayout.setBackgroundResource(R.color.blue_50);
@@ -4366,7 +4289,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             case ProxyHelper.I2P:
                 // Set the app bar background to indicate proxying through Orbot is enabled.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     appBarLayout.setBackgroundResource(R.color.dark_blue_30);
                 } else {
                     appBarLayout.setBackgroundResource(R.color.blue_50);
@@ -4393,7 +4316,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             case ProxyHelper.CUSTOM:
                 // Set the app bar background to indicate proxying through Orbot is enabled.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     appBarLayout.setBackgroundResource(R.color.dark_blue_30);
                 } else {
                     appBarLayout.setBackgroundResource(R.color.blue_50);
@@ -4426,12 +4349,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
     private void updatePrivacyIcons(boolean runInvalidateOptionsMenu) {
         // Only update the privacy icons if the options menu and the current WebView have already been populated.
         if ((optionsMenu != null) && (currentWebView != null)) {
-            // Get a handle for the shared preferences.
-            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-            // Get the theme and screenshot preferences.
-            boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
             // Get handles for the menu items.
             MenuItem privacyMenuItem = optionsMenu.findItem(R.id.toggle_javascript);
             MenuItem firstPartyCookiesMenuItem = optionsMenu.findItem(R.id.toggle_first_party_cookies);
@@ -4447,14 +4364,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 privacyMenuItem.setIcon(R.drawable.privacy_mode);
             }
 
+            // Get the current theme status.
+            int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
             // Update the first-party cookies icon.
             if (currentWebView.getAcceptFirstPartyCookies()) {  // First-party cookies are enabled.
                 firstPartyCookiesMenuItem.setIcon(R.drawable.cookies_enabled);
             } else {  // First-party cookies are disabled.
-                if (darkTheme) {
-                    firstPartyCookiesMenuItem.setIcon(R.drawable.cookies_disabled_dark);
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                    firstPartyCookiesMenuItem.setIcon(R.drawable.cookies_disabled_night);
                 } else {
-                    firstPartyCookiesMenuItem.setIcon(R.drawable.cookies_disabled_light);
+                    firstPartyCookiesMenuItem.setIcon(R.drawable.cookies_disabled_day);
                 }
             }
 
@@ -4462,27 +4382,27 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             if (currentWebView.getSettings().getJavaScriptEnabled() && currentWebView.getSettings().getDomStorageEnabled()) {  // Both JavaScript and DOM storage are enabled.
                 domStorageMenuItem.setIcon(R.drawable.dom_storage_enabled);
             } else if (currentWebView.getSettings().getJavaScriptEnabled()) {  // JavaScript is enabled but DOM storage is disabled.
-                if (darkTheme) {
-                    domStorageMenuItem.setIcon(R.drawable.dom_storage_disabled_dark);
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                    domStorageMenuItem.setIcon(R.drawable.dom_storage_disabled_night);
                 } else {
-                    domStorageMenuItem.setIcon(R.drawable.dom_storage_disabled_light);
+                    domStorageMenuItem.setIcon(R.drawable.dom_storage_disabled_day);
                 }
             } else {  // JavaScript is disabled, so DOM storage is ghosted.
-                if (darkTheme) {
-                    domStorageMenuItem.setIcon(R.drawable.dom_storage_ghosted_dark);
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                    domStorageMenuItem.setIcon(R.drawable.dom_storage_ghosted_night);
                 } else {
-                    domStorageMenuItem.setIcon(R.drawable.dom_storage_ghosted_light);
+                    domStorageMenuItem.setIcon(R.drawable.dom_storage_ghosted_day);
                 }
             }
 
             // Update the refresh icon.
-            if (darkTheme) {
-                refreshMenuItem.setIcon(R.drawable.refresh_enabled_dark);
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                refreshMenuItem.setIcon(R.drawable.refresh_enabled_night);
             } else {
-                refreshMenuItem.setIcon(R.drawable.refresh_enabled_light);
+                refreshMenuItem.setIcon(R.drawable.refresh_enabled_day);
             }
 
-            // `invalidateOptionsMenu` calls `onPrepareOptionsMenu()` and redraws the icons in the `AppBar`.
+            // `invalidateOptionsMenu()` calls `onPrepareOptionsMenu()` and redraws the icons in the app bar.
             if (runInvalidateOptionsMenu) {
                 invalidateOptionsMenu();
             }
@@ -4953,12 +4873,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
     }
 
     private void setCurrentWebView(int pageNumber) {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-        // Get the theme preference.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Get handles for the URL views.
         RelativeLayout urlRelativeLayout = findViewById(R.id.url_relativelayout);
         EditText urlEditText = findViewById(R.id.url_edittext);
@@ -5036,8 +4950,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             // 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. The deprecated `.getDrawable()` must be used until the minimum API >= 21.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     urlRelativeLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_dark_blue));
                 } else {
                     urlRelativeLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_light_green));
@@ -5062,11 +4979,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
     @Override
     public void initializeWebView(NestedScrollWebView nestedScrollWebView, int pageNumber, ProgressBar progressBar, String url) {
+        // Get a handle for the app compat delegate.
+        AppCompatDelegate appCompatDelegate = getDelegate();
+
         // Get handles for the activity views.
         FrameLayout rootFrameLayout = findViewById(R.id.root_framelayout);
         DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
         RelativeLayout mainContentRelativeLayout = findViewById(R.id.main_content_relativelayout);
-        ActionBar actionBar = getSupportActionBar();
+        ActionBar actionBar = appCompatDelegate.getSupportActionBar();
         LinearLayout tabsLinearLayout = findViewById(R.id.tabs_linearlayout);
         EditText urlEditText = findViewById(R.id.url_edittext);
         TabLayout tabLayout = findViewById(R.id.tablayout);
@@ -5124,9 +5044,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                     // Toggle the full screen browsing mode.
                     if (inFullScreenBrowsingMode) {  // Switch to full screen mode.
-                        // Store the swipe refresh layout top padding.
-                        swipeRefreshLayoutPaddingTop = swipeRefreshLayout.getPaddingTop();
-
                         // Hide the app bar if specified.
                         if (hideAppBar) {
                             // Close the find on page bar if it is visible.
@@ -5138,10 +5055,13 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                             // Hide the action bar.
                             actionBar.hide();
 
-                            // Check to see if app bar scrolling is disabled.
+                            // If the app bar is not being scrolled, the swipe refresh layout needs to be adjusted.
                             if (!scrollAppBar) {
                                 // Remove the padding from the top of the swipe refresh layout.
                                 swipeRefreshLayout.setPadding(0, 0, 0, 0);
+
+                                // The swipe refresh circle must be moved above the now removed status bar location.
+                                swipeRefreshLayout.setProgressViewOffset(false, -200, defaultProgressViewEndOffset);
                             }
                         }
 
@@ -5150,9 +5070,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                             AdHelper.hideAd(findViewById(R.id.adview));
                         }
 
-                        // Remove the translucent status flag.  This is necessary so the root frame layout can fill the entire screen.
-                        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-
                         /* Hide the system bars.
                          * SYSTEM_UI_FLAG_FULLSCREEN hides the status bar at the top of the screen.
                          * SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the root frame layout fill the area that is normally reserved for the status bar.
@@ -5162,16 +5079,22 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                         rootFrameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                                 View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
                     } else {  // Switch to normal viewing mode.
-                        // Show the tab linear layout.
-                        tabsLinearLayout.setVisibility(View.VISIBLE);
+                        // Show the app bar if it was hidden.
+                        if (hideAppBar) {
+                            // Show the tab linear layout.
+                            tabsLinearLayout.setVisibility(View.VISIBLE);
 
-                        // Show the action bar.
-                        actionBar.show();
+                            // Show the action bar.
+                            actionBar.show();
+
+                            // If the app bar is not being scrolled, the swipe refresh layout needs to be adjusted.
+                            if (!scrollAppBar) {
+                                // The swipe refresh layout must be manually moved below the app bar layout.
+                                swipeRefreshLayout.setPadding(0, appBarHeight, 0, 0);
 
-                        // Check to see if app bar scrolling is disabled.
-                        if (!scrollAppBar) {
-                            // Add the padding from the top of the swipe refresh layout.
-                            swipeRefreshLayout.setPadding(0, swipeRefreshLayoutPaddingTop, 0, 0);
+                                // The swipe to refresh circle doesn't always hide itself completely unless it is moved up 10 pixels.
+                                swipeRefreshLayout.setProgressViewOffset(false, defaultProgressViewStartOffset - 10 + appBarHeight, defaultProgressViewEndOffset + appBarHeight);
+                            }
                         }
 
                         // Show the banner ad in the free flavor.
@@ -5182,9 +5105,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                         // Remove the `SYSTEM_UI` flags from the root frame layout.
                         rootFrameLayout.setSystemUiVisibility(0);
-
-                        // Add the translucent status flag.
-                        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                     }
 
                     // Consume the double-tap.
@@ -5411,12 +5331,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 // Hide the main content relative layout.
                 mainContentRelativeLayout.setVisibility(View.GONE);
 
-                // Remove the translucent status bar overlay on the `Drawer Layout`, which is special and needs its own command.
-                drawerLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
-
-                // Remove the translucent status flag.  This is necessary so the root frame layout can fill the entire screen.
-                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-
                 /* Hide the system bars.
                  * SYSTEM_UI_FLAG_FULLSCREEN hides the status bar at the top of the screen.
                  * SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the root frame layout fill the area that is normally reserved for the status bar.
@@ -5479,9 +5393,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                         AdHelper.hideAd(findViewById(R.id.adview));
                     }
 
-                    // Remove the translucent status flag.  This is necessary so the root frame layout can fill the entire screen.
-                    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
-
                     /* Hide the system bars.
                      * SYSTEM_UI_FLAG_FULLSCREEN hides the status bar at the top of the screen.
                      * SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the root frame layout fill the area that is normally reserved for the status bar.
@@ -5493,9 +5404,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 } else {  // Switch to normal viewing mode.
                     // Remove the `SYSTEM_UI` flags from the root frame layout.
                     rootFrameLayout.setSystemUiVisibility(0);
-
-                    // Add the translucent status flag.
-                    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                 }
 
                 // Reload the ad for the free flavor if not in full screen mode.
@@ -5992,21 +5900,20 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             public void onPageStarted(WebView view, String url, Bitmap favicon) {
                 // Get the preferences.
                 boolean scrollAppBar = sharedPreferences.getBoolean("scroll_app_bar", true);
-                boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
 
                 // Get a handler for the app bar layout.
                 AppBarLayout appBarLayout = findViewById(R.id.appbar_layout);
 
-                // Set the top padding of the swipe refresh layout according to the app bar scrolling preference.
-                if (scrollAppBar) {
+                // Set the top padding of the swipe refresh layout according to the app bar scrolling preference.  This can't be done in `appAppSettings()` because the app bar is not yet populated there.
+                if (scrollAppBar || (inFullScreenBrowsingMode && hideAppBar)) {
                     // No padding is needed because it will automatically be placed below the app bar layout due to the scrolling layout behavior.
                     swipeRefreshLayout.setPadding(0, 0, 0, 0);
 
                     // The swipe to refresh circle doesn't always hide itself completely unless it is moved up 10 pixels.
                     swipeRefreshLayout.setProgressViewOffset(false, defaultProgressViewStartOffset - 10, defaultProgressViewEndOffset);
                 } else {
-                    // Get the app bar layout height.  This can't be done in `applyAppSettings()` because the app bar is not yet populated.
-                    int appBarHeight = appBarLayout.getHeight();
+                    // Get the app bar layout height.  This can't be done in `applyAppSettings()` because the app bar is not yet populated there.
+                    appBarHeight = appBarLayout.getHeight();
 
                     // The swipe refresh layout must be manually moved below the app bar layout.
                     swipeRefreshLayout.setPadding(0, appBarHeight, 0, 0);
@@ -6021,6 +5928,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 // Reset the requests counters.
                 nestedScrollWebView.resetRequestsCounters();
 
+                // TODO.  Make the background of a new tab match the theme.
                 // If night mode is enabled, hide `mainWebView` until after the night mode CSS is applied.
                 if (nestedScrollWebView.getNightMode()) {
                     nestedScrollWebView.setVisibility(View.INVISIBLE);
@@ -6068,10 +5976,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                     // If the icon is displayed in the AppBar, set it according to the theme.
                     if (displayAdditionalAppBarIcons) {
-                        if (darkTheme) {
-                            refreshMenuItem.setIcon(R.drawable.close_dark);
+                        // 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_YES) {
+                            refreshMenuItem.setIcon(R.drawable.close_night);
                         } else {
-                            refreshMenuItem.setIcon(R.drawable.close_light);
+                            refreshMenuItem.setIcon(R.drawable.close_day);
                         }
                     }
                 }
@@ -6094,14 +6006,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                     // Get the app bar and theme preferences.
                     boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean("display_additional_app_bar_icons", false);
-                    boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
 
-                    // If the icon is displayed in the AppBar, reset it according to the theme.
+                    // If the icon is displayed in the app bar, reset it according to the theme.
                     if (displayAdditionalAppBarIcons) {
-                        if (darkTheme) {
-                            refreshMenuItem.setIcon(R.drawable.refresh_enabled_dark);
+                        // 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_YES) {
+                            refreshMenuItem.setIcon(R.drawable.refresh_enabled_night);
                         } else {
-                            refreshMenuItem.setIcon(R.drawable.refresh_enabled_light);
+                            refreshMenuItem.setIcon(R.drawable.refresh_enabled_day);
                         }
                     }
                 }
index c7be71c5283b14995bf391c32df1568b8a6008eb..2adeb318a54a7b8410d40a17aa24395969f9dcfe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2018-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2018-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -60,21 +60,16 @@ public class RequestsActivity extends AppCompatActivity implements ViewRequestDi
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
 
-        // Get the screenshot and theme preferences.
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
 
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
-        }
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
index 7119b0f7958be10c507b322524388ae265ca3620..b306cc1225411b055a2a93c8e38d55e843a6fedd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -37,19 +37,14 @@ public class SettingsActivity extends AppCompatActivity {
 
         // Get the screenshot and theme preferences.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
 
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // Set the activity theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserSettingsDark);
-        } else {
-            setTheme(R.style.PrivacyBrowserSettingsLight);
-        }
+        // Set the theme.
+        setTheme(R.style.PrivacyBrowserSettings);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
index a0f51d14b7a2853f31fd5df68ab08d151f42079b..51036fbc38bc82cf46b6d87fd97c070b275a6d90 100644 (file)
@@ -23,10 +23,12 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.text.Spanned;
 import android.text.style.ForegroundColorSpan;
+import android.util.TypedValue;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -61,9 +63,8 @@ public class ViewSourceActivity extends AppCompatActivity {
         // Get a handle for the shared preferences.
         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
 
-        // Get the screenshot and theme preferences.
+        // Get the screenshot preference.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
 
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
@@ -71,11 +72,7 @@ public class ViewSourceActivity extends AppCompatActivity {
         }
 
         // Set the theme.
-        if (darkTheme) {
-            setTheme(R.style.PrivacyBrowserDark);
-        } else {
-            setTheme(R.style.PrivacyBrowserLight);
-        }
+        setTheme(R.style.PrivacyBrowser);
 
         // Run the default commands.
         super.onCreate(savedInstanceState);
@@ -189,14 +186,28 @@ public class ViewSourceActivity extends AppCompatActivity {
             }
         });
 
-        // Set the swipe to refresh color according to the theme.
-        if (darkTheme) {
-            swipeRefreshLayout.setColorSchemeResources(R.color.blue_600);
-            swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.gray_800);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+        // Set the refresh color scheme according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            swipeRefreshLayout.setColorSchemeResources(R.color.blue_500);
         } else {
             swipeRefreshLayout.setColorSchemeResources(R.color.blue_700);
         }
 
+        // Initialize a color background typed value.
+        TypedValue colorBackgroundTypedValue = new TypedValue();
+
+        // Get the color background from the theme.
+        getTheme().resolveAttribute(android.R.attr.colorBackground, colorBackgroundTypedValue, true);
+
+        // Get the color background int from the typed value.
+        int colorBackgroundInt = colorBackgroundTypedValue.data;
+
+        // Set the swipe refresh background color.
+        swipeRefreshLayout.setProgressBackgroundColorSchemeColor(colorBackgroundInt);
+
         // Get the source using an AsyncTask if the URL begins with `http`.
         if ((currentUrl != null) && currentUrl.startsWith("http")) {
             new GetSource(this, this, userAgent).execute(currentUrl);
index edc64f810678699d612d953d91e31ecb689444af..fcccba4861caf0f0388f084a466ffbdf25015ed0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2018-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2018-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -20,8 +20,7 @@
 package com.stoutner.privacybrowser.adapters;
 
 import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
+import android.content.res.Configuration;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -45,12 +44,6 @@ public class RequestsArrayAdapter extends ArrayAdapter<String[]> {
     @Override
     @NonNull
     public View getView(int position, View view, @NonNull ViewGroup parent) {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Get a handle for the context.
         Context context = getContext();
 
@@ -73,6 +66,9 @@ public class RequestsArrayAdapter extends ArrayAdapter<String[]> {
         // The ID is one greater than the position because it is 0 based.
         int id = position + 1;
 
+        // Get the current theme status.
+        int currentThemeStatus = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
         // Set the action text and the background color.
         switch (entryStringArray[0]) {
             case BlocklistHelper.REQUEST_DEFAULT:
@@ -94,7 +90,7 @@ public class RequestsArrayAdapter extends ArrayAdapter<String[]> {
                 dispositionTextView.setText(requestAllowed);
 
                 // Set the background color.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     linearLayout.setBackgroundColor(context.getResources().getColor(R.color.blue_700_50));
                 } else {
                     linearLayout.setBackgroundColor(context.getResources().getColor(R.color.blue_100));
@@ -109,7 +105,7 @@ public class RequestsArrayAdapter extends ArrayAdapter<String[]> {
                 dispositionTextView.setText(requestThirdParty);
 
                 // Set the background color.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     linearLayout.setBackgroundColor(context.getResources().getColor(R.color.yellow_700_50));
                 } else {
                     linearLayout.setBackgroundColor(context.getResources().getColor(R.color.yellow_100));
@@ -125,7 +121,7 @@ public class RequestsArrayAdapter extends ArrayAdapter<String[]> {
                 dispositionTextView.setText(requestBlocked);
 
                 // Set the background color.
-                if (darkTheme) {
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     linearLayout.setBackgroundColor(context.getResources().getColor(R.color.red_700_40));
                 } else {
                     linearLayout.setBackgroundColor(context.getResources().getColor(R.color.red_100));
@@ -137,7 +133,7 @@ public class RequestsArrayAdapter extends ArrayAdapter<String[]> {
         urlTextView.setText(entryStringArray[1]);
 
         // Set the text color.  For some unexplained reason, `android:textColor="?android:textColorPrimary"` doesn't work in the layout file.  Probably some bug relating to array adapters.
-        if (darkTheme) {
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
             dispositionTextView.setTextColor(context.getResources().getColor(R.color.gray_200));
             urlTextView.setTextColor(context.getResources().getColor(R.color.gray_200));
         } else {
index 5f0020d0403c9e994e68e448586385207d3465c6..46c3a039f4ad4a578e43fb94a7509f4c819426d6 100644 (file)
 
 package com.stoutner.privacybrowser.asynctasks;
 
-import android.app.AlertDialog;
 import android.content.Context;
 import android.os.AsyncTask;
 import android.webkit.CookieManager;
 import android.widget.TextView;
 
+import androidx.appcompat.app.AlertDialog;
+
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.helpers.ProxyHelper;
 
@@ -164,6 +165,9 @@ public class GetUrlSize extends AsyncTask<String, Void, String> {
         // Get a handle for the file size text view.
         TextView fileSizeTextView = alertDialog.findViewById(R.id.file_size_textview);
 
+        // Remove the incorrect warning below that the file size text view might be null.
+        assert fileSizeTextView != null;
+
         // Update the file size.
         fileSizeTextView.setText(fileSize);
     }
index 30bcf8d0e1d0212d24b1d27db16c948d6fabd520..70247f052bf5e333e34e536da370010472345d9c 100644 (file)
 
 package com.stoutner.privacybrowser.dialogs
 
-import android.app.AlertDialog
 import android.app.Dialog
+import android.content.res.Configuration
 import android.os.Bundle
 import android.view.WindowManager
 
+import androidx.appcompat.app.AlertDialog
 import androidx.fragment.app.DialogFragment
 import androidx.preference.PreferenceManager
 
@@ -31,29 +32,19 @@ import com.stoutner.privacybrowser.R
 
 class AboutViewSourceDialog: DialogFragment() {
     override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
-        // Get a handle for the shared preferences.
-        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
-        // Get the screenshot and theme preferences.
-        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
-        val darkTheme = sharedPreferences.getBoolean("dark_theme", false)
-
         // Use a builder to create the alert dialog.
-        val dialogBuilder: AlertDialog.Builder
+        val dialogBuilder: AlertDialog.Builder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
 
-        // Set the style and the icon according to the theme.
-        if (darkTheme) {
-            // Use a dark style.
-            dialogBuilder = AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogDark)
+        // Get the current theme status.
+        val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
 
+        // Set the style and the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
             // Set a dark icon.
-            dialogBuilder.setIcon(R.drawable.about_dark)
+            dialogBuilder.setIcon(R.drawable.about_night)
         } else {
-            // Use a light style.
-            dialogBuilder = AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogLight)
-
             // Set a light icon.
-            dialogBuilder.setIcon(R.drawable.about_light)
+            dialogBuilder.setIcon(R.drawable.about_day)
         }
 
         // Set the title.
@@ -68,6 +59,12 @@ class AboutViewSourceDialog: DialogFragment() {
         // Create an alert dialog from the alert dialog builder.
         val alertDialog = dialogBuilder.create()
 
+        // Get a handle for the shared preferences.
+        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+        // Get the screenshot preference.
+        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
index 8b56f2d479eb78fec3e89435943478112013aebb..527e0d7d031996f66b9e3a5a7de439158f462368 100644 (file)
 package com.stoutner.privacybrowser.dialogs
 
 import android.annotation.SuppressLint
-import android.app.AlertDialog
 import android.app.Dialog
 import android.content.Context
 import android.content.DialogInterface
+import android.content.res.Configuration
 import android.net.Uri
 import android.os.Bundle
 import android.text.Editable
@@ -34,6 +34,7 @@ import android.view.WindowManager
 import android.widget.EditText
 import android.widget.TextView
 
+import androidx.appcompat.app.AlertDialog
 import androidx.fragment.app.DialogFragment
 import androidx.preference.PreferenceManager
 
@@ -87,27 +88,17 @@ class AddDomainDialog: DialogFragment() {
         // Get the URL from the bundle.
         val urlString = arguments.getString("url_string")
 
-        // Get a handle for the shared preferences.
-        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
-        // Get the screenshot and theme preferences.
-        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
-        val darkTheme = sharedPreferences.getBoolean("dark_theme", false)
-
         // Use an alert dialog builder to create the alert dialog.
-        val dialogBuilder: AlertDialog.Builder
+        val dialogBuilder: AlertDialog.Builder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
 
-        // USet the style and the icon according to the theme.
-        if (darkTheme) {
-            // Set the dark style.
-            dialogBuilder = AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogDark)
+        // Get the current theme status.
+        val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
 
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
             // Set the dark icon.
-            dialogBuilder.setIcon(R.drawable.domains_dark)
+            dialogBuilder.setIcon(R.drawable.domains_night)
         } else {
-            // Set the light style.
-            dialogBuilder = AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogLight)
-
             // Set the light icon.
             dialogBuilder.setIcon(R.drawable.domains_light)
         }
@@ -130,6 +121,12 @@ class AddDomainDialog: DialogFragment() {
         // Create an alert dialog from the builder.
         val alertDialog = dialogBuilder.create()
 
+        // Get a handle for the shared preferences.
+        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+        // Get the screenshot preference.
+        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
@@ -142,8 +139,8 @@ class AddDomainDialog: DialogFragment() {
         val domainsDatabaseHelper = DomainsDatabaseHelper(context, null, null, 0)
 
         // Get handles for the views in the alert dialog.
-        val addDomainEditText = alertDialog.findViewById<EditText>(R.id.domain_name_edittext)
-        val domainNameAlreadyExistsTextView = alertDialog.findViewById<TextView>(R.id.domain_name_already_exists_textview)
+        val addDomainEditText = alertDialog.findViewById<EditText>(R.id.domain_name_edittext)!!
+        val domainNameAlreadyExistsTextView = alertDialog.findViewById<TextView>(R.id.domain_name_already_exists_textview)!!
         val addButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
 
         //  Update the status of the warning text and the add button when the domain name changes.
index 0b1dea00386ccc572f98b4071e26205a55616750..a10e574a5a003ff012849fb6a1ce5e77373e0929 100644 (file)
@@ -20,7 +20,6 @@
 package com.stoutner.privacybrowser.dialogs
 
 import android.annotation.SuppressLint
-import android.app.AlertDialog
 import android.app.Dialog
 import android.content.Context
 import android.content.DialogInterface
@@ -34,6 +33,7 @@ import android.view.View
 import android.view.WindowManager
 import android.widget.EditText
 
+import androidx.appcompat.app.AlertDialog
 import androidx.fragment.app.DialogFragment
 import androidx.preference.PreferenceManager
 
@@ -104,19 +104,8 @@ class CreateBookmarkDialog: DialogFragment() {
         // Convert the favorite icon byte array to a bitmap.
         val favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.size)
 
-        // Get a handle for the shared preferences.
-        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
-        // Get the screenshot and theme preferences.
-        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
-        val darkTheme = sharedPreferences.getBoolean("dark_theme", false)
-
-        // Use an alert dialog builder to create the dialog and set the style according to the theme.
-        val dialogBuilder = if (darkTheme) {
-            AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogDark)
-        } else {
-            AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogLight)
-        }
+        // Use an alert dialog builder to create the dialog.
+        val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
 
         // Set the title.
         dialogBuilder.setTitle(R.string.create_bookmark)
@@ -142,6 +131,13 @@ class CreateBookmarkDialog: DialogFragment() {
         // Create an alert dialog from the builder.
         val alertDialog = dialogBuilder.create()
 
+
+        // Get a handle for the shared preferences.
+        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+        // Get the screenshot preference.
+        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
@@ -151,8 +147,8 @@ class CreateBookmarkDialog: DialogFragment() {
         alertDialog.show()
 
         // Get a handle for the edit texts.
-        val createBookmarkNameEditText = alertDialog.findViewById<EditText>(R.id.create_bookmark_name_edittext)
-        val createBookmarkUrlEditText = alertDialog.findViewById<EditText>(R.id.create_bookmark_url_edittext)
+        val createBookmarkNameEditText = alertDialog.findViewById<EditText>(R.id.create_bookmark_name_edittext)!!
+        val createBookmarkUrlEditText = alertDialog.findViewById<EditText>(R.id.create_bookmark_url_edittext)!!
 
         // Set the initial texts for the edit texts.
         createBookmarkNameEditText.setText(titleString)
index d4f12193d153346f13bc4022f9fdf3d9363d8e3d..83670bc8923b66b1ddb5fc0f8244b6efc042287f 100644 (file)
@@ -19,7 +19,6 @@
 package com.stoutner.privacybrowser.dialogs
 
 import android.annotation.SuppressLint
-import android.app.AlertDialog
 import android.app.Dialog
 import android.content.Context
 import android.content.DialogInterface
@@ -33,6 +32,7 @@ import android.view.View
 import android.view.WindowManager
 import android.widget.EditText
 import android.widget.ImageView
+import androidx.appcompat.app.AlertDialog
 
 import androidx.fragment.app.DialogFragment
 import androidx.preference.PreferenceManager
@@ -101,19 +101,8 @@ class CreateBookmarkFolderDialog: DialogFragment() {
         // Convert the favorite icon byte array to a bitmap.
         val favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.size)
 
-        // Get a handle for the shared preferences.
-        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
-        // Get the screenshot and theme preferences.
-        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
-        val darkTheme = sharedPreferences.getBoolean("dark_theme", false)
-
-        // Use an alert dialog builder to create the dialog and set the style according to the theme.
-        val dialogBuilder = if (darkTheme) {
-            AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogDark)
-        } else {
-            AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogLight)
-        }
+        // Use an alert dialog builder to create the dialog.
+        val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
 
         // Set the title.
         dialogBuilder.setTitle(R.string.create_folder)
@@ -133,6 +122,12 @@ class CreateBookmarkFolderDialog: DialogFragment() {
         // Create an alert dialog from the builder.
         val alertDialog = dialogBuilder.create()
 
+        // Get a handle for the shared preferences.
+        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+        // Get the screenshot preference.
+        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
@@ -145,8 +140,8 @@ class CreateBookmarkFolderDialog: DialogFragment() {
         alertDialog.show()
 
         // Get handles for the views in the dialog.
-        val webPageIconImageView = alertDialog.findViewById<ImageView>(R.id.create_folder_web_page_icon)
-        val folderNameEditText = alertDialog.findViewById<EditText>(R.id.create_folder_name_edittext)
+        val webPageIconImageView = alertDialog.findViewById<ImageView>(R.id.create_folder_web_page_icon)!!
+        val folderNameEditText = alertDialog.findViewById<EditText>(R.id.create_folder_name_edittext)!!
         val createButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
 
         // Display the current favorite icon.
index ddcc72ccd575f37381cfddf9c881c7d8ddaca76a..69be19d27344fe231a9c3944e75c7423b6ce353c 100644 (file)
@@ -104,19 +104,8 @@ class CreateHomeScreenShortcutDialog: DialogFragment() {
         // Convert the favorite icon byte array to a bitmap.
         val favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.size)
 
-        // Get a handle for the shared preferences.
-        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
-        // Get the theme and screenshot preferences.
-        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
-        val darkTheme = sharedPreferences.getBoolean("dark_theme", false)
-
-        // Use an alert dialog builder to create the dialog and set the style according to the theme.
-        val dialogBuilder = if (darkTheme) {
-            AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialogDark)
-        } else {
-            AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialogLight)
-        }
+        // Use an alert dialog builder to create the dialog.
+        val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
 
         // Create a drawable version of the favorite icon.
         val favoriteIconDrawable: Drawable = BitmapDrawable(resources, favoriteIconBitmap)
@@ -140,6 +129,12 @@ class CreateHomeScreenShortcutDialog: DialogFragment() {
         // Create an alert dialog from the alert dialog builder.
         val alertDialog = dialogBuilder.create()
 
+        // Get a handle for the shared preferences.
+        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+        // Get the screenshot preference.
+        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
index 57f764be844710cfcf724a9500c808864e51d469..4de3543173402cdd18c9d8fef528c161a9c3a610 100644 (file)
@@ -19,7 +19,6 @@
 package com.stoutner.privacybrowser.dialogs
 
 import android.annotation.SuppressLint
-import android.app.AlertDialog
 import android.app.Dialog
 import android.content.Context
 import android.content.DialogInterface
@@ -37,6 +36,7 @@ import android.view.WindowManager
 import android.widget.*
 import android.widget.AdapterView.OnItemSelectedListener
 
+import androidx.appcompat.app.AlertDialog
 import androidx.core.content.ContextCompat
 import androidx.fragment.app.DialogFragment
 import androidx.preference.PreferenceManager
@@ -127,19 +127,8 @@ class EditBookmarkDatabaseViewDialog: DialogFragment() {
         // Move the cursor to the first position.
         bookmarkCursor.moveToFirst()
 
-        // Get a handle for the shared preferences.
-        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
-        // Get the screenshot and theme preferences.
-        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
-        val darkTheme = sharedPreferences.getBoolean("dark_theme", false)
-
         // Use an alert dialog builder to create the dialog and set the style according to the theme.
-        val dialogBuilder = if (darkTheme) {
-            AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogDark)
-        } else {
-            AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialogLight)
-        }
+        val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
 
         // Set the title.
         dialogBuilder.setTitle(R.string.edit_bookmark)
@@ -159,6 +148,12 @@ class EditBookmarkDatabaseViewDialog: DialogFragment() {
         // Create an alert dialog from the alert dialog builder.
         val alertDialog = dialogBuilder.create()
 
+        // Get a handle for the shared preferences.
+        val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+        // Get the screenshot preference.
+        val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false)
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
@@ -168,15 +163,15 @@ class EditBookmarkDatabaseViewDialog: DialogFragment() {
         alertDialog.show()
 
         // Get handles for the layout items.
-        val databaseIdTextView = alertDialog.findViewById<TextView>(R.id.edit_bookmark_database_id_textview)
-        val iconRadioGroup = alertDialog.findViewById<RadioGroup>(R.id.edit_bookmark_icon_radiogroup)
-        val currentIconImageView = alertDialog.findViewById<ImageView>(R.id.edit_bookmark_current_icon)
-        val newFavoriteIconImageView = alertDialog.findViewById<ImageView>(R.id.edit_bookmark_webpage_favorite_icon)
-        newIconRadioButton = alertDialog.findViewById(R.id.edit_bookmark_webpage_favorite_icon_radiobutton)
-        nameEditText = alertDialog.findViewById(R.id.edit_bookmark_name_edittext)
-        urlEditText = alertDialog.findViewById(R.id.edit_bookmark_url_edittext)
-        folderSpinner = alertDialog.findViewById(R.id.edit_bookmark_folder_spinner)
-        displayOrderEditText = alertDialog.findViewById(R.id.edit_bookmark_display_order_edittext)
+        val databaseIdTextView = alertDialog.findViewById<TextView>(R.id.edit_bookmark_database_id_textview)!!
+        val iconRadioGroup = alertDialog.findViewById<RadioGroup>(R.id.edit_bookmark_icon_radiogroup)!!
+        val currentIconImageView = alertDialog.findViewById<ImageView>(R.id.edit_bookmark_current_icon)!!
+        val newFavoriteIconImageView = alertDialog.findViewById<ImageView>(R.id.edit_bookmark_webpage_favorite_icon)!!
+        newIconRadioButton = alertDialog.findViewById(R.id.edit_bookmark_webpage_favorite_icon_radiobutton)!!
+        nameEditText = alertDialog.findViewById(R.id.edit_bookmark_name_edittext)!!
+        urlEditText = alertDialog.findViewById(R.id.edit_bookmark_url_edittext)!!
+        folderSpinner = alertDialog.findViewById(R.id.edit_bookmark_folder_spinner)!!
+        displayOrderEditText = alertDialog.findViewById(R.id.edit_bookmark_display_order_edittext)!!
         editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
 
         // Store the current bookmark values.
index adf6d44e39946801f741f205436f889efd1b49f5..df4a1a14e2e175fceeeaf6f9690bb1711692824c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -20,7 +20,6 @@
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -42,7 +41,8 @@ import android.widget.RadioButton;
 import android.widget.RadioGroup;
 
 import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <=22.
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper;
@@ -125,21 +125,7 @@ public class EditBookmarkDialog extends DialogFragment {
         bookmarkCursor.moveToFirst();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
-        } else {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-        }
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
 
         // Set the title.
         dialogBuilder.setTitle(R.string.edit_bookmark);
@@ -167,6 +153,12 @@ public class EditBookmarkDialog extends DialogFragment {
         // remove the incorrect lint warning below that `getWindow().addFlags()` might be null.
         assert alertDialog.getWindow() != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -183,6 +175,13 @@ public class EditBookmarkDialog extends DialogFragment {
         EditText urlEditText = alertDialog.findViewById(R.id.edit_bookmark_url_edittext);
         Button editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert iconRadioGroup != null;
+        assert currentIconImageView != null;
+        assert newFavoriteIconImageView != null;
+        assert nameEditText != null;
+        assert urlEditText != null;
+
         // Get the current favorite icon byte array from the cursor.
         byte[] currentIconByteArray = bookmarkCursor.getBlob(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.FAVORITE_ICON));
 
@@ -295,6 +294,11 @@ public class EditBookmarkDialog extends DialogFragment {
         RadioButton newIconRadioButton = alertdialog.findViewById(R.id.edit_bookmark_webpage_favorite_icon_radiobutton);
         Button editButton = alertdialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert nameEditText != null;
+        assert urlEditText != null;
+        assert newIconRadioButton != null;
+
         // Get the text from the edit texts.
         String newName = nameEditText.getText().toString();
         String newUrl = urlEditText.getText().toString();
index 0f7eff1a7ee12ba00e092b6a525f1c5123cb7e74..7960c68a73620f1e56e811ab268777833572d999 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -20,7 +20,6 @@
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -50,6 +49,7 @@ import android.widget.Spinner;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
 import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <=22.
 
@@ -136,21 +136,7 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment {
         folderCursor.moveToFirst();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
-        } else {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-        }
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
 
         // Set the title.
         dialogBuilder.setTitle(R.string.edit_folder);
@@ -178,6 +164,12 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment {
         // Remove the warning below that `getWindow()` might be null.
         assert alertDialog.getWindow() != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -196,6 +188,15 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment {
         EditText displayOrderEditText = alertDialog.findViewById(R.id.edit_folder_display_order_edittext);
         Button editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert databaseIdTextView != null;
+        assert iconRadioGroup != null;
+        assert currentIconImageView != null;
+        assert newFavoriteIconImageView != null;
+        assert nameEditText != null;
+        assert folderSpinner != null;
+        assert displayOrderEditText != null;
+
         // Store the current folder values.
         String currentFolderName = folderCursor.getString(folderCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME));
         int currentDisplayOrder = folderCursor.getInt(folderCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER));
@@ -410,6 +411,12 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment {
         RadioButton currentIconRadioButton = alertDialog.findViewById(R.id.edit_folder_current_icon_radiobutton);
         Button editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warning below that the views might be null.
+        assert nameEditText != null;
+        assert folderSpinner != null;
+        assert displayOrderEditText != null;
+        assert currentIconRadioButton != null;
+
         // Get the values from the dialog.
         String newFolderName = nameEditText.getText().toString();
         int newParentFolderDatabaseId = (int) folderSpinner.getSelectedItemId();
index 230abd3491614d4e6395d60615370f5eb28bfb51..216f0d3833d256a00442086e09e10aab2c1224a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -20,7 +20,6 @@
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -42,6 +41,7 @@ import android.widget.RadioButton;
 import android.widget.RadioGroup;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <=22.
 
 import com.stoutner.privacybrowser.R;
@@ -125,21 +125,7 @@ public class EditBookmarkFolderDialog extends DialogFragment {
         folderCursor.moveToFirst();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
-        } else {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-        }
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
 
         // Set the title.
         dialogBuilder.setTitle(R.string.edit_folder);
@@ -167,6 +153,12 @@ public class EditBookmarkFolderDialog extends DialogFragment {
         // Remove the warning below that `getWindow()` might be null.
         assert alertDialog.getWindow() != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -183,6 +175,13 @@ public class EditBookmarkFolderDialog extends DialogFragment {
         EditText folderNameEditText = alertDialog.findViewById(R.id.edit_folder_name_edittext);
         Button editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert iconRadioGroup != null;
+        assert currentIconRadioButton != null;
+        assert currentIconImageView != null;
+        assert webPageFavoriteIconImageView != null;
+        assert folderNameEditText != null;
+
         // Initially disable the edit button.
         editButton.setEnabled(false);
 
index 2349189c2909118d120fedb484c28990d524a8fd..7a0e07ebf91647af0a27e1f8e68ccb096a36451c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -21,11 +21,11 @@ package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.View;
@@ -34,6 +34,7 @@ import android.view.WindowManager;
 import android.widget.EditText;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.fragment.app.DialogFragment;
 import androidx.preference.PreferenceManager;
 
@@ -87,9 +88,6 @@ public class FontSizeDialog extends DialogFragment {
         assert activity != null;
         assert context != null;
 
-        // Use a builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
         // Get the arguments.
         Bundle arguments = getArguments();
 
@@ -99,20 +97,17 @@ public class FontSizeDialog extends DialogFragment {
         // Get the current font size.
         int currentFontSize = arguments.getInt("font_size");
 
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+        // Use a builder to create the alert dialog.
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
 
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-        // Set the style and icon according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogDark);
-            dialogBuilder.setIcon(R.drawable.font_size_dark);
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.font_size_night);
         } else {
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogLight);
-            dialogBuilder.setIcon(R.drawable.font_size_light);
+            dialogBuilder.setIcon(R.drawable.font_size_day);
         }
 
         // Set the title.
@@ -139,6 +134,12 @@ public class FontSizeDialog extends DialogFragment {
         // Remove the incorrect lint warning below that the dialog window might be null.
         assert dialogWindow != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+        // Get the screenshot preferences.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             dialogWindow.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -153,6 +154,9 @@ public class FontSizeDialog extends DialogFragment {
         // Get a handle for the font size edit text.
         EditText fontSizeEditText = alertDialog.findViewById(R.id.font_size_edittext);
 
+        // Remove the incorrect lint warning below that the edit text might be null.
+        assert fontSizeEditText != null;
+
         // Display the current font size.
         fontSizeEditText.setText(String.valueOf(currentFontSize));
 
index 4b68108987b22d62484d5ac0627c882c4832869a..20e04a4b5d41b5f288d3ed37ed5642e23dbe5bad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2017-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.text.SpannableStringBuilder;
@@ -39,7 +39,8 @@ import android.widget.EditText;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <=22.
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.activities.MainWebViewActivity;
@@ -111,28 +112,16 @@ public class HttpAuthenticationDialog extends DialogFragment{
         LayoutInflater layoutInflater = getActivity().getLayoutInflater();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialog);
 
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            // Set the dialog theme.
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.lock_dark);
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.lock_night);
         } else {
-            // Set the dialog theme.
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.lock_light);
+            dialogBuilder.setIcon(R.drawable.lock_day);
         }
 
         // Set the title.
@@ -168,6 +157,12 @@ public class HttpAuthenticationDialog extends DialogFragment{
         // Remove the incorrect lint warning below that the dialog window might be null.
         assert dialogWindow != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -185,11 +180,15 @@ public class HttpAuthenticationDialog extends DialogFragment{
         usernameEditText = alertDialog.findViewById(R.id.http_authentication_username);
         passwordEditText = alertDialog.findViewById(R.id.http_authentication_password);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert realmTextView != null;
+        assert hostTextView != null;
+
         // Set the realm text.
         realmTextView.setText(httpAuthRealm);
 
-        // Set the realm text color according to the theme.  The deprecated `.getColor()` must be used until API >= 23.
-        if (darkTheme) {
+        // Set the realm text color according to the theme.  The deprecated `getResources()` must be used until API >= 23.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
             realmTextView.setTextColor(getResources().getColor(R.color.gray_300));
         } else {
             realmTextView.setTextColor(getResources().getColor(R.color.black));
@@ -202,8 +201,8 @@ public class HttpAuthenticationDialog extends DialogFragment{
         // Create a blue `ForegroundColorSpan`.
         ForegroundColorSpan blueColorSpan;
 
-        // Set `blueColorSpan` according to the theme.  The deprecated `getColor()` must be used until API >= 23.
-        if (darkTheme) {
+        // Set `blueColorSpan` according to the theme.  The deprecated `getResources()` must be used until API >= 23.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
             blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400));
         } else {
             blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
index cf944c04a8ce381f85542f17e6186c1576fb2974..2406e95af31d69582f8fe7606cbe1d9e543c88f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -20,7 +20,6 @@
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -46,8 +45,9 @@ import android.widget.ListView;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
-import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <= 22.
+import androidx.fragment.app.DialogFragment;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.activities.BookmarksActivity;
@@ -83,21 +83,7 @@ public class MoveToFolderDialog extends DialogFragment {
         bookmarksDatabaseHelper = new BookmarksDatabaseHelper(getContext(), null, null, 0);
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
-        } else {
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-        }
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
 
         // Set the title.
         dialogBuilder.setTitle(R.string.move_to_folder);
@@ -122,6 +108,12 @@ public class MoveToFolderDialog extends DialogFragment {
         // Create an alert dialog from the alert dialog builder.
         final AlertDialog alertDialog = dialogBuilder.create();
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             // Remove the warning below that `getWindow()` might be null.
@@ -278,8 +270,13 @@ public class MoveToFolderDialog extends DialogFragment {
             };
         }
 
-        // Display the ListView
+        // Get a handle for the folders list view.
         ListView foldersListView = alertDialog.findViewById(R.id.move_to_folder_listview);
+
+        // Remove the incorrect lint warning below that the view might be null.
+        assert foldersListView != null;
+
+        // Set the folder list view adapter.
         foldersListView.setAdapter(foldersCursorAdapter);
 
         // Enable the move button when a folder is selected.
index 59aa177ba945c1fa58288357987a22c69570bfa9..43594860a3d16508e4f0fe2b98035b44c3de8c74 100644 (file)
@@ -22,13 +22,13 @@ package com.stoutner.privacybrowser.dialogs;
 import android.Manifest;
 import android.annotation.SuppressLint;
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.content.res.Configuration;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
@@ -42,6 +42,7 @@ import android.widget.EditText;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
 import androidx.fragment.app.DialogFragment;
 import androidx.preference.PreferenceManager;
@@ -76,36 +77,20 @@ public class OpenDialog extends DialogFragment {
     @NonNull
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         // Get a handle for the activity and the context.
-        Activity activity = getActivity();
-        Context context = getContext();
-
-        // Remove the incorrect lint warnings below that the activity and the context might be null.
-        assert activity != null;
-        assert context != null;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+        Activity activity = requireActivity();
+        Context context = requireContext();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
 
-        // Set the style and icon according to the theme.
-        if (darkTheme) {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogDark);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.proxy_enabled_dark);
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.proxy_enabled_night);
         } else {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogLight);
-
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.proxy_enabled_light);
+            dialogBuilder.setIcon(R.drawable.proxy_enabled_day);
         }
 
         // Set the title.
@@ -129,6 +114,12 @@ public class OpenDialog extends DialogFragment {
         // Remove the incorrect lint warning below that the window might be null.
         assert alertDialog.getWindow() != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -144,6 +135,12 @@ public class OpenDialog extends DialogFragment {
         TextView storagePermissionTextView = alertDialog.findViewById(R.id.storage_permission_textview);
         Button openButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert fileNameEditText != null;
+        assert browseButton != null;
+        assert fileDoesNotExistTextView != null;
+        assert storagePermissionTextView != null;
+
         // Update the status of the open button when the file name changes.
         fileNameEditText.addTextChangedListener(new TextWatcher() {
             @Override
index 675f1e8a95712ca8029d02ec356b71545ac105f7..0ab49b4ce315dd444f8bdca45584348782ab5765 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2017-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
@@ -54,6 +54,7 @@ import java.util.ArrayList;
 import java.util.Date;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
 import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <=22.
 import androidx.viewpager.widget.PagerAdapter;
@@ -129,23 +130,7 @@ public class PinnedMismatchDialog extends DialogFragment {
         nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview);
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            // Set the dialog theme.
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
-        } else {
-            // Set the dialog theme.
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-        }
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
 
         // Get the context.
         Context context = getContext();
@@ -170,11 +155,14 @@ public class PinnedMismatchDialog extends DialogFragment {
 
         // Set the favorite icon as the dialog icon if it exists.
         if (favoriteIconBitmap.sameAs(defaultFavoriteIconBitmap)) {  // There is no website favorite icon.
+            // Get the current theme status.
+            int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
             // Set the icon according to the theme.
-            if (darkTheme) {
-                dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_dark);
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+                dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_night);
             } else {
-                dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_light);
+                dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_day);
             }
         } else {  // There is a favorite icon.
             // Create a drawable version of the favorite icon.
@@ -253,6 +241,12 @@ public class PinnedMismatchDialog extends DialogFragment {
         // Create an alert dialog from the alert dialog builder.
         final AlertDialog alertDialog = dialogBuilder.create();
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             // Remove the warning below that `getWindow()` might be null.
@@ -265,15 +259,21 @@ public class PinnedMismatchDialog extends DialogFragment {
         // Show the alert dialog so the items in the layout can be modified.
         alertDialog.show();
 
-        //  Setup the view pager.
+        //  Get a handle for the views.
         WrapVerticalContentViewPager wrapVerticalContentViewPager = alertDialog.findViewById(R.id.pinned_ssl_certificate_mismatch_viewpager);
+        TabLayout tabLayout = alertDialog.findViewById(R.id.pinned_ssl_certificate_mismatch_tablayout);
+
+        // Remove the incorrect lint warning below that the views might be null.
+        assert wrapVerticalContentViewPager != null;
+        assert tabLayout != null;
+
+        // Set the view pager adapter.
         wrapVerticalContentViewPager.setAdapter(new pagerAdapter());
 
-        // Setup the tab layout and connect it to the view pager.
-        TabLayout tabLayout = alertDialog.findViewById(R.id.pinned_ssl_certificate_mismatch_tablayout);
+        // Connect the tab layout to the view pager.
         tabLayout.setupWithViewPager(wrapVerticalContentViewPager);
 
-        // `onCreateDialog()` requires the return of an `AlertDialog`.
+        // Return the alert dialog.
         return alertDialog;
     }
 
@@ -424,23 +424,20 @@ public class PinnedMismatchDialog extends DialogFragment {
                 }
             }
 
-            // Get a handle for the shared preferences.
-            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-            // Get the screenshot and theme preferences.
-            boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
-            // Create a red foreground color span.  The deprecated `getResources().getColor` must be used until the minimum API >= 23.
-            ForegroundColorSpan redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700));
-
-            // Create a blue foreground color span.
+            // Define the color spans.
             ForegroundColorSpan blueColorSpan;
+            ForegroundColorSpan redColorSpan;
+
+            // Get the current theme status.
+            int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-            // Set the blue color span according to the theme.  The deprecated `getResources().getColor` must be used until the minimum API >= 23.
-            if (darkTheme) {
+            // Set the color spans according to the theme.  The deprecated `getResources()` must be used until the minimum API >= 23.
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400));
+                redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_900));
             } else {
                 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
+                redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700));
             }
 
             // Set the domain name to be blue.
index fa17c43909797d750070acd0dcdb317c0e633b4d..9b70e0d27338946916473f803f6195e0df25f723 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
 
 package com.stoutner.privacybrowser.dialogs;
 
-import android.app.Activity;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.view.WindowManager;
 
@@ -57,13 +57,8 @@ public class ProxyNotInstalledDialog extends DialogFragment {
     @Override
     @NonNull
     public Dialog onCreateDialog(Bundle savedInstanceState) {
-        // Get the context and the activity.
-        Context context = getContext();
-        Activity activity = getActivity();
-
-        // Remove the incorrect lint warnings below that the context or the activity might be null.
-        assert context != null;
-        assert activity != null;
+        // Get the context.
+        Context context = requireContext();
 
         // Get the arguments.
         Bundle arguments = getArguments();
@@ -74,32 +69,20 @@ public class ProxyNotInstalledDialog extends DialogFragment {
         // Get the proxy mode from the arguments.
         String proxyMode = arguments.getString("proxy_mode");
 
-        // Remove the incorrect lint warning below tha tth eproxy mode migth be null.
+        // Remove the incorrect lint warning below that the proxy mode might be null.
         assert proxyMode != null;
 
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
-
-        // Get the screenshot and the theme preferences.
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-
         // Use a builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
 
-        // Set the style and the icon according to the theme.
-        if (darkTheme) {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogDark);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.proxy_enabled_dark);
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.proxy_enabled_night);
         } else {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogLight);
-
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.proxy_enabled_light);
+            dialogBuilder.setIcon(R.drawable.proxy_enabled_day);
         }
 
         // Set the title and the message according to the proxy mode.
@@ -129,6 +112,12 @@ public class ProxyNotInstalledDialog extends DialogFragment {
         // Create an alert dialog from the alert dialog builder.
         AlertDialog alertDialog = dialogBuilder.create();
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             // Remove the warning below that `getWindows()` might be null.
index 71eecb15350248199faadaf6daab3ab3222f6654..0730717cabbec14a2933ec5e1fac55cf3570215b 100644 (file)
@@ -22,13 +22,13 @@ package com.stoutner.privacybrowser.dialogs;
 import android.Manifest;
 import android.annotation.SuppressLint;
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.content.res.Configuration;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
@@ -43,6 +43,7 @@ import android.widget.EditText;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
 import androidx.fragment.app.DialogFragment;
 import androidx.preference.PreferenceManager;
@@ -117,58 +118,44 @@ public class SaveDialog extends DialogFragment {
         boolean cookiesEnabled = arguments.getBoolean("cookies_enabled");
 
         // Get a handle for the activity and the context.
-        Activity activity = getActivity();
-        Context context = getContext();
-
-        // Remove the incorrect lint warnings below that the activity and context might be null.
-        assert activity != null;
-        assert context != null;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+        Activity activity = requireActivity();
+        Context context = requireContext();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
 
-        // Set the style and icon according to the theme.
-        if (darkTheme) {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogDark);
+        // 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_YES) {  // The night theme is enabled.
             // Set the icon according to the save type.
             switch (saveType) {
                 case StoragePermissionDialog.SAVE_URL:
-                    dialogBuilder.setIcon(R.drawable.copy_enabled_dark);
+                    dialogBuilder.setIcon(R.drawable.copy_enabled_night);
                     break;
 
                 case StoragePermissionDialog.SAVE_AS_ARCHIVE:
-                    dialogBuilder.setIcon(R.drawable.dom_storage_cleared_dark);
+                    dialogBuilder.setIcon(R.drawable.dom_storage_cleared_night);
                     break;
 
                 case StoragePermissionDialog.SAVE_AS_IMAGE:
-                    dialogBuilder.setIcon(R.drawable.images_enabled_dark);
+                    dialogBuilder.setIcon(R.drawable.images_enabled_night);
                     break;
             }
-        } else {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogLight);
-
+        } else {  // The day theme is enabled.
             // Set the icon according to the save type.
             switch (saveType) {
                 case StoragePermissionDialog.SAVE_URL:
-                    dialogBuilder.setIcon(R.drawable.copy_enabled_light);
+                    dialogBuilder.setIcon(R.drawable.copy_enabled_day);
                     break;
 
                 case StoragePermissionDialog.SAVE_AS_ARCHIVE:
-                    dialogBuilder.setIcon(R.drawable.dom_storage_cleared_light);
+                    dialogBuilder.setIcon(R.drawable.dom_storage_cleared_day);
                     break;
 
                 case StoragePermissionDialog.SAVE_AS_IMAGE:
-                    dialogBuilder.setIcon(R.drawable.images_enabled_light);
+                    dialogBuilder.setIcon(R.drawable.images_enabled_day);
                     break;
             }
         }
@@ -206,6 +193,12 @@ public class SaveDialog extends DialogFragment {
         // Remove the incorrect lint warning below that the window might be null.
         assert alertDialog.getWindow() != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -223,6 +216,14 @@ public class SaveDialog extends DialogFragment {
         TextView storagePermissionTextView = alertDialog.findViewById(R.id.storage_permission_textview);
         Button saveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect warnings that the views might be null.
+        assert urlEditText != null;
+        assert fileNameEditText != null;
+        assert browseButton != null;
+        assert fileSizeTextView != null;
+        assert fileExistsWarningTextView != null;
+        assert storagePermissionTextView != null;
+
         // Set the file size text view.
         fileSizeTextView.setText(fileSizeString);
 
index 624e45532e98e81c6239c46ec745832ada65fe25..c73cfdc6ecd6fe897bc71401d573bdb051769f72 100644 (file)
@@ -22,13 +22,13 @@ package com.stoutner.privacybrowser.dialogs;
 import android.Manifest;
 import android.annotation.SuppressLint;
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.content.res.Configuration;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
@@ -43,8 +43,9 @@ import android.widget.EditText;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
-import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment is required or an error is produced on API <=22.  It is also required for the browse button to work correctly.
+import androidx.fragment.app.DialogFragment;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.helpers.DownloadLocationHelper;
@@ -74,39 +75,23 @@ public class SaveLogcatDialog extends DialogFragment {
     @Override
     @NonNull
     public Dialog onCreateDialog(Bundle savedInstanceState) {
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
-        // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
         // Get a handle for the activity and the context.
-        Activity activity = getActivity();
-        Context context = getContext();
-
-        // Remove the incorrect lint warnings.
-        assert activity != null;
-        assert context != null;
-
-        // Set the style according to the theme.
-        if (darkTheme) {
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogDark);
-        } else {
-            dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogLight);
-        }
+        Activity activity = requireActivity();
+        Context context = requireContext();
 
+        // Use an alert dialog builder to create the alert dialog.
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
         // Set the title.
         dialogBuilder.setTitle(R.string.save_logcat);
 
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
         // Set the icon according to the theme.
-        if (darkTheme) {
-            dialogBuilder.setIcon(R.drawable.save_dialog_dark);
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.save_dialog_night);
         } else {
-            dialogBuilder.setIcon(R.drawable.save_dialog_light);
+            dialogBuilder.setIcon(R.drawable.save_dialog_day);
         }
 
         // Set the view.  The parent view is null because it will be assigned by the alert dialog.
@@ -129,6 +114,12 @@ public class SaveLogcatDialog extends DialogFragment {
         // Remove the incorrect lint warning below that `getWindow()` might be null.
         assert alertDialog.getWindow() != null;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -144,6 +135,12 @@ public class SaveLogcatDialog extends DialogFragment {
         TextView storagePermissionTextView = alertDialog.findViewById(R.id.storage_permission_textview);
         Button saveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert fileNameEditText != null;
+        assert browseButton != null;
+        assert fileExistsWarningTextView != null;
+        assert storagePermissionTextView != null;
+
         // Update the status of the save button when the file name changes.
         fileNameEditText.addTextChangedListener(new TextWatcher() {
             @Override
index 7d8e0b6384b103b95976d940bc72f5695037a5e6..9e329434c002609cacb9d47ff8b535f80ea3f73a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -21,10 +21,10 @@ package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.net.Uri;
 import android.net.http.SslCertificate;
 import android.net.http.SslError;
@@ -41,7 +41,8 @@ import android.webkit.SslErrorHandler;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment must be used or an error is produced on API <=22.
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.activities.MainWebViewActivity;
@@ -137,35 +138,20 @@ public class SslCertificateErrorDialog extends DialogFragment {
         // Get a handle for the SSL error handler.
         SslErrorHandler sslErrorHandler = nestedScrollWebView.getSslErrorHandler();
 
-        // Remove the incorrect lint warning that `getActivity()` might be null.
-        assert getActivity() != null;
-
         // Get the activity's layout inflater.
-        LayoutInflater layoutInflater = getActivity().getLayoutInflater();
+        LayoutInflater layoutInflater = requireActivity().getLayoutInflater();
 
         // Use an alert dialog builder to create the alert dialog.
-        AlertDialog.Builder dialogBuilder;
-
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-        // Get the screenshot and theme preferences.
-        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
-        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
 
-        // Set the style and icon according to the theme.
-        if (darkTheme) {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
+        // Get the current theme status.
+        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_dark);
+        // Set the icon according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+            dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_night);
         } else {
-            // Set the style.
-            dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
-
-            // Set the icon.
-            dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_light);
+            dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_day);
         }
 
         // Set the title.
@@ -202,6 +188,12 @@ public class SslCertificateErrorDialog extends DialogFragment {
         // Create an alert dialog from the alert dialog builder.
         AlertDialog alertDialog = dialogBuilder.create();
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot preference.
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             // Remove the warning below that `getWindow()` might be null.
@@ -234,6 +226,20 @@ public class SslCertificateErrorDialog extends DialogFragment {
         TextView startDateTextView = alertDialog.findViewById(R.id.start_date);
         TextView endDateTextView = alertDialog.findViewById(R.id.end_date);
 
+        // Remove the incorrect lint warnings below that the views might be null.
+        assert primaryErrorTextView != null;
+        assert urlTextView != null;
+        assert issuedToCNameTextView != null;
+        assert issuedToONameTextView != null;
+        assert issuedToUNameTextView != null;
+        assert issuedByTextView != null;
+        assert issuedByCNameTextView != null;
+        assert issuedByONameTextView != null;
+        assert issuedByUNameTextView != null;
+        assert validDatesTextView != null;
+        assert startDateTextView != null;
+        assert endDateTextView != null;
+
         // Setup the common strings.
         String urlLabel = getString(R.string.url_label) + "  ";
         String cNameLabel = getString(R.string.common_name) + "  ";
@@ -253,17 +259,17 @@ public class SslCertificateErrorDialog extends DialogFragment {
         SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + startDate);
         SpannableStringBuilder endDateStringBuilder = new SpannableStringBuilder((endDateLabel + endDate));
 
-        // Create a red foreground color span.  The deprecated `getResources().getColor` must be used until the minimum API >= 23.
-        ForegroundColorSpan redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700));
-
-        // Create a blue `ForegroundColorSpan`.
+        // Define the color spans.
         ForegroundColorSpan blueColorSpan;
+        ForegroundColorSpan redColorSpan;
 
-        // Set a blue color span according to the theme.  The deprecated `getResources().getColor` must be used until the minimum API >= 23.
-        if (darkTheme