From 816341030f6a775624d53d6e0f13f55ddf519631 Mon Sep 17 00:00:00 2001 From: Brian LeRoux Date: Tue, 26 Jan 2010 17:58:27 -0800 Subject: [PATCH] generating apps works; needs to build js from assets --- README.md | 19 +++++++++++-------- droidgap | 35 ++++++++++++++++++++++++----------- framework/AndroidManifest.xml | 4 ++-- framework/build.xml | 6 +++--- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c49817e2..a7bbc10b 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,18 @@ Recommended: Getting Started with PhoneGap Android -------------------------------------- -1. Make sure you have Ruby and the nokogiri gem installed. Run 'gem list' to see a list of installed Ruby gems, and 'gem install nokogiri' from command-line if you don't have it. -2. Clone the repository using git, from command line: git clone git://github.com/phonegap/phonegap-android.git -3. Run 'cd phonegap-android/framework' -4. Create a local.properties file with the following line in it: - sdk-location=/path/to/your/androidsdk - -5. Run 'ant jar' - this will create the phonegap.jar file and build a fresh phonegap.js for use in your HTML/JS/CSS-based application (for accessing native functionality). -6. cd back to the root directory (cd ..) +1. Clone the repository using git, from command line: git clone git://github.com/phonegap/phonegap-android.git +2. Run the following command: + + ./droidgap + + + + + + + 7. Run 'ruby build.rb ', where: - app-name: Name of application without spaces - package name: Java namespace of package ( i.e. com.nitobi.demo). This must be unique otherwise it won't load properly on your phone diff --git a/droidgap b/droidgap index f97d6f81..458bf8de 100755 --- a/droidgap +++ b/droidgap @@ -1,25 +1,34 @@ #!/usr/bin/env ruby class Build - def start(*args) - @android_sdk_path, @name, @pkg, @www, @path = args - + attr_reader :android_sdk_path, :name, :pkg, :www, :path + + def initialize(*a) + @android_sdk_path, @name, @pkg, @www, @path = a + end + + # runs the build script + def run build_jar create_android generate_manifest copy_libs write_java - end + end # removes local.properties and recreates based on android_sdk_path # then generates framework/phonegap.jar def build_jar - `rm framework/local.properties` + `rm framework/local.properties` if File.exists? 'framework/local.properties' + `rm framework/phonegap.jar` if File.exists? 'framework/phonegap.jar' + `rm framework/phonegap.js` if File.exists? 'framework/phonegap.js' `ECHO 'sdk-location=#{ @android_sdk_path }' > framework/local.properties` - `ant jar` + `cd framework; ant jar` end # runs android create project + # TODO need to allow more flexible SDK targetting + # TODO validate Android SDK def create_android `android create project -t 5 -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }` end @@ -42,10 +51,11 @@ class Build # - copy www/icon.png into #{ @path }/res/drawable/icon.png # def copy_libs + `mkdir -p #{ @path }/assets/wwww` `cp framework/phonegap.jar #{ @path }/libs` `cp framework/res/values/strings.xml #{ @path }/res/values/strings.xml` - `cp framework/res #{ @path }/res` - `cp framework/assets/www #{ @path }/assets/wwww` + `cp -R framework/res #{ @path }/res` + `cp -R example #{ @path }/assets/wwww` end # this is so fucking unholy yet oddly beautiful @@ -68,14 +78,17 @@ class Build } } " - open("#{ @path }/src/#{ @pkg.gsub '.', '/' }",'w') { |f| f.puts j } + dir = "#{ @path }/src/#{ @pkg.gsub '.', '/' }"; + cls = "#{ @name }.java" + pth = File.join(dir,cls) + open(pth,'w') { |f| f.puts j } end # end -if(ARGV.length == 5) - Build.new.start(ARGV) +if ARGV.length == 5 + Build.new(*ARGV).run else puts <<-EOF diff --git a/framework/AndroidManifest.xml b/framework/AndroidManifest.xml index a3b0fba1..e4d33ba4 100644 --- a/framework/AndroidManifest.xml +++ b/framework/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.phonegap" android:versionName="1.1" android:versionCode="5"> - + diff --git a/framework/build.xml b/framework/build.xml index fe8d049b..8f306c76 100644 --- a/framework/build.xml +++ b/framework/build.xml @@ -64,9 +64,9 @@ assets directory --> - - - + + +