From 6d0167dcf31beb72af44f01afc424a66da5f03cb Mon Sep 17 00:00:00 2001 From: albexk Date: Thu, 14 Dec 2023 22:10:22 +0300 Subject: [PATCH] Get back the ability to open configuration files Doesn't work in all applications because some applications pass an abstract URI instead of the file path in the 'content' scheme --- client/android/AndroidManifest.xml | 28 +++++++++++++++++++ .../org/amnezia/vpn/ImportConfigActivity.kt | 22 +++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/client/android/AndroidManifest.xml b/client/android/AndroidManifest.xml index 7a362a8a..30b77f09 100644 --- a/client/android/AndroidManifest.xml +++ b/client/android/AndroidManifest.xml @@ -98,6 +98,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + { - intent.getStringExtra(EXTRA_TEXT)?.let(::startMainActivity) - } + "text/plain" -> intent.getStringExtra(EXTRA_TEXT)?.let(::startMainActivity) } } ACTION_VIEW -> { - Log.v(TAG, "Process VIEW action") - intent.data?.toString()?.let(::startMainActivity) + Log.v(TAG, "Process VIEW action, scheme: ${intent.scheme}") + when (intent.scheme) { + "file", "content" -> { + intent.data?.let { uri -> + checkPermissions( + uri, + onSuccess = ::processUri, + onFail = ::finish + ) + } + return + } + + "vpn" -> intent.data?.toString()?.let(::startMainActivity) + } + } } finish()