forked from bafmin/Appcelerator-Android-Barcode-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
99 lines (73 loc) · 2.97 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Barcode Scanner For Appcelerator Titanium
=========================================
This is a small barcode scanner module you can use together with [Titanium Appcelerator](http://appcelerator.com) on an Android device.
Build prerequisites
-------------------
To build the module, there are some dependencies which need to be fulfilled:
- Git
- Titanium Mobile SDK 1.8.0.1 or above
- Python >= 2.5
- Sun Java SDK 6.0
- Android SDK with Google APIs and SDK version 8 installed
- Ant >= 1.7.1
Build the module
----------------
To build the module, you need to clone our git repository and build the sources with ant:
# clone the repository
git clone https://github.com/bafmin/Appcelerator-Android-Barcode-module
cd Appcelerator-Android-Barcode-module
# run ant to build the module
ant clean && ant
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.8.0.1/android
android.platform=/opt/android-sdk/platforms/android-8
google.apis=/opt/android-sdk/add-ons/addon_google_apis_google_inc_-8
The newly created *.jar and *.zip files can be found in the dist directory. The module you need is called com.mwaysolutions.barcode-android-$VERSION.zip
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.5">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
The Scanner looks strange on devices with a high resolution screen?!
--------------------------------------------------------------------
If the layout of the scanner activity is not centered, add the following entry to your tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
</manifest>
</android>
Code Example
------------
var window = Ti.UI.createWindow({
backgroundColor:'white'
});
var label = Ti.UI.createLabel();
window.add(label);
window.open();
var titaniumBarcode = require('com.mwaysolutions.barcode');
titaniumBarcode.scan({
success: function (data) {
if(data && data.barcode) {
var label = Titanium.UI.createLabel({
text:'Barcode: ' + data.barcode,
textAlign:'center',
width:'auto'
});
win.add(label);
} else {
alert(JSON.stringify(data));
}
},
error: function (err) {
alert("Error!! " + err);
},
cancel: function () {
alert("cancel");
}
});