commit
835ec949ba
|
@ -93,7 +93,9 @@ android {
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
|
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
|
||||||
}
|
}
|
||||||
|
androidExtensions {
|
||||||
|
experimental = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +121,7 @@ dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation "androidx.fragment:fragment:$supportLibVersion"
|
implementation "androidx.fragment:fragment:$supportLibVersion"
|
||||||
implementation "androidx.appcompat:appcompat:1.0.2"
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
implementation "androidx.recyclerview:recyclerview:$supportLibVersion"
|
implementation "androidx.recyclerview:recyclerview:$supportLibVersion"
|
||||||
implementation "androidx.gridlayout:gridlayout:$supportLibVersion"
|
implementation "androidx.gridlayout:gridlayout:$supportLibVersion"
|
||||||
implementation "androidx.cardview:cardview:$supportLibVersion"
|
implementation "androidx.cardview:cardview:$supportLibVersion"
|
||||||
|
@ -129,48 +131,39 @@ dependencies {
|
||||||
implementation "androidx.legacy:legacy-support-v13:$supportLibVersion"
|
implementation "androidx.legacy:legacy-support-v13:$supportLibVersion"
|
||||||
implementation "androidx.legacy:legacy-preference-v14:$supportLibVersion"
|
implementation "androidx.legacy:legacy-preference-v14:$supportLibVersion"
|
||||||
implementation "com.google.android.material:material:$supportLibVersion"
|
implementation "com.google.android.material:material:$supportLibVersion"
|
||||||
implementation "androidx.palette:palette-ktx:1.0.0"
|
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||||
|
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||||
implementation "com.squareup.retrofit2:retrofit:2.5.0"
|
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
|
||||||
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
|
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
|
||||||
implementation "com.squareup.retrofit2:adapter-rxjava2:2.5.0"
|
|
||||||
|
|
||||||
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
||||||
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
||||||
implementation 'com.afollestad.material-dialogs:input:2.0.0'
|
implementation 'com.afollestad.material-dialogs:input:2.0.0'
|
||||||
implementation 'com.afollestad.material-dialogs:color:2.0.0'
|
implementation 'com.afollestad.material-dialogs:color:2.0.0'
|
||||||
implementation 'com.afollestad:material-cab:0.1.12'
|
implementation 'com.afollestad:material-cab:0.1.12'
|
||||||
|
|
||||||
implementation 'com.github.bumptech.glide:glide:4.8.0'
|
implementation 'com.github.bumptech.glide:glide:4.8.0'
|
||||||
implementation 'com.github.bumptech.glide:okhttp3-integration:4.8.0'
|
implementation 'com.github.bumptech.glide:okhttp3-integration:4.8.0'
|
||||||
|
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
|
||||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
|
|
||||||
|
|
||||||
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
|
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
implementation 'com.github.ksoichiro:android-observablescrollview:1.6.0'
|
implementation 'com.github.ksoichiro:android-observablescrollview:1.6.0'
|
||||||
implementation 'com.github.kabouzeid:RecyclerView-FastScroll:1.0.16-kmod'
|
implementation 'com.github.kabouzeid:RecyclerView-FastScroll:1.0.16-kmod'
|
||||||
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
|
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
|
||||||
|
|
||||||
/*UI Library*/
|
/*UI Library*/
|
||||||
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
|
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
|
||||||
implementation 'com.r0adkll:slidableactivity:2.0.6'
|
implementation 'com.r0adkll:slidableactivity:2.0.6'
|
||||||
/*Backend all*/
|
/*Backend all*/
|
||||||
implementation project(':appthemehelper')
|
|
||||||
implementation 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.0-kmod3'
|
implementation 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.0-kmod3'
|
||||||
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'
|
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'
|
||||||
implementation 'org.nanohttpd:nanohttpd:2.3.1'
|
implementation 'org.nanohttpd:nanohttpd:2.3.1'
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
|
||||||
implementation 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
|
implementation 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
|
||||||
implementation 'com.github.jetradarmobile:android-snowfall:1.2.0'
|
implementation 'com.github.jetradarmobile:android-snowfall:1.2.0'
|
||||||
implementation 'com.github.takahirom.downloadable.calligraphy:downloadable-calligraphy:0.1.3'
|
implementation 'com.github.takahirom.downloadable.calligraphy:downloadable-calligraphy:0.1.3'
|
||||||
|
|
||||||
kapt 'com.github.bumptech.glide:compiler:4.8.0'
|
kapt 'com.github.bumptech.glide:compiler:4.8.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
implementation project(':appthemehelper')
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -34,7 +34,6 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.ui.activities.MainActivity
|
import code.name.monkey.retromusic.ui.activities.MainActivity
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.bumptech.glide.request.transition.Transition
|
import com.bumptech.glide.request.transition.Transition
|
||||||
|
|
||||||
|
@ -50,9 +49,9 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
|
|
||||||
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
|
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
|
||||||
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art)
|
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art)
|
||||||
appWidgetView.setImageViewBitmap(R.id.button_next, BaseAppWidget.Companion.createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
|
appWidgetView.setImageViewBitmap(R.id.button_next, BaseAppWidget.createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
|
||||||
appWidgetView.setImageViewBitmap(R.id.button_prev, BaseAppWidget.Companion.createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
|
appWidgetView.setImageViewBitmap(R.id.button_prev, BaseAppWidget.createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
|
||||||
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, BaseAppWidget.Companion.createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
|
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, BaseAppWidget.createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
|
||||||
|
|
||||||
linkButtons(context, appWidgetView)
|
linkButtons(context, appWidgetView)
|
||||||
pushUpdate(context, appWidgetIds, appWidgetView)
|
pushUpdate(context, appWidgetIds, appWidgetView)
|
||||||
|
@ -106,7 +105,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||||
super.onLoadFailed( errorDrawable)
|
super.onLoadFailed(errorDrawable)
|
||||||
update(null, MaterialValueHelper.getSecondaryTextColor(appContext, true))
|
update(null, MaterialValueHelper.getSecondaryTextColor(appContext, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,14 @@ import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
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.loaders.PlaylistLoader
|
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.ui.adapter.playlist.AddToPlaylist
|
import code.name.monkey.retromusic.ui.adapter.playlist.AddToPlaylist
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_add_to_playlist.*
|
import kotlinx.android.synthetic.main.dialog_add_to_playlist.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class AddToPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class AddToPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
|
||||||
|
@ -40,15 +41,14 @@ class AddToPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
||||||
|
|
||||||
actionAddPlaylist.setOnClickListener {
|
actionAddPlaylist.setOnClickListener {
|
||||||
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
|
||||||
CreatePlaylistDialog.create(songs!!).show(activity!!.supportFragmentManager, "ADD_TO_PLAYLIST")
|
CreatePlaylistDialog.create(songs!!).show(activity!!.supportFragmentManager, "ADD_TO_PLAYLIST")
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||||
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
|
||||||
val playlists = PlaylistLoader.getAllPlaylists(activity!!).blockingFirst()
|
val playlists = PlaylistLoader.getAllPlaylists(activity!!).blockingFirst()
|
||||||
val playlistAdapter = AddToPlaylist(activity!!, playlists, R.layout.item_playlist, songs!!, dialog)
|
val playlistAdapter = AddToPlaylist(activity!!, playlists, R.layout.item_playlist, songs!!, dialog)
|
||||||
recyclerView.apply {
|
recyclerView.apply {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return@positiveButton
|
return@positiveButton
|
||||||
}
|
}
|
||||||
playlist.clear(activity)
|
playlist.clear(activity!!)
|
||||||
}
|
}
|
||||||
negativeButton { (android.R.string.cancel) }
|
negativeButton { (android.R.string.cancel) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,13 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_playlist.*
|
import kotlinx.android.synthetic.main.dialog_playlist.*
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class CreatePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class CreatePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
@ -41,6 +43,8 @@ class CreatePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val accentColor = ThemeStore.accentColor(Objects.requireNonNull<Context>(context))
|
val accentColor = ThemeStore.accentColor(Objects.requireNonNull<Context>(context))
|
||||||
|
|
||||||
|
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
||||||
|
|
||||||
MaterialUtil.setTint(actionCreate, true)
|
MaterialUtil.setTint(actionCreate, true)
|
||||||
MaterialUtil.setTint(actionCancel, false)
|
MaterialUtil.setTint(actionCancel, false)
|
||||||
MaterialUtil.setTint(actionNewPlaylistContainer, true)
|
MaterialUtil.setTint(actionNewPlaylistContainer, true)
|
||||||
|
@ -59,8 +63,6 @@ class CreatePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
val playlistId = PlaylistsUtil
|
val playlistId = PlaylistsUtil
|
||||||
.createPlaylist(activity!!, actionNewPlaylist!!.text!!.toString())
|
.createPlaylist(activity!!, actionNewPlaylist!!.text!!.toString())
|
||||||
if (playlistId != -1 && activity != null) {
|
if (playlistId != -1 && activity != null) {
|
||||||
|
|
||||||
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
|
||||||
if (songs != null) {
|
if (songs != null) {
|
||||||
PlaylistsUtil.addToPlaylist(activity!!, songs, playlistId, true)
|
PlaylistsUtil.addToPlaylist(activity!!, songs, playlistId, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,12 @@ import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_delete.*
|
import kotlinx.android.synthetic.main.dialog_delete.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class DeleteSongsDialog : RoundedBottomSheetDialogFragment() {
|
class DeleteSongsDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class DeleteSongsDialog : RoundedBottomSheetDialogFragment() {
|
||||||
val content: CharSequence
|
val content: CharSequence
|
||||||
if (songs != null) {
|
if (songs != null) {
|
||||||
content = if (songs.size > 1) {
|
content = if (songs.size > 1) {
|
||||||
getString(R.string.delete_x_songs, songs.size)
|
getString(R.string.delete_x_songs, songs.size)
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.delete_song_x, songs[0].title)
|
getString(R.string.delete_song_x, songs[0].title)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@ import android.view.ViewGroup
|
||||||
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.model.PlaylistSong
|
import code.name.monkey.retromusic.model.PlaylistSong
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_remove_from_playlist.*
|
import kotlinx.android.synthetic.main.dialog_remove_from_playlist.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val songs = arguments!!.getParcelableArrayList<PlaylistSong>("songs")
|
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
||||||
val title: Int
|
val title: Int
|
||||||
val content: CharSequence
|
val content: CharSequence
|
||||||
if (songs!!.size > 1) {
|
if (songs!!.size > 1) {
|
||||||
|
@ -56,7 +56,7 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
text = content
|
text = content
|
||||||
setTextColor(ThemeStore.textColorSecondary(context))
|
setTextColor(ThemeStore.textColorSecondary(context))
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs)
|
PlaylistsUtil.removeFromPlaylist(activity!!, songs as ArrayList<PlaylistSong>)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@ import kotlinx.android.synthetic.main.dialog_playlist.*
|
||||||
|
|
||||||
class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
savedInstanceState: Bundle?): View? {
|
|
||||||
|
|
||||||
return inflater.inflate(R.layout.dialog_playlist, container, false)
|
return inflater.inflate(R.layout.dialog_playlist, container, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
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.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
@ -132,7 +133,7 @@ class SongDetailDialog : RoundedBottomSheetDialogFragment() {
|
||||||
private fun getFileSizeString(sizeInBytes: Long): String {
|
private fun getFileSizeString(sizeInBytes: Long): String {
|
||||||
val fileSizeInKB = sizeInBytes / 1024
|
val fileSizeInKB = sizeInBytes / 1024
|
||||||
val fileSizeInMB = fileSizeInKB / 1024
|
val fileSizeInMB = fileSizeInKB / 1024
|
||||||
return fileSizeInMB.toString() + " MB"
|
return "$fileSizeInMB MB"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,14 @@ import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_file_share.*
|
import kotlinx.android.synthetic.main.dialog_file_share.*
|
||||||
|
|
||||||
|
|
||||||
class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_file_share, container, false)
|
return inflater.inflate(R.layout.dialog_file_share, container, false)
|
||||||
|
@ -37,7 +39,7 @@ class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
||||||
@SuppressLint("StringFormatInvalid")
|
@SuppressLint("StringFormatInvalid")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val song = arguments!!.getParcelable<Song>("song")!!
|
val song = arguments!!.getParcelable<Song>("song")
|
||||||
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||||
|
|
||||||
audioText.apply {
|
audioText.apply {
|
||||||
|
@ -57,7 +59,7 @@ class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
||||||
audioFile.apply {
|
audioFile.apply {
|
||||||
setTextColor(ThemeStore.textColorSecondary(context!!))
|
setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
activity!!.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, activity), null))
|
activity!!.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, context), null))
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_share_white_24dp)
|
icon = ContextCompat.getDrawable(context, R.drawable.ic_share_white_24dp)
|
||||||
|
|
|
@ -70,23 +70,28 @@ public final class RetroGlideExtension {
|
||||||
.signature(createSignature(song));
|
.signature(createSignature(song));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Key createSignature(Artist artist) {
|
@NonNull
|
||||||
|
public static Key createSignature(@NonNull Artist artist) {
|
||||||
return ArtistSignatureUtil.getInstance().getArtistSignature(artist.getName());
|
return ArtistSignatureUtil.getInstance().getArtistSignature(artist.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Key createSignature(Song song) {
|
@NonNull
|
||||||
return new MediaStoreSignature("", song.dateModified, 0);
|
public static Key createSignature(@NonNull Song song) {
|
||||||
|
return new MediaStoreSignature("", song.getDateModified(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getArtistModel(Artist artist) {
|
@NonNull
|
||||||
|
public static Object getArtistModel(@NonNull Artist artist) {
|
||||||
return getArtistModel(artist, CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext()).hasCustomArtistImage(artist), false);
|
return getArtistModel(artist, CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext()).hasCustomArtistImage(artist), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getArtistModel(Artist artist, boolean forceDownload) {
|
@NonNull
|
||||||
|
public static Object getArtistModel(@NonNull Artist artist, boolean forceDownload) {
|
||||||
return getArtistModel(artist, CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext()).hasCustomArtistImage(artist), forceDownload);
|
return getArtistModel(artist, CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext()).hasCustomArtistImage(artist), forceDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getArtistModel(Artist artist, boolean hasCustomImage, boolean forceDownload) {
|
@NonNull
|
||||||
|
public static Object getArtistModel(@NonNull Artist artist, boolean hasCustomImage, boolean forceDownload) {
|
||||||
if (!hasCustomImage) {
|
if (!hasCustomImage) {
|
||||||
return new ArtistImage(artist.getName(), forceDownload);
|
return new ArtistImage(artist.getName(), forceDownload);
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,18 +99,21 @@ public final class RetroGlideExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getSongModel(Song song) {
|
@NonNull
|
||||||
|
public static Object getSongModel(@NonNull Song song) {
|
||||||
return getSongModel(song, PreferenceUtil.getInstance().ignoreMediaStoreArtwork());
|
return getSongModel(song, PreferenceUtil.getInstance().ignoreMediaStoreArtwork());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getSongModel(Song song, boolean ignoreMediaStore) {
|
@NonNull
|
||||||
|
public static Object getSongModel(@NonNull Song song, boolean ignoreMediaStore) {
|
||||||
if (ignoreMediaStore) {
|
if (ignoreMediaStore) {
|
||||||
return new AudioFileCover(song.data);
|
return new AudioFileCover(song.getData());
|
||||||
} else {
|
} else {
|
||||||
return MusicUtil.getMediaStoreAlbumCoverUri(song.albumId);
|
return MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public static <TranscodeType> GenericTransitionOptions<TranscodeType> getDefaultTransition() {
|
public static <TranscodeType> GenericTransitionOptions<TranscodeType> getDefaultTransition() {
|
||||||
return new GenericTransitionOptions<TranscodeType>().transition(android.R.anim.fade_in);
|
return new GenericTransitionOptions<TranscodeType>().transition(android.R.anim.fade_in);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,19 +15,17 @@
|
||||||
package code.name.monkey.retromusic.helper
|
package code.name.monkey.retromusic.helper
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
|
||||||
import java.io.BufferedWriter
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileWriter
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.model.Playlist
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.ObservableEmitter
|
import io.reactivex.ObservableEmitter
|
||||||
|
import java.io.BufferedWriter
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileWriter
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class M3UWriter : M3UConstants {
|
class M3UWriter : M3UConstants {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.provider.DocumentsContract
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.loaders.SongLoader
|
import code.name.monkey.retromusic.loaders.SongLoader
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
@ -47,7 +48,7 @@ object MusicPlayerRemote {
|
||||||
val currentSong: Song
|
val currentSong: Song
|
||||||
get() = if (musicService != null) {
|
get() = if (musicService != null) {
|
||||||
musicService!!.currentSong
|
musicService!!.currentSong
|
||||||
} else Song.EMPTY_SONG
|
} else Song.emptySong
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Async
|
* Async
|
||||||
|
|
|
@ -24,10 +24,10 @@ import java.util.*
|
||||||
|
|
||||||
|
|
||||||
object SearchQueryHelper {
|
object SearchQueryHelper {
|
||||||
private val TITLE_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.TITLE + ") = ?"
|
private const val TITLE_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.TITLE + ") = ?"
|
||||||
private val ALBUM_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ALBUM + ") = ?"
|
private const val ALBUM_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ALBUM + ") = ?"
|
||||||
private val ARTIST_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ARTIST + ") = ?"
|
private const val ARTIST_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ARTIST + ") = ?"
|
||||||
private val AND = " AND "
|
private const val AND = " AND "
|
||||||
var songs = ArrayList<Song>()
|
var songs = ArrayList<Song>()
|
||||||
|
|
||||||
fun getSongs(context: Context, extras: Bundle): ArrayList<Song> {
|
fun getSongs(context: Context, extras: Bundle): ArrayList<Song> {
|
||||||
|
|
|
@ -17,6 +17,7 @@ package code.name.monkey.retromusic.helper.menu
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
|
|
@ -20,6 +20,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.view.View
|
||||||
import android.widget.PopupMenu
|
import android.widget.PopupMenu
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package code.name.monkey.retromusic.helper.menu
|
package code.name.monkey.retromusic.helper.menu
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||||
|
|
|
@ -18,10 +18,8 @@ import android.content.Context
|
||||||
import android.provider.MediaStore.Audio.AudioColumns
|
import android.provider.MediaStore.Audio.AudioColumns
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.model.Song
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import java.util.*
|
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
object ArtistLoader {
|
object ArtistLoader {
|
||||||
|
|
|
@ -17,15 +17,13 @@ package code.name.monkey.retromusic.loaders
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.annotations.NonNull
|
import io.reactivex.annotations.NonNull
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 16/08/17.
|
* Created by hemanths on 16/08/17.
|
||||||
|
|
|
@ -64,7 +64,7 @@ object PlaylistSongsLoader {
|
||||||
val year = cursor.getInt(3)
|
val year = cursor.getInt(3)
|
||||||
val duration = cursor.getLong(4)
|
val duration = cursor.getLong(4)
|
||||||
val data = cursor.getString(5)
|
val data = cursor.getString(5)
|
||||||
val dateModified = cursor.getInt(6)
|
val dateModified = cursor.getLong(6)
|
||||||
val albumId = cursor.getInt(7)
|
val albumId = cursor.getInt(7)
|
||||||
val albumName = cursor.getString(8)
|
val albumName = cursor.getString(8)
|
||||||
val artistId = cursor.getInt(9)
|
val artistId = cursor.getInt(9)
|
||||||
|
|
|
@ -134,7 +134,7 @@ object SongLoader {
|
||||||
val song: Song = if (cursor != null && cursor.moveToFirst()) {
|
val song: Song = if (cursor != null && cursor.moveToFirst()) {
|
||||||
getSongFromCursorImpl(cursor)
|
getSongFromCursorImpl(cursor)
|
||||||
} else {
|
} else {
|
||||||
Song.EMPTY_SONG
|
Song.emptySong
|
||||||
}
|
}
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
e.onNext(song)
|
e.onNext(song)
|
||||||
|
|
|
@ -15,27 +15,20 @@
|
||||||
package code.name.monkey.retromusic.model;
|
package code.name.monkey.retromusic.model;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
|
import kotlinx.android.parcel.Parcelize;
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
public abstract class AbsCustomPlaylist extends Playlist {
|
public abstract class AbsCustomPlaylist extends Playlist {
|
||||||
public AbsCustomPlaylist(int id, String name) {
|
public AbsCustomPlaylist(int id, @NonNull String name) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbsCustomPlaylist() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbsCustomPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public abstract Observable<ArrayList<Song>> getSongs(Context context);
|
public abstract Observable<ArrayList<Song>> getSongs(@NonNull Context context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,6 @@ class Album {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun safeGetFirstSong(): Song {
|
fun safeGetFirstSong(): Song {
|
||||||
return if (songs!!.isEmpty()) Song.EMPTY_SONG else songs[0]
|
return if (songs!!.isEmpty()) Song.emptySong else songs[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Hemanth S (h4h13).
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Genre implements Parcelable {
|
|
||||||
|
|
||||||
public static final Creator<Genre> CREATOR = new Creator<Genre>() {
|
|
||||||
@Override
|
|
||||||
public Genre createFromParcel(Parcel in) {
|
|
||||||
return new Genre(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Genre[] newArray(int size) {
|
|
||||||
return new Genre[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public final int id;
|
|
||||||
public final String name;
|
|
||||||
public final int songCount;
|
|
||||||
|
|
||||||
public Genre(final int id, final String name, int songCount) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.songCount = songCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// For unknown genre
|
|
||||||
public Genre(final String name, final int songCount) {
|
|
||||||
this.id = -1;
|
|
||||||
this.name = name;
|
|
||||||
this.songCount = songCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Genre(Parcel in) {
|
|
||||||
id = in.readInt();
|
|
||||||
name = in.readString();
|
|
||||||
songCount = in.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeInt(id);
|
|
||||||
dest.writeString(name);
|
|
||||||
dest.writeInt(songCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
Genre genre = (Genre) o;
|
|
||||||
|
|
||||||
if (id != genre.id) return false;
|
|
||||||
return name != null ? name.equals(genre.name) : genre.name == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = id;
|
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Genre{" +
|
|
||||||
"id=" + id +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hemanth S (h4h13).
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
class Genre(val id: Int = -1, val name: String, val songCount: Int) : Parcelable
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
|
||||||
import androidx.annotation.StringRes;
|
|
||||||
import code.name.monkey.retromusic.ui.adapter.HomeAdapter.Companion.HomeSection;
|
|
||||||
|
|
||||||
public class Home {
|
|
||||||
@StringRes
|
|
||||||
int title;
|
|
||||||
@StringRes
|
|
||||||
int subtitle;
|
|
||||||
@HomeSection
|
|
||||||
int homeSection;
|
|
||||||
@DrawableRes
|
|
||||||
int icon;
|
|
||||||
|
|
||||||
ArrayList arrayList;
|
|
||||||
|
|
||||||
public Home(int title, int subtitle, ArrayList arrayList, @HomeSection int homeSection, @DrawableRes int icon) {
|
|
||||||
this.title = title;
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
this.arrayList = arrayList;
|
|
||||||
this.homeSection = homeSection;
|
|
||||||
this.icon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@HomeSection
|
|
||||||
public int getHomeSection() {
|
|
||||||
return homeSection;
|
|
||||||
}
|
|
||||||
|
|
||||||
@StringRes
|
|
||||||
public int getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@StringRes
|
|
||||||
public int getSubtitle() {
|
|
||||||
return subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getArrayList() {
|
|
||||||
return arrayList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DrawableRes
|
|
||||||
public int getIcon() {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import code.name.monkey.retromusic.ui.adapter.HomeAdapter.Companion.HomeSection
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by hemanths on 3/4/19
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Home(@StringRes val title: Int,
|
||||||
|
@StringRes val subTitle: Int,
|
||||||
|
val arrayList: ArrayList<*>,
|
||||||
|
@HomeSection
|
||||||
|
val homeSection: Int,
|
||||||
|
@DrawableRes
|
||||||
|
val icon: Int)
|
|
@ -1,86 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
|
|
||||||
public class Playlist implements Parcelable {
|
|
||||||
public static final Creator<Playlist> CREATOR = new Creator<Playlist>() {
|
|
||||||
public Playlist createFromParcel(Parcel source) {
|
|
||||||
return new Playlist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Playlist[] newArray(int size) {
|
|
||||||
return new Playlist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public final int id;
|
|
||||||
public final String name;
|
|
||||||
|
|
||||||
public Playlist(final int id, final String name) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Playlist() {
|
|
||||||
this.id = -1;
|
|
||||||
this.name = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Playlist(Parcel in) {
|
|
||||||
this.id = in.readInt();
|
|
||||||
this.name = in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
Playlist playlist = (Playlist) o;
|
|
||||||
|
|
||||||
if (id != playlist.id) return false;
|
|
||||||
return name != null ? name.equals(playlist.name) : playlist.name == null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = id;
|
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Playlist{" +
|
|
||||||
"id=" + id +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeInt(this.id);
|
|
||||||
dest.writeString(this.name);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
open class Playlist(val id: Int = -1, val name: String = "") : Parcelable
|
|
@ -14,72 +14,42 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model;
|
package code.name.monkey.retromusic.model;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import kotlinx.android.parcel.Parcelize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by hemanths on 3/4/19
|
||||||
|
*/
|
||||||
|
@Parcelize
|
||||||
public class PlaylistSong extends Song {
|
public class PlaylistSong extends Song {
|
||||||
public static final Creator<PlaylistSong> CREATOR = new Creator<PlaylistSong>() {
|
final int playlistId;
|
||||||
public PlaylistSong createFromParcel(Parcel source) {
|
final int idInPlayList;
|
||||||
return new PlaylistSong(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaylistSong[] newArray(int size) {
|
public PlaylistSong(int id,
|
||||||
return new PlaylistSong[size];
|
@NotNull String title,
|
||||||
}
|
int trackNumber,
|
||||||
};
|
int year,
|
||||||
public final int playlistId;
|
long duration,
|
||||||
public final int idInPlayList;
|
@NotNull String data,
|
||||||
|
long dateModified,
|
||||||
public PlaylistSong(int id, String title, int trackNumber, int year, long duration, String data, int dateModified, int albumId, String albumName, int artistId, String artistName, final int playlistId, final int idInPlayList, String composer) {
|
int albumId,
|
||||||
|
@NotNull String albumName,
|
||||||
|
int artistId,
|
||||||
|
@NotNull String artistName,
|
||||||
|
int playlistId,
|
||||||
|
int idInPlayList,
|
||||||
|
@NotNull String composer) {
|
||||||
super(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, composer);
|
super(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, composer);
|
||||||
this.playlistId = playlistId;
|
this.playlistId = playlistId;
|
||||||
this.idInPlayList = idInPlayList;
|
this.idInPlayList = idInPlayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PlaylistSong(Parcel in) {
|
public int getPlaylistId() {
|
||||||
super(in);
|
return playlistId;
|
||||||
this.playlistId = in.readInt();
|
|
||||||
this.idInPlayList = in.readInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getIdInPlayList() {
|
||||||
public boolean equals(Object o) {
|
return idInPlayList;
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
|
|
||||||
PlaylistSong that = (PlaylistSong) o;
|
|
||||||
|
|
||||||
if (playlistId != that.playlistId) return false;
|
|
||||||
return idInPlayList == that.idInPlayList;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = super.hashCode();
|
|
||||||
result = 31 * result + playlistId;
|
|
||||||
result = 31 * result + idInPlayList;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return super.toString() +
|
|
||||||
"PlaylistSong{" +
|
|
||||||
"playlistId=" + playlistId +
|
|
||||||
", idInPlayList=" + idInPlayList +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
dest.writeInt(this.playlistId);
|
|
||||||
dest.writeInt(this.idInPlayList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
|
||||||
*/
|
|
||||||
public class Song implements Parcelable {
|
|
||||||
public static final Song EMPTY_SONG = new Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", "");
|
|
||||||
public static final Creator<Song> CREATOR = new Creator<Song>() {
|
|
||||||
public Song createFromParcel(Parcel source) {
|
|
||||||
return new Song(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Song[] newArray(int size) {
|
|
||||||
return new Song[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public final int id;
|
|
||||||
public final String title;
|
|
||||||
public final int trackNumber;
|
|
||||||
public final int year;
|
|
||||||
public final long duration;
|
|
||||||
public final String data;
|
|
||||||
public final long dateModified;
|
|
||||||
public final int albumId;
|
|
||||||
public final String albumName;
|
|
||||||
public final int artistId;
|
|
||||||
public final String artistName;
|
|
||||||
public final String composer;
|
|
||||||
|
|
||||||
public Song(int id, String title, int trackNumber, int year, long duration, String data, long dateModified, int albumId, String albumName, int artistId, String artistName, String composer) {
|
|
||||||
this.id = id;
|
|
||||||
this.title = title;
|
|
||||||
this.trackNumber = trackNumber;
|
|
||||||
this.year = year;
|
|
||||||
this.duration = duration;
|
|
||||||
this.data = data;
|
|
||||||
this.dateModified = dateModified;
|
|
||||||
this.albumId = albumId;
|
|
||||||
this.albumName = albumName;
|
|
||||||
this.artistId = artistId;
|
|
||||||
this.artistName = artistName;
|
|
||||||
this.composer = composer;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Song(Parcel in) {
|
|
||||||
this.id = in.readInt();
|
|
||||||
this.title = in.readString();
|
|
||||||
this.trackNumber = in.readInt();
|
|
||||||
this.year = in.readInt();
|
|
||||||
this.duration = in.readLong();
|
|
||||||
this.data = in.readString();
|
|
||||||
this.dateModified = in.readLong();
|
|
||||||
this.albumId = in.readInt();
|
|
||||||
this.albumName = in.readString();
|
|
||||||
this.artistId = in.readInt();
|
|
||||||
this.artistName = in.readString();
|
|
||||||
this.composer = in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeInt(this.id);
|
|
||||||
dest.writeString(this.title);
|
|
||||||
dest.writeInt(this.trackNumber);
|
|
||||||
dest.writeInt(this.year);
|
|
||||||
dest.writeLong(this.duration);
|
|
||||||
dest.writeString(this.data);
|
|
||||||
dest.writeLong(this.dateModified);
|
|
||||||
dest.writeInt(this.albumId);
|
|
||||||
dest.writeString(this.albumName);
|
|
||||||
dest.writeInt(this.artistId);
|
|
||||||
dest.writeString(this.artistName);
|
|
||||||
dest.writeString(this.composer);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package code.name.monkey.retromusic.model
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
|
*/
|
||||||
|
@Parcelize
|
||||||
|
open class Song(val id: Int, val title: String, val trackNumber: Int, val year: Int, val duration: Long, val data: String, val dateModified: Long, val albumId: Int, val albumName: String, val artistId: Int, val artistName: String, val composer: String?) : Parcelable {
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
val emptySong = Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", "")
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,27 +15,29 @@
|
||||||
package code.name.monkey.retromusic.model.lyrics;
|
package code.name.monkey.retromusic.model.lyrics;
|
||||||
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import code.name.monkey.retromusic.model.Song;
|
||||||
|
|
||||||
|
|
||||||
public class Lyrics {
|
public class Lyrics {
|
||||||
private static final ArrayList<Class<? extends Lyrics>> FORMATS = new ArrayList<>();
|
private static final ArrayList<Class<? extends Lyrics>> FORMATS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Lyrics.FORMATS.add(SynchronizedLyricsLRC.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Song song;
|
public Song song;
|
||||||
|
@NonNull
|
||||||
public String data;
|
public String data;
|
||||||
|
|
||||||
protected boolean parsed = false;
|
protected boolean parsed = false;
|
||||||
protected boolean valid = false;
|
protected boolean valid = false;
|
||||||
|
|
||||||
public Lyrics setData(Song song, String data) {
|
@NonNull
|
||||||
this.song = song;
|
public static Lyrics parse(@NonNull Song song, @NonNull String data) {
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Lyrics parse(Song song, String data) {
|
|
||||||
for (Class<? extends Lyrics> format : Lyrics.FORMATS) {
|
for (Class<? extends Lyrics> format : Lyrics.FORMATS) {
|
||||||
try {
|
try {
|
||||||
Lyrics lyrics = format.newInstance().setData(song, data);
|
Lyrics lyrics = format.newInstance().setData(song, data);
|
||||||
|
@ -47,7 +49,7 @@ public class Lyrics {
|
||||||
return new Lyrics().setData(song, data).parse(false);
|
return new Lyrics().setData(song, data).parse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSynchronized(String data) {
|
public static boolean isSynchronized(@NonNull String data) {
|
||||||
for (Class<? extends Lyrics> format : Lyrics.FORMATS) {
|
for (Class<? extends Lyrics> format : Lyrics.FORMATS) {
|
||||||
try {
|
try {
|
||||||
Lyrics lyrics = format.newInstance().setData(null, data);
|
Lyrics lyrics = format.newInstance().setData(null, data);
|
||||||
|
@ -59,6 +61,13 @@ public class Lyrics {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Lyrics setData(@NonNull Song song, @NonNull String data) {
|
||||||
|
this.song = song;
|
||||||
|
this.data = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Lyrics parse(boolean check) {
|
public Lyrics parse(boolean check) {
|
||||||
this.valid = true;
|
this.valid = true;
|
||||||
this.parsed = true;
|
this.parsed = true;
|
||||||
|
@ -74,11 +83,8 @@ public class Lyrics {
|
||||||
return this.valid;
|
return this.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return this.data.trim().replaceAll("(\r?\n){3,}", "\r\n\r\n");
|
return this.data.trim().replaceAll("(\r?\n){3,}", "\r\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
|
||||||
Lyrics.FORMATS.add(SynchronizedLyricsLRC.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,63 +15,22 @@
|
||||||
package code.name.monkey.retromusic.model.smartplaylist;
|
package code.name.monkey.retromusic.model.smartplaylist;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Parcel;
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist;
|
import code.name.monkey.retromusic.model.AbsCustomPlaylist;
|
||||||
|
import kotlinx.android.parcel.Parcelize;
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
public abstract class AbsSmartPlaylist extends AbsCustomPlaylist {
|
public abstract class AbsSmartPlaylist extends AbsCustomPlaylist {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
public final int iconRes;
|
public final int iconRes;
|
||||||
|
|
||||||
public AbsSmartPlaylist(final String name, final int iconRes) {
|
public AbsSmartPlaylist(final @NonNull String name, final int iconRes) {
|
||||||
super(-Math.abs(31 * name.hashCode() + (iconRes * name.hashCode() * 31 * 31)), name);
|
super(-Math.abs(31 * name.hashCode() + (iconRes * name.hashCode() * 31 * 31)), name);
|
||||||
this.iconRes = iconRes;
|
this.iconRes = iconRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbsSmartPlaylist() {
|
public abstract void clear(@NonNull Context context);
|
||||||
super();
|
|
||||||
this.iconRes = R.drawable.ic_playlist_play_white_24dp;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected AbsSmartPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
this.iconRes = in.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void clear(Context context);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + iconRes;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable final Object obj) {
|
|
||||||
if (super.equals(obj)) {
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final AbsSmartPlaylist other = (AbsSmartPlaylist) obj;
|
|
||||||
return iconRes == other.iconRes;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
dest.writeInt(this.iconRes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model.smartplaylist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
|
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
import code.name.monkey.retromusic.providers.HistoryStore;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
|
|
||||||
|
|
||||||
public class HistoryPlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<HistoryPlaylist> CREATOR = new Parcelable.Creator<HistoryPlaylist>() {
|
|
||||||
public HistoryPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new HistoryPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HistoryPlaylist[] newArray(int size) {
|
|
||||||
return new HistoryPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public HistoryPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HistoryPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
|
||||||
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getRecentlyPlayedTracks(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
HistoryStore.getInstance(context).clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model.smartplaylist
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.providers.HistoryStore
|
||||||
|
import io.reactivex.Observable
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
|
class HistoryPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp) {
|
||||||
|
|
||||||
|
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||||
|
return TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clear(context: Context) {
|
||||||
|
HistoryStore.getInstance(context).clear()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model.smartplaylist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.loaders.LastAddedSongsLoader;
|
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
|
|
||||||
|
|
||||||
public class LastAddedPlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<LastAddedPlaylist> CREATOR = new Parcelable.Creator<LastAddedPlaylist>() {
|
|
||||||
public LastAddedPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new LastAddedPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LastAddedPlaylist[] newArray(int size) {
|
|
||||||
return new LastAddedPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public LastAddedPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LastAddedPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
|
||||||
return LastAddedSongsLoader.INSTANCE.getLastAddedSongs(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model.smartplaylist
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.loaders.LastAddedSongsLoader
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import io.reactivex.Observable
|
||||||
|
|
||||||
|
class LastAddedPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp) {
|
||||||
|
|
||||||
|
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||||
|
return LastAddedSongsLoader.getLastAddedSongs(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clear(context: Context) {}
|
||||||
|
}
|
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model.smartplaylist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
|
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
import code.name.monkey.retromusic.providers.SongPlayCountStore;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
|
|
||||||
|
|
||||||
public class MyTopTracksPlaylist extends AbsSmartPlaylist implements Parcelable {
|
|
||||||
public static final Creator<MyTopTracksPlaylist> CREATOR = new Creator<MyTopTracksPlaylist>() {
|
|
||||||
public MyTopTracksPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new MyTopTracksPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyTopTracksPlaylist[] newArray(int size) {
|
|
||||||
return new MyTopTracksPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public MyTopTracksPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MyTopTracksPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
|
||||||
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getTopTracks(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
SongPlayCountStore.getInstance(context).clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model.smartplaylist
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.providers.SongPlayCountStore
|
||||||
|
import io.reactivex.Observable
|
||||||
|
|
||||||
|
|
||||||
|
class MyTopTracksPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp) {
|
||||||
|
|
||||||
|
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||||
|
return TopAndRecentlyPlayedTracksLoader.getTopTracks(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clear(context: Context) {
|
||||||
|
SongPlayCountStore.getInstance(context).clear()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model.smartplaylist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.loaders.SongLoader;
|
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
|
|
||||||
public class ShuffleAllPlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<ShuffleAllPlaylist> CREATOR = new Parcelable.Creator<ShuffleAllPlaylist>() {
|
|
||||||
public ShuffleAllPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new ShuffleAllPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShuffleAllPlaylist[] newArray(int size) {
|
|
||||||
return new ShuffleAllPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public ShuffleAllPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ShuffleAllPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
|
||||||
return SongLoader.INSTANCE.getAllSongs(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
// Shuffle all is not a real "Smart Playlist"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package code.name.monkey.retromusic.model.smartplaylist
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.loaders.SongLoader
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import io.reactivex.Observable
|
||||||
|
|
||||||
|
class ShuffleAllPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp) {
|
||||||
|
|
||||||
|
|
||||||
|
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||||
|
return SongLoader.getAllSongs(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clear(context: Context) {
|
||||||
|
// Shuffle all is not a real "Smart Playlist"
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,10 +24,10 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.loaders.SongLoader;
|
import code.name.monkey.retromusic.loaders.SongLoader;
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import code.name.monkey.retromusic.model.Song;
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
|
||||||
public static final String DATABASE_NAME = "music_playback_state.db";
|
public static final String DATABASE_NAME = "music_playback_state.db";
|
||||||
public static final String PLAYING_QUEUE_TABLE_NAME = "playing_queue";
|
public static final String PLAYING_QUEUE_TABLE_NAME = "playing_queue";
|
||||||
public static final String ORIGINAL_PLAYING_QUEUE_TABLE_NAME = "original_playing_queue";
|
public static final String ORIGINAL_PLAYING_QUEUE_TABLE_NAME = "original_playing_queue";
|
||||||
private static final int VERSION = 7;
|
private static final int VERSION = 10;
|
||||||
@Nullable
|
@Nullable
|
||||||
private static MusicPlaybackQueueStore sInstance = null;
|
private static MusicPlaybackQueueStore sInstance = null;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
|
||||||
builder.append(" STRING NOT NULL,");
|
builder.append(" STRING NOT NULL,");
|
||||||
|
|
||||||
builder.append(AudioColumns.COMPOSER);
|
builder.append(AudioColumns.COMPOSER);
|
||||||
builder.append(" STRING NOT NULL);");
|
builder.append(" STRING);");
|
||||||
|
|
||||||
db.execSQL(builder.toString());
|
db.execSQL(builder.toString());
|
||||||
}
|
}
|
||||||
|
@ -163,18 +163,18 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
|
||||||
Song song = queue.get(i);
|
Song song = queue.get(i);
|
||||||
ContentValues values = new ContentValues(4);
|
ContentValues values = new ContentValues(4);
|
||||||
|
|
||||||
values.put(BaseColumns._ID, song.id);
|
values.put(BaseColumns._ID, song.getId());
|
||||||
values.put(AudioColumns.TITLE, song.title);
|
values.put(AudioColumns.TITLE, song.getTitle());
|
||||||
values.put(AudioColumns.TRACK, song.trackNumber);
|
values.put(AudioColumns.TRACK, song.getTrackNumber());
|
||||||
values.put(AudioColumns.YEAR, song.year);
|
values.put(AudioColumns.YEAR, song.getYear());
|
||||||
values.put(AudioColumns.DURATION, song.duration);
|
values.put(AudioColumns.DURATION, song.getDuration());
|
||||||
values.put(AudioColumns.DATA, song.data);
|
values.put(AudioColumns.DATA, song.getData());
|
||||||
values.put(AudioColumns.DATE_MODIFIED, song.dateModified);
|
values.put(AudioColumns.DATE_MODIFIED, song.getDateModified());
|
||||||
values.put(AudioColumns.ALBUM_ID, song.albumId);
|
values.put(AudioColumns.ALBUM_ID, song.getAlbumId());
|
||||||
values.put(AudioColumns.ALBUM, song.albumName);
|
values.put(AudioColumns.ALBUM, song.getAlbumName());
|
||||||
values.put(AudioColumns.ARTIST_ID, song.artistId);
|
values.put(AudioColumns.ARTIST_ID, song.getArtistId());
|
||||||
values.put(AudioColumns.ARTIST, song.artistName);
|
values.put(AudioColumns.ARTIST, song.getArtistName());
|
||||||
values.put(AudioColumns.COMPOSER, song.composer);
|
values.put(AudioColumns.COMPOSER, song.getComposer());
|
||||||
|
|
||||||
database.insert(tableName, null, values);
|
database.insert(tableName, null, values);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.bumptech.glide.request.target.SimpleTarget;
|
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
@ -262,7 +261,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
};
|
};
|
||||||
|
|
||||||
private static String getTrackUri(@NonNull Song song) {
|
private static String getTrackUri(@NonNull Song song) {
|
||||||
return MusicUtil.getSongFileUri(song.id).toString();
|
return MusicUtil.getSongFileUri(song.getId()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Bitmap copy(Bitmap bitmap) {
|
private static Bitmap copy(Bitmap bitmap) {
|
||||||
|
@ -423,7 +422,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
playlistSongs = ((AbsCustomPlaylist) playlist).getSongs(getApplicationContext()).blockingFirst();
|
playlistSongs = ((AbsCustomPlaylist) playlist).getSongs(getApplicationContext()).blockingFirst();
|
||||||
} else {
|
} else {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(getApplicationContext(), playlist.id).blockingFirst();
|
playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(getApplicationContext(), playlist.getId()).blockingFirst();
|
||||||
}
|
}
|
||||||
if (!playlistSongs.isEmpty()) {
|
if (!playlistSongs.isEmpty()) {
|
||||||
if (shuffleMode == SHUFFLE_MODE_SHUFFLE) {
|
if (shuffleMode == SHUFFLE_MODE_SHUFFLE) {
|
||||||
|
@ -663,7 +662,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNotification() {
|
public void updateNotification() {
|
||||||
if (playingNotification != null && getCurrentSong().id != -1) {
|
if (playingNotification != null && getCurrentSong().getId() != -1) {
|
||||||
playingNotification.update();
|
playingNotification.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,19 +679,19 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
private void updateMediaSessionMetaData() {
|
private void updateMediaSessionMetaData() {
|
||||||
final Song song = getCurrentSong();
|
final Song song = getCurrentSong();
|
||||||
|
|
||||||
if (song.id == -1) {
|
if (song.getId() == -1) {
|
||||||
mediaSession.setMetadata(null);
|
mediaSession.setMetadata(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder()
|
final MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder()
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.artistName)
|
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.getArtistName())
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.artistName)
|
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.getArtistName())
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.albumName)
|
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.getAlbumName())
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.title)
|
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.getTitle())
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration)
|
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.getDuration())
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getPosition() + 1)
|
.putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getPosition() + 1)
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.year)
|
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.getYear())
|
||||||
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
|
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
@ -744,7 +743,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
if (position >= 0 && position < getPlayingQueue().size()) {
|
if (position >= 0 && position < getPlayingQueue().size()) {
|
||||||
return getPlayingQueue().get(position);
|
return getPlayingQueue().get(position);
|
||||||
} else {
|
} else {
|
||||||
return Song.EMPTY_SONG;
|
return Song.Companion.getEmptySong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,13 +860,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
|
|
||||||
public void removeSong(@NonNull Song song) {
|
public void removeSong(@NonNull Song song) {
|
||||||
for (int i = 0; i < playingQueue.size(); i++) {
|
for (int i = 0; i < playingQueue.size(); i++) {
|
||||||
if (playingQueue.get(i).id == song.id) {
|
if (playingQueue.get(i).getId() == song.getId()) {
|
||||||
playingQueue.remove(i);
|
playingQueue.remove(i);
|
||||||
rePosition(i);
|
rePosition(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < originalPlayingQueue.size(); i++) {
|
for (int i = 0; i < originalPlayingQueue.size(); i++) {
|
||||||
if (originalPlayingQueue.get(i).id == song.id) {
|
if (originalPlayingQueue.get(i).getId() == song.getId()) {
|
||||||
originalPlayingQueue.remove(i);
|
originalPlayingQueue.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,7 +1032,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
public long getQueueDurationMillis(int position) {
|
public long getQueueDurationMillis(int position) {
|
||||||
long duration = 0;
|
long duration = 0;
|
||||||
for (int i = position + 1; i < playingQueue.size(); i++)
|
for (int i = position + 1; i < playingQueue.size(); i++)
|
||||||
duration += playingQueue.get(i).duration;
|
duration += playingQueue.get(i).getDuration();
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1087,11 +1086,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
break;
|
break;
|
||||||
case SHUFFLE_MODE_NONE:
|
case SHUFFLE_MODE_NONE:
|
||||||
this.shuffleMode = shuffleMode;
|
this.shuffleMode = shuffleMode;
|
||||||
int currentSongId = getCurrentSong().id;
|
int currentSongId = getCurrentSong().getId();
|
||||||
playingQueue = new ArrayList<>(originalPlayingQueue);
|
playingQueue = new ArrayList<>(originalPlayingQueue);
|
||||||
int newPosition = 0;
|
int newPosition = 0;
|
||||||
for (Song song : getPlayingQueue()) {
|
for (Song song : getPlayingQueue()) {
|
||||||
if (song.id == currentSongId) {
|
if (song.getId() == currentSongId) {
|
||||||
newPosition = getPlayingQueue().indexOf(song);
|
newPosition = getPlayingQueue().indexOf(song);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1118,11 +1117,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
|
|
||||||
final Song song = getCurrentSong();
|
final Song song = getCurrentSong();
|
||||||
|
|
||||||
intent.putExtra("id", song.id);
|
intent.putExtra("id", song.getId());
|
||||||
intent.putExtra("artist", song.artistName);
|
intent.putExtra("artist", song.getArtistName());
|
||||||
intent.putExtra("album", song.albumName);
|
intent.putExtra("album", song.getAlbumName());
|
||||||
intent.putExtra("track", song.title);
|
intent.putExtra("track", song.getTitle());
|
||||||
intent.putExtra("duration", song.duration);
|
intent.putExtra("duration", song.getDuration());
|
||||||
intent.putExtra("position", (long) getSongProgressMillis());
|
intent.putExtra("position", (long) getSongProgressMillis());
|
||||||
intent.putExtra("playing", isPlaying());
|
intent.putExtra("playing", isPlaying());
|
||||||
intent.putExtra("scrobbling_source", RETRO_MUSIC_PACKAGE_NAME);
|
intent.putExtra("scrobbling_source", RETRO_MUSIC_PACKAGE_NAME);
|
||||||
|
@ -1157,9 +1156,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
savePosition();
|
savePosition();
|
||||||
savePositionInTrack();
|
savePositionInTrack();
|
||||||
final Song currentSong = getCurrentSong();
|
final Song currentSong = getCurrentSong();
|
||||||
HistoryStore.getInstance(this).addSongId(currentSong.id);
|
HistoryStore.getInstance(this).addSongId(currentSong.getId());
|
||||||
if (songPlayCountHelper.shouldBumpPlayCount()) {
|
if (songPlayCountHelper.shouldBumpPlayCount()) {
|
||||||
SongPlayCountStore.getInstance(this).bumpPlayCount(songPlayCountHelper.getSong().id);
|
SongPlayCountStore.getInstance(this).bumpPlayCount(songPlayCountHelper.getSong().getId());
|
||||||
}
|
}
|
||||||
songPlayCountHelper.notifySongChanged(currentSong);
|
songPlayCountHelper.notifySongChanged(currentSong);
|
||||||
break;
|
break;
|
||||||
|
@ -1389,14 +1388,14 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
public static final String TAG = SongPlayCountHelper.class.getSimpleName();
|
public static final String TAG = SongPlayCountHelper.class.getSimpleName();
|
||||||
|
|
||||||
private StopWatch stopWatch = new StopWatch();
|
private StopWatch stopWatch = new StopWatch();
|
||||||
private Song song = Song.EMPTY_SONG;
|
private Song song = Song.getEmptySong();
|
||||||
|
|
||||||
public Song getSong() {
|
public Song getSong() {
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldBumpPlayCount() {
|
boolean shouldBumpPlayCount() {
|
||||||
return song.duration * 0.5d < stopWatch.getElapsedTime();
|
return song.getDuration() * 0.5d < stopWatch.getElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void notifySongChanged(Song song) {
|
void notifySongChanged(Song song) {
|
||||||
|
|
|
@ -241,9 +241,9 @@ public class WearBrowserService extends MediaBrowserService {
|
||||||
List<Song> songList = SongLoader.INSTANCE.getAllSongs(mContext).blockingFirst();
|
List<Song> songList = SongLoader.INSTANCE.getAllSongs(mContext).blockingFirst();
|
||||||
for (Song song : songList) {
|
for (Song song : songList) {
|
||||||
fillMediaItems(mediaItems,
|
fillMediaItems(mediaItems,
|
||||||
String.valueOf(song.id),
|
String.valueOf(song.getId()),
|
||||||
song.title,
|
song.getTitle(),
|
||||||
song.albumName,
|
song.getAlbumName(),
|
||||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||||
}
|
}
|
||||||
|
@ -253,9 +253,9 @@ public class WearBrowserService extends MediaBrowserService {
|
||||||
List<Song> albumSongList = AlbumLoader.Companion.getAlbum(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
|
List<Song> albumSongList = AlbumLoader.Companion.getAlbum(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
|
||||||
for (Song song : albumSongList) {
|
for (Song song : albumSongList) {
|
||||||
fillMediaItems(mediaItems,
|
fillMediaItems(mediaItems,
|
||||||
String.valueOf(song.id),
|
String.valueOf(song.getId()),
|
||||||
song.title,
|
song.getTitle(),
|
||||||
song.albumName,
|
song.getAlbumName(),
|
||||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||||
}
|
}
|
||||||
|
@ -264,9 +264,9 @@ public class WearBrowserService extends MediaBrowserService {
|
||||||
List<Song> artistSongs = ArtistLoader.INSTANCE.getArtist(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
|
List<Song> artistSongs = ArtistLoader.INSTANCE.getArtist(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
|
||||||
for (Song song : artistSongs) {
|
for (Song song : artistSongs) {
|
||||||
fillMediaItems(mediaItems,
|
fillMediaItems(mediaItems,
|
||||||
String.valueOf(song.id),
|
String.valueOf(song.getId()),
|
||||||
song.title,
|
song.getTitle(),
|
||||||
song.albumName,
|
song.getAlbumName(),
|
||||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,8 @@ public class WearBrowserService extends MediaBrowserService {
|
||||||
int size = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, playlist).blockingFirst().size();
|
int size = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, playlist).blockingFirst().size();
|
||||||
String songCount = String.format("%d %s", size, size > 1 ? "Songs" : "Song");
|
String songCount = String.format("%d %s", size, size > 1 ? "Songs" : "Song");
|
||||||
fillMediaItems(mediaItems,
|
fillMediaItems(mediaItems,
|
||||||
Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.id),
|
Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.getId()),
|
||||||
playlist.name,
|
playlist.getName(),
|
||||||
songCount,
|
songCount,
|
||||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"),
|
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"),
|
||||||
MediaBrowser.MediaItem.FLAG_BROWSABLE);
|
MediaBrowser.MediaItem.FLAG_BROWSABLE);
|
||||||
|
@ -288,9 +288,9 @@ public class WearBrowserService extends MediaBrowserService {
|
||||||
List<Song> playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst();
|
List<Song> playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst();
|
||||||
for (Song song : playlistSongs) {
|
for (Song song : playlistSongs) {
|
||||||
fillMediaItems(mediaItems,
|
fillMediaItems(mediaItems,
|
||||||
String.valueOf(song.id),
|
String.valueOf(song.getId()),
|
||||||
song.title,
|
song.getTitle(),
|
||||||
song.albumName,
|
song.getAlbumName(),
|
||||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,7 @@ import code.name.monkey.retromusic.glide.RetroGlideExtension
|
||||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.misc.AppBarStateChangeListener
|
import code.name.monkey.retromusic.misc.AppBarStateChangeListener
|
||||||
import code.name.monkey.retromusic.model.Album
|
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.model.Song
|
|
||||||
import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract
|
import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract
|
||||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
|
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
|
||||||
import code.name.monkey.retromusic.rest.LastFMRestClient
|
import code.name.monkey.retromusic.rest.LastFMRestClient
|
||||||
|
|
|
@ -243,7 +243,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
||||||
val data = MusicUtil.getLyrics(song)
|
val data = MusicUtil.getLyrics(song)
|
||||||
return if (TextUtils.isEmpty(data)) {
|
return if (TextUtils.isEmpty(data)) {
|
||||||
null
|
null
|
||||||
} else Lyrics.parse(song, data)
|
} else Lyrics.parse(song, data!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreExecute() {
|
override fun onPreExecute() {
|
||||||
|
|
|
@ -111,7 +111,7 @@ class AlbumCoverPagerAdapter(fm: FragmentManager, private val dataSet: ArrayList
|
||||||
private fun loadAlbumCover() {
|
private fun loadAlbumCover() {
|
||||||
GlideApp.with(context!!)
|
GlideApp.with(context!!)
|
||||||
.asBitmapPalette()
|
.asBitmapPalette()
|
||||||
.load(RetroGlideExtension.getSongModel(song))
|
.load(RetroGlideExtension.getSongModel(song!!))
|
||||||
.transition(RetroGlideExtension.getDefaultTransition())
|
.transition(RetroGlideExtension.getDefaultTransition())
|
||||||
.songOptions(song)
|
.songOptions(song)
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package code.name.monkey.retromusic.ui.adapter.playlist
|
package code.name.monkey.retromusic.ui.adapter.playlist
|
||||||
|
|
||||||
import android.graphics.PorterDuff
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
@ -152,7 +151,6 @@ class PlaylistAdapter(protected val activity: AppCompatActivity, dataSet: ArrayL
|
||||||
for (playlist in playlists) {
|
for (playlist in playlists) {
|
||||||
if (playlist is AbsCustomPlaylist) {
|
if (playlist is AbsCustomPlaylist) {
|
||||||
songs.addAll(playlist.getSongs(activity).blockingFirst())
|
songs.addAll(playlist.getSongs(activity).blockingFirst())
|
||||||
//((AbsCustomPlaylist) playlist).getSongs(activity).subscribe(this::setSongs);
|
|
||||||
} else {
|
} else {
|
||||||
songs
|
songs
|
||||||
.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id).blockingFirst())
|
.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id).blockingFirst())
|
||||||
|
|
|
@ -61,7 +61,7 @@ abstract class AbsOffsetSongAdapter : SongAdapter {
|
||||||
|
|
||||||
override// could also return null, just to be safe return empty song
|
override// could also return null, just to be safe return empty song
|
||||||
val song: Song
|
val song: Song
|
||||||
get() = if (itemViewType == OFFSET_ITEM) Song.EMPTY_SONG else dataSet[adapterPosition - 1]
|
get() = if (itemViewType == OFFSET_ITEM) Song.emptySong else dataSet[adapterPosition - 1]
|
||||||
|
|
||||||
override fun onClick(v: View?) {
|
override fun onClick(v: View?) {
|
||||||
if (isInQuickSelectMode && itemViewType != OFFSET_ITEM) {
|
if (isInQuickSelectMode && itemViewType != OFFSET_ITEM) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.util.Pair
|
import androidx.core.util.Pair
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
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.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
||||||
|
@ -148,7 +149,7 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getName(song: Song): String {
|
override fun getName(song: Song): String {
|
||||||
return song.title!!
|
return song.title
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMultipleItemAction(menuItem: MenuItem,
|
override fun onMultipleItemAction(menuItem: MenuItem,
|
||||||
|
@ -158,13 +159,14 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
|
||||||
|
|
||||||
override fun getSectionName(position: Int): String {
|
override fun getSectionName(position: Int): String {
|
||||||
if (!showSectionName) {
|
if (!showSectionName) {
|
||||||
return "";
|
return ""
|
||||||
}
|
}
|
||||||
val sectionName: String? = when (PreferenceUtil.getInstance().songSortOrder) {
|
val sectionName: String? = when (PreferenceUtil.getInstance().songSortOrder) {
|
||||||
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
||||||
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
||||||
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
|
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
|
||||||
SortOrder.SongSortOrder.SONG_YEAR -> return MusicUtil.getYearString(dataSet[position].year)
|
SortOrder.SongSortOrder.SONG_YEAR -> return MusicUtil.getYearString(dataSet[position].year)
|
||||||
|
SortOrder.SongSortOrder.COMPOSER -> dataSet[position].composer
|
||||||
else -> {
|
else -> {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
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.dialogs.*
|
import code.name.monkey.retromusic.dialogs.*
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
|
|
@ -2,6 +2,7 @@ package code.name.monkey.retromusic.ui.fragments.mainactivity
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.mvp.contract.SongContract
|
import code.name.monkey.retromusic.mvp.contract.SongContract
|
||||||
|
@ -14,7 +15,8 @@ import java.util.*
|
||||||
|
|
||||||
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(), SongContract.SongView {
|
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(), SongContract.SongView {
|
||||||
|
|
||||||
private var presenter: SongPresenter? = null
|
|
||||||
|
private lateinit var presenter: SongPresenter
|
||||||
|
|
||||||
override val emptyMessage: Int
|
override val emptyMessage: Int
|
||||||
get() = R.string.no_songs
|
get() = R.string.no_songs
|
||||||
|
|
|
@ -48,6 +48,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||||
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.helper.MusicPlayerRemote;
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||||
import code.name.monkey.retromusic.helper.menu.SongMenuHelper;
|
import code.name.monkey.retromusic.helper.menu.SongMenuHelper;
|
||||||
|
@ -365,7 +366,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
File file1 = (File) extra;
|
File file1 = (File) extra;
|
||||||
int startIndex = -1;
|
int startIndex = -1;
|
||||||
for (int i = 0; i < songs.size(); i++) {
|
for (int i = 0; i < songs.size(); i++) {
|
||||||
if (file1.getPath().equals(songs.get(i).data)) { // path is already canonical here
|
if (file1.getPath().equals(songs.get(i).getData())) { // path is already canonical here
|
||||||
startIndex = i;
|
startIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ class PortraitImpl(private val fragment: ClassicPlayerFragment) : BaseImpl(fragm
|
||||||
}
|
}
|
||||||
|
|
||||||
private var currentSongViewHolder: MediaEntryViewHolder? = null
|
private var currentSongViewHolder: MediaEntryViewHolder? = null
|
||||||
var currentSong = Song.EMPTY_SONG!!
|
var currentSong = Song.emptySong
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ class ColorFragment : AbsPlayerFragment() {
|
||||||
val data = MusicUtil.getLyrics(song)
|
val data = MusicUtil.getLyrics(song)
|
||||||
return if (TextUtils.isEmpty(data)) {
|
return if (TextUtils.isEmpty(data)) {
|
||||||
null
|
null
|
||||||
} else Lyrics.parse(song, data)
|
} else Lyrics.parse(song, data!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPostExecute(l: Lyrics?) {
|
override fun onPostExecute(l: Lyrics?) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package code.name.monkey.retromusic.ui.fragments.player.full
|
||||||
|
|
||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
|
|
|
@ -71,10 +71,10 @@ public class MusicUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static Intent createShareSongFileIntent(@NonNull final Song song, Context context) {
|
public static Intent createShareSongFileIntent(@NonNull final Song song, @NonNull Context context) {
|
||||||
try {
|
try {
|
||||||
return new Intent().setAction(Intent.ACTION_SEND).putExtra(Intent.EXTRA_STREAM,
|
return new Intent().setAction(Intent.ACTION_SEND).putExtra(Intent.EXTRA_STREAM,
|
||||||
FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName(), new File(song.data)))
|
FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName(), new File(song.getData())))
|
||||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
.setType("audio/*");
|
.setType("audio/*");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -120,10 +120,10 @@ public class MusicUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static String getSongInfoString(@NonNull final Song song) {
|
public static String getSongInfoString(@NonNull Song song) {
|
||||||
return MusicUtil.buildInfoString(
|
return MusicUtil.buildInfoString(
|
||||||
song.artistName,
|
song.getArtistName(),
|
||||||
song.albumName
|
song.getAlbumName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ public class MusicUtil {
|
||||||
|
|
||||||
long duration = 0;
|
long duration = 0;
|
||||||
for (int i = 0; i < songs.size(); i++) {
|
for (int i = 0; i < songs.size(); i++) {
|
||||||
duration += songs.get(i).duration;
|
duration += songs.get(i).getDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
return songCount + " " + songString + " • " + MusicUtil.getReadableDurationString(duration);
|
return songCount + " " + songString + " • " + MusicUtil.getReadableDurationString(duration);
|
||||||
|
@ -247,7 +247,7 @@ public class MusicUtil {
|
||||||
final StringBuilder selection = new StringBuilder();
|
final StringBuilder selection = new StringBuilder();
|
||||||
selection.append(BaseColumns._ID + " IN (");
|
selection.append(BaseColumns._ID + " IN (");
|
||||||
for (int i = 0; i < songs.size(); i++) {
|
for (int i = 0; i < songs.size(); i++) {
|
||||||
selection.append(songs.get(i).id);
|
selection.append(songs.get(i).getId());
|
||||||
if (i < songs.size() - 1) {
|
if (i < songs.size() - 1) {
|
||||||
selection.append(",");
|
selection.append(",");
|
||||||
}
|
}
|
||||||
|
@ -308,10 +308,10 @@ public class MusicUtil {
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getLyrics(Song song) {
|
public static String getLyrics(@NonNull Song song) {
|
||||||
String lyrics = null;
|
String lyrics = null;
|
||||||
|
|
||||||
File file = new File(song.data);
|
File file = new File(song.getData());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
lyrics = AudioFileIO.read(file).getTagOrCreateDefault().getFirst(FieldKey.LYRICS);
|
lyrics = AudioFileIO.read(file).getTagOrCreateDefault().getFirst(FieldKey.LYRICS);
|
||||||
|
@ -326,7 +326,7 @@ public class MusicUtil {
|
||||||
if (dir != null && dir.exists() && dir.isDirectory()) {
|
if (dir != null && dir.exists() && dir.isDirectory()) {
|
||||||
String format = ".*%s.*\\.(lrc|txt)";
|
String format = ".*%s.*\\.(lrc|txt)";
|
||||||
String filename = Pattern.quote(FileUtil.stripExtension(file.getName()));
|
String filename = Pattern.quote(FileUtil.stripExtension(file.getName()));
|
||||||
String songtitle = Pattern.quote(song.title);
|
String songtitle = Pattern.quote(song.getTitle());
|
||||||
|
|
||||||
final ArrayList<Pattern> patterns = new ArrayList<>();
|
final ArrayList<Pattern> patterns = new ArrayList<>();
|
||||||
patterns.add(Pattern.compile(String.format(format, filename),
|
patterns.add(Pattern.compile(String.format(format, filename),
|
||||||
|
@ -366,18 +366,16 @@ public class MusicUtil {
|
||||||
|
|
||||||
public static void toggleFavorite(@NonNull final Context context, @NonNull final Song song) {
|
public static void toggleFavorite(@NonNull final Context context, @NonNull final Song song) {
|
||||||
if (isFavorite(context, song)) {
|
if (isFavorite(context, song)) {
|
||||||
PlaylistsUtil
|
PlaylistsUtil.removeFromPlaylist(context, song, getFavoritesPlaylist(context).blockingFirst().getId());
|
||||||
.removeFromPlaylist(context, song, getFavoritesPlaylist(context).blockingFirst().id);
|
|
||||||
} else {
|
} else {
|
||||||
PlaylistsUtil
|
PlaylistsUtil.addToPlaylist(context, song, getOrCreateFavoritesPlaylist(context).blockingFirst().getId(),
|
||||||
.addToPlaylist(context, song, getOrCreateFavoritesPlaylist(context).blockingFirst().id,
|
false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFavoritePlaylist(@NonNull final Context context,
|
public static boolean isFavoritePlaylist(@NonNull final Context context,
|
||||||
@NonNull final Playlist playlist) {
|
@NonNull final Playlist playlist) {
|
||||||
return playlist.name != null && playlist.name.equals(context.getString(R.string.favorites));
|
return playlist.getName() != null && playlist.getName().equals(context.getString(R.string.favorites));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Observable<Playlist> getFavoritesPlaylist(@NonNull final Context context) {
|
private static Observable<Playlist> getFavoritesPlaylist(@NonNull final Context context) {
|
||||||
|
@ -399,7 +397,7 @@ public class MusicUtil {
|
||||||
//getFavoritesPlaylist(context).blockingFirst().id.subscribe(MusicUtil::setPlaylist);
|
//getFavoritesPlaylist(context).blockingFirst().id.subscribe(MusicUtil::setPlaylist);
|
||||||
//return PlaylistsUtil.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id);
|
//return PlaylistsUtil.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id);
|
||||||
return PlaylistsUtil
|
return PlaylistsUtil
|
||||||
.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id);
|
.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().getId(), song.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isArtistNameUnknown(@Nullable String artistName) {
|
public static boolean isArtistNameUnknown(@Nullable String artistName) {
|
||||||
|
@ -430,18 +428,19 @@ public class MusicUtil {
|
||||||
return String.valueOf(musicMediaTitle.charAt(0)).toUpperCase();
|
return String.valueOf(musicMediaTitle.charAt(0)).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public static Playlist getPlaylist() {
|
public static Playlist getPlaylist() {
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlaylist(Playlist playlist) {
|
public static void setPlaylist(@NonNull Playlist playlist) {
|
||||||
MusicUtil.playlist = playlist;
|
MusicUtil.playlist = playlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getTotalDuration(@NonNull final Context context, @NonNull List<Song> songs) {
|
public static long getTotalDuration(@NonNull final Context context, @NonNull List<Song> songs) {
|
||||||
long duration = 0;
|
long duration = 0;
|
||||||
for (int i = 0; i < songs.size(); i++) {
|
for (int i = 0; i < songs.size(); i++) {
|
||||||
duration += songs.get(i).duration;
|
duration += songs.get(i).getDuration();
|
||||||
}
|
}
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.audiofx.AudioEffect;
|
import android.media.audiofx.AudioEffect;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -75,10 +76,10 @@ public class NavigationUtil {
|
||||||
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, i);
|
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, i);
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
ActivityCompat.startActivity(activity, intent,
|
ActivityCompat.startActivity(activity, intent,
|
||||||
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, null).toBundle());
|
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, (Pair<View, String>) null).toBundle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void goToPlaylistNew(@NonNull Activity activity, Playlist playlist) {
|
public static void goToPlaylistNew(@NonNull Activity activity, @NonNull Playlist playlist) {
|
||||||
Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
||||||
intent.putExtra(PlaylistDetailActivity.Companion.getEXTRA_PLAYLIST(), playlist);
|
intent.putExtra(PlaylistDetailActivity.Companion.getEXTRA_PLAYLIST(), playlist);
|
||||||
ActivityCompat.startActivity(activity, intent, null);
|
ActivityCompat.startActivity(activity, intent, null);
|
||||||
|
|
|
@ -22,14 +22,14 @@ import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.helper.M3UWriter;
|
import code.name.monkey.retromusic.helper.M3UWriter;
|
||||||
import code.name.monkey.retromusic.model.Playlist;
|
import code.name.monkey.retromusic.model.Playlist;
|
||||||
|
@ -99,7 +99,7 @@ public class PlaylistsUtil {
|
||||||
final StringBuilder selection = new StringBuilder();
|
final StringBuilder selection = new StringBuilder();
|
||||||
selection.append(MediaStore.Audio.Playlists._ID + " IN (");
|
selection.append(MediaStore.Audio.Playlists._ID + " IN (");
|
||||||
for (int i = 0; i < playlists.size(); i++) {
|
for (int i = 0; i < playlists.size(); i++) {
|
||||||
selection.append(playlists.get(i).id);
|
selection.append(playlists.get(i).getId());
|
||||||
if (i < playlists.size() - 1) {
|
if (i < playlists.size() - 1) {
|
||||||
selection.append(",");
|
selection.append(",");
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,7 @@ public class PlaylistsUtil {
|
||||||
public static void addToPlaylist(@NonNull final Context context, @NonNull final List<Song> songs, final int playlistId, final boolean showToastOnFinish) {
|
public static void addToPlaylist(@NonNull final Context context, @NonNull final List<Song> songs, final int playlistId, final boolean showToastOnFinish) {
|
||||||
final int size = songs.size();
|
final int size = songs.size();
|
||||||
final ContentResolver resolver = context.getContentResolver();
|
final ContentResolver resolver = context.getContentResolver();
|
||||||
final String[] projection = new String[]{
|
final String[] projection = new String[]{"max(" + MediaStore.Audio.Playlists.Members.PLAY_ORDER + ")",};
|
||||||
"max(" + MediaStore.Audio.Playlists.Members.PLAY_ORDER + ")",
|
|
||||||
};
|
|
||||||
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId);
|
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId);
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
int base = 0;
|
int base = 0;
|
||||||
|
@ -153,7 +151,7 @@ public class PlaylistsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static ContentValues[] makeInsertItems(@NonNull final List<Song> songs, final int offset, int len, final int base) {
|
private static ContentValues[] makeInsertItems(@NonNull final List<Song> songs, final int offset, int len, final int base) {
|
||||||
if (offset + len > songs.size()) {
|
if (offset + len > songs.size()) {
|
||||||
len = songs.size() - offset;
|
len = songs.size() - offset;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +161,7 @@ public class PlaylistsUtil {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
contentValues[i] = new ContentValues();
|
contentValues[i] = new ContentValues();
|
||||||
contentValues[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, base + offset + i);
|
contentValues[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, base + offset + i);
|
||||||
contentValues[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(offset + i).id);
|
contentValues[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(offset + i).getAlbumId());
|
||||||
}
|
}
|
||||||
return contentValues;
|
return contentValues;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +170,7 @@ public class PlaylistsUtil {
|
||||||
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(
|
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(
|
||||||
"external", playlistId);
|
"external", playlistId);
|
||||||
String selection = MediaStore.Audio.Playlists.Members.AUDIO_ID + " =?";
|
String selection = MediaStore.Audio.Playlists.Members.AUDIO_ID + " =?";
|
||||||
String[] selectionArgs = new String[]{String.valueOf(song.id)};
|
String[] selectionArgs = new String[]{String.valueOf(song.getId())};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.getContentResolver().delete(uri, selection, selectionArgs);
|
context.getContentResolver().delete(uri, selection, selectionArgs);
|
||||||
|
@ -181,12 +179,12 @@ public class PlaylistsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeFromPlaylist(@NonNull final Context context, @NonNull final List<PlaylistSong> songs) {
|
public static void removeFromPlaylist(@NonNull final Context context, @NonNull final List<PlaylistSong> songs) {
|
||||||
final int playlistId = songs.get(0).playlistId;
|
final int playlistId = songs.get(0).getPlaylistId();
|
||||||
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(
|
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(
|
||||||
"external", playlistId);
|
"external", playlistId);
|
||||||
String selectionArgs[] = new String[songs.size()];
|
String selectionArgs[] = new String[songs.size()];
|
||||||
for (int i = 0; i < selectionArgs.length; i++) {
|
for (int i = 0; i < selectionArgs.length; i++) {
|
||||||
selectionArgs[i] = String.valueOf(songs.get(i).idInPlayList);
|
selectionArgs[i] = String.valueOf(songs.get(i).getIdInPlayList());
|
||||||
}
|
}
|
||||||
String selection = MediaStore.Audio.Playlists.Members._ID + " in (";
|
String selection = MediaStore.Audio.Playlists.Members._ID + " in (";
|
||||||
//noinspection unused
|
//noinspection unused
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
include ':app', ':appthemehelper', ':models'
|
include ':app', ':appthemehelper'
|
Loading…
Reference in New Issue