X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FEditBookmarkDialog.java;h=117d58400eb67c36775b6410cb9fe2b968ac8407;hb=871520acac2bd75f528e943c1b2a650017c852b9;hp=a2db731be916baa5d6bcce5f749e8ac632cef57d;hpb=61a76e491469916f2f30aebb47b98cda7cceb557;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java index a2db731b..117d5840 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 Soren Stoutner . + * Copyright © 2016-2017 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -75,10 +75,20 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { Cursor bookmarkCursor = BookmarksActivity.bookmarksDatabaseHelper.getBookmarkCursor(selectedBookmarkDatabaseId); bookmarkCursor.moveToFirst(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. The style formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } + + // Set the title. dialogBuilder.setTitle(R.string.edit_bookmark); - // The parent view is `null` because it will be assigned by `AlertDialog`. + + // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_dialog, null)); // Set an `onClick()` listener for the negative button. @@ -117,17 +127,14 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { Bitmap currentIconBitmap = BitmapFactory.decodeByteArray(currentIconByteArray, 0, currentIconByteArray.length); // Display `currentIconBitmap` in `edit_bookmark_current_icon`. ImageView currentIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_bookmark_current_icon); - assert currentIconImageView != null; // Remove the warning below that `currentIconImageView` might be null; currentIconImageView.setImageBitmap(currentIconBitmap); // Get a `Bitmap` of the favorite icon from `MainWebViewActivity` and display it in `edit_bookmark_web_page_favorite_icon`. ImageView newFavoriteIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_bookmark_web_page_favorite_icon); - assert newFavoriteIconImageView != null; // Remove the warning below that `newFavoriteIcon` might be null. - newFavoriteIconImageView.setImageBitmap(MainWebViewActivity.favoriteIcon); + newFavoriteIconImageView.setImageBitmap(MainWebViewActivity.favoriteIconBitmap); // Load the text for `edit_bookmark_name_edittext`. EditText bookmarkNameEditText = (EditText) alertDialog.findViewById(R.id.edit_bookmark_name_edittext); - assert bookmarkNameEditText != null; // Remove the warning below that `bookmarkNameEditText` might be null. bookmarkNameEditText.setText(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME))); // Allow the `enter` key on the keyboard to save the bookmark from `edit_bookmark_name_edittext`. @@ -150,7 +157,6 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { // Load the text for `edit_bookmark_url_edittext`. EditText bookmarkUrlEditText = (EditText) alertDialog.findViewById(R.id.edit_bookmark_url_edittext); - assert bookmarkUrlEditText != null;// Remove the warning below that `bookmarkUrlEditText` might be null. bookmarkUrlEditText.setText(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL))); // Allow the "enter" key on the keyboard to save the bookmark from `edit_bookmark_url_edittext`.