Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

compiled with titanium sdk 1.8.1

commit 21ff4b80f0b57d4a42b885c628ec239ea95f2c3d 1 parent a20af62
@RaduCirstoiu RaduCirstoiu authored
View
4 README.md
@@ -9,7 +9,7 @@ Build prerequisites
To build the module, there are some dependencies which need to be fulfilled:
- Git
-- Titanium Mobile SDK 1.5.0 or above
+- Titanium Mobile SDK 1.8.1 or above
- Python >= 2.5
- Sun Java SDK 6.0
- Android SDK with Google APIs and SDK version 4 installed
@@ -29,7 +29,7 @@ To build the module, you need to clone our git repository and build the sources
If the build fails, make sure the entries in the buld.properies file point to the right path:
- titanium.platform=/Library/Application Support/Titanium/mobilesdk/osx/1.5.1/android
+ titanium.platform=/Library/Application Support/Titanium/mobilesdk/osx/1.8.1/android
android.platform=/opt/android-sdk/platforms/android-4
google.apis=/opt/android-sdk/add-ons/addon_google_apis_google_inc_4
View
2  build.xml
@@ -1,4 +1,4 @@
-<project name="titanium-barcode" default="dist">
+<project name="barcode" default="dist">
<description>
Ant build script for Titanium Android module titanium-barcode
</description>
View
5 manifest
@@ -3,14 +3,15 @@
# during compilation, packaging, distribution, etc.
#
version: 0.2
+apiversion: 2
description: Barcode module
author: M-WAY Solutions GmbH
license: Apache v2 license
copyright: Copyright (c) 2011 M-WAY Solutions GmbH
# these should not be edited
-name: titanium-barcode
+name: barcode
moduleid: com.mwaysolutions.barcode
guid: bc88d841-a015-45a8-8d95-31a4fa924c35
platform: android
-minsdk: 1.6.0
+minsdk: 1.8.1
View
33 src/com/mwaysolutions/barcode/TitaniumBarcodeModule.java
@@ -21,9 +21,11 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollInvocation;
import org.appcelerator.kroll.KrollModule;
+import org.appcelerator.kroll.KrollObject;
import org.appcelerator.kroll.annotations.Kroll;
+import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiContext;
-import org.appcelerator.titanium.kroll.KrollCallback;
+import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiActivityResultHandler;
import org.appcelerator.titanium.util.TiActivitySupport;
@@ -44,7 +46,7 @@
public class TitaniumBarcodeModule extends KrollModule {
private static final String LCAT = "TitaniumBarcodeModule";
- private static final boolean DBG = true; // TiConfig.LOGD;
+ private static final boolean DBG = true;
protected static final int UNKNOWN_ERROR = 0;
public TitaniumBarcodeModule(final TiContext context) {
@@ -52,16 +54,17 @@ public TitaniumBarcodeModule(final TiContext context) {
}
@Kroll.method
- public void scan(KrollInvocation invocation, KrollDict options) {
+ public void scan(KrollDict options) {
logDebug("scan() called");
-
- final KrollCallback successCallback = getCallback(options, "success");
- final KrollCallback cancelCallback = getCallback(options, "cancel");
- final KrollCallback errorCallback = getCallback(options, "error");
+
+ final KrollFunction successCallback = getCallback(options, "success");
+ final KrollFunction cancelCallback = getCallback(options, "cancel");
+ final KrollFunction errorCallback = getCallback(options, "error");
logDebug("launchScanActivity() called");
+
- final Activity activity = invocation.getTiContext().getActivity();
+ final Activity activity = TiApplication.getAppCurrentActivity();
final TiActivitySupport activitySupport = (TiActivitySupport) activity;
final TiIntentWrapper barcodeIntent = new TiIntentWrapper(new Intent(
@@ -85,9 +88,9 @@ private KrollDict getDictForResult(final String result) {
return dict;
}
- private KrollCallback getCallback(final KrollDict options, final String name) {
+ private KrollFunction getCallback(final KrollDict options, final String name) {
if (options.containsKey(name)) {
- return (KrollCallback) options.get(name);
+ return (KrollFunction) options.get(name);
} else {
logError("Callback not found: " + name);
return null;
@@ -108,7 +111,7 @@ private void logDebug(final String msg) {
Runnable {
protected int code;
- protected KrollCallback successCallback, cancelCallback, errorCallback;
+ protected KrollFunction successCallback, cancelCallback, errorCallback;
protected TiActivitySupport activitySupport;
protected Intent barcodeIntent;
@@ -119,10 +122,10 @@ public void run() {
public void onError(Activity activity, int requestCode, Exception e) {
String msg = "Problem with scanner; " + e.getMessage();
- logError("error: " + msg);
+ logError("error: " + msg);
if (errorCallback != null) {
errorCallback
- .callAsync(createErrorResponse(UNKNOWN_ERROR, msg));
+ .callAsync((KrollObject)errorCallback,createErrorResponse(UNKNOWN_ERROR, msg));
}
}
@@ -133,14 +136,14 @@ public void onResult(Activity activity, int requestCode,
if (resultCode == Activity.RESULT_CANCELED) {
logDebug("scan canceled");
if (cancelCallback != null) {
- cancelCallback.callAsync();
+ cancelCallback.callAsync((KrollObject)cancelCallback,new KrollDict());
}
} else {
logDebug("scan successful");
String result = data
.getStringExtra(TitaniumBarcodeActivity.EXTRA_RESULT);
logDebug("scan result: " + result);
- successCallback.callAsync(getDictForResult(result));
+ successCallback.callAsync((KrollObject)successCallback,getDictForResult(result));
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.