🗑Deleted unwanted files
This commit is contained in:
parent
25fbbce11e
commit
41e8aa8a03
19 changed files with 172 additions and 579 deletions
|
@ -1,77 +1,73 @@
|
||||||
/*
|
|
||||||
* 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.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import code.name.monkey.retromusic.EXTRA_PLAYLISTS
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.db.PlaylistEntity
|
||||||
|
import code.name.monkey.retromusic.db.SongEntity
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
|
import code.name.monkey.retromusic.fragments.ReloadType.Playlists
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.repository.PlaylistRepository
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import kotlinx.coroutines.Dispatchers
|
||||||
import org.koin.android.ext.android.inject
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
|
class AddToPlaylistDialog : BottomSheetDialogFragment() {
|
||||||
|
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||||
|
|
||||||
class AddToPlaylistDialog : DialogFragment() {
|
companion object {
|
||||||
private val playlistRepository by inject<PlaylistRepository>()
|
fun create(playlistEntities: List<PlaylistEntity>, song: Song): AddToPlaylistDialog {
|
||||||
override fun onCreateDialog(
|
val list = mutableListOf<Song>()
|
||||||
savedInstanceState: Bundle?
|
list.add(song)
|
||||||
): Dialog {
|
return create(playlistEntities, list)
|
||||||
val playlists = playlistRepository.playlists()
|
}
|
||||||
|
|
||||||
|
fun create(playlistEntities: List<PlaylistEntity>, songs: List<Song>): AddToPlaylistDialog {
|
||||||
|
return AddToPlaylistDialog().apply {
|
||||||
|
arguments = bundleOf(
|
||||||
|
EXTRA_SONG to songs,
|
||||||
|
EXTRA_PLAYLISTS to playlistEntities
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val playlistEntities = extraNotNull<List<PlaylistEntity>>(EXTRA_PLAYLISTS).value
|
||||||
|
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
||||||
val playlistNames = mutableListOf<String>()
|
val playlistNames = mutableListOf<String>()
|
||||||
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
|
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
|
||||||
for (p in playlists) {
|
for (p in playlistEntities) {
|
||||||
playlistNames.add(p.name)
|
playlistNames.add(p.playlistName)
|
||||||
}
|
}
|
||||||
return materialDialog(R.string.add_playlist_title)
|
return materialDialog(R.string.add_playlist_title)
|
||||||
.setItems(playlistNames.toTypedArray()) { _, which ->
|
.setItems(playlistNames.toTypedArray()) { _, which ->
|
||||||
val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value
|
|
||||||
if (which == 0) {
|
if (which == 0) {
|
||||||
CreatePlaylistDialog.create(songs)
|
CreatePlaylistDialog.create(songs)
|
||||||
.show(requireActivity().supportFragmentManager, "ADD_TO_PLAYLIST")
|
.show(requireActivity().supportFragmentManager, "Dialog")
|
||||||
} else {
|
} else {
|
||||||
PlaylistsUtil.addToPlaylist(
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
requireContext(),
|
val songEntities = songs.toSongEntity(playlistEntities[which - 1])
|
||||||
songs,
|
libraryViewModel.insertSongs(songEntities)
|
||||||
playlists[which - 1].id,
|
libraryViewModel.forceReload(Playlists)
|
||||||
true
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
.create().colorButtons()
|
.create().colorButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(song: Song): AddToPlaylistDialog {
|
|
||||||
val list = ArrayList<Song>()
|
|
||||||
list.add(song)
|
|
||||||
return create(list)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun create(songs: List<Song>): AddToPlaylistDialog {
|
private fun List<Song>.toSongEntity(playlistEntity: PlaylistEntity): List<SongEntity> {
|
||||||
val dialog = AddToPlaylistDialog()
|
return map {
|
||||||
val args = Bundle()
|
it.toSongEntity(playlistEntity.playListId)
|
||||||
args.putParcelableArrayList(EXTRA_SONG, ArrayList(songs))
|
|
||||||
dialog.arguments = args
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,73 +0,0 @@
|
||||||
package code.name.monkey.retromusic.dialogs
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import code.name.monkey.retromusic.EXTRA_PLAYLISTS
|
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import code.name.monkey.retromusic.db.PlaylistEntity
|
|
||||||
import code.name.monkey.retromusic.db.SongEntity
|
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType.Playlists
|
|
||||||
import code.name.monkey.retromusic.model.Song
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
|
||||||
|
|
||||||
class AddToRetroPlaylist : BottomSheetDialogFragment() {
|
|
||||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun create(playlistEntities: List<PlaylistEntity>, song: Song): AddToRetroPlaylist {
|
|
||||||
val list = mutableListOf<Song>()
|
|
||||||
list.add(song)
|
|
||||||
return create(playlistEntities, list)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(playlistEntities: List<PlaylistEntity>, songs: List<Song>): AddToRetroPlaylist {
|
|
||||||
return AddToRetroPlaylist().apply {
|
|
||||||
arguments = bundleOf(
|
|
||||||
EXTRA_SONG to songs,
|
|
||||||
EXTRA_PLAYLISTS to playlistEntities
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
val playlistEntities = extraNotNull<List<PlaylistEntity>>(EXTRA_PLAYLISTS).value
|
|
||||||
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
|
||||||
val playlistNames = mutableListOf<String>()
|
|
||||||
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
|
|
||||||
for (p in playlistEntities) {
|
|
||||||
playlistNames.add(p.playlistName)
|
|
||||||
}
|
|
||||||
return materialDialog(R.string.add_playlist_title)
|
|
||||||
.setItems(playlistNames.toTypedArray()) { _, which ->
|
|
||||||
if (which == 0) {
|
|
||||||
CreateRetroPlaylist.create(songs)
|
|
||||||
.show(requireActivity().supportFragmentManager, "Dialog")
|
|
||||||
} else {
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
|
||||||
val songEntities = songs.toSongEntity(playlistEntities[which - 1])
|
|
||||||
libraryViewModel.insertSongs(songEntities)
|
|
||||||
libraryViewModel.forceReload(Playlists)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
.create().colorButtons()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun List<Song>.toSongEntity(playlistEntity: PlaylistEntity): List<SongEntity> {
|
|
||||||
return map {
|
|
||||||
it.toSongEntity(playlistEntity.playListId)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +1,77 @@
|
||||||
/*
|
|
||||||
* 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.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.db.PlaylistEntity
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
|
import code.name.monkey.retromusic.fragments.ReloadType.Playlists
|
||||||
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.repository.RealRepository
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import kotlinx.android.synthetic.main.dialog_playlist.view.*
|
import kotlinx.android.synthetic.main.dialog_playlist.view.*
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
class CreatePlaylistDialog : DialogFragment() {
|
class CreatePlaylistDialog : DialogFragment() {
|
||||||
|
private val repository by inject<RealRepository>()
|
||||||
|
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
companion object {
|
||||||
override fun onCreateDialog(
|
fun create(song: Song): CreatePlaylistDialog {
|
||||||
savedInstanceState: Bundle?
|
val list = mutableListOf<Song>()
|
||||||
): Dialog {
|
list.add(song)
|
||||||
|
return create(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create(songs: List<Song>): CreatePlaylistDialog {
|
||||||
|
return CreatePlaylistDialog().apply {
|
||||||
|
arguments = bundleOf(EXTRA_SONG to songs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val view = LayoutInflater.from(requireActivity()).inflate(R.layout.dialog_playlist, null)
|
val view = LayoutInflater.from(requireActivity()).inflate(R.layout.dialog_playlist, null)
|
||||||
|
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
||||||
val playlistView: TextInputEditText = view.actionNewPlaylist
|
val playlistView: TextInputEditText = view.actionNewPlaylist
|
||||||
val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer
|
val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer
|
||||||
MaterialUtil.setTint(playlistContainer, false)
|
|
||||||
|
|
||||||
return materialDialog(R.string.new_playlist_title)
|
return materialDialog(R.string.new_playlist_title)
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.setPositiveButton(
|
.setPositiveButton(
|
||||||
R.string.create_action
|
R.string.create_action
|
||||||
) { _, _ ->
|
) { _, _ ->
|
||||||
val extra = extraNotNull<ArrayList<Song>>(EXTRA_SONG)
|
|
||||||
val playlistName = playlistView.text.toString()
|
val playlistName = playlistView.text.toString()
|
||||||
if (!TextUtils.isEmpty(playlistName)) {
|
if (!TextUtils.isEmpty(playlistName)) {
|
||||||
val playlistId = PlaylistsUtil.createPlaylist(
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
requireContext(),
|
if (repository.checkPlaylistExists(playlistName).isEmpty()) {
|
||||||
playlistView.text.toString()
|
val playlistId = repository.createPlaylist(PlaylistEntity(playlistName))
|
||||||
)
|
println(playlistId)
|
||||||
if (playlistId != -1) {
|
repository.insertSongs(songs.map { it.toSongEntity(playlistId.toInt()) })
|
||||||
PlaylistsUtil.addToPlaylist(requireContext(), extra.value, playlistId, true)
|
libraryViewModel.forceReload(Playlists)
|
||||||
|
} else {
|
||||||
|
Toast.makeText(requireContext(), "Playlist exists", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
playlistContainer.error = "Playlist is can't be empty"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmOverloads
|
|
||||||
@JvmStatic
|
|
||||||
fun create(song: Song? = null): CreatePlaylistDialog {
|
|
||||||
val list = ArrayList<Song>()
|
|
||||||
if (song != null) {
|
|
||||||
list.add(song)
|
|
||||||
}
|
|
||||||
return create(list)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun create(songs: ArrayList<Song>): CreatePlaylistDialog {
|
|
||||||
val dialog = CreatePlaylistDialog()
|
|
||||||
val args = Bundle()
|
|
||||||
args.putParcelableArrayList(EXTRA_SONG, songs)
|
|
||||||
dialog.arguments = args
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,77 +0,0 @@
|
||||||
package code.name.monkey.retromusic.dialogs
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.text.TextUtils
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import code.name.monkey.retromusic.db.PlaylistEntity
|
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType.Playlists
|
|
||||||
import code.name.monkey.retromusic.model.Song
|
|
||||||
import code.name.monkey.retromusic.repository.RealRepository
|
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
|
||||||
import kotlinx.android.synthetic.main.dialog_playlist.view.*
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import org.koin.android.ext.android.inject
|
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
|
||||||
|
|
||||||
class CreateRetroPlaylist : DialogFragment() {
|
|
||||||
private val repository by inject<RealRepository>()
|
|
||||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun create(song: Song): CreateRetroPlaylist {
|
|
||||||
val list = mutableListOf<Song>()
|
|
||||||
list.add(song)
|
|
||||||
return create(list)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(songs: List<Song>): CreateRetroPlaylist {
|
|
||||||
return CreateRetroPlaylist().apply {
|
|
||||||
arguments = bundleOf(EXTRA_SONG to songs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
val view = LayoutInflater.from(requireActivity()).inflate(R.layout.dialog_playlist, null)
|
|
||||||
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
|
||||||
val playlistView: TextInputEditText = view.actionNewPlaylist
|
|
||||||
val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer
|
|
||||||
return materialDialog(R.string.new_playlist_title)
|
|
||||||
.setView(view)
|
|
||||||
.setPositiveButton(
|
|
||||||
R.string.create_action
|
|
||||||
) { _, _ ->
|
|
||||||
val playlistName = playlistView.text.toString()
|
|
||||||
if (!TextUtils.isEmpty(playlistName)) {
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
|
||||||
if (repository.checkPlaylistExists(playlistName).isEmpty()) {
|
|
||||||
val playlistId = repository.createPlaylist(PlaylistEntity(playlistName))
|
|
||||||
println(playlistId)
|
|
||||||
repository.insertSongs(songs.map { it.toSongEntity(playlistId.toInt()) })
|
|
||||||
libraryViewModel.forceReload(Playlists)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(requireContext(), "Playlist exists", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
playlistContainer.error = "Playlist is can't be empty"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.create()
|
|
||||||
.colorButtons()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +1,41 @@
|
||||||
/*
|
|
||||||
* 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.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.EXTRA_PLAYLIST
|
import code.name.monkey.retromusic.EXTRA_PLAYLIST
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.db.PlaylistEntity
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.fragments.ReloadType
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
class DeletePlaylistDialog : DialogFragment() {
|
class DeletePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun create(playlist: PlaylistEntity): DeletePlaylistDialog {
|
||||||
|
val list = mutableListOf<PlaylistEntity>()
|
||||||
|
list.add(playlist)
|
||||||
|
return create(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create(playlists: List<PlaylistEntity>): DeletePlaylistDialog {
|
||||||
|
return DeletePlaylistDialog().apply {
|
||||||
|
arguments = bundleOf(EXTRA_PLAYLIST to playlists)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val playlists = extraNotNull<List<Playlist>>(EXTRA_PLAYLIST).value
|
val playlists = extraNotNull<List<PlaylistEntity>>(EXTRA_PLAYLIST).value
|
||||||
val title: Int
|
val title: Int
|
||||||
val message: CharSequence
|
val message: CharSequence
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
|
@ -42,7 +48,7 @@ class DeletePlaylistDialog : DialogFragment() {
|
||||||
} else {
|
} else {
|
||||||
title = R.string.delete_playlist_title
|
title = R.string.delete_playlist_title
|
||||||
message = HtmlCompat.fromHtml(
|
message = HtmlCompat.fromHtml(
|
||||||
String.format(getString(R.string.delete_playlist_x), playlists[0].name),
|
String.format(getString(R.string.delete_playlist_x), playlists[0].playlistName),
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -52,26 +58,12 @@ class DeletePlaylistDialog : DialogFragment() {
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.action_delete) { _, _ ->
|
.setPositiveButton(R.string.action_delete) { _, _ ->
|
||||||
PlaylistsUtil.deletePlaylists(requireContext(), playlists)
|
libraryViewModel.deleteSongsFromPlaylist(playlists)
|
||||||
|
libraryViewModel.deleteRoomPlaylist(playlists)
|
||||||
|
libraryViewModel.forceReload(ReloadType.Playlists)
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(playlist: Playlist): DeletePlaylistDialog {
|
|
||||||
val list = ArrayList<Playlist>()
|
|
||||||
list.add(playlist)
|
|
||||||
return create(list)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(playlist: ArrayList<Playlist>): DeletePlaylistDialog {
|
|
||||||
val dialog = DeletePlaylistDialog()
|
|
||||||
val args = Bundle()
|
|
||||||
args.putParcelableArrayList(EXTRA_PLAYLIST, playlist)
|
|
||||||
dialog.arguments = args
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,69 +0,0 @@
|
||||||
package code.name.monkey.retromusic.dialogs
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.core.text.HtmlCompat
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import code.name.monkey.retromusic.EXTRA_PLAYLIST
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import code.name.monkey.retromusic.db.PlaylistEntity
|
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType
|
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
|
||||||
|
|
||||||
class DeleteRetroPlaylist : DialogFragment() {
|
|
||||||
|
|
||||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(playlist: PlaylistEntity): DeleteRetroPlaylist {
|
|
||||||
val list = mutableListOf<PlaylistEntity>()
|
|
||||||
list.add(playlist)
|
|
||||||
return create(list)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(playlists: List<PlaylistEntity>): DeleteRetroPlaylist {
|
|
||||||
return DeleteRetroPlaylist().apply {
|
|
||||||
arguments = bundleOf(EXTRA_PLAYLIST to playlists)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
val playlists = extraNotNull<List<PlaylistEntity>>(EXTRA_PLAYLIST).value
|
|
||||||
val title: Int
|
|
||||||
val message: CharSequence
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
if (playlists.size > 1) {
|
|
||||||
title = R.string.delete_playlists_title
|
|
||||||
message = HtmlCompat.fromHtml(
|
|
||||||
String.format(getString(R.string.delete_x_playlists), playlists.size),
|
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
title = R.string.delete_playlist_title
|
|
||||||
message = HtmlCompat.fromHtml(
|
|
||||||
String.format(getString(R.string.delete_playlist_x), playlists[0].playlistName),
|
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return materialDialog(title)
|
|
||||||
.setTitle(title)
|
|
||||||
.setMessage(message)
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.setPositiveButton(R.string.action_delete) { _, _ ->
|
|
||||||
libraryViewModel.deleteSongsFromPlaylist(playlists)
|
|
||||||
libraryViewModel.deleteRoomPlaylist(playlists)
|
|
||||||
libraryViewModel.forceReload(ReloadType.Playlists)
|
|
||||||
}
|
|
||||||
.create()
|
|
||||||
.colorButtons()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,84 +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.dialogs
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.core.text.HtmlCompat
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import code.name.monkey.retromusic.R.string
|
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
|
||||||
import code.name.monkey.retromusic.model.PlaylistSong
|
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
|
||||||
|
|
||||||
class RemoveFromPlaylistDialog : DialogFragment() {
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
val songs = requireArguments().getParcelableArrayList<PlaylistSong>(EXTRA_SONG)
|
|
||||||
|
|
||||||
var title = 0
|
|
||||||
var message: CharSequence = ""
|
|
||||||
if (songs != null) {
|
|
||||||
if (songs.size > 1) {
|
|
||||||
title = R.string.remove_songs_from_playlist_title
|
|
||||||
message = HtmlCompat.fromHtml(
|
|
||||||
String.format(getString(string.remove_x_songs_from_playlist), songs.size),
|
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
title = R.string.remove_song_from_playlist_title
|
|
||||||
message = HtmlCompat.fromHtml(
|
|
||||||
String.format(
|
|
||||||
getString(string.remove_song_x_from_playlist),
|
|
||||||
songs[0].title
|
|
||||||
),
|
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return materialDialog(title)
|
|
||||||
.setMessage(message)
|
|
||||||
.setPositiveButton(R.string.remove_action) { _, _ ->
|
|
||||||
PlaylistsUtil.removeFromPlaylist(
|
|
||||||
requireContext(),
|
|
||||||
songs as MutableList<PlaylistSong>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.create()
|
|
||||||
.colorButtons()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(song: PlaylistSong): RemoveFromPlaylistDialog {
|
|
||||||
val list = ArrayList<PlaylistSong>()
|
|
||||||
list.add(song)
|
|
||||||
return create(list)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(songs: ArrayList<PlaylistSong>): RemoveFromPlaylistDialog {
|
|
||||||
val dialog = RemoveFromPlaylistDialog()
|
|
||||||
val args = Bundle()
|
|
||||||
args.putParcelableArrayList(EXTRA_SONG, songs)
|
|
||||||
dialog.arguments = args
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +1,57 @@
|
||||||
/*
|
|
||||||
* 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.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore.Audio.Playlists.Members.PLAYLIST_ID
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import code.name.monkey.retromusic.EXTRA_PLAYLIST_ID
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.db.PlaylistEntity
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
|
import code.name.monkey.retromusic.fragments.ReloadType
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
class RenamePlaylistDialog : DialogFragment() {
|
class RenamePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
companion object {
|
||||||
override fun onCreateDialog(
|
fun create(playlistEntity: PlaylistEntity): RenamePlaylistDialog {
|
||||||
savedInstanceState: Bundle?
|
return RenamePlaylistDialog().apply {
|
||||||
): Dialog {
|
arguments = bundleOf(
|
||||||
val layout = LayoutInflater.from(requireContext())
|
EXTRA_PLAYLIST_ID to playlistEntity
|
||||||
.inflate(R.layout.dialog_playlist, null)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val playlistEntity = extraNotNull<PlaylistEntity>(EXTRA_PLAYLIST_ID).value
|
||||||
|
val layout = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_playlist, null)
|
||||||
val inputEditText: TextInputEditText = layout.findViewById(R.id.actionNewPlaylist)
|
val inputEditText: TextInputEditText = layout.findViewById(R.id.actionNewPlaylist)
|
||||||
val nameContainer: TextInputLayout =
|
val nameContainer: TextInputLayout = layout.findViewById(R.id.actionNewPlaylistContainer)
|
||||||
layout.findViewById(R.id.actionNewPlaylistContainer)
|
nameContainer.accentColor()
|
||||||
MaterialUtil.setTint(nameContainer, false)
|
inputEditText.setText(playlistEntity.playlistName)
|
||||||
|
|
||||||
return materialDialog(R.string.rename_playlist_title)
|
return materialDialog(R.string.rename_playlist_title)
|
||||||
.setView(layout)
|
.setView(layout)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.action_rename) { _, _ ->
|
.setPositiveButton(R.string.action_rename) { _, _ ->
|
||||||
val name = inputEditText.text.toString()
|
val name = inputEditText.text.toString()
|
||||||
if (name.isNotEmpty()) {
|
if (name.isNotEmpty()) {
|
||||||
PlaylistsUtil.renamePlaylist(
|
libraryViewModel.renameRoomPlaylist(playlistEntity.playListId, name)
|
||||||
requireContext(),
|
libraryViewModel.forceReload(ReloadType.Playlists)
|
||||||
extraNotNull<Long>(PLAYLIST_ID).value,
|
} else {
|
||||||
name
|
nameContainer.error = "Playlist name should'nt be empty"
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(playlistId: Long): RenamePlaylistDialog {
|
|
||||||
val dialog = RenamePlaylistDialog()
|
|
||||||
val args = Bundle()
|
|
||||||
args.putLong(PLAYLIST_ID, playlistId)
|
|
||||||
dialog.arguments = args
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
package code.name.monkey.retromusic.dialogs
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import code.name.monkey.retromusic.EXTRA_PLAYLIST_ID
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import code.name.monkey.retromusic.db.PlaylistEntity
|
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType
|
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
|
||||||
|
|
||||||
class RenameRetroPlaylistDialog : DialogFragment() {
|
|
||||||
|
|
||||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun create(playlistEntity: PlaylistEntity): RenameRetroPlaylistDialog {
|
|
||||||
return RenameRetroPlaylistDialog().apply {
|
|
||||||
arguments = bundleOf(
|
|
||||||
EXTRA_PLAYLIST_ID to playlistEntity
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
val playlistEntity = extraNotNull<PlaylistEntity>(EXTRA_PLAYLIST_ID).value
|
|
||||||
val layout = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_playlist, null)
|
|
||||||
val inputEditText: TextInputEditText = layout.findViewById(R.id.actionNewPlaylist)
|
|
||||||
val nameContainer: TextInputLayout = layout.findViewById(R.id.actionNewPlaylistContainer)
|
|
||||||
nameContainer.accentColor()
|
|
||||||
inputEditText.setText(playlistEntity.playlistName)
|
|
||||||
return materialDialog(R.string.rename_playlist_title)
|
|
||||||
.setView(layout)
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.setPositiveButton(R.string.action_rename) { _, _ ->
|
|
||||||
val name = inputEditText.text.toString()
|
|
||||||
if (name.isNotEmpty()) {
|
|
||||||
libraryViewModel.renameRoomPlaylist(playlistEntity.playListId, name)
|
|
||||||
libraryViewModel.forceReload(ReloadType.Playlists)
|
|
||||||
} else {
|
|
||||||
nameContainer.error = "Playlist name should'nt be empty"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.create()
|
|
||||||
.colorButtons()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package code.name.monkey.retromusic.dialogs
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.widget.ArrayAdapter
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
|
|
||||||
class RetroSingleCheckedListAdapter(
|
|
||||||
context: Context,
|
|
||||||
resource: Int = R.layout.dialog_list_item,
|
|
||||||
objects: MutableList<String>
|
|
||||||
) : ArrayAdapter<String>(context, resource, objects)
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
|
class SavePlaylistDialog {
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
||||||
import code.name.monkey.retromusic.activities.tageditor.AlbumTagEditorActivity
|
import code.name.monkey.retromusic.activities.tageditor.AlbumTagEditorActivity
|
||||||
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
||||||
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
||||||
import code.name.monkey.retromusic.dialogs.AddToRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
import code.name.monkey.retromusic.extensions.applyOutlineColor
|
import code.name.monkey.retromusic.extensions.applyOutlineColor
|
||||||
|
@ -286,7 +286,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
AddToRetroPlaylist.create(playlists, songs)
|
AddToPlaylistDialog.create(playlists, songs)
|
||||||
.show(childFragmentManager, "ADD_PLAYLIST")
|
.show(childFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
||||||
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
||||||
import code.name.monkey.retromusic.dialogs.AddToRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
import code.name.monkey.retromusic.extensions.applyOutlineColor
|
import code.name.monkey.retromusic.extensions.applyOutlineColor
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
|
@ -229,7 +229,7 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
AddToRetroPlaylist.create(playlists, songs)
|
AddToPlaylistDialog.create(playlists, songs)
|
||||||
.show(childFragmentManager, "ADD_PLAYLIST")
|
.show(childFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme
|
||||||
lifecycleScope.launch(IO) {
|
lifecycleScope.launch(IO) {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
AddToRetroPlaylist.create(playlists, song)
|
AddToPlaylistDialog.create(playlists, song)
|
||||||
.show(childFragmentManager, "ADD_PLAYLIST")
|
.show(childFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.action_save_playing_queue -> {
|
R.id.action_save_playing_queue -> {
|
||||||
CreateRetroPlaylist.create(ArrayList(MusicPlayerRemote.playingQueue))
|
CreatePlaylistDialog.create(ArrayList(MusicPlayerRemote.playingQueue))
|
||||||
.show(childFragmentManager, "ADD_TO_PLAYLIST")
|
.show(childFragmentManager, "ADD_TO_PLAYLIST")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -209,9 +209,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
val icon =
|
val icon =
|
||||||
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
|
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
|
||||||
val drawable: Drawable? =
|
val drawable: Drawable? = RetroUtil.getTintedVectorDrawable(
|
||||||
|
|
||||||
RetroUtil.getTintedVectorDrawable(
|
|
||||||
requireContext(),
|
requireContext(),
|
||||||
icon,
|
icon,
|
||||||
toolbarIconColor()
|
toolbarIconColor()
|
||||||
|
|
|
@ -9,7 +9,7 @@ import androidx.navigation.ui.NavigationUI
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor
|
||||||
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.dialogs.CreateRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.findNavController
|
import code.name.monkey.retromusic.extensions.findNavController
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||||
|
@ -34,7 +34,7 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
|
||||||
addPlaylist.apply {
|
addPlaylist.apply {
|
||||||
accentColor()
|
accentColor()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
CreateRetroPlaylist().show(childFragmentManager, "ShowCreatePlaylistDialog")
|
CreatePlaylistDialog().show(childFragmentManager, "ShowCreatePlaylistDialog")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setupNavigationController()
|
setupNavigationController()
|
||||||
|
|
|
@ -17,7 +17,7 @@ package code.name.monkey.retromusic.helper.menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
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.AddToRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Genre
|
import code.name.monkey.retromusic.model.Genre
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
@ -47,7 +47,7 @@ object GenreMenuHelper : KoinComponent {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
AddToRetroPlaylist.create(playlists, getGenreSongs(genre))
|
AddToPlaylistDialog.create(playlists, getGenreSongs(genre))
|
||||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ import code.name.monkey.retromusic.App
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.db.PlaylistWithSongs
|
import code.name.monkey.retromusic.db.PlaylistWithSongs
|
||||||
import code.name.monkey.retromusic.db.toSongs
|
import code.name.monkey.retromusic.db.toSongs
|
||||||
import code.name.monkey.retromusic.dialogs.AddToRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.DeleteRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.RenameRetroPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.RenamePlaylistDialog
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.misc.WeakContextAsyncTask
|
import code.name.monkey.retromusic.misc.WeakContextAsyncTask
|
||||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||||
|
@ -60,7 +60,7 @@ object PlaylistMenuHelper : KoinComponent {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
AddToRetroPlaylist.create(playlists, playlistWithSongs.songs.toSongs())
|
AddToPlaylistDialog.create(playlists, playlistWithSongs.songs.toSongs())
|
||||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,17 +71,18 @@ object PlaylistMenuHelper : KoinComponent {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.action_rename_playlist -> {
|
R.id.action_rename_playlist -> {
|
||||||
RenameRetroPlaylistDialog.create(playlistWithSongs.playlistEntity)
|
RenamePlaylistDialog.create(playlistWithSongs.playlistEntity)
|
||||||
.show(activity.supportFragmentManager, "RENAME_PLAYLIST")
|
.show(activity.supportFragmentManager, "RENAME_PLAYLIST")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.action_delete_playlist -> {
|
R.id.action_delete_playlist -> {
|
||||||
DeleteRetroPlaylist.create(playlistWithSongs.playlistEntity)
|
DeletePlaylistDialog.create(playlistWithSongs.playlistEntity)
|
||||||
.show(activity.supportFragmentManager, "DELETE_PLAYLIST")
|
.show(activity.supportFragmentManager, "DELETE_PLAYLIST")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.action_save_playlist -> {
|
R.id.action_save_playlist -> {
|
||||||
//SavePlaylistAsyncTask(activity).execute(playlistWithSongs.songs.toSongs())
|
//SavePlaylistAsyncTask(activity).execute(playlistWithSongs.songs.toSongs())
|
||||||
|
Toast.makeText(activity, "Coming soon", Toast.LENGTH_SHORT).show()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import code.name.monkey.retromusic.EXTRA_ARTIST_ID
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
||||||
import code.name.monkey.retromusic.activities.tageditor.SongTagEditorActivity
|
import code.name.monkey.retromusic.activities.tageditor.SongTagEditorActivity
|
||||||
import code.name.monkey.retromusic.dialogs.AddToRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||||
import code.name.monkey.retromusic.dialogs.SongDetailDialog
|
import code.name.monkey.retromusic.dialogs.SongDetailDialog
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -73,7 +73,7 @@ object SongMenuHelper : KoinComponent {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
AddToRetroPlaylist.create(playlists, song)
|
AddToPlaylistDialog.create(playlists, song)
|
||||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ 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.AddToRetroPlaylist
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
@ -47,7 +47,7 @@ object SongsMenuHelper : KoinComponent {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val playlists = get<RealRepository>().fetchPlaylists()
|
val playlists = get<RealRepository>().fetchPlaylists()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
AddToRetroPlaylist.create(playlists, songs)
|
AddToPlaylistDialog.create(playlists, songs)
|
||||||
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
.show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue