diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt index deb76056d..1442d45d7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -10,9 +10,7 @@ import android.view.WindowManager import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.view.forEach -import androidx.core.view.updateLayoutParams import androidx.navigation.NavDirections -import com.google.android.material.card.MaterialCardView import com.topjohnwu.magisk.MainDirections import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseUIActivity @@ -22,8 +20,6 @@ import com.topjohnwu.magisk.core.* import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding import com.topjohnwu.magisk.ktx.startAnimations import com.topjohnwu.magisk.ui.home.HomeFragmentDirections -import com.topjohnwu.magisk.utils.HideBottomViewOnScrollBehavior -import com.topjohnwu.magisk.utils.HideTopViewOnScrollBehavior import com.topjohnwu.magisk.utils.HideableBehavior import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.view.MagiskDialog @@ -77,12 +73,6 @@ open class MainActivity : BaseUIActivity( setSupportActionBar(binding.mainToolbar) - binding.mainToolbarWrapper.updateLayoutParams { - behavior = HideTopViewOnScrollBehavior() - } - binding.mainBottomBar.updateLayoutParams { - behavior = HideBottomViewOnScrollBehavior() - } binding.mainNavigation.setOnNavigationItemSelectedListener { getScreen(it.itemId)?.navigate() true diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/HideBottomViewOnScrollBehavior.kt b/app/src/main/java/com/topjohnwu/magisk/utils/HideBottomViewOnScrollBehavior.kt index 9bbcf4dee..b2b76e23a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/HideBottomViewOnScrollBehavior.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/HideBottomViewOnScrollBehavior.kt @@ -1,5 +1,7 @@ package com.topjohnwu.magisk.utils +import android.content.Context +import android.util.AttributeSet import android.view.View import android.view.ViewGroup import androidx.coordinatorlayout.widget.CoordinatorLayout @@ -13,8 +15,8 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Info import kotlin.math.roundToInt -class HideBottomViewOnScrollBehavior : HideBottomViewOnScrollBehavior(), - HideableBehavior { +class HideBottomViewOnScrollBehavior(context: Context, attrs: AttributeSet) : + HideBottomViewOnScrollBehavior(), HideableBehavior { private var lockState: Boolean = false private var isLaidOut = false @@ -122,4 +124,4 @@ class HideBottomViewOnScrollBehavior : HideBottomViewOnScrollBehavior< .setInterpolator(FastOutSlowInInterpolator()) .start() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/HideTopViewOnScrollBehavior.kt b/app/src/main/java/com/topjohnwu/magisk/utils/HideTopViewOnScrollBehavior.kt index 6ce5f5af8..637431fb6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/HideTopViewOnScrollBehavior.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/HideTopViewOnScrollBehavior.kt @@ -1,6 +1,8 @@ package com.topjohnwu.magisk.utils import android.animation.TimeInterpolator +import android.content.Context +import android.util.AttributeSet import android.view.View import android.view.ViewGroup import android.view.ViewPropertyAnimator @@ -8,9 +10,8 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.view.ViewCompat import com.google.android.material.animation.AnimationUtils -class HideTopViewOnScrollBehavior : - CoordinatorLayout.Behavior(), - HideableBehavior { +class HideTopViewOnScrollBehavior(context: Context, attrs: AttributeSet) : + CoordinatorLayout.Behavior(), HideableBehavior { companion object { private const val STATE_SCROLLED_DOWN = 1 @@ -139,4 +140,4 @@ class HideTopViewOnScrollBehavior : .setDuration(duration) .withEndAction { currentAnimator = null } .let { currentAnimator = it } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/activity_main_md2.xml b/app/src/main/res/layout/activity_main_md2.xml index 45fcb2f88..ae9a5e784 100644 --- a/app/src/main/res/layout/activity_main_md2.xml +++ b/app/src/main/res/layout/activity_main_md2.xml @@ -35,6 +35,7 @@ style="@style/WidgetFoundation.Appbar" android:layout_width="match_parent" android:layout_height="wrap_content" + app:layout_behavior=".utils.HideTopViewOnScrollBehavior" app:fitsSystemWindowsInsets="top">