fix: file selection on older devices

Fixes bug where file selection was causing app to crash on older devices.
This commit is contained in:
Zane Schepke 2023-08-11 21:13:54 -04:00
parent 135f8c0459
commit f513297ba0
2 changed files with 7 additions and 2 deletions

View File

@ -17,7 +17,7 @@ android {
val versionMajor = 2
val versionMinor = 3
val versionPatch = 4
val versionPatch = 5
val versionBuild = 0
defaultConfig {

View File

@ -144,7 +144,12 @@ class MainViewModel @Inject constructor(private val application : Application,
@SuppressLint("Range")
private fun getFileName(context: Context, uri: Uri): String {
if (uri.scheme == "content") {
val cursor = context.contentResolver.query(uri, null, null, null, null)
val cursor = try {
context.contentResolver.query(uri, null, null, null, null)
} catch (e : Exception) {
Timber.d("Exception getting config name")
null
}
cursor ?: return defaultConfigName()
cursor.use {
if(cursor.moveToFirst()) {