]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.java
Switch to the new Day/Night theme. https://redmine.stoutner.com/issues/522
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / WaitingForProxyDialog.java
index 08e39212a6418bda7526c3f5a32bdc583dd69887..b413584e5786bbe2e1e2bed797cdb64febe94ba9 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -20,7 +20,6 @@
 package com.stoutner.privacybrowser.dialogs;
 
 import android.annotation.SuppressLint;
 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;
 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) {
     @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.
 
         // 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.
 
         // 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));
 
         // 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();
 
         // 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.
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
             // Remove the warning below that `getWindow()` might be null.