Added icons for material design and Updated the Album style for Now playing themes

This commit is contained in:
h4h13 2020-05-06 02:11:07 +05:30
parent fd22134a23
commit c8837f13ef
18 changed files with 165 additions and 86 deletions

View file

@ -34,6 +34,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_drive_mode.*
import kotlinx.coroutines.CoroutineScope
@ -217,7 +218,7 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
.build()
.transform(BlurTransformation.Builder(this).build())
.into(object : RetroMusicColoredTarget(image) {
override fun onColorReady(color: Int) {
override fun onColorReady(color: MediaNotificationProcessor) {
}
})
}

View file

@ -246,7 +246,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
TINY -> TinyPlayerFragment()
PEAK -> PeakPlayerFragment()
CIRCLE -> CirclePlayerFragment()
EXAMPLE -> ClassicPlayerFragment()
CLASSIC -> ClassicPlayerFragment()
else -> PlayerFragment()
} // must implement AbsPlayerFragment
supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment)

View file

@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
import code.name.monkey.retromusic.fragments.NowPlayingScreen
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
@ -94,12 +95,7 @@ class AlbumCoverPagerAdapter(
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val finalLayout = when {
PreferenceUtil.getInstance(requireContext())
.carouselEffect() -> R.layout.fragment_album_carousel_cover
else -> layout
}
val view = inflater.inflate(finalLayout, container, false)
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
albumCover = view.findViewById(R.id.player_image)
albumCover.setOnClickListener {
NavigationUtil.goToLyrics(requireActivity())
@ -107,6 +103,34 @@ class AlbumCoverPagerAdapter(
return view
}
private fun getLayoutWithPlayerTheme(): Int {
return when (PreferenceUtil.getInstance(requireContext()).nowPlayingScreen) {
NowPlayingScreen.CARD,
NowPlayingScreen.FIT,
NowPlayingScreen.TINY,
NowPlayingScreen.CLASSIC,
NowPlayingScreen.FULL -> R.layout.fragment_album_full_cover
else -> {
if (PreferenceUtil.getInstance(requireContext())
.carouselEffect()
) {
R.layout.fragment_album_carousel_cover
} else {
when (PreferenceUtil.getInstance(requireContext()).albumCoverStyle) {
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover
AlbumCoverStyle.CARD -> R.layout.fragment_album_card_cover
AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover
AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover
AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover
else -> R.layout.fragment_album_cover
}
}
}
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
loadAlbumCover()

View file

@ -20,30 +20,25 @@ import androidx.fragment.app.DialogFragment
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.loaders.PlaylistLoader
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
import code.name.monkey.retromusic.room.playlist.PlaylistEntity
import code.name.monkey.retromusic.util.PlaylistsUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.list.listItems
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
class AddToPlaylistDialog : DialogFragment() {
override fun onCreateDialog(
savedInstanceState: Bundle?
): Dialog {
val names = requireArguments().getParcelableArrayList<PlaylistEntity>("names")
val playlists = PlaylistLoader.getAllPlaylists(requireContext())
val playlistNames: MutableList<String> = mutableListOf()
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
for (p in names!!) {
playlistNames.add(p.playlistName)
for (p in playlists) {
playlistNames.add(p.name)
}
return MaterialDialog(requireContext()).show {
title(R.string.add_playlist_title)
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
@ -57,18 +52,12 @@ class AddToPlaylistDialog : DialogFragment() {
}
} else {
dialog.dismiss()
/*PlaylistsUtil.addToPlaylist(
PlaylistsUtil.addToPlaylist(
requireContext(),
songs,
playlists[index - 1].id,
true
)*/
GlobalScope.launch(Dispatchers.IO) {
PlaylistDatabaseModel().also {
it.addSongsToPlaylist(songs, names[index - 1])
}
}
)
}
}
}
@ -89,17 +78,5 @@ class AddToPlaylistDialog : DialogFragment() {
dialog.arguments = args
return dialog
}
fun create(
songs: ArrayList<Song>,
names: List<PlaylistEntity>
): AddToPlaylistDialog {
val dialog = AddToPlaylistDialog()
val args = Bundle()
args.putParcelableArrayList("songs", ArrayList(songs))
args.putParcelableArrayList("names", ArrayList(names))
dialog.arguments = args
return dialog
}
}
}

View file

@ -24,10 +24,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.R.layout
import code.name.monkey.retromusic.R.string
import code.name.monkey.retromusic.extensions.appHandleColor
import code.name.monkey.retromusic.fragments.playlists.PlaylistViewModel
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
import code.name.monkey.retromusic.room.playlist.PlaylistEntity
import code.name.monkey.retromusic.util.PlaylistsUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.LayoutMode
@ -60,14 +57,13 @@ class CreatePlaylistDialog : DialogFragment() {
?: return@positiveButton
if (playlistView.text.toString().trim { it <= ' ' }.isNotEmpty()) {
/*val playlistId = PlaylistsUtil.createPlaylist(
val playlistId = PlaylistsUtil.createPlaylist(
requireContext(),
playlistView.text.toString()
)
if (playlistId != -1) {
PlaylistsUtil.addToPlaylist(requireContext(), songs, playlistId, true)
}*/
PlaylistDatabaseModel().savePlaylist(PlaylistEntity(playlistView.text.toString()))
}
}
}
}

View file

@ -26,5 +26,5 @@ enum class NowPlayingScreen constructor(
PLAIN(R.string.plain, R.drawable.np_plain, 3),
SIMPLE(R.string.simple, R.drawable.np_simple, 8),
TINY(R.string.tiny, R.drawable.np_tiny, 7),
EXAMPLE(R.string.tiny, R.drawable.np_tiny, 16),
CLASSIC(R.string.classic, R.drawable.np_tiny, 16),
}

View file

@ -38,13 +38,15 @@ class ColorFragment : AbsPlayerFragment() {
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
color.secondaryTextColor,
requireActivity()
)
colorGradientBackground?.setBackgroundColor(color.backgroundColor)
playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(color.backgroundColor))
}
override fun onFavoriteToggled() {
//toggleFavorite(MusicPlayerRemote.currentSong)
toggleFavorite(MusicPlayerRemote.currentSong)
}
override fun onShow() {
@ -130,10 +132,7 @@ class ColorFragment : AbsPlayerFragment() {
companion object {
fun newInstance(): ColorFragment {
val args = Bundle()
val fragment = ColorFragment()
fragment.arguments = args
return fragment
return ColorFragment()
}
}
}

View file

@ -140,9 +140,9 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_64dp)
playPauseButton.setImageResource(R.drawable.ic_pause_sharp_white_64dp)
} else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_64dp)
playPauseButton.setImageResource(R.drawable.ic_play_arrow_sharp_white_64dp)
}
}
@ -189,18 +189,18 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp)
repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp)
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
MusicService.REPEAT_MODE_THIS -> {
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
repeatButton.setImageResource(R.drawable.ic_repeat_one_sharp_white_24dp)
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
}
}

View file

@ -29,17 +29,12 @@ import code.name.monkey.retromusic.dialogs.SongDetailDialog
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.PaletteColorHolder
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.RingtoneManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
object SongMenuHelper {
val MENU_RES = R.menu.menu_item_song
const val MENU_RES = R.menu.menu_item_song
fun handleMenuClick(activity: FragmentActivity, song: Song, menuItemId: Int): Boolean {
when (menuItemId) {
@ -66,15 +61,8 @@ object SongMenuHelper {
return true
}
R.id.action_add_to_playlist -> {
/* AddToPlaylistDialog.create(song)
.show(activity.supportFragmentManager, "ADD_PLAYLIST")*/
GlobalScope.launch(Dispatchers.IO) {
val names = async { PlaylistDatabaseModel().getPlaylistNames() }.await()
println(names.toString())
AddToPlaylistDialog.create(arrayListOf(song), names)
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
}
AddToPlaylistDialog.create(song)
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
return true
}
R.id.action_play_next -> {

View file

@ -21,11 +21,6 @@ import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.room.playlist.PlaylistDatabaseModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import java.util.*
@ -45,12 +40,8 @@ object SongsMenuHelper {
return true
}
R.id.action_add_to_playlist -> {
GlobalScope.launch(Dispatchers.IO) {
val names = async { PlaylistDatabaseModel().getPlaylistNames() }.await()
println(names.toString())
/*AddToPlaylistDialog.create(songs, names.await())
.show(activity.supportFragmentManager, "ADD_PLAYLIST")*/
}
AddToPlaylistDialog.create(songs)
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
return true
}
R.id.action_delete_from_device -> {

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M6 19h4V5H6v14zm8-14v14h4V5h-4z" />
</vector>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2020 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M8 5v14l11-7L8 5z" />
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z" />
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" />
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm0.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z" />
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/icon_notification_dimen"
android:height="@dimen/icon_notification_dimen"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z" />
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/icon_notification_dimen"
android:height="@dimen/icon_notification_dimen"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/md_white_1000"
android:pathData="M6 6h2v12H6V6zm3.5 6l8.5 6V6l-8.5 6z" />
</vector>

View file

@ -146,7 +146,7 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/repeatButton"
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
app:srcCompat="@drawable/ic_skip_previous_sharp_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
@ -160,7 +160,7 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/previousButton"
app:layout_constraintTop_toBottomOf="@+id/songInfo"
app:srcCompat="@drawable/ic_pause_white_64dp"
app:srcCompat="@drawable/ic_pause_sharp_white_64dp"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
@ -175,7 +175,7 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/playPauseButton"
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
app:srcCompat="@drawable/ic_skip_next_white_24dp"
app:srcCompat="@drawable/ic_skip_next_sharp_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
@ -190,7 +190,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/nextButton"
app:layout_constraintTop_toTopOf="@+id/nextButton"
app:srcCompat="@drawable/ic_shuffle_white_24dp"
app:srcCompat="@drawable/ic_shuffle_sharp_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />