@sapui5/sap.ndc 1.96.8 → 1.96.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapui5/sap.ndc",
3
- "version": "1.96.8",
3
+ "version": "1.96.9",
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-2021 SAP SE. All rights reserved.</copyright>
8
- <version>1.96.8</version>
8
+ <version>1.96.9</version>
9
9
 
10
10
  <documentation>SAPUI5 library with controls with native device capabilities.</documentation>
11
11
 
@@ -23,9 +23,10 @@ sap.ui.define([
23
23
  'sap/m/Button',
24
24
  'sap/m/Dialog',
25
25
  "sap/ui/dom/includeStylesheet",
26
- "./BarcodeScannerUIContainer"
26
+ "./BarcodeScannerUIContainer",
27
+ "sap/m/MessageToast"
27
28
  ],
28
- function(Log, JSONModel, ResourceModel, Input, Label, Button, Dialog, includeStylesheet, BarcodeScannerUIContainer) {
29
+ function(Log, JSONModel, ResourceModel, Input, Label, Button, Dialog, includeStylesheet, BarcodeScannerUIContainer, MessageToast) {
29
30
  "use strict";
30
31
 
31
32
  /*global cordova*/
@@ -82,6 +83,8 @@ sap.ui.define([
82
83
  }
83
84
  },
84
85
  oPreferFrontCamera,
86
+ oFrameRate,
87
+ oZoom,
85
88
 
86
89
  oBarcodeScannerUIContainer = null,
87
90
 
@@ -284,6 +287,10 @@ sap.ui.define([
284
287
  } else {
285
288
  defaultConstraints.video.facingMode = 'environment';
286
289
  }
290
+ // Reset frameRate
291
+ if (defaultConstraints.video.frameRate !== undefined) {
292
+ delete defaultConstraints.video.frameRate;
293
+ }
287
294
  navigator.mediaDevices
288
295
  .getUserMedia(defaultConstraints)
289
296
  .then(
@@ -390,7 +397,16 @@ sap.ui.define([
390
397
  if (!oBarcodeVideoDOM) {
391
398
  oBarcodeVideoDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('video') : undefined;
392
399
  }
393
-
400
+ if (typeof oFrameRate === "number" && oFrameRate > 0) {
401
+ defaultConstraints.video.frameRate = oFrameRate;
402
+ } else if (typeof oFrameRate !== 'undefined') {
403
+ MessageToast.show(
404
+ oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_UPDATE_PARAMETER_ERROR_MSG', 'frameRate'),
405
+ {
406
+ duration: 1000
407
+ }
408
+ );
409
+ }
394
410
  oZXingScannerAPI.decodeFromConstraints(defaultConstraints, oBarcodeScannerUIContainer.getId() + '-video', function (result, err) {
395
411
  oScanFrame();
396
412
  if (result) {
@@ -492,6 +508,8 @@ sap.ui.define([
492
508
  oBarcodeOverlayDOM = oBarcodeScannerUIContainer.getDomRef('overlay');
493
509
  }
494
510
 
511
+ updateZoom();
512
+
495
513
  if (oBarcodeOverlayDOM) {
496
514
  var oBarcodeOverlayWidthTemp = oBarcodeVideoDOM.clientWidth * (1 - 2 * iInactiveZonePercent);
497
515
  var oBarcodeOverlayHeightTemp = oBarcodeVideoDOM.clientHeight * (1 - 2 * iInactiveZonePercent);
@@ -511,6 +529,60 @@ sap.ui.define([
511
529
  }
512
530
  }
513
531
 
532
+ function updateZoom() {
533
+ if (oZoom !== "skipUpdateZoom" && oBarcodeVideoDOM) {
534
+ var videoTrack = oBarcodeVideoDOM.srcObject.getVideoTracks();
535
+ var oSupport = window.navigator.mediaDevices.getSupportedConstraints();
536
+ var capabilities = videoTrack[0].getCapabilities();
537
+ // Verify the permission about updating zoom
538
+ if (oSupport.zoom && capabilities && capabilities.zoom) {
539
+ Log.debug("Support zoom to update");
540
+ if (typeof oZoom === 'undefined' || oZoom === null) {
541
+ // reset zoom
542
+ oZoom = capabilities.zoom.min;
543
+ }
544
+ } else {
545
+ Log.debug("Don't support zoom or getCapabilities() failed.");
546
+ oZoom = "skipUpdateZoom";
547
+ return;
548
+ }
549
+ // Update zoom
550
+ try {
551
+ videoTrack[0].applyConstraints(
552
+ {
553
+ advanced: [{
554
+ zoom: oZoom
555
+ }]
556
+ }
557
+ ).then(
558
+ function() {
559
+ oZoom = "skipUpdateZoom";
560
+ Log.debug("The zoom is updated successfully.");
561
+ }
562
+ ).catch(
563
+ function(error) {
564
+ if (error && error.message && error.message.match(/out of range|Failed to read the 'zoom' property/i)) {
565
+ oZoom = "skipUpdateZoom";
566
+ MessageToast.show(
567
+ oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_UPDATE_PARAMETER_ERROR_MSG', 'zoom'),
568
+ {
569
+ duration: 1000
570
+ }
571
+ );
572
+ } else {
573
+ Log.error("Update zoom failed. Error Message:" + error);
574
+ }
575
+ }
576
+ );
577
+ } catch (err) {
578
+ Log.error("applyConstraints() failed. Error Message:" + err);
579
+ oZoom = "skipUpdateZoom";
580
+ }
581
+ var settings = videoTrack[0].getSettings();
582
+ Log.debug("frameRate is " + settings.frameRate + ". zoom is " + settings.zoom);
583
+ }
584
+ }
585
+
514
586
  function closeZXingScanContain() {
515
587
  if (oZXingScannerAPI) {
516
588
  oZXingScannerAPI.reset();
@@ -551,7 +623,10 @@ sap.ui.define([
551
623
  * function (mParams) {
552
624
  * alert("Value entered: " + mParams.newValue);
553
625
  * },
554
- * "Enter Product Bar Code"
626
+ * "Enter Product Bar Code",
627
+ * true,
628
+ * 30,
629
+ * 1
555
630
  * );
556
631
  * });
557
632
  * </pre>
@@ -560,11 +635,14 @@ sap.ui.define([
560
635
  * @param {function} [fnFail] Function to be called when the scanning is failed
561
636
  * @param {function} [fnLiveUpdate] Function to be called when value of the dialog's input is changed
562
637
  * @param {string} [dialogTitle] Defines the bar code input dialog title. If unset, a predefined title will be used.
638
+ * @param {boolean} [preferFrontCamera] Flag, which defines whether the front or back camera should be used.
639
+ * @param {float} [frameRate] Defines the frame rate of the camera.
640
+ * @param {float} [zoom] Defines the zoom of the camera. This parameter is not supported on iOS.
563
641
  *
564
642
  * @public
565
643
  * @static
566
644
  */
567
- BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle, preferFrontCamera) {
645
+ BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle, preferFrontCamera, frameRate, zoom) {
568
646
  if (!bReady) {
569
647
  Log.error("Barcode scanning is already in progress.");
570
648
  return;
@@ -572,6 +650,8 @@ sap.ui.define([
572
650
 
573
651
  bReady = false;
574
652
  oPreferFrontCamera = preferFrontCamera;
653
+ oFrameRate = frameRate;
654
+ oZoom = zoom;
575
655
 
576
656
  if (oStatusModel.getProperty("/available") == true && oCordovaScannerAPI == null && oZXingScannerAPI == null){
577
657
  //in case we do not have feature vectore we still would like to allow the use
@@ -57,7 +57,16 @@ sap.ui.define(["sap/ui/thirdparty/jquery", './BarcodeScanner', './library', 'sap
57
57
  /**
58
58
  * If set to true, the front camera will be used to decode.
59
59
  */
60
- preferFrontCamera : {type : "boolean", defaultValue : false}
60
+ preferFrontCamera : {type : "boolean", defaultValue : false},
61
+
62
+ /**
63
+ * Defines the frame rate of the camera.
64
+ */
65
+ frameRate : {type : "float"},
66
+ /**
67
+ * Defines the zoom of the camera. This parameter is not supported on iOS.
68
+ */
69
+ zoom : {type : "float"}
61
70
  },
62
71
  aggregations : {
63
72
 
@@ -131,7 +140,9 @@ sap.ui.define(["sap/ui/thirdparty/jquery", './BarcodeScanner', './library', 'sap
131
140
  jQuery.proxy(this._onScanFail, this),
132
141
  jQuery.proxy(this._onInputLiveUpdate, this),
133
142
  this.getProperty("dialogTitle"),
134
- this.getProperty("preferFrontCamera")
143
+ this.getProperty("preferFrontCamera"),
144
+ this.getProperty("frameRate"),
145
+ this.getProperty("zoom")
135
146
  );
136
147
  };
137
148
 
@@ -32,7 +32,7 @@ sap.ui.define(['sap/m/library', 'sap/ui/core/library'],
32
32
  ],
33
33
  elements: [],
34
34
  noLibraryCSS: true,
35
- version: "1.96.8"
35
+ version: "1.96.9"
36
36
  });
37
37
 
38
38
  return sap.ndc;
@@ -1,17 +1,20 @@
1
- #This is the resource bundle for the sap.ndc library
2
- #__ldi.translation.uuid=242cacb8-b0ca-42c0-980c-c7eeb3ce9a2b
3
-
4
- #XTIT: title of the manual bar code input
5
- BARCODE_DIALOG_TITLE=Enter Bar Code
6
-
7
- #XBUT: OK button in the manual bar code input dialog
8
- BARCODE_DIALOG_OK=OK
9
-
10
- #XBUT: Cancel button in the manual bar code input dialog
11
- BARCODE_DIALOG_CANCEL=Cancel
12
-
13
- #XFLD: Placeholder of the bar code input field
14
- BARCODE_DIALOG_PLACEHOLDER=Enter bar code
15
-
16
- #YMSG: Message in the manual bar code input dialog
17
- BARCODE_DIALOG_MSG=Scanner is not available
1
+ #This is the resource bundle for the sap.ndc library
2
+ #__ldi.translation.uuid=242cacb8-b0ca-42c0-980c-c7eeb3ce9a2b
3
+
4
+ #XTIT: title of the manual bar code input
5
+ BARCODE_DIALOG_TITLE=Enter Bar Code
6
+
7
+ #XBUT: OK button in the manual bar code input dialog
8
+ BARCODE_DIALOG_OK=OK
9
+
10
+ #XBUT: Cancel button in the manual bar code input dialog
11
+ BARCODE_DIALOG_CANCEL=Cancel
12
+
13
+ #XFLD: Placeholder of the bar code input field
14
+ BARCODE_DIALOG_PLACEHOLDER=Enter bar code
15
+
16
+ #YMSG: Message in the manual bar code input dialog
17
+ BARCODE_DIALOG_MSG=Scanner is not available
18
+
19
+ #XMSG: error message for updating parameter of Camera
20
+ BARCODE_DIALOG_CAMERA_UPDATE_PARAMETER_ERROR_MSG=The {0} parameter is out of range.