X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FEditBookmarkFolderDatabaseViewDialog.java;h=7960c68a73620f1e56e811ab268777833572d999;hp=0f7eff1a7ee12ba00e092b6a525f1c5123cb7e74;hb=74655c0cd0ba72c80ac6c48df55bc3d2f5280ad2;hpb=6bc00e202749ba0cb337be462825002ba74be8fc diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDatabaseViewDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDatabaseViewDialog.java index 0f7eff1a..7960c68a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDatabaseViewDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkFolderDatabaseViewDialog.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2019 Soren Stoutner . + * Copyright © 2016-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.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; @@ -50,6 +49,7 @@ import android.widget.Spinner; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment must be used or an error is produced on API <=22. @@ -136,21 +136,7 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment { folderCursor.moveToFirst(); // 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 (darkTheme) { - dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); - } else { - dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); - } + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog); // Set the title. dialogBuilder.setTitle(R.string.edit_folder); @@ -178,6 +164,12 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment { // Remove the warning below that `getWindow()` might be null. assert alertDialog.getWindow() != null; + // 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) { alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); @@ -196,6 +188,15 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment { EditText displayOrderEditText = alertDialog.findViewById(R.id.edit_folder_display_order_edittext); Button editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); + // Remove the incorrect lint warnings below that the views might be null. + assert databaseIdTextView != null; + assert iconRadioGroup != null; + assert currentIconImageView != null; + assert newFavoriteIconImageView != null; + assert nameEditText != null; + assert folderSpinner != null; + assert displayOrderEditText != null; + // Store the current folder values. String currentFolderName = folderCursor.getString(folderCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)); int currentDisplayOrder = folderCursor.getInt(folderCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)); @@ -410,6 +411,12 @@ public class EditBookmarkFolderDatabaseViewDialog extends DialogFragment { RadioButton currentIconRadioButton = alertDialog.findViewById(R.id.edit_folder_current_icon_radiobutton); Button editButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); + // Remove the incorrect lint warning below that the views might be null. + assert nameEditText != null; + assert folderSpinner != null; + assert displayOrderEditText != null; + assert currentIconRadioButton != null; + // Get the values from the dialog. String newFolderName = nameEditText.getText().toString(); int newParentFolderDatabaseId = (int) folderSpinner.getSelectedItemId();