mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: Add warning for KeyFile length #1780
This commit is contained in:
@@ -159,9 +159,7 @@ class SetMainCredentialDialogFragment : DatabaseDialogFragment() {
|
||||
keyFileSelectionView.error = null
|
||||
keyFileCheckBox.isChecked = true
|
||||
keyFileSelectionView.uri = pathUri
|
||||
if (lengthFile <= 0L) {
|
||||
showEmptyKeyFileConfirmationDialog()
|
||||
}
|
||||
showLengthKeyFileConfirmationDialog(lengthFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,21 +337,31 @@ class SetMainCredentialDialogFragment : DatabaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showEmptyKeyFileConfirmationDialog() {
|
||||
private fun showLengthKeyFileConfirmationDialog(length: Long) {
|
||||
activity?.let {
|
||||
val builder = AlertDialog.Builder(it)
|
||||
builder.setMessage(SpannableStringBuilder().apply {
|
||||
append(getString(R.string.warning_empty_keyfile))
|
||||
append("\n\n")
|
||||
append(getString(R.string.warning_empty_keyfile_explanation))
|
||||
append("\n\n")
|
||||
append(getString(R.string.warning_sure_add_file))
|
||||
})
|
||||
.setPositiveButton(android.R.string.ok) { _, _ -> }
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ ->
|
||||
keyFileCheckBox.isChecked = false
|
||||
keyFileSelectionView.uri = null
|
||||
}
|
||||
var warning = false
|
||||
if (length <= 0L) {
|
||||
warning = true
|
||||
append("\n\n")
|
||||
append(getString(R.string.warning_empty_keyfile))
|
||||
} else if (length > 10485760L) {
|
||||
warning = true
|
||||
append("\n\n")
|
||||
append(getString(R.string.warning_large_keyfile))
|
||||
}
|
||||
if (warning) {
|
||||
append("\n\n")
|
||||
append(getString(R.string.warning_sure_add_file))
|
||||
}
|
||||
})
|
||||
.setPositiveButton(android.R.string.ok) { _, _ -> }
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ ->
|
||||
keyFileCheckBox.isChecked = false
|
||||
keyFileSelectionView.uri = null
|
||||
}
|
||||
mEmptyKeyFileConfirmationDialog = builder.create()
|
||||
mEmptyKeyFileConfirmationDialog?.show()
|
||||
}
|
||||
|
||||
@@ -373,6 +373,7 @@
|
||||
<string name="warning_remove_unlinked_attachment">Removing unlinked data may decrease the size of your database but may also delete data used for KeePass plugins.</string>
|
||||
<string name="warning_sure_remove_data">Remove this data anyway?</string>
|
||||
<string name="warning_empty_keyfile">It is not recommended to add an empty keyfile.</string>
|
||||
<string name="warning_large_keyfile">It is not recommended to add a large keyfile, this may prevent the database from opening.</string>
|
||||
<string name="warning_empty_keyfile_explanation">The content of the keyfile should never be changed, and in the best case, should contain randomly generated data.</string>
|
||||
<string name="warning_database_info_changed">The information contained in your database file has been modified outside the app.</string>
|
||||
<string name="warning_database_info_changed_options">Merge the data, overwrite the external modifications by saving the database or reload it with the latest changes.</string>
|
||||
|
||||
Reference in New Issue
Block a user