mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-25 19:41:34 -08:00
Encapsulate database in fragments
This commit is contained in:
1 parent
3536629dd9
commit
ed82c36628
25 files changed
+228
-228
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package com.kunzisoft.keepass.activities.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import com.kunzisoft.keepass.activities.stylish.StylishFragment
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
|
||||
abstract class DatabaseFragment : StylishFragment() {
|
||||
|
||||
protected var mDatabase: Database? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,8 @@ import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.EntryEditActivity
|
||||
import com.kunzisoft.keepass.activities.dialogs.GeneratePasswordDialogFragment
|
||||
import com.kunzisoft.keepass.activities.lock.resetAppTimeoutWhenViewFocusedOrChanged
|
||||
import com.kunzisoft.keepass.activities.stylish.StylishFragment
|
||||
import com.kunzisoft.keepass.adapters.EntryAttachmentsItemsAdapter
|
||||
import com.kunzisoft.keepass.database.element.Attachment
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.education.EntryEditActivityEducation
|
||||
@@ -53,7 +51,7 @@ import com.kunzisoft.keepass.view.applyFontVisibility
|
||||
import com.kunzisoft.keepass.view.collapse
|
||||
import com.kunzisoft.keepass.view.expand
|
||||
|
||||
class EntryEditFragment: StylishFragment() {
|
||||
class EntryEditFragment: DatabaseFragment() {
|
||||
|
||||
private lateinit var entryTitleLayoutView: TextInputLayout
|
||||
private lateinit var entryTitleView: EditText
|
||||
@@ -87,13 +85,9 @@ class EntryEditFragment: StylishFragment() {
|
||||
private var mLastFocusedEditField: FocusedEditField? = null
|
||||
private var mExtraViewToRequestFocus: EditText? = null
|
||||
|
||||
private var mDatabase: Database? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
|
||||
val rootView = inflater.cloneInContext(contextThemed)
|
||||
.inflate(R.layout.fragment_entry_edit_contents, container, false)
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ import android.view.ViewGroup
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.stylish.StylishFragment
|
||||
import com.kunzisoft.keepass.adapters.IconPickerAdapter
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageDraw
|
||||
import com.kunzisoft.keepass.viewmodels.IconPickerViewModel
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -38,15 +36,13 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
abstract class IconFragment<T: IconImageDraw> : StylishFragment(),
|
||||
abstract class IconFragment<T: IconImageDraw> : DatabaseFragment(),
|
||||
IconPickerAdapter.IconPickerListener<T> {
|
||||
|
||||
protected lateinit var iconsGridView: RecyclerView
|
||||
protected lateinit var iconPickerAdapter: IconPickerAdapter<T>
|
||||
protected var iconActionSelectionMode = false
|
||||
|
||||
protected var mDatabase: Database? = null
|
||||
|
||||
protected val iconPickerViewModel: IconPickerViewModel by activityViewModels()
|
||||
|
||||
abstract fun retrieveMainLayoutId(): Int
|
||||
@@ -56,8 +52,6 @@ abstract class IconFragment<T: IconImageDraw> : StylishFragment(),
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
|
||||
// Retrieve the textColor to tint the icon
|
||||
val ta = contextThemed?.obtainStyledAttributes(intArrayOf(android.R.attr.textColor))
|
||||
val tintColor = ta?.getColor(0, Color.BLACK) ?: Color.BLACK
|
||||
|
||||
@@ -9,20 +9,16 @@ import androidx.viewpager2.widget.ViewPager2
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.stylish.StylishFragment
|
||||
import com.kunzisoft.keepass.adapters.IconPickerPagerAdapter
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.viewmodels.IconPickerViewModel
|
||||
|
||||
class IconPickerFragment : StylishFragment() {
|
||||
class IconPickerFragment : DatabaseFragment() {
|
||||
|
||||
private var iconPickerPagerAdapter: IconPickerPagerAdapter? = null
|
||||
private lateinit var viewPager: ViewPager2
|
||||
|
||||
private val iconPickerViewModel: IconPickerViewModel by activityViewModels()
|
||||
|
||||
private var mDatabase: Database? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@@ -32,8 +28,6 @@ class IconPickerFragment : StylishFragment() {
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
mDatabase = Database.getInstance()
|
||||
|
||||
viewPager = view.findViewById(R.id.icon_picker_pager)
|
||||
val tabLayout = view.findViewById<TabLayout>(R.id.icon_picker_tabs)
|
||||
iconPickerPagerAdapter = IconPickerPagerAdapter(this,
|
||||
|
||||
@@ -33,9 +33,7 @@ import com.kunzisoft.keepass.activities.dialogs.SortDialogFragment
|
||||
import com.kunzisoft.keepass.activities.helpers.EntrySelectionHelper
|
||||
import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
|
||||
import com.kunzisoft.keepass.activities.helpers.SpecialMode
|
||||
import com.kunzisoft.keepass.activities.stylish.StylishFragment
|
||||
import com.kunzisoft.keepass.adapters.NodeAdapter
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.database.element.Group
|
||||
import com.kunzisoft.keepass.database.element.SortNodeEnum
|
||||
import com.kunzisoft.keepass.database.element.node.Node
|
||||
@@ -43,7 +41,7 @@ import com.kunzisoft.keepass.database.element.node.Type
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import java.util.*
|
||||
|
||||
class ListNodesFragment : StylishFragment(), SortDialogFragment.SortSelectionListener {
|
||||
class ListNodesFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListener {
|
||||
|
||||
private var nodeClickListener: NodeClickListener? = null
|
||||
private var onScrollListener: OnScrollListener? = null
|
||||
@@ -63,8 +61,6 @@ class ListNodesFragment : StylishFragment(), SortDialogFragment.SortSelectionLis
|
||||
private var notFoundView: View? = null
|
||||
private var isASearchResult: Boolean = false
|
||||
|
||||
private var mDatabase: Database? = null
|
||||
|
||||
private var readOnly: Boolean = false
|
||||
private var specialMode: SpecialMode = SpecialMode.DEFAULT
|
||||
|
||||
@@ -100,8 +96,6 @@ class ListNodesFragment : StylishFragment(), SortDialogFragment.SortSelectionLis
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
|
||||
setHasOptionsMenu(true)
|
||||
|
||||
readOnly = ReadOnlyHelper.retrieveReadOnlyFromInstanceStateOrArguments(savedInstanceState, arguments)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.kunzisoft.keepass.settings
|
||||
|
||||
import android.content.Context
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
|
||||
abstract class DatabasePreferenceFragment : PreferenceFragmentCompat() {
|
||||
|
||||
protected var mDatabase: Database? = null
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,9 @@ package com.kunzisoft.keepass.settings
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
|
||||
class MainPreferenceFragment : PreferenceFragmentCompat() {
|
||||
class MainPreferenceFragment : DatabasePreferenceFragment() {
|
||||
|
||||
private var mCallback: Callback? = null
|
||||
|
||||
@@ -82,7 +80,7 @@ class MainPreferenceFragment : PreferenceFragmentCompat() {
|
||||
mCallback?.onNestedPreferenceSelected(NestedSettingsFragment.Screen.DATABASE)
|
||||
false
|
||||
}
|
||||
if (!Database.getInstance().loaded) {
|
||||
if (mDatabase?.loaded != true) {
|
||||
isEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.kunzisoft.keepass.activities.stylish.Stylish
|
||||
import com.kunzisoft.keepass.app.database.CipherDatabaseAction
|
||||
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
|
||||
import com.kunzisoft.keepass.biometric.AdvancedUnlockManager
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.education.Education
|
||||
import com.kunzisoft.keepass.icons.IconPackChooser
|
||||
import com.kunzisoft.keepass.settings.preference.IconPackListPreference
|
||||
@@ -55,14 +54,6 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
|
||||
|
||||
private var deleteKeysAlertDialog: AlertDialog? = null
|
||||
|
||||
private var mDatabase: Database? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
}
|
||||
|
||||
override fun onCreateScreenPreference(screen: Screen, savedInstanceState: Bundle?, rootKey: String?) {
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
|
||||
+154
-151
@@ -33,7 +33,6 @@ import com.kunzisoft.keepass.activities.dialogs.AssignMasterKeyDialogFragment
|
||||
import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
|
||||
import com.kunzisoft.keepass.database.crypto.EncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.database.crypto.kdf.KdfEngine
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
|
||||
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
|
||||
import com.kunzisoft.keepass.settings.preference.*
|
||||
@@ -43,7 +42,6 @@ import com.kunzisoft.keepass.utils.MenuUtil
|
||||
|
||||
class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
|
||||
private var mDatabase: Database = Database.getInstance()
|
||||
private var mDatabaseReadOnly: Boolean = false
|
||||
private var mDatabaseAutoSaveEnabled: Boolean = true
|
||||
|
||||
@@ -64,7 +62,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
override fun onCreateScreenPreference(screen: Screen, savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setHasOptionsMenu(true)
|
||||
|
||||
mDatabaseReadOnly = mDatabase.isReadOnly
|
||||
mDatabaseReadOnly = mDatabase?.isReadOnly == true
|
||||
|| ReadOnlyHelper.retrieveReadOnlyFromInstanceStateOrArguments(savedInstanceState, arguments)
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
@@ -85,124 +83,125 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
private fun onCreateDatabasePreference(rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.preferences_database, rootKey)
|
||||
|
||||
if (mDatabase.loaded) {
|
||||
mDatabase?.let { database ->
|
||||
if (database.loaded) {
|
||||
|
||||
val dbGeneralPrefCategory: PreferenceCategory? = findPreference(getString(R.string.database_category_general_key))
|
||||
val dbGeneralPrefCategory: PreferenceCategory? = findPreference(getString(R.string.database_category_general_key))
|
||||
|
||||
// Database name
|
||||
dbNamePref = findPreference(getString(R.string.database_name_key))
|
||||
if (mDatabase.allowName) {
|
||||
dbNamePref?.summary = mDatabase.name
|
||||
} else {
|
||||
dbGeneralPrefCategory?.removePreference(dbNamePref)
|
||||
}
|
||||
|
||||
// Database description
|
||||
dbDescriptionPref = findPreference(getString(R.string.database_description_key))
|
||||
if (mDatabase.allowDescription) {
|
||||
dbDescriptionPref?.summary = mDatabase.description
|
||||
} else {
|
||||
dbGeneralPrefCategory?.removePreference(dbDescriptionPref)
|
||||
}
|
||||
|
||||
// Database default username
|
||||
dbDefaultUsername = findPreference(getString(R.string.database_default_username_key))
|
||||
if (mDatabase.allowDefaultUsername) {
|
||||
dbDefaultUsername?.summary = mDatabase.defaultUsername
|
||||
} else {
|
||||
dbDefaultUsername?.isEnabled = false
|
||||
// TODO dbGeneralPrefCategory?.removePreference(dbDefaultUsername)
|
||||
}
|
||||
|
||||
// Database custom color
|
||||
dbCustomColorPref = findPreference(getString(R.string.database_custom_color_key))
|
||||
if (mDatabase.allowCustomColor) {
|
||||
dbCustomColorPref?.apply {
|
||||
try {
|
||||
color = Color.parseColor(mDatabase.customColor)
|
||||
summary = mDatabase.customColor
|
||||
} catch (e: Exception) {
|
||||
color = DialogColorPreference.DISABLE_COLOR
|
||||
summary = ""
|
||||
}
|
||||
// Database name
|
||||
dbNamePref = findPreference(getString(R.string.database_name_key))
|
||||
if (database.allowName) {
|
||||
dbNamePref?.summary = database.name
|
||||
} else {
|
||||
dbGeneralPrefCategory?.removePreference(dbNamePref)
|
||||
}
|
||||
} else {
|
||||
dbCustomColorPref?.isEnabled = false
|
||||
// TODO dbGeneralPrefCategory?.removePreference(dbCustomColorPref)
|
||||
}
|
||||
|
||||
// Version
|
||||
findPreference<Preference>(getString(R.string.database_version_key))
|
||||
?.summary = mDatabase.version
|
||||
// Database description
|
||||
dbDescriptionPref = findPreference(getString(R.string.database_description_key))
|
||||
if (database.allowDescription) {
|
||||
dbDescriptionPref?.summary = database.description
|
||||
} else {
|
||||
dbGeneralPrefCategory?.removePreference(dbDescriptionPref)
|
||||
}
|
||||
|
||||
val dbCompressionPrefCategory: PreferenceCategory? = findPreference(getString(R.string.database_category_data_key))
|
||||
// Database default username
|
||||
dbDefaultUsername = findPreference(getString(R.string.database_default_username_key))
|
||||
if (database.allowDefaultUsername) {
|
||||
dbDefaultUsername?.summary = database.defaultUsername
|
||||
} else {
|
||||
dbDefaultUsername?.isEnabled = false
|
||||
// TODO dbGeneralPrefCategory?.removePreference(dbDefaultUsername)
|
||||
}
|
||||
|
||||
// Database compression
|
||||
dbDataCompressionPref = findPreference(getString(R.string.database_data_compression_key))
|
||||
if (mDatabase.allowDataCompression) {
|
||||
dbDataCompressionPref?.summary = (mDatabase.compressionAlgorithm
|
||||
?: CompressionAlgorithm.None).getName(resources)
|
||||
} else {
|
||||
dbCompressionPrefCategory?.isVisible = false
|
||||
}
|
||||
|
||||
val dbRecycleBinPrefCategory: PreferenceCategory? = findPreference(getString(R.string.database_category_recycle_bin_key))
|
||||
recycleBinGroupPref = findPreference(getString(R.string.recycle_bin_group_key))
|
||||
|
||||
// Recycle bin
|
||||
if (mDatabase.allowConfigurableRecycleBin) {
|
||||
val recycleBinEnablePref: SwitchPreference? = findPreference(getString(R.string.recycle_bin_enable_key))
|
||||
recycleBinEnablePref?.apply {
|
||||
isChecked = mDatabase.isRecycleBinEnabled
|
||||
isEnabled = if (!mDatabaseReadOnly) {
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val recycleBinEnabled = newValue as Boolean
|
||||
mDatabase.isRecycleBinEnabled = recycleBinEnabled
|
||||
if (recycleBinEnabled) {
|
||||
mDatabase.ensureRecycleBinExists(resources)
|
||||
} else {
|
||||
mDatabase.removeRecycleBin()
|
||||
}
|
||||
refreshRecycleBinGroup()
|
||||
// Save the database if not in readonly mode
|
||||
(context as SettingsActivity?)?.
|
||||
mProgressDatabaseTaskProvider?.startDatabaseSave(mDatabaseAutoSaveEnabled)
|
||||
true
|
||||
// Database custom color
|
||||
dbCustomColorPref = findPreference(getString(R.string.database_custom_color_key))
|
||||
if (database.allowCustomColor) {
|
||||
dbCustomColorPref?.apply {
|
||||
try {
|
||||
color = Color.parseColor(database.customColor)
|
||||
summary = database.customColor
|
||||
} catch (e: Exception) {
|
||||
color = DialogColorPreference.DISABLE_COLOR
|
||||
summary = ""
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
dbCustomColorPref?.isEnabled = false
|
||||
// TODO dbGeneralPrefCategory?.removePreference(dbCustomColorPref)
|
||||
}
|
||||
// Recycle Bin group
|
||||
refreshRecycleBinGroup()
|
||||
|
||||
// Version
|
||||
findPreference<Preference>(getString(R.string.database_version_key))
|
||||
?.summary = database.version
|
||||
|
||||
val dbCompressionPrefCategory: PreferenceCategory? = findPreference(getString(R.string.database_category_data_key))
|
||||
|
||||
// Database compression
|
||||
dbDataCompressionPref = findPreference(getString(R.string.database_data_compression_key))
|
||||
if (database.allowDataCompression) {
|
||||
dbDataCompressionPref?.summary = (database.compressionAlgorithm
|
||||
?: CompressionAlgorithm.None).getName(resources)
|
||||
} else {
|
||||
dbCompressionPrefCategory?.isVisible = false
|
||||
}
|
||||
|
||||
val dbRecycleBinPrefCategory: PreferenceCategory? = findPreference(getString(R.string.database_category_recycle_bin_key))
|
||||
recycleBinGroupPref = findPreference(getString(R.string.recycle_bin_group_key))
|
||||
|
||||
// Recycle bin
|
||||
if (database.allowConfigurableRecycleBin) {
|
||||
val recycleBinEnablePref: SwitchPreference? = findPreference(getString(R.string.recycle_bin_enable_key))
|
||||
recycleBinEnablePref?.apply {
|
||||
isChecked = database.isRecycleBinEnabled
|
||||
isEnabled = if (!mDatabaseReadOnly) {
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val recycleBinEnabled = newValue as Boolean
|
||||
database.isRecycleBinEnabled = recycleBinEnabled
|
||||
if (recycleBinEnabled) {
|
||||
database.ensureRecycleBinExists(resources)
|
||||
} else {
|
||||
database.removeRecycleBin()
|
||||
}
|
||||
refreshRecycleBinGroup()
|
||||
// Save the database if not in readonly mode
|
||||
(context as SettingsActivity?)?.mProgressDatabaseTaskProvider?.startDatabaseSave(mDatabaseAutoSaveEnabled)
|
||||
true
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// Recycle Bin group
|
||||
refreshRecycleBinGroup()
|
||||
} else {
|
||||
dbRecycleBinPrefCategory?.isVisible = false
|
||||
}
|
||||
|
||||
// History
|
||||
findPreference<PreferenceCategory>(getString(R.string.database_category_history_key))
|
||||
?.isVisible = database.manageHistory == true
|
||||
|
||||
// Max history items
|
||||
dbMaxHistoryItemsPref = findPreference<InputNumberPreference>(getString(R.string.max_history_items_key))?.apply {
|
||||
summary = database.historyMaxItems.toString()
|
||||
}
|
||||
|
||||
// Max history size
|
||||
dbMaxHistorySizePref = findPreference<InputNumberPreference>(getString(R.string.max_history_size_key))?.apply {
|
||||
summary = database.historyMaxSize.toString()
|
||||
}
|
||||
|
||||
} else {
|
||||
dbRecycleBinPrefCategory?.isVisible = false
|
||||
Log.e(javaClass.name, "Database isn't ready")
|
||||
}
|
||||
|
||||
// History
|
||||
findPreference<PreferenceCategory>(getString(R.string.database_category_history_key))
|
||||
?.isVisible = mDatabase.manageHistory == true
|
||||
|
||||
// Max history items
|
||||
dbMaxHistoryItemsPref = findPreference<InputNumberPreference>(getString(R.string.max_history_items_key))?.apply {
|
||||
summary = mDatabase.historyMaxItems.toString()
|
||||
}
|
||||
|
||||
// Max history size
|
||||
dbMaxHistorySizePref = findPreference<InputNumberPreference>(getString(R.string.max_history_size_key))?.apply {
|
||||
summary = mDatabase.historyMaxSize.toString()
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.e(javaClass.name, "Database isn't ready")
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshRecycleBinGroup() {
|
||||
recycleBinGroupPref?.apply {
|
||||
if (mDatabase.isRecycleBinEnabled) {
|
||||
summary = mDatabase.recycleBin?.title
|
||||
if (mDatabase?.isRecycleBinEnabled == true) {
|
||||
summary = mDatabase?.recycleBin?.title
|
||||
isEnabled = true
|
||||
} else {
|
||||
summary = null
|
||||
@@ -214,58 +213,62 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
private fun onCreateDatabaseSecurityPreference(rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.preferences_database_security, rootKey)
|
||||
|
||||
if (mDatabase.loaded) {
|
||||
// Encryption Algorithm
|
||||
mEncryptionAlgorithmPref = findPreference<DialogListExplanationPreference>(getString(R.string.encryption_algorithm_key))?.apply {
|
||||
summary = mDatabase.getEncryptionAlgorithmName()
|
||||
}
|
||||
mDatabase?.let { database ->
|
||||
if (database.loaded) {
|
||||
// Encryption Algorithm
|
||||
mEncryptionAlgorithmPref = findPreference<DialogListExplanationPreference>(getString(R.string.encryption_algorithm_key))?.apply {
|
||||
summary = database.getEncryptionAlgorithmName()
|
||||
}
|
||||
|
||||
// Key derivation function
|
||||
mKeyDerivationPref = findPreference<DialogListExplanationPreference>(getString(R.string.key_derivation_function_key))?.apply {
|
||||
summary = mDatabase.getKeyDerivationName()
|
||||
}
|
||||
// Key derivation function
|
||||
mKeyDerivationPref = findPreference<DialogListExplanationPreference>(getString(R.string.key_derivation_function_key))?.apply {
|
||||
summary = database.getKeyDerivationName()
|
||||
}
|
||||
|
||||
// Round encryption
|
||||
mRoundPref = findPreference<InputKdfNumberPreference>(getString(R.string.transform_rounds_key))?.apply {
|
||||
summary = mDatabase.numberKeyEncryptionRounds.toString()
|
||||
}
|
||||
// Round encryption
|
||||
mRoundPref = findPreference<InputKdfNumberPreference>(getString(R.string.transform_rounds_key))?.apply {
|
||||
summary = database.numberKeyEncryptionRounds.toString()
|
||||
}
|
||||
|
||||
// Memory Usage
|
||||
mMemoryPref = findPreference<InputKdfSizePreference>(getString(R.string.memory_usage_key))?.apply {
|
||||
summary = mDatabase.memoryUsage.toString()
|
||||
}
|
||||
// Memory Usage
|
||||
mMemoryPref = findPreference<InputKdfSizePreference>(getString(R.string.memory_usage_key))?.apply {
|
||||
summary = database.memoryUsage.toString()
|
||||
}
|
||||
|
||||
// Parallelism
|
||||
mParallelismPref = findPreference<InputKdfNumberPreference>(getString(R.string.parallelism_key))?.apply {
|
||||
summary = mDatabase.parallelism.toString()
|
||||
// Parallelism
|
||||
mParallelismPref = findPreference<InputKdfNumberPreference>(getString(R.string.parallelism_key))?.apply {
|
||||
summary = database.parallelism.toString()
|
||||
}
|
||||
} else {
|
||||
Log.e(javaClass.name, "Database isn't ready")
|
||||
}
|
||||
} else {
|
||||
Log.e(javaClass.name, "Database isn't ready")
|
||||
}
|
||||
}
|
||||
|
||||
private fun onCreateDatabaseMasterKeyPreference(rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.preferences_database_master_key, rootKey)
|
||||
|
||||
if (mDatabase.loaded) {
|
||||
findPreference<Preference>(getString(R.string.settings_database_change_credentials_key))?.apply {
|
||||
isEnabled = if (!mDatabaseReadOnly) {
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
AssignMasterKeyDialogFragment.getInstance(mDatabase.allowNoMasterKey)
|
||||
.show(parentFragmentManager, "passwordDialog")
|
||||
mDatabase?.let { database ->
|
||||
if (database.loaded) {
|
||||
findPreference<Preference>(getString(R.string.settings_database_change_credentials_key))?.apply {
|
||||
isEnabled = if (!mDatabaseReadOnly) {
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
AssignMasterKeyDialogFragment.getInstance(database.allowNoMasterKey)
|
||||
.show(parentFragmentManager, "passwordDialog")
|
||||
false
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
Log.e(javaClass.name, "Database isn't ready")
|
||||
}
|
||||
} else {
|
||||
Log.e(javaClass.name, "Database isn't ready")
|
||||
}
|
||||
}
|
||||
|
||||
private val colorSelectedListener: ((Boolean, Int)-> Unit)? = { enable, color ->
|
||||
private val colorSelectedListener: ((Boolean, Int)-> Unit) = { enable, color ->
|
||||
dbCustomColorPref?.summary = ChromaUtil.getFormattedColorString(color, false)
|
||||
if (enable) {
|
||||
dbCustomColorPref?.color = color
|
||||
@@ -304,7 +307,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newName
|
||||
} else {
|
||||
mDatabase.name = oldName
|
||||
mDatabase?.name = oldName
|
||||
oldName
|
||||
}
|
||||
dbNamePref?.summary = nameToShow
|
||||
@@ -316,7 +319,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newDescription
|
||||
} else {
|
||||
mDatabase.description = oldDescription
|
||||
mDatabase?.description = oldDescription
|
||||
oldDescription
|
||||
}
|
||||
dbDescriptionPref?.summary = descriptionToShow
|
||||
@@ -328,7 +331,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newDefaultUsername
|
||||
} else {
|
||||
mDatabase.defaultUsername = oldDefaultUsername
|
||||
mDatabase?.defaultUsername = oldDefaultUsername
|
||||
oldDefaultUsername
|
||||
}
|
||||
dbDefaultUsername?.summary = defaultUsernameToShow
|
||||
@@ -341,7 +344,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newColor
|
||||
} else {
|
||||
mDatabase.customColor = oldColor
|
||||
mDatabase?.customColor = oldColor
|
||||
oldColor
|
||||
}
|
||||
dbCustomColorPref?.summary = defaultColorToShow
|
||||
@@ -353,7 +356,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newCompression
|
||||
} else {
|
||||
mDatabase.compressionAlgorithm = oldCompression
|
||||
mDatabase?.compressionAlgorithm = oldCompression
|
||||
oldCompression
|
||||
}
|
||||
dbDataCompressionPref?.summary = algorithmToShow.getName(resources)
|
||||
@@ -365,7 +368,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newMaxHistoryItems
|
||||
} else {
|
||||
mDatabase.historyMaxItems = oldMaxHistoryItems
|
||||
mDatabase?.historyMaxItems = oldMaxHistoryItems
|
||||
oldMaxHistoryItems
|
||||
}
|
||||
dbMaxHistoryItemsPref?.summary = maxHistoryItemsToShow.toString()
|
||||
@@ -377,7 +380,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newMaxHistorySize
|
||||
} else {
|
||||
mDatabase.historyMaxSize = oldMaxHistorySize
|
||||
mDatabase?.historyMaxSize = oldMaxHistorySize
|
||||
oldMaxHistorySize
|
||||
}
|
||||
dbMaxHistorySizePref?.summary = maxHistorySizeToShow.toString()
|
||||
@@ -395,7 +398,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newEncryption
|
||||
} else {
|
||||
mDatabase.encryptionAlgorithm = oldEncryption
|
||||
mDatabase?.encryptionAlgorithm = oldEncryption
|
||||
oldEncryption
|
||||
}
|
||||
mEncryptionAlgorithmPref?.summary = algorithmToShow.toString()
|
||||
@@ -407,7 +410,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newKeyDerivationEngine
|
||||
} else {
|
||||
mDatabase.kdfEngine = oldKeyDerivationEngine
|
||||
mDatabase?.kdfEngine = oldKeyDerivationEngine
|
||||
oldKeyDerivationEngine
|
||||
}
|
||||
mKeyDerivationPref?.summary = kdfEngineToShow.toString()
|
||||
@@ -424,7 +427,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newIterations
|
||||
} else {
|
||||
mDatabase.numberKeyEncryptionRounds = oldIterations
|
||||
mDatabase?.numberKeyEncryptionRounds = oldIterations
|
||||
oldIterations
|
||||
}
|
||||
mRoundPref?.summary = roundsToShow.toString()
|
||||
@@ -436,7 +439,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newMemoryUsage
|
||||
} else {
|
||||
mDatabase.memoryUsage = oldMemoryUsage
|
||||
mDatabase?.memoryUsage = oldMemoryUsage
|
||||
oldMemoryUsage
|
||||
}
|
||||
mMemoryPref?.summary = memoryToShow.toString()
|
||||
@@ -448,7 +451,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
if (result.isSuccess) {
|
||||
newParallelism
|
||||
} else {
|
||||
mDatabase.parallelism = oldParallelism
|
||||
mDatabase?.parallelism = oldParallelism
|
||||
oldParallelism
|
||||
}
|
||||
mParallelismPref?.summary = parallelismToShow.toString()
|
||||
|
||||
@@ -22,14 +22,13 @@ package com.kunzisoft.keepass.settings
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.SwitchPreference
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.dialogs.UnderDevelopmentFeatureDialogFragment
|
||||
import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
|
||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
|
||||
abstract class NestedSettingsFragment : PreferenceFragmentCompat() {
|
||||
abstract class NestedSettingsFragment : DatabasePreferenceFragment() {
|
||||
|
||||
enum class Screen {
|
||||
APPLICATION, FORM_FILLING, ADVANCED_UNLOCK, APPEARANCE, DATABASE, DATABASE_SECURITY, DATABASE_MASTER_KEY
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ class DatabaseColorPreferenceDialogFragmentCompat : DatabaseSavePreferenceDialog
|
||||
val fragmentManager = childFragmentManager
|
||||
chromaColorFragment = fragmentManager.findFragmentByTag(TAG_FRAGMENT_COLORS) as ChromaColorFragment?
|
||||
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
val initColor = try {
|
||||
enableSwitchView.isChecked = true
|
||||
Color.parseColor(database.customColor)
|
||||
@@ -80,7 +80,7 @@ class DatabaseColorPreferenceDialogFragmentCompat : DatabaseSavePreferenceDialog
|
||||
|
||||
onColorSelectedListener?.invoke(customColorEnable, currentColor)
|
||||
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
val newColor = if (customColorEnable) {
|
||||
ChromaUtil.getFormattedColorString(currentColor, false)
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ class DatabaseDataCompressionPreferenceDialogFragmentCompat
|
||||
compressionAdapter.setRadioItemSelectedCallback(this)
|
||||
recyclerView.adapter = compressionAdapter
|
||||
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
compressionSelected = database.compressionAlgorithm?.apply {
|
||||
compressionAdapter.setItems(database.availableCompressionAlgorithms, this)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class DatabaseDataCompressionPreferenceDialogFragmentCompat
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
if (compressionSelected != null) {
|
||||
val newCompression = compressionSelected
|
||||
val oldCompression = database.compressionAlgorithm
|
||||
|
||||
+2
-2
@@ -27,11 +27,11 @@ class DatabaseDefaultUsernamePreferenceDialogFragmentCompat : DatabaseSavePrefer
|
||||
override fun onBindDialogView(view: View) {
|
||||
super.onBindDialogView(view)
|
||||
|
||||
inputText = database?.defaultUsername?: ""
|
||||
inputText = mDatabase?.defaultUsername?: ""
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
if (positiveResult) {
|
||||
val newDefaultUsername = inputText
|
||||
val oldDefaultUsername = database.defaultUsername
|
||||
|
||||
+2
-2
@@ -27,11 +27,11 @@ class DatabaseDescriptionPreferenceDialogFragmentCompat : DatabaseSavePreference
|
||||
override fun onBindDialogView(view: View) {
|
||||
super.onBindDialogView(view)
|
||||
|
||||
inputText = database?.description ?: ""
|
||||
inputText = mDatabase?.description ?: ""
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
if (positiveResult) {
|
||||
val newDescription = inputText
|
||||
val oldDescription = database.description
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ class DatabaseEncryptionAlgorithmPreferenceDialogFragmentCompat
|
||||
encryptionAlgorithmAdapter.setRadioItemSelectedCallback(this)
|
||||
recyclerView.adapter = encryptionAlgorithmAdapter
|
||||
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
algorithmSelected = database.encryptionAlgorithm?.apply {
|
||||
encryptionAlgorithmAdapter.setItems(database.availableEncryptionAlgorithms, this)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class DatabaseEncryptionAlgorithmPreferenceDialogFragmentCompat
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
if (algorithmSelected != null) {
|
||||
val newAlgorithm = algorithmSelected
|
||||
val oldAlgorithm = database.encryptionAlgorithm
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ class DatabaseKeyDerivationPreferenceDialogFragmentCompat
|
||||
kdfAdapter.setRadioItemSelectedCallback(this)
|
||||
recyclerView.adapter = kdfAdapter
|
||||
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
kdfEngineSelected = database.kdfEngine?.apply {
|
||||
kdfAdapter.setItems(database.availableKdfEngines, this)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class DatabaseKeyDerivationPreferenceDialogFragmentCompat
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
if (database.allowKdfModification) {
|
||||
val newKdfEngine = kdfEngineSelected
|
||||
val oldKdfEngine = database.kdfEngine
|
||||
|
||||
+2
-2
@@ -27,12 +27,12 @@ class DatabaseNamePreferenceDialogFragmentCompat : DatabaseSavePreferenceDialogF
|
||||
override fun onBindDialogView(view: View) {
|
||||
super.onBindDialogView(view)
|
||||
|
||||
inputText = database?.name ?: ""
|
||||
inputText = mDatabase?.name ?: ""
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
val newName = inputText
|
||||
val oldName = database.name
|
||||
database.name = newName
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class DatabaseRemoveUnlinkedDataPreferenceDialogFragmentCompat : DatabaseSavePre
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
database?.let { _ ->
|
||||
mDatabase?.let { _ ->
|
||||
if (positiveResult) {
|
||||
mProgressDatabaseTaskProvider?.startDatabaseRemoveUnlinkedData(mDatabaseAutoSaveEnable)
|
||||
}
|
||||
|
||||
-9
@@ -20,24 +20,15 @@
|
||||
package com.kunzisoft.keepass.settings.preferencedialogfragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.kunzisoft.keepass.database.action.ProgressDatabaseTaskProvider
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.settings.SettingsActivity
|
||||
|
||||
abstract class DatabaseSavePreferenceDialogFragmentCompat : InputPreferenceDialogFragmentCompat() {
|
||||
|
||||
protected var database: Database? = null
|
||||
protected var mDatabaseAutoSaveEnable = true
|
||||
protected var mProgressDatabaseTaskProvider: ProgressDatabaseTaskProvider? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
this.database = Database.getInstance()
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
// Attach dialog thread to start action
|
||||
|
||||
+10
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.settings.preferencedialogfragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
@@ -29,6 +30,7 @@ import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
|
||||
abstract class InputPreferenceDialogFragmentCompat : PreferenceDialogFragmentCompat() {
|
||||
|
||||
@@ -39,6 +41,14 @@ abstract class InputPreferenceDialogFragmentCompat : PreferenceDialogFragmentCom
|
||||
|
||||
private var mOnInputTextEditorActionListener: TextView.OnEditorActionListener? = null
|
||||
|
||||
protected var mDatabase: Database? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mDatabase = Database.getInstance()
|
||||
}
|
||||
|
||||
var inputText: String
|
||||
get() = this.inputTextView?.text?.toString() ?: ""
|
||||
set(inputText) {
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ class MaxHistoryItemsPreferenceDialogFragmentCompat : DatabaseSavePreferenceDial
|
||||
super.onBindDialogView(view)
|
||||
|
||||
setExplanationText(R.string.max_history_items_summary)
|
||||
database?.historyMaxItems?.let { maxItemsDatabase ->
|
||||
mDatabase?.historyMaxItems?.let { maxItemsDatabase ->
|
||||
inputText = maxItemsDatabase.toString()
|
||||
setSwitchAction({ isChecked ->
|
||||
inputText = if (!isChecked) {
|
||||
@@ -44,7 +44,7 @@ class MaxHistoryItemsPreferenceDialogFragmentCompat : DatabaseSavePreferenceDial
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
var maxHistoryItems: Int = try {
|
||||
inputText.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ class MaxHistorySizePreferenceDialogFragmentCompat : DatabaseSavePreferenceDialo
|
||||
super.onBindDialogView(view)
|
||||
|
||||
setExplanationText(R.string.max_history_size_summary)
|
||||
database?.historyMaxSize?.let { maxItemsDatabase ->
|
||||
mDatabase?.historyMaxSize?.let { maxItemsDatabase ->
|
||||
dataByte = DataByte(maxItemsDatabase, DataByte.ByteFormat.BYTE)
|
||||
.toBetterByteFormat()
|
||||
inputText = dataByte.number.toString()
|
||||
@@ -60,7 +60,7 @@ class MaxHistorySizePreferenceDialogFragmentCompat : DatabaseSavePreferenceDialo
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
val maxHistorySize: Long = try {
|
||||
inputText.toLong()
|
||||
} catch (e: NumberFormatException) {
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ class MemoryUsagePreferenceDialogFragmentCompat : DatabaseSavePreferenceDialogFr
|
||||
|
||||
setExplanationText(R.string.memory_usage_explanation)
|
||||
|
||||
val memoryBytes = database?.memoryUsage ?: MIN_MEMORY_USAGE
|
||||
val memoryBytes = mDatabase?.memoryUsage ?: MIN_MEMORY_USAGE
|
||||
dataByte = DataByte(memoryBytes, DataByte.ByteFormat.BYTE)
|
||||
.toBetterByteFormat()
|
||||
inputText = dataByte.number.toString()
|
||||
@@ -42,7 +42,7 @@ class MemoryUsagePreferenceDialogFragmentCompat : DatabaseSavePreferenceDialogFr
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
var newMemoryUsage: Long = try {
|
||||
inputText.toLong()
|
||||
} catch (e: NumberFormatException) {
|
||||
|
||||
+2
-2
@@ -29,12 +29,12 @@ class ParallelismPreferenceDialogFragmentCompat : DatabaseSavePreferenceDialogFr
|
||||
super.onBindDialogView(view)
|
||||
|
||||
setExplanationText(R.string.parallelism_explanation)
|
||||
inputText = database?.parallelism?.toString() ?: MIN_PARALLELISM.toString()
|
||||
inputText = mDatabase?.parallelism?.toString() ?: MIN_PARALLELISM.toString()
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
val parallelism: Long = try {
|
||||
inputText.toLong()
|
||||
} catch (e: NumberFormatException) {
|
||||
|
||||
+2
-2
@@ -30,12 +30,12 @@ class RoundsPreferenceDialogFragmentCompat : DatabaseSavePreferenceDialogFragmen
|
||||
super.onBindDialogView(view)
|
||||
|
||||
explanationText = getString(R.string.rounds_explanation)
|
||||
inputText = database?.numberKeyEncryptionRounds?.toString() ?: MIN_ITERATIONS.toString()
|
||||
inputText = mDatabase?.numberKeyEncryptionRounds?.toString() ?: MIN_ITERATIONS.toString()
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
mDatabase?.let { database ->
|
||||
var rounds: Long = try {
|
||||
inputText.toLong()
|
||||
} catch (e: NumberFormatException) {
|
||||
|
||||
Reference in new issue
Block a user