Added material desing theme improvements
This commit is contained in:
parent
16d256e210
commit
58e29691cb
6 changed files with 72 additions and 231 deletions
|
@ -109,7 +109,6 @@ class AlbumCoverPagerAdapter(
|
|||
NowPlayingScreen.FIT,
|
||||
NowPlayingScreen.TINY,
|
||||
NowPlayingScreen.CLASSIC,
|
||||
NowPlayingScreen.MATERIAL,
|
||||
NowPlayingScreen.FULL -> R.layout.fragment_album_full_cover
|
||||
else -> {
|
||||
if (PreferenceUtil.getInstance(requireContext())
|
||||
|
|
|
@ -44,22 +44,38 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewPager.addOnPageChangeListener(this)
|
||||
val nowPlayingScreen = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen
|
||||
val nps = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).carouselEffect() &&
|
||||
!((nowPlayingScreen == FULL) || (nowPlayingScreen == ADAPTIVE) || (nowPlayingScreen == FIT))
|
||||
) {
|
||||
if (nps == FULL || nps == CLASSIC || nps == FIT) {
|
||||
viewPager.offscreenPageLimit = 2
|
||||
} else if (PreferenceUtil.getInstance(requireContext()).carouselEffect()) {
|
||||
viewPager.clipToPadding = false
|
||||
viewPager.setPadding(40, 40, 40, 0)
|
||||
viewPager.pageMargin = 0
|
||||
viewPager.setPageTransformer(false, CarousalPagerTransformer(requireContext()))
|
||||
} else {
|
||||
}else{
|
||||
viewPager.offscreenPageLimit = 2
|
||||
viewPager.setPageTransformer(
|
||||
true,
|
||||
PreferenceUtil.getInstance(requireContext()).albumCoverTransform
|
||||
)
|
||||
}
|
||||
|
||||
/* if (PreferenceUtil.getInstance(requireContext()).carouselEffect() &&
|
||||
!((nps == FULL) || (nps == ADAPTIVE) || (nps == FIT))
|
||||
) {
|
||||
viewPager.clipToPadding = false
|
||||
viewPager.setPadding(40, 40, 40, 0)
|
||||
viewPager.pageMargin = 0
|
||||
viewPager.setPageTransformer(false, CarousalPagerTransformer(requireContext()))
|
||||
} else if () {
|
||||
} else {
|
||||
viewPager.offscreenPageLimit = 2
|
||||
viewPager.setPageTransformer(
|
||||
true,
|
||||
PreferenceUtil.getInstance(requireContext()).albumCoverTransform
|
||||
)
|
||||
}*/
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
@ -20,7 +20,6 @@ import kotlinx.android.synthetic.main.fragment_color_player.*
|
|||
class ColorFragment : AbsPlayerFragment() {
|
||||
|
||||
private var lastColor: Int = 0
|
||||
private var backgroundColor: Int = 0
|
||||
private lateinit var playbackControlsFragment: ColorPlaybackControlsFragment
|
||||
private var valueAnimator: ValueAnimator? = null
|
||||
|
||||
|
@ -29,7 +28,7 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override val paletteColor: Int
|
||||
get() = backgroundColor
|
||||
get() = lastColor
|
||||
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
|
@ -116,20 +115,6 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setColors(colors: MediaNotificationProcessor) {
|
||||
this.lastColor = colors.backgroundColor
|
||||
this.backgroundColor = colors.backgroundColor
|
||||
playbackControlsFragment.setDark(colors)
|
||||
colorGradientBackground?.setBackgroundColor(colors.backgroundColor)
|
||||
playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(colors.backgroundColor))
|
||||
callbacks?.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
colors.secondaryTextColor,
|
||||
requireActivity()
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ColorFragment {
|
||||
return ColorFragment()
|
||||
|
|
|
@ -4,57 +4,22 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.CustomBottomSheetBehavior
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import kotlinx.android.synthetic.main.fragment_material.*
|
||||
import kotlinx.android.synthetic.main.status_bar.*
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
class MaterialFragment : AbsPlayerFragment(), View.OnLayoutChangeListener {
|
||||
private lateinit var queueAdapter: PlayingQueueAdapter
|
||||
private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
(requireActivity() as AbsSlidingMusicPanelActivity).getBottomSheetBehavior()
|
||||
.setAllowDragging(false)
|
||||
|
||||
sheetContent.setPadding(
|
||||
sheetContent.paddingLeft,
|
||||
(slideOffset * status_bar.height).toInt(),
|
||||
sheetContent.paddingRight,
|
||||
sheetContent.paddingBottom
|
||||
)
|
||||
|
||||
playerControlsContainer.layoutParams.height = playerContainer.width
|
||||
}
|
||||
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
val activity = requireActivity() as AbsSlidingMusicPanelActivity
|
||||
if (newState == BottomSheetBehavior.STATE_EXPANDED || newState == BottomSheetBehavior.STATE_DRAGGING) {
|
||||
activity.getBottomSheetBehavior().setAllowDragging(false)
|
||||
} else {
|
||||
activity.getBottomSheetBehavior().setAllowDragging(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
class MaterialFragment : AbsPlayerFragment() {
|
||||
|
||||
override fun playerToolbar(): Toolbar {
|
||||
return playerToolbar
|
||||
|
@ -85,9 +50,6 @@ class MaterialFragment : AbsPlayerFragment(), View.OnLayoutChangeListener {
|
|||
}
|
||||
|
||||
override fun onColorChanged(color: MediaNotificationProcessor) {
|
||||
val darkColor = ColorUtil.darkenColorTheme(color.backgroundColor)
|
||||
playerContainer?.setBackgroundColor(ColorUtil.darkenColorTheme(color.backgroundColor))
|
||||
upComing?.setBackgroundColor(ColorUtil.darkenColorTheme(darkColor))
|
||||
playbackControlsFragment.setDark(color.backgroundColor)
|
||||
lastColor = color.backgroundColor
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
@ -121,40 +83,6 @@ class MaterialFragment : AbsPlayerFragment(), View.OnLayoutChangeListener {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpSubFragments()
|
||||
setUpPlayerToolbar()
|
||||
setupPanel()
|
||||
setUpQueue()
|
||||
getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList)
|
||||
|
||||
playerQueueSheet.setOnTouchListener { _, _ ->
|
||||
(requireActivity() as AbsSlidingMusicPanelActivity).getBottomSheetBehavior()
|
||||
.setAllowDragging(false)
|
||||
getQueuePanel().setAllowDragging(true)
|
||||
return@setOnTouchListener false
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpQueue() {
|
||||
queueAdapter = PlayingQueueAdapter(
|
||||
requireActivity() as AppCompatActivity, mutableListOf(),
|
||||
MusicPlayerRemote.position,
|
||||
R.layout.item_queue
|
||||
)
|
||||
recyclerView.apply {
|
||||
adapter = queueAdapter
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPanel() {
|
||||
if (!ViewCompat.isLaidOut(playerContainer) || playerContainer.isLayoutRequested) {
|
||||
playerContainer.addOnLayoutChangeListener(this)
|
||||
return
|
||||
}
|
||||
val height = playerContainer?.height ?: 0
|
||||
val width = playerContainer?.width ?: 0
|
||||
val finalHeight = height - (playerControlsContainer.height - width)
|
||||
val panel = getQueuePanel()
|
||||
panel.peekHeight = finalHeight
|
||||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
|
@ -180,7 +108,6 @@ class MaterialFragment : AbsPlayerFragment(), View.OnLayoutChangeListener {
|
|||
|
||||
override fun onServiceConnected() {
|
||||
updateIsFavorite()
|
||||
queueAdapter.swapDataSet(MusicPlayerRemote.playingQueue)
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
@ -193,32 +120,4 @@ class MaterialFragment : AbsPlayerFragment(), View.OnLayoutChangeListener {
|
|||
return PlayerFragment()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getQueuePanel(): CustomBottomSheetBehavior<FrameLayout> {
|
||||
return CustomBottomSheetBehavior.from(playerQueueSheet) as CustomBottomSheetBehavior<FrameLayout>
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
getQueuePanel().removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
override fun onLayoutChange(
|
||||
v: View?,
|
||||
left: Int,
|
||||
top: Int,
|
||||
right: Int,
|
||||
bottom: Int,
|
||||
oldLeft: Int,
|
||||
oldTop: Int,
|
||||
oldRight: Int,
|
||||
oldBottom: Int
|
||||
) {
|
||||
val height = playerContainer?.height ?: 0
|
||||
val width = playerContainer?.width ?: 0
|
||||
val finalHeight = height - width
|
||||
playerControlsContainer.layoutParams.height = height - width
|
||||
val panel = getQueuePanel()
|
||||
panel.peekHeight = finalHeight
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue