diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt
index 129d89b29..b26c94c18 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt
@@ -42,15 +42,11 @@ import androidx.appcompat.view.ActionMode
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
-import androidx.core.graphics.BlendModeColorFilterCompat
-import androidx.core.graphics.BlendModeCompat
import androidx.core.view.GravityCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.drawerlayout.widget.DrawerLayout
-import androidx.navigation.ui.AppBarConfiguration
import androidx.recyclerview.widget.RecyclerView
-import com.google.android.material.navigation.NavigationView
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.dialogs.*
import com.kunzisoft.keepass.activities.fragments.GroupFragment
@@ -96,12 +92,7 @@ class GroupActivity : DatabaseLockActivity(),
// Views
private var drawerLayout: DrawerLayout? = null
- private var databaseNavView: NavigationView? = null
- private var databaseNavContainerView: View? = null
- private var databaseNavIconView: ImageView? = null
- private var databaseNavColorView: ImageView? = null
- private var databaseNavNameView: TextView? = null
- private var databaseNavVersionView: TextView? = null
+ private var databaseNavView: NavigationDatabaseView? = null
private var rootContainerView: ViewGroup? = null
private var coordinatorLayout: CoordinatorLayout? = null
private var lockView: View? = null
@@ -118,8 +109,6 @@ class GroupActivity : DatabaseLockActivity(),
private var breadcrumbListView: RecyclerView? = null
private var loadingView: ProgressBar? = null
- private lateinit var appBarConfiguration: AppBarConfiguration
-
private val mGroupViewModel: GroupViewModel by viewModels()
private val mGroupEditViewModel: GroupEditViewModel by viewModels()
@@ -235,11 +224,6 @@ class GroupActivity : DatabaseLockActivity(),
// Initialize views
drawerLayout = findViewById(R.id.drawer_layout)
databaseNavView = findViewById(R.id.database_nav_view)
- databaseNavContainerView = databaseNavView?.getHeaderView(0)
- databaseNavIconView = databaseNavContainerView?.findViewById(R.id.nav_database_icon)
- databaseNavColorView = databaseNavContainerView?.findViewById(R.id.nav_database_color)
- databaseNavNameView = databaseNavContainerView?.findViewById(R.id.nav_database_name)
- databaseNavVersionView = databaseNavContainerView?.findViewById(R.id.nav_database_version)
rootContainerView = findViewById(R.id.activity_group_container_view)
coordinatorLayout = findViewById(R.id.group_coordinator)
numberChildrenView = findViewById(R.id.group_numbers)
@@ -567,21 +551,18 @@ class GroupActivity : DatabaseLockActivity(),
// Search suggestion
database?.let {
val databaseName = it.name.ifEmpty { getString(R.string.database) }
- databaseNavNameView?.text = databaseName
+ databaseNavView?.setDatabaseName(databaseName)
databaseNameView?.text = databaseName
- databaseNavVersionView?.text = it.version
+ databaseNavView?.setDatabaseVersion(it.version)
val customColor = it.customColor
+ databaseNavView?.setDatabaseColor(customColor)
if (customColor != null) {
- databaseNavColorView?.drawable?.colorFilter = BlendModeColorFilterCompat
- .createBlendModeColorFilterCompat(customColor, BlendModeCompat.SRC_IN)
- databaseNavColorView?.visibility = View.VISIBLE
databaseColorView?.visibility = View.VISIBLE
databaseColorView?.setColorFilter(
customColor,
PorterDuff.Mode.SRC_IN
)
} else {
- databaseNavColorView?.visibility = View.GONE
databaseColorView?.visibility = View.GONE
}
mBreadcrumbAdapter?.iconDrawableFactory = it.iconDrawableFactory
diff --git a/app/src/main/java/com/kunzisoft/keepass/view/NavigationDatabaseView.kt b/app/src/main/java/com/kunzisoft/keepass/view/NavigationDatabaseView.kt
new file mode 100644
index 000000000..b0ab2277f
--- /dev/null
+++ b/app/src/main/java/com/kunzisoft/keepass/view/NavigationDatabaseView.kt
@@ -0,0 +1,55 @@
+package com.kunzisoft.keepass.view
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.core.graphics.BlendModeColorFilterCompat
+import androidx.core.graphics.BlendModeCompat
+import com.google.android.material.navigation.NavigationView
+import com.kunzisoft.keepass.R
+
+class NavigationDatabaseView @JvmOverloads constructor(context: Context,
+ attrs: AttributeSet? = null,
+ defStyle: Int = 0)
+ : NavigationView(context, attrs, defStyle) {
+
+ private var databaseNavContainerView: View? = null
+ private var databaseNavIconView: ImageView? = null
+ private var databaseNavColorView: ImageView? = null
+ private var databaseNavNameView: TextView? = null
+ private var databaseNavVersionView: TextView? = null
+
+ init {
+ inflateHeaderView(R.layout.nav_header_database)
+ databaseNavIconView = databaseNavContainerView?.findViewById(R.id.nav_database_icon)
+ databaseNavColorView = databaseNavContainerView?.findViewById(R.id.nav_database_color)
+ databaseNavNameView = databaseNavContainerView?.findViewById(R.id.nav_database_name)
+ databaseNavVersionView = databaseNavContainerView?.findViewById(R.id.nav_database_version)
+ }
+
+ override fun inflateHeaderView(res: Int): View {
+ val headerView = super.inflateHeaderView(res)
+ databaseNavContainerView = headerView
+ return headerView
+ }
+
+ fun setDatabaseName(name: String) {
+ databaseNavNameView?.text = name
+ }
+
+ fun setDatabaseVersion(version: String) {
+ databaseNavVersionView?.text = version
+ }
+
+ fun setDatabaseColor(color: Int?) {
+ if (color != null) {
+ databaseNavColorView?.drawable?.colorFilter = BlendModeColorFilterCompat
+ .createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_IN)
+ databaseNavColorView?.visibility = View.VISIBLE
+ } else {
+ databaseNavColorView?.visibility = View.GONE
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_group.xml b/app/src/main/res/layout/activity_group.xml
index 1e5a50f50..70a53feca 100644
--- a/app/src/main/res/layout/activity_group.xml
+++ b/app/src/main/res/layout/activity_group.xml
@@ -164,12 +164,11 @@
-
diff --git a/app/src/main/res/layout/nav_header_main.xml b/app/src/main/res/layout/nav_header_database.xml
similarity index 97%
rename from app/src/main/res/layout/nav_header_main.xml
rename to app/src/main/res/layout/nav_header_database.xml
index 91b6599e2..7cb06a0fd 100644
--- a/app/src/main/res/layout/nav_header_main.xml
+++ b/app/src/main/res/layout/nav_header_database.xml
@@ -29,7 +29,8 @@
android:paddingRight="8dp"
style="@style/KeepassDXStyle.TextAppearance.Info"
android:textSize="10sp"
- tools:text="version" />
+ tools:text="version"
+ tools:ignore="SmallSp" />