X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FCreateBookmarkFolderDialog.java;h=7954478e623745ccf8d57885c26ca37eca861fad;hp=dfe6cbd8a1a861b66ffedac5bd36ceab0df878a3;hb=65ff2d87f3a8fd1c26a26678498a7451e76ebb16;hpb=b8a2c6af93b55788b8fa978dc8ea28abddb7ddc4 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java index dfe6cbd8..7954478e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.java @@ -38,9 +38,9 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; -import com.stoutner.privacybrowser.activities.BookmarksActivity; -import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; +import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper; public class CreateBookmarkFolderDialog extends AppCompatDialogFragment { // The public interface is used to send information back to the parent activity. @@ -113,13 +113,17 @@ public class CreateBookmarkFolderDialog extends AppCompatDialogFragment { // The `AlertDialog` must be shown before items in the alert dialog can be modified. alertDialog.show(); - // Get a handle for the create button. + // Get handles for the views in the dialog. final Button createButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); EditText folderNameEditText = (EditText) alertDialog.findViewById(R.id.create_folder_name_edittext); + ImageView webPageIconImageView = (ImageView) alertDialog.findViewById(R.id.create_folder_web_page_icon); // Initially disable the create button. createButton.setEnabled(false); + // Initialize the database helper. The two `nulls` do not specify the database name or a `CursorFactory`. The `0` specifies a database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`. + final BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(getContext(), null, null, 0); + // Enable the create button if the new folder name is unique. folderNameEditText.addTextChangedListener(new TextWatcher() { @Override @@ -138,7 +142,7 @@ public class CreateBookmarkFolderDialog extends AppCompatDialogFragment { String folderName = s.toString(); // Check if a folder with the name already exists. - Cursor folderExistsCursor = BookmarksActivity.bookmarksDatabaseHelper.getFolderCursor(folderName); + Cursor folderExistsCursor = bookmarksDatabaseHelper.getFolderCursor(folderName); // Enable the create button if the new folder name is not empty and doesn't already exist. createButton.setEnabled(!folderName.isEmpty() && (folderExistsCursor.getCount() == 0)); @@ -163,7 +167,6 @@ public class CreateBookmarkFolderDialog extends AppCompatDialogFragment { }); // Display the current favorite icon. - ImageView webPageIconImageView = (ImageView) alertDialog.findViewById(R.id.create_folder_web_page_icon); webPageIconImageView.setImageBitmap(MainWebViewActivity.favoriteIconBitmap); // `onCreateDialog()` requires the return of an `AlertDialog`.