X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2FEditBookmark.java;h=ed6cc85089c4d595833e535e4fe247950c94b3d9;hb=e29020961c70d97a06c810aaff28ef1fd6af4ae7;hp=61074703e2fd6871d60352eb418e35c27411467d;hpb=88279fa8a750a4ff24b093649159dc833cbce1fd;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java b/app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java index 61074703..ed6cc850 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java +++ b/app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java @@ -38,8 +38,6 @@ import android.widget.ImageView; public class EditBookmark extends DialogFragment { // The public interface is used to send information back to the parent activity. public interface EditBookmarkListener { - void onCancelEditBookmark(DialogFragment dialogFragment); - void onSaveEditBookmark(DialogFragment dialogFragment); } @@ -77,8 +75,7 @@ public class EditBookmark extends DialogFragment { dialogBuilder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - // Return the `DialogFragment` to the parent activity on cancel. - editBookmarkListener.onCancelEditBookmark(EditBookmark.this); + // Do nothing. The `AlertDialog` will close automatically. } }); @@ -95,7 +92,7 @@ public class EditBookmark extends DialogFragment { // Create an `AlertDialog` from the `AlertDialog.Builder`. final AlertDialog alertDialog = dialogBuilder.create(); - // Show the keyboard when the `Dialog` is displayed on the screen. + // Show the keyboard when `alertDialog` is displayed on the screen. alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); // We need to show the `AlertDialog` before we can modify items in the layout. @@ -122,10 +119,11 @@ public class EditBookmark extends DialogFragment { // Allow the `enter` key on the keyboard to save the bookmark from `edit_bookmark_name_edittext`. bookmarkNameEditText.setOnKeyListener(new View.OnKeyListener() { + @Override public boolean onKey(View v, int keyCode, KeyEvent event) { - // If the event is a key-down on the "enter" button, select the PositiveButton `Save`. + // If the event is an `ACTION_DOWN` on the `enter` key, save the bookmark. if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { - // Trigger `editBookmarkListener` and return the DialogFragment to the parent activity. + // Trigger `onSaveEditBookmark()` and return the `DialogFragment` to the parent activity. editBookmarkListener.onSaveEditBookmark(EditBookmark.this); // Manually dismiss `alertDialog`. alertDialog.dismiss();