Refactor
This commit is contained in:
parent
63c417cd61
commit
a81536ab9a
96 changed files with 729 additions and 724 deletions
|
@ -5,12 +5,14 @@ import android.text.Html
|
|||
import android.view.LayoutInflater
|
||||
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.model.Playlist
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||
import kotlinx.android.synthetic.main.dialog_remove_from_playlist.*
|
||||
import kotlinx.android.synthetic.main.dialog_delete.*
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
@ -18,7 +20,7 @@ class DeletePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.dialog_remove_from_playlist, container, false)
|
||||
return inflater.inflate(R.layout.dialog_delete, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -32,17 +34,22 @@ class DeletePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
} else {
|
||||
Html.fromHtml(getString(R.string.delete_playlist_x, playlists[0].name))
|
||||
}
|
||||
bannerTitle.text = content
|
||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
dialogTitle.text = content
|
||||
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
|
||||
actionRemove.setText(R.string.action_delete)
|
||||
actionRemove.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
actionCancel.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
|
||||
actionCancel.setOnClickListener { dismiss() }
|
||||
actionRemove.setOnClickListener {
|
||||
PlaylistsUtil.deletePlaylists(activity!!, playlists)
|
||||
dismiss()
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.text.Html
|
|||
import android.view.LayoutInflater
|
||||
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
|
||||
|
@ -19,28 +20,33 @@ class DeleteSongsDialog : RoundedBottomSheetDialogFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
title.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
MaterialUtil.setTint(actionDelete)
|
||||
MaterialUtil.setTint(actionCancel)
|
||||
|
||||
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
//noinspection unchecked,ConstantConditions
|
||||
val songs = arguments!!.getParcelableArrayList<Song>("songs")
|
||||
val content: CharSequence
|
||||
if (songs != null) {
|
||||
content = if (songs.size > 1) {
|
||||
Html.fromHtml(getString(R.string.delete_x_songs, songs.size))
|
||||
getString(R.string.delete_x_songs, songs.size)
|
||||
} else {
|
||||
Html.fromHtml(getString(R.string.delete_song_x, songs[0].title))
|
||||
getString(R.string.delete_song_x, songs[0].title)
|
||||
}
|
||||
this.title.text = content
|
||||
dialogTitle.text = content
|
||||
}
|
||||
actionDelete.setOnClickListener {
|
||||
if (songs != null) {
|
||||
MusicUtil.deleteTracks(activity!!, songs)
|
||||
actionDelete.apply {
|
||||
setOnClickListener {
|
||||
if (songs != null) {
|
||||
MusicUtil.deleteTracks(activity!!, songs)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
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)
|
||||
}
|
||||
actionCancel.setOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,11 +58,7 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionBuyPro.let {
|
||||
it.visibility = if (!App.isProVersion) View.VISIBLE else View.GONE
|
||||
it.iconTint = ColorStateList.valueOf(ThemeStore.accentColor(it.context))
|
||||
it.setTextColor(ColorStateList.valueOf(ThemeStore.accentColor(it.context)))
|
||||
}
|
||||
|
||||
text!!.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
titleWelcome!!.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
titleWelcome!!.text = String.format("%s %s!", timeOfTheDay, PreferenceUtil.getInstance().userName)
|
||||
|
@ -76,8 +72,14 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
|
|||
actionFolders.setOnClickListener(this)
|
||||
actionRate.setOnClickListener(this)
|
||||
actionShare.setOnClickListener(this)
|
||||
actionBuyPro.setOnClickListener(this)
|
||||
actionBugReport.setOnClickListener(this)
|
||||
buyProContainer.apply {
|
||||
setCardBackgroundColor(ThemeStore.accentColor(context!!))
|
||||
visibility = if (!App.isProVersion) View.VISIBLE else View.GONE
|
||||
setOnClickListener {
|
||||
NavigationUtil.goToProVersion(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,7 +99,7 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
|
|||
R.id.actionShare -> shareApp()
|
||||
R.id.actionBugReport -> prepareBugReport()
|
||||
R.id.actionEqualizer -> NavigationUtil.openEqualizer(mainActivity)
|
||||
R.id.actionBuyPro -> NavigationUtil.goToProVersion(mainActivity)
|
||||
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.ViewGroup
|
|||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
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.views.RoundedBottomSheetDialogFragment
|
||||
import kotlinx.android.synthetic.main.dialog_remove_from_playlist.*
|
||||
|
@ -40,18 +39,23 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
title = R.string.remove_song_from_playlist_title
|
||||
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs[0].title))
|
||||
}
|
||||
actionRemove.text = content
|
||||
bannerTitle.setText(title)
|
||||
|
||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
actionRemove.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
actionCancel.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
|
||||
actionRemove.setOnClickListener {
|
||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs)
|
||||
dismiss()
|
||||
actionDelete.apply {
|
||||
text = content
|
||||
setTextColor(ThemeStore.textColorSecondary(context))
|
||||
setOnClickListener {
|
||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
bannerTitle.apply {
|
||||
setText(title)
|
||||
setTextColor(ThemeStore.textColorPrimary(context))
|
||||
}
|
||||
|
||||
actionCancel.apply {
|
||||
setTextColor(ThemeStore.textColorSecondary(context))
|
||||
setOnClickListener { dismiss() }
|
||||
}
|
||||
actionCancel.setOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
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
|
||||
|
@ -23,10 +24,8 @@ class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val accentColor = ThemeStore.accentColor(context!!)
|
||||
actionCreate.setText(R.string.action_rename)
|
||||
|
||||
MaterialUtil.setTint(actionCreate, true)
|
||||
MaterialUtil.setTint(actionCancel, false)
|
||||
|
||||
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
||||
|
||||
actionNewPlaylist.apply {
|
||||
|
@ -41,12 +40,22 @@ class RenamePlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
|
||||
bannerTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
bannerTitle.setText(R.string.rename_playlist_title)
|
||||
actionCancel.setOnClickListener { dismiss() }
|
||||
actionCreate.setOnClickListener {
|
||||
if (actionNewPlaylist.toString().trim { it <= ' ' } != "") {
|
||||
val playlistId = arguments!!.getLong("playlist_id")
|
||||
PlaylistsUtil.renamePlaylist(context!!, playlistId, actionNewPlaylist.text!!.toString())
|
||||
actionCancel.apply {
|
||||
MaterialUtil.setTint(actionCancel, false)
|
||||
setOnClickListener { dismiss() }
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_close_white_24dp)
|
||||
}
|
||||
|
||||
actionCreate.apply {
|
||||
setText(R.string.action_rename)
|
||||
setOnClickListener {
|
||||
if (actionNewPlaylist.toString().trim { it <= ' ' } != "") {
|
||||
val playlistId = arguments!!.getLong("playlist_id")
|
||||
PlaylistsUtil.renamePlaylist(context!!, playlistId, actionNewPlaylist.text!!.toString())
|
||||
}
|
||||
}
|
||||
MaterialUtil.setTint(this)
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_edit_white_24dp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.SeekBar
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.Constants.ACTION_QUIT
|
||||
|
@ -45,7 +46,6 @@ class SleepTimerDialog : RoundedBottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
return inflater.inflate(R.layout.dialog_sleep_timer, container, false)
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class SleepTimerDialog : RoundedBottomSheetDialogFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
MaterialUtil.setTint(actionSet, true)
|
||||
|
||||
MaterialUtil.setTint(actionCancel, false)
|
||||
|
||||
title.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
|
@ -88,26 +88,32 @@ class SleepTimerDialog : RoundedBottomSheetDialogFragment() {
|
|||
}
|
||||
})
|
||||
|
||||
actionCancel.setOnClickListener {
|
||||
|
||||
val previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE)
|
||||
if (previous != null) {
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.cancel(previous)
|
||||
previous.cancel()
|
||||
Toast.makeText(activity, activity!!.resources.getString(R.string.sleep_timer_canceled), Toast.LENGTH_SHORT).show()
|
||||
actionCancel.apply {
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_close_white_24dp)
|
||||
setOnClickListener {
|
||||
val previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE)
|
||||
if (previous != null) {
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.cancel(previous)
|
||||
previous.cancel()
|
||||
Toast.makeText(activity, activity!!.resources.getString(R.string.sleep_timer_canceled), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
actionSet.setOnClickListener {
|
||||
val minutes = seekArcProgress
|
||||
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.getInstance().setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
|
||||
Toast.makeText(activity, activity!!.resources.getString(R.string.sleep_timer_set, minutes), Toast.LENGTH_SHORT).show()
|
||||
dismiss()
|
||||
actionSet.apply {
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_time_lapse_white_24dp)
|
||||
MaterialUtil.setTint(actionSet)
|
||||
setOnClickListener {
|
||||
val minutes = seekArcProgress
|
||||
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.getInstance().setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
|
||||
Toast.makeText(activity, activity!!.resources.getString(R.string.sleep_timer_set, minutes), Toast.LENGTH_SHORT).show()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,41 +6,50 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
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.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||
import kotlinx.android.synthetic.main.dialog_file_share.*
|
||||
import kotlinx.android.synthetic.main.dialog_delete.*
|
||||
|
||||
|
||||
class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
||||
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_delete, container, false)
|
||||
}
|
||||
|
||||
@SuppressLint("StringFormatInvalid")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val song = arguments!!.getParcelable<Song>("song")!!
|
||||
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
|
||||
audioText.text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||
audioFile.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
audioText.setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
title.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
|
||||
audioFile.setOnClickListener {
|
||||
MusicUtil.createShareSongFileIntent(song, context)
|
||||
dismiss()
|
||||
}
|
||||
audioText.setOnClickListener {
|
||||
val currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||
activity!!.startActivity(Intent.createChooser(Intent().setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"), null))
|
||||
dismiss()
|
||||
actionDelete.apply {
|
||||
text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||
setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
setOnClickListener {
|
||||
val currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||
activity!!.startActivity(Intent.createChooser(Intent().setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"), null))
|
||||
dismiss()
|
||||
}
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_text_fields_black_24dp)
|
||||
MaterialUtil.setTint(this)
|
||||
}
|
||||
|
||||
actionCancel.apply {
|
||||
setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
setOnClickListener {
|
||||
MusicUtil.createShareSongFileIntent(song, context)
|
||||
dismiss()
|
||||
}
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_share_white_24dp)
|
||||
MaterialUtil.setTint(this, false)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue