- 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
This commit is contained in:
Javier Varona 2018-10-07 20:02:56 -04:00
parent be679e655f
commit 303011e419
2 changed files with 10 additions and 2 deletions

View file

@ -405,6 +405,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
mScannerView.setResultHandler(this);
mScannerView.startCamera();
/*builder.setNeutralButton("Scan QR Code", new DialogInterface.OnClickListener() { /*builder.setNeutralButton("Scan QR Code", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
@ -419,6 +421,12 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
loadUserImage(); loadUserImage();
} }
@Override
public void onPause() {
super.onPause();
mScannerView.stopCamera();
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -652,6 +660,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
public void beginScanQrCode(){ public void beginScanQrCode(){
//mScannerView = new ZXingScannerView(getContext()); //mScannerView = new ZXingScannerView(getContext());
mScannerView.setFormats(listOf(BarcodeFormat.QR_CODE)); mScannerView.setFormats(listOf(BarcodeFormat.QR_CODE));
mScannerView.setAspectTolerance(0.5f);
mScannerView.setAutoFocus(true); mScannerView.setAutoFocus(true);
mScannerView.setLaserColor(R.color.colorAccent); mScannerView.setLaserColor(R.color.colorAccent);
mScannerView.setMaskColor(R.color.colorAccent); mScannerView.setMaskColor(R.color.colorAccent);
@ -719,7 +728,6 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@Override @Override
public void handleResult(Result result) { public void handleResult(Result result) {
try { try {
System.out.println("CAMERA result " + result.getText() );
Invoice invoice = Invoice.fromQrCode(result.getText()); Invoice invoice = Invoice.fromQrCode(result.getText());
etTo.setText(invoice.getTo()); etTo.setText(invoice.getTo());

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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