Fixed AppBarLayout issues
This commit is contained in:
parent
cb8ef7f32c
commit
efeacfa622
7 changed files with 14 additions and 16 deletions
|
@ -313,7 +313,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomNavAnimator?.end()
|
||||
bottomNavAnimator = binding.bottomNavigationView.translateYAnimate(0F)
|
||||
binding.bottomNavigationView.bringToFront()
|
||||
libraryViewModel.setFabMargin(heightOfBarWithTabs - windowInsets.safeGetBottomInsets())
|
||||
libraryViewModel.setFabMargin(heightOfBarWithTabs - 2 * windowInsets.safeGetBottomInsets())
|
||||
} else {
|
||||
println("Details")
|
||||
bottomSheetBehavior.peekHeightAnimate(heightOfBar)
|
||||
|
@ -323,7 +323,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomNavAnimator?.doOnEnd {
|
||||
binding.slidingPanel.bringToFront()
|
||||
}
|
||||
libraryViewModel.setFabMargin(heightOfBar - windowInsets.safeGetBottomInsets())
|
||||
libraryViewModel.setFabMargin(heightOfBar - 2 * windowInsets.safeGetBottomInsets())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ import android.view.ViewGroup.MarginLayoutParams
|
|||
import android.view.ViewTreeObserver
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.animation.doOnStart
|
||||
import androidx.core.view.*
|
||||
import androidx.core.view.WindowInsetsCompat.Type.navigationBars
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
@ -191,17 +191,16 @@ fun View.requestApplyInsetsWhenAttached() {
|
|||
}
|
||||
}
|
||||
|
||||
fun AppBarLayout.drawNextToNavbar() {
|
||||
val initialMargin = recordInitialMarginForView(this)
|
||||
fun View.drawNextToNavbar() {
|
||||
val initialPadding = recordInitialPaddingForView(this)
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(
|
||||
(this)
|
||||
) { v: View, windowInsets: WindowInsetsCompat ->
|
||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.updatePadding(
|
||||
top = initialMargin.top + insets.top,
|
||||
left = initialMargin.left + insets.left,
|
||||
right = initialMargin.right + insets.right
|
||||
left = initialPadding.left + insets.left,
|
||||
right = initialPadding.right + insets.right
|
||||
)
|
||||
windowInsets
|
||||
}
|
||||
|
@ -228,7 +227,7 @@ data class InitialMargin(
|
|||
val right: Int, val bottom: Int
|
||||
)
|
||||
|
||||
private fun recordInitialMarginForView(view: View) = InitialMargin(
|
||||
fun recordInitialMarginForView(view: View) = InitialMargin(
|
||||
view.marginLeft, view.marginTop, view.marginRight, view.marginBottom
|
||||
)
|
||||
|
||||
|
|
|
@ -64,9 +64,6 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
initAdapter()
|
||||
setUpRecyclerView()
|
||||
setupToolbar()
|
||||
binding.appBarLayout.statusBarForeground =
|
||||
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
|
||||
|
||||
// Add listeners when shuffle is visible
|
||||
if (isShuffleVisible) {
|
||||
binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
|
@ -95,7 +92,6 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
bottomMargin = it
|
||||
}
|
||||
})
|
||||
binding.appBarLayout.drawNextToNavbar()
|
||||
}
|
||||
|
||||
open fun onShuffleClicked() {
|
||||
|
@ -117,6 +113,9 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
}
|
||||
val appName = resources.getString(titleRes)
|
||||
binding.appNameText.text = appName
|
||||
binding.toolbarContainer.drawNextToNavbar()
|
||||
binding.appBarLayout.statusBarForeground =
|
||||
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
|
||||
}
|
||||
|
||||
abstract val titleRes: Int
|
||||
|
|
|
@ -124,7 +124,7 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
|||
}
|
||||
}
|
||||
})
|
||||
binding.appBarLayout.drawNextToNavbar()
|
||||
binding.toolbarContainer.drawNextToNavbar()
|
||||
}
|
||||
|
||||
private fun setUpTitle() {
|
||||
|
|
|
@ -76,7 +76,7 @@ class HomeFragment :
|
|||
view.doOnPreDraw { startPostponedEnterTransition() }
|
||||
binding.appBarLayout.statusBarForeground =
|
||||
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
|
||||
binding.appBarLayout.drawNextToNavbar()
|
||||
binding.toolbar.drawNextToNavbar()
|
||||
}
|
||||
|
||||
private fun setupListeners() {
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
android:layout_gravity="bottom"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginBottom="70dp"
|
||||
android:fitsSystemWindows="false"
|
||||
android:gravity="center"
|
||||
android:text="@string/save"
|
||||
app:icon="@drawable/ic_save"
|
||||
|
|
|
@ -191,7 +191,6 @@
|
|||
<style name="BottomSheetStyle" parent="Widget.Material3.BottomSheet">
|
||||
<item name="android:maxWidth">@empty</item>
|
||||
<item name="android:backgroundTint">?attr/bottomSheetTint</item>
|
||||
<item name="gestureInsetBottomIgnored">true</item>
|
||||
</style>
|
||||
|
||||
<style name="MaterialCardViewStroke">
|
||||
|
|
Loading…
Reference in a new issue