summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-10-25 22:37:01 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-10-25 22:42:39 +0530
commitfae74dd3ca4d05f99c9301fcd6ba82e2fbd4a002 (patch)
treecd67401c5ab3be2a3bf46faed78d671426e6d162 /ui/src/main/java/com/wireguard/android
parente462ae270db0ebcf8aaafb39112fe5fd27018278 (diff)
ui: upgrade zxing-android-embedded
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt20
1 files changed, 10 insertions, 10 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
index c76ca6ac..eb24658a 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
@@ -21,7 +21,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
-import com.google.zxing.integration.android.IntentIntegrator
+import com.journeyapps.barcodescanner.ScanContract
+import com.journeyapps.barcodescanner.ScanOptions
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.activity.TunnelCreatorActivity
@@ -55,12 +56,12 @@ class TunnelListFragment : BaseFragment() {
}
}
- private val qrImportResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
- val qrCode = IntentIntegrator.parseActivityResult(result.resultCode, result.data)?.contents
- ?: return@registerForActivityResult
- val activity = activity ?: return@registerForActivityResult
- val fragManager = parentFragmentManager
- activity.lifecycleScope.launch { TunnelImporter.importTunnel(fragManager, qrCode) { showSnackbar(it) } }
+ private val qrImportResultLauncher = registerForActivityResult(ScanContract()) { result ->
+ val qrCode = result.contents
+ val activity = activity
+ if (qrCode != null && activity != null) {
+ activity.lifecycleScope.launch { TunnelImporter.importTunnel(parentFragmentManager, qrCode) { showSnackbar(it) } }
+ }
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -89,11 +90,10 @@ class TunnelListFragment : BaseFragment() {
tunnelFileImportResultLauncher.launch("*/*")
}
AddTunnelsSheet.REQUEST_SCAN -> {
- qrImportResultLauncher.launch(IntentIntegrator(requireActivity())
+ qrImportResultLauncher.launch(ScanOptions()
.setOrientationLocked(false)
.setBeepEnabled(false)
- .setPrompt(getString(R.string.qr_code_hint))
- .createScanIntent())
+ .setPrompt(getString(R.string.qr_code_hint)))
}
}
}