Inherit colors and icon from template #1213 #1130

This commit is contained in:
J-Jamet
2022-01-25 17:59:06 +01:00
parent 98804db478
commit 05d1656a9e
6 changed files with 18 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
KeePassDX(3.2.0)
* Manage data merge #840 #977
* Inherit color from template #1213
* Inherit colors and icon from template #1213 #1130
* Add path in quick search
* Small fixes

View File

@@ -195,7 +195,6 @@ class EntryActivity : DatabaseLockActivity() {
ColorDrawable(mColorAccent)
}
val entryTemplate = entryInfoHistory.template
val entryInfo = entryInfoHistory.entryInfo
// Manage entry copy to start notification if allowed (at the first start)
if (savedInstanceState == null) {
@@ -215,8 +214,8 @@ class EntryActivity : DatabaseLockActivity() {
toolbar?.title = entryTitle
mUrl = entryInfo.url
// Assign colors
mBackgroundColor = entryInfo.backgroundColor ?: entryTemplate.backgroundColor
mForegroundColor = entryInfo.foregroundColor ?: entryTemplate.foregroundColor
mBackgroundColor = entryInfo.backgroundColor
mForegroundColor = entryInfo.foregroundColor
loadingView?.hideByFading()
mEntryLoaded = true

View File

@@ -185,7 +185,6 @@ class NodesAdapter (private val context: Context,
&& oldItem.username == newItem.username
&& oldItem.backgroundColor == newItem.backgroundColor
&& oldItem.foregroundColor == newItem.foregroundColor
&& database.getTemplate(oldItem) == database.getTemplate(newItem)
&& oldItem.getOtpElement() == newItem.getOtpElement()
&& oldItem.containsAttachment() == newItem.containsAttachment()
} else if (oldItem is Group && newItem is Group) {
@@ -398,8 +397,6 @@ class NodesAdapter (private val context: Context,
// Specific elements for entry
if (subNode.type == Type.ENTRY) {
val entry = subNode as Entry
val entryTemplate = database.getTemplate(entry)
database.startManageEntry(entry)
holder.text.text = entry.getVisualTitle()
@@ -439,7 +436,7 @@ class NodesAdapter (private val context: Context,
if (entry.containsAttachment()) View.VISIBLE else View.GONE
// Assign colors
val backgroundColor = entry.backgroundColor ?: entryTemplate?.backgroundColor
val backgroundColor = entry.backgroundColor
if (!holder.container.isSelected) {
if (backgroundColor != null) {
holder.container.setBackgroundColor(backgroundColor)
@@ -449,7 +446,7 @@ class NodesAdapter (private val context: Context,
} else {
holder.container.setBackgroundColor(mColorAccentLight)
}
val foregroundColor = entry.foregroundColor ?: entryTemplate?.foregroundColor
val foregroundColor = entry.foregroundColor
if (!holder.container.isSelected) {
if (foregroundColor != null) {
holder.text.setTextColor(foregroundColor)

View File

@@ -93,6 +93,7 @@ abstract class TemplateAbstractView<
fun setTemplate(template: Template?) {
if (mTemplate != template) {
mTemplate = template
applyTemplateParametersToEntry()
if (mEntryInfo != null) {
populateEntryInfoWithViews(templateFieldNotEmpty = true,
retrieveDefaultValues = false)
@@ -104,6 +105,16 @@ abstract class TemplateAbstractView<
}
}
private fun applyTemplateParametersToEntry() {
// Change the entry icon by the template icon
mTemplate?.icon?.let { templateIcon ->
mEntryInfo?.icon = templateIcon
}
// Change the entry color by the template color
mEntryInfo?.backgroundColor = mTemplate?.backgroundColor
mEntryInfo?.foregroundColor = mTemplate?.foregroundColor
}
private fun buildTemplate() {
// Retrieve preferences
mHideProtectedValue = PreferencesUtil.hideProtectedValue(context)
@@ -402,8 +413,6 @@ abstract class TemplateAbstractView<
if (mEntryInfo == null)
mEntryInfo = EntryInfo()
// Icon already populate
try {
val titleView: TEntryFieldView? = findViewWithTag(FIELD_TITLE_TAG)
titleView?.value?.let {

View File

@@ -1,4 +1,4 @@
* Manage data merge #840 #977
* Inherit color from template #1213
* Inherit colors and icon from template #1213 #1130
* Add path in quick search
* Small fixes

View File

@@ -1,4 +1,4 @@
* Gestion de la fusion des données #840 #977
* Héritage de la couleur du gabarit #1213
* Héritage des couleurs et icone du gabarit #1213
* Ajout du chemin dans la recherche rapide
* Petis correctifs