Unverified Commit 63e6e604 authored by Max Lv's avatar Max Lv Committed by GitHub

Merge pull request #2551 from Mygod/mlkit

Migrate to ML kit for scanning QR code
parents 73fa7c97 0828a7e0
......@@ -71,7 +71,7 @@ dependencies {
val workVersion = "2.4.0-rc01"
api(project(":plugin"))
api("androidx.fragment:fragment-ktx:1.2.5")
api("androidx.fragment:fragment-ktx:1.3.0-alpha06")
api("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion")
api("androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion")
api("androidx.preference:preference:1.1.1")
......
......@@ -44,7 +44,7 @@ import java.net.InetAddress
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
fun <T> Iterable<T>.forEachTry(action: (T) -> Unit) {
inline fun <T> Iterable<T>.forEachTry(action: (T) -> Unit) {
var result: Exception? = null
for (element in this) try {
action(element)
......
......@@ -12,14 +12,18 @@ setupApp()
android.defaultConfig.applicationId = "com.github.shadowsocks"
dependencies {
val cameraxVersion = "1.0.0-beta06"
implementation("androidx.browser:browser:1.2.0")
implementation("androidx.camera:camera-camera2:$cameraxVersion")
implementation("androidx.camera:camera-lifecycle:$cameraxVersion")
implementation("androidx.camera:camera-view:1.0.0-alpha13")
implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta7")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
implementation("com.google.android.gms:play-services-vision:20.1.0")
implementation("com.google.firebase:firebase-ads:19.2.0")
implementation("com.google.mlkit:barcode-scanning:16.0.0")
implementation("com.google.zxing:core:3.4.0")
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")
implementation("com.twofortyfouram:android-plugin-api-for-locale:1.0.4")
implementation("me.zhanghai.android.fastscroll:library:1.1.4")
implementation("xyz.belvi.mobilevision:barcodescanner:2.0.3")
}
......@@ -56,6 +56,8 @@
android:name=".ScannerActivity"
android:label="@string/add_profile_methods_scan_qr_code"
android:parentActivityName=".MainActivity"
android:theme="@style/Theme.Shadowsocks.Immersive"
android:screenOrientation="locked"
android:excludeFromRecents="true"/>
<activity android:name=".tasker.ConfigActivity"
......
......@@ -33,7 +33,7 @@ object ListHolderListener : View.OnApplyWindowInsetsListener {
return insets.replaceSystemWindowInsets(0, 0, 0, insets.systemWindowInsetBottom)
}
fun setup(activity: AppCompatActivity) = activity.findViewById<View>(android.R.id.content).apply {
fun setup(activity: AppCompatActivity) = activity.findViewById<View>(android.R.id.content).run {
setOnApplyWindowInsetsListener(ListHolderListener)
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar_light_dark" />
<fragment
<androidx.camera.view.PreviewView
android:id="@+id/barcode"
android:name="com.google.android.gms.samples.vision.barcodereader.BarcodeCapture"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:gvb_auto_focus="true"/>
android:layout_height="fill_parent"/>
</LinearLayout>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment