Commit 8335a580 authored by Mygod's avatar Mygod

Take user to fallback QR code scanner if Google's scanner is not operational

Fixes #1970, #2032.
parent 3f14c9c8
......@@ -56,12 +56,6 @@ More details: https://kb.adguard.com/en/android/solving-problems/battery
Allow this app to consume background data in app settings.
### Why Camera permission is required on devices below Android 6.0?
To scan the QR code through the integrated QR scanner.
By the way, upgrade your Android system already.
### How to use Transproxy mode?
1. Install [AFWall+](https://github.com/ukanth/afwall);
......
......@@ -25,6 +25,7 @@ import android.content.Intent
import android.content.pm.ShortcutManager
import android.hardware.camera2.CameraAccessException
import android.hardware.camera2.CameraManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.Log
......@@ -59,6 +60,11 @@ class ScannerActivity : AppCompatActivity(), BarcodeRetriever {
private lateinit var detector: BarcodeDetector
private fun fallback() {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=tw.com.quickmark")))
finish()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
detector = BarcodeDetector.Builder(this)
......@@ -71,9 +77,9 @@ class ScannerActivity : AppCompatActivity(), BarcodeRetriever {
if (dialog == null) {
Toast.makeText(this, R.string.common_google_play_services_notification_ticker, Toast.LENGTH_SHORT)
.show()
finish()
fallback()
} else {
dialog.setOnDismissListener { finish() }
dialog.setOnDismissListener { fallback() }
dialog.show()
}
return
......
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