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=8343ace2ff3818dd3afb149604de1698a45459b3;hpb=c4ad9f457f41cbc86391e0099629cd94a235258a;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 8343ace2..ed6cc850 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java +++ b/app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java @@ -26,8 +26,6 @@ import android.content.DialogInterface; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; import android.os.Bundle; // If we don't use `android.support.v7.app.AlertDialog` instead of `android.app.AlertDialog` then the dialog will be covered by the keyboard. import android.support.v7.app.AlertDialog; @@ -40,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); } @@ -79,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. } }); @@ -97,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. @@ -124,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();