Added extension functions to apply insets

This commit is contained in:
Prathamesh More 2021-10-03 19:28:05 +05:30
parent 9f5b9d32ad
commit 03b9e36014
25 changed files with 116 additions and 66 deletions

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="md3_available">true</bool>
</resources>

View file

@ -22,8 +22,6 @@ import android.view.ViewTreeObserver
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.commit import androidx.fragment.app.commit
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
@ -118,6 +116,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = createContentView() binding = createContentView()
setContentView(binding.root) setContentView(binding.root)
binding.bottomNavigationView.drawAboveNavBarWithPadding()
chooseFragmentForTheme() chooseFragmentForTheme()
setupSlidingUpPanel() setupSlidingUpPanel()
setupBottomSheet() setupBottomSheet()
@ -128,13 +127,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
println("dimBackground") println("dimBackground")
collapsePanel() collapsePanel()
} }
binding.bottomNavigationView.apply {
val navbarHeight = RetroUtil.getNavigationBarHeight()
updatePadding(bottom = navbarHeight)
binding.bottomNavigationView.updateLayoutParams {
height = dip(R.dimen.bottom_nav_height) + navbarHeight
}
}
} }
private fun setupBottomSheet() { private fun setupBottomSheet() {
@ -280,6 +272,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
} }
fun setBottomBarVisibility(visible: Boolean) { fun setBottomBarVisibility(visible: Boolean) {
if (!(visible && binding.bottomNavigationView.isVisible)) {
if (visible) {
binding.bottomNavigationView.translateYAnimate(0F)
} else {
binding.bottomNavigationView.translateYAnimate(dip(R.dimen.bottom_nav_height).toFloat())
}
}
binding.bottomNavigationView.isVisible = visible binding.bottomNavigationView.isVisible = visible
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty()) hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
} }
@ -313,7 +312,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
libraryViewModel.setFabMargin(heightOfBar - RetroUtil.getNavigationBarHeight()) libraryViewModel.setFabMargin(heightOfBar - RetroUtil.getNavigationBarHeight())
} }
} }
bottomSheetBehavior.setAllowDragging(true)
} }
} }

View file

@ -14,15 +14,13 @@
*/ */
package code.name.monkey.retromusic.extensions package code.name.monkey.retromusic.extensions
import android.app.Activity
import android.content.Context import android.content.Context
import android.content.res.Configuration import android.content.res.Configuration
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.PowerManager import android.os.PowerManager
import android.widget.Toast import android.widget.Toast
import androidx.annotation.DrawableRes import androidx.annotation.*
import androidx.annotation.IdRes
import androidx.annotation.IntegerRes
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.content.res.AppCompatResources
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
@ -101,4 +99,8 @@ fun Fragment.getDrawableCompat(@DrawableRes drawableRes: Int): Drawable {
fun Fragment.applyToolbar(toolbar: MaterialToolbar) { fun Fragment.applyToolbar(toolbar: MaterialToolbar) {
(requireActivity() as AppCompatActivity).applyToolbar(toolbar) (requireActivity() as AppCompatActivity).applyToolbar(toolbar)
}
fun Fragment.dip(@DimenRes id: Int): Int {
return resources.getDimensionPixelSize(id)
} }

View file

@ -19,15 +19,20 @@ import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.animation.doOnStart import androidx.core.animation.doOnStart
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import code.name.monkey.appthemehelper.ThemeStore 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.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
@ -124,4 +129,52 @@ fun ShapeableImageView.setCircleShape(boolean: Boolean) {
val radius = width / 2f val radius = width / 2f
shapeAppearanceModel = ShapeAppearanceModel().withCornerSize(radius) shapeAppearanceModel = ShapeAppearanceModel().withCornerSize(radius)
} }
}
/**
* This will draw our view above the navigation bar instead of behind it by adding margins.
*/
fun View.drawAboveNavBar() {
ViewCompat.setOnApplyWindowInsetsListener(
(this)
) { v: View, insets: WindowInsetsCompat ->
v.updateLayoutParams<MarginLayoutParams> {
bottomMargin =
insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
}
insets
}
}
/**
* This will draw our view above the navigation bar instead of behind it by adding padding.
*/
fun View.drawAboveNavBarWithPadding() {
ViewCompat.setOnApplyWindowInsetsListener(
(this)
) { v: View, insets: WindowInsetsCompat ->
val navBarHeight = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
v.updatePadding(bottom = navBarHeight)
insets
}
requestApplyInsetsWhenAttached()
}
fun View.requestApplyInsetsWhenAttached() {
if (isAttachedToWindow) {
// We're already attached, just request as normal
requestApplyInsets()
} else {
// We're not attached to the hierarchy, add a listener to
// request when we are
addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) {
v.removeOnAttachStateChangeListener(this)
v.requestApplyInsets()
}
override fun onViewDetachedFromWindow(v: View) = Unit
})
}
} }

View file

@ -33,8 +33,8 @@ import code.name.monkey.retromusic.databinding.FragmentMainRecyclerBinding
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.accentColor import code.name.monkey.retromusic.extensions.accentColor
import code.name.monkey.retromusic.extensions.dip
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.DensityUtil
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
import com.google.android.material.transition.MaterialSharedAxis import com.google.android.material.transition.MaterialSharedAxis
@ -159,10 +159,10 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
val itemCount: Int = adapter?.itemCount ?: 0 val itemCount: Int = adapter?.itemCount ?: 0
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) { if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
val height = DensityUtil.dip2px(requireContext(), 112f) val height = dip(R.dimen.mini_player_height_expanded)
binding.recyclerView.updatePadding(0, 0, 0, height) binding.recyclerView.updatePadding(0, 0, 0, height)
} else { } else {
val height = DensityUtil.dip2px(requireContext(), 56f) val height = dip(R.dimen.mini_player_height)
binding.recyclerView.updatePadding(0, 0, 0, height) binding.recyclerView.updatePadding(0, 0, 0, height)
} }
} }

View file

@ -26,6 +26,7 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.MainActivity
import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask
import code.name.monkey.retromusic.databinding.FragmentLyricsBinding import code.name.monkey.retromusic.databinding.FragmentLyricsBinding
import code.name.monkey.retromusic.databinding.FragmentNormalLyricsBinding import code.name.monkey.retromusic.databinding.FragmentNormalLyricsBinding
@ -361,5 +362,8 @@ class LyricsFragment : AbsMusicServiceFragment(R.layout.fragment_lyrics) {
} }
} }
override fun onDestroyView() {
super.onDestroyView()
(requireActivity() as MainActivity).expandPanel()
}
} }

View file

@ -21,6 +21,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentAdaptivePlayerBinding import code.name.monkey.retromusic.databinding.FragmentAdaptivePlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.extensions.surfaceColor import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.extensions.textColorPrimary import code.name.monkey.retromusic.extensions.textColorPrimary
import code.name.monkey.retromusic.extensions.textColorSecondary import code.name.monkey.retromusic.extensions.textColorSecondary
@ -47,7 +48,7 @@ class AdaptiveFragment : AbsPlayerFragment(R.layout.fragment_adaptive_player) {
_binding = FragmentAdaptivePlayerBinding.bind(view) _binding = FragmentAdaptivePlayerBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(binding.root) binding.root.drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.NEW_BLUR_AMOUNT import code.name.monkey.retromusic.NEW_BLUR_AMOUNT
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentBlurBinding import code.name.monkey.retromusic.databinding.FragmentBlurBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.glide.BlurTransformation import code.name.monkey.retromusic.glide.BlurTransformation
@ -56,7 +57,7 @@ class BlurPlayerFragment : AbsPlayerFragment(R.layout.fragment_blur),
_binding = FragmentBlurBinding.bind(view) _binding = FragmentBlurBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(binding.playerToolbar) binding.playerToolbar.drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -21,12 +21,12 @@ import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentCardPlayerBinding import code.name.monkey.retromusic.databinding.FragmentCardPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
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.RetroUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
class CardFragment : AbsPlayerFragment(R.layout.fragment_card_player) { class CardFragment : AbsPlayerFragment(R.layout.fragment_card_player) {
@ -83,7 +83,7 @@ class CardFragment : AbsPlayerFragment(R.layout.fragment_card_player) {
_binding = FragmentCardPlayerBinding.bind(view) _binding = FragmentCardPlayerBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(binding.playbackControlsFragment.parent as View) (binding.playbackControlsFragment.parent as View).drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.NEW_BLUR_AMOUNT import code.name.monkey.retromusic.NEW_BLUR_AMOUNT
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerBinding import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
@ -94,7 +95,7 @@ class CardBlurFragment : AbsPlayerFragment(R.layout.fragment_card_blur_player),
_binding = FragmentCardBlurPlayerBinding.bind(view) _binding = FragmentCardBlurPlayerBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(binding.cardContainer) binding.cardContainer?.drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentColorPlayerBinding import code.name.monkey.retromusic.databinding.FragmentColorPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -115,7 +116,7 @@ class ColorFragment : AbsPlayerFragment(R.layout.fragment_color_player) {
val playerAlbumCoverFragment = val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -21,6 +21,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentFitBinding import code.name.monkey.retromusic.databinding.FragmentFitBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -86,7 +87,7 @@ class FitFragment : AbsPlayerFragment(R.layout.fragment_fit) {
_binding = FragmentFitBinding.bind(view) _binding = FragmentFitBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -26,6 +26,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentFlatPlayerBinding import code.name.monkey.retromusic.databinding.FragmentFlatPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -91,7 +92,7 @@ class FlatPlayerFragment : AbsPlayerFragment(R.layout.fragment_flat_player) {
_binding = FragmentFlatPlayerBinding.bind(view) _binding = FragmentFlatPlayerBinding.bind(view)
setUpPlayerToolbar() setUpPlayerToolbar()
setUpSubFragments() setUpSubFragments()
RetroUtil.drawAboveNavBar(binding.playbackControlsFragment) binding.playbackControlsFragment.drawAboveNavBar()
} }
override fun onShow() { override fun onShow() {

View file

@ -21,6 +21,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentMaterialBinding import code.name.monkey.retromusic.databinding.FragmentMaterialBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
@ -94,7 +95,7 @@ class MaterialFragment : AbsPlayerFragment(R.layout.fragment_material) {
_binding = FragmentMaterialBinding.bind(view) _binding = FragmentMaterialBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentPlayerBinding import code.name.monkey.retromusic.databinding.FragmentPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -121,7 +122,7 @@ class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player) {
_binding = FragmentPlayerBinding.bind(view) _binding = FragmentPlayerBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
override fun onDestroyView() { override fun onDestroyView() {

View file

@ -21,6 +21,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentPlainPlayerBinding import code.name.monkey.retromusic.databinding.FragmentPlainPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.base.goToAlbum import code.name.monkey.retromusic.fragments.base.goToAlbum
import code.name.monkey.retromusic.fragments.base.goToArtist import code.name.monkey.retromusic.fragments.base.goToArtist
@ -85,7 +86,7 @@ class PlainPlayerFragment : AbsPlayerFragment(R.layout.fragment_plain_player) {
binding.text.setOnClickListener { binding.text.setOnClickListener {
goToArtist(requireActivity()) goToArtist(requireActivity())
} }
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -21,6 +21,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentSimplePlayerBinding import code.name.monkey.retromusic.databinding.FragmentSimplePlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -52,7 +53,7 @@ class SimplePlayerFragment : AbsPlayerFragment(R.layout.fragment_simple_player)
_binding = FragmentSimplePlayerBinding.bind(view) _binding = FragmentSimplePlayerBinding.bind(view)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -27,6 +27,7 @@ import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding
import code.name.monkey.retromusic.extensions.drawAboveNavBar
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
@ -39,7 +40,6 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
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 kotlin.math.abs import kotlin.math.abs
@ -148,7 +148,7 @@ class TinyPlayerFragment : AbsPlayerFragment(R.layout.fragment_tiny_player),
binding.text.setOnClickListener { binding.text.setOnClickListener {
goToArtist(requireActivity()) goToArtist(requireActivity())
} }
RetroUtil.drawAboveNavBar(playerToolbar()) playerToolbar().drawAboveNavBar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {

View file

@ -231,31 +231,6 @@ public class RetroUtil {
window.setStatusBarColor(Color.TRANSPARENT); window.setStatusBarColor(Color.TRANSPARENT);
} }
/**
* This will draw our view above the navigation bar instead of behind it by adding margins.
*
* @param view view to draw above Navigation Bar
*/
public static void drawAboveNavBar(View view) {
ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
params.bottomMargin = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom;
return WindowInsetsCompat.CONSUMED;
});
}
/**
* This will draw our view above the navigation bar instead of behind it by adding padding.
*
* @param view view to draw above Navigation Bar
*/
public static void drawAboveNavBarWithPadding(View view) {
ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> {
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom);
return WindowInsetsCompat.CONSUMED;
});
}
public static String getIpAddress(boolean useIPv4) { public static String getIpAddress(boolean useIPv4) {
try { try {
List<NetworkInterface> interfaces = List<NetworkInterface> interfaces =

View file

@ -49,7 +49,7 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
accentColor accentColor
) )
itemRippleColor = ColorStateList.valueOf(accentColor.addAlpha(0.08F)) itemRippleColor = ColorStateList.valueOf(accentColor.addAlpha(0.08F))
background = ColorDrawable(ATHUtil.resolveColor(context, R.attr.colorSurface)) background = ColorDrawable(ATHUtil.resolveColor(context, R.attr.bottomSheetTint))
itemActiveIndicatorColor = ColorStateList.valueOf(accentColor.addAlpha(0.12F)) itemActiveIndicatorColor = ColorStateList.valueOf(accentColor.addAlpha(0.12F))
} }
} }

View file

@ -49,7 +49,6 @@
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_list" /> tools:listitem="@layout/item_list" />
<LinearLayout <LinearLayout
android:id="@android:id/empty" android:id="@android:id/empty"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:background="@null"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">

View file

@ -74,7 +74,7 @@
<Space <Space
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="112dp" /> android:layout_height="@dimen/mini_player_height_expanded" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -8,6 +8,7 @@
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container" android:id="@+id/fragment_container"
tools:layout="@layout/fragment_home"
android:name="androidx.navigation.fragment.NavHostFragment" android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -57,10 +58,13 @@
android:id="@+id/bottomNavigationView" android:id="@+id/bottomNavigationView"
style="@style/Widget.Material3.BottomNavigationView" style="@style/Widget.Material3.BottomNavigationView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_nav_height" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:elevation="0dp" android:elevation="0dp"
android:minHeight="@dimen/bottom_nav_height"
app:itemHorizontalTranslationEnabled="false" app:itemHorizontalTranslationEnabled="false"
app:itemPaddingBottom="0dp"
app:itemPaddingTop="8dp"
app:menu="@menu/bottom_navigation_main" app:menu="@menu/bottom_navigation_main"
tools:layout_height="wrap_content" /> tools:layout_height="wrap_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -13,6 +13,12 @@
<dimen name="list_item_image_icon_padding">8dp</dimen> <dimen name="list_item_image_icon_padding">8dp</dimen>
<dimen name="mini_player_height">56dp</dimen> <dimen name="mini_player_height">56dp</dimen>
<dimen name="cast_mini_player_height">64dp</dimen>
<dimen name="mini_player_height_expanded">120dp</dimen>
<dimen name="mini_cast_player_height_expanded">128dp</dimen>
<dimen name="bottom_nav_height">64dp</dimen>
<dimen name="app_widget_classic_height">96dp</dimen> <dimen name="app_widget_classic_height">96dp</dimen>
<dimen name="app_widget_classic_image_size">96dp</dimen> <dimen name="app_widget_classic_image_size">96dp</dimen>
@ -34,8 +40,6 @@
<dimen name="now_playing_top_margin">12dp</dimen> <dimen name="now_playing_top_margin">12dp</dimen>
<dimen name="icon_notification_dimen">32dp</dimen> <dimen name="icon_notification_dimen">32dp</dimen>
<dimen name="mini_player_height_expanded">136dp</dimen>
<dimen name="mini_cast_player_height_expanded">144dp</dimen>
<dimen name="toolbar_margin_horizontal">8dp</dimen> <dimen name="toolbar_margin_horizontal">8dp</dimen>
<dimen name="toolbar_height">48dp</dimen> <dimen name="toolbar_height">48dp</dimen>
<dimen name="item_song_height">52dp</dimen> <dimen name="item_song_height">52dp</dimen>
@ -52,6 +56,4 @@
<dimen name="lyrics_text_size">18sp</dimen> <dimen name="lyrics_text_size">18sp</dimen>
<dimen name="indicator_radius">10dp</dimen> <dimen name="indicator_radius">10dp</dimen>
<dimen name="lyrics_dialog_radius">20dp</dimen> <dimen name="lyrics_dialog_radius">20dp</dimen>
<dimen name="cast_mini_player_height">64dp</dimen>
<dimen name="bottom_nav_height">80dp</dimen>
</resources> </resources>