mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Tweak new QR processing some more.
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
android:theme="@style/Theme.App">
|
android:theme="@style/Theme.App">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".QrMainActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
|||||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||||
import org.signal.qr.QrScannerView
|
import org.signal.qr.QrScannerView
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class QrMainActivity : AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
@@ -36,7 +36,7 @@ class QrProcessor {
|
|||||||
val source = PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false)
|
val source = PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false)
|
||||||
|
|
||||||
val bitmap = BinaryBitmap(HybridBinarizer(source))
|
val bitmap = BinaryBitmap(HybridBinarizer(source))
|
||||||
val result: Result? = reader.decode(bitmap, emptyMap<DecodeHintType, String>())
|
val result: Result? = reader.decode(bitmap, mapOf(DecodeHintType.TRY_HARDER to true, DecodeHintType.CHARACTER_SET to "ISO-8859-1"))
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result.text
|
return result.text
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ internal class ScannerView21 constructor(
|
|||||||
val preview = Preview.Builder().build()
|
val preview = Preview.Builder().build()
|
||||||
|
|
||||||
val imageAnalysis = ImageAnalysis.Builder()
|
val imageAnalysis = ImageAnalysis.Builder()
|
||||||
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
|
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
|
||||||
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
|
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
imageAnalysis.setAnalyzer(analyzerExecutor) { proxy ->
|
imageAnalysis.setAnalyzer(analyzerExecutor) { proxy ->
|
||||||
val buffer = proxy.planes[0].buffer
|
val buffer = proxy.planes[0].buffer.apply { rewind() }
|
||||||
val bytes = ByteArray(buffer.capacity())
|
val bytes = ByteArray(buffer.capacity())
|
||||||
buffer.get(bytes)
|
buffer.get(bytes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user