Merge branch 'master' of git://github.com/phonegap/phonegap-android

This commit is contained in:
macdonst 2011-06-22 14:48:49 -04:00
commit 1a9471a2e0
3 changed files with 43 additions and 10 deletions

View File

@ -119,8 +119,13 @@ public class DroidGap extends PhonegapActivity {
protected boolean clearHistory = false; protected boolean clearHistory = false;
// The initial URL for our app // The initial URL for our app
// ie http://server/path/index.html#abc?query
private String url; private String url;
// The initial URL for our app up to and including the file name
// ie http://server/path/index.html
private String urlFile;
// The base of the initial URL for our app // The base of the initial URL for our app
private String baseUrl; private String baseUrl;
@ -330,6 +335,7 @@ public class DroidGap extends PhonegapActivity {
*/ */
public void loadUrl(final String url) { public void loadUrl(final String url) {
System.out.println("loadUrl("+url+")"); System.out.println("loadUrl("+url+")");
this.urlFile = this.getUrlFile(url);
this.url = url; this.url = url;
int i = url.lastIndexOf('/'); int i = url.lastIndexOf('/');
if (i > 0) { if (i > 0) {
@ -693,13 +699,29 @@ public class DroidGap extends PhonegapActivity {
this.callbackServer.sendJavascript(statement); this.callbackServer.sendJavascript(statement);
} }
/**
* Return up to file part of url.
* If url = http://server/page.html#abc, then return http://server/page.html
*
* @param url
* @return
*/
private String getUrlFile(String url) {
int p1 = url.indexOf("#");
int p2 = url.indexOf("?");
if (p1 < 0) p1 = url.length();
if (p2 < 0) p2 = url.length();
int p3 = (p1 < p2) ? p1 : p2;
return url.substring(0, p3);
}
/** /**
* Provides a hook for calling "alert" from javascript. Useful for * Provides a hook for calling "alert" from javascript. Useful for
* debugging your javascript. * debugging your javascript.
*/ */
public class GapClient extends WebChromeClient { public class GapClient extends WebChromeClient {
private Context ctx; private DroidGap ctx;
/** /**
* Constructor. * Constructor.
@ -707,7 +729,7 @@ public class DroidGap extends PhonegapActivity {
* @param ctx * @param ctx
*/ */
public GapClient(Context ctx) { public GapClient(Context ctx) {
this.ctx = ctx; this.ctx = (DroidGap)ctx;
} }
/** /**
@ -780,7 +802,7 @@ public class DroidGap extends PhonegapActivity {
@Override @Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
boolean reqOk = false; boolean reqOk = false;
if (((DroidGap)(this.ctx)).url.equals(url)) { if (this.ctx.urlFile.equals(this.ctx.getUrlFile(url))) {
reqOk = true; reqOk = true;
} }
@ -1135,6 +1157,7 @@ public class DroidGap extends PhonegapActivity {
// If back key is bound, then send event to JavaScript // If back key is bound, then send event to JavaScript
if (this.bound) { if (this.bound) {
this.appView.loadUrl("javascript:PhoneGap.fireEvent('backbutton');"); this.appView.loadUrl("javascript:PhoneGap.fireEvent('backbutton');");
return true;
} }
// If not bound // If not bound
@ -1143,6 +1166,7 @@ public class DroidGap extends PhonegapActivity {
// Go to previous page in webview if it is possible to go back // Go to previous page in webview if it is possible to go back
if (this.appView.canGoBack()) { if (this.appView.canGoBack()) {
this.appView.goBack(); this.appView.goBack();
return true;
} }
// If not, then invoke behavior of super class // If not, then invoke behavior of super class
@ -1155,11 +1179,13 @@ public class DroidGap extends PhonegapActivity {
// If menu key // If menu key
else if (keyCode == KeyEvent.KEYCODE_MENU) { else if (keyCode == KeyEvent.KEYCODE_MENU) {
this.appView.loadUrl("javascript:PhoneGap.fireEvent('menubutton');"); this.appView.loadUrl("javascript:PhoneGap.fireEvent('menubutton');");
return true;
} }
// If search key // If search key
else if (keyCode == KeyEvent.KEYCODE_SEARCH) { else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
this.appView.loadUrl("javascript:PhoneGap.fireEvent('searchbutton');"); this.appView.loadUrl("javascript:PhoneGap.fireEvent('searchbutton');");
return true;
} }
return false; return false;

View File

@ -275,7 +275,7 @@ public class NetworkManager extends Plugin {
public int isReachable(String uri, boolean isIpAddress) { public int isReachable(String uri, boolean isIpAddress) {
int reachable = NOT_REACHABLE; int reachable = NOT_REACHABLE;
if (uri.indexOf("http://") == -1) { if (uri.indexOf("http://") == -1 && uri.indexOf("https://") == -1) {
uri = "http://" + uri; uri = "http://" + uri;
} }

View File

@ -33,12 +33,19 @@ class Update
# TODO need to allow for www import inc icon # TODO need to allow for www import inc icon
def copy_libs def copy_libs
puts "Copying over libraries and assets..." puts "Copying over libraries and assets..."
version = IO.read(File.join(@framework_dir, '../VERSION'))
FileUtils.mkdir_p File.join(@path, "libs") FileUtils.cp File.join(@framework_dir, "phonegap.#{ version }.jar"), File.join(@path, "libs")
FileUtils.cp File.join(@framework_dir, "phonegap.jar"), File.join(@path, "libs")
FileUtils.mkdir_p File.join(@path, "assets", "www") # concat JS and put into www folder. this can be overridden in the config.xml via @app_js_dir
FileUtils.cp File.join(@framework_dir, "assets", "www", "phonegap.js"), File.join(@path, "assets", "www") 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", "phonegap.#{ version }.js"), 'w') {|f| f.write(phonegapjs) }
end end
# #
end end