X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FCreateBookmarkFolderDialog.kt;h=d5fd6d82d8390996022a5183d03483fa01efc934;hb=5702947e2275caf08ec6683de117d19e924f0492;hp=83670bc8923b66b1ddb5fc0f8244b6efc042287f;hpb=74655c0cd0ba72c80ac6c48df55bc3d2f5280ad2;p=PrivacyBrowserAndroid.git 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..d5fd6d82 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkFolderDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2020 Soren Stoutner . + * Copyright © 2016-2021 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with Privacy Browser. If not, see . */ + package com.stoutner.privacybrowser.dialogs import android.annotation.SuppressLint @@ -42,15 +43,18 @@ import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper import java.io.ByteArrayOutputStream -class CreateBookmarkFolderDialog: DialogFragment() { +// Declare the class constants. +private const val FAVORITE_ICON_BYTE_ARRAY = "favorite_icon_byte_array" + +class CreateBookmarkFolderDialog : DialogFragment() { + // Declare the class variables. + private lateinit var createBookmarkFolderListener: CreateBookmarkFolderListener + // 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()`. - private lateinit var createBookmarkFolderListener: CreateBookmarkFolderListener - override fun onAttach(context: Context) { // Run the default commands. super.onAttach(context) @@ -60,7 +64,7 @@ class CreateBookmarkFolderDialog: DialogFragment() { } companion object { - // `@JvmStatic` will no longer be required once all the code has transitioned to Kotlin. Also, the function can then be moved out of a companion object and just become a package-level function. + // `@JvmStatic` will no longer be required once all the code has transitioned to Kotlin. @JvmStatic fun createBookmarkFolder(favoriteIconBitmap: Bitmap): CreateBookmarkFolderDialog { // Create a favorite icon byte array output stream. @@ -76,7 +80,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 +93,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 +130,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) {