Fix depricated issues
This commit is contained in:
parent
ce98c82fc5
commit
98ead185d5
8 changed files with 33 additions and 130 deletions
|
@ -43,7 +43,8 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
title(R.string.add_playlist_title)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
listItems(items = playlistNames) { dialog, index, _ ->
|
||||
val songs = arguments!!.getParcelableArrayList<Song>("songs") ?: return@listItems
|
||||
val songs =
|
||||
requireArguments().getParcelableArrayList<Song>("songs") ?: return@listItems
|
||||
if (index == 0) {
|
||||
dialog.dismiss()
|
||||
activity?.supportFragmentManager?.let {
|
||||
|
|
|
@ -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.model.smartplaylist.AbsSmartPlaylist
|
||||
|
@ -30,10 +30,13 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
|||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
||||
val playlist = arguments!!.getParcelable<AbsSmartPlaylist>("playlist")
|
||||
val playlist = requireArguments().getParcelable<AbsSmartPlaylist>("playlist")
|
||||
val title = R.string.clear_playlist_title
|
||||
|
||||
val content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist!!.name))
|
||||
val content = HtmlCompat.fromHtml(
|
||||
getString(R.string.clear_playlist_x, playlist!!.name),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(title)
|
||||
|
@ -43,7 +46,7 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
|||
if (activity == null) {
|
||||
return@positiveButton
|
||||
}
|
||||
playlist.clear(activity!!)
|
||||
playlist.clear(requireActivity())
|
||||
}
|
||||
negativeButton { (android.R.string.cancel) }
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
if (activity == null) {
|
||||
return@positiveButton
|
||||
}
|
||||
val songs = arguments?.getParcelableArrayList<Song>("songs")
|
||||
val songs = requireArguments().getParcelableArrayList<Song>("songs")
|
||||
?: return@positiveButton
|
||||
|
||||
if (playlistView.text.toString().trim { it <= ' ' }.isNotEmpty()) {
|
||||
|
@ -61,7 +61,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
requireContext(),
|
||||
playlistView.text.toString()
|
||||
)
|
||||
if (playlistId != -1 && activity != null) {
|
||||
if (playlistId != -1) {
|
||||
PlaylistsUtil.addToPlaylist(requireContext(), songs, playlistId, true)
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
|
||||
MaterialUtil.setTint(actionNewPlaylistContainer, false)
|
||||
|
||||
val playlistId = arguments!!.getLong(MediaStore.Audio.Playlists.Members.PLAYLIST_ID)
|
||||
val playlistId = requireArguments().getLong(MediaStore.Audio.Playlists.Members.PLAYLIST_ID)
|
||||
playlistView.appHandleColor()
|
||||
.setText(
|
||||
PlaylistsUtil.getNameForPlaylist(requireContext(), playlistId),
|
||||
|
|
|
@ -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
|
||||
|
@ -31,16 +31,22 @@ import java.util.*
|
|||
class DeletePlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val playlists = arguments!!.getParcelableArrayList<Playlist>("playlist")
|
||||
val playlists = requireArguments().getParcelableArrayList<Playlist>("playlist")
|
||||
val title: Int
|
||||
val content: CharSequence
|
||||
//noinspection ConstantConditions
|
||||
if (playlists!!.size > 1) {
|
||||
title = string.delete_playlists_title
|
||||
content = Html.fromHtml(getString(string.delete_x_playlists, playlists.size))
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(string.delete_x_playlists, playlists.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = string.delete_playlist_title
|
||||
content = Html.fromHtml(getString(string.delete_playlist_x, playlists[0].name))
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(string.delete_playlist_x, playlists[0].name),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
|
|
|
@ -18,7 +18,7 @@ import android.app.Dialog
|
|||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
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.activities.saf.SAFGuideActivity
|
||||
|
@ -40,16 +40,22 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
private var deleteSongsAsyncTask: DeleteSongsAsyncTask? = null
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val songs: ArrayList<Song>? = arguments?.getParcelableArrayList("songs")
|
||||
val songs: ArrayList<Song>? = requireArguments().getParcelableArrayList("songs")
|
||||
var title = 0
|
||||
var content: CharSequence = ""
|
||||
if (songs != null) {
|
||||
if (songs.size > 1) {
|
||||
title = R.string.delete_songs_title
|
||||
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size))
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(R.string.delete_x_songs, songs.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = R.string.delete_song_title
|
||||
content = Html.fromHtml(getString(R.string.delete_song_x, songs[0].title))
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(R.string.delete_song_x, songs[0].title),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.MainActivity
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.views.OptionMenuItemView
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
|
||||
class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
|
||||
|
||||
override fun onClick(view: View) {
|
||||
val mainActivity = activity as MainActivity? ?: return
|
||||
when (view.id) {
|
||||
R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity)
|
||||
R.id.actionDriveMode -> NavigationUtil.gotoDriveMode(mainActivity)
|
||||
R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity)
|
||||
}
|
||||
materialDialog.dismiss()
|
||||
}
|
||||
|
||||
private lateinit var actionSettings: OptionMenuItemView
|
||||
private lateinit var actionRate: OptionMenuItemView
|
||||
private lateinit var actionDriveMode: OptionMenuItemView
|
||||
private lateinit var materialDialog: MaterialDialog
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
||||
val layout = LayoutInflater.from(context).inflate(R.layout.fragment_main_options, null)
|
||||
actionSettings = layout.findViewById(R.id.actionSettings)
|
||||
actionRate = layout.findViewById(R.id.actionRate)
|
||||
actionDriveMode = layout.findViewById(R.id.actionDriveMode)
|
||||
|
||||
actionSettings.setOnClickListener(this)
|
||||
actionRate.setOnClickListener(this)
|
||||
actionDriveMode.setOnClickListener(this)
|
||||
|
||||
if (MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||
actionDriveMode.hide()
|
||||
}
|
||||
|
||||
materialDialog = MaterialDialog(requireActivity(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
icon(R.mipmap.ic_launcher_round)
|
||||
title(R.string.app_name)
|
||||
customView(view = layout, scrollable = true)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
return materialDialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
dialog?.window?.let {
|
||||
(requireActivity() as MainActivity).setNavigationbarColorAuto()
|
||||
(requireActivity() as MainActivity).setLightNavigationBar(true)
|
||||
}
|
||||
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val WHICH_ONE = "which_one"
|
||||
@JvmField
|
||||
var LIBRARY: Int = 0
|
||||
@JvmField
|
||||
var FOLDER: Int = 1
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(selectedId: Int): OptionsSheetDialogFragment {
|
||||
val bundle = Bundle()
|
||||
bundle.putInt(WHICH_ONE, selectedId)
|
||||
val fragment = OptionsSheetDialogFragment()
|
||||
fragment.arguments = bundle
|
||||
return fragment
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(): OptionsSheetDialogFragment {
|
||||
return OptionsSheetDialogFragment()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
|||
class RemoveFromPlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val songs = arguments!!.getParcelableArrayList<PlaylistSong>("songs")
|
||||
val songs = requireArguments().getParcelableArrayList<PlaylistSong>("songs")
|
||||
|
||||
var title = 0
|
||||
var content: CharSequence = ""
|
||||
|
|
|
@ -7,7 +7,6 @@ import code.name.monkey.appthemehelper.util.ColorUtil
|
|||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.MainActivity
|
||||
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment
|
||||
|
||||
abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue