mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2d91c2556 | |||
| 634a9c0f4c | |||
| c846111099 | |||
| 960e0f3412 | |||
| 39f261c6e2 | |||
| d7c8bc799d | |||
| f4da7e164d | |||
| 05192a91da | |||
| 3835144b93 | |||
| bdf452b02a | |||
| bcc2957f20 | |||
| 81059b398f | |||
| 31d5a94ea9 | |||
| 1e5457a47d | |||
| 7b75e2f1b0 | |||
| 180696baec | |||
| 76820ebaff |
@@ -4,6 +4,6 @@
|
||||
|
||||
# if there are no devices listed then emulate
|
||||
|
||||
|
||||
ant clean
|
||||
ant debug install
|
||||
adb shell am start -n $PACKAGE/$PACKAGE.$ACTIVITY
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-1.6.1.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="cordova-1.6.1.js"></script>
|
||||
<script src="cordova-1.7.0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -34,4 +34,5 @@
|
||||
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
||||
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
||||
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
||||
</plugins>
|
||||
|
||||
@@ -38,7 +38,7 @@ import android.telephony.TelephonyManager;
|
||||
public class Device extends Plugin {
|
||||
public static final String TAG = "Device";
|
||||
|
||||
public static String cordovaVersion = "1.6.1"; // Cordova version
|
||||
public static String cordovaVersion = "1.7.0"; // Cordova version
|
||||
public static String platform = "Android"; // Device OS
|
||||
public static String uuid; // Device UUID
|
||||
|
||||
|
||||
@@ -37,17 +37,18 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Display;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@@ -433,9 +434,6 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
|
||||
// If spashscreen
|
||||
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
|
||||
if ((this.urls.size() == 0) && (this.splashscreen != 0)) {
|
||||
root.setBackgroundResource(this.splashscreen);
|
||||
}
|
||||
|
||||
// If loadUrlTimeoutValue
|
||||
int timeout = this.getIntegerProperty("loadUrlTimeoutValue", 0);
|
||||
@@ -608,38 +606,12 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
if (!url.startsWith("javascript:")) {
|
||||
LOG.d(TAG, "DroidGap.loadUrl(%s, %d)", url, time);
|
||||
}
|
||||
final DroidGap me = this;
|
||||
|
||||
// Handle activity parameters
|
||||
this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (me.appView == null) {
|
||||
me.init();
|
||||
}
|
||||
me.handleActivityParameters();
|
||||
}
|
||||
});
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
synchronized(this) {
|
||||
this.wait(time);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!me.cancelLoadUrl) {
|
||||
me.loadUrlIntoView(url);
|
||||
}
|
||||
else{
|
||||
me.cancelLoadUrl = false;
|
||||
LOG.d(TAG, "Aborting loadUrl(%s): Another URL was loaded before timer expired.", url);
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
|
||||
this.handleActivityParameters();
|
||||
if (this.splashscreen != 0) {
|
||||
this.showSplashScreen(time);
|
||||
}
|
||||
this.loadUrlIntoView(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1072,7 +1044,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a key is pressed.
|
||||
* Called when a key is de-pressed. (Key UP)
|
||||
*
|
||||
* @param keyCode
|
||||
* @param event
|
||||
@@ -1085,21 +1057,16 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
|
||||
// If back key
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
||||
// If back key is bound, then send event to JavaScript
|
||||
if (this.bound) {
|
||||
this.appView.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not bound
|
||||
else {
|
||||
|
||||
} else {
|
||||
// If not bound
|
||||
// Go to previous page in webview if it is possible to go back
|
||||
if (this.backHistory()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not, then invoke behavior of super class
|
||||
else {
|
||||
this.activityState = ACTIVITY_EXITING;
|
||||
@@ -1437,4 +1404,47 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
return this.bound;
|
||||
}
|
||||
|
||||
protected Dialog splashDialog;
|
||||
|
||||
/**
|
||||
* Removes the Dialog that displays the splash screen
|
||||
*/
|
||||
public void removeSplashScreen() {
|
||||
if (splashDialog != null) {
|
||||
splashDialog.dismiss();
|
||||
splashDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the splash screen over the full Activity
|
||||
*/
|
||||
protected void showSplashScreen(int time) {
|
||||
// Get reference to display
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
|
||||
// Create the layout for the dialog
|
||||
LinearLayout root = new LinearLayout(this);
|
||||
root.setMinimumHeight(display.getHeight());
|
||||
root.setMinimumWidth(display.getWidth());
|
||||
root.setOrientation(LinearLayout.VERTICAL);
|
||||
root.setBackgroundColor(this.getIntegerProperty("backgroundColor", Color.BLACK));
|
||||
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
|
||||
root.setBackgroundResource(this.splashscreen);
|
||||
|
||||
// Create and show the dialog
|
||||
splashDialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
|
||||
splashDialog.setContentView(root);
|
||||
splashDialog.setCancelable(false);
|
||||
splashDialog.show();
|
||||
|
||||
// Set Runnable to remove splash screen just in case
|
||||
final Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
removeSplashScreen();
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class FileTransfer extends Plugin {
|
||||
*/
|
||||
public JSONObject download(String source, String target) throws IOException {
|
||||
try {
|
||||
File file = new File(target);
|
||||
File file = getFileFromPath(target);
|
||||
|
||||
// create needed directories
|
||||
file.getParentFile().mkdirs();
|
||||
@@ -421,6 +421,14 @@ public class FileTransfer extends Plugin {
|
||||
URL url = new URL(source);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
//Add cookie support
|
||||
String cookie = CookieManager.getInstance().getCookie(source);
|
||||
if(cookie != null)
|
||||
{
|
||||
connection.setRequestProperty("cookie", cookie);
|
||||
}
|
||||
|
||||
connection.connect();
|
||||
|
||||
Log.d(LOG_TAG, "Download file:" + url);
|
||||
@@ -480,4 +488,17 @@ public class FileTransfer extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a File object from the passed in path
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
private File getFileFromPath(String path) {
|
||||
if (path.startsWith("file://")) {
|
||||
return new File(path.substring(7));
|
||||
} else {
|
||||
return new File(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class NetworkManager extends Plugin {
|
||||
public static final String LTE = "lte";
|
||||
public static final String UMB = "umb";
|
||||
public static final String HSPA_PLUS = "hspa+";
|
||||
// return types
|
||||
// return type
|
||||
public static final String TYPE_UNKNOWN = "unknown";
|
||||
public static final String TYPE_ETHERNET = "ethernet";
|
||||
public static final String TYPE_WIFI = "wifi";
|
||||
@@ -89,7 +89,7 @@ public class NetworkManager extends Plugin {
|
||||
*/
|
||||
public void setContext(CordovaInterface ctx) {
|
||||
super.setContext(ctx);
|
||||
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
this.connectionCallbackId = null;
|
||||
|
||||
// We need to listen to connectivity events to update navigator.connection
|
||||
@@ -98,7 +98,7 @@ public class NetworkManager extends Plugin {
|
||||
if (this.receiver == null) {
|
||||
this.receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
|
||||
}
|
||||
};
|
||||
@@ -117,7 +117,7 @@ public class NetworkManager extends Plugin {
|
||||
*/
|
||||
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
||||
PluginResult.Status status = PluginResult.Status.INVALID_ACTION;
|
||||
String result = "Unsupported Operation: " + action;
|
||||
String result = "Unsupported Operation: " + action;
|
||||
|
||||
if (action.equals("getConnectionInfo")) {
|
||||
this.connectionCallbackId = callbackId;
|
||||
@@ -137,8 +137,7 @@ public class NetworkManager extends Plugin {
|
||||
* @return T=returns value
|
||||
*/
|
||||
public boolean isSynch(String action) {
|
||||
// All methods take a while, so always use async
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +181,7 @@ public class NetworkManager extends Plugin {
|
||||
// If we are not connected to any network set type to none
|
||||
if (!info.isConnected()) {
|
||||
type = TYPE_NONE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = getType(info);
|
||||
}
|
||||
@@ -212,7 +211,7 @@ public class NetworkManager extends Plugin {
|
||||
*/
|
||||
private String getType(NetworkInfo info) {
|
||||
if (info != null) {
|
||||
String type = info.getTypeName();
|
||||
String type = info.getTypeName();
|
||||
|
||||
if (type.toLowerCase().equals(WIFI)) {
|
||||
return TYPE_WIFI;
|
||||
|
||||
@@ -233,7 +233,7 @@ public class Notification extends Plugin {
|
||||
|
||||
// First button
|
||||
if (fButtons.length > 0) {
|
||||
dlg.setPositiveButton(fButtons[0],
|
||||
dlg.setNegativeButton(fButtons[0],
|
||||
new AlertDialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
@@ -255,7 +255,7 @@ public class Notification extends Plugin {
|
||||
|
||||
// Third button
|
||||
if (fButtons.length > 2) {
|
||||
dlg.setNegativeButton(fButtons[2],
|
||||
dlg.setPositiveButton(fButtons[2],
|
||||
new AlertDialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apache.cordova;
|
||||
|
||||
import org.apache.cordova.api.Plugin;
|
||||
import org.apache.cordova.api.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
|
||||
public class SplashScreen extends Plugin {
|
||||
|
||||
@Override
|
||||
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
||||
PluginResult.Status status = PluginResult.Status.OK;
|
||||
String result = "";
|
||||
|
||||
if (action.equals("hide")) {
|
||||
((DroidGap)this.ctx).removeSplashScreen();
|
||||
}
|
||||
else {
|
||||
status = PluginResult.Status.INVALID_ACTION;
|
||||
}
|
||||
return new PluginResult(status, result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user