X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FStoragePermissionDialog.java;h=e1d0c409eb795bcc54bed84f4239d296ab357fd8;hb=f825cc15f0383acce10bb16443e027edb869a11e;hp=4743f9be21ce88ea0b5c5ec9d9cbe207623b0c9e;hpb=8f7e9b7db429568e26f00bc2eef88402d722bec7;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/StoragePermissionDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/StoragePermissionDialog.java index 4743f9be..e1d0c409 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/StoragePermissionDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/StoragePermissionDialog.java @@ -19,16 +19,17 @@ package com.stoutner.privacybrowser.dialogs; -import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.WindowManager; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import com.stoutner.privacybrowser.R; @@ -37,8 +38,9 @@ public class StoragePermissionDialog extends DialogFragment { // Define the save type constants. public static final int OPEN = 0; public static final int SAVE_URL = 1; - public static final int SAVE_AS_ARCHIVE = 2; - public static final int SAVE_AS_IMAGE = 3; + public static final int SAVE_ARCHIVE = 2; + public static final int SAVE_TEXT = 3; + public static final int SAVE_IMAGE = 4; // The listener is used in `onAttach()` and `onCreateDialog()`. private StoragePermissionDialogListener storagePermissionDialogListener; @@ -86,23 +88,17 @@ public class StoragePermissionDialog extends DialogFragment { // Get the save type. int requestType = arguments.getInt("request_type"); - // 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); - // Use a builder to create the alert dialog. - AlertDialog.Builder dialogBuilder; + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog); + + // Get the current theme status. + int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - // Set the style and the icon according to the theme. - if (darkTheme) { - dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); - dialogBuilder.setIcon(R.drawable.import_export_dark); + // Set the icon according to the theme. + if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { + dialogBuilder.setIcon(R.drawable.import_export_night); } else { - dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); - dialogBuilder.setIcon(R.drawable.import_export_light); + dialogBuilder.setIcon(R.drawable.import_export_day); } // Set the title. @@ -120,6 +116,12 @@ public class StoragePermissionDialog extends DialogFragment { // Create an alert dialog from the builder. final AlertDialog alertDialog = dialogBuilder.create(); + // Get a handle for the shared preferences. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); + + // 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.