@sapui5/sap.ndc 1.143.0 → 1.144.0
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 +236 -63
- package/src/sap/ndc/BarcodeScannerButton.js +29 -1
- package/src/sap/ndc/library.js +1 -1
- package/src/sap/ndc/messagebundle.properties +15 -0
- package/src/sap/ndc/messagebundle_ar.properties +15 -0
- package/src/sap/ndc/messagebundle_bg.properties +15 -0
- package/src/sap/ndc/messagebundle_ca.properties +15 -0
- package/src/sap/ndc/messagebundle_cnr.properties +15 -0
- package/src/sap/ndc/messagebundle_cs.properties +15 -0
- package/src/sap/ndc/messagebundle_cy.properties +15 -0
- package/src/sap/ndc/messagebundle_da.properties +15 -0
- package/src/sap/ndc/messagebundle_de.properties +15 -0
- package/src/sap/ndc/messagebundle_el.properties +15 -0
- package/src/sap/ndc/messagebundle_en.properties +15 -0
- package/src/sap/ndc/messagebundle_en_GB.properties +15 -0
- package/src/sap/ndc/messagebundle_en_US_saprigi.properties +15 -0
- package/src/sap/ndc/messagebundle_es.properties +15 -0
- package/src/sap/ndc/messagebundle_es_MX.properties +15 -0
- package/src/sap/ndc/messagebundle_et.properties +15 -0
- package/src/sap/ndc/messagebundle_fi.properties +15 -0
- package/src/sap/ndc/messagebundle_fr.properties +15 -0
- package/src/sap/ndc/messagebundle_fr_CA.properties +15 -0
- package/src/sap/ndc/messagebundle_hi.properties +15 -0
- package/src/sap/ndc/messagebundle_hr.properties +15 -0
- package/src/sap/ndc/messagebundle_hu.properties +15 -0
- package/src/sap/ndc/messagebundle_id.properties +15 -0
- package/src/sap/ndc/messagebundle_it.properties +15 -0
- package/src/sap/ndc/messagebundle_iw.properties +15 -0
- package/src/sap/ndc/messagebundle_ja.properties +15 -0
- package/src/sap/ndc/messagebundle_kk.properties +15 -0
- package/src/sap/ndc/messagebundle_ko.properties +15 -0
- package/src/sap/ndc/messagebundle_lt.properties +15 -0
- package/src/sap/ndc/messagebundle_lv.properties +15 -0
- package/src/sap/ndc/messagebundle_mk.properties +15 -0
- package/src/sap/ndc/messagebundle_ms.properties +16 -1
- package/src/sap/ndc/messagebundle_nl.properties +15 -0
- package/src/sap/ndc/messagebundle_no.properties +15 -0
- package/src/sap/ndc/messagebundle_pl.properties +15 -0
- package/src/sap/ndc/messagebundle_pt.properties +15 -0
- package/src/sap/ndc/messagebundle_pt_PT.properties +15 -0
- package/src/sap/ndc/messagebundle_ro.properties +15 -0
- package/src/sap/ndc/messagebundle_ru.properties +15 -0
- package/src/sap/ndc/messagebundle_sh.properties +15 -0
- package/src/sap/ndc/messagebundle_sk.properties +15 -0
- package/src/sap/ndc/messagebundle_sl.properties +15 -0
- package/src/sap/ndc/messagebundle_sr.properties +15 -0
- package/src/sap/ndc/messagebundle_sv.properties +15 -0
- package/src/sap/ndc/messagebundle_th.properties +15 -0
- package/src/sap/ndc/messagebundle_tr.properties +15 -0
- package/src/sap/ndc/messagebundle_uk.properties +15 -0
- package/src/sap/ndc/messagebundle_vi.properties +15 -0
- package/src/sap/ndc/messagebundle_zh_CN.properties +15 -0
- package/src/sap/ndc/messagebundle_zh_TW.properties +15 -0
package/package.json
CHANGED
package/src/sap/ndc/.library
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<vendor>SAP SE</vendor>
|
|
6
6
|
<copyright>SAPUI5
|
|
7
7
|
* (c) Copyright 2025 SAP SE. All rights reserved.</copyright>
|
|
8
|
-
<version>1.
|
|
8
|
+
<version>1.144.0</version>
|
|
9
9
|
|
|
10
10
|
<documentation>SAPUI5 library with controls with native device capabilities.</documentation>
|
|
11
11
|
|
|
@@ -116,7 +116,7 @@ sap.ui.define([
|
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
deviceId: undefined,
|
|
119
|
-
|
|
119
|
+
facingMode: undefined,
|
|
120
120
|
enableGS1Header: false
|
|
121
121
|
},
|
|
122
122
|
scanDialog: {
|
|
@@ -137,6 +137,7 @@ sap.ui.define([
|
|
|
137
137
|
customInput: null
|
|
138
138
|
},
|
|
139
139
|
devices: {
|
|
140
|
+
loaded: false,
|
|
140
141
|
mainCamera: undefined,
|
|
141
142
|
needCheck: true,
|
|
142
143
|
all: [],
|
|
@@ -208,10 +209,36 @@ sap.ui.define([
|
|
|
208
209
|
// TODO: following var is not used, right now it is useless // bInitialized = false, // Flag indicating whether the feature vector (sap.Settings) is available
|
|
209
210
|
// sap.Settings might be loaded later, so it is checked again the next scan
|
|
210
211
|
}),
|
|
212
|
+
oResourceModel = new ResourceModel({
|
|
213
|
+
bundleName: "sap.ndc.messagebundle"
|
|
214
|
+
}),
|
|
211
215
|
oStatusModel = new JSONModel({
|
|
212
216
|
scannerAPI: "unknown",
|
|
213
217
|
available: false,
|
|
214
218
|
deviceId: undefined,
|
|
219
|
+
facingMode: undefined,
|
|
220
|
+
facingModes: [
|
|
221
|
+
{
|
|
222
|
+
"key": "",
|
|
223
|
+
"text": oResourceModel.getProperty("BARCODE_DEFAULT")
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"key": "front",
|
|
227
|
+
"text": oResourceModel.getProperty("BARCODE_FACINGMODE_FRONT")
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"key": "back",
|
|
231
|
+
"text": oResourceModel.getProperty("BARCODE_FACINGMODE_BACK")
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"key": "left",
|
|
235
|
+
"text": oResourceModel.getProperty("BARCODE_FACINGMODE_LEFT")
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"key": "right",
|
|
239
|
+
"text": oResourceModel.getProperty("BARCODE_FACINGMODE_RIGHT")
|
|
240
|
+
}
|
|
241
|
+
],
|
|
215
242
|
devices: [],
|
|
216
243
|
apis: {
|
|
217
244
|
ZebraEnterpriseBrowser: {
|
|
@@ -238,11 +265,7 @@ sap.ui.define([
|
|
|
238
265
|
status: oScannerAPIStatus.UnAvailable
|
|
239
266
|
}
|
|
240
267
|
}
|
|
241
|
-
}).setDefaultBindingMode(BindingMode.OneWay)
|
|
242
|
-
|
|
243
|
-
oResourceModel = new ResourceModel({
|
|
244
|
-
bundleName: "sap.ndc.messagebundle"
|
|
245
|
-
});
|
|
268
|
+
}).setDefaultBindingMode(BindingMode.OneWay);
|
|
246
269
|
|
|
247
270
|
/**
|
|
248
271
|
* Get the scanner API in data model
|
|
@@ -440,7 +463,11 @@ sap.ui.define([
|
|
|
440
463
|
function initFeatureAPIs() {
|
|
441
464
|
jQuery(document).ready(function() {
|
|
442
465
|
if (isEnumerateDevicesSupported()) {
|
|
443
|
-
|
|
466
|
+
if (isPermissionsSupported()) {
|
|
467
|
+
getDeviceCamerasWithPermissions();
|
|
468
|
+
} else {
|
|
469
|
+
getDeviceCameras();
|
|
470
|
+
}
|
|
444
471
|
}
|
|
445
472
|
});
|
|
446
473
|
initialZXingCPPAPI();
|
|
@@ -533,11 +560,21 @@ sap.ui.define([
|
|
|
533
560
|
return !!(window && window.navigator && window.navigator.mediaDevices && window.navigator.mediaDevices.enumerateDevices);
|
|
534
561
|
}
|
|
535
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Used to detect if browser support permissions API
|
|
565
|
+
* @private
|
|
566
|
+
* @returns {boolean} true is permissions API supported by browser
|
|
567
|
+
*/
|
|
568
|
+
function isPermissionsSupported() {
|
|
569
|
+
return !!(navigator.permissions && navigator.permissions.query);
|
|
570
|
+
}
|
|
571
|
+
|
|
536
572
|
/**
|
|
537
573
|
* Get the device cameras
|
|
574
|
+
* @param {function} resolve Function to be called when done
|
|
538
575
|
* @private
|
|
539
576
|
*/
|
|
540
|
-
function getDeviceCameras() {
|
|
577
|
+
function getDeviceCameras(resolve) {
|
|
541
578
|
Log.debug("BarcodeScanner.getDeviceCameras: start to get device cameras");
|
|
542
579
|
// List cameras and microphones
|
|
543
580
|
window.navigator.mediaDevices.enumerateDevices()
|
|
@@ -555,15 +592,18 @@ sap.ui.define([
|
|
|
555
592
|
"label": device.label
|
|
556
593
|
};
|
|
557
594
|
if (oDevice.label && oDevice.label !== "") {
|
|
558
|
-
|
|
595
|
+
// get lower case of device label
|
|
596
|
+
var sLabel = oDevice.label.toLowerCase();
|
|
597
|
+
if (sLabel.indexOf('0, facing back') > 0) {
|
|
559
598
|
// set the main camera if one camera label contains "0, facing back"
|
|
560
599
|
Log.debug("BarcodeScanner.getDeviceCameras: has a camera with label contains '0, facing back', set it as main camera.");
|
|
561
600
|
oDevices.needCheck = false;
|
|
562
601
|
oDevices.mainCamera = oDevice;
|
|
563
602
|
}
|
|
564
|
-
|
|
603
|
+
// on MS Surface devices, label of back camare contains "rear", not "back"
|
|
604
|
+
if (sLabel.indexOf('back') > 0 || sLabel.indexOf('rear') > 0) {
|
|
565
605
|
oDevices.back.push(oDevice);
|
|
566
|
-
} else if (
|
|
606
|
+
} else if (sLabel.indexOf('front') > 0) {
|
|
567
607
|
oDevices.front.push(oDevice);
|
|
568
608
|
}
|
|
569
609
|
} else {
|
|
@@ -573,10 +613,35 @@ sap.ui.define([
|
|
|
573
613
|
oDevices.all.push(oDevice);
|
|
574
614
|
}
|
|
575
615
|
});
|
|
616
|
+
// get the number n in the label if the camera label contains "camera <n>"
|
|
617
|
+
var _extractLabelNumber = function(sLabel) {
|
|
618
|
+
if (!sLabel) {
|
|
619
|
+
return Infinity;
|
|
620
|
+
}
|
|
621
|
+
sLabel = ('' + sLabel).toLowerCase();
|
|
622
|
+
// Prefer explicit "camera <n>" pattern when present
|
|
623
|
+
var mCam = sLabel.match(/camera\s*(\d+)/i);
|
|
624
|
+
if (mCam && mCam[1]) {
|
|
625
|
+
return Number.parseInt(String(mCam[1]));
|
|
626
|
+
} else {
|
|
627
|
+
return Infinity;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
// sort the back and front camera list by the number in the label
|
|
631
|
+
if (Array.isArray(oDevices.back) && oDevices.back.length > 1) {
|
|
632
|
+
oDevices.back.sort(function(a, b) {
|
|
633
|
+
return _extractLabelNumber(a.label) - _extractLabelNumber(b.label);
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
if (Array.isArray(oDevices.front) && oDevices.front.length > 1) {
|
|
637
|
+
oDevices.front.sort(function(a, b) {
|
|
638
|
+
return _extractLabelNumber(a.label) - _extractLabelNumber(b.label);
|
|
639
|
+
});
|
|
640
|
+
}
|
|
576
641
|
if (!oDevices.mainCamera) {
|
|
577
642
|
if (oDevices.back.length === 1) {
|
|
578
643
|
// set the main camera if only has 1 back camera
|
|
579
|
-
Log.debug("BarcodeScanner.getDeviceCameras: has only one camera which label contains 'back', set it as main camera.");
|
|
644
|
+
Log.debug("BarcodeScanner.getDeviceCameras: has only one camera which label contains 'back' or 'rear', set it as main camera.");
|
|
580
645
|
oDevices.mainCamera = deepClone(oDevices.back[0]);
|
|
581
646
|
oDevices.needCheck = false;
|
|
582
647
|
} else if (oDevices.all.length === 1) {
|
|
@@ -586,17 +651,58 @@ sap.ui.define([
|
|
|
586
651
|
oDevices.needCheck = false;
|
|
587
652
|
}
|
|
588
653
|
}
|
|
654
|
+
oDevices.loaded = true;
|
|
589
655
|
oModel.setProperty("/devices", oDevices);
|
|
590
656
|
updateDevicesInStatusModel();
|
|
657
|
+
if (typeof resolve === "function") {
|
|
658
|
+
resolve();
|
|
659
|
+
}
|
|
591
660
|
}
|
|
592
661
|
)
|
|
593
662
|
.catch(
|
|
594
663
|
function(oErr) {
|
|
595
664
|
oModel.setProperty("/devices/needCheck", false);
|
|
596
665
|
Log.error("BarcodeScanner.getDeviceCameras: Can not get device cameras.\nError Message: " + oErr);
|
|
666
|
+
updateDevicesInStatusModel();
|
|
667
|
+
if (typeof resolve === "function") {
|
|
668
|
+
// resolve exists, means called after granted camera permissions. But getting device cameras failed, need to stop loading devices again.
|
|
669
|
+
Log.debug("BarcodeScanner.getDeviceCameras: set devices loaded to true even get device cameras failed when permissions granted.");
|
|
670
|
+
oModel.setProperty("/devices/loaded", true);
|
|
671
|
+
resolve();
|
|
672
|
+
}
|
|
597
673
|
});
|
|
598
674
|
}
|
|
599
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Get the device cameras with permissions API
|
|
678
|
+
* @private
|
|
679
|
+
*/
|
|
680
|
+
function getDeviceCamerasWithPermissions(resolve) {
|
|
681
|
+
Log.debug("BarcodeScanner.getDeviceCamerasWithPermissions: start to get device cameras");
|
|
682
|
+
navigator.permissions.query({ name: 'camera' }).then(function(status) {
|
|
683
|
+
if (status.state === 'granted') {
|
|
684
|
+
Log.debug("BarcodeScanner.getDeviceCamerasWithPermissions: camera permission granted.");
|
|
685
|
+
getDeviceCameras(resolve);
|
|
686
|
+
} else {
|
|
687
|
+
Log.debug("BarcodeScanner.getDeviceCamerasWithPermissions: camera permission not granted, ignore getting device cameras.");
|
|
688
|
+
updateDevicesInStatusModel();
|
|
689
|
+
if (typeof resolve === "function") {
|
|
690
|
+
resolve();
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}).catch(function(err) {
|
|
694
|
+
oModel.setProperty("/devices/needCheck", false);
|
|
695
|
+
Log.error("BarcodeScanner.getDeviceCamerasWithPermissions: query camera permissions failed.\nError Message: " + err);
|
|
696
|
+
updateDevicesInStatusModel();
|
|
697
|
+
if (typeof resolve === "function") {
|
|
698
|
+
// resolve exists, means called after granted camera permissions. But getting permissions failed, need to stop loading devices again.
|
|
699
|
+
Log.debug("BarcodeScanner.getDeviceCameras: set devices loaded to true when getting permissions failed.");
|
|
700
|
+
oModel.setProperty("/devices/loaded", true);
|
|
701
|
+
resolve();
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
|
|
600
706
|
/**
|
|
601
707
|
* Find the main camera in the camera list
|
|
602
708
|
* @param {Array} aCameras the camera list
|
|
@@ -673,8 +779,15 @@ sap.ui.define([
|
|
|
673
779
|
*/
|
|
674
780
|
function updateDevicesInStatusModel() {
|
|
675
781
|
Log.debug("BarcodeScanner.updateDevicesInStatusModel: update the devices in status model");
|
|
676
|
-
var
|
|
677
|
-
|
|
782
|
+
var aDevices = [{
|
|
783
|
+
"deviceId": "",
|
|
784
|
+
"label": oResourceModel.getProperty("BARCODE_DEFAULT")
|
|
785
|
+
}];
|
|
786
|
+
var aDevicesInModel = oModel.getProperty("/devices/all");
|
|
787
|
+
if (aDevicesInModel.length > 0) {
|
|
788
|
+
aDevices = aDevices.concat(aDevicesInModel);
|
|
789
|
+
}
|
|
790
|
+
oStatusModel.setProperty("/devices", aDevices);
|
|
678
791
|
}
|
|
679
792
|
|
|
680
793
|
/**
|
|
@@ -1315,7 +1428,7 @@ sap.ui.define([
|
|
|
1315
1428
|
* @private
|
|
1316
1429
|
*/
|
|
1317
1430
|
function openCorrectCamera() {
|
|
1318
|
-
if (!oModel.getProperty("/config/
|
|
1431
|
+
if (!oModel.getProperty("/config/facingMode")) {
|
|
1319
1432
|
delete oModel.getProperty("/config/defaultConstraints/video").facingMode;
|
|
1320
1433
|
var oDevices = oModel.getProperty("/devices");
|
|
1321
1434
|
if (!oModel.getProperty("/config/deviceId") && !oDevices.mainCamera && !Device.os.ios && !Device.os.macintosh && oDevices.needCheck && oDevices.all.length > 1) {
|
|
@@ -1334,25 +1447,40 @@ sap.ui.define([
|
|
|
1334
1447
|
Log.debug("BarcodeScanner.openCamera: start to open camera");
|
|
1335
1448
|
oModel.setProperty("/scanDialog/pausedOrientation", undefined);
|
|
1336
1449
|
var bIsMainCamera = false;
|
|
1450
|
+
var oDevices = oModel.getProperty("/devices");
|
|
1451
|
+
var sFacingMode = oModel.getProperty("/config/facingMode");
|
|
1337
1452
|
if (oModel.getProperty("/config/deviceId")) {
|
|
1338
|
-
// if
|
|
1453
|
+
// if user has selected a camera, open the selected camera directly
|
|
1339
1454
|
delete oModel.getProperty("/config/defaultConstraints/video").facingMode;
|
|
1340
1455
|
oModel.setProperty("/config/defaultConstraints/video/deviceId", {
|
|
1341
1456
|
exact: oModel.getProperty("/config/deviceId")
|
|
1342
1457
|
});
|
|
1343
|
-
} else if (
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1458
|
+
} else if (sFacingMode) {
|
|
1459
|
+
// if user defines facingMode, use it
|
|
1460
|
+
if (sFacingMode === "back") {
|
|
1461
|
+
// if facingMode === back, use the first back camera if found
|
|
1462
|
+
if (Array.isArray(oDevices.back) && oDevices.back.length > 0) {
|
|
1463
|
+
oModel.setProperty("/config/defaultConstraints/video/deviceId", {
|
|
1464
|
+
exact: oDevices.back[0].deviceId
|
|
1465
|
+
});
|
|
1466
|
+
} else {
|
|
1467
|
+
// if no back camera, use facingMode "environment"
|
|
1468
|
+
oModel.setProperty("/config/defaultConstraints/video/facingMode", "environment");
|
|
1469
|
+
delete oModel.getProperty("/config/defaultConstraints/video").deviceId;
|
|
1470
|
+
}
|
|
1353
1471
|
} else {
|
|
1354
|
-
|
|
1472
|
+
// if facingMode === front || left || right, use facingMode directly
|
|
1473
|
+
oModel.setProperty("/config/defaultConstraints/video/facingMode", sFacingMode === "front" ? "user" : sFacingMode);
|
|
1474
|
+
delete oModel.getProperty("/config/defaultConstraints/video").deviceId;
|
|
1355
1475
|
}
|
|
1476
|
+
} else if (oDevices.mainCamera && oDevices.mainCamera.deviceId !== "") {
|
|
1477
|
+
bIsMainCamera = true;
|
|
1478
|
+
oModel.setProperty("/config/defaultConstraints/video/deviceId", {
|
|
1479
|
+
exact: oDevices.mainCamera.deviceId
|
|
1480
|
+
});
|
|
1481
|
+
} else {
|
|
1482
|
+
oModel.setProperty("/config/defaultConstraints/video/facingMode", "environment");
|
|
1483
|
+
delete oModel.getProperty("/config/defaultConstraints/video").deviceId;
|
|
1356
1484
|
}
|
|
1357
1485
|
var oConstraints = deepClone(oModel.getProperty("/config/defaultConstraints"));
|
|
1358
1486
|
var oVideoResolution = calculateVideoResolution();
|
|
@@ -1361,39 +1489,52 @@ sap.ui.define([
|
|
|
1361
1489
|
.getUserMedia(oConstraints)
|
|
1362
1490
|
.then(
|
|
1363
1491
|
function(stream) {
|
|
1364
|
-
|
|
1365
|
-
if (
|
|
1366
|
-
//
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
if (
|
|
1371
|
-
|
|
1372
|
-
oModel.setProperty("/scanDialog/hasFlashLight", oDevices.mainCamera.hasFlashLight);
|
|
1373
|
-
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", oDevices.mainCamera.hasFlashLight);
|
|
1492
|
+
var videoTrack;
|
|
1493
|
+
if (!oModel.getProperty("/devices/loaded") && isEnumerateDevicesSupported()) {
|
|
1494
|
+
// close current stream to release camera
|
|
1495
|
+
videoTrack = typeof stream.stop === "function" ? stream : stream.getTracks()[0];
|
|
1496
|
+
videoTrack.stop();
|
|
1497
|
+
// get the device list after permission granted, then open correct camera again
|
|
1498
|
+
if (isPermissionsSupported()) {
|
|
1499
|
+
getDeviceCamerasWithPermissions(openCamera);
|
|
1374
1500
|
} else {
|
|
1375
|
-
|
|
1376
|
-
checkFlashLight(videoTrack).then(function() {
|
|
1377
|
-
// enable flashlight
|
|
1378
|
-
oModel.setProperty("/scanDialog/hasFlashLight", true);
|
|
1379
|
-
if (bIsMainCamera) {
|
|
1380
|
-
oDevices.mainCamera.hasFlashLight = true;
|
|
1381
|
-
}
|
|
1382
|
-
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", true);
|
|
1383
|
-
}, function() {
|
|
1384
|
-
oModel.setProperty("/scanDialog/hasFlashLight", false);
|
|
1385
|
-
if (bIsMainCamera) {
|
|
1386
|
-
oDevices.mainCamera.hasFlashLight = false;
|
|
1387
|
-
}
|
|
1388
|
-
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", false);
|
|
1389
|
-
});
|
|
1501
|
+
getDeviceCameras(openCamera);
|
|
1390
1502
|
}
|
|
1391
|
-
}
|
|
1392
|
-
if (oStream) {
|
|
1393
|
-
playbackVideoAndDecode(bAttachOrientationChangeListener);
|
|
1394
1503
|
} else {
|
|
1395
|
-
|
|
1396
|
-
|
|
1504
|
+
oStream = stream;
|
|
1505
|
+
if (Device.os.ios) {
|
|
1506
|
+
// can not control flashlight on ios devices since no API supported now
|
|
1507
|
+
oModel.setProperty("/scanDialog/hasFlashLight", false);
|
|
1508
|
+
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", false);
|
|
1509
|
+
} else {
|
|
1510
|
+
if (bIsMainCamera && typeof oDevices.mainCamera.hasFlashLight === "boolean") {
|
|
1511
|
+
// set flashlight
|
|
1512
|
+
oModel.setProperty("/scanDialog/hasFlashLight", oDevices.mainCamera.hasFlashLight);
|
|
1513
|
+
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", oDevices.mainCamera.hasFlashLight);
|
|
1514
|
+
} else {
|
|
1515
|
+
videoTrack = typeof stream.stop === "function" ? stream : stream.getTracks()[0];
|
|
1516
|
+
checkFlashLight(videoTrack).then(function() {
|
|
1517
|
+
// enable flashlight
|
|
1518
|
+
oModel.setProperty("/scanDialog/hasFlashLight", true);
|
|
1519
|
+
if (bIsMainCamera) {
|
|
1520
|
+
oDevices.mainCamera.hasFlashLight = true;
|
|
1521
|
+
}
|
|
1522
|
+
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", true);
|
|
1523
|
+
}, function() {
|
|
1524
|
+
oModel.setProperty("/scanDialog/hasFlashLight", false);
|
|
1525
|
+
if (bIsMainCamera) {
|
|
1526
|
+
oDevices.mainCamera.hasFlashLight = false;
|
|
1527
|
+
}
|
|
1528
|
+
oScanDialog && oScanDialog.getModel().setProperty("/hasFlashLight", false);
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
if (oStream) {
|
|
1533
|
+
playbackVideoAndDecode(bAttachOrientationChangeListener);
|
|
1534
|
+
} else {
|
|
1535
|
+
oScanDialog && oScanDialog.getModel().setProperty("/isNoScanner", true);
|
|
1536
|
+
openBarcodeInputDialog(oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_STREAM_ERROR_MSG'));
|
|
1537
|
+
}
|
|
1397
1538
|
}
|
|
1398
1539
|
}
|
|
1399
1540
|
)
|
|
@@ -1600,7 +1741,7 @@ sap.ui.define([
|
|
|
1600
1741
|
*/
|
|
1601
1742
|
function scanWithCordova() {
|
|
1602
1743
|
var options;
|
|
1603
|
-
if (oModel.getProperty("/config/
|
|
1744
|
+
if (oModel.getProperty("/config/facingMode") === "front") {
|
|
1604
1745
|
options = {
|
|
1605
1746
|
preferFrontCamera: true
|
|
1606
1747
|
};
|
|
@@ -2652,7 +2793,7 @@ sap.ui.define([
|
|
|
2652
2793
|
* alert("Value entered: " + mParams.newValue);
|
|
2653
2794
|
* },
|
|
2654
2795
|
* "Enter Product Barcode",
|
|
2655
|
-
*
|
|
2796
|
+
* "front",
|
|
2656
2797
|
* 30,
|
|
2657
2798
|
* 1,
|
|
2658
2799
|
* false,
|
|
@@ -2665,7 +2806,7 @@ sap.ui.define([
|
|
|
2665
2806
|
* @param {function} [fnFail] Function to be called when the scanning is failed
|
|
2666
2807
|
* @param {function} [fnLiveUpdate] Function to be called when value of the dialog's input is changed
|
|
2667
2808
|
* @param {string} [dialogTitle] Defines the barcode input dialog title. If unset, a predefined title will be used.
|
|
2668
|
-
* @param {boolean} [
|
|
2809
|
+
* @param {string|boolean} [facingMode] Defines the facingMode of the camera which should be used. Value can be "", "front", "back", "left", "right", true or false (Backward Compatibility for deprecated parameter "preferFrontCamera"). If value is unset or "", the default camera of device will be used. If set to true, means the value is "front". If set to false, means the value is "" as before.
|
|
2669
2810
|
* @param {float} [frameRate] Defines the frame rate of the camera.
|
|
2670
2811
|
* @param {float} [zoom] Defines the zoom of the camera. This parameter is not supported on iOS.
|
|
2671
2812
|
* @param {boolean} [keepCameraScan] Flag, which defines whether the camera should be used for scanning in Zebra Enterprise Browser.
|
|
@@ -2675,7 +2816,7 @@ sap.ui.define([
|
|
|
2675
2816
|
* @public
|
|
2676
2817
|
* @static
|
|
2677
2818
|
*/
|
|
2678
|
-
BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle,
|
|
2819
|
+
BarcodeScanner.scan = function (fnSuccess, fnFail, fnLiveUpdate, dialogTitle, facingMode, frameRate, zoom, keepCameraScan, disableBarcodeInputDialog, customInput) {
|
|
2679
2820
|
if (!oModel.getProperty("/bReady")) {
|
|
2680
2821
|
Log.error("BarcodeScanner.scan: Barcode scanning is already in progress.");
|
|
2681
2822
|
return;
|
|
@@ -2704,7 +2845,24 @@ sap.ui.define([
|
|
|
2704
2845
|
oModel.setProperty("/scanDialog/title", oResourceModel.getProperty("BARCODE_DIALOG_TITLE"));
|
|
2705
2846
|
}
|
|
2706
2847
|
oModel.setProperty("/scanDialog/scanningStartTime", Date.now());
|
|
2707
|
-
|
|
2848
|
+
// apply value of facingMode parameter
|
|
2849
|
+
if (typeof facingMode === "boolean") {
|
|
2850
|
+
// backward compatibility for preferFrontCamera
|
|
2851
|
+
if (facingMode) {
|
|
2852
|
+
oModel.setProperty("/config/facingMode", "front");
|
|
2853
|
+
} else {
|
|
2854
|
+
oModel.setProperty("/config/facingMode", null);
|
|
2855
|
+
}
|
|
2856
|
+
} else if (typeof facingMode === "string"){
|
|
2857
|
+
oModel.setProperty("/config/facingMode", facingMode);
|
|
2858
|
+
} else if (typeof facingMode !== "undefined") {
|
|
2859
|
+
MessageToast.show(
|
|
2860
|
+
oResourceModel.getResourceBundle().getText('BARCODE_DIALOG_CAMERA_UPDATE_PARAMETER_ERROR_MSG', ['facingMode']),
|
|
2861
|
+
{
|
|
2862
|
+
duration: 1000
|
|
2863
|
+
}
|
|
2864
|
+
);
|
|
2865
|
+
}
|
|
2708
2866
|
// Reset frameRate
|
|
2709
2867
|
if (oModel.getProperty("/config/defaultConstraints/video/frameRate") !== undefined) {
|
|
2710
2868
|
delete oModel.getProperty("/config/defaultConstraints/video").frameRate;
|
|
@@ -2916,6 +3074,7 @@ sap.ui.define([
|
|
|
2916
3074
|
* {
|
|
2917
3075
|
* "enableGS1Header": true, //If set to true, add the symbology identifier (GS1 specification 5.4.3.7. and 5.4.6.4.) as prefix into the result text.
|
|
2918
3076
|
* "deviceId": "string" // The specific camera id to scan the Barcode. If set to "", Barcode Scanner will use default camera. This option is not working for iOS devices since do not support to get all the cameras.
|
|
3077
|
+
* "facingMode": "string" // Defines the facingMode of the camera which should be used. Value can be "", "front", "back", "left", "right". If set to "", Barcode Scanner will use default camera.
|
|
2919
3078
|
* "multiScan": {
|
|
2920
3079
|
* "enabled": false, // If set to true, will support scan multi barcodes, and the max number of the barcodes in each scanning is 10. Default value is false. Only working for ZXingCPP.
|
|
2921
3080
|
* "showPauseButton": false, // If set to true, will show a button so that can pause/restart the scan in the scan dialog.
|
|
@@ -2941,14 +3100,27 @@ sap.ui.define([
|
|
|
2941
3100
|
var oMultiScan = Object.assign({}, oModel.getProperty("/apis/ZXingCPP/multiScan"), options.multiScan);
|
|
2942
3101
|
oModel.setProperty("/apis/ZXingCPP/multiScan", oMultiScan);
|
|
2943
3102
|
oStatusModel.setProperty("/apis/ZXingCPP/multiScan", deepClone(oMultiScan));
|
|
3103
|
+
Log.debug("The parameter(multiScan) has been changed.");
|
|
2944
3104
|
delete oConfig.multiScan;
|
|
3105
|
+
} else if (oKey === "preferFrontCamera") {
|
|
3106
|
+
// backward compatibility for preferFrontCamera
|
|
3107
|
+
if (typeof options.preferFrontCamera === "boolean") {
|
|
3108
|
+
if (options.preferFrontCamera) {
|
|
3109
|
+
oConfig.facingMode = "front";
|
|
3110
|
+
oStatusModel.setProperty("/facingMode", "front");
|
|
3111
|
+
} else {
|
|
3112
|
+
oConfig.facingMode = null;
|
|
3113
|
+
oStatusModel.setProperty("/facingMode", null);
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
Log.debug("The parameter(preferFrontCamera) has been changed.");
|
|
2945
3117
|
} else if (oConfig.hasOwnProperty(oKey)) {
|
|
2946
3118
|
oConfig[oKey] = options[oKey];
|
|
2947
3119
|
if (checkZebraEBScanAvailable() && oKey === "enableGS1Header") {
|
|
2948
3120
|
oModel.setProperty("/apis/ZebraEnterpriseBrowser/enableBarcodeState", false);
|
|
2949
3121
|
EB.Barcode.disable(zebraEBScanEnable);
|
|
2950
3122
|
}
|
|
2951
|
-
if (oKey === "deviceId") {
|
|
3123
|
+
if (oKey === "deviceId" || oKey === "facingMode") {
|
|
2952
3124
|
oStatusModel.setProperty("/" + oKey, options[oKey]);
|
|
2953
3125
|
}
|
|
2954
3126
|
Log.debug("The parameter(" + oKey + ") has been changed.");
|
|
@@ -2957,6 +3129,7 @@ sap.ui.define([
|
|
|
2957
3129
|
}
|
|
2958
3130
|
}
|
|
2959
3131
|
oModel.setProperty("/config", oConfig);
|
|
3132
|
+
oModel.checkUpdate();
|
|
2960
3133
|
oStatusModel.checkUpdate();
|
|
2961
3134
|
} else {
|
|
2962
3135
|
Log.error("The options are not available.");
|
|
@@ -57,9 +57,20 @@ sap.ui.define([
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* If set to true, the front camera will be used to decode.
|
|
60
|
+
* @deprecated As of version 1.144.0, use the 'facingMode' property with value 'front' instead.
|
|
60
61
|
*/
|
|
61
62
|
preferFrontCamera : {type : "boolean", defaultValue : false},
|
|
62
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Defines the facing mode of the camera to use.
|
|
66
|
+
* If unset, use the default camera of device.
|
|
67
|
+
* <li><code>front</code> - facing mode: front.
|
|
68
|
+
* <li><code>back</code> - facing mode: back.
|
|
69
|
+
* <li><code>left</code> - facing mode: left. Useless now since most devices have no facing left camera.
|
|
70
|
+
* <li><code>right</code> - facing mode: right. Useless now since most devices have no facing right camera.
|
|
71
|
+
*/
|
|
72
|
+
facingMode : {type : "string", defaultValue : null},
|
|
73
|
+
|
|
63
74
|
/**
|
|
64
75
|
* Defines the frame rate of the camera.
|
|
65
76
|
*/
|
|
@@ -173,7 +184,7 @@ sap.ui.define([
|
|
|
173
184
|
this._onScanFail.bind(this),
|
|
174
185
|
this._onInputLiveUpdate.bind(this),
|
|
175
186
|
this.getProperty("dialogTitle"),
|
|
176
|
-
this.getProperty("
|
|
187
|
+
this.getProperty("facingMode"),
|
|
177
188
|
this.getProperty("frameRate"),
|
|
178
189
|
this.getProperty("zoom"),
|
|
179
190
|
this.getProperty("keepCameraScan"),
|
|
@@ -182,6 +193,23 @@ sap.ui.define([
|
|
|
182
193
|
);
|
|
183
194
|
};
|
|
184
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Sets the preferFrontCamera
|
|
198
|
+
* @deprecated As of version 1.144.0, use the 'facingMode' property instead.
|
|
199
|
+
* @param {boolean} bValue use front camera or not
|
|
200
|
+
*/
|
|
201
|
+
BarcodeScannerButton.prototype.setPreferFrontCamera = function (bValue) {
|
|
202
|
+
if (typeof bValue === "boolean") {
|
|
203
|
+
this.setProperty("preferFrontCamera", bValue);
|
|
204
|
+
if (bValue) {
|
|
205
|
+
this.setProperty("facingMode", "front");
|
|
206
|
+
} else {
|
|
207
|
+
this.setProperty("facingMode", null);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return this;
|
|
211
|
+
};
|
|
212
|
+
|
|
185
213
|
BarcodeScannerButton.prototype._onScanSuccess = function (mArguments) {
|
|
186
214
|
this.fireScanSuccess(mArguments);
|
|
187
215
|
};
|
package/src/sap/ndc/library.js
CHANGED
|
@@ -102,3 +102,18 @@ BARCODE_DIALOG_CAMERA_SECURITYERROR_ERROR_MSG=SecurityError: User media support
|
|
|
102
102
|
|
|
103
103
|
#XMSG: TypeError message for User Media
|
|
104
104
|
BARCODE_DIALOG_CAMERA_TYPEERROR_ERROR_MSG=TypeError: Empty constraint list or all constraints set to false, or getUserMedia method called in insecure context.
|
|
105
|
+
|
|
106
|
+
#XLST: Label for 'defatult'
|
|
107
|
+
BARCODE_DEFAULT=Default
|
|
108
|
+
|
|
109
|
+
#XLST: Label for facing mode 'front'
|
|
110
|
+
BARCODE_FACINGMODE_FRONT=Front
|
|
111
|
+
|
|
112
|
+
#XLST: Label for facing mode 'back'
|
|
113
|
+
BARCODE_FACINGMODE_BACK=Back
|
|
114
|
+
|
|
115
|
+
#XLST: Label for facing mode 'left'
|
|
116
|
+
BARCODE_FACINGMODE_LEFT=Left
|
|
117
|
+
|
|
118
|
+
#XLST: Label for facing mode 'right'
|
|
119
|
+
BARCODE_FACINGMODE_RIGHT=Right
|
|
@@ -102,3 +102,18 @@ BARCODE_DIALOG_CAMERA_SECURITYERROR_ERROR_MSG=SecurityError\: \u062A\u0645 \u062
|
|
|
102
102
|
|
|
103
103
|
#XMSG: TypeError message for User Media
|
|
104
104
|
BARCODE_DIALOG_CAMERA_TYPEERROR_ERROR_MSG=TypeError\: \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0642\u064A\u0648\u062F \u0641\u0627\u0631\u063A\u0629 \u0623\u0648 \u062A\u0645 \u062A\u0639\u064A\u064A\u0646 \u062C\u0645\u064A\u0639 \u0627\u0644\u0642\u064A\u0648\u062F \u0639\u0644\u0649 "\u062E\u0637\u0623"\u060C \u0623\u0648 \u062A\u0645 \u0627\u0633\u062A\u062F\u0639\u0627\u0621 \u0627\u0644\u0623\u0633\u0644\u0648\u0628 getUserMedia \u0641\u064A \u0633\u064A\u0627\u0642 \u063A\u064A\u0631 \u0622\u0645\u0646.
|
|
105
|
+
|
|
106
|
+
#XLST: Label for 'defatult'
|
|
107
|
+
BARCODE_DEFAULT=\u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A
|
|
108
|
+
|
|
109
|
+
#XLST: Label for facing mode 'front'
|
|
110
|
+
BARCODE_FACINGMODE_FRONT=\u0623\u0645\u0627\u0645\u064A
|
|
111
|
+
|
|
112
|
+
#XLST: Label for facing mode 'back'
|
|
113
|
+
BARCODE_FACINGMODE_BACK=\u0627\u0644\u062E\u0644\u0641
|
|
114
|
+
|
|
115
|
+
#XLST: Label for facing mode 'left'
|
|
116
|
+
BARCODE_FACINGMODE_LEFT=\u064A\u0633\u0627\u0631
|
|
117
|
+
|
|
118
|
+
#XLST: Label for facing mode 'right'
|
|
119
|
+
BARCODE_FACINGMODE_RIGHT=\u064A\u0645\u064A\u0646
|
|
@@ -102,3 +102,18 @@ BARCODE_DIALOG_CAMERA_SECURITYERROR_ERROR_MSG=SecurityError\: \u041F\u043E\u0434
|
|
|
102
102
|
|
|
103
103
|
#XMSG: TypeError message for User Media
|
|
104
104
|
BARCODE_DIALOG_CAMERA_TYPEERROR_ERROR_MSG=TypeError\: \u041F\u0440\u0430\u0437\u0435\u043D \u0441\u043F\u0438\u0441\u044A\u043A \u0441 \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0438\u044F \u0438\u043B\u0438 \u0437\u0430 \u0432\u0441\u0438\u0447\u043A\u0438 \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0438\u044F \u0435 \u0437\u0430\u0434\u0430\u0434\u0435\u043D\u043E \u201E\u041D\u0435\u0432\u044F\u0440\u043D\u043E\u201D, \u0438\u043B\u0438 \u043C\u0435\u0442\u043E\u0434\u044A\u0442 getUserMedia \u0435 \u0438\u0437\u0432\u0438\u043A\u0430\u043D \u0432 \u043D\u0435\u0441\u0438\u0433\u0443\u0440\u0435\u043D \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442.
|
|
105
|
+
|
|
106
|
+
#XLST: Label for 'defatult'
|
|
107
|
+
BARCODE_DEFAULT=\u041F\u043E \u043F\u043E\u0434\u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043D\u0435
|
|
108
|
+
|
|
109
|
+
#XLST: Label for facing mode 'front'
|
|
110
|
+
BARCODE_FACINGMODE_FRONT=\u041E\u0442\u043F\u0440\u0435\u0434
|
|
111
|
+
|
|
112
|
+
#XLST: Label for facing mode 'back'
|
|
113
|
+
BARCODE_FACINGMODE_BACK=\u041E\u0442\u0437\u0430\u0434
|
|
114
|
+
|
|
115
|
+
#XLST: Label for facing mode 'left'
|
|
116
|
+
BARCODE_FACINGMODE_LEFT=\u041E\u0442\u043B\u044F\u0432\u043E
|
|
117
|
+
|
|
118
|
+
#XLST: Label for facing mode 'right'
|
|
119
|
+
BARCODE_FACINGMODE_RIGHT=\u041E\u0442\u0434\u044F\u0441\u043D\u043E
|
|
@@ -102,3 +102,18 @@ BARCODE_DIALOG_CAMERA_SECURITYERROR_ERROR_MSG=SecurityError\: El suport de mitja
|
|
|
102
102
|
|
|
103
103
|
#XMSG: TypeError message for User Media
|
|
104
104
|
BARCODE_DIALOG_CAMERA_TYPEERROR_ERROR_MSG=TypeError\: La llista de restriccions buida o totes les restriccions estan definides com a falses; o, s'ha cridat al m\u00E8tode getUserMedia en un context no segur.
|
|
105
|
+
|
|
106
|
+
#XLST: Label for 'defatult'
|
|
107
|
+
BARCODE_DEFAULT=Predeterminat
|
|
108
|
+
|
|
109
|
+
#XLST: Label for facing mode 'front'
|
|
110
|
+
BARCODE_FACINGMODE_FRONT=Frontal
|
|
111
|
+
|
|
112
|
+
#XLST: Label for facing mode 'back'
|
|
113
|
+
BARCODE_FACINGMODE_BACK=Posterior
|
|
114
|
+
|
|
115
|
+
#XLST: Label for facing mode 'left'
|
|
116
|
+
BARCODE_FACINGMODE_LEFT=Esquerra
|
|
117
|
+
|
|
118
|
+
#XLST: Label for facing mode 'right'
|
|
119
|
+
BARCODE_FACINGMODE_RIGHT=Dreta
|
|
@@ -102,3 +102,18 @@ BARCODE_DIALOG_CAMERA_SECURITYERROR_ERROR_MSG=SecurityError\: Korisni\u010Dka po
|
|
|
102
102
|
|
|
103
103
|
#XMSG: TypeError message for User Media
|
|
104
104
|
BARCODE_DIALOG_CAMERA_TYPEERROR_ERROR_MSG=TypeError\: Prazna lista ograni\u010Denja ili sva ograni\u010Denja postavljena na false ili je metod getUserMedia pozvan u nesigurnom kontekstu.
|
|
105
|
+
|
|
106
|
+
#XLST: Label for 'defatult'
|
|
107
|
+
BARCODE_DEFAULT=Standardno
|
|
108
|
+
|
|
109
|
+
#XLST: Label for facing mode 'front'
|
|
110
|
+
BARCODE_FACINGMODE_FRONT=Naprijed
|
|
111
|
+
|
|
112
|
+
#XLST: Label for facing mode 'back'
|
|
113
|
+
BARCODE_FACINGMODE_BACK=Nazad
|
|
114
|
+
|
|
115
|
+
#XLST: Label for facing mode 'left'
|
|
116
|
+
BARCODE_FACINGMODE_LEFT=Lijevo
|
|
117
|
+
|
|
118
|
+
#XLST: Label for facing mode 'right'
|
|
119
|
+
BARCODE_FACINGMODE_RIGHT=Desno
|