Commit 81f35acf authored by Mygod's avatar Mygod

Let Zxing try harder

parent a755b669
......@@ -41,10 +41,7 @@ import com.github.shadowsocks.App.Companion.app
import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.database.ProfileManager
import com.github.shadowsocks.utils.resolveResourceId
import com.google.zxing.BinaryBitmap
import com.google.zxing.MultiFormatReader
import com.google.zxing.RGBLuminanceSource
import com.google.zxing.Result
import com.google.zxing.*
import com.google.zxing.common.HybridBinarizer
import me.dm7.barcodescanner.zxing.ZXingScannerView
......@@ -53,6 +50,8 @@ class ScannerActivity : AppCompatActivity(), ZXingScannerView.ResultHandler, Too
private const val MY_PERMISSIONS_REQUEST_CAMERA = 1
private const val REQUEST_IMPORT = 2
private const val REQUEST_IMPORT_OR_FINISH = 3
private val hints by lazy { mapOf(Pair(DecodeHintType.TRY_HARDER, true)) }
}
private lateinit var scannerView: ZXingScannerView
......@@ -151,7 +150,7 @@ class ScannerActivity : AppCompatActivity(), ZXingScannerView.ResultHandler, Too
val pixels = IntArray(bitmap.width * bitmap.height)
bitmap.getPixels(pixels, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height)
Profile.findAll(reader.decode(BinaryBitmap(HybridBinarizer(
RGBLuminanceSource(bitmap.width, bitmap.height, pixels)))).text).forEach {
RGBLuminanceSource(bitmap.width, bitmap.height, pixels))), hints).text).forEach {
ProfileManager.createProfile(it)
success = true
}
......
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