Fix warning at emptying recycle bin #742

This commit is contained in:
J-Jamet committed 2020-10-18 13:24:47 +02:00
1 parent e6a5be6c66
commit a7765cb635
7 files changed
+63 -13

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ KeePassDX(2.9)
* Save new credentials with Autofill #524
* Fix biometric issues #724 #740 #731
* Fix autofill #725 #551
* Small fixes and translations #732 #736 #737
* Small fixes and translations #732 #736 #737 #742
KeePassDX(2.8.7)
* Downgrade to Android API 29 (crash on startup with API 30 on some devices)
@@ -45,10 +45,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.fragment.app.FragmentManager
import com.google.android.material.snackbar.Snackbar
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.dialogs.DeleteNodesDialogFragment
import com.kunzisoft.keepass.activities.dialogs.GroupEditDialogFragment
import com.kunzisoft.keepass.activities.dialogs.IconPickerDialogFragment
import com.kunzisoft.keepass.activities.dialogs.SortDialogFragment
import com.kunzisoft.keepass.activities.dialogs.*
import com.kunzisoft.keepass.activities.helpers.EntrySelectionHelper
import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
import com.kunzisoft.keepass.activities.helpers.SpecialMode
@@ -754,7 +751,7 @@ class GroupActivity : LockingActivity(),
return true
}
override fun onDeleteMenuClick(nodes: List<Node>): Boolean {
private fun deleteNodes(nodes: List<Node>, recycleBin: Boolean = false): Boolean {
val database = mDatabase
// If recycle bin enabled, ensure it exists
@@ -774,13 +771,22 @@ class GroupActivity : LockingActivity(),
}
// else open the dialog to confirm deletion
else {
DeleteNodesDialogFragment.getInstance(nodes)
.show(supportFragmentManager, "deleteNodesDialogFragment")
val deleteNodesDialogFragment: DeleteNodesDialogFragment =
if (recycleBin) {
EmptyRecycleBinDialogFragment.getInstance(nodes)
} else {
DeleteNodesDialogFragment.getInstance(nodes)
}
deleteNodesDialogFragment.show(supportFragmentManager, "deleteNodesDialogFragment")
}
finishNodeAction()
return true
}
override fun onDeleteMenuClick(nodes: List<Node>): Boolean {
return deleteNodes(nodes)
}
override fun permanentlyDeleteNodes(nodes: List<Node>) {
mProgressDatabaseTaskProvider?.startDatabaseDeleteNodes(
nodes,
@@ -957,7 +963,7 @@ class GroupActivity : LockingActivity(),
R.id.menu_empty_recycle_bin -> {
mCurrentGroup?.getChildren()?.let { listChildren ->
// Automatically delete all elements
onDeleteMenuClick(listChildren)
deleteNodes(listChildren, true)
}
return true
}
@@ -31,7 +31,7 @@ import com.kunzisoft.keepass.notifications.DatabaseTaskNotificationService
import com.kunzisoft.keepass.notifications.DatabaseTaskNotificationService.Companion.getBundleFromListNodes
import com.kunzisoft.keepass.notifications.DatabaseTaskNotificationService.Companion.getListNodesFromBundle
class DeleteNodesDialogFragment : DialogFragment() {
open class DeleteNodesDialogFragment : DialogFragment() {
private var mNodesToDelete: List<Node> = ArrayList()
private var mListener: DeleteNodeListener? = null
@@ -51,6 +51,10 @@ class DeleteNodesDialogFragment : DialogFragment() {
super.onDetach()
}
protected open fun retrieveMessage(): String {
return getString(R.string.warning_permanently_delete_nodes)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
arguments?.apply {
@@ -68,7 +72,7 @@ class DeleteNodesDialogFragment : DialogFragment() {
// Use the Builder class for convenient dialog construction
val builder = AlertDialog.Builder(activity)
builder.setMessage(getString(R.string.warning_permanently_delete_nodes))
builder.setMessage(retrieveMessage())
builder.setPositiveButton(android.R.string.ok) { _, _ ->
mListener?.permanentlyDeleteNodes(mNodesToDelete)
}
@@ -0,0 +1,39 @@
/*
* Copyright 2020 Jeremy Jamet / Kunzisoft.
*
* This file is part of KeePassDX.
*
* KeePassDX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KeePassDX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.kunzisoft.keepass.activities.dialogs
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.database.element.node.Node
import com.kunzisoft.keepass.notifications.DatabaseTaskNotificationService.Companion.getBundleFromListNodes
class EmptyRecycleBinDialogFragment : DeleteNodesDialogFragment() {
override fun retrieveMessage(): String {
return getString(R.string.warning_empty_recycle_bin)
}
companion object {
fun getInstance(nodesToDelete: List<Node>): EmptyRecycleBinDialogFragment {
return EmptyRecycleBinDialogFragment().apply {
arguments = getBundleFromListNodes(nodesToDelete)
}
}
}
}
+1
View File
@@ -260,6 +260,7 @@
<string name="warning_empty_password">Continue without password unlocking protection?</string>
<string name="warning_no_encryption_key">Continue without encryption key?</string>
<string name="warning_permanently_delete_nodes">Permanently delete selected nodes?</string>
<string name="warning_empty_recycle_bin">Permanently delete all nodes from the recycle bin?</string>
<string name="warning_file_too_big">A KeePass database is supposed to contain only small utility files (such as PGP key files).\n\nYour database may get very large and reduce performance with this upload.</string>
<string name="warning_replace_file">Uploading this file will replace the existing one.</string>
<string name="warning_sure_add_file">Add the file anyway?</string>
@@ -2,4 +2,4 @@
* Save new credentials with Autofill #524
* Fix biometric issues #724 #740 #731
* Fix autofill #725 #551
* Small fixes and translations #732 #736 #737
* Small fixes and translations #732 #736 #737 #742
@@ -2,4 +2,4 @@
* Sauvegarde de nouveaux identifiants avec le remplissage automatique #524
* Correction de problèmes biométriques #724 #740 #731
* Correction de l'autofill #725 #551
* Petites corrections et traductions #732 #736 #737
* Petites corrections et traductions #732 #736 #737 #742