mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add pool of tags
This commit is contained in:
@@ -112,10 +112,17 @@ class GroupEditDialogFragment : DatabaseDialogFragment() {
|
||||
|
||||
override fun onDatabaseRetrieved(database: Database?) {
|
||||
super.onDatabaseRetrieved(database)
|
||||
|
||||
mPopulateIconMethod = { imageView, icon ->
|
||||
database?.iconDrawableFactory?.assignDatabaseIcon(imageView, icon, mIconColor)
|
||||
}
|
||||
mPopulateIconMethod?.invoke(iconButtonView, mGroupInfo.icon)
|
||||
|
||||
tagsAdapter = TagsProposalAdapter(requireContext(), database?.tagPool)
|
||||
tagsCompletionView.apply {
|
||||
threshold = 1
|
||||
setAdapter(tagsAdapter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
@@ -149,13 +156,6 @@ class GroupEditDialogFragment : DatabaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO default tags in pool
|
||||
tagsAdapter = TagsProposalAdapter(requireContext(), arrayOf())
|
||||
tagsCompletionView.apply {
|
||||
threshold = 1
|
||||
setAdapter(tagsAdapter)
|
||||
}
|
||||
|
||||
// populate info in views
|
||||
populateInfoToViews(mGroupInfo)
|
||||
|
||||
|
||||
@@ -98,13 +98,6 @@ class EntryEditFragment: DatabaseFragment() {
|
||||
(itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
|
||||
}
|
||||
|
||||
// TODO default tags in pool
|
||||
tagsAdapter = TagsProposalAdapter(requireContext(), arrayOf())
|
||||
tagsCompletionView.apply {
|
||||
threshold = 1
|
||||
setAdapter(tagsAdapter)
|
||||
}
|
||||
|
||||
templateView.apply {
|
||||
setOnIconClickListener {
|
||||
mEntryEditViewModel.requestIconSelection(templateView.getIcon())
|
||||
@@ -288,6 +281,12 @@ class EntryEditFragment: DatabaseFragment() {
|
||||
attachmentsContainerView.expand(true)
|
||||
}
|
||||
}
|
||||
|
||||
tagsAdapter = TagsProposalAdapter(requireContext(), database?.tagPool)
|
||||
tagsCompletionView.apply {
|
||||
threshold = 1
|
||||
setAdapter(tagsAdapter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assignEntryInfo(entryInfo: EntryInfo?) {
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.kunzisoft.keepass.adapters
|
||||
|
||||
import android.content.Context
|
||||
import com.kunzisoft.keepass.database.element.Tags
|
||||
import com.tokenautocomplete.FilteredArrayAdapter
|
||||
|
||||
class TagsProposalAdapter(context: Context, proposal: Array<String>)
|
||||
: FilteredArrayAdapter<String>(context, android.R.layout.simple_list_item_1, proposal) {
|
||||
class TagsProposalAdapter(context: Context, proposal: Tags?)
|
||||
: FilteredArrayAdapter<String>(
|
||||
context,
|
||||
android.R.layout.simple_list_item_1,
|
||||
(proposal ?: Tags()).toList()
|
||||
) {
|
||||
|
||||
override fun keepObject(obj: String, mask: String?): Boolean {
|
||||
if (mask == null)
|
||||
|
||||
@@ -816,6 +816,11 @@ class Database {
|
||||
}, omitBackup, max)
|
||||
}
|
||||
|
||||
val tagPool: Tags
|
||||
get() {
|
||||
return mDatabaseKDBX?.tagPool ?: Tags()
|
||||
}
|
||||
|
||||
val attachmentPool: AttachmentPool
|
||||
get() {
|
||||
return mDatabaseKDB?.attachmentPool ?: mDatabaseKDBX?.attachmentPool ?: AttachmentPool()
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.kunzisoft.keepass.utils.StringUtil.removeSpaceChars
|
||||
|
||||
class Tags: Parcelable {
|
||||
|
||||
private val mTags = ArrayList<String>()
|
||||
private val mTags = mutableListOf<String>()
|
||||
|
||||
constructor()
|
||||
|
||||
@@ -40,6 +40,12 @@ class Tags: Parcelable {
|
||||
mTags.add(tag)
|
||||
}
|
||||
|
||||
fun put(tags: Tags) {
|
||||
tags.mTags.forEach {
|
||||
put(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
return mTags.isEmpty()
|
||||
}
|
||||
@@ -52,6 +58,10 @@ class Tags: Parcelable {
|
||||
mTags.clear()
|
||||
}
|
||||
|
||||
fun toList(): List<String> {
|
||||
return mTags
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return mTags.joinToString(DELIMITER.toString())
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.kunzisoft.keepass.database.crypto.kdf.KdfParameters
|
||||
import com.kunzisoft.keepass.database.element.CustomData
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
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.database.DatabaseKDB.Companion.BACKUP_FOLDER_TITLE
|
||||
import com.kunzisoft.keepass.database.element.entry.EntryKDBX
|
||||
@@ -165,6 +166,8 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
||||
var publicCustomData = VariantDictionary()
|
||||
val customData = CustomData()
|
||||
|
||||
val tagPool = Tags()
|
||||
|
||||
var localizedAppName = "KeePassDX"
|
||||
|
||||
constructor()
|
||||
@@ -833,16 +836,19 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
||||
|
||||
override fun addEntryTo(newEntry: EntryKDBX, parent: GroupKDBX?) {
|
||||
super.addEntryTo(newEntry, parent)
|
||||
tagPool.put(newEntry.tags)
|
||||
mFieldReferenceEngine.clear()
|
||||
}
|
||||
|
||||
override fun updateEntry(entry: EntryKDBX) {
|
||||
super.updateEntry(entry)
|
||||
tagPool.put(entry.tags)
|
||||
mFieldReferenceEngine.clear()
|
||||
}
|
||||
|
||||
override fun removeEntryFrom(entryToRemove: EntryKDBX, parent: GroupKDBX?) {
|
||||
super.removeEntryFrom(entryToRemove, parent)
|
||||
// Do not remove tags from pool, it's only in temp memory
|
||||
mFieldReferenceEngine.clear()
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.util.Log
|
||||
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.EncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.database.crypto.HmacBlock
|
||||
import com.kunzisoft.keepass.database.element.*
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
@@ -876,7 +875,9 @@ class DatabaseInputKDBX(database: DatabaseKDBX)
|
||||
|
||||
@Throws(IOException::class, XmlPullParserException::class)
|
||||
private fun readTags(xpp: XmlPullParser): Tags {
|
||||
return Tags(readString(xpp))
|
||||
val tags = Tags(readString(xpp))
|
||||
mDatabase.tagPool.put(tags)
|
||||
return tags
|
||||
}
|
||||
|
||||
@Throws(XmlPullParserException::class, IOException::class)
|
||||
|
||||
Reference in New Issue
Block a user