]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java
Add a requests activity. https://redmine.stoutner.com/issues/170
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / AddDomainDialog.java
index 292ef453abe7f295041915e579287cb0b2f3d093..edffc63fb8b3d069ce2f08818ee1daac19c4af21 100644 (file)
@@ -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);