From 922fa1656fdc20242c266346ea30d4c2e9489eb9 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Wed, 21 Jun 2017 16:37:22 -0700 Subject: [PATCH] Create a dark theme for `BookMarksActivity` and `BookmarksDatabaseViewActivity`. --- app/src/main/AndroidManifest.xml | 2 -- .../activities/BookmarksActivity.java | 32 ++++++++++++++--- .../BookmarksDatabaseViewActivity.java | 15 +++++++- .../activities/MainWebViewActivity.java | 6 ++-- .../main/res/drawable/create_folder_dark.xml | 18 ++++++++++ ...ate_folder.xml => create_folder_light.xml} | 2 +- .../drawable/domains_list_selector_light.xml | 26 -------------- app/src/main/res/drawable/edit_dark.xml | 18 ++++++++++ .../res/drawable/{edit.xml => edit_light.xml} | 2 +- ...lector_dark.xml => list_selector_dark.xml} | 2 +- ...t_selector.xml => list_selector_light.xml} | 2 +- .../listview_item_background_selector.xml | 26 -------------- ...wn_disabled.xml => move_down_disabled.xml} | 2 +- .../res/drawable/move_down_enabled_dark.xml | 13 +++++++ ...nabled.xml => move_down_enabled_light.xml} | 2 +- .../main/res/drawable/move_to_folder_dark.xml | 18 ++++++++++ ...to_folder.xml => move_to_folder_light.xml} | 2 +- ...k_up_disabled.xml => move_up_disabled.xml} | 2 +- .../res/drawable/move_up_enabled_dark.xml | 13 +++++++ ..._enabled.xml => move_up_enabled_light.xml} | 2 +- app/src/main/res/drawable/select_all_dark.xml | 13 +++++++ .../{select_all.xml => select_all_light.xml} | 2 +- .../layout/bookmarks_coordinatorlayout.xml | 14 ++++---- ...kmarks_database_view_coordinatorlayout.xml | 9 ++--- ...kmarks_database_view_item_linearlayout.xml | 7 ++-- .../layout/bookmarks_item_linearlayout.xml | 4 +-- .../res/layout/domain_name_linearlayout.xml | 2 +- .../move_to_folder_item_linearlayout.xml | 4 +-- .../main/res/menu/bookmarks_context_menu.xml | 10 +++--- .../main/res/menu/bookmarks_options_menu.xml | 4 +-- app/src/main/res/values/attrs.xml | 7 +++- app/src/main/res/values/styles.xml | 35 +++++++++++-------- 32 files changed, 197 insertions(+), 119 deletions(-) create mode 100644 app/src/main/res/drawable/create_folder_dark.xml rename app/src/main/res/drawable/{create_folder.xml => create_folder_light.xml} (82%) delete mode 100644 app/src/main/res/drawable/domains_list_selector_light.xml create mode 100644 app/src/main/res/drawable/edit_dark.xml rename app/src/main/res/drawable/{edit.xml => edit_light.xml} (84%) rename app/src/main/res/drawable/{domains_list_selector_dark.xml => list_selector_dark.xml} (97%) rename app/src/main/res/drawable/{domains_list_selector.xml => list_selector_light.xml} (97%) delete mode 100644 app/src/main/res/drawable/listview_item_background_selector.xml rename app/src/main/res/drawable/{move_bookmark_down_disabled.xml => move_down_disabled.xml} (70%) create mode 100644 app/src/main/res/drawable/move_down_enabled_dark.xml rename app/src/main/res/drawable/{move_bookmark_down_enabled.xml => move_down_enabled_light.xml} (70%) create mode 100644 app/src/main/res/drawable/move_to_folder_dark.xml rename app/src/main/res/drawable/{move_to_folder.xml => move_to_folder_light.xml} (83%) rename app/src/main/res/drawable/{move_bookmark_up_disabled.xml => move_up_disabled.xml} (70%) create mode 100644 app/src/main/res/drawable/move_up_enabled_dark.xml rename app/src/main/res/drawable/{move_bookmark_up_enabled.xml => move_up_enabled_light.xml} (70%) create mode 100644 app/src/main/res/drawable/select_all_dark.xml rename app/src/main/res/drawable/{select_all.xml => select_all_light.xml} (82%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 004984e5..be16084b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -84,7 +84,6 @@ = 21. @@ -185,7 +195,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma editBookmarkMenuItem = menu.findItem(R.id.edit_bookmark); selectAllBookmarksMenuItem = menu.findItem(R.id.context_menu_select_all_bookmarks); - // Get a handle for `contextualActionMode` so we can close it programatically. + // Store `contextualActionMode` so we can close it programatically. contextualActionMode = mode; return true; @@ -225,19 +235,31 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma // Disable `moveBookmarkUpMenuItem` if the selected bookmark is at the top of the ListView. if (selectedBookmarkDatabaseId == firstBookmarkDatabaseId) { moveBookmarkUpMenuItem.setEnabled(false); - moveBookmarkUpMenuItem.setIcon(R.drawable.move_bookmark_up_disabled); + moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_disabled); } else { // Otherwise enable `moveBookmarkUpMenuItem`. moveBookmarkUpMenuItem.setEnabled(true); - moveBookmarkUpMenuItem.setIcon(R.drawable.move_bookmark_up_enabled); + + // Set the icon according to the theme. + if (MainWebViewActivity.darkTheme) { + moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_dark); + } else { + moveBookmarkUpMenuItem.setIcon(R.drawable.move_up_enabled_light); + } } // Disable `moveBookmarkDownMenuItem` if the selected bookmark is at the bottom of the ListView. if (selectedBookmarkDatabaseId == lastBookmarkDatabaseId) { moveBookmarkDownMenuItem.setEnabled(false); - moveBookmarkDownMenuItem.setIcon(R.drawable.move_bookmark_down_disabled); + moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_disabled); } else { // Otherwise enable `moveBookmarkDownMenuItem`. moveBookmarkDownMenuItem.setEnabled(true); - moveBookmarkDownMenuItem.setIcon(R.drawable.move_bookmark_down_enabled); + + // Set the icon according to the theme. + if (MainWebViewActivity.darkTheme) { + moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_dark); + } else { + moveBookmarkDownMenuItem.setIcon(R.drawable.move_down_enabled_light); + } } } else { // More than one bookmark is selected. // List the number of selected bookmarks in the subtitle. diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java index c996a677..53fb657d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java @@ -48,6 +48,13 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { + // Set the activity theme. + if (MainWebViewActivity.darkTheme) { + setTheme(R.style.PrivacyBrowserDark_SecondaryActivity); + } else { + setTheme(R.style.PrivacyBrowserLight_SecondaryActivity); + } + super.onCreate(savedInstanceState); setContentView(R.layout.bookmarks_database_view_coordinatorlayout); @@ -129,7 +136,13 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity { } else { parentFolderImageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.folder_dark_blue)); bookmarkParentFolderTextView.setText(bookmarkParentFolder); - bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black)); + + // Set the text color according to the theme. + if (MainWebViewActivity.darkTheme) { + bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.gray_300)); + } else { + bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black)); + } } // Get the bookmark URL form the `Cursor` and display it in `bookmarkUrlTextView`. diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 24acf916..6db0595a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -122,9 +122,9 @@ import java.util.Set; public class MainWebViewActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, CreateHomeScreenShortcutDialog.CreateHomeScreenSchortcutListener, SslCertificateErrorDialog.SslCertificateErrorListener, DownloadFileDialog.DownloadFileListener, DownloadImageDialog.DownloadImageListener, UrlHistoryDialog.UrlHistoryListener { - // `darkTheme` is public static so it can be accessed from `AboutActivity`, `GuideActivity`, `AddDomainDialog`, `SettingsActivity`, `DomainsActivity`, `DomainsSettingsActivity`, `CreateBookmarkDialog`, `CreateBookmarkFolderDialog`, - // `DownloadFileDialog`, `DownloadImageDialog`, `EditBookmarkDialog`, `EditBookmarkFolderDialog`, `MoveToFolderDialog`, `SslCertificateErrorDialog`, `UrlHistoryDialog`, `ViewSslCertificateDialog`, `CreateHomeScreenShortcutDialog`, and `OrbotProxyHelper`. - // It is also used in `onCreate()`, `applyAppSettings()`, `applyDomainSettings()`, and `updatePrivacyIcons()`. + // `darkTheme` is public static so it can be accessed from `AboutActivity`, `GuideActivity`, `AddDomainDialog`, `SettingsActivity`, `DomainsActivity`, `DomainsSettingsActivity`, `BookmarksActivity`, `BookmarksDatabaseViewActivity`, + // `CreateBookmarkDialog`, `CreateBookmarkFolderDialog`, `DownloadFileDialog`, `DownloadImageDialog`, `EditBookmarkDialog`, `EditBookmarkFolderDialog`, `MoveToFolderDialog`, `SslCertificateErrorDialog`, `UrlHistoryDialog`, `ViewSslCertificateDialog`, + // `CreateHomeScreenShortcutDialog`, and `OrbotProxyHelper`. It is also used in `onCreate()`, `applyAppSettings()`, `applyDomainSettings()`, and `updatePrivacyIcons()`. public static boolean darkTheme; // `favoriteIconBitmap` is public static so it can be accessed from `CreateHomeScreenShortcutDialog`, `BookmarksActivity`, `CreateBookmarkDialog`, `CreateBookmarkFolderDialog`, `EditBookmarkDialog`, `EditBookmarkFolderDialog`, `ViewSslCertificateDialog`. diff --git a/app/src/main/res/drawable/create_folder_dark.xml b/app/src/main/res/drawable/create_folder_dark.xml new file mode 100644 index 00000000..b3f351eb --- /dev/null +++ b/app/src/main/res/drawable/create_folder_dark.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/create_folder.xml b/app/src/main/res/drawable/create_folder_light.xml similarity index 82% rename from app/src/main/res/drawable/create_folder.xml rename to app/src/main/res/drawable/create_folder_light.xml index 78c67f21..6799516c 100644 --- a/app/src/main/res/drawable/create_folder.xml +++ b/app/src/main/res/drawable/create_folder_light.xml @@ -1,4 +1,4 @@ - + - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/edit_dark.xml b/app/src/main/res/drawable/edit_dark.xml new file mode 100644 index 00000000..7fec0072 --- /dev/null +++ b/app/src/main/res/drawable/edit_dark.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/edit.xml b/app/src/main/res/drawable/edit_light.xml similarity index 84% rename from app/src/main/res/drawable/edit.xml rename to app/src/main/res/drawable/edit_light.xml index 93320210..97ea7d92 100644 --- a/app/src/main/res/drawable/edit.xml +++ b/app/src/main/res/drawable/edit_light.xml @@ -1,4 +1,4 @@ - + . --> - + . --> - + - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/move_bookmark_down_disabled.xml b/app/src/main/res/drawable/move_down_disabled.xml similarity index 70% rename from app/src/main/res/drawable/move_bookmark_down_disabled.xml rename to app/src/main/res/drawable/move_down_disabled.xml index 4148b5e4..10bc6b8e 100644 --- a/app/src/main/res/drawable/move_bookmark_down_disabled.xml +++ b/app/src/main/res/drawable/move_down_disabled.xml @@ -1,4 +1,4 @@ - + + + + + + diff --git a/app/src/main/res/drawable/move_bookmark_down_enabled.xml b/app/src/main/res/drawable/move_down_enabled_light.xml similarity index 70% rename from app/src/main/res/drawable/move_bookmark_down_enabled.xml rename to app/src/main/res/drawable/move_down_enabled_light.xml index dc9806db..0cb9fc38 100644 --- a/app/src/main/res/drawable/move_bookmark_down_enabled.xml +++ b/app/src/main/res/drawable/move_down_enabled_light.xml @@ -1,4 +1,4 @@ - + + + + + + + + diff --git a/app/src/main/res/drawable/move_to_folder.xml b/app/src/main/res/drawable/move_to_folder_light.xml similarity index 83% rename from app/src/main/res/drawable/move_to_folder.xml rename to app/src/main/res/drawable/move_to_folder_light.xml index 410ad13e..92e9b197 100644 --- a/app/src/main/res/drawable/move_to_folder.xml +++ b/app/src/main/res/drawable/move_to_folder_light.xml @@ -1,4 +1,4 @@ - + + + + + + + diff --git a/app/src/main/res/drawable/move_bookmark_up_enabled.xml b/app/src/main/res/drawable/move_up_enabled_light.xml similarity index 70% rename from app/src/main/res/drawable/move_bookmark_up_enabled.xml rename to app/src/main/res/drawable/move_up_enabled_light.xml index c0d2986c..3fb4e53b 100644 --- a/app/src/main/res/drawable/move_bookmark_up_enabled.xml +++ b/app/src/main/res/drawable/move_up_enabled_light.xml @@ -1,4 +1,4 @@ - + + + + + + diff --git a/app/src/main/res/drawable/select_all.xml b/app/src/main/res/drawable/select_all_light.xml similarity index 82% rename from app/src/main/res/drawable/select_all.xml rename to app/src/main/res/drawable/select_all_light.xml index 54151e54..b9bf3e1d 100644 --- a/app/src/main/res/drawable/select_all.xml +++ b/app/src/main/res/drawable/select_all_light.xml @@ -1,4 +1,4 @@ - + . --> - + + android:layout_width="match_parent" > + android:background="?attr/colorPrimaryDark" + android:theme="?attr/appBarTextTheme" + app:popupTheme="?attr/popupsTheme" /> - + - + @@ -89,8 +92,7 @@ - + + @@ -153,10 +163,7 @@ - - - - + \ No newline at end of file -- 2.45.2