diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt
index 6f3d6603b..fffe79658 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt
@@ -36,6 +36,9 @@ import androidx.activity.result.ActivityResultLauncher
import androidx.activity.viewModels
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
+import androidx.core.graphics.BlendModeColorFilterCompat
+import androidx.core.graphics.BlendModeCompat
+import androidx.core.graphics.ColorUtils
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.kunzisoft.keepass.R
@@ -99,9 +102,10 @@ class EntryActivity : DatabaseLockActivity() {
}
private var mIcon: IconImage? = null
- private var mIconColor: Int = 0
+ private var mColorAccent: Int = 0
private var mControlColor: Int = 0
- private var molorPrimary: Int = 0
+ private var mColorPrimary: Int = 0
+ private var mColorBackground: Int = 0
private var mBackgroundColor: Int? = null
private var mForegroundColor: Int? = null
@@ -129,16 +133,19 @@ class EntryActivity : DatabaseLockActivity() {
collapsingToolbarLayout?.title = " "
toolbar?.title = " "
- // Retrieve the textColor to tint the icon
- val taIconColor = theme.obtainStyledAttributes(intArrayOf(R.attr.colorAccent))
- mIconColor = taIconColor.getColor(0, Color.BLACK)
- taIconColor.recycle()
- val taColorControl = theme.obtainStyledAttributes(intArrayOf(R.attr.colorControlNormal))
- mControlColor = taColorControl.getColor(0, Color.BLACK)
- taColorControl.recycle()
+ // Retrieve the textColor to tint the toolbar
+ val taColorAccent = theme.obtainStyledAttributes(intArrayOf(R.attr.colorAccent))
+ val taControlColor = theme.obtainStyledAttributes(intArrayOf(R.attr.toolbarColorControl))
val taColorPrimary = theme.obtainStyledAttributes(intArrayOf(R.attr.colorPrimary))
- molorPrimary = taColorPrimary.getColor(0, Color.BLACK)
+ val taColorBackground = theme.obtainStyledAttributes(intArrayOf(android.R.attr.windowBackground))
+ mColorAccent = taColorAccent.getColor(0, Color.BLACK)
+ mControlColor = taControlColor.getColor(0, Color.BLACK)
+ mColorPrimary = taColorPrimary.getColor(0, Color.BLACK)
+ mColorBackground = taColorBackground.getColor(0, Color.BLACK)
+ taColorAccent.recycle()
+ taControlColor.recycle()
taColorPrimary.recycle()
+ taColorBackground.recycle()
// Get Entry from UUID
try {
@@ -183,10 +190,8 @@ class EntryActivity : DatabaseLockActivity() {
// Assign history dedicated view
historyView?.visibility = if (entryIsHistory) View.VISIBLE else View.GONE
if (entryIsHistory) {
- val taColorAccent = theme.obtainStyledAttributes(intArrayOf(R.attr.colorAccent))
collapsingToolbarLayout?.contentScrim =
- ColorDrawable(taColorAccent.getColor(0, Color.BLACK))
- taColorAccent.recycle()
+ ColorDrawable(mColorAccent)
}
val entryInfo = entryInfoHistory.entryInfo
@@ -201,9 +206,6 @@ class EntryActivity : DatabaseLockActivity() {
}
// Assign title icon
mIcon = entryInfo.icon
- titleIconView?.let { iconView ->
- mIconDrawableFactory?.assignDatabaseIcon(iconView, entryInfo.icon, mIconColor)
- }
// Assign title text
val entryTitle =
if (entryInfo.title.isNotEmpty()) entryInfo.title else UuidUtil.toHexString(entryInfo.id)
@@ -272,13 +274,6 @@ class EntryActivity : DatabaseLockActivity() {
super.onDatabaseRetrieved(database)
mEntryViewModel.loadDatabase(database)
-
- // Assign title icon
- mIcon?.let { icon ->
- titleIconView?.let { iconView ->
- mIconDrawableFactory?.assignDatabaseIcon(iconView, icon, mIconColor)
- }
- }
}
override fun onDatabaseActionFinished(
@@ -325,8 +320,24 @@ class EntryActivity : DatabaseLockActivity() {
}
private fun applyToolbarColors() {
- appBarLayout?.setBackgroundColor(mBackgroundColor ?: molorPrimary)
- collapsingToolbarLayout?.contentScrim = ColorDrawable(mBackgroundColor ?: molorPrimary)
+ appBarLayout?.setBackgroundColor(mBackgroundColor ?: mColorPrimary)
+ collapsingToolbarLayout?.contentScrim = ColorDrawable(mBackgroundColor ?: mColorPrimary)
+ val backgroundDarker = if (mBackgroundColor != null) {
+ ColorUtils.blendARGB(mBackgroundColor!!, Color.BLACK, 0.1f)
+ } else {
+ mColorBackground
+ }
+ titleIconView?.background?.colorFilter = BlendModeColorFilterCompat
+ .createBlendModeColorFilterCompat(backgroundDarker, BlendModeCompat.SRC_IN)
+ mIcon?.let { icon ->
+ titleIconView?.let { iconView ->
+ mIconDrawableFactory?.assignDatabaseIcon(
+ iconView,
+ icon,
+ mForegroundColor ?: mColorAccent
+ )
+ }
+ }
toolbar?.changeControlColor(mForegroundColor ?: mControlColor)
collapsingToolbarLayout?.changeTitleColor(mForegroundColor ?: mControlColor)
}
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index a59fcc14d..8e927c2b9 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -27,6 +27,7 @@
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 9ae579815..6e50fcb2f 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -22,6 +22,7 @@
8dp
22dp
8dp
+ 15dp
144dp
6dp
10dp
diff --git a/app/src/main/res/values/style_classic.xml b/app/src/main/res/values/style_classic.xml
index 18752233e..d13fe72a8 100644
--- a/app/src/main/res/values/style_classic.xml
+++ b/app/src/main/res/values/style_classic.xml
@@ -31,6 +31,7 @@
- @color/cyan_lightest
- @color/cyan_lightest
- @color/white_darkest
+ - @color/grey_light
- @style/KeepassDXStyle.Toolbar.Clear
- @style/KeepassDXStyle.Toolbar.Home.Clear
- @style/KeepassDXStyle.Toolbar.Special.Clear
diff --git a/app/src/main/res/values/style_divine.xml b/app/src/main/res/values/style_divine.xml
index 1e572de68..699cddc49 100644
--- a/app/src/main/res/values/style_divine.xml
+++ b/app/src/main/res/values/style_divine.xml
@@ -33,6 +33,7 @@
- @color/green_light
- @color/green_light
- @color/white
+ - @color/grey_light
- @style/KeepassDXStyle.Toolbar.White
- @style/KeepassDXStyle.Toolbar.Home.White
- @style/KeepassDXStyle.Toolbar.Special.White
diff --git a/app/src/main/res/values/style_kunzite.xml b/app/src/main/res/values/style_kunzite.xml
index 8493abfcc..53e678d37 100644
--- a/app/src/main/res/values/style_kunzite.xml
+++ b/app/src/main/res/values/style_kunzite.xml
@@ -101,6 +101,7 @@
- @color/purple_lighter
- @color/purple_lighter
- @color/black_purple_dark
+ - @color/white
- @style/KeepassDXStyle.Toolbar.Purple.Dark
- @style/KeepassDXStyle.Toolbar.Home.Purple.Dark
- @style/KeepassDXStyle.Toolbar.Special.Purple.Dark
diff --git a/app/src/main/res/values/style_moon.xml b/app/src/main/res/values/style_moon.xml
index 41251a4ef..98fbcbc8e 100644
--- a/app/src/main/res/values/style_moon.xml
+++ b/app/src/main/res/values/style_moon.xml
@@ -29,6 +29,7 @@
- @color/blue_light
- @color/blue_lighter
- @color/white_dark
+ - @color/white
- @style/KeepassDXStyle.Toolbar.Blue
- @style/KeepassDXStyle.Toolbar.Home.Blue
- @style/KeepassDXStyle.Toolbar.Special.Blue
diff --git a/app/src/main/res/values/style_sun.xml b/app/src/main/res/values/style_sun.xml
index f1b05d64f..d48239d38 100644
--- a/app/src/main/res/values/style_sun.xml
+++ b/app/src/main/res/values/style_sun.xml
@@ -29,6 +29,7 @@
- @color/red
- @color/red_lighter
- @color/white_dark
+ - @color/white
- @style/KeepassDXStyle.Toolbar.Red
- @style/KeepassDXStyle.Toolbar.Home.Red
- @style/KeepassDXStyle.Toolbar.Special.Red
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 0155638e0..98f672bc9 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -78,6 +78,7 @@
- @style/Widget.AppCompat.Toolbar
+ - @color/white
- @style/KeepassDXStyle.Toolbar.Light
- @style/KeepassDXStyle.Toolbar.Home.Light
- @style/KeepassDXStyle.Toolbar.Special.Light
@@ -141,6 +142,7 @@
- @style/Widget.AppCompat.Toolbar
+ - @color/white
- @style/KeepassDXStyle.Toolbar.Night
- @style/KeepassDXStyle.Toolbar.Home.Night
- @style/KeepassDXStyle.Toolbar.Special.Night