@sapui5/sap.ndc 1.110.0 → 1.111.1

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.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/src/sap/ndc/.library +1 -1
  3. package/src/sap/ndc/BarcodeScanner.js +306 -37
  4. package/src/sap/ndc/BarcodeScannerUIContainer.js +29 -0
  5. package/src/sap/ndc/css/sapNdcBarcodeScanner.css +29 -0
  6. package/src/sap/ndc/library.js +1 -1
  7. package/src/sap/ndc/messagebundle.properties +27 -0
  8. package/src/sap/ndc/messagebundle_ar.properties +18 -0
  9. package/src/sap/ndc/messagebundle_bg.properties +18 -0
  10. package/src/sap/ndc/messagebundle_ca.properties +18 -0
  11. package/src/sap/ndc/messagebundle_cs.properties +18 -0
  12. package/src/sap/ndc/messagebundle_cy.properties +18 -0
  13. package/src/sap/ndc/messagebundle_da.properties +18 -0
  14. package/src/sap/ndc/messagebundle_de.properties +18 -0
  15. package/src/sap/ndc/messagebundle_el.properties +18 -0
  16. package/src/sap/ndc/messagebundle_en.properties +18 -0
  17. package/src/sap/ndc/messagebundle_en_GB.properties +18 -0
  18. package/src/sap/ndc/messagebundle_en_US_sappsd.properties +18 -0
  19. package/src/sap/ndc/messagebundle_en_US_saprigi.properties +1 -1
  20. package/src/sap/ndc/messagebundle_en_US_saptrc.properties +18 -0
  21. package/src/sap/ndc/messagebundle_es.properties +18 -0
  22. package/src/sap/ndc/messagebundle_es_MX.properties +18 -0
  23. package/src/sap/ndc/messagebundle_et.properties +18 -0
  24. package/src/sap/ndc/messagebundle_fi.properties +18 -0
  25. package/src/sap/ndc/messagebundle_fr.properties +18 -0
  26. package/src/sap/ndc/messagebundle_fr_CA.properties +18 -0
  27. package/src/sap/ndc/messagebundle_hi.properties +18 -0
  28. package/src/sap/ndc/messagebundle_hr.properties +18 -0
  29. package/src/sap/ndc/messagebundle_hu.properties +18 -0
  30. package/src/sap/ndc/messagebundle_id.properties +18 -0
  31. package/src/sap/ndc/messagebundle_it.properties +18 -0
  32. package/src/sap/ndc/messagebundle_iw.properties +18 -0
  33. package/src/sap/ndc/messagebundle_ja.properties +18 -0
  34. package/src/sap/ndc/messagebundle_kk.properties +18 -0
  35. package/src/sap/ndc/messagebundle_ko.properties +18 -0
  36. package/src/sap/ndc/messagebundle_lt.properties +18 -0
  37. package/src/sap/ndc/messagebundle_lv.properties +18 -0
  38. package/src/sap/ndc/messagebundle_ms.properties +18 -0
  39. package/src/sap/ndc/messagebundle_nl.properties +18 -0
  40. package/src/sap/ndc/messagebundle_no.properties +18 -0
  41. package/src/sap/ndc/messagebundle_pl.properties +18 -0
  42. package/src/sap/ndc/messagebundle_pt.properties +18 -0
  43. package/src/sap/ndc/messagebundle_pt_PT.properties +18 -0
  44. package/src/sap/ndc/messagebundle_ro.properties +18 -0
  45. package/src/sap/ndc/messagebundle_ru.properties +18 -0
  46. package/src/sap/ndc/messagebundle_sh.properties +18 -0
  47. package/src/sap/ndc/messagebundle_sk.properties +18 -0
  48. package/src/sap/ndc/messagebundle_sl.properties +18 -0
  49. package/src/sap/ndc/messagebundle_sv.properties +18 -0
  50. package/src/sap/ndc/messagebundle_th.properties +18 -0
  51. package/src/sap/ndc/messagebundle_tr.properties +18 -0
  52. package/src/sap/ndc/messagebundle_uk.properties +18 -0
  53. package/src/sap/ndc/messagebundle_vi.properties +18 -0
  54. package/src/sap/ndc/messagebundle_zh_CN.properties +18 -0
  55. package/src/sap/ndc/messagebundle_zh_TW.properties +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapui5/sap.ndc",
3
- "version": "1.110.0",
3
+ "version": "1.111.1",
4
4
  "description": "SAPUI5 Library sap.ndc",
5
5
  "homepage": "https://sap.github.io/ui5-tooling/pages/SAPUI5/",
6
6
  "author": "SAP SE (https://www.sap.com)",
@@ -5,7 +5,7 @@
5
5
  <vendor>SAP SE</vendor>
6
6
  <copyright>SAPUI5
7
7
  * (c) Copyright 2009-2023 SAP SE. All rights reserved.</copyright>
8
- <version>1.110.0</version>
8
+ <version>1.111.1</version>
9
9
 
10
10
  <documentation>SAPUI5 library with controls with native device capabilities.</documentation>
11
11
 
@@ -41,9 +41,10 @@ sap.ui.define([
41
41
  "sap/ui/base/EventProvider",
42
42
  'sap/ui/Device',
43
43
  "sap/ui/thirdparty/jquery",
44
- "sap/base/util/deepClone"
44
+ "sap/base/util/deepClone",
45
+ "sap/m/Avatar"
45
46
  ],
46
- function(Log, JSONModel, BindingMode, ResourceModel, Input, Label, Button, Dialog, BusyDialog, includeStylesheet, BarcodeScannerUIContainer, MessageToast, mobileLibrary, Event, EventProvider, Device, jQuery, deepClone) {
47
+ function(Log, JSONModel, BindingMode, ResourceModel, Input, Label, Button, Dialog, BusyDialog, includeStylesheet, BarcodeScannerUIContainer, MessageToast, mobileLibrary, Event, EventProvider, Device, jQuery, deepClone, Avatar) {
47
48
  "use strict";
48
49
 
49
50
  document.addEventListener("settingsDone", init);
@@ -93,6 +94,7 @@ sap.ui.define([
93
94
  oCap,
94
95
  oScanDialog,
95
96
  oBarcodeVideoDOM,
97
+ oBarcodeImageDOM,
96
98
  oBarcodeOverlayDOM,
97
99
  oBarcodeHighlightDOM,
98
100
 
@@ -660,6 +662,7 @@ sap.ui.define([
660
662
  */
661
663
  function findMainCamera(aCameras, fnCallback) {
662
664
  var aCamerasClone = deepClone(aCameras);
665
+ var iIndex = aCameras.length;
663
666
  var fnCheckStream = function () {
664
667
  if (aCamerasClone.length === 0) {
665
668
  oModel.setProperty("/devices/needCheck", false);
@@ -668,6 +671,7 @@ sap.ui.define([
668
671
  fnCallback();
669
672
  } else {
670
673
  var oCamera = aCamerasClone.pop();
674
+ iIndex--;
671
675
  var oConstraints = deepClone(oModel.getProperty("/config/defaultConstraints"));
672
676
  oConstraints.video.deviceId = {
673
677
  exact: oCamera.deviceId
@@ -677,13 +681,16 @@ sap.ui.define([
677
681
  .then(
678
682
  function(stream) {
679
683
  var videoTrack = typeof stream.stop === "function" ? stream : stream.getTracks()[0];
680
- // main camera always support flash light.
684
+ // main camera always support flashlight.
681
685
  checkFlashLight(videoTrack).then(function() {
682
- oCamera.flashLight = true;
683
- oModel.setProperty("/devices/mainCamera", oCamera);
686
+ aCameras[iIndex].hasFlashLight = true;
687
+ oModel.setProperty("/devices/mainCamera", aCameras[iIndex]);
684
688
  oModel.setProperty("/devices/needCheck", false);
685
689
  updateDevicesInStatusModel();
686
690
  Log.debug("BarcodeScanner.findMainCamera: the main camera is " + oCamera.deviceId);
691
+ oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", true);
692
+ oModel.setProperty("/scanDialog/hasFlashLight", true);
693
+ Log.debug("BarcodeScanner.findMainCamera: enable flashlight");
687
694
  oStream = stream;
688
695
  // use ZXingCPP or ZXing to scan the barcode directly if :
689
696
  // current scanner API is ZXing, and ZXing is available
@@ -693,10 +700,11 @@ sap.ui.define([
693
700
  || (getCurrentScannerAPI() === "ZXing" && isScannerAPIAvailable("ZXing"))) {
694
701
  openBarcodeScannerDialogContains();
695
702
  } else {
696
- oScanDialog.getModel().setProperty("/isNoScanner", true);
703
+ oScanDialog && oScanDialog.getModel().setProperty("/isNoScanner", true);
697
704
  openBarcodeInputDialog();
698
705
  }
699
706
  }, function() {
707
+ aCameras[iIndex].hasFlashLight = false;
700
708
  videoTrack.stop();
701
709
  Log.debug("BarcodeScanner.findMainCamera: " + oCamera.deviceId + " is not the main camera, check the next camera");
702
710
  fnCheckStream();
@@ -744,10 +752,10 @@ sap.ui.define([
744
752
  return new Promise(function (resolve, reject) {
745
753
  oImageCapture.getPhotoCapabilities().then(function(oCapabilities) {
746
754
  if (oCapabilities.fillLightMode && oCapabilities.fillLightMode.includes("flash")) {
747
- Log.debug("BarcodeScanner.checkFlashLight: Camera does support flash light");
755
+ Log.debug("BarcodeScanner.checkFlashLight: Camera supports flashlight");
748
756
  resolve();
749
757
  } else {
750
- Log.debug("BarcodeScanner.checkFlashLight: Camera doesn't support flash light");
758
+ Log.debug("BarcodeScanner.checkFlashLight: Camera doesn't support flashlight");
751
759
  reject();
752
760
  }
753
761
  }).catch(function(oError) {
@@ -758,6 +766,189 @@ sap.ui.define([
758
766
  }
759
767
  }
760
768
 
769
+ /**
770
+ * Open or close flashlight
771
+ * @private
772
+ */
773
+ function toggleFlashLight() {
774
+ if (!oModel.getProperty("/scanDialog/hasFlashLight")) {
775
+ Log.error("BarcodeScanner.toggleFlashLight: No flashlight currently");
776
+ return;
777
+ }
778
+ var bIsFlashLightOn = oModel.getProperty("/scanDialog/flashLightOn");
779
+ var sProcess = !bIsFlashLightOn ? "Open" : "Close";
780
+ var videoTrack = typeof oStream.stop === "function" ? oStream : oStream.getTracks()[0];
781
+ videoTrack.applyConstraints({
782
+ advanced: [{
783
+ torch: !bIsFlashLightOn
784
+ }]
785
+ }).then(
786
+ function() {
787
+ oModel.setProperty("/scanDialog/flashLightOn", !bIsFlashLightOn);
788
+ Log.debug("BarcodeScanner.toggleFlashLight: " + sProcess + " flashlight of camera success.");
789
+ }
790
+ ).catch(
791
+ function(error) {
792
+ var sErrorMsgKey = "BARCODE_DIALOG_" + sProcess.toUpperCase() + "_FLASHLIGHT_ERROR_MSG";
793
+ MessageToast.show(
794
+ oResourceModel.getResourceBundle().getText(sErrorMsgKey),
795
+ {
796
+ duration: 1000
797
+ }
798
+ );
799
+ Log.error("BarcodeScanner.toggleFlashLight: " + sProcess + " flashlight of camera failed. Error Message:" + error);
800
+ }
801
+ );
802
+ }
803
+
804
+ /**
805
+ * Open image gallery to select image
806
+ * @private
807
+ */
808
+ function openImageGallery() {
809
+ // close the flashlight if it is ON
810
+ var bIsFlashLightOn = oModel.getProperty("/scanDialog/flashLightOn");
811
+ if (bIsFlashLightOn) {
812
+ toggleFlashLight();
813
+ }
814
+ if (oBarcodeImageDOM) {
815
+ return oBarcodeImageDOM.click();
816
+ }
817
+ }
818
+
819
+ function fileSelected() {
820
+ BarcodeScanner.closeScanDialog();
821
+ var oFile = oBarcodeImageDOM.files[0];
822
+ if (oFile) {
823
+ oBarcodeVideoDOM = undefined;
824
+ scanFile(oFile);
825
+ }
826
+ }
827
+
828
+ /**
829
+ * Scan the selected image file
830
+ * @private
831
+ */
832
+ function scanFile(oFile) {
833
+ var oBusyDialog = new BusyDialog({
834
+ title: oResourceModel.getProperty("BARCODE_DIALOG_SCAN_IMAGE_BUSY_TITLE")
835
+ });
836
+ oBusyDialog.open();
837
+ oModel.setProperty("/scanDialog/scanningStartTime", Date.now());
838
+ var reader = new FileReader();
839
+ reader.onload = function(evt) {
840
+ // compress the selected image file, then decode it with ZXingCPP
841
+ compress(evt.target.result).then(function(fileData) {
842
+ var buffer;
843
+ var oZXingCPPScannerAPI = oModel.getProperty("/apis/ZXingCPP/scannerAPI");
844
+ try {
845
+ buffer = oZXingCPPScannerAPI._malloc(fileData.length);
846
+ oZXingCPPScannerAPI.HEAPU8.set(fileData, buffer);
847
+ } catch (err) {
848
+ Log.info("BarcodeScanner.scanFile: zxing.HEAPU8 error: " + err);
849
+ }
850
+ var result = oZXingCPPScannerAPI.readBarcodeFromImage(buffer, fileData.length, true, "");
851
+ oZXingCPPScannerAPI._free(buffer);
852
+ oBusyDialog.close();
853
+ if (result.format) {
854
+ if (result.cancelled === "false" || !result.cancelled) {
855
+ result.cancelled = false;
856
+ var onFnSuccess = oModel.getProperty("/callBackHandler/onFnSuccess");
857
+ if (typeof onFnSuccess === "function") {
858
+ var scanningStopTime = Date.now();
859
+ result.scanningTime = scanningStopTime - oModel.getProperty("/scanDialog/scanningStartTime");
860
+ if (oModel.getProperty("/config/enableGS1Header")) {
861
+ // Add the symbology identifier of GS1 as prefix into the result text of ZXingCPP
862
+ result.text = result.symbologyIdentifier + result.text;
863
+ }
864
+ onFnSuccess(result);
865
+ oModel.setProperty("/scanDialog/scanningStartTime", 0);
866
+ }
867
+ }
868
+ } else {
869
+ MessageToast.show(
870
+ oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_SCAN_IMAGE_ERROR_MSG'),
871
+ {
872
+ duration: 1000
873
+ }
874
+ );
875
+ }
876
+ }, function() {
877
+ oBusyDialog.close();
878
+ MessageToast.show(
879
+ oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_SCAN_IMAGE_COMPRESS_FAILED_MSG'),
880
+ {
881
+ duration: 1000
882
+ }
883
+ );
884
+ });
885
+ };
886
+ reader.onerror = function() {
887
+ oBusyDialog.close();
888
+ MessageToast.show(
889
+ oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_SCAN_IMAGE_LOAD_FAILED_MSG'),
890
+ {
891
+ duration: 1000
892
+ }
893
+ );
894
+ };
895
+ reader.readAsDataURL(oFile);
896
+ }
897
+
898
+ /**
899
+ * Compress the image file since currently the image file size may be very large
900
+ * @private
901
+ */
902
+ function compress(res) {
903
+ var maxWidth = 800,
904
+ maxHeight = 800,
905
+ imageType = "image/png";
906
+ return new Promise(function (resolve, reject) {
907
+ var img = new Image();
908
+ img.onload = function() {
909
+ var originWidth = this.width,
910
+ originHeight = this.height;
911
+ var canvas = document.createElement("canvas");
912
+ var context = canvas.getContext("2d");
913
+
914
+ var targetWidth = originWidth,
915
+ targetHeight = originHeight;
916
+ // if image width or height is larger than 800, reset the width and height
917
+ if (originWidth > maxWidth || originHeight > maxHeight) {
918
+ if (originWidth / originHeight > maxWidth / maxHeight) {
919
+ targetWidth = maxWidth;
920
+ targetHeight = Math.round(maxWidth * (originHeight / originWidth));
921
+ } else {
922
+ targetHeight = maxHeight;
923
+ targetWidth = Math.round(maxHeight * (originWidth / originHeight));
924
+ }
925
+ }
926
+
927
+ // use canvas to compress the image
928
+ canvas.width = targetWidth;
929
+ canvas.height = targetHeight;
930
+
931
+ // clean
932
+ context.clearRect(0, 0, targetWidth, targetHeight);
933
+ // draw the image
934
+ context.drawImage(img, 0, 0, targetWidth, targetHeight);
935
+
936
+ var data = canvas.toDataURL(imageType);
937
+ data = data.split(',')[1];
938
+ data = window.atob(data);
939
+ var ia = new Uint8Array(data.length);
940
+ for (var i = 0; i < data.length; i++) {
941
+ ia[i] = data.charCodeAt(i);
942
+ }
943
+ resolve(ia);
944
+ };
945
+ img.onerror = function() {
946
+ reject();
947
+ };
948
+ img.src = res;
949
+ });
950
+ }
951
+
761
952
  /**
762
953
  * Used to detect browsers which does not have access to html5 user media api and can not use device camera
763
954
  * @private
@@ -872,6 +1063,7 @@ sap.ui.define([
872
1063
  Log.warning("BarcodeScanner.openBarcodeInputDialog: isNoScanner. Message: " + sMessage);
873
1064
  }
874
1065
 
1066
+ oScanDialog.setShowHeader(true);
875
1067
  oScanDialog.destroyContent();
876
1068
  oScanDialog.setTitle('');
877
1069
  oScanDialog.setStretch(false);
@@ -965,6 +1157,7 @@ sap.ui.define([
965
1157
  }
966
1158
 
967
1159
  function openCamera() {
1160
+ var bIsMainCamera = false;
968
1161
  if (oModel.getProperty("/config/deviceId")) {
969
1162
  // if config/deviceId is set, use it as camera deviceId directly
970
1163
  delete oModel.getProperty("/config/defaultConstraints/video").facingMode;
@@ -977,6 +1170,7 @@ sap.ui.define([
977
1170
  } else {
978
1171
  var oDevices = oModel.getProperty("/devices");
979
1172
  if (oDevices.mainCamera && oDevices.mainCamera.deviceId !== "") {
1173
+ bIsMainCamera = true;
980
1174
  oModel.setProperty("/config/defaultConstraints/video/deviceId", {
981
1175
  exact: oDevices.mainCamera.deviceId
982
1176
  });
@@ -989,6 +1183,33 @@ sap.ui.define([
989
1183
  .then(
990
1184
  function(stream) {
991
1185
  oStream = stream;
1186
+ if (Device.os.ios) {
1187
+ // can not control flashlight on ios devices since no API supported now
1188
+ oModel.setProperty("/scanDialog/hasFlashLight", false);
1189
+ oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", false);
1190
+ } else {
1191
+ if (bIsMainCamera && typeof oDevices.mainCamera.hasFlashLight === "boolean") {
1192
+ // set flashlight
1193
+ oModel.setProperty("/scanDialog/hasFlashLight", oDevices.mainCamera.hasFlashLight);
1194
+ oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", oDevices.mainCamera.hasFlashLight);
1195
+ } else {
1196
+ var videoTrack = typeof stream.stop === "function" ? stream : stream.getTracks()[0];
1197
+ checkFlashLight(videoTrack).then(function() {
1198
+ // enable flashlight
1199
+ oModel.setProperty("/scanDialog/hasFlashLight", true);
1200
+ if (bIsMainCamera) {
1201
+ oDevices.mainCamera.hasFlashLight = true;
1202
+ }
1203
+ oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", true);
1204
+ }, function() {
1205
+ oModel.setProperty("/scanDialog/hasFlashLight", false);
1206
+ if (bIsMainCamera) {
1207
+ oDevices.mainCamera.hasFlashLight = false;
1208
+ }
1209
+ oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", false);
1210
+ });
1211
+ }
1212
+ }
992
1213
  // use ZXingCPP or ZXing to scan the barcode if :
993
1214
  // current scanner API is ZXing, and ZXing is available
994
1215
  // or
@@ -1015,21 +1236,15 @@ sap.ui.define([
1015
1236
  var oDialogModel;
1016
1237
 
1017
1238
  if (!oScanDialog || (oScanDialog && oScanDialog.getContent().length === 0)) {
1018
- oDialogModel = new JSONModel();
1239
+ oDialogModel = new JSONModel({
1240
+ hasFlashLight: oModel.getProperty("/scanDialog/hasFlashLight") && !Device.os.ios
1241
+ });
1019
1242
  oScanDialog = new Dialog('sapNdcBarcodeScannerDialog', {
1020
1243
  icon: 'sap-icon://bar-code',
1021
1244
  title: oResourceModel.getProperty("BARCODE_DIALOG_SCANNING_TITLE"),
1022
1245
  stretch: true,
1023
1246
  horizontalScrolling: false,
1024
1247
  verticalScrolling: false,
1025
- endButton: new Button({
1026
- text: "{i18n>BARCODE_DIALOG_CANCEL}",
1027
- enabled: false,
1028
- press: function() {
1029
- oScanDialog.getModel().setProperty("/isNoScanner", false);
1030
- openBarcodeInputDialog();
1031
- }
1032
- }),
1033
1248
  afterClose: function() {
1034
1249
  closeScannerContain();
1035
1250
  oScanDialog.destroyContent();
@@ -1189,6 +1404,29 @@ sap.ui.define([
1189
1404
  }
1190
1405
  }
1191
1406
 
1407
+ function updateScanDialogButtonAndGetDOMs(oBarcodeScannerUIContainer) {
1408
+ // Dev note: if video element dom reference is unavailable at this point (console exception)
1409
+ // some error happened during dialog creation and may not be directly related to video element
1410
+ oScanDialog.setBusy(false);
1411
+
1412
+ if (!oBarcodeHighlightDOM) {
1413
+ oBarcodeHighlightDOM = oBarcodeScannerUIContainer.getDomRef('highlight');
1414
+ }
1415
+ if (!oBarcodeVideoDOM) {
1416
+ oBarcodeVideoDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('video') : undefined;
1417
+ if (oBarcodeVideoDOM) {
1418
+ document.body.style.setProperty("--sapNdcRTCDialogVideoHeight", oBarcodeVideoDOM.clientHeight + 'px');
1419
+ document.body.style.setProperty("--sapNdcRTCDialogVideoWidth", oBarcodeVideoDOM.clientWidth + 'px');
1420
+ }
1421
+ }
1422
+ if (!oBarcodeImageDOM) {
1423
+ oBarcodeImageDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('image') : undefined;
1424
+ if (oBarcodeImageDOM) {
1425
+ oBarcodeImageDOM.addEventListener("change", fileSelected);
1426
+ }
1427
+ }
1428
+ }
1429
+
1192
1430
  /**
1193
1431
  * Opens Barcode Scanner dialog, called when code reader is ready
1194
1432
  * @private
@@ -1200,15 +1438,7 @@ sap.ui.define([
1200
1438
  oScanDialog.attachAfterOpen(function() {
1201
1439
  // Dev note: if video element dom reference is unavailable at this point (console exception)
1202
1440
  // some error happened during dialog creation and may not be directly related to video element
1203
- oScanDialog.getEndButton().setEnabled(true);
1204
- oScanDialog.setBusy(false);
1205
-
1206
- if (!oBarcodeHighlightDOM) {
1207
- oBarcodeHighlightDOM = oBarcodeScannerUIContainer.getDomRef('highlight');
1208
- }
1209
- if (!oBarcodeVideoDOM) {
1210
- oBarcodeVideoDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('video') : undefined;
1211
- }
1441
+ updateScanDialogButtonAndGetDOMs(oBarcodeScannerUIContainer);
1212
1442
  try {
1213
1443
  oBarcodeVideoDOM.srcObject = oStream;
1214
1444
  oBarcodeVideoDOM
@@ -1237,24 +1467,58 @@ sap.ui.define([
1237
1467
  oScanDialog.attachAfterOpen(function() {
1238
1468
  // Dev note: if video element dom reference is unavailable at this point (console exception)
1239
1469
  // some error happened during dialog creation and may not be directly related to video element
1240
- oScanDialog.getEndButton().setEnabled(true);
1241
- oScanDialog.setBusy(false);
1242
-
1243
- if (!oBarcodeHighlightDOM) {
1244
- oBarcodeHighlightDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('highlight') : undefined;
1245
- }
1246
- if (!oBarcodeVideoDOM) {
1247
- oBarcodeVideoDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('video') : undefined;
1248
- }
1470
+ updateScanDialogButtonAndGetDOMs(oBarcodeScannerUIContainer);
1249
1471
  decodeWithZXing();
1250
1472
  });
1251
1473
  }
1474
+ oScanDialog.setShowHeader(false);
1252
1475
  oScanDialog.destroyContent();
1253
1476
  oBarcodeHighlightDOM = undefined;
1254
1477
  oBarcodeOverlayDOM = undefined;
1255
1478
  oBarcodeVideoDOM = undefined;
1479
+ oBarcodeImageDOM = undefined;
1256
1480
 
1257
1481
  oBarcodeScannerUIContainer = new BarcodeScannerUIContainer();
1482
+ // add close button
1483
+ oBarcodeScannerUIContainer.setAggregation("_oCloseButton", new Avatar({
1484
+ src: "sap-icon://decline",
1485
+ backgroundColor: "Transparent",
1486
+ press: function() {
1487
+ oScanDialog.getModel().setProperty("/isNoScanner", false);
1488
+ openBarcodeInputDialog();
1489
+ }
1490
+ }).addStyleClass("sapNdcRTCDialogCloseButton"));
1491
+ // add toggle falshlight button
1492
+ oBarcodeScannerUIContainer.setAggregation("_oFlashLightButton", new Avatar({
1493
+ src: "sap-icon://lightbulb",
1494
+ visible: "{/hasFlashLight}",
1495
+ backgroundColor: "Transparent",
1496
+ tooltip: {
1497
+ path: "/flashLightOn",
1498
+ formatter: function (bFlashLightOn) {
1499
+ var sMessageKey = "";
1500
+ if (!bFlashLightOn) {
1501
+ sMessageKey = "BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_OPEN";
1502
+ } else {
1503
+ sMessageKey = "BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_CLOSE";
1504
+ }
1505
+ return oResourceModel.getResourceBundle().getText(sMessageKey);
1506
+ }
1507
+ },
1508
+ press: function() {
1509
+ toggleFlashLight();
1510
+ }
1511
+ }).addStyleClass("sapNdcRTCDialogFlashLightButton"));
1512
+ // add open image gallery button
1513
+ oBarcodeScannerUIContainer.setAggregation("_oImageButton", new Avatar({
1514
+ src: "sap-icon://picture",
1515
+ visible: getCurrentScannerAPI() !== "ZXing",
1516
+ tooltip: oResourceModel.getResourceBundle().getText("BARCODE_DIALOG_SELECT_IMAGE_BUTTON_TOOLTIP"),
1517
+ press: function() {
1518
+ openImageGallery();
1519
+ }
1520
+ }).addStyleClass("sapNdcRTCDialogImageButton"));
1521
+
1258
1522
  oScanDialog.addContent(oBarcodeScannerUIContainer);
1259
1523
 
1260
1524
  oScanDialog.setContentWidth('100%');
@@ -1271,8 +1535,11 @@ sap.ui.define([
1271
1535
  * @private
1272
1536
  */
1273
1537
  function decodeWithZXingCPP() {
1274
- if (!oBarcodeVideoDOM.srcObject && oSrc) {
1275
- oSrc.delete();
1538
+ if (!oBarcodeVideoDOM || !oBarcodeVideoDOM.srcObject) {
1539
+ if (oSrc) {
1540
+ oSrc.delete();
1541
+ oSrc = null;
1542
+ }
1276
1543
  return;
1277
1544
  }
1278
1545
  scanFrame(oBarcodeVideoDOM);
@@ -1480,6 +1747,8 @@ sap.ui.define([
1480
1747
  oBarcodeOverlayDOM.style.borderWidth = (video.clientHeight - oBarcodeOverlayHeightTemp) / 2 + 'px ' + (video.clientWidth - oBarcodeOverlayWidthTemp) / 2 + 'px';
1481
1748
  }
1482
1749
  }
1750
+ document.body.style.setProperty("--sapNdcRTCDialogVideoHeight", video.clientHeight + 'px');
1751
+ document.body.style.setProperty("--sapNdcRTCDialogVideoWidth", video.clientWidth + 'px');
1483
1752
  }
1484
1753
 
1485
1754
  function updateZoom(video) {
@@ -14,6 +14,23 @@ sap.ui.define([
14
14
  metadata : {
15
15
  properties : {
16
16
  "prefixId" : "string"
17
+ },
18
+ aggregations: {
19
+ _oCloseButton: {
20
+ type: "sap.ui.core.Control",
21
+ multiple: false,
22
+ visibility: "hidden"
23
+ },
24
+ _oFlashLightButton: {
25
+ type: "sap.ui.core.Control",
26
+ multiple: false,
27
+ visibility: "hidden"
28
+ },
29
+ _oImageButton: {
30
+ type: "sap.ui.core.Control",
31
+ multiple: false,
32
+ visibility: "hidden"
33
+ }
17
34
  }
18
35
  },
19
36
 
@@ -57,6 +74,18 @@ sap.ui.define([
57
74
  oRm.class("sapNdcRTCDialogHighlight");
58
75
  oRm.openEnd();
59
76
  oRm.close("div");
77
+
78
+ // Div for select image
79
+ oRm.openStart("input", oControl.getId() + "-image");
80
+ oRm.attr("hidden", true);
81
+ oRm.attr("type", "file");
82
+ oRm.attr("accept", "image/*");
83
+ oRm.openEnd();
84
+ oRm.close("div");
85
+
86
+ oRm.renderControl(oControl.getAggregation("_oCloseButton"));
87
+ oRm.renderControl(oControl.getAggregation("_oFlashLightButton"));
88
+ oRm.renderControl(oControl.getAggregation("_oImageButton"));
60
89
  }
61
90
  }
62
91
  });
@@ -7,6 +7,35 @@
7
7
  z-index: 999;
8
8
  }
9
9
 
10
+ .sapNdcRTCDialogCloseButton {
11
+ position: absolute !important;
12
+ z-index: 999;
13
+ color: white !important;
14
+ box-shadow: none !important;
15
+ outline: none !important;
16
+ margin: 0.5rem 0rem 0rem 0.5rem;
17
+ }
18
+
19
+ .sapNdcRTCDialogFlashLightButton {
20
+ position: absolute !important;
21
+ z-index: 999;
22
+ color: white !important;
23
+ box-shadow: none !important;
24
+ outline: none !important;
25
+ margin: 0.5rem 0rem 0rem calc(var(--sapNdcRTCDialogVideoWidth, 100%) - 3.5rem);
26
+ }
27
+
28
+ .sapNdcRTCDialogImageButton {
29
+ position: absolute !important;
30
+ z-index: 999;
31
+ color: white !important;
32
+ box-shadow: none !important;
33
+ outline: none !important;
34
+ border-bottom: 0px !important;
35
+ margin: calc(var(--sapNdcRTCDialogVideoHeight, 100%) - 4rem) 0rem 0.5rem calc(var(--sapNdcRTCDialogVideoWidth, 100%) / 2 - 1.5rem);
36
+ background-color: #007cc0 !important;
37
+ }
38
+
10
39
  .sapNdcRTCDialogHighlight {
11
40
  top: 0;
12
41
  left: 0;
@@ -32,7 +32,7 @@ sap.ui.define([
32
32
  ],
33
33
  elements: [],
34
34
  noLibraryCSS: true,
35
- version: "1.110.0"
35
+ version: "1.111.1"
36
36
  });
37
37
 
38
38
  return thisLib;
@@ -30,3 +30,30 @@ BARCODE_DIALOG_BUSY_TITLE=Loading Libraries
30
30
 
31
31
  #XTXT: text of loading zxing-cpp in the scan bar busy dialog
32
32
  BARCODE_DIALOG_BUSY_TEXT_ZXINGCPP=Loading ZXing-cpp library and OpenCV library...
33
+
34
+ #XMSG: error message for opening flashlight
35
+ BARCODE_DIALOG_OPEN_FLASHLIGHT_ERROR_MSG=Open flashlight failed.
36
+
37
+ #XMSG: error message for closing flashlight
38
+ BARCODE_DIALOG_CLOSE_FLASHLIGHT_ERROR_MSG=Close flashlight failed.
39
+
40
+ #XTOL: Barcode Scanner Select Image Button tooltip
41
+ BARCODE_DIALOG_SELECT_IMAGE_BUTTON_TOOLTIP=Select an image to scan
42
+
43
+ #XTIT: title of the scan image busy dialog
44
+ BARCODE_DIALOG_SCAN_IMAGE_BUSY_TITLE=Scanning selected image
45
+
46
+ #XMSG: error message for loading image failed
47
+ BARCODE_DIALOG_SCAN_IMAGE_LOAD_FAILED_MSG=Load image failed
48
+
49
+ #XMSG: error message for compressing image failed
50
+ BARCODE_DIALOG_SCAN_IMAGE_COMPRESS_FAILED_MSG=Compress image failed
51
+
52
+ #XMSG: error message for scanning image
53
+ BARCODE_DIALOG_SCAN_IMAGE_ERROR_MSG=Can not scan the selected image
54
+
55
+ #XTOL: Barcode Scanner flashlight Button tooltip OPEN
56
+ BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_OPEN=Open flashlight
57
+
58
+ #XTOL: Barcode Scanner flashlight Button tooltip CLOSE
59
+ BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_CLOSE=Close flashlight
@@ -18,3 +18,21 @@ BARCODE_SCANNER_BUTTON_TOOLTIP=\u0632\u0631 \u0645\u0627\u0633\u062D \u0634\u063
18
18
  BARCODE_DIALOG_BUSY_TITLE=\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u0643\u062A\u0628\u0627\u062A
19
19
 
20
20
  BARCODE_DIALOG_BUSY_TEXT_ZXINGCPP=\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0645\u0643\u062A\u0628\u0629 ZXing-cpp \u0648\u0645\u0643\u062A\u0628\u0629 OpenCV...
21
+
22
+ BARCODE_DIALOG_OPEN_FLASHLIGHT_ERROR_MSG=\u062A\u0639\u0630\u0631 \u0641\u062A\u062D \u0627\u0644\u0645\u0635\u0628\u0627\u062D \u0627\u0644\u0643\u0627\u0634\u0641
23
+
24
+ BARCODE_DIALOG_CLOSE_FLASHLIGHT_ERROR_MSG=\u062A\u0639\u0630\u0631 \u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0645\u0635\u0628\u0627\u062D \u0627\u0644\u0643\u0627\u0634\u0641
25
+
26
+ BARCODE_DIALOG_SELECT_IMAGE_BUTTON_TOOLTIP=\u062A\u062D\u062F\u064A\u062F \u0635\u0648\u0631\u0629 \u0644\u0641\u062D\u0635\u0647\u0627
27
+
28
+ BARCODE_DIALOG_SCAN_IMAGE_BUSY_TITLE=\u062C\u0627\u0631\u064D \u0641\u062D\u0635 \u0627\u0644\u0635\u0648\u0631\u0629 \u0627\u0644\u0645\u062D\u062F\u062F\u0629
29
+
30
+ BARCODE_DIALOG_SCAN_IMAGE_LOAD_FAILED_MSG=\u062A\u0639\u0630\u0631 \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0635\u0648\u0631\u0629
31
+
32
+ BARCODE_DIALOG_SCAN_IMAGE_COMPRESS_FAILED_MSG=\u062A\u0639\u0630\u0631 \u0636\u063A\u0637 \u0627\u0644\u0635\u0648\u0631\u0629
33
+
34
+ BARCODE_DIALOG_SCAN_IMAGE_ERROR_MSG=\u0644\u0627 \u064A\u0645\u0643\u0646 \u0641\u062D\u0635 \u0627\u0644\u0635\u0648\u0631\u0629 \u0627\u0644\u0645\u062D\u062F\u062F\u0629
35
+
36
+ BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_OPEN=\u0641\u062A\u062D \u0627\u0644\u0645\u0635\u0628\u0627\u062D \u0627\u0644\u0643\u0627\u0634\u0641
37
+
38
+ BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_CLOSE=\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0645\u0635\u0628\u0627\u062D \u0627\u0644\u0643\u0627\u0634\u0641
@@ -18,3 +18,21 @@ BARCODE_SCANNER_BUTTON_TOOLTIP=\u0411\u0443\u0442\u043E\u043D \u0437\u0430 \u044
18
18
  BARCODE_DIALOG_BUSY_TITLE=\u0417\u0430\u0440\u0435\u0436\u0434\u0430\u043D\u0435 \u043D\u0430 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438
19
19
 
20
20
  BARCODE_DIALOG_BUSY_TEXT_ZXINGCPP=\u0417\u0430\u0440\u0435\u0436\u0434\u0430\u043D\u0435 \u043D\u0430 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 ZXing-cpp \u0438 \u043E\u0442\u0432\u0430\u0440\u044F\u043D\u0435 \u043D\u0430 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 CV ...
21
+
22
+ BARCODE_DIALOG_OPEN_FLASHLIGHT_ERROR_MSG=\u0424\u0435\u043D\u0435\u0440\u0447\u0435\u0442\u043E \u043D\u0435 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043E\u0442\u0432\u043E\u0440\u0435\u043D\u043E
23
+
24
+ BARCODE_DIALOG_CLOSE_FLASHLIGHT_ERROR_MSG=\u0424\u0435\u043D\u0435\u0440\u0447\u0435\u0442\u043E \u043D\u0435 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0431\u044A\u0434\u0435 \u0437\u0430\u0442\u0432\u043E\u0440\u0435\u043D\u043E
25
+
26
+ BARCODE_DIALOG_SELECT_IMAGE_BUTTON_TOOLTIP=\u0418\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0437\u0430 \u0441\u043A\u0430\u043D\u0438\u0440\u0430\u043D\u0435
27
+
28
+ BARCODE_DIALOG_SCAN_IMAGE_BUSY_TITLE=\u0421\u043A\u0430\u043D\u0438\u0440\u0430\u043D\u0435 \u043D\u0430 \u0438\u0437\u0431\u0440\u0430\u043D\u043E\u0442\u043E \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435
29
+
30
+ BARCODE_DIALOG_SCAN_IMAGE_LOAD_FAILED_MSG=\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u043D\u0435 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0431\u044A\u0434\u0435 \u0437\u0430\u0440\u0435\u0434\u0435\u043D\u043E
31
+
32
+ BARCODE_DIALOG_SCAN_IMAGE_COMPRESS_FAILED_MSG=\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435\u0442\u043E \u043D\u0435 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u043E\u043C\u043F\u0440\u0435\u0441\u0438\u0440\u0430\u043D\u043E
33
+
34
+ BARCODE_DIALOG_SCAN_IMAGE_ERROR_MSG=\u0418\u0437\u0431\u0440\u0430\u043D\u043E\u0442\u043E \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u043D\u0435 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0431\u044A\u0434\u0435 \u0441\u043A\u0430\u043D\u0438\u0440\u0430\u043D\u043E
35
+
36
+ BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_OPEN=\u041E\u0442\u0432\u0430\u0440\u044F\u043D\u0435 \u043D\u0430 \u0444\u0435\u043D\u0435\u0440\u0447\u0435
37
+
38
+ BARCODE_DIALOG_SELECT_FLASHLIGHT_BUTTON_TOOLTIP_CLOSE=\u0417\u0430\u0442\u0432\u0430\u0440\u044F\u043D\u0435 \u043D\u0430 \u0444\u0435\u043D\u0435\u0440\u0447\u0435