TvMainActivity: use OpenDocument instead of GetContent
This should make it possible to open files on Android TV 14. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -57,8 +57,8 @@ import kotlinx.coroutines.withContext
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class TvMainActivity : AppCompatActivity() {
|
class TvMainActivity : AppCompatActivity() {
|
||||||
private val tunnelFileImportResultLauncher = registerForActivityResult(object : ActivityResultContracts.GetContent() {
|
private val tunnelFileImportResultLauncher = registerForActivityResult(object : ActivityResultContracts.OpenDocument() {
|
||||||
override fun createIntent(context: Context, input: String): Intent {
|
override fun createIntent(context: Context, input: Array<String>): Intent {
|
||||||
val intent = super.createIntent(context, input)
|
val intent = super.createIntent(context, input)
|
||||||
|
|
||||||
/* AndroidTV now comes with stubs that do nothing but display a Toast less helpful than
|
/* AndroidTV now comes with stubs that do nothing but display a Toast less helpful than
|
||||||
@@ -209,7 +209,7 @@ class TvMainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
tunnelFileImportResultLauncher.launch("*/*")
|
tunnelFileImportResultLauncher.launch(arrayOf("*/*"))
|
||||||
} catch (_: Throwable) {
|
} catch (_: Throwable) {
|
||||||
MaterialAlertDialogBuilder(binding.root.context).setMessage(R.string.tv_no_file_picker).setCancelable(false)
|
MaterialAlertDialogBuilder(binding.root.context).setMessage(R.string.tv_no_file_picker).setCancelable(false)
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
|
|||||||
Reference in New Issue
Block a user