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 1ebd24de2..84adc6cfa 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt @@ -21,6 +21,7 @@ package com.kunzisoft.keepass.activities import android.app.Activity import android.content.Intent import android.graphics.Color +import android.graphics.drawable.ColorDrawable import android.net.Uri import android.os.Bundle import android.os.Handler @@ -69,6 +70,8 @@ import com.kunzisoft.keepass.timeout.TimeoutHelper import com.kunzisoft.keepass.utils.UriUtil.openUrl import com.kunzisoft.keepass.utils.UuidUtil import com.kunzisoft.keepass.utils.getParcelableExtraCompat +import com.kunzisoft.keepass.view.changeControlColor +import com.kunzisoft.keepass.view.changeTitleColor import com.kunzisoft.keepass.view.hideByFading import com.kunzisoft.keepass.view.showActionErrorIfNeeded import com.kunzisoft.keepass.viewmodels.EntryViewModel @@ -110,6 +113,8 @@ class EntryActivity : DatabaseLockActivity() { private var mIcon: IconImage? = null private var mColorSecondary: Int = 0 + private var mColorSurface: Int = 0 + private var mColorOnSurface: Int = 0 private var mColorBackground: Int = 0 private var mBackgroundColor: Int? = null private var mForegroundColor: Int? = null @@ -142,10 +147,16 @@ class EntryActivity : DatabaseLockActivity() { // Retrieve the textColor to tint the toolbar val taColorSecondary = theme.obtainStyledAttributes(intArrayOf(R.attr.colorSecondary)) + val taColorSurface = theme.obtainStyledAttributes(intArrayOf(R.attr.colorSurface)) + val taColorOnSurface = theme.obtainStyledAttributes(intArrayOf(R.attr.colorOnSurface)) val taColorBackground = theme.obtainStyledAttributes(intArrayOf(android.R.attr.windowBackground)) mColorSecondary = taColorSecondary.getColor(0, Color.BLACK) + mColorSurface = taColorSurface.getColor(0, Color.BLACK) + mColorOnSurface = taColorOnSurface.getColor(0, Color.BLACK) mColorBackground = taColorBackground.getColor(0, Color.BLACK) taColorSecondary.recycle() + taColorSurface.recycle() + taColorOnSurface.recycle() taColorBackground.recycle() // Init Tags adapter @@ -355,6 +366,8 @@ class EntryActivity : DatabaseLockActivity() { } private fun applyToolbarColors() { + collapsingToolbarLayout?.setBackgroundColor(mBackgroundColor ?: mColorSurface) + collapsingToolbarLayout?.contentScrim = ColorDrawable(mBackgroundColor ?: mColorSurface) val backgroundDarker = if (mBackgroundColor != null) { ColorUtils.blendARGB(mBackgroundColor!!, Color.WHITE, 0.1f) } else { @@ -371,6 +384,8 @@ class EntryActivity : DatabaseLockActivity() { ) } } + toolbar?.changeControlColor(mForegroundColor ?: mColorOnSurface) + collapsingToolbarLayout?.changeTitleColor(mForegroundColor ?: mColorOnSurface) } override fun onCreateOptionsMenu(menu: Menu): Boolean { diff --git a/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt b/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt index ea9115a73..41c7160b9 100644 --- a/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt +++ b/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt @@ -20,6 +20,7 @@ package com.kunzisoft.keepass.adapters import android.content.Context +import android.content.res.ColorStateList import android.graphics.Color import android.util.Log import android.util.TypedValue @@ -29,6 +30,7 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.annotation.ColorInt +import androidx.core.view.ViewCompat import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.SortedList import androidx.recyclerview.widget.SortedListAdapterCallback @@ -428,6 +430,16 @@ class NodesAdapter ( if (entry.containsAttachment()) View.VISIBLE else View.GONE // Assign colors + ViewCompat.setBackgroundTintList( + holder.container, + ColorStateList.valueOf( + if (!holder.container.isSelected) { + (if (mShowEntryColors) entry.backgroundColor else null) ?: Color.TRANSPARENT + } else { + mColorSecondary + } + ) + ) val foregroundColor = if (mShowEntryColors) entry.foregroundColor else null if (!holder.container.isSelected) { if (foregroundColor != null) { diff --git a/app/src/main/res/layout/item_list_nodes_entry.xml b/app/src/main/res/layout/item_list_nodes_entry.xml index 6d490ce84..5e64a2922 100644 --- a/app/src/main/res/layout/item_list_nodes_entry.xml +++ b/app/src/main/res/layout/item_list_nodes_entry.xml @@ -21,14 +21,13 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/node_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingVertical="@dimen/selectable_margin_vertical" android:paddingHorizontal="@dimen/selectable_margin_horizontal">