Skip to content

Commit

Permalink
Add supporting Android
Browse files Browse the repository at this point in the history
  • Loading branch information
bongole committed Feb 20, 2013
1 parent 868f01b commit 74bde28
Show file tree
Hide file tree
Showing 33 changed files with 685 additions and 0 deletions.
14 changes: 14 additions & 0 deletions android/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="build/.apt_generated"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/usr/local/Cellar/android-sdk/r21/platforms/android-8/android.jar"/>
<classpathentry kind="lib" path="/usr/local/Cellar/android-sdk/r21/add-ons/addon_google_apis_google_inc_8/libs/maps.jar"/>
<classpathentry kind="lib" path="/Users/bongole/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android/titanium.jar"/>
<classpathentry kind="lib" path="/Users/bongole/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android/js.jar"/>
<classpathentry kind="lib" path="/Users/bongole/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android/kroll-common.jar"/>
<classpathentry kind="lib" path="/Users/bongole/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android/kroll-apt.jar"/>
<classpathentry kind="lib" path="/Users/bongole/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android/modules/titanium-ui.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
5 changes: 5 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tmp
bin
build
*.zip
.apt_generated
29 changes: 29 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.appcelerator.titanium.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.appcelerator.titanium.mobile.module.nature</nature>
<nature>com.aptana.projects.webnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions android/.settings/com.aptana.editor.common.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
selectUserAgents=com.appcelerator.titanium.mobile.module.nature\:android
7 changes: 7 additions & 0 deletions android/.settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Thu Sep 02 15:18:34 CDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
org.eclipse.jdt.apt.reconcileEnabled=true

org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=android.json
3 changes: 3 additions & 0 deletions android/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Thu Sep 02 15:18:34 CDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.processAnnotations=enabled
1 change: 1 addition & 0 deletions android/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Place your change log text here. This file will be incorporated with your app at package time.
1 change: 1 addition & 0 deletions android/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: place your license here and we'll include it in the module distribution
1 change: 1 addition & 0 deletions android/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Place your license text here. This file will be incorporated with your app at package time.
6 changes: 6 additions & 0 deletions android/assets/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Place your assets like PNG files in this directory and they will be packaged with your module.

If you create a file named com.bongole.ti.alabel.js in this directory, it will be
compiled and used as your module. This allows you to run pure Javascript
modules that are pre-compiled.

71 changes: 71 additions & 0 deletions android/assets/com.bongole.ti.alabel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
function walk( d, r, pos ){
var nodes = d.childNodes;
var txt = '';
for(var i = 0; i < nodes.length; i++ ){
var n = nodes.item(i);
if( n.nodeType === n.TEXT_NODE ){
txt += n.nodeValue;
pos += n.nodeValue.length;
}
else{
var subtxt = walk( n, r, pos );

var attrs = n.attributes;
var attro = {};
for( var j = 0; j < attrs.length; j++){
var nn = attrs.item(j);
attro[nn.name] = nn.value;
}

var o = {};
o[n.nodeName] = attro;

var subtxt_len = subtxt.length;

r.forEach(function(rc){
// inherit attributes.
// ex. <font fontSize="30dp">aaa<font color="red">bbb</font></font>
// "bbb" should 30dp size and red color font.
var start = rc[0];
var end = rc[0] + rc[1];
if( pos <= start && end <= (pos + subtxt_len) ){
var oc = rc[2];
for( var node_name in oc ){
if( n.nodeName == node_name ){
var attroc = oc[node_name];
for( var prop in attro ){
if( !attroc.hasOwnProperty(prop) ){
attroc[prop] = attro[prop];
}
}
}
}
}
});

r.push([pos, pos + subtxt_len, o]);

txt += subtxt;
pos += subtxt.length;
}
}

return txt;
}

exports.createALabel = function(opt){
var l = this.createAttributedLabel(opt);

l.setHTMLText = function(txt){
var doc = Ti.XML.parseString('<xml>' + txt.replace(/<br\/?>/ig, "\n") + '</xml>');
var result = [];
var t = walk( doc, result, 0);

l.attributedText = {
text: t,
attributes: result
};
};

return l;
}
4 changes: 4 additions & 0 deletions android/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
titanium.platform=/Users/bongole/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android
android.platform=/usr/local/Cellar/android-sdk/r21/platforms/android-8
android.ndk=/usr/local/Cellar/android-ndk/r8c
google.apis=/usr/local/Cellar/android-sdk/r21/add-ons/addon_google_apis_google_inc_8
10 changes: 10 additions & 0 deletions android/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<project name="android" default="dist">
<description>
Ant build script for Titanium Android module android
</description>

<property name="ti.module.root" location="${basedir}"/>
<property file="build.properties" />

<import file="${titanium.platform}/../module/android/build.xml"/>
</project>
Binary file added android/dist/android.jar
Binary file not shown.
39 changes: 39 additions & 0 deletions android/documentation/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# android Module

## Description

TODO: Enter your module description here

## Accessing the android Module

To access this module from JavaScript, you would do the following:

var android = require("com.bongole.ti.alabel");

The android variable is a reference to the Module object.

## Reference

TODO: If your module has an API, you should document
the reference here.

### ___PROJECTNAMEASIDENTIFIER__.function

TODO: This is an example of a module function.

### ___PROJECTNAMEASIDENTIFIER__.property

TODO: This is an example of a module property.

## Usage

TODO: Enter your usage example here

## Author

TODO: Enter your author name, email and other contact
details you want to share here.

## License

TODO: Enter your license/legal information here.
39 changes: 39 additions & 0 deletions android/example/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This is a test harness for your module
// You should do something interesting in this harness
// to test out the module and to provide instructions
// to users on how to use it by example.


// open a single window
var win = Ti.UI.createWindow({
backgroundColor:'white'
});
var label = Ti.UI.createLabel();
win.add(label);
win.open();

// TODO: write your module tests here
var android = require('com.bongole.ti.alabel');
Ti.API.info("module is => " + android);

label.text = android.example();

Ti.API.info("module exampleProp is => " + android.exampleProp);
android.exampleProp = "This is a test value";

if (Ti.Platform.name == "android") {
var proxy = android.createExample({
message: "Creating an example Proxy",
backgroundColor: "red",
width: 100,
height: 100,
top: 100,
left: 150
});

proxy.printMessage("Hello world!");
proxy.message = "Hi world!. It's me again.";
proxy.printMessage("Hello world!");
win.add(proxy);
}

1 change: 1 addition & 0 deletions android/hooks/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These files are not yet supported as of 1.4.0 but will be in a near future release.
35 changes: 35 additions & 0 deletions android/hooks/add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
#
# This is the module project add hook that will be
# called when your module is added to a project
#
import os, sys

def dequote(s):
if s[0:1] == '"':
return s[1:-1]
return s

def main(args,argc):
# You will get the following command line arguments
# in the following order:
#
# project_dir = the full path to the project root directory
# project_type = the type of project (desktop, mobile, ipad)
# project_name = the name of the project
#
project_dir = dequote(os.path.expanduser(args[1]))
project_type = dequote(args[2])
project_name = dequote(args[3])

# TODO: write your add hook here (optional)


# exit
sys.exit(0)



if __name__ == '__main__':
main(sys.argv,len(sys.argv))

19 changes: 19 additions & 0 deletions android/hooks/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
#
# This is the module install hook that will be
# called when your module is first installed
#
import os, sys

def main(args,argc):

# TODO: write your install hook here (optional)

# exit
sys.exit(0)



if __name__ == '__main__':
main(sys.argv,len(sys.argv))

34 changes: 34 additions & 0 deletions android/hooks/remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python
#
# This is the module project remove hook that will be
# called when your module is remove from a project
#
import os, sys

def dequote(s):
if s[0:1] == '"':
return s[1:-1]
return s

def main(args,argc):
# You will get the following command line arguments
# in the following order:
#
# project_dir = the full path to the project root directory
# project_type = the type of project (desktop, mobile, ipad)
# project_name = the name of the project
#
project_dir = dequote(os.path.expanduser(args[1]))
project_type = dequote(args[2])
project_name = dequote(args[3])

# TODO: write your remove hook here (optional)

# exit
sys.exit(0)



if __name__ == '__main__':
main(sys.argv,len(sys.argv))

18 changes: 18 additions & 0 deletions android/hooks/uninstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
#
# This is the module uninstall hook that will be
# called when your module is uninstalled
#
import os, sys

def main(args,argc):

# TODO: write your uninstall hook here (optional)

# exit
sys.exit(0)


if __name__ == '__main__':
main(sys.argv,len(sys.argv))

Binary file not shown.
Binary file added android/libs/armeabi/libcom.bongole.ti.alabel.so
Binary file not shown.
Binary file added android/libs/x86/libcom.bongole.ti.alabel.so
Binary file not shown.
19 changes: 19 additions & 0 deletions android/manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 0.1
apiversion: 2
description: My module
author: Your Name
license: Specify your license
copyright: Copyright (c) 2013 by Your Company


# these should not be edited
name: android
moduleid: com.bongole.ti.alabel
guid: 10f44e1c-a6cd-4d64-847b-a6d68bbd2add
platform: android
minsdk: 3.0.0.GA
commonjs: true
3 changes: 3 additions & 0 deletions android/platform/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You can place platform-specific files here in sub-folders named "android" and/or "iphone", just as you can with normal Titanium Mobile SDK projects. Any folders and files you place here will be merged with the platform-specific files in a Titanium Mobile project that uses this module.

When a Titanium Mobile project that uses this module is built, the files from this platform/ folder will be treated the same as files (if any) from the Titanium Mobile project's platform/ folder.
Loading

0 comments on commit 74bde28

Please sign in to comment.