-
Notifications
You must be signed in to change notification settings - Fork 5
Description
(e) => {
let result = {
cancelled: false,
message: null,
};
switch (e) {
case null:
case 'USER_CANCELLED':
result.cancelled = true;
result.message = 'Scan was cancelled.';
break;
case 'SCANNER_OPEN':
result.message = 'Another scan is already in progress.';
break;
default:
result.message = e[0] || 'Unknown error.';
break;
}
onError(result);
},
BarcodeScanner.js made reference to error thrown when user cancels the scanner. The error is never thrown when user cancels the scanner. No error is also thrown using the back button to exit the scanner activity, this freezes the UI of my application. Though I was able to emit some error informing user that scanner was cancelled by editing the CaptureActivity.java file and updating:
_CloseButton.setOnClickListener(v -> {
finish();
})
to:
_CloseButton.setOnClickListener(v -> {
Intent data = new Intent();
//you can put intent.putExtra() here to define the error but I left blank so I can get "unknown error"
setResult(CommonStatusCodes.ERROR, data);
finish();
})
for the plugin to throw an "unknown error", I believe you can update the plugin with the appropriate string like "USER_CANCELLED" so we can check for this string in the JavaScript side in error.cancelled in the error function.
I also edited this block of code to make the back button emit an error which can be handled to inform user if the scanner is exited.
if ((results == null) || (results.size() == 0) || (results.get(0) == null)) {
DrawFocusRect(Color.parseColor("#FFFFFF"), null, null);
return;
}
to:
if ((results == null) || (results.size() == 0) || (results.get(0) == null)) {
DrawFocusRect(Color.parseColor("#FFFFFF"), null, null);
Intent data = new Intent();
//you can put intent.putExtra() here to define the error but I left blank so I can get "unknown error"
setResult(CommonStatusCodes.ERROR, data);
return;
}