Fix depricated issues
This commit is contained in:
parent
98ead185d5
commit
6966351113
13 changed files with 46 additions and 60 deletions
|
@ -16,7 +16,7 @@ package code.name.monkey.retromusic.dialogs
|
|||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.string
|
||||
|
@ -37,14 +37,18 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
if (songs != null) {
|
||||
if (songs.size > 1) {
|
||||
title = R.string.remove_songs_from_playlist_title
|
||||
content = Html.fromHtml(getString(string.remove_x_songs_from_playlist, songs.size))
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(string.remove_x_songs_from_playlist, songs.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = R.string.remove_song_from_playlist_title
|
||||
content = Html.fromHtml(
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(
|
||||
code.name.monkey.retromusic.R.string.remove_song_x_from_playlist,
|
||||
songs[0].title
|
||||
)
|
||||
),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +62,10 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
positiveButton(R.string.remove_action) {
|
||||
if (activity == null)
|
||||
return@positiveButton
|
||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs as MutableList<PlaylistSong>)
|
||||
PlaylistsUtil.removeFromPlaylist(
|
||||
requireContext(),
|
||||
songs as MutableList<PlaylistSong>
|
||||
)
|
||||
}
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
negativeButton(android.R.string.cancel)
|
||||
positiveButton(string.action_rename) {
|
||||
if (playlistView.toString().trim { it <= ' ' } != "") {
|
||||
val playlistId = arguments!!.getLong(PLAYLIST_ID)
|
||||
val playlistId = requireArguments().getLong(PLAYLIST_ID)
|
||||
PlaylistsUtil.renamePlaylist(
|
||||
context,
|
||||
playlistId,
|
||||
|
|
|
@ -72,12 +72,12 @@ class SleepTimerDialog : DialogFragment() {
|
|||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.getInstance(requireContext())
|
||||
.setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val am = requireContext().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),
|
||||
requireContext(),
|
||||
requireContext().resources.getString(R.string.sleep_timer_set, minutes),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -87,12 +87,13 @@ class SleepTimerDialog : DialogFragment() {
|
|||
}
|
||||
val previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE)
|
||||
if (previous != null) {
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val am =
|
||||
requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.cancel(previous)
|
||||
previous.cancel()
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_canceled),
|
||||
requireContext(),
|
||||
requireContext().resources.getString(R.string.sleep_timer_canceled),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -101,8 +102,8 @@ class SleepTimerDialog : DialogFragment() {
|
|||
if (musicService != null && musicService.pendingQuit) {
|
||||
musicService.pendingQuit = false
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_canceled),
|
||||
requireContext(),
|
||||
requireContext().resources.getString(R.string.sleep_timer_canceled),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -166,11 +167,11 @@ class SleepTimerDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun makeTimerPendingIntent(flag: Int): PendingIntent? {
|
||||
return PendingIntent.getService(activity, 0, makeTimerIntent(), flag)
|
||||
return PendingIntent.getService(requireActivity(), 0, makeTimerIntent(), flag)
|
||||
}
|
||||
|
||||
private fun makeTimerIntent(): Intent {
|
||||
val intent = Intent(activity, MusicService::class.java)
|
||||
val intent = Intent(requireActivity(), MusicService::class.java)
|
||||
return if (shouldFinishLastSong.isChecked) {
|
||||
intent.setAction(ACTION_PENDING_QUIT)
|
||||
} else intent.setAction(ACTION_QUIT)
|
||||
|
@ -192,11 +193,11 @@ class SleepTimerDialog : DialogFragment() {
|
|||
) {
|
||||
|
||||
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) + ")"
|
||||
)
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = String.format(
|
||||
"%s %s",
|
||||
materialDialog.context.getString(R.string.cancel_current_timer),
|
||||
" (" + MusicUtil.getReadableDurationString(millisUntilFinished) + ")"
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
|
|
|
@ -17,13 +17,13 @@ package code.name.monkey.retromusic.dialogs
|
|||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.text.Spanned
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.string
|
||||
|
@ -53,7 +53,7 @@ class SongDetailDialog : DialogFragment() {
|
|||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val context: Context = requireContext()
|
||||
val song = arguments!!.getParcelable<Song>("song")
|
||||
val song = requireArguments().getParcelable<Song>("song")
|
||||
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
|
@ -180,7 +180,10 @@ class SongDetailDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun makeTextWithTitle(context: Context, titleResId: Int, text: String?): Spanned {
|
||||
return Html.fromHtml("<b>" + context.resources.getString(titleResId) + ": " + "</b>" + text)
|
||||
return HtmlCompat.fromHtml(
|
||||
"<b>" + context.resources.getString(titleResId) + ": " + "</b>" + text,
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
|
||||
private fun getFileSizeString(sizeInBytes: Long): String {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.afollestad.materialdialogs.list.listItems
|
|||
|
||||
class SongShareDialog : DialogFragment() {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val song: Song? = arguments?.getParcelable("song")
|
||||
val song: Song? = requireArguments().getParcelable("song")
|
||||
val currentlyListening: String =
|
||||
getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue