music: fix crash when adding music dirs
Fix a crash that would occur when trying to add music dirs without a file manager to handle it. Some users apparently disable the built-in file manager under the assumption that the same intents will work with other file managers. They do not, and so we need to handle that case and let the user know.
This commit is contained in:
parent
3e33510139
commit
d5941aa705
5 changed files with 21 additions and 10 deletions
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## dev
|
||||
|
||||
#### What's Fixed
|
||||
- Fixed crash that would occur in music folders dialog when user does not have a working
|
||||
file manager
|
||||
|
||||
## 3.0.1
|
||||
|
||||
#### What's New
|
||||
|
|
|
@ -173,8 +173,8 @@ class DetailViewModel(application: Application) :
|
|||
}
|
||||
|
||||
/**
|
||||
* Set a new [currentSong] from it's [Music.UID]. If the [Music.UID] differs, [currentSong]
|
||||
* and [songProperties] will be updated to align with the new [Song].
|
||||
* Set a new [currentSong] from it's [Music.UID]. If the [Music.UID] differs, [currentSong] and
|
||||
* [songProperties] will be updated to align with the new [Song].
|
||||
* @param uid The UID of the [Song] to load. Must be valid.
|
||||
*/
|
||||
fun setSongUid(uid: Music.UID) {
|
||||
|
|
|
@ -140,8 +140,7 @@ class Date private constructor(private val tokens: List<Int>) : Comparable<Date>
|
|||
min.resolveDate(context)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?) =
|
||||
other is Range && min == other.min && max == other.max
|
||||
override fun equals(other: Any?) = other is Range && min == other.min && max == other.max
|
||||
|
||||
override fun hashCode() = 31 * max.hashCode() + min.hashCode()
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.oxycblt.auxio.music.filesystem
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.storage.StorageManager
|
||||
|
@ -84,10 +85,16 @@ class MusicDirsDialog :
|
|||
val dialog = it as AlertDialog
|
||||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL)?.setOnClickListener {
|
||||
logD("Opening launcher")
|
||||
requireNotNull(openDocumentTreeLauncher) {
|
||||
val launcher = requireNotNull(openDocumentTreeLauncher) {
|
||||
"Document tree launcher was not available"
|
||||
}
|
||||
.launch(null)
|
||||
|
||||
try {
|
||||
launcher.launch(null)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// User doesn't have a capable file manager.
|
||||
requireContext().showToast(R.string.err_no_app)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +104,6 @@ class MusicDirsDialog :
|
|||
}
|
||||
|
||||
var dirs = Settings(context).getMusicDirs(storageManager)
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
val pendingDirs = savedInstanceState.getStringArrayList(KEY_PENDING_DIRS)
|
||||
if (pendingDirs != null) {
|
||||
|
|
Loading…
Reference in a new issue