Fixed overlapping navbar in landscape
This commit is contained in:
parent
65d52776f8
commit
94ccecc012
12 changed files with 72 additions and 26 deletions
|
@ -27,6 +27,7 @@ import code.name.monkey.retromusic.*
|
||||||
import code.name.monkey.retromusic.activities.base.AbsCastActivity
|
import code.name.monkey.retromusic.activities.base.AbsCastActivity
|
||||||
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
|
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
|
||||||
import code.name.monkey.retromusic.extensions.currentFragment
|
import code.name.monkey.retromusic.extensions.currentFragment
|
||||||
|
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
||||||
import code.name.monkey.retromusic.extensions.extra
|
import code.name.monkey.retromusic.extensions.extra
|
||||||
import code.name.monkey.retromusic.extensions.findNavController
|
import code.name.monkey.retromusic.extensions.findNavController
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
||||||
|
@ -39,6 +40,7 @@ import code.name.monkey.retromusic.repository.PlaylistSongsLoader
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.AppRater
|
import code.name.monkey.retromusic.util.AppRater
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.koin.android.ext.android.get
|
import org.koin.android.ext.android.get
|
||||||
|
|
|
@ -55,6 +55,7 @@ import code.name.monkey.retromusic.fragments.queue.PlayingQueueFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo
|
import code.name.monkey.retromusic.model.CategoryInfo
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
@ -121,7 +122,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
windowInsets = insets
|
windowInsets = insets
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
//binding.fragmentContainer.drawAboveNavBar()
|
||||||
binding.bottomNavigationView.drawAboveNavBarWithPadding()
|
binding.bottomNavigationView.drawAboveNavBarWithPadding()
|
||||||
|
if (RetroUtil.isLandscape()) {
|
||||||
|
binding.slidingPanel.drawAboveNavBarWithPadding(true)
|
||||||
|
}
|
||||||
chooseFragmentForTheme()
|
chooseFragmentForTheme()
|
||||||
setupSlidingUpPanel()
|
setupSlidingUpPanel()
|
||||||
setupBottomSheet()
|
setupBottomSheet()
|
||||||
|
|
|
@ -3,5 +3,5 @@ package code.name.monkey.retromusic.extensions
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
|
||||||
fun WindowInsetsCompat?.safeGetBottomInsets(): Int {
|
fun WindowInsetsCompat?.safeGetBottomInsets(): Int {
|
||||||
return this?.getInsets(WindowInsetsCompat.Type.navigationBars())?.bottom ?: 0
|
return this?.getInsets(WindowInsetsCompat.Type.systemBars())?.bottom ?: 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
|
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
|
||||||
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.imageview.ShapeableImageView
|
import com.google.android.material.imageview.ShapeableImageView
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
|
@ -140,27 +141,34 @@ fun View.drawAboveNavBar() {
|
||||||
val initialMargin = recordInitialMarginForView(this)
|
val initialMargin = recordInitialMarginForView(this)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
(this)
|
(this)
|
||||||
) { v: View, insets: WindowInsetsCompat ->
|
) { _: View, windowInsets: WindowInsetsCompat ->
|
||||||
v.updateLayoutParams<MarginLayoutParams> {
|
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
bottomMargin = initialMargin.bottom +
|
// Apply the insets as a margin to the view.
|
||||||
insets.getInsets(navigationBars()).bottom
|
updateLayoutParams<MarginLayoutParams> {
|
||||||
|
leftMargin = initialMargin.left + insets.left
|
||||||
|
bottomMargin = initialMargin.bottom + insets.bottom
|
||||||
|
rightMargin = initialMargin.right + insets.right
|
||||||
}
|
}
|
||||||
insets
|
windowInsets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will draw our view above the navigation bar instead of behind it by adding padding.
|
* This will draw our view above the navigation bar instead of behind it by adding padding.
|
||||||
*/
|
*/
|
||||||
fun View.drawAboveNavBarWithPadding() {
|
fun View.drawAboveNavBarWithPadding(consume: Boolean = false) {
|
||||||
val initialPadding = recordInitialPaddingForView(this)
|
val initialPadding = recordInitialPaddingForView(this)
|
||||||
|
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
(this)
|
(this)
|
||||||
) { v: View, insets: WindowInsetsCompat ->
|
) { v: View, windowInsets: WindowInsetsCompat ->
|
||||||
val navBarHeight = insets.getInsets(navigationBars()).bottom
|
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
v.updatePadding(bottom = initialPadding.bottom + navBarHeight)
|
v.updatePadding(
|
||||||
insets
|
left = initialPadding.left + insets.left,
|
||||||
|
bottom = initialPadding.bottom + insets.bottom,
|
||||||
|
right = initialPadding.right + insets.right
|
||||||
|
)
|
||||||
|
if (consume) WindowInsetsCompat.CONSUMED else windowInsets
|
||||||
}
|
}
|
||||||
requestApplyInsetsWhenAttached()
|
requestApplyInsetsWhenAttached()
|
||||||
}
|
}
|
||||||
|
@ -183,17 +191,38 @@ fun View.requestApplyInsetsWhenAttached() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun AppBarLayout.drawNextToNavbar() {
|
||||||
|
val initialMargin = recordInitialMarginForView(this)
|
||||||
|
|
||||||
data class InitialMargin(val left: Int, val top: Int,
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
val right: Int, val bottom: Int)
|
(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
|
||||||
|
)
|
||||||
|
windowInsets
|
||||||
|
}
|
||||||
|
requestApplyInsetsWhenAttached()
|
||||||
|
}
|
||||||
|
|
||||||
|
data class InitialMargin(
|
||||||
|
val left: Int, val top: Int,
|
||||||
|
val right: Int, val bottom: Int
|
||||||
|
)
|
||||||
|
|
||||||
private fun recordInitialMarginForView(view: View) = InitialMargin(
|
private fun recordInitialMarginForView(view: View) = InitialMargin(
|
||||||
view.marginLeft, view.marginTop, view.marginRight, view.marginBottom)
|
view.marginLeft, view.marginTop, view.marginRight, view.marginBottom
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
data class InitialPadding(
|
||||||
|
val left: Int, val top: Int,
|
||||||
|
val right: Int, val bottom: Int
|
||||||
|
)
|
||||||
|
|
||||||
data class InitialPadding(val left: Int, val top: Int,
|
private fun recordInitialPaddingForView(view: View) = InitialPadding(
|
||||||
val right: Int, val bottom: Int)
|
view.paddingLeft, view.paddingTop, view.paddingRight, view.paddingBottom
|
||||||
|
)
|
||||||
private fun recordInitialPaddingForView(view: View) = InitialMargin(
|
|
||||||
view.paddingLeft, view.paddingTop, view.paddingRight, view.paddingBottom)
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.dip
|
import code.name.monkey.retromusic.extensions.dip
|
||||||
|
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
@ -94,6 +95,7 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
||||||
bottomMargin = it
|
bottomMargin = it
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
binding.appBarLayout.drawNextToNavbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onShuffleClicked() {
|
open fun onShuffleClicked() {
|
||||||
|
|
|
@ -40,6 +40,7 @@ import code.name.monkey.retromusic.adapter.Storage
|
||||||
import code.name.monkey.retromusic.adapter.StorageAdapter
|
import code.name.monkey.retromusic.adapter.StorageAdapter
|
||||||
import code.name.monkey.retromusic.adapter.StorageClickListener
|
import code.name.monkey.retromusic.adapter.StorageClickListener
|
||||||
import code.name.monkey.retromusic.databinding.FragmentFolderBinding
|
import code.name.monkey.retromusic.databinding.FragmentFolderBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||||
import code.name.monkey.retromusic.fragments.folder.FoldersFragment.ListPathsAsyncTask.OnPathsListedCallback
|
import code.name.monkey.retromusic.fragments.folder.FoldersFragment.ListPathsAsyncTask.OnPathsListedCallback
|
||||||
|
@ -123,6 +124,7 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
binding.appBarLayout.drawNextToNavbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpTitle() {
|
private fun setUpTitle() {
|
||||||
|
|
|
@ -37,11 +37,13 @@ import code.name.monkey.retromusic.databinding.FragmentBannerHomeBinding
|
||||||
import code.name.monkey.retromusic.databinding.FragmentHomeBinding
|
import code.name.monkey.retromusic.databinding.FragmentHomeBinding
|
||||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
||||||
|
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
|
|
||||||
|
@ -74,6 +76,7 @@ class HomeFragment :
|
||||||
view.doOnPreDraw { startPostponedEnterTransition() }
|
view.doOnPreDraw { startPostponedEnterTransition() }
|
||||||
binding.appBarLayout.statusBarForeground =
|
binding.appBarLayout.statusBarForeground =
|
||||||
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
|
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
|
||||||
|
binding.appBarLayout.drawNextToNavbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListeners() {
|
private fun setupListeners() {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -86,11 +87,8 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
private val bottomSheetCallbackList = object : BottomSheetCallback() {
|
private val bottomSheetCallbackList = object : BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||||
mainActivity.getBottomSheetBehavior().setAllowDragging(false)
|
mainActivity.getBottomSheetBehavior().setAllowDragging(false)
|
||||||
binding.playerQueueSheet.setPadding(
|
binding.playerQueueSheet.updatePadding(
|
||||||
binding.playerQueueSheet.paddingLeft,
|
bottom = (slideOffset * binding.statusBarLayout.statusBar.height).toInt()
|
||||||
(slideOffset * binding.statusBarLayout.statusBar.height).toInt(),
|
|
||||||
binding.playerQueueSheet.paddingRight,
|
|
||||||
binding.playerQueueSheet.paddingBottom
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +154,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
goToArtist(requireActivity())
|
goToArtist(requireActivity())
|
||||||
}
|
}
|
||||||
binding.container.drawAboveNavBarWithPadding()
|
binding.container.drawAboveNavBarWithPadding()
|
||||||
|
binding.playbackControlsFragment.root.drawAboveNavBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
|
|
@ -30,6 +30,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import code.name.monkey.retromusic.views.DrawableGradient
|
import code.name.monkey.retromusic.views.DrawableGradient
|
||||||
|
@ -121,7 +122,7 @@ class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player) {
|
||||||
_binding = FragmentPlayerBinding.bind(view)
|
_binding = FragmentPlayerBinding.bind(view)
|
||||||
setUpSubFragments()
|
setUpSubFragments()
|
||||||
setUpPlayerToolbar()
|
setUpPlayerToolbar()
|
||||||
playerToolbar().drawAboveNavBar()
|
//playerToolbar().drawAboveNavBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|
|
@ -45,6 +45,7 @@ import com.google.android.material.transition.MaterialSharedAxis
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
|
||||||
class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWatcher,
|
class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWatcher,
|
||||||
ChipGroup.OnCheckedChangeListener {
|
ChipGroup.OnCheckedChangeListener {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
</code.name.monkey.retromusic.views.HeightFitSquareLayout>
|
</code.name.monkey.retromusic.views.HeightFitSquareLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/controlsContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
|
@ -82,8 +82,9 @@
|
||||||
android:id="@+id/shuffle_button"
|
android:id="@+id/shuffle_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|right"
|
android:layout_gravity="bottom|end"
|
||||||
app:srcCompat="@drawable/ic_shuffle"
|
app:srcCompat="@drawable/ic_shuffle"
|
||||||
|
android:contentDescription="@string/shuffle"
|
||||||
style="@style/Widget.Material3.FloatingActionButton.Primary"
|
style="@style/Widget.Material3.FloatingActionButton.Primary"
|
||||||
android:layout_marginHorizontal="16dp"/>
|
android:layout_marginHorizontal="16dp"/>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in a new issue