@sapui5/sap.ndc 1.84.18 → 1.84.22

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.84.18",
3
+ "version": "1.84.22",
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)",
@@ -6,7 +6,7 @@
6
6
  <copyright>SAPUI5
7
7
 
8
8
  (c) Copyright 2009-2020 SAP SE. All rights reserved</copyright>
9
- <version>1.84.18</version>
9
+ <version>1.84.22</version>
10
10
 
11
11
  <documentation>SAPUI5 library with controls with native device capabilities.</documentation>
12
12
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * SAPUI5
3
- * (c) Copyright 2009-2021 SAP SE. All rights reserved.
3
+ * (c) Copyright 2009-2022 SAP SE. All rights reserved.
4
4
  */
5
5
 
6
6
 
@@ -39,13 +39,11 @@ sap.ui.define([
39
39
 
40
40
  /**
41
41
  * @class
42
- * TODO: description
43
42
  *
44
- * As <code>BarcodeScanner</code> is a static class, a <code>sap.ui.define();</code>
45
- * statement must be explicitly executed before the class can be used. Example: *
43
+ * Here is an example of how to trigger the scan function of BarcodeScanner:
46
44
  * <pre>
47
- * sap.ui.define(["sap/ndc/BarcodeScanner"], function(BarcodeScanner) {
48
- * sap.ndc.BarcodeScanner.scan(
45
+ * sap.ui.require(["sap/ndc/BarcodeScanner"], function(BarcodeScanner) {
46
+ * BarcodeScanner.scan(
49
47
  * function (oResult) { / * process scan result * / },
50
48
  * function (oError) { / * handle scan error * / },
51
49
  * function (oResult) { / * handle input dialog change * / }
@@ -80,15 +78,10 @@ sap.ui.define([
80
78
  defaultConstraints = {
81
79
  audio: false,
82
80
  video: {
83
- height: {
84
- min: 480,
85
- ideal: 960,
86
- max: 1440
87
- },
88
- aspectRatio: 1.333333333,
89
81
  facingMode: 'environment'
90
82
  }
91
83
  },
84
+ oPreferFrontCamera,
92
85
 
93
86
  oBarcodeScannerUIContainer = null,
94
87
 
@@ -228,16 +221,19 @@ sap.ui.define([
228
221
  oScanDialog.removeStyleClass('sapUiNoContentPadding');
229
222
 
230
223
  oScanDialog.setTitle(oDialogTitle);
224
+
225
+ var oMSGLabel = new Label(oScanDialog.getId() + '-txt_barcode', {
226
+ text: "{i18n>BARCODE_DIALOG_MSG}",
227
+ visible: "{/isNoScanner}"
228
+ });
231
229
  oScanDialog.addContent(
232
- new Label({
233
- text: "{i18n>BARCODE_DIALOG_MSG}",
234
- visible: "{/isNoScanner}"
235
- })
230
+ oMSGLabel
236
231
  );
237
232
 
238
- var oFallbackInput = new Input({
233
+ var oFallbackInput = new Input(oScanDialog.getId() + '-inp_barcode', {
239
234
  value: "{/barcode}",
240
235
  valueLiveUpdate: true,
236
+ ariaLabelledBy: oMSGLabel.getId(),
241
237
  liveChange: function(oEvent) {
242
238
  if (typeof oScanDialogController.onLiveUpdate === "function") {
243
239
  oScanDialogController.onLiveUpdate({
@@ -250,7 +246,7 @@ sap.ui.define([
250
246
  oScanDialog.addContent(oFallbackInput);
251
247
 
252
248
  oScanDialog.setBeginButton(
253
- new Button({
249
+ new Button(oScanDialog.getId() + '-btn_barcode_ok', {
254
250
  text: "{i18n>BARCODE_DIALOG_OK}",
255
251
  press: function(oEvent) {
256
252
  BarcodeScanner.closeScanDialog();
@@ -283,6 +279,11 @@ sap.ui.define([
283
279
  */
284
280
  function openBarcodeScannerDialog() {
285
281
  if (navigator.mediaDevices.getUserMedia) {
282
+ if (oPreferFrontCamera) {
283
+ defaultConstraints.video.facingMode = 'user';
284
+ } else {
285
+ defaultConstraints.video.facingMode = 'environment';
286
+ }
286
287
  navigator.mediaDevices
287
288
  .getUserMedia(defaultConstraints)
288
289
  .then(
@@ -315,7 +316,7 @@ sap.ui.define([
315
316
 
316
317
  if (!oScanDialog || (oScanDialog && oScanDialog.getContent().length === 0)) {
317
318
  oDialogModel = new JSONModel();
318
- oScanDialog = new Dialog({
319
+ oScanDialog = new Dialog('sapNdcBarcodeScannerDialog', {
319
320
  icon: 'sap-icon://bar-code',
320
321
  title: "",
321
322
  stretch: true,
@@ -331,6 +332,7 @@ sap.ui.define([
331
332
  }
332
333
  }),
333
334
  afterClose: function() {
335
+ closeZXingScanContain();
334
336
  oScanDialog.destroyContent();
335
337
  oScanDialog.destroy();
336
338
  oScanDialog = null;
@@ -352,9 +354,10 @@ sap.ui.define([
352
354
 
353
355
  if (typeof sTitle === "string" && sTitle != null && sTitle.trim() != "") {
354
356
  oDialogTitle = sTitle;
357
+ } else {
358
+ oDialogTitle = oResourceModel.getProperty("BARCODE_DIALOG_TITLE");
355
359
  }
356
360
 
357
-
358
361
  if (!oCordovaScannerAPI && isUserMediaAccessSupported()) {
359
362
  openBarcodeScannerDialog();
360
363
  } else {
@@ -388,7 +391,7 @@ sap.ui.define([
388
391
  oBarcodeVideoDOM = oBarcodeScannerUIContainer ? oBarcodeScannerUIContainer.getDomRef('video') : undefined;
389
392
  }
390
393
 
391
- oZXingScannerAPI.decodeFromVideoDevice(null, oBarcodeScannerUIContainer.getId() + '-video', function (result, err) {
394
+ oZXingScannerAPI.decodeFromConstraints(defaultConstraints, oBarcodeScannerUIContainer.getId() + '-video', function (result, err) {
392
395
  oScanFrame();
393
396
  if (result) {
394
397
  var point, scaleX, scaleY;
@@ -512,6 +515,7 @@ sap.ui.define([
512
515
  if (oZXingScannerAPI) {
513
516
  oZXingScannerAPI.reset();
514
517
  oZXingScannerAPI.stopContinuousDecode();
518
+ oZXingScannerAPI.reader.reset();
515
519
  }
516
520
  }
517
521
 
@@ -523,10 +527,6 @@ sap.ui.define([
523
527
  * Starts the bar code scanning process either showing the live input from the camera or displaying a dialog
524
528
  * to enter the value directly if the bar code scanning feature is not available.
525
529
  *
526
- * <pre>
527
- * sap.ndc.BarcodeScanner.scan(fnSuccess, fnFail, fnLiveUpdate, dialogTitle)
528
- * </pre>
529
- *
530
530
  * The bar code scanning is done asynchronously. When it is triggered, this function returns without waiting for
531
531
  * the scanning process to finish. The applications have to provide callback functions to react to the events of
532
532
  * a successful scanning, an error during scanning, and the live input on the dialog.
@@ -537,21 +537,23 @@ sap.ui.define([
537
537
  * dialog's input field. An example:
538
538
  *
539
539
  * <pre>
540
- * sap.ndc.BarcodeScanner.scan(
541
- * function (mResult) {
542
- * alert("We got a bar code\n" +
543
- * "Result: " + mResult.text + "\n" +
544
- * "Format: " + mResult.format + "\n" +
545
- * "Cancelled: " + mResult.cancelled);
546
- * },
547
- * function (Error) {
548
- * alert("Scanning failed: " + Error);
549
- * },
550
- * function (mParams) {
551
- * alert("Value entered: " + mParams.newValue);
552
- * },
553
- * "Enter Product Bar Code"
554
- * );
540
+ * sap.ui.require(["sap/ndc/BarcodeScanner"], function(BarcodeScanner) {
541
+ * BarcodeScanner.scan(
542
+ * function (mResult) {
543
+ * alert("We got a bar code\n" +
544
+ * "Result: " + mResult.text + "\n" +
545
+ * "Format: " + mResult.format + "\n" +
546
+ * "Cancelled: " + mResult.cancelled);
547
+ * },
548
+ * function (Error) {
549
+ * alert("Scanning failed: " + Error);
550
+ * },
551
+ * function (mParams) {
552
+ * alert("Value entered: " + mParams.newValue);
553
+ * },
554
+ * "Enter Product Bar Code"
555
+ * );
556
+ * });
555
557
  * </pre>
556
558
  *
557
559
  * @param {function} [fnSuccess] Function to be called when the scanning is done or cancelled
@@ -562,13 +564,14 @@ sap.ui.define([
562
564
  * @public
563
565
  * @static
564
566
  */
565
- BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle) {
567
+ BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle, preferFrontCamera) {
566
568
  if (!bReady) {
567
569
  Log.error("Barcode scanning is already in progress.");
568
570
  return;
569
571
  }
570
572
 
571
573
  bReady = false;
574
+ oPreferFrontCamera = preferFrontCamera;
572
575
 
573
576
  if (oStatusModel.getProperty("/available") == true && oCordovaScannerAPI == null && oZXingScannerAPI == null){
574
577
  //in case we do not have feature vectore we still would like to allow the use
@@ -577,6 +580,12 @@ sap.ui.define([
577
580
  }
578
581
 
579
582
  if (oCordovaScannerAPI) {
583
+ var options;
584
+ if (oPreferFrontCamera) {
585
+ options = {
586
+ preferFrontCamera: true
587
+ };
588
+ }
580
589
  oCordovaScannerAPI.scan(
581
590
  function (oResult) {
582
591
  if (oResult.cancelled === "false" || !oResult.cancelled) {
@@ -591,11 +600,17 @@ sap.ui.define([
591
600
  },
592
601
  function (oEvent) {
593
602
  Log.error("Barcode scanning failed.");
603
+ bReady = true;
594
604
  if (typeof fnFail === "function") {
605
+ if (typeof oEvent === "string") {
606
+ var str = oEvent;
607
+ oEvent = {"text": str};
608
+ Log.debug("Change the type of oEvent from string to object");
609
+ }
595
610
  fnFail(oEvent);
596
611
  }
597
- bReady = true;
598
- }
612
+ },
613
+ options
599
614
  );
600
615
  } else {
601
616
  getScanDialog(fnSuccess, fnFail, fnLiveUpdate, dialogTitle);
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * SAPUI5
3
- * (c) Copyright 2009-2021 SAP SE. All rights reserved.
3
+ * (c) Copyright 2009-2022 SAP SE. All rights reserved.
4
4
  */
5
5
 
6
6
  // Provides control sap.ndc.BarcodeScannerButton.
@@ -52,7 +52,12 @@ sap.ui.define(["sap/ui/thirdparty/jquery", './BarcodeScanner', './library', 'sap
52
52
  /**
53
53
  * Defines the bar code input dialog title. If unset, a predefined title will be used.
54
54
  */
55
- dialogTitle : {type: "string", defaultValue: null}
55
+ dialogTitle : {type: "string", defaultValue: null},
56
+
57
+ /**
58
+ * If set to true, the front camera will be used to decode.
59
+ */
60
+ preferFrontCamera : {type : "boolean", defaultValue : false}
56
61
  },
57
62
  aggregations : {
58
63
 
@@ -125,7 +130,8 @@ sap.ui.define(["sap/ui/thirdparty/jquery", './BarcodeScanner', './library', 'sap
125
130
  jQuery.proxy(this._onScanSuccess, this),
126
131
  jQuery.proxy(this._onScanFail, this),
127
132
  jQuery.proxy(this._onInputLiveUpdate, this),
128
- this.getProperty("dialogTitle")
133
+ this.getProperty("dialogTitle"),
134
+ this.getProperty("preferFrontCamera")
129
135
  );
130
136
  };
131
137
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * SAPUI5
3
- * (c) Copyright 2009-2021 SAP SE. All rights reserved.
3
+ * (c) Copyright 2009-2022 SAP SE. All rights reserved.
4
4
  */
5
5
  sap.ui.define([],
6
6
  function() {
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * SAPUI5
3
- * (c) Copyright 2009-2021 SAP SE. All rights reserved.
3
+ * (c) Copyright 2009-2022 SAP SE. All rights reserved.
4
4
  */
5
5
 
6
6
  sap.ui.define([
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * SAPUI5
3
- * (c) Copyright 2009-2021 SAP SE. All rights reserved.
3
+ * (c) Copyright 2009-2022 SAP SE. All rights reserved.
4
4
  */
5
5
 
6
6
  /**
@@ -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.84.18"
35
+ version: "1.84.22"
36
36
  });
37
37
 
38
38
  return sap.ndc;
@@ -8839,6 +8839,11 @@
8839
8839
  if (readers.length === 0) {
8840
8840
  readers.push(new EAN13Reader());
8841
8841
  // UPC-A is covered by EAN-13
8842
+ // ##### BEGIN: MODIFIED BY SAP
8843
+ // Add UPCAReader() into readers array
8844
+ // see https://github.com/zxing-js/library/pull/304
8845
+ readers.push(new UPCAReader());
8846
+ // ##### END: MODIFIED BY SAP
8842
8847
  readers.push(new EAN8Reader());
8843
8848
  readers.push(new UPCEReader());
8844
8849
  }