X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FCreateBookmarkDialog.java;h=f89649bc542d8f9910be6c37f74630a252b01f85;hp=4da0f14eb73c0e13094dd17c1a42c01e1161840f;hb=b235ba52731f112015d9058ade4c5a66abf7ed5c;hpb=5d3cafb4a4fbb2bf851d36f973cc1e8b23ecebab diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java index 4da0f14e..f89649bc 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java @@ -176,40 +176,42 @@ public class CreateBookmarkDialog extends DialogFragment { // Set the current `WebView` title as the text for `create_bookmark_name_edittext`. createBookmarkNameEditText.setText(title); - // Allow the `enter` key on the keyboard to create the bookmark from `create_bookmark_name_edittext`. - createBookmarkNameEditText.setOnKeyListener((View view, int keyCode, KeyEvent event) -> { - // If the event is a key-down on the `enter` key, select the `PositiveButton` `Create`. - if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) { - // Trigger `createBookmarkListener` and return the `DialogFragment` to the parent activity. + // Allow the `enter` key on the keyboard to create the bookmark from the create bookmark name edittext`. + createBookmarkNameEditText.setOnKeyListener((View view, int keyCode, KeyEvent keyEvent) -> { + // If the event is a key-down on the `enter` key, select the create button. + if ((keyCode == KeyEvent.KEYCODE_ENTER) && (keyEvent.getAction() == KeyEvent.ACTION_DOWN)) { + // Trigger the create bookmark listener and return the dialog fragment and the favorite icon bitmap to the parent activity. createBookmarkListener.onCreateBookmark(this, favoriteIconBitmap); - // Manually dismiss the `AlertDialog`. + // Manually dismiss the alert dialog. alertDialog.dismiss(); // Consume the event. return true; - } else { // If any other key was pressed, do not consume the event. + } else { // Some other key was pressed. + // Do not consume the event. return false; } }); - // Set the formattedUrlString as the initial text of `create_bookmark_url_edittext`. + // Set the formatted URL string as the initial text of the create bookmark URL edit text. EditText createBookmarkUrlEditText = alertDialog.findViewById(R.id.create_bookmark_url_edittext); createBookmarkUrlEditText.setText(url); - // Allow the `enter` key on the keyboard to create the bookmark from `create_bookmark_url_edittext`. - createBookmarkUrlEditText.setOnKeyListener((View v, int keyCode, KeyEvent event) -> { - // If the event is a key-down on the "enter" key, select the PositiveButton "Create". - if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) { - // Trigger `createBookmarkListener` and return the DialogFragment to the parent activity. + // Allow the enter key on the keyboard to create the bookmark from create bookmark URL edit text. + createBookmarkUrlEditText.setOnKeyListener((View v, int keyCode, KeyEvent keyEvent) -> { + // If the event is a key-down on the `enter` key, select the create button. + if ((keyCode == KeyEvent.KEYCODE_ENTER) && (keyEvent.getAction() == KeyEvent.ACTION_DOWN)) { + // Trigger the create bookmark listener and return the dialog fragment and the favorite icon bitmap to the parent activity. createBookmarkListener.onCreateBookmark(this, favoriteIconBitmap); - // Manually dismiss the `AlertDialog`. + // Manually dismiss the alert dialog. alertDialog.dismiss(); // Consume the event. return true; - } else { // If any other key was pressed, do not consume the event. + } else { // Some other key was pressed. + // Do not consume the event. return false; } });