diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt b/app/src/main/java/com/google/android/material/appbar/TachiyomiAppBarLayout.kt similarity index 87% rename from app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt rename to app/src/main/java/com/google/android/material/appbar/TachiyomiAppBarLayout.kt index 2a730fc37..6cc8239b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt +++ b/app/src/main/java/com/google/android/material/appbar/TachiyomiAppBarLayout.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.widget +package com.google.android.material.appbar import android.animation.AnimatorSet import android.animation.ValueAnimator @@ -11,9 +11,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.lifecycle.coroutineScope import androidx.lifecycle.findViewTreeLifecycleOwner import com.google.android.material.animation.AnimationUtils -import com.google.android.material.appbar.AppBarLayout -import com.google.android.material.appbar.HideToolbarOnScrollBehavior -import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.shape.getStateAlpha import eu.kanade.tachiyomi.R @@ -23,7 +20,12 @@ import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.android.view.HierarchyChangeEvent import reactivecircus.flowbinding.android.view.hierarchyChangeEvents -class ElevationAppBarLayout @JvmOverloads constructor( +/** + * [AppBarLayout] with our own lift state handler and custom title alpha. + * + * Inside this package to access some package-private methods. + */ +class TachiyomiAppBarLayout @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null ) : AppBarLayout(context, attrs) { @@ -50,8 +52,8 @@ class ElevationAppBarLayout @JvmOverloads constructor( private var statusBarForegroundAnimator: ValueAnimator? = null private val offsetListener = OnOffsetChangedListener { appBarLayout, verticalOffset -> // Show status bar foreground when offset - val foreground = appBarLayout?.statusBarForeground ?: return@OnOffsetChangedListener - val start = foreground.alpha + val foreground = (appBarLayout?.statusBarForeground as? MaterialShapeDrawable) ?: return@OnOffsetChangedListener + val start = foreground.getStateAlpha() val end = if (verticalOffset != 0) 255 else 0 statusBarForegroundAnimator?.cancel() @@ -82,7 +84,7 @@ class ElevationAppBarLayout @JvmOverloads constructor( override fun getBehavior(): CoordinatorLayout.Behavior = HideToolbarOnScrollBehavior() /** - * Disabled. Lift on scroll is handled manually with [TachiyomiCoordinatorLayout] + * Disabled. Lift on scroll is handled manually with [eu.kanade.tachiyomi.widget.TachiyomiCoordinatorLayout] */ override fun isLiftOnScroll(): Boolean = false @@ -98,6 +100,8 @@ class ElevationAppBarLayout @JvmOverloads constructor( } } + override fun setLiftedState(lifted: Boolean, force: Boolean): Boolean = false + override fun onAttachedToWindow() { super.onAttachedToWindow() addOnOffsetChangedListener(offsetListener) @@ -143,6 +147,7 @@ class ElevationAppBarLayout @JvmOverloads constructor( ValueAnimator.ofFloat(fromElevation, toElevation).apply { addUpdateListener { elevation = it.animatedValue as Float + (statusBarForeground as? MaterialShapeDrawable)?.elevation = it.animatedValue as Float } animators.add(this) } @@ -171,4 +176,8 @@ class ElevationAppBarLayout @JvmOverloads constructor( } } } + + init { + statusBarForeground = MaterialShapeDrawable.createWithElevationOverlay(context) + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackAdapter.kt index 05eca0698..67a866e6c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackAdapter.kt @@ -4,7 +4,6 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import eu.kanade.tachiyomi.databinding.TrackItemBinding -import eu.kanade.tachiyomi.util.view.applyElevationOverlay class TrackAdapter(listener: OnClickListener) : RecyclerView.Adapter() { @@ -30,7 +29,6 @@ class TrackAdapter(listener: OnClickListener) : RecyclerView.Adapter= 0 } } diff --git a/app/src/main/res/layout-sw720dp/main_activity.xml b/app/src/main/res/layout-sw720dp/main_activity.xml index adc1e8ff3..2d7463fd3 100644 --- a/app/src/main/res/layout-sw720dp/main_activity.xml +++ b/app/src/main/res/layout-sw720dp/main_activity.xml @@ -11,7 +11,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + - + app:elevation="0dp"> - + @style/Widget.Tachiyomi.Switch @style/Widget.Tachiyomi.Slider @style/Widget.Material3.CardView.Elevated - false false