Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

titanium 1.8.0.x support #4

Merged
merged 2 commits into from

2 participants

@RaduCirstoiu

No description provided.

@mwaylabs mwaylabs merged commit 404a2af into mwaylabs:master
@mwaylabs

Titanium 1.8.0.x Support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2012
  1. @RaduCirstoiu
  2. @RaduCirstoiu

    changed version to 0.3

    RaduCirstoiu authored
This page is out of date. Refresh to see the latest.
View
6 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
@@ -40,7 +40,7 @@ Use the module
- Build the module or download is from the download section
- Place it into your appcelerator project directory
-- Add the module to the module section of your tiapp.xml file: <modules><module version="0.2">com.mwaysolutions.barcode</module></modules>
+- Add the module to the module section of your tiapp.xml file: <modules><module version="0.3">com.mwaysolutions.barcode</module></modules>
- Use it in your application with require('com.mwaysolutions.barcode');
- Build your project as usual with the Titanium Developer application
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
7 manifest
@@ -2,15 +2,16 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
-version: 0.2
+version: 0.3
+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));
}
}
}
Something went wrong with that request. Please try again.