]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/DownloadLocationPermissionDialog.java
Add setting to disable screenshots. https://redmine.stoutner.com/issues/266
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / DownloadLocationPermissionDialog.java
index 0ad43d1c7a69d15e5adde01cb5a86c818c671b0b..57b3889d1bfa0741f3337a8f4ef1a960833782e0 100644 (file)
@@ -25,6 +25,7 @@ import android.app.DialogFragment;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.os.Bundle;
+import android.view.WindowManager;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.activities.MainWebViewActivity;
@@ -102,7 +103,19 @@ public class DownloadLocationPermissionDialog extends DialogFragment {
         // Set the text.
         dialogBuilder.setMessage(R.string.download_location_message);
 
+        // Create an alert dialog from the alert dialog builder.
+        final AlertDialog alertDialog = dialogBuilder.create();
+
+        // Disable screenshots if not allowed.
+        if (!MainWebViewActivity.allowScreenshots) {
+            // Remove the warning below that `getWindow()` might be null.
+            assert alertDialog.getWindow() != null;
+
+            // Disable screenshots.
+            alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+        }
+
         // `onCreateDialog` requires the return of an `AlertDialog`.
-        return dialogBuilder.create();
+        return alertDialog;
     }
 }
\ No newline at end of file