Fixed Fab Movement when snackbar is showing + Text fixes
This commit is contained in:
parent
d719cae942
commit
62af86c77a
@ -476,7 +476,7 @@ class LibraryController(
|
|||||||
val mangas = selectedMangas.toList()
|
val mangas = selectedMangas.toList()
|
||||||
presenter.removeMangaFromLibrary(mangas, true)
|
presenter.removeMangaFromLibrary(mangas, true)
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
view?.snack(activity?.getString(R.string.remove_from_library) ?: "", 5000) {
|
view?.snack(activity?.getString(R.string.manga_removed_library) ?: "", 5000) {
|
||||||
setAction(R.string.action_undo) {
|
setAction(R.string.action_undo) {
|
||||||
presenter.addMangas(mangas)
|
presenter.addMangas(mangas)
|
||||||
}
|
}
|
||||||
|
@ -393,9 +393,9 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
val view = view
|
val view = view
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
presenter.downloadChapters(chapters)
|
presenter.downloadChapters(chapters)
|
||||||
if (view != null && !presenter.manga.favorite) {
|
if (view != null && !presenter.manga.favorite && (snack == null || snack?.getText() != view.context.getString(R.string.snack_add_to_library))) {
|
||||||
snack = view.snack(view.context.getString(R.string.snack_add_to_library), Snackbar
|
snack =
|
||||||
.LENGTH_INDEFINITE) {
|
view.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
|
||||||
setAction(R.string.action_add) {
|
setAction(R.string.action_add) {
|
||||||
presenter.addToLibrary()
|
presenter.addToLibrary()
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,11 @@ Int = 0) {
|
|||||||
ViewCompat.setElevation(this.view, 6f)
|
ViewCompat.setElevation(this.view, 6f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Snackbar.getText(): CharSequence {
|
||||||
|
val textView: TextView = view.findViewById(com.google.android.material.R.id.snackbar_text)
|
||||||
|
return textView.text
|
||||||
|
}
|
||||||
|
|
||||||
inline fun View.visible() {
|
inline fun View.visible() {
|
||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,14 @@ abstract class FABAnimationBase : FloatingActionButton.Behavior() {
|
|||||||
|
|
||||||
var isAnimatingOut = false
|
var isAnimatingOut = false
|
||||||
|
|
||||||
override fun onStartNestedScroll(coordinatorLayout: androidx.coordinatorlayout.widget.CoordinatorLayout, child: FloatingActionButton,
|
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton,
|
||||||
directTargetChild: View, target: View, axes: Int, type: Int): Boolean {
|
directTargetChild: View, target: View, axes: Int, type: Int): Boolean {
|
||||||
// Ensure we react to vertical scrolling
|
// Ensure we react to vertical scrolling
|
||||||
return axes == ViewCompat.SCROLL_AXIS_VERTICAL ||
|
return axes == ViewCompat.SCROLL_AXIS_VERTICAL ||
|
||||||
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type)
|
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNestedScroll(coordinatorLayout: androidx.coordinatorlayout.widget.CoordinatorLayout, child: FloatingActionButton,
|
override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton,
|
||||||
target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int,
|
target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int,
|
||||||
dyUnconsumed: Int, type: Int) {
|
dyUnconsumed: Int, type: Int) {
|
||||||
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type)
|
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type)
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
package eu.kanade.tachiyomi.widget
|
package eu.kanade.tachiyomi.widget
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import android.graphics.Rect
|
||||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import timber.log.Timber
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
@Suppress("unused", "UNUSED_PARAMETER")
|
@Suppress("unused", "UNUSED_PARAMETER")
|
||||||
@ -53,18 +55,10 @@ class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: Attribut
|
|||||||
button.startAnimation(inAnimation)
|
button.startAnimation(inAnimation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
|
||||||
return dependency is Snackbar.SnackbarLayout
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
||||||
val translationY = getFabTranslationYForSnackbar(parent, child)
|
val translationY = getFabTranslationYForSnackbar(parent, child)
|
||||||
val percentComplete = -translationY / dependency.height
|
child.translationY = translationY
|
||||||
val scaleFactor = 1 - percentComplete
|
return true
|
||||||
|
|
||||||
child.translationY = -translationY
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFabTranslationYForSnackbar(parent: CoordinatorLayout, fab:
|
private fun getFabTranslationYForSnackbar(parent: CoordinatorLayout, fab:
|
||||||
@ -74,9 +68,15 @@ class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: Attribut
|
|||||||
for (i in 0 until dependencies.size) {
|
for (i in 0 until dependencies.size) {
|
||||||
val view = dependencies[i]
|
val view = dependencies[i]
|
||||||
if (view is Snackbar.SnackbarLayout) {
|
if (view is Snackbar.SnackbarLayout) {
|
||||||
|
Timber.d("snack y: ${view.translationY}")
|
||||||
minOffset = min(minOffset, view.translationY - view.height)
|
minOffset = min(minOffset, view.translationY - view.height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minOffset
|
return minOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getInsetDodgeRect(parent: CoordinatorLayout, child: FloatingActionButton, rect: Rect): Boolean {
|
||||||
|
rect.set(child.left, child.top + 100, child.right, child.bottom - 1000)
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user