Compare commits

...

39 Commits

Author SHA1 Message Date
Joe Bowser
f4da7e164d Incrementing project to 1.7.0rc1 2012-04-23 11:37:33 -07:00
macdonst
05192a91da Removing un-needed logs 2012-04-19 21:03:55 -04:00
Fil Maj
3835144b93 [CB-473] run ant clean before ant debug install 2012-04-19 17:25:19 -07:00
Joe Bowser
bdf452b02a Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android 2012-04-19 16:48:32 -07:00
Joe Bowser
bcc2957f20 Fix for CB-549 2012-04-19 16:45:15 -07:00
Fil Maj
81059b398f Proper fix for CB-164. Online/offline events now propagated to webview properly 2012-04-19 16:35:55 -07:00
Fil Maj
31d5a94ea9 [CB-164] Changed network plugin to sync from async and removed setKeepCallback(true) on plugin result in there. Fixes location.reload() not firing deviceready due to network plugin being unresponsive 2012-04-19 12:33:45 -07:00
Joe Bowser
1e5457a47d Reverting the back button change that I made, for some reason certain methods aren't inherited when you extend DroidGap 2012-04-19 12:22:33 -07:00
macdonst
7b75e2f1b0 CB-539: FileTransfer.download fails when target starts with 'file://' 2012-04-18 13:56:29 -04:00
Joe Bowser
180696baec Fixed back button behaviour. WIN 2012-04-17 17:50:07 -07:00
Joe Bowser
76820ebaff CB-480 work, back button and history issues are preventing this from being tested properly 2012-04-17 17:13:33 -07:00
Joe Bowser
c341cf0d47 Adding fix for CB-482 2012-04-17 12:20:23 -07:00
macdonst
f2c38ea0a7 Automatically update index.html in templates directory on version change 2012-04-13 16:36:46 -04:00
Joe Bowser
0772a315c4 CB-489 - Adding .js to the example, thought it was removed for a reason 2012-04-13 13:08:13 -07:00
macdonst
08d7a9c87a Remove duplicate files from repository
We should only have these files in one place in the repo. Changes have been made to the scripts to pick up the xml files from their proper location.
2012-04-13 15:35:49 -04:00
Joe Bowser
eb48055acd Getting setup to tag 1.6.1 2012-04-12 16:37:27 -07:00
Joe Bowser
e4a52de0a5 Copying new XML into the templates for 1.6.1. Turns out tags are broken 2012-04-12 14:33:29 -07:00
macdonst
ac06892dec CB-472: FileWriter.seek(0) does not actually seek to the beginning of the file 2012-04-11 10:44:09 -04:00
Joe Bowser
5e1997c8d8 Updating with tagged JS 2012-04-10 13:26:35 -07:00
Bryce Curtis
36e6b572b7 Update to version 1.6.0. 2012-04-10 09:01:37 -05:00
Joe Bowser
3bda8afdc1 Updating the sample index.html 2012-04-09 17:11:51 -07:00
Joe Bowser
cdf148bb58 Starting Release Process 2012-04-09 17:11:13 -07:00
Joe Bowser
b532cf8545 Fixing the template, since this doesn't have to be unit tested. :) 2012-04-09 13:43:36 -07:00
macdonst
ecebcbabf8 CB-446: Enhance setting data source for local files in AudioPlayer 2012-04-09 10:13:43 -04:00
macdonst
aa00e07b3c Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android 2012-04-05 19:52:36 -04:00
macdonst
cb473dfed4 CB-453: FileWriter.append - Chinese characters are not appended to the file correctly 2012-04-05 19:51:45 -04:00
Bryce Curtis
8b05ce41dd Update project template cordova.js reference and title. 2012-04-05 15:39:33 -05:00
macdonst
5d43835db8 CB-446: Enhance setting data source for local files in AudioPlayer 2012-04-05 13:43:00 -04:00
macdonst
838286df96 Return MediaError object and not error code from native side of Media API 2012-04-05 13:31:09 -04:00
macdonst
04aa6d3c38 CB-438: File metadata.modificationTime returns an invalid date 2012-04-04 13:03:39 -04:00
macdonst
e213772f98 Updating cordova.android.js for CB-421 and CB-426 2012-04-03 13:09:31 -04:00
macdonst
0577b4bf5d CB-426: camera.getPicture ignores mediaType in 1.5 2012-04-03 13:02:25 -04:00
Bryce Curtis
a37d0699db [CB-423] Problem displaying patch-9 splash screen. 2012-04-02 11:34:57 -05:00
macdonst
5fa77e97bd CB-163: contactFindOptions.filter does not work as expected on Android 2012-03-30 16:28:04 -04:00
macdonst
8d479c8269 Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android 2012-03-30 15:31:54 -04:00
macdonst
700ae50e9b CB-321: Media API: 'mediaSuccess' callback param to new Media() is called soon after new obj created 2012-03-30 15:29:26 -04:00
Bryce Curtis
900be3afe0 Tests to verify Android native features. 2012-03-30 11:37:29 -05:00
macdonst
d2b329636f Fixing license header in com.phonegap.api.PluginManager 2012-03-29 15:08:44 -04:00
Fil Maj
993fb296d6 updating network status plugin label and updating cordova-js to latest 2012-03-28 13:47:45 -07:00
82 changed files with 7786 additions and 423 deletions

View File

@@ -1 +1 @@
1.6.0rc1
1.7.0rc1

View File

@@ -34,6 +34,10 @@ cp ./framework/assets/www/cordova-$VERSION.js $PROJECT_PATH/.cordova/android/cor
# copy in cordova.jar
cp ./framework/cordova-$VERSION.jar $PROJECT_PATH/.cordova/android/cordova-$VERSION.jar
# copy in res/xml
cp ./framework/res/xml/cordova.xml $PROJECT_PATH/.cordova/android/cordova.xml
cp ./framework/res/xml/plugins.xml $PROJECT_PATH/.cordova/android/plugins.xml
# app properties
cat > $PROJECT_PATH/.cordova/config <<eom
VERSION=$VERSION

View File

@@ -25,6 +25,11 @@ cp ./.cordova/android/cordova-$VERSION.js ./assets/www
# copy in cordova.jar
cp ./.cordova/android/cordova-$VERSION.jar ./libs
# copy in res/xml
mkdir ./res/xml
cp ./.cordova/android/cordova.xml ./res/xml
cp ./.cordova/android/plugins.xml ./res/xml
# copy in default activity
cat ./cordova/templates/Activity.java > $ACTIVITY_PATH

View File

@@ -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

View File

@@ -2,13 +2,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="__PACKAGE__" android:versionName="1.1" android:versionCode="5">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
@@ -27,24 +27,17 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<activity android:name="__ACTIVITY__" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
</intent-filter>
android:debuggable="true">
<activity android:name="__ACTIVITY__" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
<uses-sdk android:minSdkVersion="5" />
</manifest>

View File

@@ -4,13 +4,13 @@
<meta name="viewport" content="width=320; user-scalable=no" />
<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.5.0.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="cordova-1.7.0rc1.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>Welcome to PhoneGap!</h1>
<h1>Welcome to Cordova!</h1>
<h2>this file is located at assets/www/index.html</h2>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
@@ -25,14 +25,14 @@
</dl>
<a href="#" class="btn large" onclick="toggleAccel();">Toggle Accelerometer</a>
<a href="#" class="btn large" onclick="getLocation();">Get Location</a>
<a href="tel:411" class="btn large">Call 411</a>
<a href="tel:411" class="btn large">Call 411</a>
<a href="#" class="btn large" onclick="beep();">Beep</a>
<a href="#" class="btn large" onclick="vibrate();">Vibrate</a>
<a href="#" class="btn large" onclick="show_pic();">Get a Picture</a>
<a href="#" class="btn large" onclick="get_contacts();return false;">Get Phone's Contacts</a>
<a href="#" class="btn large" onclick="check_network();return false;">Check Network</a>
<dl>
<dt>Compass Heading:</dt><dd id="h">Off</dd>
<dt>Compass Heading:</dt><dd id="h">Off</dd>
</dl>
<a href="#" class="btn large" onclick="toggleCompass();return false;">Toggle Compass</a>
<div id="viewport" class="viewport" style="display: none;">

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@
<html>
<head>
<title></title>
<script src="cordova-1.5.0.js"></script>
<script src="cordova-1.7.0rc1.js"></script>
</head>
<body>

View File

@@ -122,6 +122,7 @@
<!-- update project files to reference cordova-x.x.x.min.js -->
<replaceregexp match="cordova(.*)\.js" replace="cordova-${version}.js" byline="true">
<fileset file="assets/www/index.html" />
<fileset file="../bin/templates/project/cordova/templates/project/assets/www/index.html" />
</replaceregexp>
<!-- This is sketchy, but it works, ${dblQuote} does not -->

View File

@@ -27,7 +27,7 @@
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
<plugin name="File" value="org.apache.cordova.FileUtils"/>
<plugin name="Network Status" value="org.apache.cordova.NetworkManager"/>
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
<plugin name="Notification" value="org.apache.cordova.Notification"/>
<plugin name="Storage" value="org.apache.cordova.Storage"/>
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>

View File

@@ -1,4 +1,5 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file

View File

@@ -28,6 +28,7 @@ import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
/**
@@ -116,7 +117,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
public void startRecording(String file) {
if (this.mPlayer != null) {
Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
// Make sure we're not already recording
@@ -137,11 +138,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
} catch (IOException e) {
e.printStackTrace();
}
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
else {
Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
}
@@ -183,7 +184,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
public void startPlaying(String file) {
if (this.recorder != null) {
Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
// If this is a new request to play audio, or stopped
@@ -215,9 +216,16 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
android.content.res.AssetFileDescriptor fd = this.handler.ctx.getBaseContext().getAssets().openFd(f);
this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
}
else {
this.mPlayer.setDataSource("/sdcard/" + file);
}
else {
File fp = new File(file);
if (fp.exists()) {
FileInputStream fileInputStream = new FileInputStream(file);
this.mPlayer.setDataSource(fileInputStream.getFD());
}
else {
this.mPlayer.setDataSource("/sdcard/" + file);
}
}
this.setState(MEDIA_STARTING);
this.mPlayer.setOnPreparedListener(this);
this.mPlayer.prepare();
@@ -228,7 +236,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
}
catch (Exception e) {
e.printStackTrace();
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
}
@@ -242,7 +250,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
}
else {
Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state);
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
}
}
@@ -270,7 +278,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
}
else {
Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state);
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_NONE_ACTIVE+"});");
}
}
@@ -284,7 +292,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
}
else {
Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_NONE_ACTIVE+"});");
}
}
@@ -413,7 +421,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
this.mPlayer.release();
// Send error notification to JavaScript
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+arg1+");");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', { \"code\":"+arg1+"});");
return false;
}

View File

@@ -31,8 +31,6 @@ import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.ContentValues;
@@ -115,6 +113,7 @@ public class CameraLauncher extends Plugin {
this.targetWidth = args.getInt(3);
this.targetHeight = args.getInt(4);
this.encodingType = args.getInt(5);
this.mediaType = args.getInt(6);
if (srcType == CAMERA) {
this.takePicture(destType, encodingType);

View File

@@ -84,7 +84,8 @@ public abstract class ContactAccessor {
map.put("displayName", true);
}
else if (key.startsWith("name")) {
map.put("name", true);
map.put("displayName", true);
map.put("name", true);
}
else if (key.startsWith("nickname")) {
map.put("nickname", true);

View File

@@ -216,6 +216,9 @@ public class CordovaChromeClient extends WebChromeClient {
// Cordova JS has initialized, so show webview
// (This solves white flash seen when rendering HTML)
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
if (ctx.splashscreen != 0) {
ctx.root.setBackgroundResource(0);
}
ctx.appView.setVisibility(View.VISIBLE);
ctx.spinnerStop();
result.confirm("OK");

View File

@@ -229,6 +229,9 @@ public class CordovaWebViewClient extends WebViewClient {
Thread.sleep(2000);
ctx.runOnUiThread(new Runnable() {
public void run() {
if (ctx.splashscreen != 0) {
ctx.root.setBackgroundResource(0);
}
ctx.appView.setVisibility(View.VISIBLE);
ctx.spinnerStop();
}

View File

@@ -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.0rc1"; // Cordova version
public static String cordovaVersion = "1.7.0rc1"; // Cordova version
public static String platform = "Android"; // Device OS
public static String uuid; // Device UUID

View File

@@ -48,6 +48,7 @@ import android.graphics.Color;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Menu;
@@ -1072,7 +1073,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 +1086,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;

View File

@@ -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);
}
}
}

View File

@@ -142,8 +142,7 @@ public class FileUtils extends Plugin {
return new PluginResult(status, obj);
}
else if (action.equals("getMetadata")) {
JSONObject obj = getMetadata(args.getString(0));
return new PluginResult(status, obj);
return new PluginResult(status, getMetadata(args.getString(0)));
}
else if (action.equals("getFileMetadata")) {
JSONObject obj = getFileMetadata(args.getString(0));
@@ -764,21 +763,17 @@ public class FileUtils extends Plugin {
* Look up metadata about this entry.
*
* @param filePath to entry
* @return a Metadata object
* @return a long
* @throws FileNotFoundException
* @throws JSONException
*/
private JSONObject getMetadata(String filePath) throws FileNotFoundException, JSONException {
private long getMetadata(String filePath) throws FileNotFoundException {
File file = createFileObject(filePath);
if (!file.exists()) {
throw new FileNotFoundException("Failed to find file in getMetadata");
}
JSONObject metadata = new JSONObject();
metadata.put("modificationTime", file.lastModified());
return metadata;
return file.lastModified();
}
/**
@@ -978,23 +973,23 @@ public class FileUtils extends Plugin {
/**/
public long write(String filename, String data, int offset) throws FileNotFoundException, IOException {
filename = stripFileProtocol(filename);
boolean append = false;
if (offset > 0) {
this.truncateFile(filename, offset);
append = true;
}
byte [] rawData = data.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(rawData);
FileOutputStream out = new FileOutputStream(filename, append);
byte buff[] = new byte[rawData.length];
in.read(buff, 0, buff.length);
out.write(buff, 0, rawData.length);
out.flush();
out.close();
byte [] rawData = data.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(rawData);
FileOutputStream out = new FileOutputStream(filename, append);
byte buff[] = new byte[rawData.length];
in.read(buff, 0, buff.length);
out.write(buff, 0, rawData.length);
out.flush();
out.close();
return data.length();
return rawData.length;
}
/**

View File

@@ -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;

View File

@@ -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();

42
releasenotes.md Normal file
View File

@@ -0,0 +1,42 @@
Bryce Curtis (5):
[CB-352] Support initializing DroidGap with existing WebView, WebViewClient and webViewChrome. [CB-353] Create PluginEntry object to use by PluginManager.
[CB-367] Back button event should fire on key up not key down Also changed menu key and search key to be consistent.
Tests to verify Android native features.
[CB-423] Problem displaying patch-9 splash screen.
Update project template cordova.js reference and title.
Fil Maj (6):
switched from "require" syntax to "cordova.require"
cordova.require("cordova") is pretty funny. wish i didnt write it
updates to JS: removing require+define from global scope, tweaking geolocation code, online/offline events fire on document now
removed old javascript files and removed unused target + commented out lines in build.xml
spacing fixes, null check in getPhoneType in contacts, returning error integers instead of objects in contacts
updating network status plugin label and updating cordova-js to latest
Joe Bowser (11):
We show the default 404 on non-resolved domains
Fixing CB-210 with patch and adding fix for CB-210
Tweaked File Transfer to fix CB-74
Changing to the modern icon
Added temporary Cordova splash for now
Checking for the callback server before we call sendJavascript for the Kindle Fire, CB-247
Fixing CB-343: We need to respect the whitelist
Fixing a bug with File Upload on Android where Chunked mode isn't used by default
First stab at CB-21, I really need more info before I can close this
Tagged 1.6rc1
Fixing the template, since this doesn't have to be unit tested. :)
macdonst (12):
CB-383: Fixes issue with misspelled destinationType for Camera.getPicture()
Fix for CB-389: resolveLocalFileSystemURI does not work on a resized image captured from Camera.getPicture()
Fixing license header in com.phonegap.api.PluginManager
CB-321: Media API: 'mediaSuccess' callback param to new Media() is called soon after new obj created
CB-163: contactFindOptions.filter does not work as expected on Android
CB-426: camera.getPicture ignores mediaType in 1.5
Updating cordova.android.js for CB-421 and CB-426
CB-438: File metadata.modificationTime returns an invalid date
Return MediaError object and not error code from native side of Media API
CB-446: Enhance setting data source for local files in AudioPlayer
CB-453: FileWriter.append - Chinese characters are not appended to the file correctly
CB-446: Enhance setting data source for local files in AudioPlayer

8
test/.classpath Executable file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

33
test/.project Executable file
View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CordovaTest</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

87
test/AndroidManifest.xml Executable file
View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="org.apache.cordova.test" android:versionName="1.1" android:versionCode="5">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<activity android:name="tests" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="splashscreen" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="timeout" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="htmlnotfound" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="errorurl" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="userwebview" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="menus" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="loading" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="lifecycle" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="jqmtabbackbutton" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="backbuttonmultipage" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="whitelist" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="background" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="iframe" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name="xhr" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
</manifest>

23
test/README.md Executable file
View File

@@ -0,0 +1,23 @@
## Android Native Tests ##
These tests are designed to verify Android native features and other Android specific features.
Before running the tests, they need to be set up.
1. Copy the version of cordova-x.y.z.js into assets/www directory
2. Edit assets/www/cordova.js to reference the correct version
3. Copy cordova-x.y.z.jar into libs directory
To run from command line:
4. Build by entering "ant debug install"
5. Run tests by clicking on "CordovaTest" icon on device
To run from Eclipse:
4. Import Android project into Eclipse
5. Ensure Project properties "Java Build Path" includes the lib/cordova-x.y.z.jar
6. Create run configuration if not already created
7. Run tests

17
test/ant.properties Executable file
View File

@@ -0,0 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@@ -0,0 +1,23 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backbutton</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>Page 1</h4>
Go to next page.<br>
If returning from previous page, press "backbutton". You should exit this app.
</div>
<a href="sample2.html" class="btn large">Next page</a>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backbutton</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>Page 2</h4>
Go to next page.<br>
If returning from previous page, press "backbutton". You should go to Page 1.
</div>
<a href="sample3.html" class="btn large">Next page</a>
</body>
</html>

View File

@@ -0,0 +1,26 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backbutton</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>Page 3</h4>
Press the 3 buttons below. You should stay on same page.<br>
Press "backbutton" 4 times. This will go back to #test3, #test2, #test1, then return to previous Page 2.<br>
(NOTE: IS THIS CORRECT BEHAVIOR?)
</div>
<a href="sample3.html#test1" class="btn large">page3#test1</a>
<a href="sample3.html#test2" class="btn large">page3#test2</a>
<a href="sample3.html#test3" class="btn large">page3#test3</a>
</body>
</html>

View File

@@ -0,0 +1,99 @@
<!DOCTYPE HTML>
<html>
<head>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Background Page 1</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad() {
console.log("Page1: onload");
log("Page1: onload @ " + new Date().toLocaleTimeString());
document.addEventListener("deviceready", onDeviceReady, false);
}
function onUnLoaded() {
console.log("Page1: onunload");
log("Page1: onunload @ " + new Date().toLocaleTimeString());
}
function onDeviceReady() {
// Register the event listener
document.getElementById("platform").innerHTML = device.platform;
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
document.getElementById("name").innerHTML = device.name;
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
window.setInterval(function() {
log("Page1: Running");
}, 2000);
}
function onPause() {
console.log("Page1: onpause");
log("Page1: onpause @ " + new Date().toLocaleTimeString());
}
function onResume() {
console.log("Page1: onresume");
log("Page1: onresume @ " + new Date().toLocaleTimeString());
}
function log(s) {
var el = document.getElementById('status');
var status = el.innerHTML + s + "<br>";
el.innerHTML = status;
localStorage.backgroundstatus = status;
}
function clearStatus() {
console.log("clear()");
localStorage.backgroundstatus = "";
document.getElementById('status').innerHTML = "";
}
</script>
</head>
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
</div>
<div id="info">
Press "Home" button, then return to this app to see pause/resume.<br>
There shouldn't be any "Running" entries between pause and resume.<br>
</div>
<div id="info">
<h4>Info for event testing:</h4>
<div id="status"></div>
</div>
<!-- a href="index2.html" class="btn large" >Load new page</a -->
<a href="javascript:" class="btn large" onclick="clearStatus();">Clear status</a>
<script>
document.getElementById('status').innerHTML = localStorage.backgroundstatus;
</script>
</body>
</html>

View File

@@ -0,0 +1,98 @@
<!DOCTYPE HTML>
<html>
<head>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Background Page 2</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad() {
console.log("Page2: onload");
log("Page2: onload @ " + new Date().toLocaleTimeString());
document.addEventListener("deviceready", onDeviceReady, false);
}
function onUnLoaded() {
console.log("Page2: onunload");
log("Page2: onunload @ " + new Date().toLocaleTimeString());
}
function onDeviceReady() {
// Register the event listener
document.getElementById("platform").innerHTML = device.platform;
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
document.getElementById("name").innerHTML = device.name;
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
window.setInterval(function() {
log("Page2: Running");
}, 2000);
}
function onPause() {
console.log("Page2: onpause");
log("Page2: onpause @ " + new Date().toLocaleTimeString());
}
function onResume() {
console.log("Page2: onresume");
log("Page2: onresume @ " + new Date().toLocaleTimeString());
}
function log(s) {
var el = document.getElementById('status');
var status = el.innerHTML + s + "<br>";
el.innerHTML = status;
localStorage.backgroundstatus = status;
}
function clearStatus() {
console.log("clear()");
localStorage.backgroundstatus = "";
document.getElementById('status').innerHTML = "";
}
</script>
</head>
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
</div>
<div id="info">
<h4>Press "Back" button to return to Page 1.</h4>
</div>
<div id="info">
<h4>Info for event testing:</h4>
<div id="status"></div>
</div>
<a href="index.html" class="btn large" >Load new page</a>
<a href="javascript:" class="btn large" onclick="clearStatus();">Clear status</a>
<script>
document.getElementById('status').innerHTML = localStorage.backgroundstatus;
</script>
</body>
</html>

4985
test/assets/www/cordova-1.6.0.js vendored Executable file

File diff suppressed because it is too large Load Diff

2
test/assets/www/cordova.js vendored Executable file
View File

@@ -0,0 +1,2 @@
document.write('<script type="text/javascript" charset="utf-8" src="../cordova-1.6.0.js"></script>');
document.write('<script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>');

View File

@@ -0,0 +1 @@
This is an error page.

View File

@@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
<script>
function loadUrl(url) {
document.getElementById('iframe').src = url;
}</script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>IFrame</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
Press the two buttons:<br>
1. Google Maps should display in iframe.<br>
2. Page 2 replaces current page.<br>
(NOTE: THIS BEHAVIOR IS WRONG - AND NEEDS TO BE FIXED IN FUTURE RELEASE.)
</div>
<iframe id="iframe" src="" width="90%" height="200px"></iframe>
<a href="javascript:" class="btn large" onclick="loadUrl('http://maps.google.com/maps?output=embed');">Google Maps</a>
<a href="javascript:" class="btn large" onclick="loadUrl('index2.html');">Page 2</a>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>IFrame window</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
This should display a Cordova page inside an iframe. The info above should be filled out.
(NOTE: THIS DOES NOT WORK AND NEEDS TO BE FIXED IN FUTURE RELEASE.)
</div>
</body>
</html>

47
test/assets/www/index.html Executable file
View File

@@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
<script>
function startActivity(className) {
cordova.exec(function() {console.log("Success");}, function(e) {console.log("Error: "+e);}, "Activity", "start", [className]);
};
localStorage.lifecyclestatus = "";
localStorage.backgroundstatus = "";
</script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
<h4>Cordova Version: <span id="cordova">&nbsp;</span></h4>
</div>
<div id="info">
<h4>Run each of the tests below:</h4>
</div>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.jqmtabbackbutton');">Backbutton jQM tab</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.backbuttonmultipage');">Backbutton with multiple pages</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.errorurl');">Error URL</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.htmlnotfound');">HTML not found</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.iframe');">IFrame</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.lifecycle');">Lifecycle</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.loading');">Loading indicator</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.menus');">Menus</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.background');">No multitasking</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.splashscreen');">Splash screen</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.timeout');">Load timeout</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.userwebview');">User WebView/Client/Chrome</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.whitelist');">Whitelist</button>
<button class="btn large" onclick="startActivity('org.apache.cordova.test.xhr');">XHR</button>
</body>
</html>

View File

@@ -0,0 +1,49 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backbutton</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type="text/javascript" src="../cordova.js"></script>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
// Without backbutton handler, each tab loaded will be popped off history until history is empty, then it will exit app.
function handleBackButton() {
alert("Back Button Pressed! - exiting app");
navigator.app.exitApp();
}
function onDeviceReady() {
console.log("onDeviceReady()");
document.addEventListener("backbutton", handleBackButton, false);
}
</script>
</head>
<body>
<div data-role="page" id="tabTab">
<div data-role="header">
<h1>Main</h1>
</div>
<div data-role="content" id="tabContent">
To test, press several tabs.<br>
The "backbutton" can be pressed any time to exit app.
</div>
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="tab1.html" data-transition="none">Tab 1</a>
</li>
<li><a href="tab2.html" data-transition="none">Tab 2</a>
</li>
<li><a href="tab3.html" data-transition="none">Tab 3</a>
</li>
</ul>
</div>
</div>
</div>

View File

@@ -0,0 +1,29 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tab 1</title>
</head>
<body>
<div data-role="page" id="tab1Tab">
<div data-role="header">
<h1>Tab 1</h1>
</div>
<div data-role="content" id="tab1Content">
Tab 1 content.
</div>
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="tab1.html" data-transition="none">Tab 1</a>
</li>
<li><a href="tab2.html" data-transition="none">Tab 2</a>
</li>
<li><a href="tab3.html" data-transition="none">Tab 3</a>
</li>
</ul>
</div>
<!-- /navbar -->
</div>
<!-- /footer -->
</div>

View File

@@ -0,0 +1,30 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tab 2</title>
</head>
<body>
<div data-role="page" id="tab2Tab">
<div data-role="header">
<h1>Tab 2</h1>
</div>
<div data-role="content" id="tab2Content">
Tab 2 content.
</div>
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="tab1.html" data-transition="none">Tab 1</a>
</li>
<li><a href="tab2.html" data-transition="none">Tab 2</a>
</li>
<li><a href="tab3.html" data-transition="none">Tab 3</a>
</li>
</ul>
</div>
<!-- /navbar -->
</div>
<!-- /footer -->
</div>

View File

@@ -0,0 +1,30 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tab 3</title>
</head>
<body>
<div data-role="page" id="tab3Tab">
<div data-role="header">
<h1>Tab 3</h1>
</div>
<div data-role="content" id="tab3Content">
Tab 3 content.
</div>
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="tab1.html" data-transition="none">Tab 1</a>
</li>
<li><a href="tab2.html" data-transition="none">Tab 2</a>
</li>
<li><a href="tab3.html" data-transition="none">Tab 3</a>
</li>
</ul>
</div>
<!-- /navbar -->
</div>
<!-- /footer -->
</div>

View File

@@ -0,0 +1,108 @@
<!DOCTYPE HTML>
<html>
<head>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Lifecycle Page 1</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad() {
console.log("Page1: onload");
log("Page1: onload @ " + new Date().toLocaleTimeString());
document.addEventListener("deviceready", onDeviceReady, false);
}
function onUnLoaded() {
console.log("Page1: onunload");
log("Page1: onunload @ " + new Date().toLocaleTimeString());
}
function onDeviceReady() {
// Register the event listener
document.getElementById("platform").innerHTML = device.platform;
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
document.getElementById("name").innerHTML = device.name;
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
window.setInterval(function() {
log("Page1: Running");
}, 2000);
}
function onPause() {
console.log("Page1: onpause");
log("Page1: onpause @ " + new Date().toLocaleTimeString());
}
function onResume() {
console.log("Page1: onresume");
log("Page1: onresume @ " + new Date().toLocaleTimeString());
}
function log(s) {
var el = document.getElementById('status');
var status = el.innerHTML + s + "<br>";
el.innerHTML = status;
localStorage.lifecyclestatus = status;
}
function clearStatus() {
console.log("clear()");
localStorage.lifecyclestatus = "";
document.getElementById('status').innerHTML = "";
}
</script>
</head>
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
</div>
<div id="info">
<h4>Test 1</h4>
Press "Home" button, then return to this app to see pause/resume.<br>
There should be "Running" entries between pause and resume since app continues to run in the background.
<h4>Test 2</h4>
Press "Load new page" button to load a new Cordova page.<br>
When returning, you should see
<ul>
<li>Page2: onunload</li>
<li>Page1: onload</li>
<li>Page1: Running</li>
</ul>
</div>
<div id="info">
<h4>Info for event testing:</h4>
<div id="status"></div>
</div>
<a href="index2.html" class="btn large" >Load new page</a>
<a href="javascript:" class="btn large" onclick="clearStatus();">Clear status</a>
<script>
document.getElementById('status').innerHTML = localStorage.lifecyclestatus;
</script>
</body>
</html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE HTML>
<html>
<head>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Lifecycle Page 2</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad() {
console.log("Page2: onload");
log("Page2: onload @ " + new Date().toLocaleTimeString());
document.addEventListener("deviceready", onDeviceReady, false);
}
function onUnLoaded() {
console.log("Page2: onunload");
log("Page2: onunload @ " + new Date().toLocaleTimeString());
}
function onDeviceReady() {
// Register the event listener
document.getElementById("platform").innerHTML = device.platform;
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
document.getElementById("name").innerHTML = device.name;
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
window.setInterval(function() {
log("Page2: Running");
}, 2000);
}
function onPause() {
console.log("Page2: onpause");
log("Page2: onpause @ " + new Date().toLocaleTimeString());
}
function onResume() {
console.log("Page2: onresume");
log("Page2: onresume @ " + new Date().toLocaleTimeString());
}
function log(s) {
var el = document.getElementById('status');
var status = el.innerHTML + s + "<br>";
el.innerHTML = status;
localStorage.lifecyclestatus = status;
}
function clearStatus() {
console.log("clear()");
localStorage.lifecyclestatus = "";
document.getElementById('status').innerHTML = "";
}
</script>
</head>
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
</div>
<div id="info">
You should see<br>
<ul>
<li>Page1: onunload</li>
<li>Page2: onload</li>
<li>Page2: Running</li>
</ul>
Press "backbutton" to return to Page 1.
</div>
<div id="info">
<h4>Info for event testing:</h4>
<div id="status"></div>
</div>
<a href="index.html" class="btn large" >Load new page</a>
<a href="javascript:" class="btn large" onclick="clearStatus();">Clear status</a>
<script>
document.getElementById('status').innerHTML = localStorage.lifecyclestatus;
</script>
</body>
</html>

150
test/assets/www/main.js Executable file
View File

@@ -0,0 +1,150 @@
var deviceInfo = function() {
document.getElementById("platform").innerHTML = device.platform;
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
document.getElementById("name").innerHTML = device.name;
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
var el = document.getElementById("cordova");
if (el) {
el.innerHTML = device.cordova;
}
};
var getLocation = function() {
var suc = function(p) {
alert(p.coords.latitude + " " + p.coords.longitude);
};
var locFail = function() {
};
navigator.geolocation.getCurrentPosition(suc, locFail);
};
var beep = function() {
navigator.notification.beep(2);
};
var vibrate = function() {
navigator.notification.vibrate(0);
};
function roundNumber(num) {
var dec = 3;
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
}
var accelerationWatch = null;
function updateAcceleration(a) {
document.getElementById('x').innerHTML = roundNumber(a.x);
document.getElementById('y').innerHTML = roundNumber(a.y);
document.getElementById('z').innerHTML = roundNumber(a.z);
}
var toggleAccel = function() {
if (accelerationWatch !== null) {
navigator.accelerometer.clearWatch(accelerationWatch);
updateAcceleration({
x : "",
y : "",
z : ""
});
accelerationWatch = null;
} else {
var options = {};
options.frequency = 1000;
accelerationWatch = navigator.accelerometer.watchAcceleration(
updateAcceleration, function(ex) {
alert("accel fail (" + ex.name + ": " + ex.message + ")");
}, options);
}
};
var preventBehavior = function(e) {
e.preventDefault();
};
function dump_pic(data) {
var viewport = document.getElementById('viewport');
console.log(data);
viewport.style.display = "";
viewport.style.position = "absolute";
viewport.style.top = "10px";
viewport.style.left = "10px";
document.getElementById("test_img").src = "data:image/jpeg;base64," + data;
}
function fail(msg) {
alert(msg);
}
function show_pic() {
navigator.camera.getPicture(dump_pic, fail, {
quality : 50
});
}
function close() {
var viewport = document.getElementById('viewport');
viewport.style.position = "relative";
viewport.style.display = "none";
}
function contacts_success(contacts) {
alert(contacts.length
+ ' contacts returned.'
+ (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
: ''));
}
function get_contacts() {
var obj = new ContactFindOptions();
obj.filter = "";
obj.multiple = true;
navigator.contacts.find(
[ "displayName", "name" ], contacts_success,
fail, obj);
}
function check_network() {
var networkState = navigator.network.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.NONE] = 'No network connection';
confirm('Connection type:\n ' + states[networkState]);
}
var watchID = null;
function updateHeading(h) {
document.getElementById('h').innerHTML = h.magneticHeading;
}
function toggleCompass() {
if (watchID !== null) {
navigator.compass.clearWatch(watchID);
watchID = null;
updateHeading({ magneticHeading : "Off"});
} else {
var options = { frequency: 1000 };
watchID = navigator.compass.watchHeading(updateHeading, function(e) {
alert('Compass Error: ' + e.code);
}, options);
}
}
function init() {
// the next line makes it impossible to see Contacts on the HTC Evo since it
// doesn't have a scroll button
// document.addEventListener("touchmove", preventBehavior, false);
document.addEventListener("deviceready", deviceInfo, true);
}

117
test/assets/www/master.css Executable file
View File

@@ -0,0 +1,117 @@
body {
background:#222 none repeat scroll 0 0;
color:#666;
font-family:Helvetica;
font-size:72%;
line-height:1.5em;
margin:0;
border-top:1px solid #393939;
}
#info{
background:#ffa;
border: 1px solid #ffd324;
-webkit-border-radius: 5px;
border-radius: 5px;
clear:both;
margin:15px 6px 0;
width:295px;
padding:4px 0px 2px 10px;
}
#info > h4{
font-size:.95em;
margin:5px 0;
}
#stage.theme{
padding-top:3px;
}
/* Definition List */
#stage.theme > dl{
padding-top:10px;
clear:both;
margin:0;
list-style-type:none;
padding-left:10px;
overflow:auto;
}
#stage.theme > dl > dt{
font-weight:bold;
float:left;
margin-left:5px;
}
#stage.theme > dl > dd{
width:45px;
float:left;
color:#a87;
font-weight:bold;
}
/* Content Styling */
#stage.theme > h1, #stage.theme > h2, #stage.theme > p{
margin:1em 0 .5em 13px;
}
#stage.theme > h1{
color:#eee;
font-size:1.6em;
text-align:center;
margin:0;
margin-top:15px;
padding:0;
}
#stage.theme > h2{
clear:both;
margin:0;
padding:3px;
font-size:1em;
text-align:center;
}
/* Stage Buttons */
#stage.theme a.btn{
border: 1px solid #555;
-webkit-border-radius: 5px;
border-radius: 5px;
text-align:center;
display:block;
float:left;
background:#444;
width:150px;
color:#9ab;
font-size:1.1em;
text-decoration:none;
padding:1.2em 0;
margin:3px 0px 3px 5px;
}
#stage.theme a.btn.large{
width:308px;
padding:1.2em 0;
}
/* Stage Buttons */
#stage.theme button.btn{
border: 1px solid #555;
-webkit-border-radius: 5px;
border-radius: 5px;
text-align:center;
display:block;
float:left;
background:#444;
width:150px;
color:#9ab;
font-size:1.1em;
text-decoration:none;
padding:1.2em 0;
margin:3px 0px 3px 5px;
}
#stage.theme button.btn.large{
width:308px;
padding:1.2em 0;
}

View File

@@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>Menu Test</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>The menu items should be:</h4>
<li>Item1<br>
<li>Item2<br>
<li>Item3<br>
<h4>There is also a context menu. Touch and hold finger here to see:</h4>
<li>Context Item1<br>
</div>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>Splash Screen Test</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
You should have seen the splash screen for 2 seconds.</div>
</body>
</html>

View File

@@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>User WebView/Client/Chrome Test</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>The following should be seen in LogCat:</h4>
<li>userwebview: TestViewClient()<br>
<li>userwebview: TestChromeClient()<br>
<li>userwebview: onGeolocationPermissionsShowPrompt(file://)<br>
<li>userwebview: shouldOverrideUrlLoading(test://this_will_call_shouldOverrideUrlLoading)<br>
</div>
<script>
/**
* Get current location
*/
console.log("getLocation()");
// Success callback
var success = function(p){
console.log("Location = "+p.coords.latitude+","+p.coords.longitude);
window.location = "test://this_will_call_shouldOverrideUrlLoading";
};
// Fail callback
var fail = function(e){
console.log("Error: "+e.code);
};
// Get location
navigator.geolocation.getCurrentPosition(success, fail, {enableHighAccuracy: true});
</script>
</body>
</html>

View File

@@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>Whitelist Page 1</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
Loading Page 2 should be successful.<br>
Loading Page 3 should be in web browser.<br>
Loading Page 2 with target=_blank should be in web browser? <br>
(THIS DOESN'T HAPPEN.) https://issues.apache.org/jira/browse/CB-362
</div>
<a href="index2.html" class="btn large">Page 2</a>
<a href="http://www.google.com" class="btn large">Page 3</a>
<a href="index2.html" class="btn large" target="_blank">Page 2 with target=_blank</a>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>Whitelist Page 2</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
Press "backbutton"
</div>
</body>
</html>

48
test/assets/www/xhr/index.html Executable file
View File

@@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
<script>
function XHR(url) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState === 4){
// If success
if (xmlhttp.status === 200) {
alert("XHR success. Result="+xmlhttp.responseText);
}
// If error
else {
alert("XHR error. Status="+xmlhttp.status);
}
}
};
console.log("GET "+url);
xmlhttp.open("GET", url , true);
xmlhttp.send();
}
</script>
</head>
<body onload="init();" id="stage" class="theme">
<h1>XHR</h1>
<div id="info">
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
Press buttons below to test. You should see an alert with results displayed.
</div>
<a href="javascript:" class="btn large" onclick="XHR('file:///android_asset/www/xhr/index.html')">Load file://</a>
<a href="javascript:" class="btn large" onclick="XHR('http://www.google.com');">Load Google</a>
<!--
<a href="javascript:" class="btn large" onclick="XHR('content://com.android.contacts/data/1');">Load content://</a>
-->
</body>
</html>

85
test/build.xml Executable file
View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="tests" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

BIN
test/libs/cordova-1.6.0.jar Executable file

Binary file not shown.

11
test/project.properties Executable file
View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=Google Inc.:Google APIs:14

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
test/res/drawable/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
test/res/drawable/sandy.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

13
test/res/layout/main.xml Executable file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, tests"
/>
</LinearLayout>

4
test/res/values/strings.xml Executable file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">CordovaTests</string>
</resources>

View File

@@ -9,7 +9,7 @@
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
<plugin name="File" value="org.apache.cordova.FileUtils"/>
<plugin name="Network Status" value="org.apache.cordova.NetworkManager"/>
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
<plugin name="Notification" value="org.apache.cordova.Notification"/>
<plugin name="Storage" value="org.apache.cordova.Storage"/>
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>

View File

@@ -0,0 +1,81 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import org.apache.cordova.api.LOG;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Intent;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
/**
* This class provides a service.
*/
public class ActivityPlugin extends Plugin {
static String TAG = "ActivityPlugin";
/**
* Constructor.
*/
public ActivityPlugin() {
}
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
PluginResult.Status status = PluginResult.Status.OK;
String result = "";
try {
if (action.equals("start")) {
this.startActivity(args.getString(0));
}
return new PluginResult(status, result);
} catch (JSONException e) {
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}
// --------------------------------------------------------------------------
// LOCAL METHODS
// --------------------------------------------------------------------------
public void startActivity(String className) {
try {
Intent intent = new Intent().setClass(this.ctx.getContext(), Class.forName(className));
LOG.d(TAG, "Starting activity %s", className);
this.ctx.startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
LOG.e(TAG, "Error starting activity %s", className);
}
}
}

View File

@@ -0,0 +1,43 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.content.Context;
import android.webkit.WebView;
public class FixWebView extends WebView {
public FixWebView(Context context) {
super(context);
}
@Override
public void pauseTimers() {
// Do nothing
}
/**
* This method is with different signature in order to stop the timers while move application to background
* @param realPause
*/
public void pauseTimers(@SuppressWarnings("unused") boolean realPause) {
super.pauseTimers();
}
}

View File

@@ -0,0 +1,30 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class backbuttonmultipage extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/backbuttonmultipage/index.html");
}
}

View File

@@ -0,0 +1,34 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import android.webkit.WebView;
import org.apache.cordova.*;
public class background extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//super.init(new FixWebView(this), new CordovaWebViewClient(this), new CordovaChromeClient(this));
super.setBooleanProperty("keepRunning", false);
super.loadUrl("file:///android_asset/www/background/index.html");
}
}

View File

@@ -0,0 +1,32 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class errorurl extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
this.setStringProperty("errorUrl", "file:///android_asset/www/htmlnotfound/error.html");
super.loadUrl("file:///android_asset/www/htmlnotfound/index.html");
}
}

View File

@@ -0,0 +1,31 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class htmlnotfound extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
super.loadUrl("file:///android_asset/www/htmlnotfound/index.html");
}
}

View File

@@ -0,0 +1,30 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class iframe extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/iframe/index.html");
}
}

View File

@@ -0,0 +1,30 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class jqmtabbackbutton extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/jqmtabbackbutton/index.html");
}
}

View File

@@ -0,0 +1,30 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class lifecycle extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/lifecycle/index.html");
}
}

View File

@@ -0,0 +1,31 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class loading extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setStringProperty("loadingDialog", "Testing,Loading...");
super.loadUrl("http://www.google.com");
}
}

View File

@@ -0,0 +1,80 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import org.apache.cordova.*;
import org.apache.cordova.api.LOG;
public class menus extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
super.registerForContextMenu(super.appView);
super.loadUrl("file:///android_asset/www/menus/index.html");
}
// Demonstrate how to add your own menus to app
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
int base = Menu.FIRST;
// Group, item id, order, title
menu.add(base, base, base, "Item1");
menu.add(base, base + 1, base + 1, "Item2");
menu.add(base, base + 2, base + 2, "Item3");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
LOG.d("menus", "Item " + item.getItemId() + " pressed.");
this.appView.loadUrl("javascript:alert('Menu " + item.getItemId() + " pressed.')");
return super.onOptionsItemSelected(item);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
LOG.d("menus", "onPrepareOptionsMenu()");
// this.appView.loadUrl("javascript:alert('onPrepareOptionsMenu()')");
return true;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
LOG.d("menus", "onCreateContextMenu()");
menu.setHeaderTitle("Test Context Menu");
menu.add(200, 200, 200, "Context Item1");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')");
return true;
}
}

View File

@@ -0,0 +1,35 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class splashscreen extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
// Show splashscreen
this.setIntegerProperty("splashscreen", R.drawable.sandy);
super.loadUrl("file:///android_asset/www/splashscreen/index.html", 2000);
}
}

View File

@@ -0,0 +1,32 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class tests extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
super.pluginManager.addService("Activity", "org.apache.cordova.test.ActivityPlugin");
super.loadUrl("file:///android_asset/www/index.html");
}
}

View File

@@ -0,0 +1,34 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class timeout extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
// Short timeout to cause error
this.setIntegerProperty("loadUrlTimeoutValue", 10);
super.loadUrl("http://www.google.com");
}
}

View File

@@ -0,0 +1,72 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.GeolocationPermissions.Callback;
import org.apache.cordova.*;
import org.apache.cordova.api.LOG;
public class userwebview extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init(new WebView(this), new TestViewClient(this), new TestChromeClient(this));
super.loadUrl("file:///android_asset/www/userwebview/index.html");
}
public class TestChromeClient extends CordovaChromeClient {
public TestChromeClient(DroidGap arg0) {
super(arg0);
LOG.d("userwebview", "TestChromeClient()");
}
@Override
public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
LOG.d("userwebview", "onGeolocationPermissionsShowPrompt(" + origin + ")");
super.onGeolocationPermissionsShowPrompt(origin, callback);
callback.invoke(origin, true, false);
}
}
/**
* This class can be used to override the GapViewClient and receive notification of webview events.
*/
public class TestViewClient extends CordovaWebViewClient {
public TestViewClient(DroidGap arg0) {
super(arg0);
LOG.d("userwebview", "TestViewClient()");
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LOG.d("userwebview", "shouldOverrideUrlLoading(" + url + ")");
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
LOG.d("userwebview", "onReceivedError: Error code=" + errorCode + " Description=" + description + " URL=" + failingUrl);
super.onReceivedError(view, errorCode, description, failingUrl);
}
}
}

View File

@@ -0,0 +1,51 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import android.webkit.WebView;
import org.apache.cordova.*;
import org.apache.cordova.api.LOG;
public class whitelist extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init(new WebView(this), new TestViewClient(this), new CordovaChromeClient(this));
super.loadUrl("file:///android_asset/www/whitelist/index.html");
}
/**
* This class can be used to override the GapViewClient and receive notification of webview events.
*/
public class TestViewClient extends CordovaWebViewClient {
public TestViewClient(DroidGap arg0) {
super(arg0);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LOG.d("whitelist", "shouldOverrideUrlLoading(" + url + ")");
LOG.d("whitelist", "originalUrl=" + view.getOriginalUrl());
return super.shouldOverrideUrlLoading(view, url);
}
}
}

View File

@@ -0,0 +1,30 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
public class xhr extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/xhr/index.html");
}
}