]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/AboutViewSourceDialog.java
Release 3.3.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / AboutViewSourceDialog.java
index e4f558b6032ee65fcbe4200e9fce386f660e6e1d..bc565a656037d8df278caedfd1eba6ae73d34300 100644 (file)
@@ -21,13 +21,14 @@ package com.stoutner.privacybrowser.dialogs;
 
 import android.app.AlertDialog;
 import android.app.Dialog;
+import android.content.Context;
 import android.content.SharedPreferences;
 import android.os.Bundle;
-import android.preference.PreferenceManager;
 import android.view.WindowManager;
 
 import androidx.annotation.NonNull;
 import androidx.fragment.app.DialogFragment;
+import androidx.preference.PreferenceManager;
 
 import com.stoutner.privacybrowser.R;
 
@@ -35,8 +36,14 @@ public class AboutViewSourceDialog extends DialogFragment {
     @Override
     @NonNull
     public Dialog onCreateDialog(Bundle savedInstanceState) {
+        // Get the context.
+        Context context = getContext();
+
+        // Remove the incorrect lint warning below that the context might be null.
+        assert context != null;
+
         // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
 
         // Get the screenshot and theme preferences.
         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
@@ -64,7 +71,7 @@ public class AboutViewSourceDialog extends DialogFragment {
         dialogBuilder.setMessage(R.string.about_view_source_message);
 
         // Create an alert dialog from the alert dialog builder.
-        final AlertDialog alertDialog = dialogBuilder.create();
+        AlertDialog alertDialog = dialogBuilder.create();
 
         // Disable screenshots if not allowed.
         if (!allowScreenshots) {
@@ -75,7 +82,7 @@ public class AboutViewSourceDialog extends DialogFragment {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
-        // `onCreateDialog` requires the return of an `AlertDialog`.
+        // Return the alert dialog.
         return alertDialog;
     }
 }