Skip to content

Commit 67db72a

Browse files
committed
TvMainActivity: use OpenDocument instead of GetContent
This should make it possible to open files on Android TV 14. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 452a339 commit 67db72a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ import kotlinx.coroutines.withContext
5757
import java.io.File
5858

5959
class TvMainActivity : AppCompatActivity() {
60-
private val tunnelFileImportResultLauncher = registerForActivityResult(object : ActivityResultContracts.GetContent() {
61-
override fun createIntent(context: Context, input: String): Intent {
60+
private val tunnelFileImportResultLauncher = registerForActivityResult(object : ActivityResultContracts.OpenDocument() {
61+
override fun createIntent(context: Context, input: Array<String>): Intent {
6262
val intent = super.createIntent(context, input)
6363

6464
/* AndroidTV now comes with stubs that do nothing but display a Toast less helpful than
@@ -209,7 +209,7 @@ class TvMainActivity : AppCompatActivity() {
209209
}
210210
} else {
211211
try {
212-
tunnelFileImportResultLauncher.launch("*/*")
212+
tunnelFileImportResultLauncher.launch(arrayOf("*/*"))
213213
} catch (_: Throwable) {
214214
MaterialAlertDialogBuilder(binding.root.context).setMessage(R.string.tv_no_file_picker).setCancelable(false)
215215
.setPositiveButton(android.R.string.ok) { _, _ ->

0 commit comments

Comments
 (0)