mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 16:22:31 -08:00
Fix action node
This commit is contained in:
1 parent
2de6bbc6c0
commit
88ebe58a88
16 files changed
+224
-169
No files matched your search
@@ -38,7 +38,9 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
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.GroupEditDialogFragment
|
||||
import com.kunzisoft.keepass.activities.dialogs.IconPickerDialogFragment
|
||||
@@ -68,6 +70,7 @@ import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.MenuUtil
|
||||
import com.kunzisoft.keepass.view.AddNodeButtonView
|
||||
import com.kunzisoft.keepass.view.ToolbarAction
|
||||
import com.kunzisoft.keepass.view.asError
|
||||
|
||||
class GroupActivity : LockingActivity(),
|
||||
GroupEditDialogFragment.EditGroupListener,
|
||||
@@ -78,6 +81,7 @@ class GroupActivity : LockingActivity(),
|
||||
SortDialogFragment.SortSelectionListener {
|
||||
|
||||
// Views
|
||||
private var coordinatorLayout: CoordinatorLayout? = null
|
||||
private var toolbar: Toolbar? = null
|
||||
private var searchTitleView: View? = null
|
||||
private var toolbarAction: ToolbarAction? = null
|
||||
@@ -117,6 +121,7 @@ class GroupActivity : LockingActivity(),
|
||||
setContentView(layoutInflater.inflate(R.layout.activity_group, null))
|
||||
|
||||
// Initialize views
|
||||
coordinatorLayout = findViewById(R.id.group_coordinator)
|
||||
iconView = findViewById(R.id.group_icon)
|
||||
numberChildrenView = findViewById(R.id.group_numbers)
|
||||
addNodeButtonView = findViewById(R.id.add_node_button)
|
||||
@@ -253,6 +258,14 @@ class GroupActivity : LockingActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.isSuccess) {
|
||||
result.exception?.errorId?.let { errorId ->
|
||||
coordinatorLayout?.let { coordinatorLayout ->
|
||||
Snackbar.make(coordinatorLayout, errorId, Snackbar.LENGTH_LONG).asError().show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
finishNodeAction()
|
||||
}
|
||||
}
|
||||
@@ -752,7 +765,7 @@ class GroupActivity : LockingActivity(),
|
||||
updateGroup.apply {
|
||||
// WARNING remove parent and children to keep memory
|
||||
removeParent()
|
||||
removeChildren()
|
||||
removeChildren() // TODO concurrent exception
|
||||
|
||||
title = name
|
||||
this.icon = icon // TODO custom icon
|
||||
|
||||
@@ -129,6 +129,7 @@ class ProgressDialogThread(private val activity: FragmentActivity,
|
||||
serviceConnection = null
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun registerProgressTask() {
|
||||
ProgressTaskDialogFragment.stop(activity)
|
||||
|
||||
@@ -159,6 +160,7 @@ class ProgressDialogThread(private val activity: FragmentActivity,
|
||||
bindService()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun unregisterProgressTask() {
|
||||
ProgressTaskDialogFragment.stop(activity)
|
||||
|
||||
|
||||
+5
-15
@@ -1,7 +1,6 @@
|
||||
package com.kunzisoft.keepass.database.action.node
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.database.action.SaveDatabaseRunnable
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
|
||||
@@ -17,16 +16,12 @@ abstract class ActionNodeDatabaseRunnable(
|
||||
*/
|
||||
abstract fun nodeAction()
|
||||
|
||||
protected fun saveDatabase() {
|
||||
super.run()
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
try {
|
||||
nodeAction()
|
||||
// To save the database
|
||||
super.run()
|
||||
finishRun(true)
|
||||
} catch (e: Exception) {
|
||||
Log.e("ActionNodeDBRunnable", e.message)
|
||||
finishRun(false, e.message)
|
||||
}
|
||||
nodeAction()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,11 +33,6 @@ abstract class ActionNodeDatabaseRunnable(
|
||||
callbackRunnable?.apply {
|
||||
onActionNodeFinish(nodeFinish(result))
|
||||
}
|
||||
|
||||
if (!result.isSuccess) {
|
||||
displayMessage(context)
|
||||
}
|
||||
|
||||
super.onFinishRun(result)
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ class AddEntryRunnable constructor(
|
||||
mNewEntry.touch(modified = true, touchParents = true)
|
||||
mParent.touch(modified = true, touchParents = true)
|
||||
database.addEntryTo(mNewEntry, mParent)
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
|
||||
@@ -37,6 +37,8 @@ class AddGroupRunnable constructor(
|
||||
mNewGroup.touch(modified = true, touchParents = true)
|
||||
mParent.touch(modified = true, touchParents = true)
|
||||
database.addGroupTo(mNewGroup, mParent)
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
|
||||
@@ -21,8 +21,9 @@ package com.kunzisoft.keepass.database.action.node
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.*
|
||||
import com.kunzisoft.keepass.database.exception.CopyDatabaseEntryException
|
||||
import com.kunzisoft.keepass.database.exception.CopyDatabaseGroupException
|
||||
|
||||
class CopyNodesRunnable constructor(
|
||||
context: Context,
|
||||
@@ -40,7 +41,10 @@ class CopyNodesRunnable constructor(
|
||||
mNodesToCopy.forEach { currentNode ->
|
||||
|
||||
when (currentNode.type) {
|
||||
Type.GROUP -> Log.e(TAG, "Copy not allowed for group")
|
||||
Type.GROUP -> {
|
||||
Log.e(TAG, "Copy not allowed for group")// Only finish thread
|
||||
finishRun(false, CopyDatabaseGroupException())
|
||||
}
|
||||
Type.ENTRY -> {
|
||||
// Root can contains entry
|
||||
if (mNewParent != database.rootGroup || database.rootCanContainsEntry()) {
|
||||
@@ -49,14 +53,19 @@ class CopyNodesRunnable constructor(
|
||||
database.copyEntryTo(currentNode as EntryVersioned, mNewParent)?.let { entryCopied ->
|
||||
entryCopied.touch(modified = true, touchParents = true)
|
||||
mEntriesCopied.add(entryCopied)
|
||||
} ?: Log.e(TAG, "Unable to create a copy of the entry")
|
||||
} ?: run {
|
||||
Log.e(TAG, "Unable to create a copy of the entry")
|
||||
finishRun(false, CopyDatabaseEntryException())
|
||||
}
|
||||
} else {
|
||||
// Only finish thread
|
||||
throw Exception(context.getString(R.string.error_copy_entry_here))
|
||||
finishRun(false, CopyDatabaseEntryException())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
|
||||
@@ -65,6 +65,8 @@ class DeleteNodesRunnable(context: Context,
|
||||
}
|
||||
}
|
||||
}
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
|
||||
@@ -21,8 +21,9 @@ package com.kunzisoft.keepass.database.action.node
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.*
|
||||
import com.kunzisoft.keepass.database.exception.MoveDatabaseEntryException
|
||||
import com.kunzisoft.keepass.database.exception.MoveDatabaseGroupException
|
||||
|
||||
class MoveNodesRunnable constructor(
|
||||
context: Context,
|
||||
@@ -40,6 +41,7 @@ class MoveNodesRunnable constructor(
|
||||
mNodesToMove.forEach { nodeToMove ->
|
||||
// Move node in new parent
|
||||
mOldParent = nodeToMove.parent
|
||||
nodeToMove.touch(modified = true, touchParents = true)
|
||||
|
||||
when (nodeToMove.type) {
|
||||
Type.GROUP -> {
|
||||
@@ -48,10 +50,9 @@ class MoveNodesRunnable constructor(
|
||||
if (groupToMove != mNewParent
|
||||
&& !mNewParent.isContainedIn(groupToMove)) {
|
||||
database.moveGroupTo(groupToMove, mNewParent)
|
||||
finishRun(true)
|
||||
} else {
|
||||
// Only finish thread
|
||||
throw Exception(context.getString(R.string.error_move_folder_in_itself))
|
||||
finishRun(false, MoveDatabaseGroupException())
|
||||
}
|
||||
}
|
||||
Type.ENTRY -> {
|
||||
@@ -61,16 +62,15 @@ class MoveNodesRunnable constructor(
|
||||
// and root can contains entry
|
||||
&& (mNewParent != database.rootGroup || database.rootCanContainsEntry())) {
|
||||
database.moveEntryTo(entryToMove, mNewParent)
|
||||
finishRun(true)
|
||||
} else {
|
||||
// Only finish thread
|
||||
throw Exception(context.getString(R.string.error_move_entry_here))
|
||||
finishRun(false, MoveDatabaseEntryException())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nodeToMove.touch(modified = true, touchParents = true)
|
||||
}
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
@@ -78,7 +78,8 @@ class MoveNodesRunnable constructor(
|
||||
try {
|
||||
mNodesToMove.forEach { nodeToMove ->
|
||||
// If we fail to save, try to move in the first place
|
||||
if (mOldParent != null) {
|
||||
if (mOldParent != null &&
|
||||
mOldParent != nodeToMove.parent) {
|
||||
when (nodeToMove.type) {
|
||||
Type.GROUP -> database.moveGroupTo(nodeToMove as GroupVersioned, mOldParent!!)
|
||||
Type.ENTRY -> database.moveEntryTo(nodeToMove as EntryVersioned, mOldParent!!)
|
||||
|
||||
@@ -50,6 +50,9 @@ class UpdateEntryRunnable constructor(
|
||||
|
||||
// Only change data in index
|
||||
database.updateEntry(mOldEntry)
|
||||
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
|
||||
@@ -47,6 +47,9 @@ class UpdateGroupRunnable constructor(
|
||||
|
||||
// Only change data in index
|
||||
database.updateGroup(mOldGroup)
|
||||
|
||||
saveDatabase()
|
||||
finishRun(true)
|
||||
}
|
||||
|
||||
override fun nodeFinish(result: Result): ActionNodeValues {
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.kunzisoft.keepass.database.exception
|
||||
|
||||
import android.content.res.Resources
|
||||
import androidx.annotation.StringRes
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.PwNodeId
|
||||
import com.kunzisoft.keepass.database.element.Type
|
||||
|
||||
abstract class DatabaseException : Exception {
|
||||
|
||||
abstract var errorId: Int
|
||||
var parameters: (Array<out String>)? = null
|
||||
|
||||
constructor() : super()
|
||||
|
||||
constructor(throwable: Throwable) : super(throwable)
|
||||
|
||||
fun getLocalizedMessage(resources: Resources): String {
|
||||
parameters?.let {
|
||||
return resources.getString(errorId, *it)
|
||||
} ?: return resources.getString(errorId)
|
||||
}
|
||||
}
|
||||
|
||||
open class LoadDatabaseException : DatabaseException {
|
||||
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_load_database
|
||||
|
||||
constructor() : super()
|
||||
|
||||
constructor(vararg params: String) : super() {
|
||||
parameters = params
|
||||
}
|
||||
|
||||
constructor(throwable: Throwable) : super(throwable)
|
||||
}
|
||||
|
||||
class LoadDatabaseArcFourException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_arc4
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseFileNotFoundException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.file_not_found_content
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseInvalidAlgorithmException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.invalid_algorithm
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseDuplicateUuidException: LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.invalid_algorithm
|
||||
|
||||
constructor(type: Type, uuid: PwNodeId<*>) : super() {
|
||||
parameters = Array(2) {
|
||||
when(it) {
|
||||
1 -> type.name
|
||||
2 -> uuid.toString()
|
||||
else -> {""}
|
||||
}
|
||||
}
|
||||
}
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseIOException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_load_database
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseKDFMemoryException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_load_database_KDF_memory
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseSignatureException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.invalid_db_sig
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseVersionException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.unsupported_db_version
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseInvalidCredentialsException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.invalid_credentials
|
||||
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseKeyFileEmptyException : LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.keyfile_is_empty
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class LoadDatabaseNoMemoryException: LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_out_of_memory
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class MoveDatabaseEntryException: LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_move_entry_here
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class MoveDatabaseGroupException: LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_move_folder_in_itself
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class CopyDatabaseEntryException: LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_copy_entry_here
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class CopyDatabaseGroupException: LoadDatabaseException {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_copy_group_here
|
||||
constructor() : super()
|
||||
constructor(exception: Throwable) : super(exception)
|
||||
}
|
||||
|
||||
class DatabaseOutputException : Exception {
|
||||
constructor(string: String) : super(string)
|
||||
|
||||
constructor(string: String, e: Exception) : super(string, e)
|
||||
|
||||
constructor(e: Exception) : super(e)
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX 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.
|
||||
*
|
||||
* KeePass DX 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 KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.exception
|
||||
|
||||
class DatabaseOutputException : Exception {
|
||||
constructor(string: String) : super(string)
|
||||
|
||||
constructor(string: String, e: Exception) : super(string, e)
|
||||
|
||||
constructor(e: Exception) : super(e)
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.kunzisoft.keepass.database.exception
|
||||
|
||||
import android.content.res.Resources
|
||||
import androidx.annotation.StringRes
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.PwNodeId
|
||||
import com.kunzisoft.keepass.database.element.Type
|
||||
|
||||
|
||||
class LoadDatabaseArcFourException : LoadDatabaseException {
|
||||
constructor() : super(R.string.error_arc4)
|
||||
constructor(exception: Throwable) : super(exception, R.string.error_arc4)
|
||||
}
|
||||
|
||||
class LoadDatabaseFileNotFoundException : LoadDatabaseException {
|
||||
constructor() : super(R.string.file_not_found_content)
|
||||
constructor(exception: Throwable) : super(exception, R.string.file_not_found_content)
|
||||
}
|
||||
|
||||
class LoadDatabaseInvalidAlgorithmException : LoadDatabaseException {
|
||||
constructor() : super(R.string.invalid_algorithm)
|
||||
constructor(exception: Throwable) : super(exception, R.string.invalid_algorithm)
|
||||
}
|
||||
|
||||
class LoadDatabaseDuplicateUuidException(type: Type, uuid: PwNodeId<*>):
|
||||
LoadDatabaseException(R.string.invalid_db_same_uuid, type.name, uuid.toString())
|
||||
|
||||
class LoadDatabaseIOException : LoadDatabaseException {
|
||||
constructor() : super(R.string.error_load_database)
|
||||
constructor(exception: Throwable) : super(exception, R.string.error_load_database)
|
||||
}
|
||||
|
||||
class LoadDatabaseKDFMemoryException : LoadDatabaseException {
|
||||
constructor() : super(R.string.error_load_database_KDF_memory)
|
||||
constructor(exception: Throwable) : super(exception, R.string.error_load_database_KDF_memory)
|
||||
}
|
||||
|
||||
class LoadDatabaseSignatureException : LoadDatabaseException {
|
||||
constructor() : super(R.string.invalid_db_sig)
|
||||
constructor(exception: Throwable) : super(exception, R.string.invalid_db_sig)
|
||||
}
|
||||
|
||||
class LoadDatabaseVersionException : LoadDatabaseException {
|
||||
constructor() : super(R.string.unsupported_db_version)
|
||||
constructor(exception: Throwable) : super(exception, R.string.unsupported_db_version)
|
||||
}
|
||||
|
||||
class LoadDatabaseInvalidCredentialsException : LoadDatabaseException {
|
||||
constructor() : super(R.string.invalid_credentials)
|
||||
constructor(exception: Throwable) : super(exception, R.string.invalid_credentials)
|
||||
}
|
||||
|
||||
class LoadDatabaseKeyFileEmptyException : LoadDatabaseException {
|
||||
constructor() : super(R.string.keyfile_is_empty)
|
||||
constructor(exception: Throwable) : super(exception, R.string.keyfile_is_empty)
|
||||
}
|
||||
|
||||
class LoadDatabaseNoMemoryException: LoadDatabaseException {
|
||||
constructor() : super(R.string.error_out_of_memory)
|
||||
constructor(exception: Throwable) : super(exception, R.string.error_out_of_memory)
|
||||
}
|
||||
|
||||
open class LoadDatabaseException : Exception {
|
||||
|
||||
@StringRes
|
||||
var errorId: Int = R.string.error_load_database
|
||||
var parameters: (Array<out String>)? = null
|
||||
|
||||
constructor(errorMessageId: Int) : super() {
|
||||
errorId = errorMessageId
|
||||
}
|
||||
|
||||
constructor(errorMessageId: Int, vararg params: String) : super() {
|
||||
errorId = errorMessageId
|
||||
parameters = params
|
||||
}
|
||||
|
||||
constructor(throwable: Throwable, errorMessageId: Int? = null) : super(throwable) {
|
||||
errorMessageId?.let {
|
||||
errorId = it
|
||||
}
|
||||
}
|
||||
|
||||
constructor() : super()
|
||||
|
||||
fun getLocalizedMessage(resources: Resources): String {
|
||||
parameters?.let {
|
||||
return resources.getString(errorId, *it)
|
||||
} ?: return resources.getString(errorId)
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.tasks
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import com.kunzisoft.keepass.database.exception.LoadDatabaseException
|
||||
|
||||
/**
|
||||
@@ -82,24 +78,6 @@ abstract class ActionRunnable(private var nestedActionRunnable: ActionRunnable?
|
||||
*/
|
||||
abstract fun onFinishRun(result: Result)
|
||||
|
||||
/**
|
||||
* Display a message as a Toast only if [context] is an Activity
|
||||
* @param context Context to show the message
|
||||
*/
|
||||
protected fun displayMessage(context: Context) {
|
||||
val message = result.message
|
||||
Log.i(ActionRunnable::class.java.name, message)
|
||||
try {
|
||||
(context as Activity).runOnUiThread {
|
||||
message?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (exception: ClassCastException) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to manage result from ActionRunnable
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/group_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/toolbar_action">
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
<string name="error_move_folder_in_itself">You can not move a group into itself.</string>
|
||||
<string name="error_move_entry_here">You can not move an entry here.</string>
|
||||
<string name="error_copy_entry_here">You can not copy an entry here.</string>
|
||||
<string name="error_copy_group_here">You can not copy a group here.</string>
|
||||
<string name="error_create_database_file">Unable to create database with this password and key file.</string>
|
||||
<string name="field_name">Field name</string>
|
||||
<string name="field_value">Field value</string>
|
||||
|
||||
Reference in new issue
Block a user