cronapp-cordova-plugin-barcodescanner 2.8.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/.editorconfig +16 -0
- package/LICENSE.txt +22 -0
- package/README.md +52 -0
- package/hooks/windows/check-arch.js +52 -0
- package/package.json +37 -0
- package/plugin.xml +70 -0
- package/spec/helper/cordova.js +83 -0
- package/spec/index.spec.js +78 -0
- package/src/android/README.md +1 -0
- package/src/android/barcodescanner-release-2.1.5.aar +0 -0
- package/src/android/barcodescanner.gradle +17 -0
- package/src/android/com/phonegap/plugins/barcodescanner/BarcodeScanner.java +328 -0
- package/src/browser/BarcodeScannerProxy.js +24 -0
- package/src/ios/CDVBarcodeScanner.bundle/beep.caf +0 -0
- package/src/ios/CDVBarcodeScanner.bundle/torch.png +0 -0
- package/src/ios/CDVBarcodeScanner.bundle/torch@2x.png +0 -0
- package/src/ios/CDVBarcodeScanner.bundle/torch@3x.png +0 -0
- package/src/ios/CDVBarcodeScanner.mm +1072 -0
- package/src/ios/scannerOverlay.xib +185 -0
- package/src/windows/BarcodeScannerProxy.js +738 -0
- package/src/windows/assets/plugin-barcodeScanner.css +89 -0
- package/src/windows/lib/Properties/AssemblyInfo.cs +39 -0
- package/src/windows/lib/Reader.cs +173 -0
- package/src/windows/lib/WinRTBarcodeReader.csproj +137 -0
- package/src/windows/lib/ZXing.winmd +0 -0
- package/src/windows/lib.UW/ANY/ZXing.winmd +0 -0
- package/src/windows/lib.UW/ARM/ZXing.winmd +0 -0
- package/src/windows/lib.UW/x64/ZXing.winmd +0 -0
- package/src/windows/lib.UW/x86/ZXing.winmd +0 -0
- package/www/barcodescanner.js +156 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.barcode-scanner-wrap {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
outline: 0;
|
|
5
|
+
font-size: 100%;
|
|
6
|
+
vertical-align: baseline;
|
|
7
|
+
background: 0 0 black;
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
z-index: 9999999;
|
|
14
|
+
-ms-user-select: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.barcode-scanner-preview {
|
|
18
|
+
width: auto;
|
|
19
|
+
height: calc(100% - 70px);
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: calc(50% - 35px);
|
|
22
|
+
left: 50%;
|
|
23
|
+
transform: translateX(-50%) translateY(-50%);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.barcode-scanner-mark {
|
|
27
|
+
position: absolute;
|
|
28
|
+
left: 0;
|
|
29
|
+
top: 50%;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 3px;
|
|
32
|
+
background: red;
|
|
33
|
+
z-index: 9999999;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.barcode-scanner-app-bar {
|
|
37
|
+
height: 70px;
|
|
38
|
+
width: 100%;
|
|
39
|
+
padding-top: 10px;
|
|
40
|
+
z-index: 9999999;
|
|
41
|
+
text-align: center;
|
|
42
|
+
user-select: none;
|
|
43
|
+
position: absolute;
|
|
44
|
+
bottom: 0px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.app-bar-action {
|
|
48
|
+
width: 40px;
|
|
49
|
+
height: 40px;
|
|
50
|
+
margin: 0 auto;
|
|
51
|
+
font-family: "Segoe UI Symbol";
|
|
52
|
+
color: white;
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
text-transform: lowercase;
|
|
55
|
+
text-align: center;
|
|
56
|
+
cursor: default;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media all and (orientation: landscape) {
|
|
60
|
+
.app-bar-action {
|
|
61
|
+
float: right;
|
|
62
|
+
margin-right: 20px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.app-bar-action::before {
|
|
67
|
+
font-size: 28px;
|
|
68
|
+
display: block;
|
|
69
|
+
height: 36px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.action-close::before {
|
|
73
|
+
content: "\E0C7";
|
|
74
|
+
/* close icon is larger so we re-size it to fit other icons */
|
|
75
|
+
font-size: 20px;
|
|
76
|
+
line-height: 40px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.action-close:hover::before {
|
|
80
|
+
content: "\E0CA";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.no-zoom {
|
|
84
|
+
-ms-content-zooming: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.no-scroll {
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
using System.Reflection;
|
|
12
|
+
using System.Runtime.CompilerServices;
|
|
13
|
+
using System.Runtime.InteropServices;
|
|
14
|
+
|
|
15
|
+
// General Information about an assembly is controlled through the following
|
|
16
|
+
// set of attributes. Change these attribute values to modify the information
|
|
17
|
+
// associated with an assembly.
|
|
18
|
+
[assembly: AssemblyTitle("WinRTBarcodeReader")]
|
|
19
|
+
[assembly: AssemblyDescription("")]
|
|
20
|
+
[assembly: AssemblyConfiguration("")]
|
|
21
|
+
[assembly: AssemblyCompany("")]
|
|
22
|
+
[assembly: AssemblyProduct("WinRTBarcodeReader")]
|
|
23
|
+
[assembly: AssemblyCopyright("Copyright © 2014")]
|
|
24
|
+
[assembly: AssemblyTrademark("")]
|
|
25
|
+
[assembly: AssemblyCulture("")]
|
|
26
|
+
|
|
27
|
+
// Version information for an assembly consists of the following four values:
|
|
28
|
+
//
|
|
29
|
+
// Major Version
|
|
30
|
+
// Minor Version
|
|
31
|
+
// Build Number
|
|
32
|
+
// Revision
|
|
33
|
+
//
|
|
34
|
+
// You can specify all the values or you can default the Build and Revision Numbers
|
|
35
|
+
// by using the '*' as shown below:
|
|
36
|
+
// [assembly: AssemblyVersion("1.0.*")]
|
|
37
|
+
[assembly: AssemblyVersion("1.0.0.0")]
|
|
38
|
+
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
39
|
+
[assembly: ComVisible(false)]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
namespace WinRTBarcodeReader
|
|
12
|
+
{
|
|
13
|
+
using System;
|
|
14
|
+
using System.Threading;
|
|
15
|
+
using System.Threading.Tasks;
|
|
16
|
+
|
|
17
|
+
using Windows.Foundation;
|
|
18
|
+
using Windows.Graphics.Imaging;
|
|
19
|
+
using Windows.Media.Capture;
|
|
20
|
+
using Windows.Media.MediaProperties;
|
|
21
|
+
using Windows.Storage.Streams;
|
|
22
|
+
|
|
23
|
+
using ZXing;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
/// Defines the Reader type, that perform barcode search asynchronously.
|
|
27
|
+
/// </summary>
|
|
28
|
+
public sealed class Reader
|
|
29
|
+
{
|
|
30
|
+
#region Private fields
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Data reader, used to create bitmap array.
|
|
34
|
+
/// </summary>
|
|
35
|
+
private BarcodeReader barcodeReader;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// The cancel search flag.
|
|
39
|
+
/// </summary>
|
|
40
|
+
private CancellationTokenSource cancelSearch;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// MediaCapture instance, used for barcode search.
|
|
44
|
+
/// </summary>
|
|
45
|
+
private MediaCapture capture;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Encoding properties for mediaCapture object.
|
|
49
|
+
/// </summary>
|
|
50
|
+
private ImageEncodingProperties encodingProps;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
/// Flag that indicates successful barcode search.
|
|
54
|
+
/// </summary>
|
|
55
|
+
private bool barcodeFoundOrCancelled;
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// Image stream for MediaCapture content.
|
|
59
|
+
/// </summary>
|
|
60
|
+
private InMemoryRandomAccessStream imageStream;
|
|
61
|
+
|
|
62
|
+
#endregion
|
|
63
|
+
|
|
64
|
+
#region Constructor
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
/// Initializes a new instance of the <see cref="Reader" /> class.
|
|
68
|
+
/// </summary>
|
|
69
|
+
/// <param name="capture">MediaCapture instance.</param>
|
|
70
|
+
/// <param name="width">Capture frame width.</param>
|
|
71
|
+
/// <param name="height">Capture frame height.</param>
|
|
72
|
+
public void Init(MediaCapture capture, uint width, uint height)
|
|
73
|
+
{
|
|
74
|
+
this.capture = capture;
|
|
75
|
+
encodingProps = ImageEncodingProperties.CreateJpeg();
|
|
76
|
+
encodingProps.Width = width;
|
|
77
|
+
encodingProps.Height = height;
|
|
78
|
+
|
|
79
|
+
barcodeReader = new BarcodeReader {Options = {TryHarder = true}};
|
|
80
|
+
cancelSearch = new CancellationTokenSource();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#endregion
|
|
84
|
+
|
|
85
|
+
#region Public methods
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// Perform async MediaCapture analysis and searches for barcode.
|
|
89
|
+
/// </summary>
|
|
90
|
+
/// <returns>IAsyncOperation object</returns>
|
|
91
|
+
public IAsyncOperation<Result> ReadCode()
|
|
92
|
+
{
|
|
93
|
+
return this.Read().AsAsyncOperation();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// <summary>
|
|
97
|
+
/// Send signal to stop barcode search.
|
|
98
|
+
/// </summary>
|
|
99
|
+
public void Stop()
|
|
100
|
+
{
|
|
101
|
+
this.cancelSearch.Cancel();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#endregion
|
|
105
|
+
|
|
106
|
+
#region Private methods
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
/// Perform async MediaCapture analysis and searches for barcode.
|
|
110
|
+
/// </summary>
|
|
111
|
+
/// <returns>Task object</returns>
|
|
112
|
+
private async Task<Result> Read()
|
|
113
|
+
{
|
|
114
|
+
Result result = null;
|
|
115
|
+
try
|
|
116
|
+
{
|
|
117
|
+
while (result == null)
|
|
118
|
+
{
|
|
119
|
+
result = await GetCameraImage(cancelSearch.Token);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (OperationCanceledException) { }
|
|
123
|
+
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// <summary>
|
|
128
|
+
/// Perform image capture from mediaCapture object
|
|
129
|
+
/// </summary>
|
|
130
|
+
/// <param name="cancelToken">
|
|
131
|
+
/// The cancel Token.
|
|
132
|
+
/// </param>
|
|
133
|
+
/// <returns>
|
|
134
|
+
/// Decoded barcode string.
|
|
135
|
+
/// </returns>
|
|
136
|
+
private async Task<Result> GetCameraImage(CancellationToken cancelToken)
|
|
137
|
+
{
|
|
138
|
+
if (cancelToken.IsCancellationRequested)
|
|
139
|
+
{
|
|
140
|
+
throw new OperationCanceledException(cancelToken);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
imageStream = new InMemoryRandomAccessStream();
|
|
144
|
+
|
|
145
|
+
await capture.CapturePhotoToStreamAsync(encodingProps, imageStream);
|
|
146
|
+
await imageStream.FlushAsync();
|
|
147
|
+
|
|
148
|
+
var decoder = await BitmapDecoder.CreateAsync(imageStream);
|
|
149
|
+
|
|
150
|
+
byte[] pixels =
|
|
151
|
+
(await
|
|
152
|
+
decoder.GetPixelDataAsync(BitmapPixelFormat.Rgba8,
|
|
153
|
+
BitmapAlphaMode.Ignore,
|
|
154
|
+
new BitmapTransform(),
|
|
155
|
+
ExifOrientationMode.IgnoreExifOrientation,
|
|
156
|
+
ColorManagementMode.DoNotColorManage)).DetachPixelData();
|
|
157
|
+
|
|
158
|
+
const BitmapFormat format = BitmapFormat.RGB32;
|
|
159
|
+
|
|
160
|
+
imageStream.Dispose();
|
|
161
|
+
|
|
162
|
+
var result =
|
|
163
|
+
await
|
|
164
|
+
Task.Run(
|
|
165
|
+
() => barcodeReader.Decode(pixels, (int) decoder.PixelWidth, (int) decoder.PixelHeight, format),
|
|
166
|
+
cancelToken);
|
|
167
|
+
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
#endregion
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
9
|
+
-->
|
|
10
|
+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
11
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
12
|
+
<PropertyGroup>
|
|
13
|
+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
14
|
+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
15
|
+
<ProductVersion>8.0.30703</ProductVersion>
|
|
16
|
+
<SchemaVersion>2.0</SchemaVersion>
|
|
17
|
+
<ProjectName>WinRTBarcodeReader</ProjectName>
|
|
18
|
+
<ProjectGuid>{01412F36-3781-4AF0-903C-ACEA7552C99C}</ProjectGuid>
|
|
19
|
+
<OutputType>winmdobj</OutputType>
|
|
20
|
+
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
21
|
+
<RootNamespace>WinRTBarcodeReader</RootNamespace>
|
|
22
|
+
<AssemblyName>WinRTBarcodeReader</AssemblyName>
|
|
23
|
+
<DefaultLanguage>en-US</DefaultLanguage>
|
|
24
|
+
<FileAlignment>512</FileAlignment>
|
|
25
|
+
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
26
|
+
<TargetPlatformVersion>8.1</TargetPlatformVersion>
|
|
27
|
+
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
|
|
28
|
+
<TargetFrameworkVersion />
|
|
29
|
+
</PropertyGroup>
|
|
30
|
+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
31
|
+
<DebugSymbols>true</DebugSymbols>
|
|
32
|
+
<DebugType>full</DebugType>
|
|
33
|
+
<Optimize>false</Optimize>
|
|
34
|
+
<OutputPath>bin\Debug\</OutputPath>
|
|
35
|
+
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
|
36
|
+
<ErrorReport>prompt</ErrorReport>
|
|
37
|
+
<WarningLevel>4</WarningLevel>
|
|
38
|
+
</PropertyGroup>
|
|
39
|
+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
40
|
+
<DebugSymbols>false</DebugSymbols>
|
|
41
|
+
<DebugType>None</DebugType>
|
|
42
|
+
<Optimize>true</Optimize>
|
|
43
|
+
<OutputPath>bin\Release\</OutputPath>
|
|
44
|
+
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
|
45
|
+
<ErrorReport>prompt</ErrorReport>
|
|
46
|
+
<WarningLevel>4</WarningLevel>
|
|
47
|
+
</PropertyGroup>
|
|
48
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
|
49
|
+
<DebugSymbols>true</DebugSymbols>
|
|
50
|
+
<OutputPath>bin\ARM\Debug\</OutputPath>
|
|
51
|
+
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
|
52
|
+
<NoWarn>;2008</NoWarn>
|
|
53
|
+
<DebugType>full</DebugType>
|
|
54
|
+
<PlatformTarget>ARM</PlatformTarget>
|
|
55
|
+
<UseVSHostingProcess>false</UseVSHostingProcess>
|
|
56
|
+
<ErrorReport>prompt</ErrorReport>
|
|
57
|
+
<Prefer32Bit>true</Prefer32Bit>
|
|
58
|
+
</PropertyGroup>
|
|
59
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
|
60
|
+
<OutputPath>bin\ARM\Release\</OutputPath>
|
|
61
|
+
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
|
62
|
+
<Optimize>true</Optimize>
|
|
63
|
+
<NoWarn>;2008</NoWarn>
|
|
64
|
+
<DebugSymbols>false</DebugSymbols>
|
|
65
|
+
<DebugType>None</DebugType>
|
|
66
|
+
<PlatformTarget>ARM</PlatformTarget>
|
|
67
|
+
<UseVSHostingProcess>false</UseVSHostingProcess>
|
|
68
|
+
<ErrorReport>prompt</ErrorReport>
|
|
69
|
+
<Prefer32Bit>true</Prefer32Bit>
|
|
70
|
+
</PropertyGroup>
|
|
71
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
|
72
|
+
<DebugSymbols>true</DebugSymbols>
|
|
73
|
+
<OutputPath>bin\x64\Debug\</OutputPath>
|
|
74
|
+
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
|
75
|
+
<NoWarn>;2008</NoWarn>
|
|
76
|
+
<DebugType>full</DebugType>
|
|
77
|
+
<PlatformTarget>x64</PlatformTarget>
|
|
78
|
+
<UseVSHostingProcess>false</UseVSHostingProcess>
|
|
79
|
+
<ErrorReport>prompt</ErrorReport>
|
|
80
|
+
<Prefer32Bit>true</Prefer32Bit>
|
|
81
|
+
</PropertyGroup>
|
|
82
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
|
83
|
+
<OutputPath>bin\x64\Release\</OutputPath>
|
|
84
|
+
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
|
85
|
+
<Optimize>true</Optimize>
|
|
86
|
+
<NoWarn>;2008</NoWarn>
|
|
87
|
+
<DebugSymbols>false</DebugSymbols>
|
|
88
|
+
<DebugType>None</DebugType>
|
|
89
|
+
<PlatformTarget>x64</PlatformTarget>
|
|
90
|
+
<UseVSHostingProcess>false</UseVSHostingProcess>
|
|
91
|
+
<ErrorReport>prompt</ErrorReport>
|
|
92
|
+
<Prefer32Bit>true</Prefer32Bit>
|
|
93
|
+
</PropertyGroup>
|
|
94
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
|
95
|
+
<DebugSymbols>true</DebugSymbols>
|
|
96
|
+
<OutputPath>bin\x86\Debug\</OutputPath>
|
|
97
|
+
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
|
98
|
+
<NoWarn>;2008</NoWarn>
|
|
99
|
+
<DebugType>full</DebugType>
|
|
100
|
+
<PlatformTarget>x86</PlatformTarget>
|
|
101
|
+
<UseVSHostingProcess>false</UseVSHostingProcess>
|
|
102
|
+
<ErrorReport>prompt</ErrorReport>
|
|
103
|
+
<Prefer32Bit>true</Prefer32Bit>
|
|
104
|
+
</PropertyGroup>
|
|
105
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
|
106
|
+
<OutputPath>bin\x86\Release\</OutputPath>
|
|
107
|
+
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
|
108
|
+
<Optimize>true</Optimize>
|
|
109
|
+
<NoWarn>;2008</NoWarn>
|
|
110
|
+
<DebugSymbols>false</DebugSymbols>
|
|
111
|
+
<DebugType>None</DebugType>
|
|
112
|
+
<PlatformTarget>x86</PlatformTarget>
|
|
113
|
+
<UseVSHostingProcess>false</UseVSHostingProcess>
|
|
114
|
+
<ErrorReport>prompt</ErrorReport>
|
|
115
|
+
<Prefer32Bit>true</Prefer32Bit>
|
|
116
|
+
</PropertyGroup>
|
|
117
|
+
<ItemGroup>
|
|
118
|
+
<Compile Include="Reader.cs" />
|
|
119
|
+
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
120
|
+
</ItemGroup>
|
|
121
|
+
<ItemGroup>
|
|
122
|
+
<Reference Include="ZXing">
|
|
123
|
+
<HintPath>ZXing.winmd</HintPath>
|
|
124
|
+
</Reference>
|
|
125
|
+
</ItemGroup>
|
|
126
|
+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
|
|
127
|
+
<VisualStudioVersion>12.0</VisualStudioVersion>
|
|
128
|
+
</PropertyGroup>
|
|
129
|
+
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
|
130
|
+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
131
|
+
Other similar extension points exist, see Microsoft.Common.targets.
|
|
132
|
+
<Target Name="BeforeBuild">
|
|
133
|
+
</Target>
|
|
134
|
+
<Target Name="AfterBuild">
|
|
135
|
+
</Target>
|
|
136
|
+
-->
|
|
137
|
+
</Project>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cordova is available under the MIT License (2008).
|
|
3
|
+
* See http://opensource.org/licenses/alphabetical for full text.
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Matt Kane 2010
|
|
6
|
+
* Copyright (c) 2011, IBM Corporation
|
|
7
|
+
* Copyright (c) 2012-2017, Adobe Systems
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var exec = cordova.require("cordova/exec");
|
|
12
|
+
|
|
13
|
+
var scanInProgress = false;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Constructor.
|
|
17
|
+
*
|
|
18
|
+
* @returns {BarcodeScanner}
|
|
19
|
+
*/
|
|
20
|
+
function BarcodeScanner() {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Encoding constants.
|
|
24
|
+
*
|
|
25
|
+
* @type Object
|
|
26
|
+
*/
|
|
27
|
+
this.Encode = {
|
|
28
|
+
TEXT_TYPE: "TEXT_TYPE",
|
|
29
|
+
EMAIL_TYPE: "EMAIL_TYPE",
|
|
30
|
+
PHONE_TYPE: "PHONE_TYPE",
|
|
31
|
+
SMS_TYPE: "SMS_TYPE"
|
|
32
|
+
// CONTACT_TYPE: "CONTACT_TYPE", // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
|
33
|
+
// LOCATION_TYPE: "LOCATION_TYPE" // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Barcode format constants, defined in ZXing library.
|
|
38
|
+
*
|
|
39
|
+
* @type Object
|
|
40
|
+
*/
|
|
41
|
+
this.format = {
|
|
42
|
+
"all_1D": 61918,
|
|
43
|
+
"aztec": 1,
|
|
44
|
+
"codabar": 2,
|
|
45
|
+
"code_128": 16,
|
|
46
|
+
"code_39": 4,
|
|
47
|
+
"code_93": 8,
|
|
48
|
+
"data_MATRIX": 32,
|
|
49
|
+
"ean_13": 128,
|
|
50
|
+
"ean_8": 64,
|
|
51
|
+
"itf": 256,
|
|
52
|
+
"maxicode": 512,
|
|
53
|
+
"msi": 131072,
|
|
54
|
+
"pdf_417": 1024,
|
|
55
|
+
"plessey": 262144,
|
|
56
|
+
"qr_CODE": 2048,
|
|
57
|
+
"rss_14": 4096,
|
|
58
|
+
"rss_EXPANDED": 8192,
|
|
59
|
+
"upc_A": 16384,
|
|
60
|
+
"upc_E": 32768,
|
|
61
|
+
"upc_EAN_EXTENSION": 65536
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Read code from scanner.
|
|
67
|
+
*
|
|
68
|
+
* @param {Function} successCallback This function will recieve a result object: {
|
|
69
|
+
* text : '12345-mock', // The code that was scanned.
|
|
70
|
+
* format : 'FORMAT_NAME', // Code format.
|
|
71
|
+
* cancelled : true/false, // Was canceled.
|
|
72
|
+
* }
|
|
73
|
+
* @param {Function} errorCallback
|
|
74
|
+
* @param config
|
|
75
|
+
*/
|
|
76
|
+
BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config) {
|
|
77
|
+
|
|
78
|
+
if (config instanceof Array) {
|
|
79
|
+
// do nothing
|
|
80
|
+
} else {
|
|
81
|
+
if (typeof(config) === 'object') {
|
|
82
|
+
// string spaces between formats, ZXing does not like that
|
|
83
|
+
if (config.formats) {
|
|
84
|
+
config.formats = config.formats.replace(/\s+/g, '');
|
|
85
|
+
}
|
|
86
|
+
config = [ config ];
|
|
87
|
+
} else {
|
|
88
|
+
config = [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (errorCallback == null) {
|
|
93
|
+
errorCallback = function () {
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (typeof errorCallback != "function") {
|
|
98
|
+
console.log("BarcodeScanner.scan failure: failure parameter not a function");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (typeof successCallback != "function") {
|
|
103
|
+
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (scanInProgress) {
|
|
108
|
+
errorCallback('Scan is already in progress');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
scanInProgress = true;
|
|
113
|
+
|
|
114
|
+
exec(
|
|
115
|
+
function(result) {
|
|
116
|
+
scanInProgress = false;
|
|
117
|
+
// work around bug in ZXing library
|
|
118
|
+
if (result.format === 'UPC_A' && result.text.length === 13) {
|
|
119
|
+
result.text = result.text.substring(1);
|
|
120
|
+
}
|
|
121
|
+
successCallback(result);
|
|
122
|
+
},
|
|
123
|
+
function(error) {
|
|
124
|
+
scanInProgress = false;
|
|
125
|
+
errorCallback(error);
|
|
126
|
+
},
|
|
127
|
+
'BarcodeScanner',
|
|
128
|
+
'scan',
|
|
129
|
+
config
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
//-------------------------------------------------------------------
|
|
134
|
+
BarcodeScanner.prototype.encode = function (type, data, successCallback, errorCallback, options) {
|
|
135
|
+
if (errorCallback == null) {
|
|
136
|
+
errorCallback = function () {
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (typeof errorCallback != "function") {
|
|
141
|
+
console.log("BarcodeScanner.encode failure: failure parameter not a function");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (typeof successCallback != "function") {
|
|
146
|
+
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
exec(successCallback, errorCallback, 'BarcodeScanner', 'encode', [
|
|
151
|
+
{"type": type, "data": data, "options": options}
|
|
152
|
+
]);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
var barcodeScanner = new BarcodeScanner();
|
|
156
|
+
module.exports = barcodeScanner;
|