]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/SaveLogcatDialog.java
Make first-party cookies tab aware.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / SaveLogcatDialog.java
index 4faafcbaf901ee424ee89d491eadc3b6b359f6e5..ec1ef33c3648f1453a0823ca02f0417f096e15d0 100644 (file)
@@ -26,15 +26,13 @@ import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
+import android.preference.PreferenceManager;
 import android.provider.DocumentsContract;
-import android.support.annotation.NonNull;
-import android.support.v4.content.ContextCompat;
-// `AppCompatDialogFragment` is required instead of `DialogFragment` or an error is produced on API <=22.  It is also required for the browser button to work correctly.
-import android.support.v7.app.AppCompatDialogFragment;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.view.View;
@@ -43,17 +41,20 @@ import android.widget.Button;
 import android.widget.EditText;
 import android.widget.TextView;
 
+import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;  // The AndroidX dialog fragment is required or an error is produced on API <=22.  It is also required for the browse button to work correctly.
+
 import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.activities.MainWebViewActivity;
 
-public class SaveLogcatDialog extends AppCompatDialogFragment {
+public class SaveLogcatDialog extends DialogFragment {
     // Instantiate the class variables.
     private SaveLogcatListener saveLogcatListener;
     private Context parentContext;
 
     // The public interface is used to send information back to the parent activity.
     public interface SaveLogcatListener {
-        void onSaveLogcat(AppCompatDialogFragment dialogFragment);
+        void onSaveLogcat(DialogFragment dialogFragment);
     }
 
     public void onAttach(Context context) {
@@ -75,8 +76,15 @@ public class SaveLogcatDialog extends AppCompatDialogFragment {
         // Use an alert dialog builder to create the alert dialog.
         AlertDialog.Builder dialogBuilder;
 
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+        // Get the screenshot and theme preferences.
+        boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+        boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
         // Set the style according to the theme.
-        if (MainWebViewActivity.darkTheme) {
+        if (darkTheme) {
             dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
         } else {
             dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
@@ -92,7 +100,7 @@ public class SaveLogcatDialog extends AppCompatDialogFragment {
         dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.save_logcat_dialog, null));
 
         // Set the icon according to the theme.
-        if (MainWebViewActivity.darkTheme) {
+        if (darkTheme) {
             dialogBuilder.setIcon(R.drawable.save_dialog_dark);
         } else {
             dialogBuilder.setIcon(R.drawable.save_dialog_light);
@@ -116,7 +124,7 @@ public class SaveLogcatDialog extends AppCompatDialogFragment {
         assert alertDialog.getWindow() != null;
 
         // Disable screenshots if not allowed.
-        if (!MainWebViewActivity.allowScreenshots) {
+        if (!allowScreenshots) {
             alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         }
 
@@ -194,4 +202,4 @@ public class SaveLogcatDialog extends AppCompatDialogFragment {
         // Return the alert dialog.
         return alertDialog;
     }
-}
+}
\ No newline at end of file