fix: FireTV file selection bug

Fixes bug where FireTV devices were unable to launch a proper file browser to select tunnel configs.
This commit is contained in:
Zane Schepke 2023-09-11 11:15:44 -04:00
parent 64bb9f3b82
commit e81066f508
2 changed files with 10 additions and 7 deletions

View File

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

View File

@ -1,6 +1,7 @@
package com.zaneschepke.wireguardautotunnel.ui.screens.main
import android.annotation.SuppressLint
import android.content.Intent
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.AnimatedVisibility
@ -135,11 +136,9 @@ fun MainScreen(
}
val pickFileLauncher = rememberLauncherForActivityResult(
ActivityResultContracts.GetContent()
) { file ->
if (file != null) {
viewModel.onTunnelFileSelected(file)
}
ActivityResultContracts.StartActivityForResult()
) { result ->
result.data?.data?.let { viewModel.onTunnelFileSelected(it) }
}
Scaffold(
@ -196,7 +195,11 @@ fun MainScreen(
.fillMaxWidth()
.clickable {
showBottomSheet = false
pickFileLauncher.launch("*/*")
val fileSelectionIntent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "*/*"
}
pickFileLauncher.launch(fileSelectionIntent)
}
.padding(10.dp)
) {