Added MediaStore delete for A11
This commit is contained in:
parent
e9b7b5a203
commit
4eb2f68da5
2 changed files with 17 additions and 1 deletions
|
@ -21,6 +21,7 @@ import android.os.Bundle
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||||
|
@ -89,7 +90,11 @@ class DeleteSongsDialog : DialogFragment() {
|
||||||
if ((songs.size == 1) && MusicPlayerRemote.isPlaying(songs[0])) {
|
if ((songs.size == 1) && MusicPlayerRemote.isPlaying(songs[0])) {
|
||||||
MusicPlayerRemote.playNextSong()
|
MusicPlayerRemote.playNextSong()
|
||||||
}
|
}
|
||||||
if (!SAFUtil.isSAFRequiredForSongs(songs)) {
|
if (VersionUtils.hasQ()) {
|
||||||
|
dismiss()
|
||||||
|
MusicUtil.deleteTracksQ(requireActivity(), songs)
|
||||||
|
reloadTabs()
|
||||||
|
} else if (!SAFUtil.isSAFRequiredForSongs(songs)) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
dismiss()
|
dismiss()
|
||||||
MusicUtil.deleteTracks(requireContext(), songs)
|
MusicUtil.deleteTracks(requireContext(), songs)
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
package code.name.monkey.retromusic.util
|
package code.name.monkey.retromusic.util
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.ContentUris
|
import android.content.ContentUris
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.BaseColumns
|
import android.provider.BaseColumns
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
@ -517,6 +520,14 @@ object MusicUtil : KoinComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.Q)
|
||||||
|
fun deleteTracksQ(activity: Activity, songs: List<Song>) {
|
||||||
|
val pendingIntent = MediaStore.createDeleteRequest(activity.contentResolver, songs.map {
|
||||||
|
getSongFileUri(it.id)
|
||||||
|
})
|
||||||
|
activity.startIntentSenderForResult(pendingIntent.intentSender, 45, null, 0, 0, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
fun songByGenre(genreId: Long): Song {
|
fun songByGenre(genreId: Long): Song {
|
||||||
return repository.getSongByGenre(genreId)
|
return repository.getSongByGenre(genreId)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue