X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FCreateBookmarkFolderDialog.kt;h=7d4283bfe296657fc82504dac1820c9ceec5f8b2;hp=83670bc8923b66b1ddb5fc0f8244b6efc042287f;hb=bc2e180db377eedadbe1ea455d8fb311ead8f9d6;hpb=a9b4d8c78a305c2602ced2058702254ea4e3b79b diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt index 83670bc8..7d4283bf 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt @@ -42,13 +42,16 @@ import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper import java.io.ByteArrayOutputStream +// Declare the class constants. +private const val FAVORITE_ICON_BYTE_ARRAY = "favorite_icon_byte_array" + class CreateBookmarkFolderDialog: DialogFragment() { // The public interface is used to send information back to the parent activity. interface CreateBookmarkFolderListener { fun onCreateBookmarkFolder(dialogFragment: DialogFragment, favoriteIconBitmap: Bitmap) } - // The create bookmark folder listener is initialized in `onAttach()` and used in `onCreateDialog()`. + // Declare the class variables. private lateinit var createBookmarkFolderListener: CreateBookmarkFolderListener override fun onAttach(context: Context) { @@ -76,7 +79,7 @@ class CreateBookmarkFolderDialog: DialogFragment() { val argumentsBundle = Bundle() // Store the favorite icon in the bundle. - argumentsBundle.putByteArray("favorite_icon_byte_array", favoriteIconByteArray) + argumentsBundle.putByteArray(FAVORITE_ICON_BYTE_ARRAY, favoriteIconByteArray) // Create a new instance of the dialog. val createBookmarkFolderDialog = CreateBookmarkFolderDialog() @@ -89,14 +92,14 @@ class CreateBookmarkFolderDialog: DialogFragment() { } } - // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the alert dialog. + // `@SuppressLint("InflateParams")` removes the warning about using `null` as the parent view group when inflating the alert dialog. @SuppressLint("InflateParams") override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { // Get the arguments. val arguments = requireArguments() // Get the favorite icon byte array. - val favoriteIconByteArray = arguments.getByteArray("favorite_icon_byte_array")!! + val favoriteIconByteArray = arguments.getByteArray(FAVORITE_ICON_BYTE_ARRAY)!! // Convert the favorite icon byte array to a bitmap. val favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.size) @@ -126,7 +129,7 @@ class CreateBookmarkFolderDialog: DialogFragment() { val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) // Get the screenshot preference. - val allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false) + val allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false) // Disable screenshots if not allowed. if (!allowScreenshots) {