@@ -21,7 +21,8 @@ import androidx.appcompat.app.AppCompatActivity
21
21
import androidx.appcompat.view.ActionMode
22
22
import androidx.lifecycle.lifecycleScope
23
23
import com.google.android.material.snackbar.Snackbar
24
- import com.google.zxing.integration.android.IntentIntegrator
24
+ import com.journeyapps.barcodescanner.ScanContract
25
+ import com.journeyapps.barcodescanner.ScanOptions
25
26
import com.wireguard.android.Application
26
27
import com.wireguard.android.R
27
28
import com.wireguard.android.activity.TunnelCreatorActivity
@@ -55,12 +56,12 @@ class TunnelListFragment : BaseFragment() {
55
56
}
56
57
}
57
58
58
- private val qrImportResultLauncher = registerForActivityResult(ActivityResultContracts . StartActivityForResult ()) { result ->
59
- val qrCode = IntentIntegrator .parseActivityResult( result.resultCode, result.data)? .contents
60
- ? : return @registerForActivityResult
61
- val activity = activity ? : return @registerForActivityResult
62
- val fragManager = parentFragmentManager
63
- activity.lifecycleScope.launch { TunnelImporter .importTunnel(fragManager, qrCode) { showSnackbar(it) } }
59
+ private val qrImportResultLauncher = registerForActivityResult(ScanContract ()) { result ->
60
+ val qrCode = result.contents
61
+ val activity = activity
62
+ if (qrCode != null && activity != null ) {
63
+ activity.lifecycleScope.launch { TunnelImporter .importTunnel( parentFragmentManager, qrCode) { showSnackbar(it) } }
64
+ }
64
65
}
65
66
66
67
override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
@@ -89,11 +90,10 @@ class TunnelListFragment : BaseFragment() {
89
90
tunnelFileImportResultLauncher.launch(" */*" )
90
91
}
91
92
AddTunnelsSheet .REQUEST_SCAN -> {
92
- qrImportResultLauncher.launch(IntentIntegrator (requireActivity() )
93
+ qrImportResultLauncher.launch(ScanOptions ( )
93
94
.setOrientationLocked(false )
94
95
.setBeepEnabled(false )
95
- .setPrompt(getString(R .string.qr_code_hint))
96
- .createScanIntent())
96
+ .setPrompt(getString(R .string.qr_code_hint)))
97
97
}
98
98
}
99
99
}
0 commit comments