X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FDownloadFileDialog.java;h=5ff4a851a145d4eed0ee57ff9ae44555b31d3b8b;hp=cbf08390254a854a4023c234e402117e279dfeff;hb=0a5d2eabceeafb49a957598538aa74d4f11dfce0;hpb=6ccecb3374c1988aef2650a87dac20923ce3aa2f diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java index cbf08390..5ff4a851 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadFileDialog.java @@ -130,7 +130,7 @@ public class DownloadFileDialog extends AppCompatDialogFragment { // Get the activity's layout inflater. LayoutInflater layoutInflater = getActivity().getLayoutInflater(); - // 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. @@ -146,24 +146,29 @@ public class DownloadFileDialog extends AppCompatDialogFragment { // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. dialogBuilder.setView(layoutInflater.inflate(R.layout.download_file_dialog, null)); - // Set an `onClick()` listener on the negative button. + // Set an listener on the negative button. dialogBuilder.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> { // Do nothing if `Cancel` is clicked. The `Dialog` will automatically close. }); - // Set an `onClick()` listener on the positive button + // Set an listener on the positive button dialogBuilder.setPositiveButton(R.string.download, (DialogInterface dialog, int which) -> { // trigger `onDownloadFile()` and return the `DialogFragment` and the download URL to the parent activity. downloadFileListener.onDownloadFile(DownloadFileDialog.this, downloadUrl); }); - // 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 alert dialog is displayed on the screen. alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); // We need to show `alertDialog` before we can modify the contents.