diff --git a/android/documentation/index.md b/android/documentation/index.md index 660c4330..9e6da644 100644 --- a/android/documentation/index.md +++ b/android/documentation/index.md @@ -14,7 +14,7 @@ the iOS and Android modules in to full parity. When upgrading to 1.5, you will n - BREAKING CHANGE: iOS now uses event listeners instead of callbacks! Use Ti.Barcode.addEventListener('success', ...) instead of capture({ success: ...})! - BREAKING CHANGE: Android's contentType property is now an integer, instead of a string! Check out the example and documentation to find out more. -- BREAKING CHANGE: All automatically parsed "data" keys will now be lower case. This ensures consistency across the API and ease of access. +- BREAKING CHANGE: All automatically parsed "data" keys will now be lower case. This ensures consistency across the API and ease of access. - BREAKING CHANGE: Android now properly fires the "cancel" event, as documented. It was firing the "canceled" event. - Ensure that you assign the module object that is returned from "require('ti.barcode')" to a variable or your event listeners may not receive the barcode events @@ -34,13 +34,16 @@ containing any of the following properties: * showRectangle[boolean]: Whether or not to include the default rectangle around the scanning area. Defaults to true. * overlay[view]: The view to lay on top of the camera activity. * keepOpen[boolean]: Whether or not to keep the barcode scanner open after a barcode is recognized. Defaults to false. When set to true, "success" will fire once every time a barcode is recognized, up to two times per second. As such, it can fire multiple times for a single barcode! -* acceptedFormats[int[]]: An optional array of int constants detailing which barcode formats are accepted. Defaults to all formats. Check out the "Barcode Format Constants" section below to see the available int constants. +* acceptedFormats[int[]]: An optional array of int constants detailing which barcode formats are accepted. Defaults to all formats. Check out the "Barcode Format Constants" section below to see the available int constants. +* preventRotation[boolean]: Prevent the scanner from auto-rotating when the device is rotated. Default: true +* frameWidth[int]: Width of the rectangle that is shown in the scanner +* frameHeight[int]: Height of the rectangle that is shown in the scanner ### parse([args]) Parses a blob image for barcodes. Takes one required argument, a dictionary containing any of the following properties: * image[blob]: The image blob to parse for a barcode. -* acceptedFormats[int[]]: An optional array of int constants detailing which barcode formats are accepted. Defaults to all formats. Check out the "Barcode Format Constants" section below to see the available int constants. +* acceptedFormats[int[]]: An optional array of int constants detailing which barcode formats are accepted. Defaults to all formats. Check out the "Barcode Format Constants" section below to see the available int constants. ### cancel() Cancels and closes the currently open capture window. @@ -51,23 +54,23 @@ Use Ti.Barcode.addEventListener() to process the following events that are sent ### success Sent upon a successful barcode scan. The event object contains the following fields: -* format[string, Android only] : The format of the barcode -* result[string] : The raw contents of the barcode -* code[string, Android only] : The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android][] namespace +* format[string, Android only] : The format of the barcode +* result[string] : The raw contents of the barcode +* code[string, Android only] : The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android][] namespace * contentType[int] : The type of barcode content. Use the constants defined in this module to determine which. * data[object]: The parsed fields associated with the contentType. ### error Sent when an error occurs. The event object contains the following fields: -* message[string] : The error message -* code[string] : The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android][] namespace +* message[string] : The error message +* code[string] : The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android][] namespace ### cancel Sent when the scanning process is canceled. The event object contains the following fields: -* message[string] : The error message -* code[string] : The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android][] namespace +* message[string] : The error message +* code[string] : The activity result code from the scanning activity. Use the result constants defined in the [Ti.Android][] namespace ## Properties @@ -87,7 +90,7 @@ Whether or not to display helpful instructions or a changelog when the app is up ### displayedMessage[string] Controls the message that is displayed to the end user when they are capturing a barcode. - + ### useFrontCamera[boolean, defaults to false] Controls whether or not the front camera on the device will be used to capture barcodes. On Android, this requires API level 9 (Android OS 2.3) or higher. If no front camera is available, this will gracefully fall back to utilize whatever @@ -157,4 +160,4 @@ Please direct all questions, feedback, and concerns to [info@appcelerator.com](m ## License Copyright(c) 2010-2013 by Appcelerator, Inc. All Rights Reserved. Please see the LICENSE file included in the distribution for further details. -[Ti.Android]: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android-module \ No newline at end of file +[Ti.Android]: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android-module diff --git a/android/example/app.js b/android/example/app.js index ef15a138..4a537639 100644 --- a/android/example/app.js +++ b/android/example/app.js @@ -10,8 +10,8 @@ Barcode.allowMenu = false; Barcode.allowInstructions = false; Barcode.useLED = true; -var isiOS = Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'android'; var isAndroid = Ti.Platform.osname === 'android'; +var isiOS = !isAndroid; var window = Ti.UI.createWindow({ backgroundColor: 'white' diff --git a/android/lib/core-3.3.1-SNAPSHOT.jar b/android/lib/core-3.3.1-SNAPSHOT.jar deleted file mode 100644 index 3dd36bc5..00000000 Binary files a/android/lib/core-3.3.1-SNAPSHOT.jar and /dev/null differ diff --git a/android/lib/core-3.3.3.jar b/android/lib/core-3.3.3.jar new file mode 100644 index 00000000..21eee687 Binary files /dev/null and b/android/lib/core-3.3.3.jar differ diff --git a/android/manifest b/android/manifest index 7da101f2..a42ba93e 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 4.0.1 +version: 4.0.2 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 description: Lets you process 1D/2D barcodes. diff --git a/android/src/com/google/zxing/client/android/CaptureActivity.java b/android/src/com/google/zxing/client/android/CaptureActivity.java index 8f4b912a..56ffa472 100755 --- a/android/src/com/google/zxing/client/android/CaptureActivity.java +++ b/android/src/com/google/zxing/client/android/CaptureActivity.java @@ -221,7 +221,7 @@ private void resume(){ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION, true)) { + if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION, true) && intent.getBooleanExtra(Intents.Scan.PREVENT_ROTATION, true)) { setRequestedOrientation(getCurrentOrientation()); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); diff --git a/android/src/com/google/zxing/client/android/Intents.java b/android/src/com/google/zxing/client/android/Intents.java index f7b97a32..8c77ad46 100755 --- a/android/src/com/google/zxing/client/android/Intents.java +++ b/android/src/com/google/zxing/client/android/Intents.java @@ -40,6 +40,7 @@ public static final class Scan { public static final String ALLOW_MENU = "ALLOW_MENU"; public static final String ALLOW_INSTRUCTIONS = "ALLOW_INSTRUCTIONS"; public static final String SHOW_INFO_TEXT = "SHOW_INFO_TEXT"; + public static final String PREVENT_ROTATION = "PREVENT_ROTATION"; public static TiViewProxy overlayProxy = null; /** diff --git a/android/src/ti/barcode/BarcodeModule.java b/android/src/ti/barcode/BarcodeModule.java index 8706b011..4411d65d 100644 --- a/android/src/ti/barcode/BarcodeModule.java +++ b/android/src/ti/barcode/BarcodeModule.java @@ -264,10 +264,10 @@ public void capture(@Kroll.argument(optional = true) HashMap args) { _instance = this; Intent intent = new Intent(Intents.Scan.ACTION); - + if (args != null) { KrollDict argsDict = new KrollDict(args); - + // [MOD-233] Turn off default animation if requested. It is on by default. boolean animate = argsDict.optBoolean("animate", true); if (!animate) { @@ -296,10 +296,11 @@ public void capture(@Kroll.argument(optional = true) HashMap args) { intent.putExtra(Intents.Scan.SHOW_RECTANGLE, argsDict.optBoolean("showRectangle", true)); intent.putExtra(Intents.Scan.KEEP_OPEN, argsDict.optBoolean("keepOpen", false)); - + frameWidth = argsDict.optInt("frameWidth", 0); + frameHeight = argsDict.optInt("frameHeight",0); intent.putExtra(Intents.Scan.SHOW_INFO_TEXT, argsDict.optBoolean("showInfoText", false)); + intent.putExtra(Intents.Scan.PREVENT_ROTATION, argsDict.optBoolean("preventRotation", true)); } else { - Intents.Scan.overlayProxy = null; intent.putExtra(Intents.Scan.SHOW_RECTANGLE, true); intent.putExtra(Intents.Scan.KEEP_OPEN, false); @@ -375,7 +376,7 @@ public void onResult(Activity activity, int requestCode, int resultCode, Intent e.printStackTrace(); processFailed(resultCode); } - + if (!keepOpen) { _instance = null; } diff --git a/android/timodule.xml b/android/timodule.xml index 27809732..54b16a80 100644 --- a/android/timodule.xml +++ b/android/timodule.xml @@ -1,15 +1,15 @@ - 1.7 - 1.7 + 1.7 + 1.7 diff --git a/ios/example/app.js b/ios/example/app.js index ef15a138..4a537639 100644 --- a/ios/example/app.js +++ b/ios/example/app.js @@ -10,8 +10,8 @@ Barcode.allowMenu = false; Barcode.allowInstructions = false; Barcode.useLED = true; -var isiOS = Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'android'; var isAndroid = Ti.Platform.osname === 'android'; +var isiOS = !isAndroid; var window = Ti.UI.createWindow({ backgroundColor: 'white'