@sapui5/sap.ndc 1.108.21 → 1.108.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sap/ndc/.library +1 -1
- package/src/sap/ndc/BarcodeScanner.js +341 -260
- package/src/sap/ndc/BarcodeScannerButton.js +8 -2
- package/src/sap/ndc/BarcodeScannerUIContainer.js +5 -2
- package/src/sap/ndc/css/sapNdcBarcodeScanner.css +0 -1
- package/src/sap/ndc/library.js +1 -1
- package/src/sap/ndc/messagebundle.properties +27 -0
- package/src/sap/ndc/messagebundle_ar.properties +12 -0
- package/src/sap/ndc/messagebundle_bg.properties +12 -0
- package/src/sap/ndc/messagebundle_ca.properties +12 -0
- package/src/sap/ndc/messagebundle_cs.properties +12 -0
- package/src/sap/ndc/messagebundle_cy.properties +12 -0
- package/src/sap/ndc/messagebundle_da.properties +12 -0
- package/src/sap/ndc/messagebundle_de.properties +12 -0
- package/src/sap/ndc/messagebundle_el.properties +12 -0
- package/src/sap/ndc/messagebundle_en.properties +12 -0
- package/src/sap/ndc/messagebundle_en_GB.properties +12 -0
- package/src/sap/ndc/messagebundle_es.properties +12 -0
- package/src/sap/ndc/messagebundle_es_MX.properties +12 -0
- package/src/sap/ndc/messagebundle_et.properties +12 -0
- package/src/sap/ndc/messagebundle_fi.properties +12 -0
- package/src/sap/ndc/messagebundle_fr.properties +12 -0
- package/src/sap/ndc/messagebundle_fr_CA.properties +12 -0
- package/src/sap/ndc/messagebundle_hi.properties +12 -0
- package/src/sap/ndc/messagebundle_hr.properties +12 -0
- package/src/sap/ndc/messagebundle_hu.properties +12 -0
- package/src/sap/ndc/messagebundle_id.properties +12 -0
- package/src/sap/ndc/messagebundle_it.properties +12 -0
- package/src/sap/ndc/messagebundle_iw.properties +12 -0
- package/src/sap/ndc/messagebundle_ja.properties +12 -0
- package/src/sap/ndc/messagebundle_kk.properties +12 -0
- package/src/sap/ndc/messagebundle_ko.properties +12 -0
- package/src/sap/ndc/messagebundle_lt.properties +12 -0
- package/src/sap/ndc/messagebundle_lv.properties +12 -0
- package/src/sap/ndc/messagebundle_mk.properties +20 -0
- package/src/sap/ndc/messagebundle_ms.properties +12 -0
- package/src/sap/ndc/messagebundle_nl.properties +12 -0
- package/src/sap/ndc/messagebundle_no.properties +12 -0
- package/src/sap/ndc/messagebundle_pl.properties +12 -0
- package/src/sap/ndc/messagebundle_pt.properties +12 -0
- package/src/sap/ndc/messagebundle_pt_PT.properties +12 -0
- package/src/sap/ndc/messagebundle_ro.properties +12 -0
- package/src/sap/ndc/messagebundle_ru.properties +12 -0
- package/src/sap/ndc/messagebundle_sh.properties +16 -4
- package/src/sap/ndc/messagebundle_sk.properties +12 -0
- package/src/sap/ndc/messagebundle_sl.properties +12 -0
- package/src/sap/ndc/messagebundle_sr.properties +32 -0
- package/src/sap/ndc/messagebundle_sv.properties +12 -0
- package/src/sap/ndc/messagebundle_th.properties +12 -0
- package/src/sap/ndc/messagebundle_tr.properties +12 -0
- package/src/sap/ndc/messagebundle_uk.properties +12 -0
- package/src/sap/ndc/messagebundle_vi.properties +12 -0
- package/src/sap/ndc/messagebundle_zh_CN.properties +12 -0
- package/src/sap/ndc/messagebundle_zh_TW.properties +12 -0
|
@@ -82,9 +82,10 @@ sap.ui.define([
|
|
|
82
82
|
/* =========================================================== */
|
|
83
83
|
oStream,
|
|
84
84
|
oScanDialog,
|
|
85
|
+
oBarcodeScannerUIContainer,
|
|
86
|
+
oVideoTrack,
|
|
85
87
|
oBarcodeVideoDOM,
|
|
86
88
|
oBarcodeCanvasDOM,
|
|
87
|
-
oContext,
|
|
88
89
|
oBarcodeOverlayDOM,
|
|
89
90
|
oBarcodeHighlightDOM,
|
|
90
91
|
|
|
@@ -107,18 +108,16 @@ sap.ui.define([
|
|
|
107
108
|
},
|
|
108
109
|
deviceId: undefined,
|
|
109
110
|
preferFrontCamera: false,
|
|
110
|
-
zoom: null,
|
|
111
111
|
enableGS1Header: false
|
|
112
112
|
},
|
|
113
113
|
scanDialog: {
|
|
114
114
|
title: "", //oDialogTitle
|
|
115
115
|
onLiveUpdate: null, //Live update function
|
|
116
|
-
imgTruncX: 0,
|
|
117
|
-
imgTruncY: 0,
|
|
118
116
|
barcodeOverlaySetup: false,
|
|
119
117
|
isNoScanner: false,
|
|
120
118
|
scanningStartTime: 0,
|
|
121
|
-
keepCameraScan: false
|
|
119
|
+
keepCameraScan: false,
|
|
120
|
+
disableBarcodeInputDialog: false
|
|
122
121
|
},
|
|
123
122
|
callBackHandler: {
|
|
124
123
|
onFnFail: null,
|
|
@@ -376,7 +375,7 @@ sap.ui.define([
|
|
|
376
375
|
* @private
|
|
377
376
|
*/
|
|
378
377
|
function loadZXingCPPAPI() {
|
|
379
|
-
Log.
|
|
378
|
+
Log.debug("BarcodeScanner.loadZXingCPPAPI: load ZXingCPP API");
|
|
380
379
|
updateScannerAPI("ZXingCPP", oScannerAPIStatus.Loading);
|
|
381
380
|
sap.ui.require([
|
|
382
381
|
"sap/ndc/thirdparty/zxingcpp/zxing_reader"
|
|
@@ -515,7 +514,7 @@ sap.ui.define([
|
|
|
515
514
|
.catch(
|
|
516
515
|
function(oErr) {
|
|
517
516
|
oModel.setProperty("/devices/needCheck", false);
|
|
518
|
-
Log.error("BarcodeScanner.getDeviceCameras: Can not get device cameras.\
|
|
517
|
+
Log.error("BarcodeScanner.getDeviceCameras: Can not get device cameras.\nError Message: " + oErr);
|
|
519
518
|
});
|
|
520
519
|
}
|
|
521
520
|
|
|
@@ -534,11 +533,13 @@ sap.ui.define([
|
|
|
534
533
|
Log.debug("BarcodeScanner.findMainCamera: can not find the main camera.");
|
|
535
534
|
fnCallback();
|
|
536
535
|
} else {
|
|
537
|
-
var oCamera = aCamerasClone.
|
|
536
|
+
var oCamera = aCamerasClone[aCamerasClone.length - 1];
|
|
538
537
|
var oConstraints = deepClone(oModel.getProperty("/config/defaultConstraints"));
|
|
539
538
|
oConstraints.video.deviceId = {
|
|
540
539
|
exact: oCamera.deviceId
|
|
541
540
|
};
|
|
541
|
+
var oVideoResolution = calculateVideoResolution();
|
|
542
|
+
oConstraints.video = Object.assign(oConstraints.video, oVideoResolution);
|
|
542
543
|
window.navigator.mediaDevices
|
|
543
544
|
.getUserMedia(oConstraints)
|
|
544
545
|
.then(
|
|
@@ -553,19 +554,27 @@ sap.ui.define([
|
|
|
553
554
|
Log.debug("BarcodeScanner.findMainCamera: the main camera is " + oCamera.deviceId);
|
|
554
555
|
oStream = stream;
|
|
555
556
|
if (oStream) {
|
|
556
|
-
|
|
557
|
+
playbackVideoAndDecode();
|
|
557
558
|
} else {
|
|
558
559
|
oScanDialog.getModel().setProperty("/isNoScanner", true);
|
|
559
|
-
openBarcodeInputDialog();
|
|
560
|
+
openBarcodeInputDialog(oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_STREAM_ERROR_MSG'));
|
|
560
561
|
}
|
|
561
562
|
}, function() {
|
|
562
563
|
videoTrack.stop();
|
|
563
564
|
Log.debug("BarcodeScanner.findMainCamera: " + oCamera.deviceId + " is not the main camera, check the next camera");
|
|
565
|
+
aCamerasClone.pop();
|
|
564
566
|
fnCheckStream();
|
|
565
567
|
});
|
|
566
568
|
}
|
|
567
569
|
).catch(
|
|
568
|
-
function() {
|
|
570
|
+
function (error) {
|
|
571
|
+
Log.debug("BarcodeScanner.findMainCamera: getUserMedia() failed.\nError Message: " + error);
|
|
572
|
+
if (oModel.getProperty("/config/defaultConstraints/video/zoom") !== undefined) {
|
|
573
|
+
Log.debug("BarcodeScanner.findMainCamera: getUserMedia() failed maybe caused by unsupported constraint 'zoom', delete it and try again.");
|
|
574
|
+
delete oModel.getProperty("/config/defaultConstraints/video").zoom;
|
|
575
|
+
} else {
|
|
576
|
+
aCamerasClone.pop();
|
|
577
|
+
}
|
|
569
578
|
fnCheckStream();
|
|
570
579
|
}
|
|
571
580
|
);
|
|
@@ -613,7 +622,7 @@ sap.ui.define([
|
|
|
613
622
|
reject();
|
|
614
623
|
}
|
|
615
624
|
}).catch(function(oError) {
|
|
616
|
-
Log.debug("BarcodeScanner.checkFlashLight: Camera not started or not available
|
|
625
|
+
Log.debug("BarcodeScanner.checkFlashLight: Camera not started or not available.\nError Message: " + oError);
|
|
617
626
|
reject();
|
|
618
627
|
});
|
|
619
628
|
});
|
|
@@ -732,93 +741,117 @@ sap.ui.define([
|
|
|
732
741
|
function openBarcodeInputDialog(sMessage) {
|
|
733
742
|
if (sMessage) {
|
|
734
743
|
Log.warning("BarcodeScanner.openBarcodeInputDialog: isNoScanner. Message: " + sMessage);
|
|
744
|
+
var sErrorMsg = oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_OTHER_ERROR_MSG', sMessage);
|
|
745
|
+
if (sMessage.name) {
|
|
746
|
+
var sErrorMsgKey = "BARCODE_DIALOG_CAMERA_" + sMessage.name.toUpperCase() + "_ERROR_MSG";
|
|
747
|
+
sErrorMsg = oResourceModel.getResourceBundle().getText(sErrorMsgKey);
|
|
748
|
+
}
|
|
749
|
+
MessageToast.show(
|
|
750
|
+
sErrorMsg,
|
|
751
|
+
{
|
|
752
|
+
duration: 1000
|
|
753
|
+
}
|
|
754
|
+
);
|
|
735
755
|
}
|
|
736
756
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
757
|
+
var disableBarcodeInputDialog = oModel.getProperty("/scanDialog/disableBarcodeInputDialog");
|
|
758
|
+
if (disableBarcodeInputDialog) {
|
|
759
|
+
BarcodeScanner.closeScanDialog();
|
|
760
|
+
} else {
|
|
761
|
+
oScanDialog.destroyContent();
|
|
762
|
+
oScanDialog.setTitle('');
|
|
763
|
+
oScanDialog.setStretch(false);
|
|
764
|
+
oScanDialog.setContentHeight('auto');
|
|
765
|
+
if (oBarcodeOverlayDOM) {
|
|
766
|
+
oBarcodeOverlayDOM.hidden = true;
|
|
767
|
+
}
|
|
768
|
+
oScanDialog.removeStyleClass('sapUiNoContentPadding');
|
|
745
769
|
|
|
746
|
-
|
|
770
|
+
oScanDialog.setTitle(oModel.getProperty("/scanDialog/title"));
|
|
747
771
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
772
|
+
var oMSGLabel = new Label(oScanDialog.getId() + '-txt_barcode', {
|
|
773
|
+
text: "{i18n>BARCODE_DIALOG_MSG}",
|
|
774
|
+
visible: "{/isNoScanner}"
|
|
775
|
+
});
|
|
776
|
+
oScanDialog.addContent(
|
|
777
|
+
oMSGLabel
|
|
778
|
+
);
|
|
755
779
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
780
|
+
var oFallbackInput = new Input(oScanDialog.getId() + '-inp_barcode', {
|
|
781
|
+
value: "{/barcode}",
|
|
782
|
+
valueLiveUpdate: true,
|
|
783
|
+
ariaLabelledBy: oMSGLabel.getId(),
|
|
784
|
+
liveChange: function(oEvent) {
|
|
785
|
+
var onLiveUpdate = oModel.getProperty("/scanDialog/onLiveUpdate");
|
|
786
|
+
if (typeof onLiveUpdate === "function") {
|
|
787
|
+
onLiveUpdate({
|
|
788
|
+
newValue: oEvent.getParameter("newValue")
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
placeholder: "{i18n>BARCODE_DIALOG_PLACEHOLDER}"
|
|
793
|
+
});
|
|
794
|
+
oScanDialog.addContent(oFallbackInput);
|
|
771
795
|
|
|
772
|
-
|
|
773
|
-
|
|
796
|
+
// shortcut for sap.m.ButtonType
|
|
797
|
+
var ButtonType = mobileLibrary.ButtonType;
|
|
774
798
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
799
|
+
oScanDialog.setBeginButton(
|
|
800
|
+
new Button(oScanDialog.getId() + '-btn_barcode_ok', {
|
|
801
|
+
type: ButtonType.Emphasized,
|
|
802
|
+
text: "{i18n>BARCODE_DIALOG_OK}",
|
|
803
|
+
press: function(oEvent) {
|
|
804
|
+
var onFnSuccess = oModel.getProperty("/callBackHandler/onFnSuccess");
|
|
805
|
+
if (typeof onFnSuccess === "function") {
|
|
806
|
+
var oScanningTime = "unknown";
|
|
807
|
+
if (oModel.getProperty("/scanDialog/scanningStartTime") > 0) {
|
|
808
|
+
var scanningStopTime = Date.now();
|
|
809
|
+
oScanningTime = scanningStopTime - oModel.getProperty("/scanDialog/scanningStartTime");
|
|
810
|
+
}
|
|
811
|
+
onFnSuccess({
|
|
812
|
+
text: oScanDialog.getModel().getProperty("/barcode"),
|
|
813
|
+
scanningTime: oScanningTime,
|
|
814
|
+
cancelled: false
|
|
815
|
+
});
|
|
786
816
|
}
|
|
787
|
-
|
|
788
|
-
text: oScanDialog.getModel().getProperty("/barcode"),
|
|
789
|
-
scanningTime: oScanningTime,
|
|
790
|
-
cancelled: false
|
|
791
|
-
});
|
|
817
|
+
BarcodeScanner.closeScanDialog();
|
|
792
818
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
})
|
|
804
|
-
);
|
|
819
|
+
})
|
|
820
|
+
);
|
|
821
|
+
oScanDialog.setEndButton(
|
|
822
|
+
new Button({
|
|
823
|
+
text: "{i18n>BARCODE_DIALOG_CANCEL}",
|
|
824
|
+
press: function() {
|
|
825
|
+
BarcodeScanner.closeScanDialog();
|
|
826
|
+
}
|
|
827
|
+
})
|
|
828
|
+
);
|
|
805
829
|
|
|
806
|
-
|
|
807
|
-
|
|
830
|
+
oScanDialog.setBusy(false);
|
|
831
|
+
}
|
|
808
832
|
}
|
|
809
833
|
|
|
810
834
|
/**
|
|
811
|
-
*
|
|
835
|
+
* Open correct camera
|
|
812
836
|
* @private
|
|
813
837
|
*/
|
|
814
|
-
function
|
|
838
|
+
function openCorrectCamera() {
|
|
815
839
|
if (!oModel.getProperty("/config/preferFrontCamera")) {
|
|
816
840
|
delete oModel.getProperty("/config/defaultConstraints/video").facingMode;
|
|
817
841
|
var oDevices = oModel.getProperty("/devices");
|
|
818
|
-
|
|
842
|
+
// when:
|
|
843
|
+
// a. no camera seleted
|
|
844
|
+
// b. main camera not found (no camera label contains '0, facing back')
|
|
845
|
+
// c. not iphone devices
|
|
846
|
+
// d. not Mac, or not ipad devices with Safari browser
|
|
847
|
+
// e. needCheck flag !== false
|
|
848
|
+
// f. camera list length > 1
|
|
849
|
+
// need to find main camera
|
|
850
|
+
if (!oModel.getProperty("/config/deviceId") && !oDevices.mainCamera && !Device.os.ios && !Device.os.macintosh && oDevices.needCheck && oDevices.all.length > 1) {
|
|
851
|
+
// if back camera list length > 1, find main camera in back camera list, or find it in all camera list
|
|
819
852
|
var oCameras = oDevices.back.length > 1 ? oDevices.back : oDevices.all;
|
|
820
853
|
var sCategory = oDevices.back.length > 1 ? "back" : "all";
|
|
821
|
-
Log.debug("BarcodeScanner.
|
|
854
|
+
Log.debug("BarcodeScanner.openCorrectCamera: start to find the main camera in " + sCategory + " camera list.");
|
|
822
855
|
findMainCamera(oCameras, openCamera);
|
|
823
856
|
return;
|
|
824
857
|
}
|
|
@@ -826,7 +859,8 @@ sap.ui.define([
|
|
|
826
859
|
openCamera();
|
|
827
860
|
}
|
|
828
861
|
|
|
829
|
-
function openCamera() {
|
|
862
|
+
function openCamera(bAttachOrientationChangeListener) {
|
|
863
|
+
Log.debug("BarcodeScanner.openCamera: start to open camera");
|
|
830
864
|
if (oModel.getProperty("/config/deviceId")) {
|
|
831
865
|
// if config/deviceId is set, use it as camera deviceId directly
|
|
832
866
|
delete oModel.getProperty("/config/defaultConstraints/video").facingMode;
|
|
@@ -846,28 +880,38 @@ sap.ui.define([
|
|
|
846
880
|
oModel.setProperty("/config/defaultConstraints/video/facingMode", "environment");
|
|
847
881
|
}
|
|
848
882
|
}
|
|
883
|
+
var oConstraints = deepClone(oModel.getProperty("/config/defaultConstraints"));
|
|
884
|
+
var oVideoResolution = calculateVideoResolution();
|
|
885
|
+
oConstraints.video = Object.assign(oConstraints.video, oVideoResolution);
|
|
849
886
|
window.navigator.mediaDevices
|
|
850
|
-
.getUserMedia(
|
|
887
|
+
.getUserMedia(oConstraints)
|
|
851
888
|
.then(
|
|
852
889
|
function(stream) {
|
|
853
890
|
oStream = stream;
|
|
854
891
|
if (oStream) {
|
|
855
|
-
|
|
892
|
+
playbackVideoAndDecode(bAttachOrientationChangeListener);
|
|
856
893
|
} else {
|
|
857
894
|
oModel.setProperty("/scanDialog/isNoScanner", true);
|
|
858
|
-
openBarcodeInputDialog();
|
|
895
|
+
openBarcodeInputDialog(oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_STREAM_ERROR_MSG'));
|
|
859
896
|
}
|
|
860
897
|
}
|
|
861
898
|
)
|
|
862
899
|
.catch(
|
|
863
|
-
function() {
|
|
864
|
-
|
|
865
|
-
|
|
900
|
+
function (error) {
|
|
901
|
+
Log.debug("BarcodeScanner.openCamera: getUserMedia() failed.\nError Message: " + error);
|
|
902
|
+
if (oModel.getProperty("/config/defaultConstraints/video/zoom") !== undefined) {
|
|
903
|
+
Log.debug("BarcodeScanner.openCamera: getUserMedia() failed maybe caused by unsupported constraint 'zoom', delete it and try again.");
|
|
904
|
+
delete oModel.getProperty("/config/defaultConstraints/video").zoom;
|
|
905
|
+
openCamera();
|
|
906
|
+
} else {
|
|
907
|
+
oModel.setProperty("/scanDialog/isNoScanner", true);
|
|
908
|
+
openBarcodeInputDialog(error);
|
|
909
|
+
}
|
|
866
910
|
}
|
|
867
911
|
);
|
|
868
912
|
}
|
|
869
913
|
|
|
870
|
-
function
|
|
914
|
+
function openScanDialog() {
|
|
871
915
|
oModel.checkUpdate(true);
|
|
872
916
|
var oDialogModel;
|
|
873
917
|
|
|
@@ -890,8 +934,10 @@ sap.ui.define([
|
|
|
890
934
|
}),
|
|
891
935
|
afterClose: function() {
|
|
892
936
|
closeScannerContain();
|
|
893
|
-
oScanDialog
|
|
894
|
-
|
|
937
|
+
if (oScanDialog) {
|
|
938
|
+
oScanDialog.destroyContent();
|
|
939
|
+
oScanDialog.destroy();
|
|
940
|
+
}
|
|
895
941
|
oScanDialog = null;
|
|
896
942
|
}
|
|
897
943
|
});
|
|
@@ -910,8 +956,25 @@ sap.ui.define([
|
|
|
910
956
|
oScanDialog.setModel(oResourceModel, "i18n");
|
|
911
957
|
}
|
|
912
958
|
|
|
959
|
+
oScanDialog.addStyleClass('sapUiNoContentPadding');
|
|
960
|
+
oScanDialog.setBusy(true);
|
|
961
|
+
|
|
913
962
|
if (isScannerAPIAvailable("ZXingCPP") && isUserMediaAccessSupported()) {
|
|
914
|
-
|
|
963
|
+
oScanDialog.attachAfterOpen(function() {
|
|
964
|
+
openCorrectCamera();
|
|
965
|
+
});
|
|
966
|
+
oScanDialog.destroyContent();
|
|
967
|
+
oBarcodeHighlightDOM = undefined;
|
|
968
|
+
oBarcodeOverlayDOM = undefined;
|
|
969
|
+
oBarcodeVideoDOM = undefined;
|
|
970
|
+
oBarcodeCanvasDOM = undefined;
|
|
971
|
+
|
|
972
|
+
oBarcodeScannerUIContainer = new BarcodeScannerUIContainer();
|
|
973
|
+
oScanDialog.addContent(oBarcodeScannerUIContainer);
|
|
974
|
+
oScanDialog.setContentWidth('100%');
|
|
975
|
+
oScanDialog.setContentHeight('100%');
|
|
976
|
+
|
|
977
|
+
oModel.setProperty("/scanDialog/barcodeOverlaySetup", false);
|
|
915
978
|
} else {
|
|
916
979
|
if (oModel.getProperty("/available")) {
|
|
917
980
|
oModel.setProperty("/scanDialog/isNoScanner", false);
|
|
@@ -920,8 +983,7 @@ sap.ui.define([
|
|
|
920
983
|
}
|
|
921
984
|
openBarcodeInputDialog();
|
|
922
985
|
}
|
|
923
|
-
|
|
924
|
-
return oScanDialog;
|
|
986
|
+
oScanDialog.open();
|
|
925
987
|
}
|
|
926
988
|
|
|
927
989
|
/**
|
|
@@ -941,39 +1003,39 @@ sap.ui.define([
|
|
|
941
1003
|
*/
|
|
942
1004
|
function scanWithCordova() {
|
|
943
1005
|
var options;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
}
|
|
957
|
-
} else {
|
|
958
|
-
getScanDialog();
|
|
1006
|
+
if (oModel.getProperty("/config/preferFrontCamera")) {
|
|
1007
|
+
options = {
|
|
1008
|
+
preferFrontCamera: true
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
oModel.getProperty("/apis/Cordova/scannerAPI").scan(
|
|
1012
|
+
function (oResult) {
|
|
1013
|
+
if (oResult.cancelled === "false" || !oResult.cancelled) {
|
|
1014
|
+
oResult.cancelled = false;
|
|
1015
|
+
var onFnSuccess = oModel.getProperty("/callBackHandler/onFnSuccess");
|
|
1016
|
+
if (typeof onFnSuccess === "function") {
|
|
1017
|
+
onFnSuccess(oResult);
|
|
959
1018
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1019
|
+
} else {
|
|
1020
|
+
openScanDialog();
|
|
1021
|
+
}
|
|
1022
|
+
oModel.setProperty("/bReady", true);
|
|
1023
|
+
},
|
|
1024
|
+
function (oEvent) {
|
|
1025
|
+
Log.error("BarcodeScanner.scanWithCordova: Barcode scanning failed.");
|
|
1026
|
+
oModel.setProperty("/bReady", true);
|
|
1027
|
+
var onFnFail = oModel.getProperty("/callBackHandler/onFnFail");
|
|
1028
|
+
if (typeof onFnFail === "function") {
|
|
1029
|
+
if (typeof oEvent === "string") {
|
|
1030
|
+
var str = oEvent;
|
|
1031
|
+
oEvent = {"text": str};
|
|
1032
|
+
Log.debug("BarcodeScanner.scanWithCordova: Change the type of oEvent from string to object");
|
|
973
1033
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1034
|
+
onFnFail(oEvent);
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
options
|
|
1038
|
+
);
|
|
977
1039
|
}
|
|
978
1040
|
|
|
979
1041
|
/**
|
|
@@ -984,7 +1046,7 @@ sap.ui.define([
|
|
|
984
1046
|
if (checkScannerAPIStatus("ZXingCPP", oScannerAPIStatus.Initial)) {
|
|
985
1047
|
Log.debug("BarcodeScanner.scanWithZXingCPP: ZXingCPP instances is not loaded, start to load them.");
|
|
986
1048
|
loadZXingCPPInstance(function() {
|
|
987
|
-
|
|
1049
|
+
openScanDialog();
|
|
988
1050
|
}, function() {
|
|
989
1051
|
if (isScannerAPIAvailable("ZebraEnterpriseBrowser")) {
|
|
990
1052
|
setCurrentScannerAPI("ZebraEnterpriseBrowser");
|
|
@@ -993,71 +1055,47 @@ sap.ui.define([
|
|
|
993
1055
|
setCurrentScannerAPI("unknown");
|
|
994
1056
|
Log.warning("BarcodeScanner.scanWithZXingCPP: Zebra is unavailable too, set the current scanner API to unknown.");
|
|
995
1057
|
}
|
|
996
|
-
|
|
1058
|
+
openScanDialog();
|
|
997
1059
|
});
|
|
998
1060
|
} else {
|
|
999
|
-
|
|
1061
|
+
Log.debug("BarcodeScanner.scanWithZXingCPP: get scan dialog.");
|
|
1062
|
+
openScanDialog();
|
|
1000
1063
|
}
|
|
1001
1064
|
}
|
|
1002
1065
|
|
|
1003
1066
|
/**
|
|
1004
|
-
*
|
|
1067
|
+
* Playback the video, then decode via ZXingCPP
|
|
1005
1068
|
* @private
|
|
1006
1069
|
*/
|
|
1007
|
-
function
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
oScanDialog.
|
|
1011
|
-
|
|
1012
|
-
// some error happened during dialog creation and may not be directly related to video element
|
|
1013
|
-
oScanDialog.getEndButton().setEnabled(true);
|
|
1014
|
-
oScanDialog.setBusy(false);
|
|
1070
|
+
function playbackVideoAndDecode(bAttachOrientationChangeListener) {
|
|
1071
|
+
// Dev note: if video element dom reference is unavailable at this point (console exception)
|
|
1072
|
+
// some error happened during dialog creation and may not be directly related to video element
|
|
1073
|
+
oScanDialog.getEndButton().setEnabled(true);
|
|
1074
|
+
oScanDialog.setBusy(false);
|
|
1015
1075
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1076
|
+
if (!oBarcodeHighlightDOM) {
|
|
1077
|
+
oBarcodeHighlightDOM = oBarcodeScannerUIContainer.getDomRef('highlight');
|
|
1078
|
+
}
|
|
1079
|
+
if (!oBarcodeVideoDOM) {
|
|
1080
|
+
oBarcodeVideoDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('video') : undefined;
|
|
1081
|
+
}
|
|
1082
|
+
try {
|
|
1083
|
+
oBarcodeVideoDOM.srcObject = oStream;
|
|
1084
|
+
oBarcodeVideoDOM.play().then(function() {
|
|
1085
|
+
// show scan overlay box
|
|
1086
|
+
scanFrame();
|
|
1087
|
+
if (Device.support.orientation && bAttachOrientationChangeListener !== false) {
|
|
1088
|
+
Device.orientation.attachHandler(orientationChangeListener);
|
|
1026
1089
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
oBarcodeCanvasDOM.height = oBarcodeVideoDOM.videoHeight;
|
|
1037
|
-
decodeWithZXingCPP();
|
|
1038
|
-
});
|
|
1039
|
-
} catch (err) {
|
|
1040
|
-
Log.debug("BarcodeScanner.openBarcodeScannerDialogContains is failed. error: " + err);
|
|
1041
|
-
}
|
|
1042
|
-
});
|
|
1043
|
-
oScanDialog.destroyContent();
|
|
1044
|
-
oBarcodeHighlightDOM = undefined;
|
|
1045
|
-
oBarcodeOverlayDOM = undefined;
|
|
1046
|
-
oBarcodeVideoDOM = undefined;
|
|
1047
|
-
|
|
1048
|
-
oBarcodeCanvasDOM = undefined;
|
|
1049
|
-
oContext = undefined;
|
|
1050
|
-
|
|
1051
|
-
oBarcodeScannerUIContainer = new BarcodeScannerUIContainer();
|
|
1052
|
-
oScanDialog.addContent(oBarcodeScannerUIContainer);
|
|
1053
|
-
|
|
1054
|
-
oScanDialog.setContentWidth('100%');
|
|
1055
|
-
oScanDialog.setContentHeight('100%');
|
|
1056
|
-
oScanDialog.addStyleClass('sapUiNoContentPadding');
|
|
1057
|
-
oScanDialog.setBusy(true);
|
|
1058
|
-
oScanDialog.open();
|
|
1059
|
-
|
|
1060
|
-
oModel.setProperty("/scanDialog/barcodeOverlaySetup", false);
|
|
1090
|
+
Log.debug("BarcodeScanner.playbackVideoAndDecode: video screen size " + oBarcodeVideoDOM.videoHeight + "X" + oBarcodeVideoDOM.videoWidth);
|
|
1091
|
+
oVideoTrack = typeof oStream.stop === "function" ? oStream : oStream.getTracks()[0];
|
|
1092
|
+
var settings = oVideoTrack.getSettings();
|
|
1093
|
+
Log.debug("BarcodeScanner.playbackVideoAndDecode: video screen frameRate is " + settings.frameRate + ", zoom is " + settings.zoom);
|
|
1094
|
+
decodeWithZXingCPP();
|
|
1095
|
+
});
|
|
1096
|
+
} catch (err) {
|
|
1097
|
+
Log.debug("BarcodeScanner.playbackVideoAndDecode is failed. error: " + err);
|
|
1098
|
+
}
|
|
1061
1099
|
}
|
|
1062
1100
|
|
|
1063
1101
|
/**
|
|
@@ -1065,31 +1103,43 @@ sap.ui.define([
|
|
|
1065
1103
|
* @private
|
|
1066
1104
|
*/
|
|
1067
1105
|
function decodeWithZXingCPP() {
|
|
1068
|
-
Log.
|
|
1106
|
+
Log.debug("BarcodeScanner.decodeWithZXingCPP: start to decode");
|
|
1069
1107
|
if (!oBarcodeVideoDOM || !oBarcodeVideoDOM.srcObject) {
|
|
1108
|
+
Log.debug("BarcodeScanner.decodeWithZXingCPP: video dom doesn't exist, stop decoding");
|
|
1070
1109
|
return;
|
|
1071
1110
|
}
|
|
1072
|
-
scanFrame();
|
|
1073
1111
|
|
|
1074
1112
|
try {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1113
|
+
// use canvas to get video frame as image data
|
|
1114
|
+
if (!oBarcodeCanvasDOM) {
|
|
1115
|
+
oBarcodeCanvasDOM = oBarcodeScannerUIContainer ? document.createElement("canvas") : undefined;
|
|
1116
|
+
}
|
|
1117
|
+
if (!oBarcodeCanvasDOM) {
|
|
1118
|
+
Log.debug("BarcodeScanner.decodeWithZXingCPP: canvas dom doesn't exist, stop decoding");
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
var oContext = oBarcodeCanvasDOM.getContext("2d", { willReadFrequently: true });
|
|
1122
|
+
var imgWidth = oBarcodeVideoDOM.videoWidth;
|
|
1123
|
+
var imgHeight = oBarcodeVideoDOM.videoHeight;
|
|
1124
|
+
oBarcodeCanvasDOM.width = imgWidth;
|
|
1125
|
+
oBarcodeCanvasDOM.height = imgHeight;
|
|
1126
|
+
oContext.drawImage(oBarcodeVideoDOM, 0, 0, imgWidth, imgHeight);
|
|
1127
|
+
var imageData = oContext.getImageData(0, 0, imgWidth, imgHeight);
|
|
1080
1128
|
var oData = imageData.data;
|
|
1129
|
+
// decode image data via ZXingCPP
|
|
1081
1130
|
var buffer;
|
|
1082
1131
|
var oZXingCPPScannerAPI = oModel.getProperty("/apis/ZXingCPP/scannerAPI");
|
|
1083
1132
|
try {
|
|
1084
1133
|
buffer = oZXingCPPScannerAPI._malloc(oData.length);
|
|
1085
1134
|
oZXingCPPScannerAPI.HEAPU8.set(oData, buffer);
|
|
1086
1135
|
} catch (err) {
|
|
1087
|
-
Log.
|
|
1136
|
+
Log.error("BarcodeScanner.decodeWithZXingCPP: zxing.HEAPU8 error: " + err);
|
|
1088
1137
|
}
|
|
1089
1138
|
var results = oZXingCPPScannerAPI.readBarcodesFromPixmap(buffer, imgWidth, imgHeight, true, "", 1);
|
|
1090
1139
|
oZXingCPPScannerAPI._free(buffer);
|
|
1091
1140
|
var iSize = results.size();
|
|
1092
1141
|
if (iSize > 0 && results.get(0).format) {
|
|
1142
|
+
Log.debug("BarcodeScanner.decodeWithZXingCPP: decode successful");
|
|
1093
1143
|
var result = results.get(0);
|
|
1094
1144
|
highlightResult(result);
|
|
1095
1145
|
if (result.cancelled === "false" || !result.cancelled) {
|
|
@@ -1139,8 +1189,8 @@ sap.ui.define([
|
|
|
1139
1189
|
}
|
|
1140
1190
|
|
|
1141
1191
|
if (oBarcodeHighlightDOM) {
|
|
1142
|
-
scaleX =
|
|
1143
|
-
scaleY =
|
|
1192
|
+
scaleX = oBarcodeVideoDOM.clientWidth / oBarcodeVideoDOM.videoWidth;
|
|
1193
|
+
scaleY = oBarcodeVideoDOM.clientHeight / oBarcodeVideoDOM.videoHeight;
|
|
1144
1194
|
if (result.position) {
|
|
1145
1195
|
result.resultPoints = [
|
|
1146
1196
|
result.position.topLeft,
|
|
@@ -1173,8 +1223,8 @@ sap.ui.define([
|
|
|
1173
1223
|
oBarcodeHighlightDOM.hidden = false;
|
|
1174
1224
|
oBarcodeHighlightDOM.style.top = top * scaleY + 'px';
|
|
1175
1225
|
oBarcodeHighlightDOM.style.left = left * scaleX + 'px';
|
|
1176
|
-
oBarcodeHighlightDOM.style.width = (right - left > 0 ? (right - left
|
|
1177
|
-
oBarcodeHighlightDOM.style.height = (bottom - top > 0 ? (bottom - top
|
|
1226
|
+
oBarcodeHighlightDOM.style.width = (right - left > 0 ? (right - left) * scaleX : 5) + 'px';
|
|
1227
|
+
oBarcodeHighlightDOM.style.height = (bottom - top > 0 ? (bottom - top) * scaleY : 5) + 'px';
|
|
1178
1228
|
}
|
|
1179
1229
|
}
|
|
1180
1230
|
|
|
@@ -1190,22 +1240,81 @@ sap.ui.define([
|
|
|
1190
1240
|
oBarcodeHighlightDOM.style.height = '0';
|
|
1191
1241
|
}
|
|
1192
1242
|
|
|
1243
|
+
/**
|
|
1244
|
+
* If orientaition changed, reopen camera to maxsize video screen
|
|
1245
|
+
* @private
|
|
1246
|
+
*/
|
|
1247
|
+
function orientationChangeListener(oNewOrientation) {
|
|
1248
|
+
oScanDialog.setBusy(true);
|
|
1249
|
+
var sOrientation = oNewOrientation.landscape ? "landscape" : "portrait";
|
|
1250
|
+
Log.debug("BarcodeScanner.orientationChangeListener: device orientation changed to " + sOrientation + ", call openCamera again to resize");
|
|
1251
|
+
if (oBarcodeOverlayDOM) {
|
|
1252
|
+
// hide overlay during orientation change
|
|
1253
|
+
oBarcodeOverlayDOM.hidden = true;
|
|
1254
|
+
}
|
|
1255
|
+
// close the camera since video screen is not in full size after orientation changed
|
|
1256
|
+
closeScannerContain(false);
|
|
1257
|
+
if (Device.os.ios || Device.os.macintosh) {
|
|
1258
|
+
// on iOS devices (iphone and ipad), the dialog may be in small size and moved to top left after orientation changed, so max size and reposition it in center
|
|
1259
|
+
oScanDialog._positionDialog();
|
|
1260
|
+
}
|
|
1261
|
+
// need to wait for the orientation change finished, then reopen camera so that the video screen is in full size
|
|
1262
|
+
setTimeout(function() {
|
|
1263
|
+
openCamera(false);
|
|
1264
|
+
}, 500);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Calculate video height and width
|
|
1269
|
+
* @returns {object} Video height and width object
|
|
1270
|
+
* @private
|
|
1271
|
+
*/
|
|
1272
|
+
function calculateVideoResolution() {
|
|
1273
|
+
var iAvailHeight = oBarcodeScannerUIContainer.getDomRef().clientHeight,
|
|
1274
|
+
iAvailWidth = oBarcodeScannerUIContainer.getDomRef().clientWidth,
|
|
1275
|
+
iWidth = 1920,
|
|
1276
|
+
iHeight = 1440;
|
|
1277
|
+
/*
|
|
1278
|
+
if (iAvailHeight > iAvailWidth) {
|
|
1279
|
+
iHeight = 1920;
|
|
1280
|
+
iWidth = Math.trunc(1920 * iAvailWidth / iAvailHeight);
|
|
1281
|
+
} else {
|
|
1282
|
+
iWidth = 1920;
|
|
1283
|
+
iHeight = Math.trunc(1920 * iAvailHeight / iAvailWidth);
|
|
1284
|
+
}*/
|
|
1285
|
+
// in portrait mode, width means height ???, so above codes will meet Not Full Screen issue when in this mode
|
|
1286
|
+
// have to change to below, need to check document
|
|
1287
|
+
if (iAvailHeight > iAvailWidth) {
|
|
1288
|
+
iHeight = Math.trunc(1920 * iAvailWidth / iAvailHeight);
|
|
1289
|
+
} else {
|
|
1290
|
+
iHeight = Math.trunc(1920 * iAvailHeight / iAvailWidth);
|
|
1291
|
+
}
|
|
1292
|
+
return {
|
|
1293
|
+
width: { ideal: iWidth },
|
|
1294
|
+
height: { ideal: iHeight }
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1193
1298
|
function scanFrame() {
|
|
1194
|
-
|
|
1299
|
+
Log.debug("BarcodeScanner.scanFrame: start to set up overlay dom");
|
|
1300
|
+
if (!oScanDialog || !oBarcodeVideoDOM || !oBarcodeVideoDOM.videoHeight || !oBarcodeVideoDOM.videoWidth) {
|
|
1301
|
+
Log.debug("BarcodeScanner.scanFrame: scan dialog or video screen is closed, stop set up");
|
|
1195
1302
|
return;
|
|
1196
1303
|
}
|
|
1197
1304
|
var iInactiveZonePercent = 0.15;
|
|
1198
|
-
var oBarcodeScannerUIContainer = oScanDialog.getContent()[0];
|
|
1199
1305
|
|
|
1200
1306
|
if (!oBarcodeOverlayDOM && oBarcodeScannerUIContainer) {
|
|
1201
1307
|
oBarcodeOverlayDOM = oBarcodeScannerUIContainer.getDomRef('overlay');
|
|
1202
1308
|
}
|
|
1203
1309
|
|
|
1204
|
-
updateZoom();
|
|
1205
|
-
|
|
1206
1310
|
if (oBarcodeOverlayDOM) {
|
|
1207
|
-
|
|
1208
|
-
|
|
1311
|
+
// show overlay since it may be hidden during orientation change
|
|
1312
|
+
oBarcodeOverlayDOM.hidden = false;
|
|
1313
|
+
var iBarcodeVideoDOMWidth = oBarcodeVideoDOM.clientWidth,
|
|
1314
|
+
iBarcodeVideoDOMHeight = oBarcodeVideoDOM.clientHeight;
|
|
1315
|
+
var oBarcodeOverlayWidthTemp = iBarcodeVideoDOMWidth * (1 - 2 * iInactiveZonePercent);
|
|
1316
|
+
var oBarcodeOverlayHeightTemp = iBarcodeVideoDOMHeight * (1 - 2 * iInactiveZonePercent);
|
|
1317
|
+
|
|
1209
1318
|
|
|
1210
1319
|
if (oBarcodeOverlayWidthTemp <= oBarcodeOverlayHeightTemp) {
|
|
1211
1320
|
oBarcodeOverlayHeightTemp = oBarcodeOverlayWidthTemp * (1 - 2 * iInactiveZonePercent);
|
|
@@ -1219,73 +1328,23 @@ sap.ui.define([
|
|
|
1219
1328
|
|
|
1220
1329
|
oBarcodeOverlayDOM.style.width = oBarcodeOverlayWidthTemp + 'px';
|
|
1221
1330
|
oBarcodeOverlayDOM.style.height = oBarcodeOverlayHeightTemp + 'px';
|
|
1222
|
-
oBarcodeOverlayDOM.style.borderWidth = (
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
function updateZoom() {
|
|
1228
|
-
if (oModel.getProperty("/config/zoom") !== "skipUpdateZoom" && oBarcodeVideoDOM) {
|
|
1229
|
-
var videoTrack = oBarcodeVideoDOM.srcObject.getVideoTracks();
|
|
1230
|
-
var oSupport = window.navigator.mediaDevices.getSupportedConstraints();
|
|
1231
|
-
var capabilities = videoTrack[0].getCapabilities();
|
|
1232
|
-
// Verify the permission about updating zoom
|
|
1233
|
-
if (oSupport.zoom && capabilities && capabilities.zoom) {
|
|
1234
|
-
Log.debug("BarcodeScanner.updateZoom: Support zoom to update");
|
|
1235
|
-
if (oModel.getProperty("/config/zoom") === 'undefined' || oModel.getProperty("/config/zoom") === null) {
|
|
1236
|
-
// reset zoom
|
|
1237
|
-
oModel.setProperty("/config/zoom", capabilities.zoom.min);
|
|
1238
|
-
}
|
|
1239
|
-
} else {
|
|
1240
|
-
Log.debug("BarcodeScanner.updateZoom: Don't support zoom or getCapabilities() failed.");
|
|
1241
|
-
oModel.setProperty("/config/zoom", "skipUpdateZoom");
|
|
1242
|
-
return;
|
|
1331
|
+
oBarcodeOverlayDOM.style.borderWidth = (iBarcodeVideoDOMHeight - oBarcodeOverlayHeightTemp) / 2 + 'px ' + (iBarcodeVideoDOMWidth - oBarcodeOverlayWidthTemp) / 2 + 'px';
|
|
1243
1332
|
}
|
|
1244
|
-
// Update zoom
|
|
1245
|
-
try {
|
|
1246
|
-
var fRoom = oModel.getProperty("/config/zoom");
|
|
1247
|
-
videoTrack[0].applyConstraints(
|
|
1248
|
-
{
|
|
1249
|
-
advanced: [{
|
|
1250
|
-
zoom: fRoom
|
|
1251
|
-
}]
|
|
1252
|
-
}
|
|
1253
|
-
).then(
|
|
1254
|
-
function() {
|
|
1255
|
-
oModel.setProperty("/config/zoom", "skipUpdateZoom");
|
|
1256
|
-
Log.debug("BarcodeScanner.updateZoom: Zoom is updated to " + fRoom);
|
|
1257
|
-
}
|
|
1258
|
-
).catch(
|
|
1259
|
-
function(error) {
|
|
1260
|
-
if (error && error.message && error.message.match(/out of range|Failed to read the 'zoom' property/i)) {
|
|
1261
|
-
oModel.setProperty("/config/zoom", "skipUpdateZoom");
|
|
1262
|
-
MessageToast.show(
|
|
1263
|
-
oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_UPDATE_PARAMETER_ERROR_MSG', 'zoom'),
|
|
1264
|
-
{
|
|
1265
|
-
duration: 1000
|
|
1266
|
-
}
|
|
1267
|
-
);
|
|
1268
|
-
} else {
|
|
1269
|
-
Log.error("BarcodeScanner.updateZoom: Update zoom to " + fRoom + " failed. Error Message:" + error);
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
);
|
|
1273
|
-
} catch (err) {
|
|
1274
|
-
Log.error("BarcodeScanner.updateZoom: applyConstraints() failed. Error Message:" + err);
|
|
1275
|
-
oModel.setProperty("/config/zoom", "skipUpdateZoom");
|
|
1276
|
-
}
|
|
1277
|
-
var settings = videoTrack[0].getSettings();
|
|
1278
|
-
Log.debug("BarcodeScanner.updateZoom: frameRate is " + settings.frameRate + ". zoom is " + settings.zoom);
|
|
1279
1333
|
}
|
|
1280
1334
|
}
|
|
1281
1335
|
|
|
1282
|
-
function closeScannerContain() {
|
|
1336
|
+
function closeScannerContain(bDetachOrientationChangeListener) {
|
|
1283
1337
|
// oStream and oBarcodeVideoDOM.srcObject point to the same video stream, set them to undefined when closing scan screen
|
|
1338
|
+
if (oVideoTrack) {
|
|
1339
|
+
oVideoTrack.stop();
|
|
1340
|
+
oVideoTrack = undefined;
|
|
1341
|
+
}
|
|
1284
1342
|
if (oStream) {
|
|
1285
|
-
var videoTrack = typeof oStream.stop === "function" ? oStream : oStream.getTracks()[0];
|
|
1286
|
-
videoTrack.stop();
|
|
1287
1343
|
oStream = undefined;
|
|
1288
1344
|
}
|
|
1345
|
+
if (Device.support.orientation && bDetachOrientationChangeListener !== false) {
|
|
1346
|
+
Device.orientation.detachHandler(orientationChangeListener);
|
|
1347
|
+
}
|
|
1289
1348
|
if (oBarcodeVideoDOM && oBarcodeVideoDOM.srcObject) {
|
|
1290
1349
|
oBarcodeVideoDOM.srcObject = undefined;
|
|
1291
1350
|
}
|
|
@@ -1398,6 +1457,7 @@ sap.ui.define([
|
|
|
1398
1457
|
* true,
|
|
1399
1458
|
* 30,
|
|
1400
1459
|
* 1,
|
|
1460
|
+
* false,
|
|
1401
1461
|
* false
|
|
1402
1462
|
* );
|
|
1403
1463
|
* });
|
|
@@ -1411,15 +1471,17 @@ sap.ui.define([
|
|
|
1411
1471
|
* @param {float} [frameRate] Defines the frame rate of the camera.
|
|
1412
1472
|
* @param {float} [zoom] Defines the zoom of the camera. This parameter is not supported on iOS.
|
|
1413
1473
|
* @param {boolean} [keepCameraScan] Flag, which defines whether the camera should be used for scanning in Zebra Enterprise Browser.
|
|
1474
|
+
* @param {boolean} [disableBarcodeInputDialog] Flag, which defines whether the Barcode input dialog should be shown.
|
|
1414
1475
|
*
|
|
1415
1476
|
* @public
|
|
1416
1477
|
* @static
|
|
1417
1478
|
*/
|
|
1418
|
-
BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle, preferFrontCamera, frameRate, zoom, keepCameraScan) {
|
|
1479
|
+
BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle, preferFrontCamera, frameRate, zoom, keepCameraScan, disableBarcodeInputDialog) {
|
|
1419
1480
|
if (!oModel.getProperty("/bReady")) {
|
|
1420
1481
|
Log.error("BarcodeScanner.scan: Barcode scanning is already in progress.");
|
|
1421
1482
|
return;
|
|
1422
1483
|
}
|
|
1484
|
+
Log.debug("BarcodeScanner.scan: start to scan barcode.");
|
|
1423
1485
|
|
|
1424
1486
|
oModel.setProperty("/bReady", false);
|
|
1425
1487
|
if (typeof fnSuccess === 'function') {
|
|
@@ -1459,15 +1521,33 @@ sap.ui.define([
|
|
|
1459
1521
|
}
|
|
1460
1522
|
);
|
|
1461
1523
|
}
|
|
1462
|
-
|
|
1524
|
+
// Reset zoom
|
|
1525
|
+
if (oModel.getProperty("/config/defaultConstraints/video/zoom") !== undefined) {
|
|
1526
|
+
delete oModel.getProperty("/config/defaultConstraints/video").zoom;
|
|
1527
|
+
}
|
|
1528
|
+
// apply value of zoom parameter
|
|
1529
|
+
if (typeof zoom === "number" && zoom > 0) {
|
|
1530
|
+
oModel.setProperty("/config/defaultConstraints/video/zoom", zoom);
|
|
1531
|
+
} else if (typeof zoom !== 'undefined') {
|
|
1532
|
+
MessageToast.show(
|
|
1533
|
+
oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_UPDATE_PARAMETER_ERROR_MSG', 'zoom'),
|
|
1534
|
+
{
|
|
1535
|
+
duration: 1000
|
|
1536
|
+
}
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1463
1539
|
oModel.setProperty("/scanDialog/keepCameraScan", keepCameraScan);
|
|
1540
|
+
oModel.setProperty("/scanDialog/disableBarcodeInputDialog", disableBarcodeInputDialog);
|
|
1464
1541
|
oModel.checkUpdate(true);
|
|
1465
1542
|
|
|
1466
1543
|
if (checkZebraEBScanAvailable()) {
|
|
1544
|
+
Log.debug("BarcodeScanner.scan: Zebra EB is available, use it to scan barcode.");
|
|
1467
1545
|
scanWithZebra();
|
|
1468
1546
|
} else if (isScannerAPIAvailable("Cordova")) {
|
|
1547
|
+
Log.debug("BarcodeScanner.scan: Cordova is available, use it to scan barcode.");
|
|
1469
1548
|
scanWithCordova();
|
|
1470
1549
|
} else {
|
|
1550
|
+
Log.debug("BarcodeScanner.scan: both of Zebra EB and Cordova are NOT available, use ZXingCPP to scan barcode.");
|
|
1471
1551
|
scanWithZXingCPP();
|
|
1472
1552
|
}
|
|
1473
1553
|
};
|
|
@@ -1482,6 +1562,7 @@ sap.ui.define([
|
|
|
1482
1562
|
BarcodeScanner.closeScanDialog = function () {
|
|
1483
1563
|
if (oScanDialog) {
|
|
1484
1564
|
oScanDialog.close();
|
|
1565
|
+
oScanDialog.fireAfterClose();
|
|
1485
1566
|
oModel.setProperty("/scanDialog/scanningStartTime", 0);
|
|
1486
1567
|
oModel.setProperty("/scanDialog/onLiveUpdate", null);
|
|
1487
1568
|
}
|
|
@@ -1569,7 +1650,7 @@ sap.ui.define([
|
|
|
1569
1650
|
Log.error("BarcodeScanner.scan: The scanner API '" + scannerAPI + "' is unavailable, will use current scanner API '" + oModel.getProperty("/apis/" + getCurrentScannerAPI() + "/description") + "' to scan the barcode.");
|
|
1570
1651
|
return false;
|
|
1571
1652
|
} else {
|
|
1572
|
-
Log.
|
|
1653
|
+
Log.debug("BarcodeScanner.scan: Switch to scanner API '" + scannerAPI + "' to scan the barcode.");
|
|
1573
1654
|
setCurrentScannerAPI(scannerAPI);
|
|
1574
1655
|
return true;
|
|
1575
1656
|
}
|
|
@@ -1577,7 +1658,7 @@ sap.ui.define([
|
|
|
1577
1658
|
Log.error("BarcodeScanner.scan: The scanner API '" + scannerAPI + "' is unavailable, will use current scanner API '" + oModel.getProperty("/apis/" + getCurrentScannerAPI() + "/description") + "' to scan the barcode.");
|
|
1578
1659
|
return false;
|
|
1579
1660
|
} else {
|
|
1580
|
-
Log.
|
|
1661
|
+
Log.debug("BarcodeScanner.scan: Switch to scanner API '" + scannerAPI + "' to scan the barcode.");
|
|
1581
1662
|
setCurrentScannerAPI(scannerAPI);
|
|
1582
1663
|
return true;
|
|
1583
1664
|
}
|