Add tiny theme back

This commit is contained in:
h4h13 2019-02-26 23:38:07 +05:30
parent 675c2fe4fa
commit a74db34121
9 changed files with 291 additions and 33 deletions

View file

@ -19,11 +19,11 @@ import code.name.monkey.retromusic.ui.fragments.player.adaptive.AdaptiveFragment
import code.name.monkey.retromusic.ui.fragments.player.blur.BlurPlayerFragment import code.name.monkey.retromusic.ui.fragments.player.blur.BlurPlayerFragment
import code.name.monkey.retromusic.ui.fragments.player.card.CardFragment import code.name.monkey.retromusic.ui.fragments.player.card.CardFragment
import code.name.monkey.retromusic.ui.fragments.player.cardblur.CardBlurFragment import code.name.monkey.retromusic.ui.fragments.player.cardblur.CardBlurFragment
import code.name.monkey.retromusic.ui.fragments.player.classic.ClassicPlayerFragment
import code.name.monkey.retromusic.ui.fragments.player.color.ColorFragment import code.name.monkey.retromusic.ui.fragments.player.color.ColorFragment
import code.name.monkey.retromusic.ui.fragments.player.fit.FitFragment import code.name.monkey.retromusic.ui.fragments.player.fit.FitFragment
import code.name.monkey.retromusic.ui.fragments.player.flat.FlatPlayerFragment import code.name.monkey.retromusic.ui.fragments.player.flat.FlatPlayerFragment
import code.name.monkey.retromusic.ui.fragments.player.full.FullPlayerFragment import code.name.monkey.retromusic.ui.fragments.player.full.FullPlayerFragment
import code.name.monkey.retromusic.ui.fragments.player.tiny.TinyPlayerFragment
import code.name.monkey.retromusic.ui.fragments.player.material.MaterialFragment import code.name.monkey.retromusic.ui.fragments.player.material.MaterialFragment
import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.ui.fragments.player.plain.PlainPlayerFragment import code.name.monkey.retromusic.ui.fragments.player.plain.PlainPlayerFragment
@ -192,7 +192,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
NowPlayingScreen.SIMPLE -> SimplePlayerFragment() NowPlayingScreen.SIMPLE -> SimplePlayerFragment()
NowPlayingScreen.MATERIAL -> MaterialFragment() NowPlayingScreen.MATERIAL -> MaterialFragment()
NowPlayingScreen.COLOR -> ColorFragment() NowPlayingScreen.COLOR -> ColorFragment()
//NowPlayingScreen.CLASSIC -> ClassicPlayerFragment() NowPlayingScreen.TINY -> TinyPlayerFragment()
else -> PlayerFragment() else -> PlayerFragment()
} // must implement AbsPlayerFragment } // must implement AbsPlayerFragment
supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment).commit() supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment).commit()

View file

@ -20,7 +20,7 @@ enum class NowPlayingScreen constructor(@param:StringRes @field:StringRes
MATERIAL(R.string.material, R.drawable.np_material, 11), MATERIAL(R.string.material, R.drawable.np_material, 11),
NORMAL(R.string.normal, R.drawable.np_normal, 0), NORMAL(R.string.normal, R.drawable.np_normal, 0),
PLAIN(R.string.plain, R.drawable.np_plain, 3), PLAIN(R.string.plain, R.drawable.np_plain, 3),
//CLASSIC(R.string.classic, R.drawable.np_normal, 7), TINY(R.string.tiny, R.drawable.np_tiny, 7),
SIMPLE(R.string.simple, R.drawable.np_simple, 8) SIMPLE(R.string.simple, R.drawable.np_simple, 8)
} }

View file

@ -171,9 +171,14 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
} }
private fun setupToolbar() { private fun setupToolbar() {
toolbar.navigationIcon = TintHelper.createTintedDrawable(ContextCompat.getDrawable(context!!, R.drawable.ic_search_white_24dp), ThemeStore.textColorSecondary(context!!))
mainActivity.title = null mainActivity.title = null
toolbar.setBackgroundColor(Color.TRANSPARENT) toolbar.apply {
navigationIcon = TintHelper.createTintedDrawable(ContextCompat.getDrawable(context!!, R.drawable.ic_search_white_24dp), ThemeStore.textColorSecondary(context!!))
setBackgroundColor(Color.TRANSPARENT)
setNavigationOnClickListener {
NavigationUtil.goToSearch(activity)
}
}
} }
override fun handleBackPress(): Boolean { override fun handleBackPress(): Boolean {

View file

@ -0,0 +1,97 @@
package code.name.monkey.retromusic.ui.fragments.player.tiny
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.*
class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun show() {
}
override fun hide() {
}
override fun setUpProgressSlider() {
}
override fun setDark(color: Int) {
if (ColorUtil.isColorLight(color)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(getActivity(), true);
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(getActivity(), true);
} else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(getActivity(), false);
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false);
}
updateRepeatState();
updateShuffleState();
}
override fun onUpdateProgressViews(progress: Int, total: Int) {
}
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_tiny_controls_fragment, container, false);
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()
}
private fun setUpMusicControllers() {
setUpRepeatButton()
setUpShuffleButton()
setUpProgressSlider()
}
private fun setUpShuffleButton() {
playerShuffleButton.setOnClickListener { MusicPlayerRemote.toggleShuffleMode() }
}
private fun setUpRepeatButton() {
playerRepeatButton.setOnClickListener { MusicPlayerRemote.cycleRepeatMode() }
}
override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> playerShuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
else -> playerShuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
}
override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
playerRepeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
MusicService.REPEAT_MODE_ALL -> {
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
MusicService.REPEAT_MODE_THIS -> {
playerRepeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
}
}
}

View file

@ -0,0 +1,158 @@
package code.name.monkey.retromusic.ui.fragments.player.tiny
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.ThemeStore
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.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
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.ui.fragments.MiniPlayerFragment
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.ui.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.*
class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
override fun onUpdateProgressViews(progress: Int, total: Int) {
progressBar.max = total
val animator = ObjectAnimator.ofInt(progressBar, "progress", progress)
val animatorSet = AnimatorSet()
animatorSet.playSequentially(animator)
animatorSet.duration = 1500
animatorSet.interpolator = LinearInterpolator()
animatorSet.start()
playerSongTotalTime.text = String.format("%s/%s", MusicUtil.getReadableDurationString(total.toLong()),
MusicUtil.getReadableDurationString(progress.toLong()))
}
override fun toolbarGet(): Toolbar {
return playerToolbar
}
override fun onShow() {
}
override fun onHide() {
}
override fun onBackPressed(): Boolean {
return false
}
override fun toolbarIconColor(): Int {
return MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(lastColor))
}
private var lastColor: Int = 0
override val paletteColor: Int
get() = lastColor
override fun onColorChanged(color: Int) {
val lastColor = if (PreferenceUtil.getInstance().adaptiveColor) {
color
} else {
ThemeStore.accentColor(context!!)
}
callbacks?.onPaletteColorChanged()
tinyPlaybackControlsFragment.setDark(lastColor)
TintHelper.setTintAuto(progressBar, lastColor, false)
val iconColor = MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(lastColor))
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, activity)
}
override fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong)
}
private lateinit var tinyPlaybackControlsFragment: TinyPlaybackControlsFragment
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onResume() {
super.onResume()
progressViewUpdateHelper.start()
}
override fun onPause() {
super.onPause()
progressViewUpdateHelper.stop()
}
private fun updateSong() {
val song = MusicPlayerRemote.currentSong
songTitle.text = song.title
songText.text = String.format("%s \nby -%s", song.albumName, song.artistName)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_tiny_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
progressBar.setOnClickListener(PlayPauseButtonOnClickHandler())
progressBar.setOnTouchListener(MiniPlayerFragment.FlingPlayBackController(activity!!))
setUpPlayerToolbar()
setUpSubFragments()
}
private fun setUpSubFragments() {
tinyPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this)
}
private fun setUpPlayerToolbar() {
playerToolbar.apply {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { activity!!.onBackPressed() }
setOnMenuItemClickListener(this@TinyPlayerFragment)
}
}
override fun toggleFavorite(song: Song) {
super.toggleFavorite(song)
if (song.id == MusicPlayerRemote.currentSong.id) {
updateIsFavorite()
}
}
override fun onServiceConnected() {
super.onServiceConnected()
updateSong()
}
override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged()
updateSong()
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -2,7 +2,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"> <item android:id="@android:id/background">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="?attr/colorPrimary" /> <solid android:color="@android:color/transparent" />
</shape> </shape>
</item> </item>
<item android:id="@android:id/progress"> <item android:id="@android:id/progress">
@ -10,7 +10,8 @@
android:clipOrientation="vertical" android:clipOrientation="vertical"
android:gravity="bottom"> android:gravity="bottom">
<shape> <shape>
<gradient android:angle="135" <gradient
android:angle="135"
android:endColor="@color/md_blue_A200" android:endColor="@color/md_blue_A200"
android:startColor="@color/md_green_A700" /> android:startColor="@color/md_green_A700" />
</shape> </shape>

View file

@ -8,7 +8,7 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageButton <ImageButton
android:id="@+id/player_repeat_button" android:id="@+id/playerRepeatButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
@ -20,7 +20,7 @@
android:contentDescription="TODO" /> android:contentDescription="TODO" />
<ImageButton <ImageButton
android:id="@+id/player_shuffle_button" android:id="@+id/playerShuffleButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"

View file

@ -8,23 +8,20 @@
android:clickable="true" android:clickable="true"
android:focusable="true"> android:focusable="true">
<code.name.monkey.retromusic.views.WidthFitSquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:rotation="0">
<fragment <fragment
android:id="@+id/player_album_cover_fragment" android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment" android:name="code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout="@layout/fragment_player_album_cover" /> tools:layout="@layout/fragment_player_album_cover" />
</code.name.monkey.retromusic.views.WidthFitSquareLayout> <View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#90000000" />
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progressBar"
style="@android:style/Widget.ProgressBar.Horizontal" style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -60,25 +57,25 @@
android:padding="16dp"> android:padding="16dp">
<code.name.monkey.retromusic.views.VerticalTextView <code.name.monkey.retromusic.views.VerticalTextView
android:id="@+id/title" android:id="@+id/songTitle"
android:textStyle="bold" style="@style/TextAppearance.MaterialComponents.Headline2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:ellipsize="end" android:ellipsize="end"
android:freezesText="true" android:freezesText="true"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Display2" android:textStyle="bold"
app:textAllCaps="true" app:textAllCaps="true"
tools:ignore="MissingPrefix" tools:ignore="MissingPrefix"
tools:text="Song title" /> tools:text="Song title" />
<code.name.monkey.retromusic.views.VerticalTextView <code.name.monkey.retromusic.views.VerticalTextView
android:id="@+id/text" android:id="@+id/songText"
style="@style/TextAppearance.MaterialComponents.Subtitle1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
tools:text=" Album name \nby Artist name" /> tools:text=" Album name \nby Artist name" />
</LinearLayout> </LinearLayout>
@ -90,11 +87,11 @@
android:orientation="vertical"> android:orientation="vertical">
<fragment <fragment
android:id="@+id/playback_controls_fragment" android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.ui.fragments.player.hmm.HmmPlaybackControlsFragment" android:name="code.name.monkey.retromusic.ui.fragments.player.tiny.TinyPlaybackControlsFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout="@layout/fragment_hmm_controls_fragment" /> tools:layout="@layout/fragment_tiny_controls_fragment" />
<FrameLayout <FrameLayout
android:id="@+id/toolbar_container" android:id="@+id/toolbar_container"
@ -102,7 +99,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/player_toolbar" android:id="@+id/playerToolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:navigationIcon="@drawable/ic_close_white_24dp" /> app:navigationIcon="@drawable/ic_close_white_24dp" />
</FrameLayout> </FrameLayout>
@ -116,13 +113,13 @@
android:orientation="horizontal"> android:orientation="horizontal">
<code.name.monkey.retromusic.views.VerticalTextView <code.name.monkey.retromusic.views.VerticalTextView
android:id="@+id/player_song_total_time" android:id="@+id/playerSongTotalTime"
android:textStyle="bold"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_gravity="end"
android:padding="16dp" android:padding="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Display3" android:textAppearance="@style/TextAppearance.AppCompat.Display3"
android:textStyle="bold"
tools:ignore="MissingPrefix" /> tools:ignore="MissingPrefix" />
</LinearLayout> </LinearLayout>