X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FAddDomainDialog.java;h=edffc63fb8b3d069ce2f08818ee1daac19c4af21;hp=292ef453abe7f295041915e579287cb0b2f3d093;hb=012e5595c82d6e8d0b8a46f1ef18a02a56341182;hpb=6fa2fbb5a767bbe036daae06b0da883c4bafb798 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java index 292ef453..edffc63f 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java @@ -53,14 +53,11 @@ public class AddDomainDialog extends AppCompatDialogFragment { public void onAttach(Context context) { + // Run the default commands. super.onAttach(context); - // Get a handle for `AddDomainListener` from `context`. - try { - addDomainListener = (AddDomainListener) context; - } catch(ClassCastException exception) { - throw new ClassCastException(context.toString() + " must implement `AddDomainListener`."); - } + // Get a handle for the listener from the launching context. + addDomainListener = (AddDomainListener) context; } // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`. @@ -68,7 +65,7 @@ public class AddDomainDialog extends AppCompatDialogFragment { @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // 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. @@ -101,9 +98,14 @@ public class AddDomainDialog extends AppCompatDialogFragment { // Create an alert dialog from the builder. final AlertDialog alertDialog = dialogBuilder.create(); - // Remove the warning below that `setSoftInputMode` might be null. + // Remove the warning below that `getWindow()` might be null. assert alertDialog.getWindow() != null; + // 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);