mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-23 01:06:23 +08:00
changed FileUtils to public for testing purposes. added updategap that can updated a project with the latest phonegap jar and js
This commit is contained in:
parent
bb5a628a28
commit
0c52ed44a0
@ -164,9 +164,7 @@ PhoneGap.onNativeReady = new PhoneGap.Channel();
|
|||||||
// _nativeReady is global variable that the native side can set
|
// _nativeReady is global variable that the native side can set
|
||||||
// to signify that the native code is ready. It is a global since
|
// to signify that the native code is ready. It is a global since
|
||||||
// it may be called before any PhoneGap JS is ready.
|
// it may be called before any PhoneGap JS is ready.
|
||||||
try {
|
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
|
||||||
if (_nativeReady) { PhoneGap.onNativeReady.fire(); }
|
|
||||||
} catch (e) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onDeviceReady is fired only after both onDOMContentLoaded and
|
* onDeviceReady is fired only after both onDOMContentLoaded and
|
||||||
|
@ -11,7 +11,7 @@ public class FileUtils {
|
|||||||
FileReader f_in;
|
FileReader f_in;
|
||||||
FileWriter f_out;
|
FileWriter f_out;
|
||||||
|
|
||||||
FileUtils(WebView view)
|
public FileUtils(WebView view)
|
||||||
{
|
{
|
||||||
mView = view;
|
mView = view;
|
||||||
}
|
}
|
||||||
|
85
updategap
Executable file
85
updategap
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
|
# ./droidgap /Users/brianleroux/Code/android-sdk-mac MyApp com.westcoastlogic example /Users/brianleroux/Desktop/MyApp
|
||||||
|
class Build
|
||||||
|
attr_reader :android_sdk_path, :path
|
||||||
|
|
||||||
|
def initialize(*a)
|
||||||
|
@android_sdk_path, @path = a
|
||||||
|
@android_sdk_path = "/Users/davejohnson/Sdk/android-sdk-mac_86"
|
||||||
|
@android_dir = File.expand_path(File.dirname(__FILE__))
|
||||||
|
@framework_dir = File.join(@android_dir, "framework")
|
||||||
|
end
|
||||||
|
|
||||||
|
# runs the build script
|
||||||
|
def run
|
||||||
|
build_jar
|
||||||
|
copy_libs
|
||||||
|
puts "Complete!"
|
||||||
|
end
|
||||||
|
|
||||||
|
# removes local.properties and recreates based on android_sdk_path
|
||||||
|
# then generates framework/phonegap.jar
|
||||||
|
def build_jar
|
||||||
|
puts "Building the JAR..."
|
||||||
|
%w(local.properties phonegap.js phonegap.jar).each do |f|
|
||||||
|
FileUtils.rm File.join(@framework_dir, f) if File.exists? File.join(@framework_dir, f)
|
||||||
|
end
|
||||||
|
open(File.join(@framework_dir, "local.properties"), 'w') do |f|
|
||||||
|
f.puts "sdk.dir=#{ @android_sdk_path }"
|
||||||
|
end
|
||||||
|
Dir.chdir(@framework_dir)
|
||||||
|
`ant jar`
|
||||||
|
Dir.chdir(@android_dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
# copies stuff from framework into the project
|
||||||
|
# TODO need to allow for www import inc icon
|
||||||
|
def copy_libs
|
||||||
|
puts "Copying over libraries and assets and creating phonegap.js..."
|
||||||
|
|
||||||
|
FileUtils.mkdir_p File.join(@path, "libs")
|
||||||
|
FileUtils.cp File.join(@framework_dir, "phonegap.jar"), File.join(@path, "libs")
|
||||||
|
|
||||||
|
# concat JS and put into www folder.
|
||||||
|
js_dir = File.join(@framework_dir, "assets", "js")
|
||||||
|
|
||||||
|
phonegapjs = IO.read(File.join(js_dir, 'phonegap.js.base'))
|
||||||
|
|
||||||
|
Dir.new(js_dir).entries.each do |script|
|
||||||
|
next if script[0].chr == "." or script == "phonegap.js.base"
|
||||||
|
phonegapjs << IO.read(File.join(js_dir, script))
|
||||||
|
phonegapjs << "\n\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
File.open(File.join(@path, "assets", "www", "js", "phonegap.js"), 'w') {|f| f.write(phonegapjs) }
|
||||||
|
end
|
||||||
|
#
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if ARGV.length == 2
|
||||||
|
Build.new(*ARGV).run
|
||||||
|
else
|
||||||
|
puts <<-EOF
|
||||||
|
|
||||||
|
TestGap: Builds the JS and PhoneGap Android jar file and copies them to your project.
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Creates a fresh app for hybrid mobile web hacking. Delicious robot!
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
./testgap <android_sdk_path> <path>
|
||||||
|
|
||||||
|
Params:
|
||||||
|
|
||||||
|
android_sdk_path ... The path to your Android SDK install.
|
||||||
|
name ............... The name of your application.
|
||||||
|
package_name ....... The name of your package (For example: com.nitobi.demo)
|
||||||
|
www ................ The path to your www folder. (Wherein your HTML, CSS and JS app is.)
|
||||||
|
path ............... The path to generate the Android application.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user