mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix database list animation
This commit is contained in:
@@ -22,16 +22,20 @@ package com.kunzisoft.keepass.adapters
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.util.TypedValue
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.ViewSwitcher
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.model.DatabaseFile
|
||||
import com.kunzisoft.keepass.view.collapse
|
||||
import com.kunzisoft.keepass.view.expand
|
||||
|
||||
class FileDatabaseHistoryAdapter(context: Context)
|
||||
: RecyclerView.Adapter<FileDatabaseHistoryAdapter.FileDatabaseHistoryViewHolder>() {
|
||||
@@ -106,8 +110,17 @@ class FileDatabaseHistoryAdapter(context: Context)
|
||||
|
||||
// Click on information
|
||||
val isExpanded = databaseFile == mExpandedDatabaseFile
|
||||
//This line hides or shows the layout in question
|
||||
holder.fileExpandContainer.visibility = if (isExpanded) View.VISIBLE else View.GONE
|
||||
// Hides or shows info
|
||||
holder.fileExpandContainer.apply {
|
||||
if (isExpanded) {
|
||||
if (visibility != View.VISIBLE) {
|
||||
visibility = View.VISIBLE
|
||||
expand(true, resources.getDimensionPixelSize(R.dimen.item_file_info_height))
|
||||
}
|
||||
} else {
|
||||
collapse(true)
|
||||
}
|
||||
}
|
||||
|
||||
// Save alias modification
|
||||
holder.fileAliasCloseButton.setOnClickListener {
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.text.method.PasswordTransformationMethod
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.updatePadding
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -74,8 +73,8 @@ fun Snackbar.asError(): Snackbar {
|
||||
return this
|
||||
}
|
||||
|
||||
fun Toolbar.collapse(animate: Boolean = true) {
|
||||
val recordBarHeight = layoutParams.height
|
||||
fun View.collapse(animate: Boolean = true) {
|
||||
val recordViewHeight = layoutParams.height
|
||||
val slideAnimator = ValueAnimator.ofInt(height, 0)
|
||||
if (animate)
|
||||
slideAnimator.duration = 300L
|
||||
@@ -83,7 +82,7 @@ fun Toolbar.collapse(animate: Boolean = true) {
|
||||
layoutParams.height = animation.animatedValue as Int
|
||||
if (layoutParams.height <= 1) {
|
||||
visibility = View.GONE
|
||||
layoutParams.height = recordBarHeight
|
||||
layoutParams.height = recordViewHeight
|
||||
}
|
||||
requestLayout()
|
||||
}
|
||||
@@ -93,17 +92,19 @@ fun Toolbar.collapse(animate: Boolean = true) {
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun Toolbar.expand(animate: Boolean = true) {
|
||||
val actionBarHeight = layoutParams.height
|
||||
fun View.expand(animate: Boolean = true, defaultHeight: Int? = null) {
|
||||
val viewHeight = defaultHeight ?: layoutParams.height
|
||||
layoutParams.height = 0
|
||||
val slideAnimator = ValueAnimator
|
||||
.ofInt(0, actionBarHeight)
|
||||
.ofInt(0, viewHeight)
|
||||
if (animate)
|
||||
slideAnimator.duration = 300L
|
||||
var alreadyVisible = false
|
||||
slideAnimator.addUpdateListener { animation ->
|
||||
layoutParams.height = animation.animatedValue as Int
|
||||
if (layoutParams.height >= 1) {
|
||||
if (!alreadyVisible && layoutParams.height >= 1) {
|
||||
visibility = View.VISIBLE
|
||||
alreadyVisible = true
|
||||
}
|
||||
requestLayout()
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
android:id="@+id/file_expand_container"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/item_file_info_height"
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
app:layout_constraintTop_toBottomOf="@+id/file_main_switcher">
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
android:textIsSelectable="true"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:minHeight="68dp"
|
||||
android:padding="12dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/file_modify_button"
|
||||
@@ -160,6 +160,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/file_path"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/file_modify_button"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
|
||||
@@ -25,14 +25,11 @@
|
||||
<dimen name="card_view_margin">12dp</dimen>
|
||||
<dimen name="card_view_padding">14dp</dimen>
|
||||
<dimen name="card_view_margin_bottom">10dp</dimen>
|
||||
|
||||
<dimen name="item_file_info_height">120dp</dimen>
|
||||
<dimen name="icon_size">32dp</dimen>
|
||||
<dimen name="lock_button_size">48dp</dimen>
|
||||
<dimen name="hidden_lock_button_size">0dp</dimen>
|
||||
|
||||
<dimen name="content_percent">1</dimen>
|
||||
|
||||
<dimen name="toolbar_parallax_height">160dp</dimen>
|
||||
|
||||
<integer name="animation_duration">320</integer>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user