diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt index a9fbbde487..4aa257ddaa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt @@ -145,6 +145,9 @@ class CatalogueController : NucleusController(), .BottomSheetCallback() { override fun onSlide(bottomSheet: View, progress: Float) { shadow2.alpha = (1 - max(0f, progress)) * 0.25f + activity?.appbar?.elevation = max(progress * 15f, + if (recycler.canScrollVertically(-1)) 15f else 0f) + sheet_layout.alpha = 1 - progress activity?.appbar?.y = max(activity!!.appbar.y, -headerHeight * (1 - progress)) val oldShow = showingExtenions diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index 639f4bf6a5..cd96cf59a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -229,6 +229,7 @@ class MangaDetailsController : BaseController, var statusBarHeight = -1 swipe_refresh.setStyle() swipe_refresh.setDistanceToTriggerSync(70.dpToPx) + activity!!.appbar.elevation = 0f recycler.doOnApplyWindowInsets { v, insets, _ -> headerHeight = appbarHeight + insets.systemWindowInsetTop diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 7b0d8fe8e5..94b7050dce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -136,6 +136,9 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), override fun onSlide(bottomSheet: View, progress: Float) { shadow2.alpha = (1 - abs(progress)) * 0.25f shadow.alpha = (1 - abs(progress)) * 0.5f + if (progress >= 0) activity?.appbar?.elevation = max( + progress * 15f, if (recycler.canScrollVertically(-1)) 15f else 0f + ) sheet_layout.alpha = 1 - progress activity?.appbar?.y = max(activity!!.appbar.y, -headerHeight * (1 - progress)) val oldShow = showingDownloads diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt index 70837aebb7..53df954425 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt @@ -15,8 +15,7 @@ import com.bluelinelabs.conductor.ControllerChangeType import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.base.controller.BaseController -import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener -import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController +import eu.kanade.tachiyomi.util.view.scrollViewWith import rx.Observable import rx.Subscription import rx.subscriptions.CompositeSubscription @@ -35,8 +34,7 @@ abstract class SettingsController : PreferenceController() { untilDestroySubscriptions = CompositeSubscription() } val view = super.onCreateView(inflater, container, savedInstanceState) - view.applyWindowInsetsForController() - listView.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener) + scrollViewWith(listView, padBottom = true) return view } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index a4e435d137..c81a7f845e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.util.view +import android.animation.ValueAnimator import android.app.Activity import android.content.Context import android.content.res.ColorStateList @@ -30,6 +31,8 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.amulyakhare.textdrawable.TextDrawable import com.amulyakhare.textdrawable.util.ColorGenerator import com.bluelinelabs.conductor.Controller +import com.bluelinelabs.conductor.ControllerChangeHandler +import com.bluelinelabs.conductor.ControllerChangeType import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.button.MaterialButton import com.google.android.material.snackbar.Snackbar @@ -353,6 +356,31 @@ fun Controller.scrollViewWith( statusBarHeight = insets.systemWindowInsetTop afterInsets?.invoke(insets) } + var elevationAnim: ValueAnimator? = null + var elevate = false + val elevateFunc: (Boolean) -> Unit = { el -> + elevate = el + elevationAnim?.cancel() + elevationAnim = ValueAnimator.ofFloat( + activity!!.appbar.elevation, if (el) 15f else 0f + ) + elevationAnim?.addUpdateListener { valueAnimator -> + activity!!.appbar.elevation = valueAnimator.animatedValue as Float + } + elevationAnim?.start() + } + addLifecycleListener(object : Controller.LifecycleListener() { + override fun onChangeStart( + controller: Controller, + changeHandler: ControllerChangeHandler, + changeType: ControllerChangeType + ) { + super.onChangeStart(controller, changeHandler, changeType) + if (changeType.isEnter) + elevateFunc(elevate) + } + }) + elevateFunc(recycler.canScrollVertically(-1)) recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) @@ -365,11 +393,15 @@ fun Controller.scrollViewWith( ) ?: 0 activity!!.appbar.animate().y(0f).setDuration(shortAnimationDuration.toLong()) .start() + if (elevate) elevateFunc(false) } else { activity!!.appbar.y -= dy activity!!.appbar.y = clamp( activity!!.appbar.y, -activity!!.appbar.height.toFloat(), 0f ) + if ((activity!!.appbar.y <= -activity!!.appbar.height.toFloat() || + dy == 0 && activity!!.appbar.y == 0f) && !elevate) + elevateFunc(true) } } } @@ -393,6 +425,10 @@ fun Controller.scrollViewWith( if (closerToTop && !atTop) (-activity!!.appbar.height.toFloat()) else 0f ).setDuration(shortAnimationDuration.toLong()).start() + if (recycler.canScrollVertically(-1) && !elevate) + elevateFunc(true) + else if (!recycler.canScrollVertically(-1) && elevate) + elevateFunc(false) } } }