Permalink
Comparing changes
Open a pull request
- 9 commits
- 6 files changed
- 0 commit comments
- 6 contributors
Commits on Mar 30, 2015
… iOS
Unified
Split
Showing
with
329 additions
and 151 deletions.
- +6 −2 plugin.xml
- +44 −3 src/android/com/phonegap/plugins/barcodescanner/BarcodeScanner.java
- BIN src/ios/CDVBarcodeScanner.bundle/beep.caf
- +173 −51 src/ios/CDVBarcodeScanner.mm
- +93 −93 src/ios/zxing-all-in-one.cpp
- +13 −2 www/barcodescanner.js
| @@ -1,7 +1,7 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?><plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| id="com.phonegap.plugins.barcodescanner" | ||
| version="2.0.1"> | ||
| version="2.2.0"> | ||
|
|
||
| <name>BarcodeScanner</name> | ||
| <description>You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.</description> | ||
| @@ -28,6 +28,7 @@ | ||
| </config-file> | ||
|
|
||
| <resource-file src="src/ios/scannerOverlay.xib" /> | ||
| <resource-file src="src/ios/CDVBarcodeScanner.bundle" /> | ||
|
|
||
| <header-file src="src/ios/zxing-all-in-one.h" /> | ||
|
|
||
| @@ -39,6 +40,9 @@ | ||
| <framework src="AssetsLibrary.framework" /> | ||
| <framework src="CoreVideo.framework" /> | ||
| <framework src="QuartzCore.framework" /> | ||
| <framework src="CoreGraphics.framework" /> | ||
| <framework src="CoreImage.framework" /> | ||
| <framework src="AudioToolbox.framework" /> | ||
| </platform> | ||
|
|
||
| <!-- android --> | ||
| @@ -71,7 +75,7 @@ | ||
| android:windowSoftInputMode="stateAlwaysHidden" | ||
| android:exported="false"> | ||
| <intent-filter> | ||
| <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/> | ||
| <action android:name="com.google.zxing.client.android.SCAN"/> | ||
| <category android:name="android.intent.category.DEFAULT"/> | ||
| </intent-filter> | ||
| </activity> | ||
| @@ -20,6 +20,8 @@ | ||
| import org.apache.cordova.CallbackContext; | ||
| import org.apache.cordova.PluginResult; | ||
|
|
||
| import android.util.Log; | ||
|
|
||
| /** | ||
| * This calls out to the ZXing barcode reader and returns the result. | ||
| * | ||
| @@ -35,7 +37,7 @@ | ||
| private static final String TEXT = "text"; | ||
| private static final String DATA = "data"; | ||
| private static final String TYPE = "type"; | ||
| private static final String SCAN_INTENT = "com.phonegap.plugins.barcodescanner.SCAN"; | ||
| private static final String SCAN_INTENT = "com.google.zxing.client.android.SCAN"; | ||
| private static final String ENCODE_DATA = "ENCODE_DATA"; | ||
| private static final String ENCODE_TYPE = "ENCODE_TYPE"; | ||
| private static final String ENCODE_INTENT = "com.phonegap.plugins.barcodescanner.ENCODE"; | ||
| @@ -96,7 +98,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo | ||
| return true; | ||
| } | ||
| } else if (action.equals(SCAN)) { | ||
| scan(); | ||
| scan(args); | ||
| } else { | ||
| return false; | ||
| } | ||
| @@ -106,9 +108,48 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo | ||
| /** | ||
| * Starts an intent to scan and decode a barcode. | ||
| */ | ||
| public void scan() { | ||
| public void scan(JSONArray args) { | ||
| Intent intentScan = new Intent(SCAN_INTENT); | ||
| intentScan.addCategory(Intent.CATEGORY_DEFAULT); | ||
|
|
||
| // add config as intent extras | ||
| if(args.length() > 0) { | ||
|
|
||
| JSONObject obj; | ||
| JSONArray names; | ||
| String key; | ||
| Object value; | ||
|
|
||
| for(int i=0; i<args.length(); i++) { | ||
|
|
||
| try { | ||
| obj = args.getJSONObject(i); | ||
| } catch(JSONException e) { | ||
| Log.i("CordovaLog", e.getLocalizedMessage()); | ||
| continue; | ||
| } | ||
|
|
||
| names = obj.names(); | ||
| for(int j=0; j<names.length(); j++) { | ||
| try { | ||
| key = names.getString(j); | ||
| value = obj.get(key); | ||
|
|
||
| if(value instanceof Integer) { | ||
| intentScan.putExtra(key, (Integer)value); | ||
| } else if(value instanceof String) { | ||
| intentScan.putExtra(key, (String)value); | ||
| } | ||
|
|
||
| } catch(JSONException e) { | ||
| Log.i("CordovaLog", e.getLocalizedMessage()); | ||
| continue; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // avoid calling other phonegap apps | ||
| intentScan.setPackage(this.cordova.getActivity().getApplicationContext().getPackageName()); | ||
|
|
||
Binary file not shown.
Oops, something went wrong.