Fix controls alignment

This commit is contained in:
h4h13 2019-08-03 00:04:18 +05:30
parent 6acac46d45
commit 0e3a2835dd
22 changed files with 110 additions and 96 deletions

View file

@ -10,18 +10,22 @@ import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan import android.text.style.ForegroundColorSpan
import android.view.* import android.view.*
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import android.widget.Toast
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
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.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler 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.* import code.name.monkey.retromusic.util.*
import kotlinx.android.synthetic.main.fragment_mini_player.* import kotlinx.android.synthetic.main.fragment_mini_player.*
import kotlin.math.abs
open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpdateHelper.Callback, View.OnClickListener { open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpdateHelper.Callback, View.OnClickListener {
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -61,6 +65,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
actionPlayingQueue.setOnClickListener(this) actionPlayingQueue.setOnClickListener(this)
actionNext.setOnClickListener(this) actionNext.setOnClickListener(this)
actionPrevious.setOnClickListener(this) actionPrevious.setOnClickListener(this)
} }
private fun setUpMiniPlayer() { private fun setUpMiniPlayer() {
@ -91,12 +96,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
override fun onServiceConnected() { override fun onServiceConnected() {
updateSongTitle() updateSongTitle()
updatePlayPauseDrawableState() updatePlayPauseDrawableState()
updateIsFavorite() //updateIsFavorite()
} }
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {
updateSongTitle() updateSongTitle()
updateIsFavorite() //updateIsFavorite()
} }
override fun onPlayStateChanged() { override fun onPlayStateChanged() {
@ -113,12 +118,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
progressViewUpdateHelper!!.start() progressViewUpdateHelper.start()
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
progressViewUpdateHelper!!.stop() progressViewUpdateHelper.stop()
} }
protected fun updatePlayPauseDrawableState() { protected fun updatePlayPauseDrawableState() {
@ -138,7 +143,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
object : GestureDetector.SimpleOnGestureListener() { object : GestureDetector.SimpleOnGestureListener() {
override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float,
velocityY: Float): Boolean { velocityY: Float): Boolean {
if (Math.abs(velocityX) > Math.abs(velocityY)) { if (abs(velocityX) > abs(velocityY)) {
if (velocityX < 0) { if (velocityX < 0) {
MusicPlayerRemote.playNextSong() MusicPlayerRemote.playNextSong()
return true return true
@ -158,6 +163,13 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
} }
} }
fun toggleFavorite(song: Song) {
MusicUtil.toggleFavorite(requireActivity(), song)
if (song.id == MusicPlayerRemote.currentSong.id) {
//updateIsFavorite()
}
}
private var updateIsFavoriteTask: AsyncTask<*, *, *>? = null private var updateIsFavoriteTask: AsyncTask<*, *, *>? = null
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
@ -166,18 +178,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
updateIsFavoriteTask!!.cancel(false) updateIsFavoriteTask!!.cancel(false)
} }
updateIsFavoriteTask = object : AsyncTask<Song, Void, Boolean>() { updateIsFavoriteTask = object : AsyncTask<Song, Void, Boolean>() {
override fun doInBackground(vararg params: Song): Boolean? { override fun doInBackground(vararg params: Song): Boolean {
val activity = activity return MusicUtil.isFavorite(requireActivity(), params[0])
return if (activity != null) {
MusicUtil.isFavorite(requireActivity(), params[0])
} else {
cancel(false)
null
}
} }
override fun onPostExecute(isFavorite: Boolean?) { override fun onPostExecute(isFavorite: Boolean) {
val res = if (isFavorite!!) val res = if (isFavorite)
R.drawable.ic_favorite_white_24dp R.drawable.ic_favorite_white_24dp
else else
R.drawable.ic_favorite_border_white_24dp R.drawable.ic_favorite_border_white_24dp

View file

@ -4,8 +4,10 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
/** /**
* Created by hemanths on 18/08/17. * Created by hemanths on 18/08/17.
@ -33,6 +35,7 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
playerActivity!!.addMusicServiceEventListener(this) playerActivity!!.addMusicServiceEventListener(this)
} }
override fun onDestroyView() { override fun onDestroyView() {

View file

@ -62,15 +62,13 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtil.getInstance().volumeToggle) { if (PreferenceUtil.getInstance().volumeToggle) {
childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() requireFragmentManager().beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
childFragmentManager.executePendingTransactions() requireFragmentManager().executePendingTransactions()
volumeFragment = requireFragmentManager().findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
} }
} }
companion object { companion object {
const val SLIDER_ANIMATION_TIME: Long = 400 const val SLIDER_ANIMATION_TIME: Long = 400
const val VOLUME_FRAGMENT: String = "volume_fragment"
} }
} }

View file

@ -25,23 +25,30 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.* import code.name.monkey.retromusic.util.*
import code.name.monkey.retromusic.views.FitSystemWindowsLayout import code.name.monkey.retromusic.views.FitSystemWindowsLayout
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import java.io.FileNotFoundException import java.io.FileNotFoundException
abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItemClickListener, PaletteColorHolder, PlayerAlbumCoverFragment.Callbacks { abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
Toolbar.OnMenuItemClickListener,
PaletteColorHolder,
PlayerAlbumCoverFragment.Callbacks {
var callbacks: Callbacks? = null var callbacks: Callbacks? = null
private set private set
private var updateIsFavoriteTask: AsyncTask<*, *, *>? = null private var updateIsFavoriteTask: AsyncTask<*, *, *>? = null
private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null
private var playerAlbumCoverFragment: PlayerAlbumCoverFragment? = null private var playerAlbumCoverFragment: PlayerAlbumCoverFragment? = null
override fun onAttach(context: Context) { override fun onAttach(
context: Context
) {
super.onAttach(context) super.onAttach(context)
try { try {
callbacks = context as Callbacks? callbacks = context as Callbacks?
} catch (e: ClassCastException) { } catch (e: ClassCastException) {
throw RuntimeException(context.javaClass.simpleName + " must implement " + Callbacks::class.java.simpleName) throw RuntimeException(context.javaClass.simpleName + " must implement " + Callbacks::class.java.simpleName)
} }
} }
override fun onDetach() { override fun onDetach() {
@ -49,7 +56,9 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem
callbacks = null callbacks = null
} }
override fun onMenuItemClick(item: MenuItem): Boolean { override fun onMenuItemClick(
item: MenuItem
): Boolean {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
when (item.itemId) { when (item.itemId) {
R.id.action_toggle_favorite -> { R.id.action_toggle_favorite -> {
@ -178,27 +187,20 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem
updateIsFavoriteTask!!.cancel(false) updateIsFavoriteTask!!.cancel(false)
} }
updateIsFavoriteTask = object : AsyncTask<Song, Void, Boolean>() { updateIsFavoriteTask = object : AsyncTask<Song, Void, Boolean>() {
override fun doInBackground(vararg params: Song): Boolean? { override fun doInBackground(vararg params: Song): Boolean {
val activity = activity return MusicUtil.isFavorite(requireActivity(), params[0])
return if (activity != null) {
MusicUtil.isFavorite(activity, params[0])
} else {
cancel(false)
null
}
} }
override fun onPostExecute(isFavorite: Boolean?) { override fun onPostExecute(isFavorite: Boolean) {
val activity = activity val res = if (isFavorite)
if (activity != null) {
val res = if (isFavorite!!)
R.drawable.ic_favorite_white_24dp R.drawable.ic_favorite_white_24dp
else else
R.drawable.ic_favorite_border_white_24dp R.drawable.ic_favorite_border_white_24dp
val drawable = RetroUtil.getTintedVectorDrawable(activity, res, toolbarIconColor())
val drawable = RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor())
if (playerToolbar().menu.findItem(R.id.action_toggle_favorite) != null) if (playerToolbar().menu.findItem(R.id.action_toggle_favorite) != null)
playerToolbar().menu.findItem(R.id.action_toggle_favorite).setIcon(drawable).title = if (isFavorite) getString(R.string.action_remove_from_favorites) else getString(R.string.action_add_to_favorites) playerToolbar().menu.findItem(R.id.action_toggle_favorite).setIcon(drawable).title = if (isFavorite) getString(R.string.action_remove_from_favorites) else getString(R.string.action_add_to_favorites)
}
} }
}.execute(MusicPlayerRemote.currentSong) }.execute(MusicPlayerRemote.currentSong)
} }
@ -246,20 +248,14 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(ThemeStore.primaryColor(requireActivity())) view.setBackgroundColor(ThemeStore.primaryColor(requireActivity()))
if (PreferenceUtil.getInstance().fullScreenMode && view.findViewById<View>(R.id.status_bar) != null) { if (PreferenceUtil.getInstance().fullScreenMode &&
view.findViewById<View>(R.id.status_bar) != null) {
view.findViewById<View>(R.id.status_bar).visibility = View.GONE view.findViewById<View>(R.id.status_bar).visibility = View.GONE
} }
playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment? playerAlbumCoverFragment = requireFragmentManager().findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?
playerAlbumCoverFragment?.setCallbacks(this) playerAlbumCoverFragment?.setCallbacks(this)
} }
fun setSafeArea(safeArea: View) {
val layout = safeArea.findViewById<FitSystemWindowsLayout>(R.id.safeArea)
if (layout != null) {
layout.isFit = !PreferenceUtil.getInstance().fullScreenMode
}
}
interface Callbacks { interface Callbacks {
fun onPaletteColorChanged() fun onPaletteColorChanged()
@ -278,5 +274,4 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem
MusicUtil.getReadableDurationString(duration) MusicUtil.getReadableDurationString(duration)
) )
} }
} }

View file

@ -159,7 +159,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
} }
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
toolbar.setNavigationOnClickListener { v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY) } toolbar.setNavigationOnClickListener { showMainMenu(OptionsSheetDialogFragment.LIBRARY) }
} }
override fun handleBackPress(): Boolean { override fun handleBackPress(): Boolean {

View file

@ -135,7 +135,5 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
companion object { companion object {
val TAG: String = PlayerAlbumCoverFragment::class.java.simpleName val TAG: String = PlayerAlbumCoverFragment::class.java.simpleName
} }
} }

View file

@ -20,7 +20,7 @@ import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.model.lyrics.Lyrics
import kotlinx.android.synthetic.main.fragment_adaptive_player.* import kotlinx.android.synthetic.main.fragment_adaptive_player.*
class AdaptiveFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks, MusicProgressViewUpdateHelper.Callback { class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
private lateinit var lyricsLayout: FrameLayout private lateinit var lyricsLayout: FrameLayout
private lateinit var lyricsLine1: TextView private lateinit var lyricsLine1: TextView

View file

@ -8,14 +8,14 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar 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.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
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.model.Song
import kotlinx.android.synthetic.main.fragment_card_player.* import kotlinx.android.synthetic.main.fragment_card_player.*
class CardFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class CardFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }

View file

@ -21,7 +21,7 @@ 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 kotlinx.android.synthetic.main.fragment_card_blur_player.* import kotlinx.android.synthetic.main.fragment_card_blur_player.*
class CardBlurFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class CardBlurFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }

View file

@ -41,7 +41,7 @@ import kotlinx.android.synthetic.main.fragment_classic_player_playback_controls.
import kotlin.math.max import kotlin.math.max
class ClassicPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks, SlidingUpPanelLayout.PanelSlideListener { class ClassicPlayerFragment : AbsPlayerFragment(), SlidingUpPanelLayout.PanelSlideListener {
override fun onPanelSlide(p0: View?, p1: Float) { override fun onPanelSlide(p0: View?, p1: Float) {
} }

View file

@ -13,6 +13,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
@ -46,7 +47,7 @@ class ClassicPlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
} }
volumeFragment?.setTintableColor(ColorUtil.stripAlpha(lastPlaybackControlsColor)) volumeFragment?.setTintableColor(lastPlaybackControlsColor.ripAlpha())
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()

View file

@ -15,7 +15,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import kotlinx.android.synthetic.main.fragment_fit.* import kotlinx.android.synthetic.main.fragment_fit.*
class FitFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class FitFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }

View file

@ -22,7 +22,7 @@ import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.views.DrawableGradient import code.name.monkey.retromusic.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_flat_player.* import kotlinx.android.synthetic.main.fragment_flat_player.*
class FlatPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class FlatPlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }

View file

@ -29,7 +29,7 @@ import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.fragment_full.* import kotlinx.android.synthetic.main.fragment_full.*
class FullPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks, MusicProgressViewUpdateHelper.Callback { class FullPlayerFragment : AbsPlayerFragment() , MusicProgressViewUpdateHelper.Callback {
private lateinit var lyricsLayout: FrameLayout private lateinit var lyricsLayout: FrameLayout
private lateinit var lyricsLine1: TextView private lateinit var lyricsLine1: TextView
private lateinit var lyricsLine2: TextView private lateinit var lyricsLine2: TextView

View file

@ -24,6 +24,17 @@ 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.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_material_playback_controls.* import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
import kotlinx.android.synthetic.main.fragment_material_playback_controls.nextButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.previousButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_material_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_material_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_material_playback_controls.text
import kotlinx.android.synthetic.main.fragment_material_playback_controls.title
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
@ -111,7 +122,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
}.ripAlpha() }.ripAlpha()
text.setTextColor(colorFinal) text.setTextColor(colorFinal)
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) ViewUtil.setProgressDrawable(progressSlider, colorFinal, false)
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)

View file

@ -8,22 +8,23 @@ import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil 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.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
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.model.Song
import kotlinx.android.synthetic.main.fragment_material.* import kotlinx.android.synthetic.main.fragment_material.*
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
*/ */
class MaterialFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class MaterialFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }
private var lastColor: Int = 0 private var lastColor: Int = 0
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor

View file

@ -22,7 +22,7 @@ import code.name.monkey.retromusic.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_player.* import kotlinx.android.synthetic.main.fragment_player.*
class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class PlayerFragment : AbsPlayerFragment() {
private var lastColor: Int = 0 private var lastColor: Int = 0
override val paletteColor: Int override val paletteColor: Int
@ -72,7 +72,6 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
if (PreferenceUtil.getInstance().adaptiveColor) { if (PreferenceUtil.getInstance().adaptiveColor) {
colorize(color) colorize(color)
} }
} }
private fun getCutOff(): Int { private fun getCutOff(): Int {
@ -116,7 +115,8 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this)
} }
private fun setUpPlayerToolbar() { private fun setUpPlayerToolbar() {
@ -129,7 +129,6 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
override fun onServiceConnected() { override fun onServiceConnected() {
updateIsFavorite() updateIsFavorite()
} }
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {

View file

@ -60,25 +60,25 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
override fun setDark(color: Int) { override fun setDark(color: Int) {
val colorBg = ATHUtil.resolveColor(context!!, android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(context!!, true) lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(context!!, true) lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(context!!, false) lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(requireContext())
} }.ripAlpha()
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context!!, ColorUtil.isColorLight(colorFinal)), false) TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(colorFinal)), false)
TintHelper.setTintAuto(playPauseButton, colorFinal, true) TintHelper.setTintAuto(playPauseButton, colorFinal, true)
ViewUtil.setProgressDrawable(progressSlider, colorFinal.ripAlpha(), false) ViewUtil.setProgressDrawable(progressSlider, colorFinal, false)
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)

View file

@ -14,7 +14,7 @@ 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 kotlinx.android.synthetic.main.fragment_plain_player.* import kotlinx.android.synthetic.main.fragment_plain_player.*
class PlainPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class PlainPlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }

View file

@ -18,7 +18,7 @@ import kotlinx.android.synthetic.main.fragment_simple_player.*
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
*/ */
class SimplePlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { class SimplePlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }

View file

@ -14,13 +14,13 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
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.fragments.MiniPlayerFragment
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
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.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler 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.fragments.MiniPlayerFragment
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
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 kotlinx.android.synthetic.main.fragment_tiny_player.* import kotlinx.android.synthetic.main.fragment_tiny_player.*

View file

@ -16,7 +16,8 @@
android:id="@+id/playerMenu" android:id="@+id/playerMenu"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:background="?attr/roundSelector"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -30,8 +31,8 @@
android:ellipsize="marquee" android:ellipsize="marquee"
android:gravity="center" android:gravity="center"
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:paddingStart="16dp" android:paddingStart="8dp"
android:paddingEnd="16dp" android:paddingEnd="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/md_white_1000" android:textColor="@color/md_white_1000"
app:layout_constraintEnd_toStartOf="@+id/songFavourite" app:layout_constraintEnd_toStartOf="@+id/songFavourite"
@ -47,8 +48,8 @@
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:paddingStart="16dp" android:paddingStart="8dp"
android:paddingEnd="16dp" android:paddingEnd="8dp"
android:textColor="@color/md_white_1000" android:textColor="@color/md_white_1000"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/songFavourite" app:layout_constraintEnd_toStartOf="@+id/songFavourite"
@ -60,7 +61,8 @@
android:id="@+id/songFavourite" android:id="@+id/songFavourite"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:background="?attr/roundSelector"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"