From 0e3a2835dd62862ab09dc94ec96054a5c0df52ee Mon Sep 17 00:00:00 2001 From: h4h13 Date: Sat, 3 Aug 2019 00:04:18 +0530 Subject: [PATCH] Fix controls alignment --- .../fragments/MiniPlayerFragment.kt | 38 +++++++----- .../fragments/base/AbsMusicServiceFragment.kt | 5 +- .../base/AbsPlayerControlsFragment.kt | 8 +-- .../fragments/base/AbsPlayerFragment.kt | 61 +++++++++---------- .../mainactivity/home/BannerHomeFragment.kt | 2 +- .../player/PlayerAlbumCoverFragment.kt | 2 - .../player/adaptive/AdaptiveFragment.kt | 2 +- .../fragments/player/card/CardFragment.kt | 6 +- .../player/cardblur/CardBlurFragment.kt | 2 +- .../player/classic/ClassicPlayerFragment.kt | 2 +- .../ClassicPlayerPlaybackControlsFragment.kt | 3 +- .../fragments/player/fit/FitFragment.kt | 2 +- .../player/flat/FlatPlayerFragment.kt | 2 +- .../player/full/FullPlayerFragment.kt | 2 +- .../material/MaterialControlsFragment.kt | 13 +++- .../player/material/MaterialFragment.kt | 7 ++- .../fragments/player/normal/PlayerFragment.kt | 7 +-- .../normal/PlayerPlaybackControlsFragment.kt | 18 +++--- .../player/plain/PlainPlayerFragment.kt | 2 +- .../player/simple/SimplePlayerFragment.kt | 2 +- .../player/tiny/TinyPlayerFragment.kt | 6 +- .../layout/fragment_full_player_controls.xml | 14 +++-- 22 files changed, 110 insertions(+), 96 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt index e101149b..32e0c014 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt @@ -10,18 +10,22 @@ import android.text.SpannableStringBuilder import android.text.style.ForegroundColorSpan import android.view.* import android.view.animation.DecelerateInterpolator +import android.widget.Toast import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.retromusic.R 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.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.* import kotlinx.android.synthetic.main.fragment_mini_player.* +import kotlin.math.abs open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpdateHelper.Callback, View.OnClickListener { - private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null + + private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -61,6 +65,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda actionPlayingQueue.setOnClickListener(this) actionNext.setOnClickListener(this) actionPrevious.setOnClickListener(this) + } private fun setUpMiniPlayer() { @@ -91,12 +96,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda override fun onServiceConnected() { updateSongTitle() updatePlayPauseDrawableState() - updateIsFavorite() + //updateIsFavorite() } override fun onPlayingMetaChanged() { updateSongTitle() - updateIsFavorite() + //updateIsFavorite() } override fun onPlayStateChanged() { @@ -113,12 +118,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda override fun onResume() { super.onResume() - progressViewUpdateHelper!!.start() + progressViewUpdateHelper.start() } override fun onPause() { super.onPause() - progressViewUpdateHelper!!.stop() + progressViewUpdateHelper.stop() } protected fun updatePlayPauseDrawableState() { @@ -138,7 +143,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda object : GestureDetector.SimpleOnGestureListener() { override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { - if (Math.abs(velocityX) > Math.abs(velocityY)) { + if (abs(velocityX) > abs(velocityY)) { if (velocityX < 0) { MusicPlayerRemote.playNextSong() 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 @SuppressLint("StaticFieldLeak") @@ -166,18 +178,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda updateIsFavoriteTask!!.cancel(false) } updateIsFavoriteTask = object : AsyncTask() { - override fun doInBackground(vararg params: Song): Boolean? { - val activity = activity - return if (activity != null) { - MusicUtil.isFavorite(requireActivity(), params[0]) - } else { - cancel(false) - null - } + override fun doInBackground(vararg params: Song): Boolean { + return MusicUtil.isFavorite(requireActivity(), params[0]) } - override fun onPostExecute(isFavorite: Boolean?) { - val res = if (isFavorite!!) + override fun onPostExecute(isFavorite: Boolean) { + val res = if (isFavorite) R.drawable.ic_favorite_white_24dp else R.drawable.ic_favorite_border_white_24dp diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt index f916b08d..d3bc32ce 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt @@ -4,8 +4,10 @@ import android.content.Context import android.os.Bundle import android.view.View 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.interfaces.MusicServiceEventListener +import io.reactivex.subjects.PublishSubject +import io.reactivex.subjects.Subject /** * Created by hemanths on 18/08/17. @@ -33,6 +35,7 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) playerActivity!!.addMusicServiceEventListener(this) + } override fun onDestroyView() { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt index 98d7f481..b89f73c8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt @@ -62,15 +62,13 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr private fun hideVolumeIfAvailable() { if (PreferenceUtil.getInstance().volumeToggle) { - childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() - childFragmentManager.executePendingTransactions() - - volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? + requireFragmentManager().beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() + requireFragmentManager().executePendingTransactions() + volumeFragment = requireFragmentManager().findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? } } companion object { const val SLIDER_ANIMATION_TIME: Long = 400 - const val VOLUME_FRAGMENT: String = "volume_fragment" } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt index aac03f73..5e698370 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt @@ -25,23 +25,30 @@ import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.util.* import code.name.monkey.retromusic.views.FitSystemWindowsLayout +import io.reactivex.subjects.PublishSubject +import io.reactivex.subjects.Subject 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 private set private var updateIsFavoriteTask: AsyncTask<*, *, *>? = null private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null private var playerAlbumCoverFragment: PlayerAlbumCoverFragment? = null - override fun onAttach(context: Context) { + override fun onAttach( + context: Context + ) { super.onAttach(context) try { callbacks = context as Callbacks? } catch (e: ClassCastException) { throw RuntimeException(context.javaClass.simpleName + " must implement " + Callbacks::class.java.simpleName) } - } override fun onDetach() { @@ -49,7 +56,9 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem callbacks = null } - override fun onMenuItemClick(item: MenuItem): Boolean { + override fun onMenuItemClick( + item: MenuItem + ): Boolean { val song = MusicPlayerRemote.currentSong when (item.itemId) { R.id.action_toggle_favorite -> { @@ -178,27 +187,20 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem updateIsFavoriteTask!!.cancel(false) } updateIsFavoriteTask = object : AsyncTask() { - override fun doInBackground(vararg params: Song): Boolean? { - val activity = activity - return if (activity != null) { - MusicUtil.isFavorite(activity, params[0]) - } else { - cancel(false) - null - } + override fun doInBackground(vararg params: Song): Boolean { + return MusicUtil.isFavorite(requireActivity(), params[0]) } - override fun onPostExecute(isFavorite: Boolean?) { - val activity = activity - if (activity != null) { - val res = if (isFavorite!!) - R.drawable.ic_favorite_white_24dp - else - R.drawable.ic_favorite_border_white_24dp - val drawable = RetroUtil.getTintedVectorDrawable(activity, res, toolbarIconColor()) - 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) - } + override fun onPostExecute(isFavorite: Boolean) { + val res = if (isFavorite) + R.drawable.ic_favorite_white_24dp + else + R.drawable.ic_favorite_border_white_24dp + + val drawable = RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor()) + 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) + } }.execute(MusicPlayerRemote.currentSong) } @@ -246,20 +248,14 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) view.setBackgroundColor(ThemeStore.primaryColor(requireActivity())) - if (PreferenceUtil.getInstance().fullScreenMode && view.findViewById(R.id.status_bar) != null) { + if (PreferenceUtil.getInstance().fullScreenMode && + view.findViewById(R.id.status_bar) != null) { view.findViewById(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) } - fun setSafeArea(safeArea: View) { - val layout = safeArea.findViewById(R.id.safeArea) - if (layout != null) { - layout.isFit = !PreferenceUtil.getInstance().fullScreenMode - } - } - interface Callbacks { fun onPaletteColorChanged() @@ -278,5 +274,4 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), Toolbar.OnMenuItem MusicUtil.getReadableDurationString(duration) ) } - } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt index fe65fea1..bbb311e9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt @@ -159,7 +159,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba } mainActivity.setSupportActionBar(toolbar) - toolbar.setNavigationOnClickListener { v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY) } + toolbar.setNavigationOnClickListener { showMainMenu(OptionsSheetDialogFragment.LIBRARY) } } override fun handleBackPress(): Boolean { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt index 4908593d..072707c3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt @@ -135,7 +135,5 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan companion object { val TAG: String = PlayerAlbumCoverFragment::class.java.simpleName - - } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt index 122bf7ab..c469b5b6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt @@ -20,7 +20,7 @@ import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics import code.name.monkey.retromusic.model.lyrics.Lyrics 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 lyricsLine1: TextView diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt index b3f920e0..e1767503 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt @@ -8,14 +8,14 @@ import android.view.ViewGroup import androidx.appcompat.widget.Toolbar import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper 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.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 kotlinx.android.synthetic.main.fragment_card_player.* -class CardFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class CardFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt index 492dfe69..c03651e8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt @@ -21,7 +21,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import kotlinx.android.synthetic.main.fragment_card_blur_player.* -class CardBlurFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class CardBlurFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt index 1b7bf9fa..60a54e5e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt @@ -41,7 +41,7 @@ import kotlinx.android.synthetic.main.fragment_classic_player_playback_controls. import kotlin.math.max -class ClassicPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks, SlidingUpPanelLayout.PanelSlideListener { +class ClassicPlayerFragment : AbsPlayerFragment(), SlidingUpPanelLayout.PanelSlideListener { override fun onPanelSlide(p0: View?, p1: Float) { } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerPlaybackControlsFragment.kt index e4c6bab1..bc339aa6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerPlaybackControlsFragment.kt @@ -13,6 +13,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper 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.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper @@ -46,7 +47,7 @@ class ClassicPlayerPlaybackControlsFragment : AbsPlayerControlsFragment() { lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false) } - volumeFragment?.setTintableColor(ColorUtil.stripAlpha(lastPlaybackControlsColor)) + volumeFragment?.setTintableColor(lastPlaybackControlsColor.ripAlpha()) updateRepeatState() updateShuffleState() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt index f7dac974..b28808fb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt @@ -15,7 +15,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import kotlinx.android.synthetic.main.fragment_fit.* -class FitFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class FitFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt index 1a83b67b..0e60378e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt @@ -22,7 +22,7 @@ import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.views.DrawableGradient import kotlinx.android.synthetic.main.fragment_flat_player.* -class FlatPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class FlatPlayerFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt index 62a7512b..71691771 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt @@ -29,7 +29,7 @@ import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers 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 lyricsLine1: TextView private lateinit var lyricsLine2: TextView diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt index 63db40c1..b4a0159f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt @@ -24,6 +24,17 @@ import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.PreferenceUtil 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.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). @@ -111,7 +122,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() { }.ripAlpha() text.setTextColor(colorFinal) - ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) + ViewUtil.setProgressDrawable(progressSlider, colorFinal, false) volumeFragment?.setTintable(colorFinal) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt index d32b0e2f..57d9078f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt @@ -8,22 +8,23 @@ import androidx.appcompat.widget.Toolbar import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper 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.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 kotlinx.android.synthetic.main.fragment_material.* /** * @author Hemanth S (h4h13). */ -class MaterialFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class MaterialFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } private var lastColor: Int = 0 + override val paletteColor: Int get() = lastColor diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt index f0eb0203..7715ab09 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt @@ -22,7 +22,7 @@ import code.name.monkey.retromusic.views.DrawableGradient import kotlinx.android.synthetic.main.fragment_player.* -class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class PlayerFragment : AbsPlayerFragment() { private var lastColor: Int = 0 override val paletteColor: Int @@ -72,7 +72,6 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { if (PreferenceUtil.getInstance().adaptiveColor) { colorize(color) } - } private fun getCutOff(): Int { @@ -116,7 +115,8 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { private fun setUpSubFragments() { playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment - + val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment + playerAlbumCoverFragment.setCallbacks(this) } private fun setUpPlayerToolbar() { @@ -129,7 +129,6 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { override fun onServiceConnected() { updateIsFavorite() - } override fun onPlayingMetaChanged() { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt index 57174c4b..88f2d75d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt @@ -60,25 +60,25 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() { } 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)) { - lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(context!!, true) - lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(context!!, true) + lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true) + lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true) } else { - lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(context!!, false) - lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false) + lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false) + lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) } val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { color } 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) - ViewUtil.setProgressDrawable(progressSlider, colorFinal.ripAlpha(), false) + ViewUtil.setProgressDrawable(progressSlider, colorFinal, false) volumeFragment?.setTintable(colorFinal) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt index f1e064b5..78b76844 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt @@ -14,7 +14,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import kotlinx.android.synthetic.main.fragment_plain_player.* -class PlainPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class PlainPlayerFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt index 5e78135b..e550b527 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt @@ -18,7 +18,7 @@ import kotlinx.android.synthetic.main.fragment_simple_player.* * @author Hemanth S (h4h13). */ -class SimplePlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks { +class SimplePlayerFragment : AbsPlayerFragment() { override fun playerToolbar(): Toolbar { return playerToolbar } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt index 51ec79ee..170abcb4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt @@ -14,13 +14,13 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper 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.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler 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.PreferenceUtil import kotlinx.android.synthetic.main.fragment_tiny_player.* diff --git a/app/src/main/res/layout/fragment_full_player_controls.xml b/app/src/main/res/layout/fragment_full_player_controls.xml index 642f2b27..c640ffe1 100644 --- a/app/src/main/res/layout/fragment_full_player_controls.xml +++ b/app/src/main/res/layout/fragment_full_player_controls.xml @@ -16,7 +16,8 @@ android:id="@+id/playerMenu" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="16dp" + android:background="?attr/roundSelector" + android:padding="12dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -30,8 +31,8 @@ android:ellipsize="marquee" android:gravity="center" android:marqueeRepeatLimit="marquee_forever" - android:paddingStart="16dp" - android:paddingEnd="16dp" + android:paddingStart="8dp" + android:paddingEnd="8dp" android:singleLine="true" android:textColor="@color/md_white_1000" app:layout_constraintEnd_toStartOf="@+id/songFavourite" @@ -47,8 +48,8 @@ android:ellipsize="end" android:gravity="center" android:maxLines="1" - android:paddingStart="16dp" - android:paddingEnd="16dp" + android:paddingStart="8dp" + android:paddingEnd="8dp" android:textColor="@color/md_white_1000" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/songFavourite" @@ -60,7 +61,8 @@ android:id="@+id/songFavourite" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="16dp" + android:background="?attr/roundSelector" + android:padding="12dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent"