From e411f542369ec6b222799e2e85233248128f5b77 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 8 Jan 2020 21:33:10 -0500 Subject: [PATCH] Remove up/down animation for FAB, add list padding (#2456) --- .../tachiyomi/widget/FABAnimationBase.kt | 35 ------------- .../tachiyomi/widget/FABAnimationUpDown.kt | 51 ------------------- .../main/res/layout/categories_controller.xml | 7 +-- .../main/res/layout/chapters_controller.xml | 2 + app/src/main/res/values/dimens.xml | 4 +- app/src/main/res/values/styles.xml | 1 - 6 files changed, 9 insertions(+), 91 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt deleted file mode 100644 index b8586f0444..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt +++ /dev/null @@ -1,35 +0,0 @@ -package eu.kanade.tachiyomi.widget - -import androidx.coordinatorlayout.widget.CoordinatorLayout -import com.google.android.material.floatingactionbutton.FloatingActionButton -import androidx.core.view.ViewCompat -import android.view.View - -abstract class FABAnimationBase : FloatingActionButton.Behavior() { - - var isAnimatingOut = false - - override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, - directTargetChild: View, target: View, axes: Int, type: Int): Boolean { - // Ensure we react to vertical scrolling - return axes == ViewCompat.SCROLL_AXIS_VERTICAL || - super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type) - } - - override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, - target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, - dyUnconsumed: Int, type: Int) { - super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type) - - if (dyConsumed > 0 && !isAnimatingOut && child.visibility == View.VISIBLE) { - // User scrolled down and the FAB is currently visible -> hide the FAB - animateOut(child) - } else if (dyConsumed < 0 && child.visibility != View.VISIBLE) { - // User scrolled up and the FAB is currently not visible -> show the FAB - animateIn(child) - } - } - - abstract fun animateOut(button: FloatingActionButton) - abstract fun animateIn(button: FloatingActionButton) -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt deleted file mode 100644 index 855515db6c..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt +++ /dev/null @@ -1,51 +0,0 @@ -package eu.kanade.tachiyomi.widget - -import android.content.Context -import com.google.android.material.floatingactionbutton.FloatingActionButton -import androidx.interpolator.view.animation.FastOutSlowInInterpolator -import android.util.AttributeSet -import android.view.View -import android.view.animation.Animation -import android.view.animation.AnimationUtils -import eu.kanade.tachiyomi.R - -@Suppress("unused", "UNUSED_PARAMETER") -class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: AttributeSet? = null) : FABAnimationBase() { - - private val INTERPOLATOR = FastOutSlowInInterpolator() - - private val outAnimation by lazy { - AnimationUtils.loadAnimation(ctx, R.anim.fab_hide_to_bottom).apply { - duration = 200 - interpolator = INTERPOLATOR - } - } - private val inAnimation by lazy { - AnimationUtils.loadAnimation(ctx, R.anim.fab_show_from_bottom).apply { - duration = 200 - interpolator = INTERPOLATOR - } - } - - override fun animateOut(button: FloatingActionButton) { - outAnimation.setAnimationListener(object : Animation.AnimationListener { - override fun onAnimationStart(animation: Animation) { - isAnimatingOut = true - } - - override fun onAnimationEnd(animation: Animation) { - isAnimatingOut = false - button.visibility = View.INVISIBLE - } - - override fun onAnimationRepeat(animation: Animation) { - } - }) - button.startAnimation(outAnimation) - } - - override fun animateIn(button: FloatingActionButton) { - button.visibility = View.VISIBLE - button.startAnimation(inAnimation) - } -} diff --git a/app/src/main/res/layout/categories_controller.xml b/app/src/main/res/layout/categories_controller.xml index db67a00619..9d1a20f84b 100644 --- a/app/src/main/res/layout/categories_controller.xml +++ b/app/src/main/res/layout/categories_controller.xml @@ -6,12 +6,13 @@ android:layout_height="match_parent"> + android:paddingBottom="@dimen/fab_list_padding" + android:clipToPadding="false" + tools:listitem="@layout/categories_item" /> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 8b6231cdf4..f018aa9348 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,9 +6,11 @@ 16dp 16dp 16dp - 16dp 4dp + 56dp + 16dp + 88dp 24dp 20dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d2100ea3b6..4c7297853a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -145,7 +145,6 @@ fitCenter bottom|right|end @color/md_white_1000 - eu.kanade.tachiyomi.widget.FABAnimationUpDown