Convert to material dialogs 3
This commit is contained in:
parent
b94e94a636
commit
fb3546cf4b
13 changed files with 360 additions and 307 deletions
|
@ -21,6 +21,7 @@ import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
|
||||||
|
|
||||||
class ClearSmartPlaylistDialog : DialogFragment() {
|
class ClearSmartPlaylistDialog : DialogFragment() {
|
||||||
|
@ -32,7 +33,7 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
val content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist!!.name))
|
val content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist!!.name))
|
||||||
|
|
||||||
return MaterialDialog(activity!!).show {
|
return MaterialDialog(activity!!, BottomSheet()).show {
|
||||||
title(title)
|
title(title)
|
||||||
message(text = content)
|
message(text = content)
|
||||||
positiveButton(R.string.clear_action) {
|
positiveButton(R.string.clear_action) {
|
||||||
|
|
|
@ -14,31 +14,38 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.provider.MediaStore
|
||||||
import android.view.View
|
import android.widget.TextView
|
||||||
import android.view.ViewGroup
|
import androidx.fragment.app.DialogFragment
|
||||||
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.R.layout
|
||||||
|
import code.name.monkey.retromusic.R.string
|
||||||
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 com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_playlist.*
|
import com.afollestad.materialdialogs.WhichButton
|
||||||
|
import com.afollestad.materialdialogs.actions.getActionButton
|
||||||
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
|
import com.afollestad.materialdialogs.customview.getCustomView
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
|
||||||
|
|
||||||
class CreatePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class CreatePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
|
|
||||||
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_playlist, container, false)
|
return inflater.inflate(R.layout.dialog_playlist, container, false)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
/* override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
|
||||||
|
|
||||||
val accentColor = ThemeStore.accentColor(context!!)
|
val accentColor = ThemeStore.accentColor(context!!)
|
||||||
|
|
||||||
|
@ -67,10 +74,45 @@ class CreatePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
}
|
}
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
private lateinit var playlistView: TextInputEditText
|
||||||
|
private lateinit var actionNewPlaylistContainer: TextInputLayout
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val materialDialog = MaterialDialog(activity!!, BottomSheet())
|
||||||
|
.show {
|
||||||
|
title(string.new_playlist_title)
|
||||||
|
customView(layout.dialog_playlist)
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
positiveButton(string.create_action) {
|
||||||
|
if (activity == null) {
|
||||||
|
return@positiveButton
|
||||||
|
}
|
||||||
|
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
||||||
|
|
||||||
|
if (playlistView.text!!.toString().trim { it <= ' ' }.isNotEmpty()) {
|
||||||
|
val playlistId = PlaylistsUtil.createPlaylist(activity!!, playlistView.text!!.toString())
|
||||||
|
if (playlistId != -1 && activity != null) {
|
||||||
|
PlaylistsUtil.addToPlaylist(activity!!, songs, playlistId, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getActionButton(WhichButton.POSITIVE).updateTextColor(ThemeStore.accentColor(context))
|
||||||
|
}
|
||||||
|
|
||||||
|
val dialogView = materialDialog.getCustomView()
|
||||||
|
playlistView = dialogView.findViewById(R.id.actionNewPlaylist)
|
||||||
|
actionNewPlaylistContainer = dialogView.findViewById(R.id.actionNewPlaylistContainer)
|
||||||
|
|
||||||
|
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
||||||
|
|
||||||
|
val playlistId = arguments!!.getLong(MediaStore.Audio.Playlists.Members.PLAYLIST_ID)
|
||||||
|
playlistView.setText(PlaylistsUtil.getNameForPlaylist(context!!, playlistId), TextView.BufferType.EDITABLE)
|
||||||
|
return materialDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val SONGS = "songs"
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun create(song: Song? = null): CreatePlaylistDialog {
|
fun create(song: Song? = null): CreatePlaylistDialog {
|
||||||
val list = ArrayList<Song>()
|
val list = ArrayList<Song>()
|
||||||
|
|
|
@ -14,59 +14,47 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.view.LayoutInflater
|
import androidx.fragment.app.DialogFragment
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.model.Playlist
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_delete.*
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class DeletePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class DeletePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.dialog_delete, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val playlists = arguments!!.getParcelableArrayList<Playlist>("playlist")
|
val playlists = arguments!!.getParcelableArrayList<Playlist>("playlist")
|
||||||
|
val title: Int
|
||||||
val content: CharSequence
|
val content: CharSequence
|
||||||
|
//noinspection ConstantConditions
|
||||||
content = if (playlists!!.size > 1) {
|
if (playlists!!.size > 1) {
|
||||||
Html.fromHtml(getString(R.string.delete_x_playlists, playlists.size))
|
title = string.delete_playlists_title
|
||||||
|
content = Html.fromHtml(getString(string.delete_x_playlists, playlists.size))
|
||||||
} else {
|
} else {
|
||||||
Html.fromHtml(getString(R.string.delete_playlist_x, playlists[0].name))
|
title = string.delete_playlist_title
|
||||||
}
|
content = Html.fromHtml(getString(string.delete_playlist_x, playlists[0].name))
|
||||||
bannerTitle.text = content
|
|
||||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
|
||||||
|
|
||||||
actionDelete.apply {
|
|
||||||
setText(R.string.action_delete)
|
|
||||||
setOnClickListener {
|
|
||||||
PlaylistsUtil.deletePlaylists(context, playlists)
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
MaterialUtil.setTint(this)
|
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_delete_white_24dp)
|
|
||||||
}
|
|
||||||
actionCancel.apply {
|
|
||||||
MaterialUtil.setTint(this, false)
|
|
||||||
setOnClickListener { dismiss() }
|
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_close_white_24dp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return MaterialDialog(activity!!, BottomSheet())
|
||||||
|
.show {
|
||||||
|
title(title)
|
||||||
|
message(text = content)
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
positiveButton(R.string.action_delete) {
|
||||||
|
if (activity == null)
|
||||||
|
return@positiveButton
|
||||||
|
PlaylistsUtil.deletePlaylists(activity!!, playlists)
|
||||||
|
}
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
|
|
@ -14,61 +14,43 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.view.LayoutInflater
|
import androidx.fragment.app.DialogFragment
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
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 com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_delete.*
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
|
||||||
class DeleteSongsDialog : RoundedBottomSheetDialogFragment() {
|
|
||||||
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
class DeleteSongsDialog : DialogFragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
//noinspection unchecked,ConstantConditions
|
|
||||||
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
||||||
|
val title: Int
|
||||||
val content: CharSequence
|
val content: CharSequence
|
||||||
if (songs != null) {
|
if (songs.size > 1) {
|
||||||
content = if (songs.size > 1) {
|
title = R.string.delete_songs_title
|
||||||
getString(R.string.delete_x_songs, songs.size)
|
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size))
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.delete_song_x, songs[0].title)
|
title = R.string.delete_song_title
|
||||||
|
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title))
|
||||||
}
|
}
|
||||||
bannerTitle.text = Html.fromHtml(content)
|
return MaterialDialog(activity!!, BottomSheet()).show {
|
||||||
|
title(title)
|
||||||
|
message(text = content)
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
positiveButton(R.string.action_delete) {
|
||||||
|
if (activity == null)
|
||||||
|
return@positiveButton
|
||||||
|
MusicUtil.deleteTracks(activity!!, songs);
|
||||||
}
|
}
|
||||||
actionDelete.apply {
|
|
||||||
setOnClickListener {
|
|
||||||
if (songs != null) {
|
|
||||||
MusicUtil.deleteTracks(activity!!, songs)
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
MaterialUtil.setTint(this)
|
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_delete_white_24dp)
|
|
||||||
}
|
|
||||||
actionCancel.apply {
|
|
||||||
MaterialUtil.setTint(this, false)
|
|
||||||
setOnClickListener { dismiss() }
|
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_close_white_24dp)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.dialog_delete, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun create(song: Song): DeleteSongsDialog {
|
fun create(song: Song): DeleteSongsDialog {
|
||||||
|
|
|
@ -14,26 +14,21 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.os.Build
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.view.LayoutInflater
|
import androidx.fragment.app.DialogFragment
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
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.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 com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_delete.*
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
|
||||||
|
|
||||||
class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
class RemoveFromPlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
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_delete, container, false)
|
return inflater.inflate(code.name.monkey.retromusic.R.layout.dialog_delete, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
@ -42,18 +37,18 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
val content: CharSequence
|
val content: CharSequence
|
||||||
if (songs!!.size > 1) {
|
if (songs!!.size > 1) {
|
||||||
content = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
content = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size), Html.FROM_HTML_MODE_LEGACY)
|
Html.fromHtml(getString(code.name.monkey.retromusic.R.string.remove_x_songs_from_playlist, songs.size), Html.FROM_HTML_MODE_LEGACY)
|
||||||
} else {
|
} else {
|
||||||
Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size))
|
Html.fromHtml(getString(code.name.monkey.retromusic.R.string.remove_x_songs_from_playlist, songs.size))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs[0].title))
|
content = Html.fromHtml(getString(code.name.monkey.retromusic.R.string.remove_song_x_from_playlist, songs[0].title))
|
||||||
}
|
}
|
||||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||||
bannerTitle.text = content;
|
bannerTitle.text = content;
|
||||||
actionDelete.apply {
|
actionDelete.apply {
|
||||||
setIconResource(R.drawable.ic_delete_white_24dp)
|
setIconResource(code.name.monkey.retromusic.R.drawable.ic_delete_white_24dp)
|
||||||
setText(R.string.remove_action)
|
setText(code.name.monkey.retromusic.R.string.remove_action)
|
||||||
setTextColor(ThemeStore.textColorSecondary(context))
|
setTextColor(ThemeStore.textColorSecondary(context))
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val playlistSongs = ArrayList<PlaylistSong>()
|
val playlistSongs = ArrayList<PlaylistSong>()
|
||||||
|
@ -66,12 +61,39 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
|
|
||||||
|
|
||||||
actionCancel.apply {
|
actionCancel.apply {
|
||||||
setIconResource(R.drawable.ic_close_white_24dp)
|
setIconResource(code.name.monkey.retromusic.R.drawable.ic_close_white_24dp)
|
||||||
setTextColor(ThemeStore.textColorSecondary(context))
|
setTextColor(ThemeStore.textColorSecondary(context))
|
||||||
setOnClickListener { dismiss() }
|
setOnClickListener { dismiss() }
|
||||||
MaterialUtil.setTint(this, false)
|
MaterialUtil.setTint(this, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val songs = arguments!!.getParcelableArrayList<PlaylistSong>("songs")
|
||||||
|
|
||||||
|
val title: Int
|
||||||
|
val content: CharSequence
|
||||||
|
if (songs.size > 1) {
|
||||||
|
title = R.string.remove_songs_from_playlist_title
|
||||||
|
content = Html.fromHtml(getString(code.name.monkey.retromusic.R.string.remove_x_songs_from_playlist, songs.size))
|
||||||
|
} else {
|
||||||
|
title = R.string.remove_song_from_playlist_title
|
||||||
|
content = Html.fromHtml(getString(code.name.monkey.retromusic.R.string.remove_song_x_from_playlist, songs[0].title))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MaterialDialog(activity!!, BottomSheet()).show {
|
||||||
|
title(title)
|
||||||
|
message(text = content)
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
positiveButton(R.string.remove_action) {
|
||||||
|
if (activity == null)
|
||||||
|
return@positiveButton
|
||||||
|
PlaylistsUtil.removeFromPlaylist(activity!!, songs as MutableList<PlaylistSong>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
|
|
@ -14,31 +14,36 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.provider.MediaStore.Audio.Playlists.Members.PLAYLIST_ID
|
||||||
import android.view.View
|
import android.widget.TextView
|
||||||
import android.view.ViewGroup
|
import androidx.fragment.app.DialogFragment
|
||||||
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.R.layout
|
||||||
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_playlist.*
|
import com.afollestad.materialdialogs.WhichButton
|
||||||
|
import com.afollestad.materialdialogs.actions.getActionButton
|
||||||
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
|
import com.afollestad.materialdialogs.customview.getCustomView
|
||||||
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
|
||||||
class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
class RenamePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
|
/*override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_playlist, container, false)
|
return inflater.inflate(R.layout.dialog_playlist, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
|
||||||
bannerTitle.setText(R.string.rename_playlist_title)
|
|
||||||
|
|
||||||
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
||||||
val accentColor = ThemeStore.accentColor(context!!)
|
val accentColor = ThemeStore.accentColor(context!!)
|
||||||
|
@ -70,6 +75,34 @@ class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
MaterialUtil.setTint(this)
|
MaterialUtil.setTint(this)
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_edit_white_24dp)
|
icon = ContextCompat.getDrawable(context, R.drawable.ic_edit_white_24dp)
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
private lateinit var playlistView: TextInputEditText
|
||||||
|
private lateinit var actionNewPlaylistContainer: TextInputLayout
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val materialDialog = MaterialDialog(activity!!, BottomSheet())
|
||||||
|
.show {
|
||||||
|
title(string.rename_playlist_title)
|
||||||
|
customView(layout.dialog_playlist)
|
||||||
|
negativeButton(android.R.string.cancel)
|
||||||
|
positiveButton(string.action_rename) {
|
||||||
|
if (playlistView.toString().trim { it <= ' ' } != "") {
|
||||||
|
val playlistId = arguments!!.getLong(PLAYLIST_ID)
|
||||||
|
PlaylistsUtil.renamePlaylist(context, playlistId, playlistView.text!!.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getActionButton(WhichButton.POSITIVE).updateTextColor(ThemeStore.accentColor(context))
|
||||||
|
}
|
||||||
|
|
||||||
|
val dialogView = materialDialog.getCustomView()
|
||||||
|
playlistView = dialogView.findViewById(R.id.actionNewPlaylist)
|
||||||
|
actionNewPlaylistContainer = dialogView.findViewById(R.id.actionNewPlaylistContainer)
|
||||||
|
|
||||||
|
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
||||||
|
|
||||||
|
val playlistId = arguments!!.getLong(PLAYLIST_ID)
|
||||||
|
playlistView.setText(PlaylistsUtil.getNameForPlaylist(context!!, playlistId), TextView.BufferType.EDITABLE)
|
||||||
|
return materialDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -77,7 +110,7 @@ class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
||||||
fun create(playlistId: Long): RenamePlaylistDialog {
|
fun create(playlistId: Long): RenamePlaylistDialog {
|
||||||
val dialog = RenamePlaylistDialog()
|
val dialog = RenamePlaylistDialog()
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putLong("playlist_id", playlistId)
|
args.putLong(PLAYLIST_ID, playlistId)
|
||||||
dialog.arguments = args
|
dialog.arguments = args
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,22 +14,27 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
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 androidx.annotation.NonNull
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.R.layout
|
||||||
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.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 com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_file_details.*
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
|
import com.afollestad.materialdialogs.customview.getCustomView
|
||||||
import org.jaudiotagger.audio.AudioFileIO
|
import org.jaudiotagger.audio.AudioFileIO
|
||||||
import org.jaudiotagger.audio.exceptions.CannotReadException
|
import org.jaudiotagger.audio.exceptions.CannotReadException
|
||||||
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
|
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
|
||||||
|
@ -38,79 +43,83 @@ import org.jaudiotagger.tag.TagException
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
|
||||||
inline fun ViewGroup.forEach(action: (View) -> Unit) {
|
inline fun ViewGroup.forEach(action: (View) -> Unit) {
|
||||||
for (i in 0 until childCount) {
|
for (i in 0 until childCount) {
|
||||||
action(getChildAt(i))
|
action(getChildAt(i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SongDetailDialog : RoundedBottomSheetDialogFragment() {
|
class SongDetailDialog : DialogFragment() {
|
||||||
|
|
||||||
private fun setTextColor(view: ViewGroup) {
|
|
||||||
view.forEach {
|
|
||||||
if (it is TextView) {
|
|
||||||
it.setTextColor(ThemeStore.textColorPrimary(context!!))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.dialog_file_details, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
val context = context!!
|
|
||||||
|
|
||||||
setTextColor(view as ViewGroup)
|
|
||||||
|
|
||||||
fileName.text = makeTextWithTitle(context, R.string.label_file_name, "-")
|
|
||||||
filePath.text = makeTextWithTitle(context, R.string.label_file_path, "-")
|
|
||||||
fileSize.text = makeTextWithTitle(context, R.string.label_file_size, "-")
|
|
||||||
fileFormat.text = makeTextWithTitle(context, R.string.label_file_format, "-")
|
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, "-")
|
|
||||||
bitrate.text = makeTextWithTitle(context, R.string.label_bit_rate, "-")
|
|
||||||
samplingRate.text = makeTextWithTitle(context, R.string.label_sampling_rate, "-")
|
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val context: Activity = activity!!
|
||||||
val song = arguments!!.getParcelable<Song>("song")
|
val song = arguments!!.getParcelable<Song>("song")
|
||||||
|
|
||||||
|
val materialDialog = MaterialDialog(context, BottomSheet())
|
||||||
|
.show {
|
||||||
|
customView(layout.dialog_file_details,
|
||||||
|
scrollable = true)
|
||||||
|
positiveButton(android.R.string.ok)
|
||||||
|
title(string.action_details)
|
||||||
|
}
|
||||||
|
val dialogView = materialDialog.getCustomView()
|
||||||
|
|
||||||
|
val fileName: TextView = dialogView.findViewById(R.id.fileName)
|
||||||
|
val filePath: TextView = dialogView.findViewById(R.id.filePath)
|
||||||
|
val fileSize: TextView = dialogView.findViewById(R.id.fileSize)
|
||||||
|
val fileFormat: TextView = dialogView.findViewById(R.id.fileFormat)
|
||||||
|
val trackLength: TextView = dialogView.findViewById(R.id.trackLength)
|
||||||
|
val bitRate: TextView = dialogView.findViewById(R.id.bitrate)
|
||||||
|
val samplingRate: TextView = dialogView.findViewById(R.id.samplingRate)
|
||||||
|
|
||||||
|
fileName.text = makeTextWithTitle(context, string.label_file_name, "-")
|
||||||
|
filePath.text = makeTextWithTitle(context, string.label_file_path, "-")
|
||||||
|
fileSize.text = makeTextWithTitle(context, string.label_file_size, "-")
|
||||||
|
fileFormat.text = makeTextWithTitle(context, string.label_file_format, "-")
|
||||||
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, "-")
|
||||||
|
bitRate.text = makeTextWithTitle(context, string.label_bit_rate, "-")
|
||||||
|
samplingRate.text = makeTextWithTitle(context, string.label_sampling_rate, "-")
|
||||||
if (song != null) {
|
if (song != null) {
|
||||||
val songFile = File(song.data)
|
val songFile = File(song.data)
|
||||||
if (songFile.exists()) {
|
if (songFile.exists()) {
|
||||||
fileName.text = makeTextWithTitle(context, R.string.label_file_name, songFile.name)
|
fileName.text = makeTextWithTitle(context, string.label_file_name, songFile.name)
|
||||||
filePath.text = makeTextWithTitle(context, R.string.label_file_path, songFile.absolutePath)
|
filePath.text = makeTextWithTitle(context, string.label_file_path, songFile.absolutePath)
|
||||||
fileSize.text = makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length()))
|
fileSize.text = makeTextWithTitle(context, string.label_file_size, getFileSizeString(songFile.length()))
|
||||||
try {
|
try {
|
||||||
val audioFile = AudioFileIO.read(songFile)
|
val audioFile = AudioFileIO.read(songFile)
|
||||||
val audioHeader = audioFile.audioHeader
|
val audioHeader = audioFile.audioHeader
|
||||||
|
|
||||||
fileFormat.text = makeTextWithTitle(context, R.string.label_file_format, audioHeader.format)
|
fileFormat.text = makeTextWithTitle(context, string.label_file_format, audioHeader.format)
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString((audioHeader.trackLength * 1000).toLong()))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString((audioHeader.trackLength * 1000).toLong()))
|
||||||
bitrate.text = makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.bitRate + " kb/s")
|
bitRate.text = makeTextWithTitle(context, string.label_bit_rate, audioHeader.bitRate + " kb/s")
|
||||||
samplingRate.text = makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.sampleRate + " Hz")
|
samplingRate.text = makeTextWithTitle(context, string.label_sampling_rate, audioHeader.sampleRate + " Hz")
|
||||||
} catch (e: CannotReadException) {
|
} catch (@NonNull e: CannotReadException) {
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
Log.e(TAG, "error while reading the song file", e)
|
||||||
// fallback
|
// fallback
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||||
} catch (e: IOException) {
|
} catch (@NonNull e: IOException) {
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
Log.e(TAG, "error while reading the song file", e)
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||||
} catch (e: TagException) {
|
} catch (@NonNull e: TagException) {
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
Log.e(TAG, "error while reading the song file", e)
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||||
} catch (e: ReadOnlyFileException) {
|
} catch (@NonNull e: ReadOnlyFileException) {
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
Log.e(TAG, "error while reading the song file", e)
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||||
} catch (e: InvalidAudioFrameException) {
|
} catch (@NonNull e: InvalidAudioFrameException) {
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
Log.e(TAG, "error while reading the song file", e)
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// fallback
|
// fallback
|
||||||
fileName.text = makeTextWithTitle(context, R.string.label_file_name, song.title)
|
fileName.text = makeTextWithTitle(context, string.label_file_name, song.title)
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return materialDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -14,25 +14,20 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import androidx.fragment.app.DialogFragment
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
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 com.afollestad.materialdialogs.MaterialDialog
|
||||||
import kotlinx.android.synthetic.main.dialog_file_share.*
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
import com.afollestad.materialdialogs.list.listItems
|
||||||
|
|
||||||
|
|
||||||
class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
class SongShareDialog : DialogFragment() {
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +41,13 @@ class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
||||||
text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||||
setTextColor(ThemeStore.textColorSecondary(context!!))
|
setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
val currentlyListening = getString(code.name.monkey.retromusic.R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||||
activity!!.startActivity(Intent.createChooser(Intent().setAction(Intent.ACTION_SEND)
|
activity!!.startActivity(Intent.createChooser(Intent().setAction(Intent.ACTION_SEND)
|
||||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||||
.setType("text/plain"), null))
|
.setType("text/plain"), null))
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_text_fields_black_24dp)
|
icon = ContextCompat.getDrawable(context, code.name.monkey.retromusic.R.drawable.ic_text_fields_black_24dp)
|
||||||
MaterialUtil.setTint(this)
|
MaterialUtil.setTint(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,10 +57,38 @@ class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
||||||
activity!!.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, context), 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, code.name.monkey.retromusic.R.drawable.ic_share_white_24dp)
|
||||||
MaterialUtil.setTint(this, false)
|
MaterialUtil.setTint(this, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val song: Song = arguments!!.getParcelable("song")
|
||||||
|
val currentlyListening: String = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||||
|
|
||||||
|
return MaterialDialog(activity!!, BottomSheet())
|
||||||
|
.title(R.string.what_do_you_want_to_share)
|
||||||
|
.show {
|
||||||
|
listItems(items = listOf(getString(code.name.monkey.retromusic.R.string.the_audio_file), "\u201C" + currentlyListening + "\u201D")) { dialog, index, text ->
|
||||||
|
when (index) {
|
||||||
|
0 -> {
|
||||||
|
startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, context), null))
|
||||||
|
}
|
||||||
|
1 -> {
|
||||||
|
activity!!.startActivity(
|
||||||
|
Intent.createChooser(
|
||||||
|
Intent()
|
||||||
|
.setAction(Intent.ACTION_SEND)
|
||||||
|
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||||
|
.setType("text/plain"),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -18,6 +18,14 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.loader.app.LoaderManager;
|
||||||
|
import androidx.loader.content.Loader;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.afollestad.materialcab.MaterialCab;
|
import com.afollestad.materialcab.MaterialCab;
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet;
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet;
|
||||||
|
@ -36,13 +44,6 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.loader.app.LoaderManager;
|
|
||||||
import androidx.loader.content.Loader;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||||
|
@ -744,14 +745,20 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
@Override
|
@Override
|
||||||
protected Dialog createDialog(@NonNull Context context) {
|
protected Dialog createDialog(@NonNull Context context) {
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.progress_bar, null);
|
View view = LayoutInflater.from(context).inflate(R.layout.progress_bar, null);
|
||||||
|
view.setBackgroundColor(ThemeStore.Companion.primaryColor(context));
|
||||||
ProgressBar progressBar = view.findViewById(R.id.progressBar);
|
ProgressBar progressBar = view.findViewById(R.id.progressBar);
|
||||||
ViewUtil.INSTANCE.setProgressDrawable(progressBar, ThemeStore.Companion.accentColor(context));
|
TintHelper.setTintAuto(progressBar, ThemeStore.Companion.accentColor(context), false);
|
||||||
|
|
||||||
MaterialDialog materialDialog = new MaterialDialog(context, new BottomSheet());
|
MaterialDialog materialDialog = new MaterialDialog(context, new BottomSheet());
|
||||||
materialDialog.setContentView(view);
|
materialDialog.setContentView(view);
|
||||||
materialDialog.title(R.string.listing_files, "");
|
materialDialog.title(R.string.listing_files, "");
|
||||||
|
materialDialog.setOnCancelListener(dialog -> cancel(false));
|
||||||
|
materialDialog.setOnDismissListener(dialog -> cancel(false));
|
||||||
|
materialDialog.negativeButton(android.R.string.cancel, "", materialDialog1 -> {
|
||||||
|
cancel(false);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
return materialDialog;
|
return materialDialog;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,6 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:ignore="NewApi,RtlSymmetry">
|
tools:ignore="NewApi,RtlSymmetry">
|
||||||
|
|
||||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
|
||||||
android:id="@+id/title"
|
|
||||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:text="@string/action_details"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:ignore="MissingPrefix" />
|
|
||||||
|
|
||||||
|
|
||||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
||||||
android:id="@+id/filePath"
|
android:id="@+id/filePath"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -4,23 +4,14 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
|
||||||
android:id="@+id/bannerTitle"
|
|
||||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:text="@string/new_playlist_title" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/actionNewPlaylistContainer"
|
android:id="@+id/actionNewPlaylistContainer"
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
app:hintEnabled="true">
|
app:hintEnabled="true">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
@ -32,39 +23,4 @@
|
||||||
android:inputType="textPersonName|textCapWords|text"
|
android:inputType="textPersonName|textCapWords|text"
|
||||||
android:padding="16dp" />
|
android:padding="16dp" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/actionCancel"
|
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:paddingStart="24dp"
|
|
||||||
android:paddingTop="12dp"
|
|
||||||
android:paddingEnd="24dp"
|
|
||||||
android:paddingBottom="12dp"
|
|
||||||
android:text="@android:string/cancel"
|
|
||||||
app:icon="@drawable/ic_close_white_24dp"
|
|
||||||
app:strokeWidth="2dp" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/actionCreate"
|
|
||||||
style="@style/Widget.MaterialComponents.Button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:paddingStart="24dp"
|
|
||||||
android:paddingTop="12dp"
|
|
||||||
android:paddingEnd="24dp"
|
|
||||||
android:paddingBottom="12dp"
|
|
||||||
android:text="@string/create_action"
|
|
||||||
app:backgroundTint="@color/md_pink_A400"
|
|
||||||
app:icon="@drawable/ic_playlist_add_white_24dp" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -2,13 +2,13 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||||
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
|
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
|
|
|
@ -150,7 +150,8 @@
|
||||||
<string name="delete_song_x"><![CDATA[Delete the song <b>%1$s</b>?]]></string>
|
<string name="delete_song_x"><![CDATA[Delete the song <b>%1$s</b>?]]></string>
|
||||||
<string name="delete_x_playlists"><![CDATA[Delete <b>%1$d</b> playlists?]]></string>
|
<string name="delete_x_playlists"><![CDATA[Delete <b>%1$d</b> playlists?]]></string>
|
||||||
<string name="delete_x_songs"><![CDATA[Delete <b>%1$d</b> songs?]]></string>
|
<string name="delete_x_songs"><![CDATA[Delete <b>%1$d</b> songs?]]></string>
|
||||||
|
<string name="delete_song_title">Delete song</string>
|
||||||
|
<string name="delete_songs_title">Delete songs</string>
|
||||||
<string name="deleted_x_songs">Deleted %1$d songs.</string>
|
<string name="deleted_x_songs">Deleted %1$d songs.</string>
|
||||||
|
|
||||||
<string name="discord_page">Discord</string>
|
<string name="discord_page">Discord</string>
|
||||||
|
|
Loading…
Reference in a new issue