Text corrections
This commit is contained in:
parent
f6ff0f6565
commit
c35d86bfd6
28 changed files with 260 additions and 248 deletions
|
@ -230,20 +230,22 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
|
||||
override fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
|
||||
if (lastFmAlbum.album.wiki != null) {
|
||||
aboutAlbumText.show()
|
||||
aboutAlbumTitle.show()
|
||||
aboutAlbumTitle.text = String.format("About %s", lastFmAlbum.album.name)
|
||||
aboutAlbumText.text = lastFmAlbum.album.wiki.content
|
||||
}
|
||||
if (lastFmAlbum.album.listeners.isNotEmpty()) {
|
||||
listeners.show()
|
||||
listenersLabel.show()
|
||||
scrobbles.show()
|
||||
scrobblesLabel.show()
|
||||
if (lastFmAlbum.album != null) {
|
||||
if (lastFmAlbum.album.wiki != null) {
|
||||
aboutAlbumText.show()
|
||||
aboutAlbumTitle.show()
|
||||
aboutAlbumTitle.text = String.format("About %s", lastFmAlbum.album.name)
|
||||
aboutAlbumText.text = lastFmAlbum.album.wiki.content
|
||||
}
|
||||
if (lastFmAlbum.album.listeners.isNotEmpty()) {
|
||||
listeners.show()
|
||||
listenersLabel.show()
|
||||
scrobbles.show()
|
||||
scrobblesLabel.show()
|
||||
|
||||
listeners.text = RetroUtil.formatValue(lastFmAlbum.album.listeners.toFloat())
|
||||
scrobbles.text = RetroUtil.formatValue(lastFmAlbum.album.playcount.toFloat())
|
||||
listeners.text = RetroUtil.formatValue(lastFmAlbum.album.listeners.toFloat())
|
||||
scrobbles.text = RetroUtil.formatValue(lastFmAlbum.album.playcount.toFloat())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import java.util.*
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class DeletePlaylistDialog : DialogFragment() {
|
||||
|
||||
|
@ -45,18 +44,18 @@ class DeletePlaylistDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
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)
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
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 {
|
||||
|
@ -75,5 +74,4 @@ class DeletePlaylistDialog : DialogFragment() {
|
|||
return dialog
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ import android.os.Bundle
|
|||
import android.text.Html
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.string
|
||||
import code.name.monkey.retromusic.model.PlaylistSong
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
@ -26,7 +27,6 @@ import com.afollestad.materialdialogs.LayoutMode
|
|||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
|
||||
|
||||
class RemoveFromPlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
@ -37,27 +37,31 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
if (songs != null) {
|
||||
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))
|
||||
content = Html.fromHtml(getString(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))
|
||||
content = Html.fromHtml(
|
||||
getString(
|
||||
code.name.monkey.retromusic.R.string.remove_song_x_from_playlist,
|
||||
songs[0].title
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.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>)
|
||||
}
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
.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>)
|
||||
}
|
||||
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -34,25 +34,24 @@ import com.afollestad.materialdialogs.customview.getCustomView
|
|||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
|
||||
|
||||
class RenamePlaylistDialog : DialogFragment() {
|
||||
private lateinit var playlistView: TextInputEditText
|
||||
private lateinit var actionNewPlaylistContainer: TextInputLayout
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
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())
|
||||
}
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dialogView = materialDialog.getCustomView()
|
||||
playlistView = dialogView.findViewById(R.id.actionNewPlaylist)
|
||||
|
@ -61,7 +60,8 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
||||
|
||||
val playlistId = arguments!!.getLong(PLAYLIST_ID)
|
||||
playlistView.appHandleColor().setText(PlaylistsUtil.getNameForPlaylist(context!!, playlistId), TextView.BufferType.EDITABLE)
|
||||
playlistView.appHandleColor()
|
||||
.setText(PlaylistsUtil.getNameForPlaylist(context!!, playlistId), TextView.BufferType.EDITABLE)
|
||||
return materialDialog
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ import com.afollestad.materialdialogs.callbacks.onShow
|
|||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.afollestad.materialdialogs.customview.getCustomView
|
||||
|
||||
|
||||
class SleepTimerDialog : DialogFragment() {
|
||||
|
||||
private var seekArcProgress: Int = 0
|
||||
|
@ -60,48 +59,61 @@ class SleepTimerDialog : DialogFragment() {
|
|||
timerUpdater = TimerUpdater()
|
||||
|
||||
materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.title(R.string.action_sleep_timer)
|
||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
.positiveButton(R.string.action_set) {
|
||||
PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic = shouldFinishLastSong.isChecked
|
||||
.title(R.string.action_sleep_timer)
|
||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
.positiveButton(R.string.action_set) {
|
||||
PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic = shouldFinishLastSong.isChecked
|
||||
|
||||
val minutes = seekArcProgress
|
||||
val minutes = seekArcProgress
|
||||
|
||||
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
|
||||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.getInstance(requireContext()).setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
|
||||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.getInstance(requireContext())
|
||||
.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()
|
||||
}
|
||||
.negativeButton(android.R.string.cancel) {
|
||||
if (activity == null) {
|
||||
return@negativeButton
|
||||
}
|
||||
val previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE)
|
||||
if (previous != null) {
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
|
||||
am.cancel(previous)
|
||||
previous.cancel()
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_canceled),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
Toast.makeText(activity, activity!!.resources.getString(R.string.sleep_timer_set, minutes), Toast.LENGTH_SHORT).show()
|
||||
val musicService = MusicPlayerRemote.musicService
|
||||
if (musicService != null && musicService.pendingQuit) {
|
||||
musicService.pendingQuit = false
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_canceled),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
.negativeButton(android.R.string.cancel) {
|
||||
if (activity == null) {
|
||||
return@negativeButton
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
val musicService = MusicPlayerRemote.musicService
|
||||
if (musicService != null && musicService.pendingQuit) {
|
||||
musicService.pendingQuit = false
|
||||
Toast.makeText(activity, activity!!.resources.getString(R.string.sleep_timer_canceled), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
.customView(R.layout.dialog_sleep_timer, scrollable = false)
|
||||
.show {
|
||||
onShow {
|
||||
if (makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE) != null) {
|
||||
timerUpdater.start()
|
||||
}
|
||||
}
|
||||
.customView(R.layout.dialog_sleep_timer, scrollable = false)
|
||||
.show {
|
||||
onShow {
|
||||
if (makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE) != null) {
|
||||
timerUpdater.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activity == null || materialDialog.getCustomView() == null) {
|
||||
return materialDialog
|
||||
|
@ -133,7 +145,6 @@ class SleepTimerDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
|
@ -148,7 +159,6 @@ class SleepTimerDialog : DialogFragment() {
|
|||
timerDisplay.text = "$seekArcProgress min"
|
||||
}
|
||||
|
||||
|
||||
private fun makeTimerPendingIntent(flag: Int): PendingIntent? {
|
||||
return PendingIntent.getService(activity, 0, makeTimerIntent(), flag)
|
||||
}
|
||||
|
@ -160,22 +170,27 @@ class SleepTimerDialog : DialogFragment() {
|
|||
} else intent.setAction(ACTION_QUIT)
|
||||
}
|
||||
|
||||
|
||||
private fun updateCancelButton() {
|
||||
val musicService = MusicPlayerRemote.musicService
|
||||
if (musicService != null && musicService.pendingQuit) {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = materialDialog.context.getString(R.string.cancel_current_timer)
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text =
|
||||
materialDialog.context.getString(R.string.cancel_current_timer)
|
||||
} else {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = null
|
||||
}
|
||||
}
|
||||
|
||||
private inner class TimerUpdater internal constructor() : CountDownTimer(PreferenceUtil.getInstance(requireContext()).nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(), 1000) {
|
||||
private inner class TimerUpdater internal constructor() : CountDownTimer(
|
||||
PreferenceUtil.getInstance(requireContext()).nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(),
|
||||
1000
|
||||
) {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text =
|
||||
String.format("%s %s", materialDialog.context.getString(R.string.cancel_current_timer),
|
||||
" (" + MusicUtil.getReadableDurationString(millisUntilFinished) + ")")
|
||||
String.format(
|
||||
"%s %s", materialDialog.context.getString(R.string.cancel_current_timer),
|
||||
" (" + MusicUtil.getReadableDurationString(millisUntilFinished) + ")"
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.jaudiotagger.tag.TagException
|
|||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
inline fun ViewGroup.forEach(action: (View) -> Unit) {
|
||||
for (i in 0 until childCount) {
|
||||
action(getChildAt(i))
|
||||
|
@ -57,13 +56,15 @@ class SongDetailDialog : DialogFragment() {
|
|||
val song = arguments!!.getParcelable<Song>("song")
|
||||
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
customView(R.layout.dialog_file_details,
|
||||
scrollable = true)
|
||||
positiveButton(android.R.string.ok)
|
||||
title(string.action_details)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
.show {
|
||||
customView(
|
||||
R.layout.dialog_file_details,
|
||||
scrollable = true
|
||||
)
|
||||
positiveButton(android.R.string.ok)
|
||||
title(string.action_details)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
val dialogView = materialDialog.getCustomView()
|
||||
|
||||
val fileName: TextView = dialogView.findViewById(R.id.fileName)
|
||||
|
@ -86,37 +87,66 @@ class SongDetailDialog : DialogFragment() {
|
|||
if (songFile.exists()) {
|
||||
fileName.text = makeTextWithTitle(context, string.label_file_name, songFile.name)
|
||||
filePath.text = makeTextWithTitle(context, string.label_file_path, songFile.absolutePath)
|
||||
fileSize.text = makeTextWithTitle(context, string.label_file_size, getFileSizeString(songFile.length()))
|
||||
fileSize.text =
|
||||
makeTextWithTitle(context, string.label_file_size, getFileSizeString(songFile.length()))
|
||||
try {
|
||||
val audioFile = AudioFileIO.read(songFile)
|
||||
val audioHeader = audioFile.audioHeader
|
||||
|
||||
fileFormat.text = makeTextWithTitle(context, string.label_file_format, audioHeader.format)
|
||||
trackLength.text = makeTextWithTitle(context, 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, string.label_bit_rate, audioHeader.bitRate + " kb/s")
|
||||
samplingRate.text = makeTextWithTitle(context, string.label_sampling_rate, audioHeader.sampleRate + " Hz")
|
||||
samplingRate.text =
|
||||
makeTextWithTitle(context, string.label_sampling_rate, audioHeader.sampleRate + " Hz")
|
||||
} catch (@NonNull e: CannotReadException) {
|
||||
Log.e(TAG, "error while reading the song file", e)
|
||||
// fallback
|
||||
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||
trackLength.text = makeTextWithTitle(
|
||||
context,
|
||||
string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)
|
||||
)
|
||||
} catch (@NonNull e: IOException) {
|
||||
Log.e(TAG, "error while reading the song file", e)
|
||||
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||
trackLength.text = makeTextWithTitle(
|
||||
context,
|
||||
string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)
|
||||
)
|
||||
} catch (@NonNull e: TagException) {
|
||||
Log.e(TAG, "error while reading the song file", e)
|
||||
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||
trackLength.text = makeTextWithTitle(
|
||||
context,
|
||||
string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)
|
||||
)
|
||||
} catch (@NonNull e: ReadOnlyFileException) {
|
||||
Log.e(TAG, "error while reading the song file", e)
|
||||
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||
trackLength.text = makeTextWithTitle(
|
||||
context,
|
||||
string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)
|
||||
)
|
||||
} catch (@NonNull e: InvalidAudioFrameException) {
|
||||
Log.e(TAG, "error while reading the song file", e)
|
||||
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||
trackLength.text = makeTextWithTitle(
|
||||
context,
|
||||
string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
// fallback
|
||||
fileName.text = makeTextWithTitle(context, string.label_file_name, song.title)
|
||||
trackLength.text = makeTextWithTitle(context, string.label_track_length, MusicUtil.getReadableDurationString(song.duration))
|
||||
trackLength.text = makeTextWithTitle(
|
||||
context,
|
||||
string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +157,6 @@ class SongDetailDialog : DialogFragment() {
|
|||
|
||||
val TAG: String = SongDetailDialog::class.java.simpleName
|
||||
|
||||
|
||||
fun create(song: Song): SongDetailDialog {
|
||||
val dialog = SongDetailDialog()
|
||||
val args = Bundle()
|
||||
|
|
|
@ -27,35 +27,45 @@ import com.afollestad.materialdialogs.MaterialDialog
|
|||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
|
||||
|
||||
class SongShareDialog : DialogFragment() {
|
||||
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)
|
||||
val currentlyListening: String =
|
||||
getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName)
|
||||
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.title(R.string.what_do_you_want_to_share)
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
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(song?.let { MusicUtil.createShareSongFileIntent(it, context) }, null))
|
||||
}
|
||||
1 -> {
|
||||
activity!!.startActivity(
|
||||
Intent.createChooser(
|
||||
Intent()
|
||||
.setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"),
|
||||
null
|
||||
)
|
||||
.title(R.string.what_do_you_want_to_share)
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
listItems(
|
||||
items = listOf(
|
||||
getString(code.name.monkey.retromusic.R.string.the_audio_file),
|
||||
"\u201C" + currentlyListening + "\u201D"
|
||||
)
|
||||
) { _, index, _ ->
|
||||
when (index) {
|
||||
0 -> {
|
||||
startActivity(Intent.createChooser(song?.let {
|
||||
MusicUtil.createShareSongFileIntent(
|
||||
it,
|
||||
context
|
||||
)
|
||||
}
|
||||
}, null))
|
||||
}
|
||||
1 -> {
|
||||
activity!!.startActivity(
|
||||
Intent.createChooser(
|
||||
Intent()
|
||||
.setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"),
|
||||
null
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class PlaylistsUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean doPlaylistContains(@NonNull final Context context, final long playlistId,
|
||||
static boolean doPlaylistContains(@NonNull final Context context, final long playlistId,
|
||||
final int songId) {
|
||||
if (playlistId != -1) {
|
||||
try {
|
||||
|
@ -156,12 +156,6 @@ public class PlaylistsUtil {
|
|||
new String[]{String.valueOf(playlistId)});
|
||||
}
|
||||
|
||||
public static boolean doesPlaylistExist(@NonNull final Context context, final String name) {
|
||||
return doesPlaylistExist(context,
|
||||
MediaStore.Audio.PlaylistsColumns.NAME + "=?",
|
||||
new String[]{name});
|
||||
}
|
||||
|
||||
public static String getNameForPlaylist(@NonNull final Context context, final long id) {
|
||||
try {
|
||||
Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI,
|
||||
|
|
|
@ -23,24 +23,20 @@ import com.google.android.material.card.MaterialCardView
|
|||
* Created by hemanths on 3/18/19
|
||||
*/
|
||||
class WidthFitSquareCardView : MaterialCardView {
|
||||
constructor(context: Context) : super(context) {}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
) : super(context, attrs)
|
||||
|
||||
fun forceSquare(z: Boolean) {
|
||||
this.forceSquare = z
|
||||
requestLayout()
|
||||
constructor(
|
||||
context: Context, attrs:
|
||||
AttributeSet, defStyleAttr: Int
|
||||
) : super(context, attrs, defStyleAttr)
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec)
|
||||
}
|
||||
|
||||
override fun onMeasure(i: Int, i2: Int) {
|
||||
var width = i2
|
||||
if (this.forceSquare) {
|
||||
width = i
|
||||
}
|
||||
super.onMeasure(i, width)
|
||||
}
|
||||
|
||||
private var forceSquare = true
|
||||
}
|
||||
|
|
|
@ -1,48 +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.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class WidthFitSquareLayout extends FrameLayout {
|
||||
|
||||
public WidthFitSquareLayout(@NonNull final Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WidthFitSquareLayout(@NonNull final Context context, @Nullable final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public WidthFitSquareLayout(@NonNull final Context context, @Nullable final AttributeSet attrs,
|
||||
final int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public WidthFitSquareLayout(@NonNull final Context context, @Nullable final AttributeSet attrs,
|
||||
final int defStyleAttr,
|
||||
final int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
||||
}
|
||||
}
|
37
app/src/main/java/code/name/monkey/retromusic/views/WidthFitSquareLayout.kt
Executable file
37
app/src/main/java/code/name/monkey/retromusic/views/WidthFitSquareLayout.kt
Executable file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
|
||||
class WidthFitSquareLayout : FrameLayout {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(
|
||||
context: Context, attrs: AttributeSet?,
|
||||
defStyleAttr: Int
|
||||
) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(
|
||||
context: Context, attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue