From f513297ba0a54cf8f3f691d706d8d599a174e89f Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Fri, 11 Aug 2023 21:13:54 -0400 Subject: [PATCH] fix: file selection on older devices Fixes bug where file selection was causing app to crash on older devices. --- app/build.gradle.kts | 2 +- .../wireguardautotunnel/ui/screens/main/MainViewModel.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c9a5dae..b47383b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,7 +17,7 @@ android { val versionMajor = 2 val versionMinor = 3 - val versionPatch = 4 + val versionPatch = 5 val versionBuild = 0 defaultConfig { diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt index e1c151f..6897cff 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt @@ -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()) {