mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:42:53 +08:00
Merge branch 'master' of git://github.com/phonegap/phonegap-android
This commit is contained in:
commit
55379d6fba
@ -367,6 +367,9 @@ PhoneGap.Channel.join(function() {
|
|||||||
// Fire onDeviceReady event once all constructors have run and PhoneGap info has been
|
// Fire onDeviceReady event once all constructors have run and PhoneGap info has been
|
||||||
// received from native side, and any user defined initialization channels.
|
// received from native side, and any user defined initialization channels.
|
||||||
PhoneGap.Channel.join(function() {
|
PhoneGap.Channel.join(function() {
|
||||||
|
// Let native code know we are inited on JS side
|
||||||
|
prompt("", "gap_init:");
|
||||||
|
|
||||||
PhoneGap.onDeviceReady.fire();
|
PhoneGap.onDeviceReady.fire();
|
||||||
|
|
||||||
// Fire the onresume event, since first one happens before JavaScript is loaded
|
// Fire the onresume event, since first one happens before JavaScript is loaded
|
||||||
|
@ -95,6 +95,10 @@ import com.phonegap.api.PluginManager;
|
|||||||
* // (String - default=null)
|
* // (String - default=null)
|
||||||
* super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
|
* super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
|
||||||
*
|
*
|
||||||
|
* // Display a native loading dialog when loading sub-pages. Format for value = "Title,Message".
|
||||||
|
* // (String - default=null)
|
||||||
|
* super.setStringProperty("loadingPageDialog", "Loading page...");
|
||||||
|
*
|
||||||
* // Cause all links on web page to be loaded into existing web view,
|
* // Cause all links on web page to be loaded into existing web view,
|
||||||
* // instead of being loaded into new browser. (Boolean - default=false)
|
* // instead of being loaded into new browser. (Boolean - default=false)
|
||||||
* super.setBooleanProperty("loadInWebView", true);
|
* super.setBooleanProperty("loadInWebView", true);
|
||||||
@ -103,6 +107,10 @@ import com.phonegap.api.PluginManager;
|
|||||||
* // (Integer - default=0)
|
* // (Integer - default=0)
|
||||||
* super.setIntegerProperty("splashscreen", R.drawable.splash);
|
* super.setIntegerProperty("splashscreen", R.drawable.splash);
|
||||||
*
|
*
|
||||||
|
* // Set the background color.
|
||||||
|
* // (Integer - default=0 or BLACK)
|
||||||
|
* super.setIntegerProperty("backgroundColor", Color.WHITE);
|
||||||
|
*
|
||||||
* // Time in msec to wait before triggering a timeout error when loading
|
* // Time in msec to wait before triggering a timeout error when loading
|
||||||
* // with super.loadUrl(). (Integer - default=20000)
|
* // with super.loadUrl(). (Integer - default=20000)
|
||||||
* super.setIntegerProperty("loadUrlTimeoutValue", 60000);
|
* super.setIntegerProperty("loadUrlTimeoutValue", 60000);
|
||||||
@ -144,6 +152,10 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
// Flag indicates that a loadUrl timeout occurred
|
// Flag indicates that a loadUrl timeout occurred
|
||||||
private int loadUrlTimeout = 0;
|
private int loadUrlTimeout = 0;
|
||||||
|
|
||||||
|
// Default background color for activity
|
||||||
|
// (this is not the color for the webview, which is set in HTML)
|
||||||
|
private int backgroundColor = Color.BLACK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The variables below are used to cache some of the activity properties.
|
* The variables below are used to cache some of the activity properties.
|
||||||
*/
|
*/
|
||||||
@ -183,7 +195,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
|
|
||||||
root = new LinearLayoutSoftKeyboardDetect(this, width, height);
|
root = new LinearLayoutSoftKeyboardDetect(this, width, height);
|
||||||
root.setOrientation(LinearLayout.VERTICAL);
|
root.setOrientation(LinearLayout.VERTICAL);
|
||||||
root.setBackgroundColor(Color.BLACK);
|
root.setBackgroundColor(this.backgroundColor);
|
||||||
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||||
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
|
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
|
||||||
|
|
||||||
@ -297,6 +309,10 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If backgroundColor
|
||||||
|
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
|
||||||
|
this.root.setBackgroundColor(this.backgroundColor);
|
||||||
|
|
||||||
// If spashscreen
|
// If spashscreen
|
||||||
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
|
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
|
||||||
if (this.splashscreen != 0) {
|
if (this.splashscreen != 0) {
|
||||||
@ -712,7 +728,8 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
public void showWebPage(String url, boolean usePhoneGap, boolean clearPrev, HashMap<String, Object> params) throws android.content.ActivityNotFoundException {
|
public void showWebPage(String url, boolean usePhoneGap, boolean clearPrev, HashMap<String, Object> params) throws android.content.ActivityNotFoundException {
|
||||||
Intent intent = null;
|
Intent intent = null;
|
||||||
if (usePhoneGap) {
|
if (usePhoneGap) {
|
||||||
intent = new Intent().setClass(this, com.phonegap.DroidGap.class);
|
try {
|
||||||
|
intent = new Intent().setClass(this, Class.forName(this.getComponentName().getClassName()));
|
||||||
intent.putExtra("url", url);
|
intent.putExtra("url", url);
|
||||||
|
|
||||||
// Add parameters
|
// Add parameters
|
||||||
@ -737,6 +754,11 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setData(Uri.parse(url));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
@ -915,6 +937,14 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
result.confirm(r);
|
result.confirm(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PhoneGap JS has initialized, so show webview
|
||||||
|
// (This solves white flash seen when rendering HTML)
|
||||||
|
else if (reqOk && defaultValue.equals("gap_init:")) {
|
||||||
|
appView.setVisibility(View.VISIBLE);
|
||||||
|
ctx.spinnerStop();
|
||||||
|
result.confirm("OK");
|
||||||
|
}
|
||||||
|
|
||||||
// Show dialog
|
// Show dialog
|
||||||
else {
|
else {
|
||||||
final JsPromptResult res = result;
|
final JsPromptResult res = result;
|
||||||
@ -1123,7 +1153,11 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
try {
|
try {
|
||||||
// Init parameters to new DroidGap activity and propagate existing parameters
|
// Init parameters to new DroidGap activity and propagate existing parameters
|
||||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("loadingDialog", null);
|
String loadingPage = this.ctx.getStringProperty("loadingPageDialog", null);
|
||||||
|
if (loadingPage != null) {
|
||||||
|
params.put("loadingDialog", loadingPage);
|
||||||
|
params.put("loadingPageDialog", loadingPage);
|
||||||
|
}
|
||||||
if (this.ctx.loadInWebView) {
|
if (this.ctx.loadInWebView) {
|
||||||
params.put("loadInWebView", true);
|
params.put("loadInWebView", true);
|
||||||
}
|
}
|
||||||
@ -1133,6 +1167,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
if (errorUrl != null) {
|
if (errorUrl != null) {
|
||||||
params.put("errorUrl", errorUrl);
|
params.put("errorUrl", errorUrl);
|
||||||
}
|
}
|
||||||
|
params.put("backgroundColor", this.ctx.backgroundColor);
|
||||||
|
|
||||||
this.ctx.showWebPage(url, true, false, params);
|
this.ctx.showWebPage(url, true, false, params);
|
||||||
} catch (android.content.ActivityNotFoundException e) {
|
} catch (android.content.ActivityNotFoundException e) {
|
||||||
@ -1174,11 +1209,23 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
appView.loadUrl("javascript:try{ PhoneGap.onNativeReady.fire();}catch(e){_nativeReady = true;}");
|
appView.loadUrl("javascript:try{ PhoneGap.onNativeReady.fire();}catch(e){_nativeReady = true;}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make app view visible
|
// Make app visible after 2 sec in case there was a JS error and PhoneGap JS never initialized correctly
|
||||||
|
Thread t = new Thread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
ctx.runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
appView.setVisibility(View.VISIBLE);
|
appView.setVisibility(View.VISIBLE);
|
||||||
|
ctx.spinnerStop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
|
||||||
// Stop "app loading" spinner if showing
|
|
||||||
this.ctx.spinnerStop();
|
|
||||||
|
|
||||||
// Clear history, so that previous screen isn't there when Back button is pressed
|
// Clear history, so that previous screen isn't there when Back button is pressed
|
||||||
if (this.ctx.clearHistory) {
|
if (this.ctx.clearHistory) {
|
||||||
|
Loading…
Reference in New Issue
Block a user