X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FWaitingForProxyDialog.java;h=b413584e5786bbe2e1e2bed797cdb64febe94ba9;hp=08e39212a6418bda7526c3f5a32bdc583dd69887;hb=74655c0cd0ba72c80ac6c48df55bc3d2f5280ad2;hpb=6bc00e202749ba0cb337be462825002ba74be8fc diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.java index 08e39212..b413584e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Soren Stoutner . + * Copyright © 2019-2020 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -20,7 +20,6 @@ package com.stoutner.privacybrowser.dialogs; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.SharedPreferences; @@ -41,33 +40,14 @@ public class WaitingForProxyDialog extends DialogFragment { @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // Get the context and the activity. - Context context = getContext(); - Activity activity = getActivity(); - - // Remove the incorrect lint warnings below that the context or the activity might be null. - assert context != null; - assert activity != null; + // Get a handle for the context. + Context context = requireContext(); // Get the activity's layout inflater. - LayoutInflater layoutInflater = activity.getLayoutInflater(); - - // Get a handle for the shared preferences. - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - - // Get the screenshot and theme preferences. - boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); - boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); + LayoutInflater layoutInflater = requireActivity().getLayoutInflater(); // Use a builder to create the alert dialog. - AlertDialog.Builder dialogBuilder; - - // Set the style according to the theme. - if (darkTheme) { - dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogDark); - } else { - dialogBuilder = new AlertDialog.Builder(activity, R.style.PrivacyBrowserAlertDialogLight); - } + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog); // Set the layout. The parent view is `null` because it will be assigned by the alert dialog. dialogBuilder.setView(layoutInflater.inflate(R.layout.waiting_for_proxy_dialog, null)); @@ -75,6 +55,12 @@ public class WaitingForProxyDialog extends DialogFragment { // Create an alert dialog from the alert dialog builder. AlertDialog alertDialog = dialogBuilder.create(); + // Get a handle for the shared preferences. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + + // Get the screenshot preference. + boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); + // Disable screenshots if not allowed. if (!allowScreenshots) { // Remove the warning below that `getWindow()` might be null.