fix: Java import

This commit is contained in:
J-Jamet committed 2026-05-01 19:01:29 +02:00
1 parent b98c3418c9
commit f552e87cc8
64 files changed
+229 -190

No files matched your search

@@ -73,7 +73,7 @@ class IconPickerActivity : DatabaseLockActivity() {
private val iconPickerViewModel: IconPickerViewModel by viewModels()
private var mCustomIconsSelectionMode = false
private var mIconsSelected: List<IconImageCustom> = ArrayList()
private var mIconsSelected: List<IconImageCustom> = emptyList()
private var mExternalFileHelper: ExternalFileHelper? = null
@@ -48,7 +48,6 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.tasks.ActionRunnable
import com.kunzisoft.keepass.utils.KeyboardUtil.hideKeyboard
import com.kunzisoft.keepass.viewmodels.GroupViewModel
import java.util.LinkedList
class GroupFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListener {
@@ -68,8 +67,8 @@ class GroupFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListen
private set
var nodeActionPasteMode: PasteMode = PasteMode.UNDEFINED
private set
private val listActionNodes = LinkedList<Node>()
private val listPasteNodes = LinkedList<Node>()
private val listActionNodes = mutableListOf<Node>()
private val listPasteNodes = mutableListOf<Node>()
private var notFoundView: View? = null
private var isASearchResult: Boolean = false
@@ -10,7 +10,7 @@ abstract class AnimatedItemsAdapter<Item, T: RecyclerView.ViewHolder>(val contex
: RecyclerView.Adapter<T>() {
protected val inflater: LayoutInflater = LayoutInflater.from(context)
var itemsList: MutableList<Item> = ArrayList()
var itemsList: MutableList<Item> = mutableListOf()
private set
var onDeleteButtonClickListener: ((item: Item)->Unit)? = null
@@ -32,7 +32,7 @@ import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
class EntryHistoryAdapter(val context: Context) : RecyclerView.Adapter<EntryHistoryAdapter.EntryHistoryViewHolder>() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
var entryHistoryList: MutableList<EntryInfo> = ArrayList()
var entryHistoryList: MutableList<EntryInfo> = mutableListOf()
var onItemClickListener: ((item: EntryInfo, position: Int)->Unit)? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EntryHistoryViewHolder {
@@ -16,7 +16,7 @@ class IconPickerAdapter<I: IconImageDraw>(val context: Context, private val tint
private val inflater: LayoutInflater = LayoutInflater.from(context)
private val iconList = ArrayList<I>()
private val iconList = mutableListOf<I>()
var iconDrawableFactory: IconDrawableFactory? = null
var iconPickerListener: IconPickerListener<I>? = null
@@ -31,7 +31,7 @@ import com.kunzisoft.keepass.database.element.Field
class KeyboardFieldsAdapter(context: Context) : RecyclerView.Adapter<KeyboardFieldsAdapter.FieldViewHolder>() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
private var fields: MutableList<Field> = ArrayList()
private var fields: MutableList<Field> = mutableListOf()
var onItemClickListener: OnItemClickListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FieldViewHolder {
@@ -53,7 +53,6 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.timeout.ClipboardHelper
import com.kunzisoft.keepass.view.setTextSize
import com.kunzisoft.keepass.view.strikeOut
import java.util.LinkedList
/**
* Create node list adapter with contextMenu or not
@@ -90,7 +89,7 @@ class NodesAdapter (
private var mOldVirtualGroup = false
private var mVirtualGroup = false
private var mActionNodesList = LinkedList<Node>()
private var mActionNodesList = mutableListOf<Node>()
private var mNodeClickCallback: NodeClickCallback? = null
private var mClipboardHelper = ClipboardHelper(context)
@@ -35,7 +35,6 @@ import com.kunzisoft.keepass.services.DeviceUnlockNotificationService
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.IOActionTask
import com.kunzisoft.keepass.utils.SingletonHolderParameter
import java.util.LinkedList
class CipherDatabaseAction(context: Context) {
@@ -49,7 +48,7 @@ class CipherDatabaseAction(context: Context) {
private var mBinder: DeviceUnlockNotificationService.DeviceUnlockBinder? = null
private var mServiceConnection: ServiceConnection? = null
private var mDatabaseListeners = LinkedList<CipherDatabaseListener>()
private var mDatabaseListeners = mutableListOf<CipherDatabaseListener>()
private var mDeviceUnlockBroadcastReceiver = DeviceUnlockNotificationService.DeviceUnlockReceiver {
deleteAll()
removeAllDataAndDetach()
@@ -91,7 +91,7 @@ class FileDatabaseHistoryAction(private val applicationContext: Context) {
PreferencesUtil.hideBrokenLocations(
applicationContext)
// Show only uri accessible
val databaseFileListLoaded = ArrayList<DatabaseFile>()
val databaseFileListLoaded = mutableListOf<DatabaseFile>()
databaseFileHistoryDao.getAll().forEach { fileDatabaseHistoryEntity ->
val fileDatabaseInfo = FileDatabaseInfo(
applicationContext,
@@ -275,8 +275,8 @@ class KeeAutofillService : AutofillService() {
// Tell the autofill framework the interest to save credentials
if (askToSaveData) {
var types: Int = SaveInfo.SAVE_DATA_TYPE_GENERIC
val requiredIds = ArrayList<AutofillId>()
val optionalIds = ArrayList<AutofillId>()
val requiredIds = mutableListOf<AutofillId>()
val optionalIds = mutableListOf<AutofillId>()
// Only if at least a password
parseResult.passwordId?.let { passwordInfo ->
@@ -552,7 +552,7 @@ class StructureParser(
}
fun allAutofillIds(): Array<AutofillId> {
val all = ArrayList<AutofillId>()
val all = mutableListOf<AutofillId>()
usernameId?.let {
all.add(it)
}
@@ -374,8 +374,8 @@ class DatabaseTaskProvider(
newParent: Group?,
save: Boolean
) {
val groupsIdToCopy = ArrayList<NodeId<*>>()
val entriesIdToCopy = ArrayList<NodeId<UUID>>()
val groupsIdToCopy = mutableListOf<NodeId<*>>()
val entriesIdToCopy = mutableListOf<NodeId<UUID>>()
nodesPaste.forEach { nodeVersioned ->
when (nodeVersioned.type) {
Type.GROUP -> {
@@ -23,10 +23,9 @@ import android.content.Context
import com.kunzisoft.keepass.database.ContextualDatabase
import com.kunzisoft.keepass.database.element.Entry
import com.kunzisoft.keepass.database.element.Group
import com.kunzisoft.keepass.database.element.node.Node
import com.kunzisoft.keepass.hardware.HardwareKey
class AddEntryRunnable constructor(
class AddEntryRunnable(
context: Context,
database: ContextualDatabase,
private val mNewEntry: Entry,
@@ -48,10 +47,6 @@ class AddEntryRunnable constructor(
database.removeEntryFrom(mNewEntry, it)
}
}
val oldNodesReturn = ArrayList<Node>()
val newNodesReturn = ArrayList<Node>()
newNodesReturn.add(mNewEntry)
return ActionNodesValues(oldNodesReturn, newNodesReturn)
return ActionNodesValues(listOf(), listOf(mNewEntry))
}
}
@@ -22,10 +22,9 @@ package com.kunzisoft.keepass.database.action.node
import android.content.Context
import com.kunzisoft.keepass.database.ContextualDatabase
import com.kunzisoft.keepass.database.element.Group
import com.kunzisoft.keepass.database.element.node.Node
import com.kunzisoft.keepass.hardware.HardwareKey
class AddGroupRunnable constructor(
class AddGroupRunnable(
context: Context,
database: ContextualDatabase,
private val mNewGroup: Group,
@@ -45,10 +44,6 @@ class AddGroupRunnable constructor(
if (!result.isSuccess) {
database.removeGroupFrom(mNewGroup, mParent)
}
val oldNodesReturn = ArrayList<Node>()
val newNodesReturn = ArrayList<Node>()
newNodesReturn.add(mNewGroup)
return ActionNodesValues(oldNodesReturn, newNodesReturn)
return ActionNodesValues(listOf(), listOf(mNewGroup))
}
}
@@ -30,7 +30,7 @@ import com.kunzisoft.keepass.database.exception.CopyEntryDatabaseException
import com.kunzisoft.keepass.database.exception.CopyGroupDatabaseException
import com.kunzisoft.keepass.hardware.HardwareKey
class CopyNodesRunnable constructor(
class CopyNodesRunnable(
context: Context,
database: ContextualDatabase,
private val mNodesToCopy: List<Node>,
@@ -40,7 +40,7 @@ class CopyNodesRunnable constructor(
challengeResponseRetriever: (HardwareKey, ByteArray?) -> ByteArray
) : ActionNodeDatabaseRunnable(context, database, afterActionNodesFinish, save, challengeResponseRetriever) {
private var mEntriesCopied = ArrayList<Entry>()
private var mEntriesCopied = mutableListOf<Entry>()
override fun nodeAction() {
@@ -40,7 +40,7 @@ class DeleteNodesRunnable(
private var mOldParent: Group? = null
private var mCanRecycle: Boolean = false
private var mNodesToDeleteBackup = ArrayList<Node>()
private var mNodesToDeleteBackup = mutableListOf<Node>()
override fun nodeAction() {
@@ -30,7 +30,7 @@ import com.kunzisoft.keepass.database.exception.MoveEntryDatabaseException
import com.kunzisoft.keepass.database.exception.MoveGroupDatabaseException
import com.kunzisoft.keepass.hardware.HardwareKey
class MoveNodesRunnable constructor(
class MoveNodesRunnable(
context: Context,
database: ContextualDatabase,
private val mNodesToMove: List<Node>,
@@ -98,11 +98,11 @@ class MoveNodesRunnable constructor(
}
}
}
} catch (e: Exception) {
} catch (_: Exception) {
Log.i(TAG, "Unable to replace the node")
}
}
return ActionNodesValues(ArrayList(), mNodesToMove)
return ActionNodesValues(emptyList(), mNodesToMove)
}
companion object {
@@ -21,9 +21,7 @@ package com.kunzisoft.keepass.database.action.node
import android.content.Context
import com.kunzisoft.keepass.database.ContextualDatabase
import com.kunzisoft.keepass.database.element.Attachment
import com.kunzisoft.keepass.database.element.Entry
import com.kunzisoft.keepass.database.element.node.Node
import com.kunzisoft.keepass.hardware.HardwareKey
class UpdateEntryRunnable(
@@ -51,7 +49,7 @@ class UpdateEntryRunnable(
// Build oldest attachments
val oldEntryAttachments = mOldEntry.getAttachments(database.attachmentPool, true)
val newEntryAttachments = mNewEntry.getAttachments(database.attachmentPool, true)
val attachmentsToRemove = ArrayList<Attachment>(oldEntryAttachments)
val attachmentsToRemove = oldEntryAttachments.toMutableList()
// Not use equals because only check name
newEntryAttachments.forEach { newAttachment ->
oldEntryAttachments.forEach { oldAttachment ->
@@ -84,11 +82,6 @@ class UpdateEntryRunnable(
// If we fail to save, back out changes to global structure
database.updateEntry(mOldEntry)
}
val oldNodesReturn = ArrayList<Node>()
oldNodesReturn.add(mOldEntry)
val newNodesReturn = ArrayList<Node>()
newNodesReturn.add(mNewEntry)
return ActionNodesValues(oldNodesReturn, newNodesReturn)
return ActionNodesValues(listOf(mOldEntry), listOf(mNewEntry))
}
}
@@ -60,11 +60,9 @@ class UpdateGroupRunnable constructor(
}
database.updateGroup(mOldGroup)
}
val oldNodesReturn = ArrayList<Node>()
oldNodesReturn.add(mOldGroup)
val newNodesReturn = ArrayList<Node>()
newNodesReturn.add(mNewGroup)
return ActionNodesValues(oldNodesReturn, newNodesReturn)
return ActionNodesValues(
listOf<Node>(mOldGroup),
listOf<Node>(mNewGroup)
)
}
}
@@ -22,15 +22,21 @@ package com.kunzisoft.keepass.icons
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.Resources
import android.graphics.*
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.Drawable
import android.util.Log
import android.widget.ImageView
import android.widget.RemoteViews
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.drawable.toDrawable
import androidx.core.graphics.scale
import androidx.core.widget.ImageViewCompat
import com.kunzisoft.keepass.database.element.binary.BinaryCache
import com.kunzisoft.keepass.database.element.binary.BinaryData
@@ -42,7 +48,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.lang.ref.WeakReference
import java.util.*
import java.util.UUID
/**
* Factory class who build database icons dynamically, can assign an icon of IconPack, or a custom icon to an ImageView with a tint
@@ -56,13 +62,13 @@ class IconDrawableFactory(
* Cache for icon drawable.
* Keys: UUID, Values: Drawables
*/
private val customIconMap = HashMap<UUID, WeakReference<Drawable>>()
private val customIconMap = mutableMapOf<UUID, WeakReference<Drawable>>()
/** standardIconMap
* Cache for icon drawable.
* Keys: Integer, Values: Drawables
*/
private val standardIconMap = HashMap<CacheKey, WeakReference<Drawable>>()
private val standardIconMap = mutableMapOf<CacheKey, WeakReference<Drawable>>()
/**
* To load an icon pack only if current one is different
@@ -117,7 +123,7 @@ class IconDrawableFactory(
BitmapFactory.decodeStream(binaryFile.getInputDataStream(binaryCache))
bitmap?.let { bitmapIcon ->
bitmap = resize(bitmapIcon, patternIcon)
val createdDraw = BitmapDrawable(resources, bitmap)
val createdDraw = bitmap.toDrawable(resources)
customIconMap[icon.uuid] = WeakReference(createdDraw)
return createdDraw
}
@@ -178,10 +184,7 @@ class IconDrawableFactory(
return if (width == dimensionPattern.width && height == dimensionPattern.height) {
bitmap
} else Bitmap.createScaledBitmap(bitmap,
dimensionPattern.width,
dimensionPattern.height,
true)
} else bitmap.scale(dimensionPattern.width, dimensionPattern.height)
}
@@ -277,7 +280,7 @@ class IconDrawableFactory(
*/
private class PatternIcon(defaultIconSize : Int) {
var blankDrawable: Drawable = ColorDrawable(Color.TRANSPARENT)
var blankDrawable: Drawable = Color.TRANSPARENT.toDrawable()
var width = -1
var height = -1
@@ -289,7 +292,7 @@ class IconDrawableFactory(
}
/**
* Utility class to prevent a custom icon to be tint
* Utility class to prevent a custom icon to be tinted
*/
class SuperDrawable(var drawable: Drawable, var tintable: Boolean = false)
@@ -34,7 +34,7 @@ object IconPackChooser {
private val TAG = IconPackChooser::class.java.name
private val iconPackList = ArrayList<IconPack>()
private val iconPackList = mutableListOf<IconPack>()
private var iconPackSelected: IconPack? = null
var defaultIconSize: Int = 0
@@ -23,11 +23,17 @@ import android.content.res.Resources
import android.graphics.Color
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.utils.IOActionTask
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import me.gosimple.nbvcxz.Nbvcxz
import me.gosimple.nbvcxz.resources.Configuration
import me.gosimple.nbvcxz.resources.ConfigurationBuilder
import java.util.*
import java.util.Locale
import kotlin.math.min
class PasswordEntropy(actionOnInitFinished: (() -> Unit)? = null) {
@@ -43,7 +43,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.LinkedList
import java.util.concurrent.CopyOnWriteArrayList
@@ -57,7 +56,7 @@ class AttachmentFileNotificationService: LockNotificationService() {
private val attachmentNotificationList = CopyOnWriteArrayList<AttachmentNotification>()
private var mActionTaskBinder = ActionTaskBinder()
private var mActionTaskListeners = LinkedList<ActionTaskListener>()
private var mActionTaskListeners = mutableListOf<ActionTaskListener>()
private val mainScope = CoroutineScope(Dispatchers.Main)
@@ -1392,7 +1392,7 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
const val DATA_BYTES = "DATA_BYTES"
fun getListNodesFromBundle(database: ContextualDatabase, bundle: Bundle): List<Node> {
val nodesAction = ArrayList<Node>()
val nodesAction = mutableListOf<Node>()
bundle.getParcelableList<NodeId<*>>(GROUPS_ID_KEY)?.forEach {
database.getGroupById(it)?.let { groupRetrieve ->
nodesAction.add(groupRetrieve)
@@ -17,7 +17,7 @@ import com.kunzisoft.keepass.timeout.TimeoutHelper.NEVER
class DeviceUnlockNotificationService : NotificationService() {
private lateinit var mTempCipherDao: ArrayList<CipherDatabaseEntity>
private lateinit var mTempCipherDao: MutableList<CipherDatabaseEntity>
private var mActionTaskBinder = DeviceUnlockBinder()
@@ -57,7 +57,7 @@ class DeviceUnlockNotificationService : NotificationService() {
override fun onCreate() {
super.onCreate()
mTempCipherDao = ArrayList()
mTempCipherDao = mutableListOf()
}
// It's simpler to use pendingIntent to perform REMOVE_DEVICE_UNLOCK_KEY_ACTION
@@ -20,21 +20,21 @@
package com.kunzisoft.keepass.settings.preference
import android.content.Context
import androidx.preference.ListPreference
import android.util.AttributeSet
import androidx.preference.ListPreference
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.icons.IconPackChooser
import java.util.*
class IconPackListPreference @JvmOverloads constructor(context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = R.attr.dialogPreferenceStyle,
defStyleRes: Int = defStyleAttr)
: ListPreference(context, attrs, defStyleAttr, defStyleRes) {
class IconPackListPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = R.attr.dialogPreferenceStyle,
defStyleRes: Int = defStyleAttr
) : ListPreference(context, attrs, defStyleAttr, defStyleRes) {
init {
val entries = ArrayList<String>()
val values = ArrayList<String>()
val entries = mutableListOf<String>()
val values = mutableListOf<String>()
for (iconPack in IconPackChooser.getIconPackList(context)) {
iconPack.id?.let { iconPackId ->
entries.add(iconPack.name)
@@ -22,16 +22,13 @@ package com.kunzisoft.keepass.settings.preferencedialogfragment
import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.model.SearchInfo
import com.kunzisoft.keepass.settings.preferencedialogfragment.adapter.AutofillBlocklistAdapter
import com.kunzisoft.keepass.utils.getParcelableArrayCompat
import java.util.*
import kotlin.Comparator
import kotlin.collections.HashSet
import java.util.TreeSet
abstract class AutofillBlocklistPreferenceDialogFragmentCompat
: InputPreferenceDialogFragmentCompat(),
@@ -20,24 +20,21 @@
package com.kunzisoft.keepass.settings.preferencedialogfragment.adapter
import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.utils.ObjectNameResource
import java.util.ArrayList
class AutofillBlocklistAdapter<T : ObjectNameResource>(private val context: Context)
: RecyclerView.Adapter<AutofillBlocklistAdapter.BlocklistItemViewHolder>() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
val items: MutableList<T> = ArrayList()
val items: MutableList<T> = mutableListOf()
private var itemDeletedCallback: ItemDeletedCallback<T>? = null
@@ -26,14 +26,13 @@ import android.view.ViewGroup
import android.widget.RadioButton
import androidx.recyclerview.widget.RecyclerView
import com.kunzisoft.keepass.R
import java.util.*
class ListRadioItemAdapter<T>(private val context: Context)
: RecyclerView.Adapter<ListRadioItemAdapter.ListRadioViewHolder>() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
private val radioItemList: MutableList<T> = ArrayList()
private val radioItemList: MutableList<T> = mutableListOf()
private var radioItemUsed: T? = null
private var radioItemSelectedCallback: RadioItemSelectedCallback<T>? = null
@@ -159,7 +159,7 @@ class DatabaseFilesViewModel(application: Application) : AndroidViewModel(applic
}
class DatabaseFileData {
val databaseFileList = ArrayList<DatabaseFile>()
val databaseFileList = mutableListOf<DatabaseFile>()
var databaseFileToActivate: DatabaseFile? = null
var databaseFileAction: DatabaseFileAction = DatabaseFileAction.NONE
@@ -23,12 +23,12 @@ import android.content.Context
import android.net.Uri
import android.text.format.Formatter
import androidx.documentfile.provider.DocumentFile
import com.kunzisoft.keepass.utils.parseUri
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
import com.kunzisoft.keepass.utils.UriUtil.takeUriPermission
import com.kunzisoft.keepass.utils.parseUri
import java.io.Serializable
import java.text.DateFormat
import java.util.*
import java.util.Date
class FileDatabaseInfo : Serializable {
@@ -21,7 +21,7 @@ package com.kunzisoft.keepass.database.crypto
import com.kunzisoft.keepass.utils.bytes16ToUuid
import java.security.NoSuchAlgorithmException
import java.util.*
import java.util.UUID
enum class EncryptionAlgorithm {
@@ -19,10 +19,25 @@
*/
package com.kunzisoft.keepass.database.crypto
import com.kunzisoft.keepass.utils.*
import java.io.*
import com.kunzisoft.keepass.utils.UnsignedInt
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.bytes4ToUInt
import com.kunzisoft.keepass.utils.bytes64ToLong
import com.kunzisoft.keepass.utils.bytes64ToULong
import com.kunzisoft.keepass.utils.readBytes2ToUShort
import com.kunzisoft.keepass.utils.readBytes4ToUInt
import com.kunzisoft.keepass.utils.readBytesLength
import com.kunzisoft.keepass.utils.write2BytesUShort
import com.kunzisoft.keepass.utils.write4BytesUInt
import com.kunzisoft.keepass.utils.write8BytesLong
import com.kunzisoft.keepass.utils.writeBooleanByte
import com.kunzisoft.keepass.utils.writeByte
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
import java.nio.charset.Charset
import java.util.*
open class VariantDictionary {
@@ -20,12 +20,12 @@
package com.kunzisoft.keepass.database.crypto.kdf
import com.kunzisoft.encrypt.HashManager
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.encrypt.aes.AESTransformer
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.bytes16ToUuid
import java.io.IOException
import java.security.SecureRandom
import java.util.*
import java.util.UUID
class AesKdf : KdfEngine() {
@@ -19,14 +19,14 @@
*/
package com.kunzisoft.keepass.database.crypto.kdf
import com.kunzisoft.keepass.utils.UnsignedInt
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.encrypt.argon2.Argon2Transformer
import com.kunzisoft.encrypt.argon2.Argon2Type
import com.kunzisoft.keepass.utils.UnsignedInt
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.bytes16ToUuid
import java.io.IOException
import java.security.SecureRandom
import java.util.*
import java.util.UUID
class Argon2Kdf(private val type: Type) : KdfEngine() {
@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database.crypto.kdf
import com.kunzisoft.keepass.utils.UnsignedInt
import java.io.IOException
import java.io.Serializable
import java.util.*
import java.util.UUID
// TODO Parcelable
abstract class KdfEngine : Serializable {
@@ -19,11 +19,11 @@
*/
package com.kunzisoft.keepass.database.crypto.kdf
import com.kunzisoft.keepass.database.crypto.VariantDictionary
import com.kunzisoft.keepass.utils.bytes16ToUuid
import com.kunzisoft.keepass.utils.uuidTo16Bytes
import com.kunzisoft.keepass.database.crypto.VariantDictionary
import java.io.IOException
import java.util.*
import java.util.UUID
class KdfParameters: VariantDictionary {
@@ -23,7 +23,6 @@ import android.os.Parcel
import android.os.Parcelable
import com.kunzisoft.keepass.utils.readStringParcelableMap
import com.kunzisoft.keepass.utils.writeStringParcelableMap
import java.util.*
class CustomData : Parcelable {
@@ -286,7 +286,7 @@ open class Database {
get() = mDatabaseKDBX != null
val availableCompressionAlgorithms: List<CompressionAlgorithm>
get() = mDatabaseKDBX?.availableCompressionAlgorithms ?: ArrayList()
get() = mDatabaseKDBX?.availableCompressionAlgorithms ?: emptyList()
var compressionAlgorithm: CompressionAlgorithm?
get() = mDatabaseKDBX?.compressionAlgorithm
@@ -331,7 +331,7 @@ open class Database {
}
val availableEncryptionAlgorithms: List<EncryptionAlgorithm>
get() = mDatabaseKDB?.availableEncryptionAlgorithms ?: mDatabaseKDBX?.availableEncryptionAlgorithms ?: ArrayList()
get() = mDatabaseKDB?.availableEncryptionAlgorithms ?: mDatabaseKDBX?.availableEncryptionAlgorithms ?: listOf()
var encryptionAlgorithm: EncryptionAlgorithm?
get() = mDatabaseKDB?.encryptionAlgorithm ?: mDatabaseKDBX?.encryptionAlgorithm
@@ -342,7 +342,7 @@ open class Database {
}
val availableKdfEngines: List<KdfEngine>
get() = mDatabaseKDB?.kdfAvailableList ?: mDatabaseKDBX?.kdfAvailableList ?: ArrayList()
get() = mDatabaseKDB?.kdfAvailableList ?: mDatabaseKDBX?.kdfAvailableList ?: listOf()
val allowKdfModification: Boolean
get() = availableKdfEngines.size > 1
@@ -550,7 +550,7 @@ open class Database {
val groupNamesNotAllowed: List<String>
get() {
return mDatabaseKDB?.groupNamesNotAllowed ?: ArrayList()
return mDatabaseKDB?.groupNamesNotAllowed ?: listOf()
}
private fun setDatabaseKDB(databaseKDB: DatabaseKDB) {
@@ -24,7 +24,7 @@ import android.os.ParcelUuid
import android.os.Parcelable
import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
import com.kunzisoft.keepass.utils.readParcelableCompat
import java.util.*
import java.util.UUID
class DeletedObject : Parcelable {
@@ -320,7 +320,7 @@ class Entry : Node, EntryVersionedInterface<Group> {
* @return Map of label/value
*/
fun getExtraFields(): List<Field> {
val extraFields = ArrayList<Field>()
val extraFields = mutableListOf<Field>()
entryKDBX?.let {
it.doForEachDecodedCustomField { field ->
extraFields.add(field)
@@ -391,7 +391,7 @@ class Entry : Node, EntryVersionedInterface<Group> {
}
fun getAttachments(attachmentPool: AttachmentPool, inHistory: Boolean = false): List<Attachment> {
val attachments = ArrayList<Attachment>()
val attachments = mutableListOf<Attachment>()
entryKDB?.getAttachment(attachmentPool)?.let {
attachments.add(it)
}
@@ -421,9 +421,9 @@ class Entry : Node, EntryVersionedInterface<Group> {
entryKDBX?.putAttachment(attachment, attachmentPool)
}
fun getHistory(): ArrayList<Entry> {
val history = ArrayList<Entry>()
val entryKDBXHistory = entryKDBX?.history ?: ArrayList()
fun getHistory(): List<Entry> {
val history = mutableListOf<Entry>()
val entryKDBXHistory = entryKDBX?.history ?: listOf()
for (entryHistory in entryKDBXHistory) {
history.add(Entry(entryHistory))
}
@@ -269,7 +269,7 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
groupKDBX?.getChildGroups()?.map {
Group(it)
} ?:
ArrayList()
listOf()
}
override fun getChildEntries(): List<Entry> {
@@ -279,11 +279,11 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
groupKDBX?.getChildEntries()?.map {
Entry(it)
} ?:
ArrayList()
listOf()
}
fun getChildEntriesInfo(database: Database): List<EntryInfo> {
val entriesInfo = ArrayList<EntryInfo>()
val entriesInfo = mutableListOf<EntryInfo>()
getChildEntries().forEach { entry ->
entriesInfo.add(entry.getEntryInfo(database))
}
@@ -1,7 +1,6 @@
package com.kunzisoft.keepass.database.element.binary
import java.io.File
import java.util.*
class BinaryCache {
@@ -29,7 +28,7 @@ class BinaryCache {
}
// Similar to file storage but much faster TODO SparseArray
private val byteArrayList = HashMap<String, ByteArray>()
private val byteArrayList = mutableMapOf<String, ByteArray>()
fun getByteArray(key: String): KeyByteArray {
if (key == UNKNOWN) {
@@ -159,7 +159,7 @@ abstract class BinaryPool<T> {
*/
protected fun orderedBinariesWithoutDuplication(condition: ((binary: BinaryData) -> Boolean) = { true })
: List<KeyBinary<T>> {
val keyBinaryList = ArrayList<KeyBinary<T>>()
val keyBinaryList = mutableListOf<KeyBinary<T>>()
for ((key, binary) in pool) {
// Don't deduplicate
val existentBinary =
@@ -2,7 +2,7 @@ package com.kunzisoft.keepass.database.element.binary
import com.kunzisoft.keepass.database.element.DateInstant
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
import java.util.*
import java.util.UUID
class CustomIconPool : BinaryPool<UUID>() {
@@ -866,7 +866,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
}
fun removeUnlinkedAttachment(binary: BinaryData, clear: Boolean) {
val listBinaries = ArrayList<BinaryData>()
val listBinaries = mutableListOf<BinaryData>()
listBinaries.add(binary)
removeUnlinkedAttachments(listBinaries, clear)
}
@@ -878,7 +878,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
private fun removeUnlinkedAttachments(binaries: List<BinaryData>, clear: Boolean) {
// TODO check in icon pool
// Build binaries to remove with all binaries known
val binariesToRemove = ArrayList<BinaryData>()
val binariesToRemove = mutableListOf<BinaryData>()
if (binaries.isEmpty()) {
attachmentPool.doForEachBinary { _, binary ->
binariesToRemove.add(binary)
@@ -30,7 +30,7 @@ class AutoType : Parcelable {
var enabled = true
var obfuscationOptions = OBF_OPT_NONE
var defaultSequence = ""
private var windowSeqPairs = ArrayList<AutoTypeItem>()
private var windowSeqPairs = mutableListOf<AutoTypeItem>()
constructor()
@@ -64,7 +64,7 @@ class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
override var previousParentGroup: UUID = DatabaseVersioned.UUID_ZERO
var qualityCheck = true
var autoType = AutoType()
var history = ArrayList<EntryKDBX>()
var history = mutableListOf<EntryKDBX>()
var additional = ""
override var expires: Boolean = false
@@ -315,7 +315,7 @@ class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
* It's a list because history labels can be defined multiple times
*/
fun getAttachments(attachmentPool: AttachmentPool, inHistory: Boolean = false): List<Attachment> {
val entryAttachmentList = ArrayList<Attachment>()
val entryAttachmentList = mutableListOf<Attachment>()
for ((label, poolId) in binaries) {
attachmentPool[poolId]?.let { binary ->
entryAttachmentList.add(Attachment(label, binary))
@@ -28,7 +28,7 @@ import com.kunzisoft.keepass.database.element.node.NodeIdInt
import com.kunzisoft.keepass.database.element.node.NodeKDBInterface
import com.kunzisoft.keepass.database.element.node.Type
import com.kunzisoft.keepass.utils.readParcelableCompat
import java.util.*
import java.util.UUID
class GroupKDB : GroupVersioned<Int, UUID, GroupKDB, EntryKDB>, NodeKDBInterface {
@@ -31,12 +31,12 @@ import com.kunzisoft.keepass.database.element.node.NodeId
import com.kunzisoft.keepass.database.element.node.NodeIdUUID
import com.kunzisoft.keepass.database.element.node.NodeKDBXInterface
import com.kunzisoft.keepass.database.element.node.Type
import com.kunzisoft.keepass.utils.readParcelableCompat
import com.kunzisoft.keepass.utils.readSerializableCompat
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.readBooleanCompat
import com.kunzisoft.keepass.utils.readParcelableCompat
import com.kunzisoft.keepass.utils.readSerializableCompat
import com.kunzisoft.keepass.utils.writeBooleanCompat
import java.util.*
import java.util.UUID
class GroupKDBX : GroupVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInterface {
@@ -22,7 +22,6 @@ package com.kunzisoft.keepass.database.element.group
import android.os.Parcel
import com.kunzisoft.keepass.database.element.entry.EntryVersioned
import com.kunzisoft.keepass.database.element.node.NodeVersioned
import java.util.*
abstract class GroupVersioned
<
@@ -35,9 +34,9 @@ abstract class GroupVersioned
private var titleGroup = ""
@Transient
private val childGroups = LinkedList<Group>()
private val childGroups = mutableListOf<Group>()
@Transient
private val childEntries = LinkedList<Entry>()
private val childEntries = mutableListOf<Entry>()
private var positionIndexChildren = 0
constructor() : super()
@@ -51,8 +50,10 @@ abstract class GroupVersioned
dest.writeString(titleGroup)
}
protected fun updateWith(source: GroupVersioned<GroupId, EntryId, Group, Entry>,
updateParents: Boolean = true) {
protected fun updateWith(
source: GroupVersioned<GroupId, EntryId, Group, Entry>,
updateParents: Boolean = true
) {
super.updateWith(source, updateParents)
titleGroup = source.titleGroup
if (updateParents) {
@@ -23,7 +23,7 @@ import com.kunzisoft.keepass.database.element.CustomData
import com.kunzisoft.keepass.database.element.DateInstant
import com.kunzisoft.keepass.database.element.Tags
import com.kunzisoft.keepass.utils.UnsignedLong
import java.util.*
import java.util.UUID
interface NodeKDBXInterface : NodeTimeInterface {
@@ -25,8 +25,7 @@ import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
import com.kunzisoft.keepass.database.element.icon.IconImage
import com.kunzisoft.keepass.utils.readListCompat
import com.kunzisoft.keepass.utils.readParcelableCompat
import java.util.*
import kotlin.collections.ArrayList
import java.util.UUID
class Template : Parcelable {
@@ -36,32 +35,34 @@ class Template : Parcelable {
var icon = IconImage()
var backgroundColor: Int? = null
var foregroundColor: Int? = null
var sections: MutableList<TemplateSection> = ArrayList()
var sections: MutableList<TemplateSection> = mutableListOf()
private set
constructor(uuid: UUID,
title: String,
icon: IconImage,
section: TemplateSection,
version: Int = 1)
: this(uuid, title, icon, ArrayList<TemplateSection>().apply {
add(section)
}, version)
constructor(
uuid: UUID,
title: String,
icon: IconImage,
section: TemplateSection,
version: Int = 1
) : this(uuid, title, icon, mutableListOf<TemplateSection>(section), version)
constructor(uuid: UUID,
title: String,
icon: IconImage,
sections: List<TemplateSection>,
version: Int = 1)
: this(uuid, title, icon, null, null, sections, version)
constructor(
uuid: UUID,
title: String,
icon: IconImage,
sections: List<TemplateSection>,
version: Int = 1
) : this(uuid, title, icon, null, null, sections, version)
constructor(uuid: UUID,
title: String,
icon: IconImage,
backgroundColor: Int?,
foregroundColor: Int?,
sections: List<TemplateSection>,
version: Int = 1) {
constructor(
uuid: UUID,
title: String,
icon: IconImage,
backgroundColor: Int?,
foregroundColor: Int?,
sections: List<TemplateSection>,
version: Int = 1
) {
this.version = version
this.uuid = uuid
this.title = title
@@ -20,7 +20,7 @@ package com.kunzisoft.keepass.database.element.template
import com.kunzisoft.keepass.database.element.icon.IconImage
import com.kunzisoft.keepass.database.element.icon.IconImageStandard
import java.util.*
import java.util.UUID
class TemplateBuilder {
@@ -25,9 +25,13 @@ import com.kunzisoft.encrypt.StreamCipher
import com.kunzisoft.keepass.database.crypto.CipherEngine
import com.kunzisoft.keepass.database.crypto.CrsAlgorithm
import com.kunzisoft.keepass.database.crypto.HmacBlock
import com.kunzisoft.keepass.database.element.*
import com.kunzisoft.keepass.database.element.Attachment
import com.kunzisoft.keepass.database.element.CustomDataItem
import com.kunzisoft.keepass.database.element.DateInstant
import com.kunzisoft.keepass.database.element.DateInstant.Companion.fromDotNetSeconds
import com.kunzisoft.keepass.database.element.DateInstant.Companion.fromISO8601Format
import com.kunzisoft.keepass.database.element.DeletedObject
import com.kunzisoft.keepass.database.element.Tags
import com.kunzisoft.keepass.database.element.binary.BinaryData
import com.kunzisoft.keepass.database.element.binary.BinaryData.Companion.BASE64_FLAG
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
@@ -40,14 +44,26 @@ import com.kunzisoft.keepass.database.element.node.NodeIdUUID
import com.kunzisoft.keepass.database.element.node.NodeKDBXInterface
import com.kunzisoft.keepass.database.element.security.MemoryProtectionConfig
import com.kunzisoft.keepass.database.element.security.ProtectedString
import com.kunzisoft.keepass.database.exception.*
import com.kunzisoft.keepass.database.exception.CorruptedDatabaseException
import com.kunzisoft.keepass.database.exception.DatabaseInputException
import com.kunzisoft.keepass.database.exception.InvalidAlgorithmDatabaseException
import com.kunzisoft.keepass.database.exception.InvalidCredentialsDatabaseException
import com.kunzisoft.keepass.database.exception.KDFMemoryDatabaseException
import com.kunzisoft.keepass.database.exception.NoMemoryDatabaseException
import com.kunzisoft.keepass.database.exception.XMLMalformedDatabaseException
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_40
import com.kunzisoft.keepass.database.file.DatabaseKDBXXML
import com.kunzisoft.keepass.stream.HashedBlockInputStream
import com.kunzisoft.keepass.stream.HmacBlockInputStream
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
import com.kunzisoft.keepass.utils.*
import com.kunzisoft.keepass.utils.UnsignedInt
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.bytes16ToUuid
import com.kunzisoft.keepass.utils.bytes64ToLong
import com.kunzisoft.keepass.utils.readBytes
import com.kunzisoft.keepass.utils.readBytes4ToUInt
import com.kunzisoft.keepass.utils.readBytesLength
import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParserFactory
@@ -56,7 +72,9 @@ import java.io.InputStream
import java.io.UnsupportedEncodingException
import java.nio.charset.Charset
import java.text.ParseException
import java.util.*
import java.util.Arrays
import java.util.Stack
import java.util.UUID
import java.util.zip.GZIPInputStream
import javax.crypto.Cipher
import javax.crypto.CipherInputStream
@@ -25,9 +25,14 @@ import android.util.Xml
import com.kunzisoft.encrypt.StreamCipher
import com.kunzisoft.keepass.database.crypto.CrsAlgorithm
import com.kunzisoft.keepass.database.crypto.kdf.KdfFactory
import com.kunzisoft.keepass.database.element.*
import com.kunzisoft.keepass.database.element.CustomData
import com.kunzisoft.keepass.database.element.CustomDataItem
import com.kunzisoft.keepass.database.element.DateInstant
import com.kunzisoft.keepass.database.element.DateInstant.Companion.toDotNetSeconds
import com.kunzisoft.keepass.database.element.DateInstant.Companion.toISO8601Format
import com.kunzisoft.keepass.database.element.DeletedObject
import com.kunzisoft.keepass.database.element.Field
import com.kunzisoft.keepass.database.element.Tags
import com.kunzisoft.keepass.database.element.binary.BinaryData.Companion.BASE64_FLAG
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
import com.kunzisoft.keepass.database.element.database.DatabaseKDBX
@@ -45,12 +50,18 @@ import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VER
import com.kunzisoft.keepass.database.file.DatabaseKDBXXML
import com.kunzisoft.keepass.stream.HashedBlockOutputStream
import com.kunzisoft.keepass.stream.HmacBlockOutputStream
import com.kunzisoft.keepass.utils.*
import com.kunzisoft.keepass.utils.UnsignedInt
import com.kunzisoft.keepass.utils.longTo8Bytes
import com.kunzisoft.keepass.utils.readAllBytes
import com.kunzisoft.keepass.utils.uuidTo16Bytes
import com.kunzisoft.keepass.utils.write4BytesUInt
import com.kunzisoft.keepass.utils.writeByte
import org.xmlpull.v1.XmlSerializer
import java.io.IOException
import java.io.OutputStream
import java.security.SecureRandom
import java.util.*
import java.util.Stack
import java.util.UUID
import java.util.zip.GZIPOutputStream
import javax.crypto.Cipher
import javax.crypto.CipherOutputStream
@@ -7,7 +7,7 @@ import com.kunzisoft.keepass.database.element.Tags
import com.kunzisoft.keepass.database.element.icon.IconImageStandard
import com.kunzisoft.keepass.database.element.icon.IconImageStandard.Companion.FOLDER_ID
import com.kunzisoft.keepass.utils.readParcelableCompat
import java.util.*
import java.util.UUID
class GroupInfo : NodeInfo {
@@ -127,7 +127,7 @@ object PasskeyEntryFields {
* Remove parameters fields use to generate auto fields
*/
fun generateAutoFields(fieldsToParse: List<Field>): MutableList<Field> {
val newCustomFields: MutableList<Field> = ArrayList(fieldsToParse)
val newCustomFields: MutableList<Field> = fieldsToParse.toMutableList()
// Remove parameter fields
val usernameField = Field(FIELD_USERNAME)
val privateKeyField = Field(FIELD_PRIVATE_KEY)
@@ -448,7 +448,7 @@ object OtpEntryFields {
if (username.isEmpty())
username = otpElement.name
// Add OTP field
val mutableCustomFields = customFields as ArrayList<Field>
val mutableCustomFields = customFields
val otpField = buildOtpField(otpElement, null, null)
if (mutableCustomFields.contains(otpField)) {
mutableCustomFields.remove(otpField)
@@ -464,7 +464,7 @@ object OtpEntryFields {
* Remove parameters fields use to generate auto fields
*/
fun generateAutoFields(fieldsToParse: List<Field>): MutableList<Field> {
val newCustomFields: MutableList<Field> = ArrayList(fieldsToParse)
val newCustomFields: MutableList<Field> = fieldsToParse.toMutableList()
// Remove parameter fields
val otpField = Field(OTP_FIELD)
val totpSeedField = Field(TOTP_SEED_FIELD)
@@ -19,14 +19,14 @@
*/
package com.kunzisoft.keepass.stream
import com.kunzisoft.keepass.database.crypto.HmacBlock
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.bytes4ToUInt
import com.kunzisoft.keepass.utils.readBytesLength
import com.kunzisoft.keepass.utils.uLongTo8Bytes
import com.kunzisoft.keepass.database.crypto.HmacBlock
import java.io.IOException
import java.io.InputStream
import java.util.*
import java.util.Arrays
import javax.crypto.Mac
class HmacBlockInputStream(private val baseStream: InputStream, private val verify: Boolean, private val key: ByteArray) : InputStream() {
@@ -27,7 +27,7 @@ import java.io.InputStream
import java.io.OutputStream
import java.nio.ByteBuffer
import java.nio.charset.Charset
import java.util.*
import java.util.UUID
/**
* Read all data of stream and invoke [readBytes] each time the buffer is full or no more data to read.
@@ -319,7 +319,7 @@ private val defaultCharset = Charset.forName("UTF-8")
private val CRLFbuf = byteArrayOf(0x0D, 0x0A)
private val CRLF = String(CRLFbuf)
private val SEP = System.getProperty("line.separator")
private val SEP = System.lineSeparator()
private val REPLACE = SEP != CRLF
fun bytesToString(buf: ByteArray, replaceCRLF: Boolean = true): String {
@@ -331,7 +331,7 @@ fun bytesToString(buf: ByteArray, replaceCRLF: Boolean = true): String {
// Get string
var jstring = String(buf, 0, len, defaultCharset)
if (replaceCRLF && REPLACE) {
jstring = jstring.replace(CRLF, SEP!!)
jstring = jstring.replace(CRLF, SEP)
}
return jstring
}
@@ -393,7 +393,7 @@ fun writeStringToStream(outputStream: OutputStream, string: String?): Int {
}
if (REPLACE) {
str = str.replace(SEP!!, CRLF)
str = str.replace(SEP, CRLF)
}
val initial = str.toByteArray(defaultCharset)
@@ -29,10 +29,15 @@ import android.content.pm.ResolveInfo
import android.net.Uri
import android.os.Build
import android.util.Log
import java.io.*
import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.InputStream
import java.io.OutputStream
import java.net.MalformedURLException
import java.net.URL
import java.util.*
import java.util.Locale
fun String.parseUri(): Uri? {
return if (this.isNotEmpty()) Uri.parse(this) else null
@@ -19,13 +19,13 @@
*/
package com.kunzisoft.keepass.tests.crypto
import com.kunzisoft.keepass.utils.readBytesLength
import com.kunzisoft.keepass.database.crypto.EncryptionAlgorithm
import com.kunzisoft.keepass.utils.readBytesLength
import org.junit.Assert.assertArrayEquals
import org.junit.Test
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.util.*
import java.util.Random
import javax.crypto.Cipher
import javax.crypto.CipherInputStream
import javax.crypto.CipherOutputStream
@@ -20,13 +20,24 @@
package com.kunzisoft.keepass.tests.utils
import com.kunzisoft.keepass.database.element.DateInstant
import com.kunzisoft.keepass.utils.*
import com.kunzisoft.keepass.utils.UnsignedInt
import com.kunzisoft.keepass.utils.UnsignedLong
import com.kunzisoft.keepass.utils.bytes16ToUuid
import com.kunzisoft.keepass.utils.bytes2ToUShort
import com.kunzisoft.keepass.utils.bytes4ToUInt
import com.kunzisoft.keepass.utils.bytes5ToDate
import com.kunzisoft.keepass.utils.bytes64ToULong
import com.kunzisoft.keepass.utils.dateTo5Bytes
import com.kunzisoft.keepass.utils.uIntTo4Bytes
import com.kunzisoft.keepass.utils.uLongTo8Bytes
import com.kunzisoft.keepass.utils.uShortTo2Bytes
import com.kunzisoft.keepass.utils.uuidTo16Bytes
import junit.framework.TestCase
import org.joda.time.DateTime
import org.joda.time.Instant
import org.junit.Assert.assertArrayEquals
import java.io.ByteArrayOutputStream
import java.util.*
import java.util.Random
class ValuesTest : TestCase() {