diff --git a/app/src/main/java/com/kunzisoft/keepass/app/database/CipherDatabaseAction.kt b/app/src/main/java/com/kunzisoft/keepass/app/database/CipherDatabaseAction.kt
index f1b576f2a..430caeca5 100644
--- a/app/src/main/java/com/kunzisoft/keepass/app/database/CipherDatabaseAction.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/app/database/CipherDatabaseAction.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.app.database
import android.content.ComponentName
@@ -9,6 +28,7 @@ import android.os.IBinder
import android.util.Base64
import android.util.Log
import com.kunzisoft.keepass.model.CipherEncryptDatabase
+import com.kunzisoft.keepass.services.AdvancedUnlockNotificationService
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.SingletonHolderParameter
import java.util.LinkedList
@@ -17,17 +37,16 @@ class CipherDatabaseAction(context: Context) {
private val applicationContext = context.applicationContext
private val cipherDatabaseDao =
- AppDatabase.getDatabase(applicationContext)
- .cipherDatabaseDao()
+ AppDatabase.getDatabase(applicationContext).cipherDatabaseDao()
// Temp DAO to easily remove content if object no longer in memory
private var useTempDao = PreferencesUtil.isTempAdvancedUnlockEnable(applicationContext)
- private var mBinder: com.kunzisoft.keepass.services.AdvancedUnlockNotificationService.AdvancedUnlockBinder? = null
+ private var mBinder: AdvancedUnlockNotificationService.AdvancedUnlockBinder? = null
private var mServiceConnection: ServiceConnection? = null
private var mDatabaseListeners = LinkedList()
- private var mAdvancedUnlockBroadcastReceiver = com.kunzisoft.keepass.services.AdvancedUnlockNotificationService.AdvancedUnlockReceiver {
+ private var mAdvancedUnlockBroadcastReceiver = AdvancedUnlockNotificationService.AdvancedUnlockReceiver {
deleteAll()
removeAllDataAndDetach()
}
@@ -49,12 +68,12 @@ class CipherDatabaseAction(context: Context) {
@Synchronized
private fun attachService(performedAction: () -> Unit) {
applicationContext.registerReceiver(mAdvancedUnlockBroadcastReceiver, IntentFilter().apply {
- addAction(com.kunzisoft.keepass.services.AdvancedUnlockNotificationService.REMOVE_ADVANCED_UNLOCK_KEY_ACTION)
+ addAction(AdvancedUnlockNotificationService.REMOVE_ADVANCED_UNLOCK_KEY_ACTION)
})
mServiceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName?, serviceBinder: IBinder?) {
- mBinder = (serviceBinder as com.kunzisoft.keepass.services.AdvancedUnlockNotificationService.AdvancedUnlockBinder)
+ mBinder = (serviceBinder as AdvancedUnlockNotificationService.AdvancedUnlockBinder)
performedAction.invoke()
}
@@ -63,7 +82,7 @@ class CipherDatabaseAction(context: Context) {
}
}
try {
- com.kunzisoft.keepass.services.AdvancedUnlockNotificationService.bindService(applicationContext,
+ AdvancedUnlockNotificationService.bindService(applicationContext,
mServiceConnection!!,
Context.BIND_AUTO_CREATE)
} catch (e: Exception) {
@@ -79,7 +98,7 @@ class CipherDatabaseAction(context: Context) {
} catch (e: Exception) {}
mServiceConnection?.let {
- com.kunzisoft.keepass.services.AdvancedUnlockNotificationService.unbindService(applicationContext, it)
+ AdvancedUnlockNotificationService.unbindService(applicationContext, it)
}
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/app/database/FileDatabaseHistoryAction.kt b/app/src/main/java/com/kunzisoft/keepass/app/database/FileDatabaseHistoryAction.kt
index 6435bc8e9..39536221a 100644
--- a/app/src/main/java/com/kunzisoft/keepass/app/database/FileDatabaseHistoryAction.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/app/database/FileDatabaseHistoryAction.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.app.database
import android.content.Context
@@ -6,17 +25,17 @@ import android.util.Log
import com.kunzisoft.keepass.hardware.HardwareKey
import com.kunzisoft.keepass.model.DatabaseFile
import com.kunzisoft.keepass.settings.PreferencesUtil
+import com.kunzisoft.keepass.utils.SingletonHolderParameter
import com.kunzisoft.keepass.utils.UriUtilDatabase
import com.kunzisoft.keepass.viewmodels.FileDatabaseInfo
class FileDatabaseHistoryAction(private val applicationContext: Context) {
private val databaseFileHistoryDao =
- AppDatabase.getDatabase(applicationContext)
- .fileDatabaseHistoryDao()
+ AppDatabase.getDatabase(applicationContext).fileDatabaseHistoryDao()
fun getDatabaseFile(databaseUri: Uri,
- databaseFileResult: (com.kunzisoft.keepass.model.DatabaseFile?) -> Unit) {
+ databaseFileResult: (DatabaseFile?) -> Unit) {
IOActionTask(
{
val fileDatabaseHistoryEntity =
@@ -59,7 +78,7 @@ class FileDatabaseHistoryAction(private val applicationContext: Context) {
).execute()
}
- fun getDatabaseFileList(databaseFileListResult: (List) -> Unit) {
+ fun getDatabaseFileList(databaseFileListResult: (List) -> Unit) {
IOActionTask(
{
val hideBrokenLocations =
@@ -101,16 +120,16 @@ class FileDatabaseHistoryAction(private val applicationContext: Context) {
fun addOrUpdateDatabaseUri(databaseUri: Uri,
keyFileUri: Uri? = null,
hardwareKey: HardwareKey? = null,
- databaseFileAddedOrUpdatedResult: ((com.kunzisoft.keepass.model.DatabaseFile?) -> Unit)? = null) {
- addOrUpdateDatabaseFile(com.kunzisoft.keepass.model.DatabaseFile(
+ databaseFileAddedOrUpdatedResult: ((DatabaseFile?) -> Unit)? = null) {
+ addOrUpdateDatabaseFile(DatabaseFile(
databaseUri,
keyFileUri,
hardwareKey
), databaseFileAddedOrUpdatedResult)
}
- fun addOrUpdateDatabaseFile(databaseFileToAddOrUpdate: com.kunzisoft.keepass.model.DatabaseFile,
- databaseFileAddedOrUpdatedResult: ((com.kunzisoft.keepass.model.DatabaseFile?) -> Unit)? = null) {
+ fun addOrUpdateDatabaseFile(databaseFileToAddOrUpdate: DatabaseFile,
+ databaseFileAddedOrUpdatedResult: ((DatabaseFile?) -> Unit)? = null) {
IOActionTask(
{
databaseFileToAddOrUpdate.databaseUri?.let { databaseUri ->
@@ -162,8 +181,8 @@ class FileDatabaseHistoryAction(private val applicationContext: Context) {
).execute()
}
- fun deleteDatabaseFile(databaseFileToDelete: com.kunzisoft.keepass.model.DatabaseFile,
- databaseFileDeletedResult: (com.kunzisoft.keepass.model.DatabaseFile?) -> Unit) {
+ fun deleteDatabaseFile(databaseFileToDelete: DatabaseFile,
+ databaseFileDeletedResult: (DatabaseFile?) -> Unit) {
IOActionTask(
{
databaseFileToDelete.databaseUri?.let { databaseUri ->
@@ -224,7 +243,7 @@ class FileDatabaseHistoryAction(private val applicationContext: Context) {
).execute()
}
- companion object : com.kunzisoft.keepass.utils.SingletonHolderParameter(::FileDatabaseHistoryAction) {
+ companion object : SingletonHolderParameter(::FileDatabaseHistoryAction) {
private val TAG = FileDatabaseHistoryAction::class.java.name
}
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/database/action/AssignMainCredentialInDatabaseRunnable.kt b/app/src/main/java/com/kunzisoft/keepass/database/action/AssignMainCredentialInDatabaseRunnable.kt
index fbef9b371..d61d83d69 100644
--- a/app/src/main/java/com/kunzisoft/keepass/database/action/AssignMainCredentialInDatabaseRunnable.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/database/action/AssignMainCredentialInDatabaseRunnable.kt
@@ -21,6 +21,7 @@ package com.kunzisoft.keepass.database.action
import android.content.Context
import android.net.Uri
+import com.kunzisoft.keepass.app.database.CipherDatabaseAction
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
import com.kunzisoft.keepass.database.element.Database
import com.kunzisoft.keepass.hardware.HardwareKey
@@ -53,7 +54,7 @@ open class AssignMainCredentialInDatabaseRunnable (
super.onFinishRun()
// Erase the biometric
- com.kunzisoft.keepass.app.database.CipherDatabaseAction.getInstance(context)
+ CipherDatabaseAction.getInstance(context)
.deleteByDatabaseUri(mDatabaseUri)
// Erase the register keyfile
FileDatabaseHistoryAction.getInstance(context)
diff --git a/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt b/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt
index 3d482968e..5bc07a36a 100644
--- a/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.database.action
import android.app.AlertDialog
@@ -5,6 +24,9 @@ import android.app.Service
import android.content.BroadcastReceiver
import android.content.ComponentName
import android.content.Context
+import android.content.Context.BIND_ABOVE_CLIENT
+import android.content.Context.BIND_AUTO_CREATE
+import android.content.Context.BIND_IMPORTANT
import android.content.Intent
import android.content.IntentFilter
import android.content.ServiceConnection
@@ -89,8 +111,7 @@ class DatabaseTaskProvider {
var onActionFinish: ((database: Database,
actionTask: String,
- result: ActionRunnable.Result
- ) -> Unit)? = null
+ result: ActionRunnable.Result) -> Unit)? = null
private var intentDatabaseTask: Intent
@@ -164,8 +185,7 @@ class DatabaseTaskProvider {
private val actionTaskListener = object: DatabaseTaskNotificationService.ActionTaskListener {
override fun onStartAction(database: Database,
- progressMessage: ProgressMessage
- ) {
+ progressMessage: ProgressMessage) {
startDialog(progressMessage)
}
@@ -176,8 +196,7 @@ class DatabaseTaskProvider {
override fun onStopAction(database: Database,
actionTask: String,
- result: ActionRunnable.Result
- ) {
+ result: ActionRunnable.Result) {
onActionFinish?.invoke(database, actionTask, result)
// Remove the progress task
stopDialog()
@@ -299,7 +318,7 @@ class DatabaseTaskProvider {
private fun bindService() {
initServiceConnection()
serviceConnection?.let {
- context.bindService(intentDatabaseTask, it, Context.BIND_AUTO_CREATE or Context.BIND_IMPORTANT or Context.BIND_ABOVE_CLIENT)
+ context.bindService(intentDatabaseTask, it, BIND_AUTO_CREATE or BIND_IMPORTANT or BIND_ABOVE_CLIENT)
}
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/database/action/LoadDatabaseRunnable.kt b/app/src/main/java/com/kunzisoft/keepass/database/action/LoadDatabaseRunnable.kt
index 330d80338..71ad8cd44 100644
--- a/app/src/main/java/com/kunzisoft/keepass/database/action/LoadDatabaseRunnable.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/database/action/LoadDatabaseRunnable.kt
@@ -21,6 +21,7 @@ package com.kunzisoft.keepass.database.action
import android.content.Context
import android.net.Uri
+import com.kunzisoft.keepass.app.database.CipherDatabaseAction
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
import com.kunzisoft.keepass.database.element.Database
import com.kunzisoft.keepass.database.element.MainCredential
@@ -31,6 +32,7 @@ import com.kunzisoft.keepass.model.CipherEncryptDatabase
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.tasks.ActionRunnable
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
+import com.kunzisoft.keepass.utils.UriUtilDatabase
class LoadDatabaseRunnable(
private val context: Context,
@@ -58,7 +60,7 @@ class LoadDatabaseRunnable(
mMainCredential,
mChallengeResponseRetriever,
mReadonly,
- com.kunzisoft.keepass.utils.UriUtilDatabase.getBinaryDir(context),
+ UriUtilDatabase.getBinaryDir(context),
{ memoryWanted ->
BinaryData.canMemoryBeAllocatedInRAM(context, memoryWanted)
},
@@ -82,7 +84,7 @@ class LoadDatabaseRunnable(
// Register the biometric
mCipherEncryptDatabase?.let { cipherDatabase ->
- com.kunzisoft.keepass.app.database.CipherDatabaseAction.getInstance(context)
+ CipherDatabaseAction.getInstance(context)
.addOrUpdateCipherDatabase(cipherDatabase) // return value not called
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateFieldKt.kt b/app/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateFieldKt.kt
index 31ca5ac3e..f915c2fea 100644
--- a/app/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateFieldKt.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateFieldKt.kt
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2021 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 .
+ */
package com.kunzisoft.keepass.database.element.template
import android.content.Context
diff --git a/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyResponseHelper.kt b/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyResponseHelper.kt
index 1c80b41d7..b13d658b2 100644
--- a/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyResponseHelper.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyResponseHelper.kt
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
import com.kunzisoft.keepass.R
+import com.kunzisoft.keepass.utils.UriUtil
import kotlinx.coroutines.launch
class HardwareKeyResponseHelper {
@@ -133,7 +134,7 @@ class HardwareKeyResponseHelper {
activity.getString(R.string.error_driver_required, hardwareKey.toString())
)
.setPositiveButton(R.string.download) { _, _ ->
- com.kunzisoft.keepass.utils.UriUtil.openExternalApp(activity, activity.getString(R.string.key_driver_app_id))
+ UriUtil.openExternalApp(activity, activity.getString(R.string.key_driver_app_id))
}
.setNegativeButton(android.R.string.cancel) { _, _ -> }
builder.create().show()
diff --git a/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.kt b/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.kt
index f3b4f7187..7f7b5eef3 100644
--- a/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2018 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 .
+ *
+ */
package com.kunzisoft.keepass.icons
import android.content.Context
diff --git a/app/src/main/java/com/kunzisoft/keepass/model/SnapFileDatabaseInfo.kt b/app/src/main/java/com/kunzisoft/keepass/model/SnapFileDatabaseInfo.kt
index 2c9c335f5..ef7b7d8d0 100644
--- a/app/src/main/java/com/kunzisoft/keepass/model/SnapFileDatabaseInfo.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/model/SnapFileDatabaseInfo.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2021 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 .
+ *
+ */
package com.kunzisoft.keepass.model
import android.content.Context
@@ -5,6 +24,7 @@ import android.net.Uri
import android.os.Parcel
import android.os.Parcelable
import android.text.format.Formatter
+import com.kunzisoft.keepass.viewmodels.FileDatabaseInfo
import java.text.DateFormat
import java.util.Date
@@ -70,7 +90,7 @@ data class SnapFileDatabaseInfo(var fileUri: Uri?,
return arrayOfNulls(size)
}
- fun fromFileDatabaseInfo(fileDatabaseInfo: com.kunzisoft.keepass.viewmodels.FileDatabaseInfo): SnapFileDatabaseInfo {
+ fun fromFileDatabaseInfo(fileDatabaseInfo: FileDatabaseInfo): SnapFileDatabaseInfo {
return SnapFileDatabaseInfo(
fileDatabaseInfo.fileUri,
fileDatabaseInfo.exists,
diff --git a/app/src/main/java/com/kunzisoft/keepass/services/AdvancedUnlockNotificationService.kt b/app/src/main/java/com/kunzisoft/keepass/services/AdvancedUnlockNotificationService.kt
index b08518298..45e0b0ccf 100644
--- a/app/src/main/java/com/kunzisoft/keepass/services/AdvancedUnlockNotificationService.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/services/AdvancedUnlockNotificationService.kt
@@ -10,8 +10,10 @@ import android.net.Uri
import android.os.Binder
import android.os.Build
import android.os.IBinder
+import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.app.database.CipherDatabaseEntity
import com.kunzisoft.keepass.settings.PreferencesUtil
+import com.kunzisoft.keepass.timeout.TimeoutHelper
class AdvancedUnlockNotificationService : NotificationService() {
@@ -45,7 +47,7 @@ class AdvancedUnlockNotificationService : NotificationService() {
}
override fun retrieveChannelName(): String {
- return getString(com.kunzisoft.keepass.R.string.advanced_unlock)
+ return getString(R.string.advanced_unlock)
}
override fun onCreate() {
@@ -70,12 +72,12 @@ class AdvancedUnlockNotificationService : NotificationService() {
val biometricUnlockEnabled = PreferencesUtil.isBiometricUnlockEnable(this)
val notificationBuilder = buildNewNotification().apply {
setSmallIcon(if (biometricUnlockEnabled) {
- com.kunzisoft.keepass.R.drawable.notification_ic_fingerprint_unlock_24dp
+ R.drawable.notification_ic_fingerprint_unlock_24dp
} else {
- com.kunzisoft.keepass.R.drawable.notification_ic_device_unlock_24dp
+ R.drawable.notification_ic_device_unlock_24dp
})
- setContentTitle(getString(com.kunzisoft.keepass.R.string.advanced_unlock))
- setContentText(getString(com.kunzisoft.keepass.R.string.advanced_unlock_tap_delete))
+ setContentTitle(getString(R.string.advanced_unlock))
+ setContentText(getString(R.string.advanced_unlock_tap_delete))
setContentIntent(pendingDeleteIntent)
// Unfortunately swipe is disabled in lollipop+
setDeleteIntent(pendingDeleteIntent)
@@ -83,7 +85,7 @@ class AdvancedUnlockNotificationService : NotificationService() {
val notificationTimeoutMilliSecs = PreferencesUtil.getAdvancedUnlockTimeout(this)
// Not necessarily a foreground service
- if (mTimerJob == null && notificationTimeoutMilliSecs != com.kunzisoft.keepass.timeout.TimeoutHelper.NEVER) {
+ if (mTimerJob == null && notificationTimeoutMilliSecs != TimeoutHelper.NEVER) {
defineTimerJob(notificationBuilder, notificationTimeoutMilliSecs) {
sendBroadcast(Intent(REMOVE_ADVANCED_UNLOCK_KEY_ACTION))
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/services/DatabaseTaskNotificationService.kt b/app/src/main/java/com/kunzisoft/keepass/services/DatabaseTaskNotificationService.kt
index 3acf9d963..1dafd5cc6 100644
--- a/app/src/main/java/com/kunzisoft/keepass/services/DatabaseTaskNotificationService.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/services/DatabaseTaskNotificationService.kt
@@ -421,8 +421,7 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
when (intentAction) {
ACTION_DATABASE_LOAD_TASK,
ACTION_DATABASE_MERGE_TASK,
- ACTION_DATABASE_RELOAD_TASK,
- -> {
+ ACTION_DATABASE_RELOAD_TASK, -> {
saveDatabaseInfo()
}
}
@@ -501,11 +500,9 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
ACTION_DATABASE_CREATE_TASK -> R.string.creating_database
ACTION_DATABASE_LOAD_TASK,
ACTION_DATABASE_MERGE_TASK,
- ACTION_DATABASE_RELOAD_TASK,
- -> R.string.loading_database
+ ACTION_DATABASE_RELOAD_TASK, -> R.string.loading_database
ACTION_DATABASE_ASSIGN_PASSWORD_TASK,
- ACTION_DATABASE_SAVE,
- -> R.string.saving_database
+ ACTION_DATABASE_SAVE, -> R.string.saving_database
else -> {
if (mSaveState)
R.string.saving_database
@@ -1216,8 +1213,7 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
private val TAG = DatabaseTaskNotificationService::class.java.name
- private const val CHANNEL_DATABASE_ID =
- "com.kunzisoft.keepass.notification.channel.database"
+ private const val CHANNEL_DATABASE_ID = "com.kunzisoft.keepass.notification.channel.database"
const val ACTION_DATABASE_CREATE_TASK = "ACTION_DATABASE_CREATE_TASK"
const val ACTION_DATABASE_LOAD_TASK = "ACTION_DATABASE_LOAD_TASK"
@@ -1234,30 +1230,19 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
const val ACTION_DATABASE_RESTORE_ENTRY_HISTORY = "ACTION_DATABASE_RESTORE_ENTRY_HISTORY"
const val ACTION_DATABASE_DELETE_ENTRY_HISTORY = "ACTION_DATABASE_DELETE_ENTRY_HISTORY"
const val ACTION_DATABASE_UPDATE_NAME_TASK = "ACTION_DATABASE_UPDATE_NAME_TASK"
- const val ACTION_DATABASE_UPDATE_DESCRIPTION_TASK =
- "ACTION_DATABASE_UPDATE_DESCRIPTION_TASK"
- const val ACTION_DATABASE_UPDATE_DEFAULT_USERNAME_TASK =
- "ACTION_DATABASE_UPDATE_DEFAULT_USERNAME_TASK"
+ const val ACTION_DATABASE_UPDATE_DESCRIPTION_TASK = "ACTION_DATABASE_UPDATE_DESCRIPTION_TASK"
+ const val ACTION_DATABASE_UPDATE_DEFAULT_USERNAME_TASK = "ACTION_DATABASE_UPDATE_DEFAULT_USERNAME_TASK"
const val ACTION_DATABASE_UPDATE_COLOR_TASK = "ACTION_DATABASE_UPDATE_COLOR_TASK"
- const val ACTION_DATABASE_UPDATE_COMPRESSION_TASK =
- "ACTION_DATABASE_UPDATE_COMPRESSION_TASK"
- const val ACTION_DATABASE_REMOVE_UNLINKED_DATA_TASK =
- "ACTION_DATABASE_REMOVE_UNLINKED_DATA_TASK"
- const val ACTION_DATABASE_UPDATE_RECYCLE_BIN_TASK =
- "ACTION_DATABASE_UPDATE_RECYCLE_BIN_TASK"
- const val ACTION_DATABASE_UPDATE_TEMPLATES_GROUP_TASK =
- "ACTION_DATABASE_UPDATE_TEMPLATES_GROUP_TASK"
- const val ACTION_DATABASE_UPDATE_MAX_HISTORY_ITEMS_TASK =
- "ACTION_DATABASE_UPDATE_MAX_HISTORY_ITEMS_TASK"
- const val ACTION_DATABASE_UPDATE_MAX_HISTORY_SIZE_TASK =
- "ACTION_DATABASE_UPDATE_MAX_HISTORY_SIZE_TASK"
+ const val ACTION_DATABASE_UPDATE_COMPRESSION_TASK = "ACTION_DATABASE_UPDATE_COMPRESSION_TASK"
+ const val ACTION_DATABASE_REMOVE_UNLINKED_DATA_TASK = "ACTION_DATABASE_REMOVE_UNLINKED_DATA_TASK"
+ const val ACTION_DATABASE_UPDATE_RECYCLE_BIN_TASK = "ACTION_DATABASE_UPDATE_RECYCLE_BIN_TASK"
+ const val ACTION_DATABASE_UPDATE_TEMPLATES_GROUP_TASK = "ACTION_DATABASE_UPDATE_TEMPLATES_GROUP_TASK"
+ const val ACTION_DATABASE_UPDATE_MAX_HISTORY_ITEMS_TASK = "ACTION_DATABASE_UPDATE_MAX_HISTORY_ITEMS_TASK"
+ const val ACTION_DATABASE_UPDATE_MAX_HISTORY_SIZE_TASK ="ACTION_DATABASE_UPDATE_MAX_HISTORY_SIZE_TASK"
const val ACTION_DATABASE_UPDATE_ENCRYPTION_TASK = "ACTION_DATABASE_UPDATE_ENCRYPTION_TASK"
- const val ACTION_DATABASE_UPDATE_KEY_DERIVATION_TASK =
- "ACTION_DATABASE_UPDATE_KEY_DERIVATION_TASK"
- const val ACTION_DATABASE_UPDATE_MEMORY_USAGE_TASK =
- "ACTION_DATABASE_UPDATE_MEMORY_USAGE_TASK"
- const val ACTION_DATABASE_UPDATE_PARALLELISM_TASK =
- "ACTION_DATABASE_UPDATE_PARALLELISM_TASK"
+ const val ACTION_DATABASE_UPDATE_KEY_DERIVATION_TASK ="ACTION_DATABASE_UPDATE_KEY_DERIVATION_TASK"
+ const val ACTION_DATABASE_UPDATE_MEMORY_USAGE_TASK ="ACTION_DATABASE_UPDATE_MEMORY_USAGE_TASK"
+ const val ACTION_DATABASE_UPDATE_PARALLELISM_TASK ="ACTION_DATABASE_UPDATE_PARALLELISM_TASK"
const val ACTION_DATABASE_UPDATE_ITERATIONS_TASK = "ACTION_DATABASE_UPDATE_ITERATIONS_TASK"
const val ACTION_DATABASE_SAVE = "ACTION_DATABASE_SAVE"
@@ -1281,10 +1266,8 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
const val SAVE_DATABASE_KEY = "SAVE_DATABASE_KEY"
const val OLD_NODES_KEY = "OLD_NODES_KEY"
const val NEW_NODES_KEY = "NEW_NODES_KEY"
- const val OLD_ELEMENT_KEY =
- "OLD_ELEMENT_KEY" // Warning type of this thing change every time
- const val NEW_ELEMENT_KEY =
- "NEW_ELEMENT_KEY" // Warning type of this thing change every time
+ const val OLD_ELEMENT_KEY ="OLD_ELEMENT_KEY" // Warning type of this thing change every time
+ const val NEW_ELEMENT_KEY ="NEW_ELEMENT_KEY" // Warning type of this thing change every time
fun getListNodesFromBundle(database: Database, bundle: Bundle): List {
val nodesAction = ArrayList()
diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt
index 4ae73cd65..a5c80a4d3 100644
--- a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.settings
import android.app.backup.BackupManager
@@ -7,18 +26,24 @@ import android.content.res.Resources
import android.net.Uri
import android.util.Log
import androidx.preference.PreferenceManager
+import com.kunzisoft.keepass.BuildConfig
import com.kunzisoft.keepass.R
+import com.kunzisoft.keepass.activities.stylish.Stylish
+import com.kunzisoft.keepass.biometric.AdvancedUnlockManager
import com.kunzisoft.keepass.database.element.SortNodeEnum
import com.kunzisoft.keepass.database.search.SearchParameters
import com.kunzisoft.keepass.education.Education
-import java.util.HashSet
-import java.util.Properties
+import com.kunzisoft.keepass.magikeyboard.MagikeyboardService
+import com.kunzisoft.keepass.password.PassphraseGenerator
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil.APP_TIMEOUT_KEY
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil.HIDE_EXPIRED_ENTRIES_KEY
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil.SETTING_ICON_PACK_CHOOSE_KEY
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil.SUBDOMAIN_SEARCH_KEY
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil.TIMEOUT_BACKUP_KEY
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil.TIMEOUT_DEFAULT
+import com.kunzisoft.keepass.timeout.TimeoutHelper
+import com.kunzisoft.keepass.utils.UriUtil
+import java.util.Properties
object PreferencesUtil {
@@ -133,34 +158,28 @@ object PreferencesUtil {
}
fun getStyle(context: Context): String {
- val defaultStyleString =
- com.kunzisoft.keepass.activities.stylish.Stylish.defaultStyle(context)
+ val defaultStyleString = Stylish.defaultStyle(context)
val styleString = PreferenceManager.getDefaultSharedPreferences(context)
.getString(context.getString(R.string.setting_style_key), defaultStyleString)
?: defaultStyleString
// Return the system style
- return com.kunzisoft.keepass.activities.stylish.Stylish.retrieveEquivalentSystemStyle(
- context,
- styleString)
+ return Stylish.retrieveEquivalentSystemStyle(context, styleString)
}
fun setStyle(context: Context, styleString: String) {
var tempThemeString = styleString
- if (!com.kunzisoft.keepass.utils.UriUtil.contributingUser(context)) {
- if (tempThemeString in com.kunzisoft.keepass.BuildConfig.STYLES_DISABLED) {
- tempThemeString =
- com.kunzisoft.keepass.activities.stylish.Stylish.defaultStyle(context)
+ if (!UriUtil.contributingUser(context)) {
+ if (tempThemeString in BuildConfig.STYLES_DISABLED) {
+ tempThemeString = Stylish.defaultStyle(context)
}
}
// Store light style to show selection in array list
- tempThemeString =
- com.kunzisoft.keepass.activities.stylish.Stylish.retrieveEquivalentLightStyle(context,
- tempThemeString)
+ tempThemeString = Stylish.retrieveEquivalentLightStyle(context, tempThemeString)
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(context.getString(R.string.setting_style_key), tempThemeString)
.apply()
- com.kunzisoft.keepass.activities.stylish.Stylish.load(context)
+ Stylish.load(context)
}
fun getStyleBrightness(context: Context): String? {
@@ -175,8 +194,7 @@ object PreferencesUtil {
fun getListTextSize(context: Context): Float {
val index = try {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- val listSizeString = prefs.getString(context.getString(R.string.list_size_key),
- context.getString(R.string.list_size_string_medium))
+ val listSizeString = prefs.getString(context.getString(R.string.list_size_key), context.getString(R.string.list_size_string_medium))
context.resources.getStringArray(R.array.list_size_string_values).indexOf(listSizeString)
} catch (e: Exception) {
1
@@ -189,8 +207,7 @@ object PreferencesUtil {
fun getDefaultPasswordLength(context: Context): Int {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getInt(context.getString(R.string.password_generator_length_key),
- context.resources.getInteger(R.integer.password_generator_length_default))
+ return prefs.getInt(context.getString(R.string.password_generator_length_key), context.resources.getInteger(R.integer.password_generator_length_default))
}
fun setDefaultPasswordLength(context: Context, passwordLength: Int) {
@@ -222,8 +239,7 @@ object PreferencesUtil {
fun getDefaultPasswordConsiderChars(context: Context): String {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getString(context.getString(R.string.password_generator_consider_chars_key),
- context.getString(R.string.password_generator_consider_chars_default)) ?: ""
+ return prefs.getString(context.getString(R.string.password_generator_consider_chars_key), context.getString(R.string.password_generator_consider_chars_default)) ?: ""
}
fun setDefaultPasswordConsiderChars(context: Context, considerChars: String) {
@@ -238,8 +254,7 @@ object PreferencesUtil {
fun getDefaultPasswordIgnoreChars(context: Context): String {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getString(context.getString(R.string.password_generator_ignore_chars_key),
- context.getString(R.string.password_generator_ignore_chars_default)) ?: ""
+ return prefs.getString(context.getString(R.string.password_generator_ignore_chars_key), context.getString(R.string.password_generator_ignore_chars_default)) ?: ""
}
fun setDefaultPasswordIgnoreChars(context: Context, ignoreChars: String) {
@@ -254,8 +269,7 @@ object PreferencesUtil {
fun getDefaultPassphraseWordCount(context: Context): Int {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getInt(context.getString(R.string.passphrase_generator_word_count_key),
- context.resources.getInteger(R.integer.passphrase_generator_word_count_default))
+ return prefs.getInt(context.getString(R.string.passphrase_generator_word_count_key), context.resources.getInteger(R.integer.passphrase_generator_word_count_default))
}
fun setDefaultPassphraseWordCount(context: Context, passphraseWordCount: Int) {
@@ -268,16 +282,16 @@ object PreferencesUtil {
}
}
- fun getDefaultPassphraseWordCase(context: Context): com.kunzisoft.keepass.password.PassphraseGenerator.WordCase {
+ fun getDefaultPassphraseWordCase(context: Context): PassphraseGenerator.WordCase {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return com.kunzisoft.keepass.password.PassphraseGenerator.WordCase.Companion.getByOrdinal(
+ return PassphraseGenerator.WordCase.getByOrdinal(
prefs.getInt(context
.getString(R.string.passphrase_generator_word_case_key),
0)
)
}
- fun setDefaultPassphraseWordCase(context: Context, wordCase: com.kunzisoft.keepass.password.PassphraseGenerator.WordCase) {
+ fun setDefaultPassphraseWordCase(context: Context, wordCase: PassphraseGenerator.WordCase) {
PreferenceManager.getDefaultSharedPreferences(context).edit().apply {
putInt(
context.getString(R.string.passphrase_generator_word_case_key),
@@ -397,46 +411,37 @@ object PreferencesUtil {
fun getClipboardTimeout(context: Context): Long {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getString(context.getString(R.string.clipboard_timeout_key),
- TIMEOUT_DEFAULT)?.toLong()
- ?: com.kunzisoft.keepass.timeout.TimeoutHelper.DEFAULT_TIMEOUT
+ return prefs.getString(context.getString(R.string.clipboard_timeout_key), TIMEOUT_DEFAULT)?.toLong() ?: TimeoutHelper.DEFAULT_TIMEOUT
}
fun getAdvancedUnlockTimeout(context: Context): Long {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getString(context.getString(R.string.temp_advanced_unlock_timeout_key),
- context.getString(R.string.temp_advanced_unlock_timeout_default))?.toLong()
- ?: com.kunzisoft.keepass.timeout.TimeoutHelper.DEFAULT_TIMEOUT
+ return prefs.getString(context.getString(R.string.temp_advanced_unlock_timeout_key), context.getString(R.string.temp_advanced_unlock_timeout_default))?.toLong() ?: TimeoutHelper.DEFAULT_TIMEOUT
}
fun isLockDatabaseWhenScreenShutOffEnable(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getBoolean(context.getString(R.string.lock_database_screen_off_key),
- context.resources.getBoolean(R.bool.lock_database_screen_off_default))
+ return prefs.getBoolean(context.getString(R.string.lock_database_screen_off_key), context.resources.getBoolean(R.bool.lock_database_screen_off_default))
}
fun isLockDatabaseWhenBackButtonOnRootClicked(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getBoolean(context.getString(R.string.lock_database_back_root_key),
- context.resources.getBoolean(R.bool.lock_database_back_root_default))
+ return prefs.getBoolean(context.getString(R.string.lock_database_back_root_key), context.resources.getBoolean(R.bool.lock_database_back_root_default))
}
fun showLockDatabaseButton(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getBoolean(context.getString(R.string.lock_database_show_button_key),
- context.resources.getBoolean(R.bool.lock_database_show_button_default))
+ return prefs.getBoolean(context.getString(R.string.lock_database_show_button_key), context.resources.getBoolean(R.bool.lock_database_show_button_default))
}
fun isAutoSaveDatabaseEnabled(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getBoolean(context.getString(R.string.enable_auto_save_database_key),
- context.resources.getBoolean(R.bool.enable_auto_save_database_default))
+ return prefs.getBoolean(context.getString(R.string.enable_auto_save_database_key), context.resources.getBoolean(R.bool.enable_auto_save_database_default))
}
fun isKeepScreenOnEnabled(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
- return prefs.getBoolean(context.getString(R.string.enable_keep_screen_on_key),
- context.resources.getBoolean(R.bool.enable_keep_screen_on_default))
+ return prefs.getBoolean(context.getString(R.string.enable_keep_screen_on_key), context.resources.getBoolean(R.bool.enable_keep_screen_on_default))
}
fun isScreenshotModeEnabled(context: Context): Boolean {
@@ -454,11 +459,10 @@ object PreferencesUtil {
return prefs.getBoolean(context.getString(R.string.biometric_unlock_enable_key),
context.resources.getBoolean(R.bool.biometric_unlock_enable_default))
&& (if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- com.kunzisoft.keepass.biometric.AdvancedUnlockManager.Companion.biometricUnlockSupported(
- context)
- } else {
- false
- })
+ AdvancedUnlockManager.biometricUnlockSupported(context)
+ } else {
+ false
+ })
}
fun isDeviceCredentialUnlockEnable(context: Context): Boolean {
@@ -579,9 +583,7 @@ object PreferencesUtil {
}
fun isKeyboardSaveSearchInfoEnable(context: Context): Boolean {
- if (!com.kunzisoft.keepass.magikeyboard.MagikeyboardService.Companion.activatedInSettings(
- context)
- )
+ if (!MagikeyboardService.activatedInSettings(context))
return false
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.keyboard_save_search_info_key),
@@ -666,7 +668,7 @@ object PreferencesUtil {
fun getDefaultApplicationIdBlocklist(resources: Resources?): Set {
return resources?.getStringArray(R.array.autofill_application_id_blocklist_default)
?.toMutableSet()?.apply {
- add(com.kunzisoft.keepass.BuildConfig.APPLICATION_ID)
+ add(BuildConfig.APPLICATION_ID)
} ?: emptySet()
}
@@ -708,8 +710,7 @@ object PreferencesUtil {
context).all) {
properties[name] = value.toString()
}
- for ((name, value) in com.kunzisoft.keepass.education.Education.Companion.getEducationSharedPreferences(
- context).all) {
+ for ((name, value) in Education.getEducationSharedPreferences(context).all) {
properties[name] = value.toString()
}
return properties
@@ -731,10 +732,8 @@ object PreferencesUtil {
for ((name, value) in properties) {
try {
putProperty(this, name as String, value as String)
- } catch (e:Exception) {
- Log.e("PreferencesUtil",
- "Error when trying to parse app property $name=$value",
- e)
+ } catch (e: Exception) {
+ Log.e("PreferencesUtil", "Error when trying to parse app property $name=$value", e)
}
}
}.apply()
diff --git a/app/src/main/java/com/kunzisoft/keepass/viewmodels/FileDatabaseInfo.kt b/app/src/main/java/com/kunzisoft/keepass/viewmodels/FileDatabaseInfo.kt
index 075ef7dde..e35c6f868 100644
--- a/app/src/main/java/com/kunzisoft/keepass/viewmodels/FileDatabaseInfo.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/viewmodels/FileDatabaseInfo.kt
@@ -1,8 +1,29 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.viewmodels
import android.content.Context
import android.net.Uri
import android.text.format.Formatter
+import androidx.documentfile.provider.DocumentFile
+import com.kunzisoft.keepass.utils.UriUtil
import java.io.Serializable
import java.text.DateFormat
import java.util.Date
@@ -10,7 +31,7 @@ import java.util.Date
class FileDatabaseInfo : Serializable {
private var context: Context
- private var documentFile: androidx.documentfile.provider.DocumentFile? = null
+ private var documentFile: DocumentFile? = null
var fileUri: Uri?
private set
@@ -22,16 +43,16 @@ class FileDatabaseInfo : Serializable {
constructor(context: Context, filePath: String) {
this.context = context
- this.fileUri = com.kunzisoft.keepass.utils.UriUtil.parse(filePath)
+ this.fileUri = UriUtil.parse(filePath)
init()
}
fun init() {
// Check permission
fileUri?.let { uri ->
- com.kunzisoft.keepass.utils.UriUtil.takeUriPermission(context.contentResolver, uri)
+ UriUtil.takeUriPermission(context.contentResolver, uri)
}
- documentFile = com.kunzisoft.keepass.utils.UriUtil.getFileData(context, fileUri)
+ documentFile = UriUtil.getFileData(context, fileUri)
}
var exists: Boolean = false
diff --git a/database/build.gradle b/database/build.gradle
index 35da30599..ea672b2ad 100644
--- a/database/build.gradle
+++ b/database/build.gradle
@@ -15,8 +15,6 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
- buildConfigField "String[]", "ICON_PACKS", "{\"classic\",\"material\"}"
-
kapt {
arguments {
arg("room.incremental", "true")
diff --git a/database/src/androidTest/java/com/kunzisoft/keepass/database/ExampleInstrumentedTest.kt b/database/src/androidTest/java/com/kunzisoft/keepass/database/ExampleInstrumentedTest.kt
deleted file mode 100644
index d446581fe..000000000
--- a/database/src/androidTest/java/com/kunzisoft/keepass/database/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.kunzisoft.keepass.database
-
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.ext.junit.runners.AndroidJUnit4
-
-import org.junit.Test
-import org.junit.runner.RunWith
-
-import org.junit.Assert.*
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("com.kunzisoft.keepass.database.test", appContext.packageName)
- }
-}
diff --git a/database/src/main/java/com/kunzisoft/keepass/database/element/Database.kt b/database/src/main/java/com/kunzisoft/keepass/database/element/Database.kt
index 78dd693e5..4caa738d1 100644
--- a/database/src/main/java/com/kunzisoft/keepass/database/element/Database.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/database/element/Database.kt
@@ -1008,7 +1008,7 @@ class Database(private val iconPackChooser: InterfaceIconPackChooser) {
}
fun clearAndClose(context: Context? = null) {
- clearIndexesAndBinaries(context?.let { com.kunzisoft.keepass.utils.UriUtilDatabase.getBinaryDir(context) })
+ clearIndexesAndBinaries(context?.let { UriUtilDatabase.getBinaryDir(context) })
this.mDatabaseKDB = null
this.mDatabaseKDBX = null
this.fileUri = null
diff --git a/database/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateEngine.kt b/database/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateEngine.kt
index 85bd7a16d..9f9efc21a 100644
--- a/database/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateEngine.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/database/element/template/TemplateEngine.kt
@@ -20,7 +20,6 @@ package com.kunzisoft.keepass.database.element.template
import android.content.res.Resources
import android.graphics.Color
import android.util.Log
-import com.kunzisoft.keepass.database.R
import com.kunzisoft.keepass.database.element.Field
import com.kunzisoft.keepass.database.element.database.DatabaseKDBX
import com.kunzisoft.keepass.database.element.entry.EntryKDBX
diff --git a/database/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInput.kt b/database/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInput.kt
index 2581f84a2..4d0bd0a0b 100644
--- a/database/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInput.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInput.kt
@@ -20,7 +20,6 @@
package com.kunzisoft.keepass.database.file.input
import android.util.Log
-import com.kunzisoft.keepass.database.R
import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
import com.kunzisoft.keepass.database.exception.DatabaseInputException
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
diff --git a/database/src/main/java/com/kunzisoft/keepass/model/CipherDecryptDatabase.kt b/database/src/main/java/com/kunzisoft/keepass/model/CipherDecryptDatabase.kt
index c3bc15dc5..6c1bb5433 100644
--- a/database/src/main/java/com/kunzisoft/keepass/model/CipherDecryptDatabase.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/model/CipherDecryptDatabase.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2022 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 .
+ *
+ */
package com.kunzisoft.keepass.model
import android.net.Uri
@@ -9,13 +28,12 @@ import com.kunzisoft.keepass.utils.writeEnum
class CipherDecryptDatabase(): Parcelable {
var databaseUri: Uri? = null
- var credentialStorage: com.kunzisoft.keepass.model.CredentialStorage =
- com.kunzisoft.keepass.model.CredentialStorage.Companion.DEFAULT
+ var credentialStorage: CredentialStorage = CredentialStorage.DEFAULT
var decryptedValue: ByteArray = byteArrayOf()
constructor(parcel: Parcel): this() {
databaseUri = parcel.readParcelable(Uri::class.java.classLoader)
- credentialStorage = parcel.readEnum() ?: credentialStorage
+ credentialStorage = parcel.readEnum() ?: credentialStorage
decryptedValue = ByteArray(parcel.readInt())
parcel.readByteArray(decryptedValue)
}
diff --git a/database/src/main/java/com/kunzisoft/keepass/model/CipherEncryptDatabase.kt b/database/src/main/java/com/kunzisoft/keepass/model/CipherEncryptDatabase.kt
index 99afc5aad..9a4886555 100644
--- a/database/src/main/java/com/kunzisoft/keepass/model/CipherEncryptDatabase.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/model/CipherEncryptDatabase.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2022 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 .
+ *
+ */
package com.kunzisoft.keepass.model
import android.net.Uri
@@ -9,14 +28,13 @@ import com.kunzisoft.keepass.utils.writeEnum
class CipherEncryptDatabase(): Parcelable {
var databaseUri: Uri? = null
- var credentialStorage: com.kunzisoft.keepass.model.CredentialStorage =
- com.kunzisoft.keepass.model.CredentialStorage.Companion.DEFAULT
+ var credentialStorage: CredentialStorage = CredentialStorage.DEFAULT
var encryptedValue: ByteArray = byteArrayOf()
var specParameters: ByteArray = byteArrayOf()
constructor(parcel: Parcel): this() {
databaseUri = parcel.readParcelable(Uri::class.java.classLoader)
- credentialStorage = parcel.readEnum() ?: credentialStorage
+ credentialStorage = parcel.readEnum() ?: credentialStorage
encryptedValue = ByteArray(parcel.readInt())
parcel.readByteArray(encryptedValue)
specParameters = ByteArray(parcel.readInt())
diff --git a/database/src/main/java/com/kunzisoft/keepass/stream/CopyInputStream.kt b/database/src/main/java/com/kunzisoft/keepass/stream/CopyInputStream.kt
index da19a8e24..5170f7a31 100644
--- a/database/src/main/java/com/kunzisoft/keepass/stream/CopyInputStream.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/stream/CopyInputStream.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2017 Brian Pellin, 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 .
+ *
+ */
package com.kunzisoft.keepass.stream
import java.io.IOException
diff --git a/database/src/main/java/com/kunzisoft/keepass/tasks/ActionRunnable.kt b/database/src/main/java/com/kunzisoft/keepass/tasks/ActionRunnable.kt
index c701ba57d..1c5b0c1e8 100644
--- a/database/src/main/java/com/kunzisoft/keepass/tasks/ActionRunnable.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/tasks/ActionRunnable.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.tasks
import android.os.Bundle
diff --git a/database/src/main/java/com/kunzisoft/keepass/timeout/TimeoutHelper.kt b/database/src/main/java/com/kunzisoft/keepass/timeout/TimeoutHelper.kt
index e3f3d3357..7fd0b4fb5 100644
--- a/database/src/main/java/com/kunzisoft/keepass/timeout/TimeoutHelper.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/timeout/TimeoutHelper.kt
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2019 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 .
+ *
+ */
package com.kunzisoft.keepass.timeout
import android.app.AlarmManager
diff --git a/database/src/main/java/com/kunzisoft/keepass/utils/StreamBytesUtils.kt b/database/src/main/java/com/kunzisoft/keepass/utils/StreamBytesUtils.kt
index 55327bfab..223ef9fd6 100644
--- a/database/src/main/java/com/kunzisoft/keepass/utils/StreamBytesUtils.kt
+++ b/database/src/main/java/com/kunzisoft/keepass/utils/StreamBytesUtils.kt
@@ -193,6 +193,20 @@ fun bytes4ToUInt(buf: ByteArray): UnsignedInt {
+ (buf[3].toInt() and 0xFF shl 24))
}
+fun bytes16ToUuid(buf: ByteArray): UUID {
+ var lsb: Long = 0
+ for (i in 15 downTo 8) {
+ lsb = lsb shl 8 or (buf[i].toLong() and 0xff)
+ }
+
+ var msb: Long = 0
+ for (i in 7 downTo 0) {
+ msb = msb shl 8 or (buf[i].toLong() and 0xff)
+ }
+
+ return UUID(msb, lsb)
+}
+
/**
* Unpack date from 5 byte format. The five bytes at 'offset' are unpacked
* to a java.util.Date instance.
@@ -251,6 +265,14 @@ fun uLongTo8Bytes(value: UnsignedLong): ByteArray {
return longTo8Bytes(value.toKotlinLong())
}
+fun longTo8Bytes(value: Long): ByteArray {
+ val buf = ByteArray(8)
+ for (i in 0 until 8) {
+ buf[i] = (value.ushr(8 * i) and 0xFF).toByte()
+ }
+ return buf
+}
+
fun uuidTo16Bytes(uuid: UUID): ByteArray {
val buf = ByteArray(16)
for (i in 0 until 8) {
@@ -329,25 +351,3 @@ fun writeStringToStream(outputStream: OutputStream, string: String?): Int {
return length
}
-
-fun bytes16ToUuid(buf: ByteArray): UUID {
- var lsb: Long = 0
- for (i in 15 downTo 8) {
- lsb = lsb shl 8 or (buf[i].toLong() and 0xff)
- }
-
- var msb: Long = 0
- for (i in 7 downTo 0) {
- msb = msb shl 8 or (buf[i].toLong() and 0xff)
- }
-
- return UUID(msb, lsb)
-}
-
-fun longTo8Bytes(value: Long): ByteArray {
- val buf = ByteArray(8)
- for (i in 0 until 8) {
- buf[i] = (value.ushr(8 * i) and 0xFF).toByte()
- }
- return buf
-}
diff --git a/database/src/test/java/com/kunzisoft/keepass/database/ExampleUnitTest.kt b/database/src/test/java/com/kunzisoft/keepass/database/ExampleUnitTest.kt
deleted file mode 100644
index 0aca27bf9..000000000
--- a/database/src/test/java/com/kunzisoft/keepass/database/ExampleUnitTest.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.kunzisoft.keepass.database
-
-import org.junit.Test
-
-import org.junit.Assert.*
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
- @Test
- fun addition_isCorrect() {
- assertEquals(4, 2 + 2)
- }
-}