Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…barcodescanner

* 'master' of https://github.com/phonegap/phonegap-plugin-barcodescanner:
  Refactor windows implementation in promise manner
  Add support for orientation change from phonegap#62 and phonegap#97
  Resolve merge conflicts and address feedback for phonegap#62
  fixing issues for windows platform
  Correct scan result to expose format name instead of format code.
  Add information about windows 10 support to README
  Removes intermediate winmd component from Win10 implementation
  Add Windows 10 Support
  Improve native look and feel for windows platform
  Rework autofocus logic for windows. This fixes phonegap#41
  comments
  added data type check, and uri prepending for encode method
  error checking, data validation
  qrcode encode working
  encode method or blackberry
  • Loading branch information
Andres Sainz de aja committed Jan 4, 2016
2 parents b40228a + e22581c commit 087aa5c
Show file tree
Hide file tree
Showing 11 changed files with 1,156 additions and 87 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ It is also possible to install via repo url directly ( unstable )

- Android
- iOS
- Windows 8
- Windows (Windows/Windows Phone 8.1 and Windows 10)
- Windows Phone 8
- BlackBerry 10
- Browser
Expand All @@ -36,6 +36,12 @@ plugman currently doesn't support Library Project refs, so its been
prebuilt as a jar library. Any updates to the Library Project should be
committed with an updated jar.

Note: Windows 10 applications can not be build for `AnyCPU` architecture, which is default for Windows platform. If you want to build/run Windows 10 app, you should specify target architecture explicitly, for example (Cordova CLI):

```
cordova run windows -- --archs=x86
```

## Using the plugin ##
The plugin creates the object `cordova/plugin/BarcodeScanner` with the method `scan(success, fail)`.

Expand Down Expand Up @@ -69,7 +75,7 @@ The following barcode types are currently supported:
* CODE_39
* ITF

### Windows8
### Windows

* UPC_A
* UPC_E
Expand Down Expand Up @@ -155,8 +161,8 @@ A full example could be:
);
```

## Windows8 quirks ##
Windows 8 implementation currently doesn't support encode functionality.
## Windows quirks ##
Windows implementation currently doesn't support encode functionality.

## Windows Phone 8 quirks ##
Windows Phone 8 implementation currently doesn't support encode functionality.
Expand Down
14 changes: 11 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@
<DeviceCapability Name="webcam" />
</config-file>

<framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference"/>
<framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference" versions="<=8.1"/>
<framework src="src/windows/lib.UW/WinRTBarcodeReader.UW.csproj" custom="true" type="projectReference" versions=">8.1"/>
<asset src="src/windows/assets/plugin-barcodeScanner.css" target="css/plugin-barcodeScanner.css" />
</platform>

<platform name="windows">
Expand All @@ -311,7 +313,12 @@
<DeviceCapability Name="webcam" />
</config-file>

<framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference"/>
<framework src="src/windows/lib.UW/x86/ZXing.winmd" target-dir="x86" arch="x86" custom="true" versions=">8.1" />
<framework src="src/windows/lib.UW/x64/ZXing.winmd" target-dir="x64" arch="x64" custom="true" versions=">8.1" />
<framework src="src/windows/lib.UW/ARM/ZXing.winmd" target-dir="ARM" arch="ARM" custom="true" versions=">8.1" />
<framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference" versions="<=8.1"/>

<asset src="src/windows/assets/plugin-barcodeScanner.css" target="css/plugin-barcodeScanner.css" />
</platform>

<!-- Windows Phone 8 -->
Expand Down Expand Up @@ -348,10 +355,11 @@
<runs />
</js-module>
</platform>

<!-- BlackBerry 10 -->
<platform name="blackberry10">
<source-file src="src/blackberry10/index.js" target-dir="BarcodeScanner" />
<source-file src="src/blackberry10/qrcode.js" target-dir="BarcodeScanner" />
<lib-file src="src/blackberry10/native/device/libBarcodeScanner.so" arch="device"/>
<lib-file src="src/blackberry10/native/simulator/libBarcodeScanner.so" arch="simulator"/>
<config-file target="www/config.xml" parent="/widget">
Expand Down
67 changes: 66 additions & 1 deletion src/blackberry10/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
var barcodescanner,
resultObjs = {},
readCallback,
_utils = require("../../lib/utils");
_utils = require("../../lib/utils"),
_qr = require('plugin/BarcodeScanner/qrcode.js');

const SMS_URI_ONE = "smsto:",
SMS_URI_TWO = "sms:",
EMAIL_URI = "mailto:",
PHONE_URI = "tel:+1",
SMS_TYPE = "SMS_TYPE",
PHONE_TYPE = "PHONE_TYPE",
EMAIL_TYPE = "EMAIL_TYPE",
TEXT_TYPE = "TEXT_TYPE";

module.exports = {

Expand Down Expand Up @@ -45,8 +55,63 @@ module.exports = {
}
},

/*
Method for barcode encoding. Returns base 64 image URI
Currently only creates QRcodes
*/
encode: function (success, fail, args, env) {

var result = new PluginResult(args, env);
values = decodeURIComponent(args[0]);
values = JSON.parse(values);
data = values["data"];
type = values["type"];

if(data == "" || data == undefined){
result.error("Data to be encoded was not specified", false);
return;
}
if(type == "" || type == undefined){
type = TEXT_TYPE;
}

if(type == SMS_TYPE){
var check_one = data.substring(0,6).toLowerCase();
var check_two = data.substring(0,4).toLowerCase();
if(!(check_one == SMS_URI_ONE || check_two == SMS_URI_TWO)){
data = SMS_URI_ONE+data;
}
}else if(type == EMAIL_TYPE){
var check = data.substring(0,7).toLowerCase();
if(check != EMAIL_URI){
data = EMAIL_URI+data;
}
}else if(type == PHONE_TYPE){
var check = data.substring(0,4).toLowerCase();
if(check != PHONE_URI){
data = PHONE_URI+data;
}
}

console.log("Type: "+type + " Data: " + data);

//Make QRcode using qrcode.js
var bdiv = document.createElement('div');
var options = {
text: data,
width: 256,
height: 256,
colorDark : "#000000",
colorLight : "#ffffff",
};

var imageURI = _qr.makeQRcode(bdiv, options);

try{
result.ok(imageURI,false);
}catch(e){
result.error("Failed to encode barcode", false);
}
}
};

Expand Down
Loading

0 comments on commit 087aa5c

Please sign in to comment.