kopia lustrzana https://github.com/ryukoposting/Signal-Android
Tweak new QR processing some more.
rodzic
f4c728f57c
commit
4c44f1ee02
|
@ -11,7 +11,7 @@
|
|||
android:theme="@style/Theme.App">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name=".QrMainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<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 org.signal.qr.QrScannerView
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
class QrMainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
|
@ -36,7 +36,7 @@ class QrProcessor {
|
|||
val source = PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false)
|
||||
|
||||
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) {
|
||||
return result.text
|
||||
|
|
|
@ -74,12 +74,12 @@ internal class ScannerView21 constructor(
|
|||
val preview = Preview.Builder().build()
|
||||
|
||||
val imageAnalysis = ImageAnalysis.Builder()
|
||||
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
|
||||
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
|
||||
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
|
||||
.build()
|
||||
|
||||
imageAnalysis.setAnalyzer(analyzerExecutor) { proxy ->
|
||||
val buffer = proxy.planes[0].buffer
|
||||
val buffer = proxy.planes[0].buffer.apply { rewind() }
|
||||
val bytes = ByteArray(buffer.capacity())
|
||||
buffer.get(bytes)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue