ui: upgrade zxing-android-embedded
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
e462ae270d
commit
fae74dd3ca
@ -17,7 +17,7 @@ buildscript {
|
|||||||
lifecycleRuntimeKtxVersion = '2.3.1'
|
lifecycleRuntimeKtxVersion = '2.3.1'
|
||||||
materialComponentsVersion = '1.4.0'
|
materialComponentsVersion = '1.4.0'
|
||||||
preferenceVersion = '1.1.1'
|
preferenceVersion = '1.1.1'
|
||||||
zxingEmbeddedVersion = '4.2.0'
|
zxingEmbeddedVersion = '4.3.0'
|
||||||
|
|
||||||
groupName = 'com.wireguard.android'
|
groupName = 'com.wireguard.android'
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,6 @@
|
|||||||
android:label="@string/permission_label"
|
android:label="@string/permission_label"
|
||||||
android:protectionLevel="dangerous" />
|
android:protectionLevel="dangerous" />
|
||||||
|
|
||||||
<!-- This is safe to override, the APIs we use work perfectly fine on Android 6 -->
|
|
||||||
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".Application"
|
android:name=".Application"
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
|
@ -21,7 +21,8 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.google.android.material.snackbar.Snackbar
|
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.Application
|
||||||
import com.wireguard.android.R
|
import com.wireguard.android.R
|
||||||
import com.wireguard.android.activity.TunnelCreatorActivity
|
import com.wireguard.android.activity.TunnelCreatorActivity
|
||||||
@ -55,12 +56,12 @@ class TunnelListFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val qrImportResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
private val qrImportResultLauncher = registerForActivityResult(ScanContract()) { result ->
|
||||||
val qrCode = IntentIntegrator.parseActivityResult(result.resultCode, result.data)?.contents
|
val qrCode = result.contents
|
||||||
?: return@registerForActivityResult
|
val activity = activity
|
||||||
val activity = activity ?: return@registerForActivityResult
|
if (qrCode != null && activity != null) {
|
||||||
val fragManager = parentFragmentManager
|
activity.lifecycleScope.launch { TunnelImporter.importTunnel(parentFragmentManager, qrCode) { showSnackbar(it) } }
|
||||||
activity.lifecycleScope.launch { TunnelImporter.importTunnel(fragManager, qrCode) { showSnackbar(it) } }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@ -89,11 +90,10 @@ class TunnelListFragment : BaseFragment() {
|
|||||||
tunnelFileImportResultLauncher.launch("*/*")
|
tunnelFileImportResultLauncher.launch("*/*")
|
||||||
}
|
}
|
||||||
AddTunnelsSheet.REQUEST_SCAN -> {
|
AddTunnelsSheet.REQUEST_SCAN -> {
|
||||||
qrImportResultLauncher.launch(IntentIntegrator(requireActivity())
|
qrImportResultLauncher.launch(ScanOptions()
|
||||||
.setOrientationLocked(false)
|
.setOrientationLocked(false)
|
||||||
.setBeepEnabled(false)
|
.setBeepEnabled(false)
|
||||||
.setPrompt(getString(R.string.qr_code_hint))
|
.setPrompt(getString(R.string.qr_code_hint)))
|
||||||
.createScanIntent())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user