From: Soren Stoutner Date: Wed, 21 Jun 2017 23:37:22 +0000 (-0700) Subject: Create a dark theme for `BookMarksActivity` and `BookmarksDatabaseViewActivity`. X-Git-Tag: v2.4~3 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=922fa1656fdc20242c266346ea30d4c2e9489eb9;p=PrivacyBrowserAndroid.git Create a dark theme for `BookMarksActivity` and `BookmarksDatabaseViewActivity`. --- 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.xml b/app/src/main/res/drawable/create_folder.xml deleted file mode 100644 index 78c67f21..00000000 --- a/app/src/main/res/drawable/create_folder.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - 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_light.xml b/app/src/main/res/drawable/create_folder_light.xml new file mode 100644 index 00000000..6799516c --- /dev/null +++ b/app/src/main/res/drawable/create_folder_light.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/domains_list_selector.xml b/app/src/main/res/drawable/domains_list_selector.xml deleted file mode 100644 index 904cf996..00000000 --- a/app/src/main/res/drawable/domains_list_selector.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/domains_list_selector_dark.xml b/app/src/main/res/drawable/domains_list_selector_dark.xml deleted file mode 100644 index da370c93..00000000 --- a/app/src/main/res/drawable/domains_list_selector_dark.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/domains_list_selector_light.xml b/app/src/main/res/drawable/domains_list_selector_light.xml deleted file mode 100644 index 904cf996..00000000 --- a/app/src/main/res/drawable/domains_list_selector_light.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/edit.xml b/app/src/main/res/drawable/edit.xml deleted file mode 100644 index 93320210..00000000 --- a/app/src/main/res/drawable/edit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - 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_light.xml b/app/src/main/res/drawable/edit_light.xml new file mode 100644 index 00000000..97ea7d92 --- /dev/null +++ b/app/src/main/res/drawable/edit_light.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/list_selector_dark.xml b/app/src/main/res/drawable/list_selector_dark.xml new file mode 100644 index 00000000..7f4f195d --- /dev/null +++ b/app/src/main/res/drawable/list_selector_dark.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/list_selector_light.xml b/app/src/main/res/drawable/list_selector_light.xml new file mode 100644 index 00000000..fef52c59 --- /dev/null +++ b/app/src/main/res/drawable/list_selector_light.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/listview_item_background_selector.xml b/app/src/main/res/drawable/listview_item_background_selector.xml deleted file mode 100644 index 7720acaa..00000000 --- a/app/src/main/res/drawable/listview_item_background_selector.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ 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_bookmark_down_disabled.xml deleted file mode 100644 index 4148b5e4..00000000 --- a/app/src/main/res/drawable/move_bookmark_down_disabled.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/move_bookmark_down_enabled.xml b/app/src/main/res/drawable/move_bookmark_down_enabled.xml deleted file mode 100644 index dc9806db..00000000 --- a/app/src/main/res/drawable/move_bookmark_down_enabled.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/move_bookmark_up_disabled.xml b/app/src/main/res/drawable/move_bookmark_up_disabled.xml deleted file mode 100644 index 20851821..00000000 --- a/app/src/main/res/drawable/move_bookmark_up_disabled.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/move_bookmark_up_enabled.xml b/app/src/main/res/drawable/move_bookmark_up_enabled.xml deleted file mode 100644 index c0d2986c..00000000 --- a/app/src/main/res/drawable/move_bookmark_up_enabled.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/move_down_disabled.xml b/app/src/main/res/drawable/move_down_disabled.xml new file mode 100644 index 00000000..10bc6b8e --- /dev/null +++ b/app/src/main/res/drawable/move_down_disabled.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/move_down_enabled_dark.xml b/app/src/main/res/drawable/move_down_enabled_dark.xml new file mode 100644 index 00000000..88d04f49 --- /dev/null +++ b/app/src/main/res/drawable/move_down_enabled_dark.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/move_down_enabled_light.xml b/app/src/main/res/drawable/move_down_enabled_light.xml new file mode 100644 index 00000000..0cb9fc38 --- /dev/null +++ b/app/src/main/res/drawable/move_down_enabled_light.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/move_to_folder.xml b/app/src/main/res/drawable/move_to_folder.xml deleted file mode 100644 index 410ad13e..00000000 --- a/app/src/main/res/drawable/move_to_folder.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/drawable/move_to_folder_dark.xml b/app/src/main/res/drawable/move_to_folder_dark.xml new file mode 100644 index 00000000..16dc955b --- /dev/null +++ b/app/src/main/res/drawable/move_to_folder_dark.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/move_to_folder_light.xml b/app/src/main/res/drawable/move_to_folder_light.xml new file mode 100644 index 00000000..92e9b197 --- /dev/null +++ b/app/src/main/res/drawable/move_to_folder_light.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/move_up_disabled.xml b/app/src/main/res/drawable/move_up_disabled.xml new file mode 100644 index 00000000..6c935705 --- /dev/null +++ b/app/src/main/res/drawable/move_up_disabled.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/move_up_enabled_dark.xml b/app/src/main/res/drawable/move_up_enabled_dark.xml new file mode 100644 index 00000000..c232a594 --- /dev/null +++ b/app/src/main/res/drawable/move_up_enabled_dark.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/move_up_enabled_light.xml b/app/src/main/res/drawable/move_up_enabled_light.xml new file mode 100644 index 00000000..3fb4e53b --- /dev/null +++ b/app/src/main/res/drawable/move_up_enabled_light.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/select_all.xml b/app/src/main/res/drawable/select_all.xml deleted file mode 100644 index 54151e54..00000000 --- a/app/src/main/res/drawable/select_all.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/select_all_dark.xml b/app/src/main/res/drawable/select_all_dark.xml new file mode 100644 index 00000000..c0099cc8 --- /dev/null +++ b/app/src/main/res/drawable/select_all_dark.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/select_all_light.xml b/app/src/main/res/drawable/select_all_light.xml new file mode 100644 index 00000000..b9bf3e1d --- /dev/null +++ b/app/src/main/res/drawable/select_all_light.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/layout/bookmarks_coordinatorlayout.xml b/app/src/main/res/layout/bookmarks_coordinatorlayout.xml index 3eb25273..e07ce174 100644 --- a/app/src/main/res/layout/bookmarks_coordinatorlayout.xml +++ b/app/src/main/res/layout/bookmarks_coordinatorlayout.xml @@ -18,8 +18,7 @@ You should have received a copy of the GNU General Public License along with Privacy Browser. If not, see . --> - + + android:layout_width="match_parent" > + android: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