From 303011e419348edcef3e68cd8680436dc3876ecd Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sun, 7 Oct 2018 20:02:56 -0400 Subject: [PATCH] - Fixed QR scanner in send fragment not triggering when the camera is focusing on a QR code - Gradle version upgraded to work with the last android studio --- .../fragments/SendTransactionFragment.java | 10 +++++++++- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java index 797321f..56b6600 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -405,6 +405,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat @Override public void onResume() { super.onResume(); + mScannerView.setResultHandler(this); + mScannerView.startCamera(); /*builder.setNeutralButton("Scan QR Code", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -419,6 +421,12 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat loadUserImage(); } + @Override + public void onPause() { + super.onPause(); + mScannerView.stopCamera(); + } + @Override public void onDestroy() { super.onDestroy(); @@ -652,6 +660,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat public void beginScanQrCode(){ //mScannerView = new ZXingScannerView(getContext()); mScannerView.setFormats(listOf(BarcodeFormat.QR_CODE)); + mScannerView.setAspectTolerance(0.5f); mScannerView.setAutoFocus(true); mScannerView.setLaserColor(R.color.colorAccent); mScannerView.setMaskColor(R.color.colorAccent); @@ -719,7 +728,6 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat @Override public void handleResult(Result result) { try { - System.out.println("CAMERA result " + result.getText() ); Invoice invoice = Invoice.fromQrCode(result.getText()); etTo.setText(invoice.getTo()); diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8163bd9..6e57679 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip