X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FEditBookmarkDialog.java;h=492c113ad710786239584b1ffc35b262be03d790;hp=e37dacdf55de130b1b9c9e8ec2586adcf0fe0bf2;hb=0a5d2eabceeafb49a957598538aa74d4f11dfce0;hpb=6ccecb3374c1988aef2650a87dac20923ce3aa2f 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 e37dacdf..492c113a 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-2018 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -95,6 +95,9 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { // Run the default commands. super.onCreate(savedInstanceState); + // Remove the incorrect lint warning that `getInt()` might be null. + assert getArguments() != null; + // Store the bookmark database ID in the class variable. selectedBookmarkDatabaseId = getArguments().getInt("Database ID"); } @@ -111,7 +114,7 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { Cursor bookmarkCursor = bookmarksDatabaseHelper.getBookmarkCursor(selectedBookmarkDatabaseId); bookmarkCursor.moveToFirst(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. + // Use an alert dialog builder to create the alert dialog. AlertDialog.Builder dialogBuilder; // Set the style according to the theme. @@ -124,30 +127,38 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { // Set the title. dialogBuilder.setTitle(R.string.edit_bookmark); + // Remove the incorrect lint warning that `getActivity()` might be null. + assert getActivity() != null; + // 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. + // Set the listener for the negative button. dialogBuilder.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> { // Do nothing. The `AlertDialog` will close automatically. }); - // Set the `onClick()` listener fo the positive button. + // Set the listener fo the positive button. dialogBuilder.setPositiveButton(R.string.save, (DialogInterface dialog, int which) -> { // Return the `DialogFragment` to the parent activity on save. editBookmarkListener.onSaveBookmark(EditBookmarkDialog.this, selectedBookmarkDatabaseId); }); - // Create an `AlertDialog` from the `AlertDialog.Builder`. + // Create an alert dialog from the alert dialog builder. final AlertDialog alertDialog = dialogBuilder.create(); - // Remove the warning below that `setSoftInputMode` might produce `java.lang.NullPointerException`. + // Remove the warning below that `getWindow()` might be null. assert alertDialog.getWindow() != null; - // Show the keyboard when `alertDialog` is displayed on the screen. + // Disable screenshots if not allowed. + if (!MainWebViewActivity.allowScreenshots) { + alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); + } + + // Show the keyboard when the alert dialog is displayed on the screen. alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); - // The `AlertDialog` must be shown before items in the layout can be modified. + // The alert dialog must be shown before items in the layout can be modified. alertDialog.show(); // Get handles for the layout items.