Compare commits

..

16 Commits
2.9.0 ... 2.8.0

Author SHA1 Message Date
Joe Bowser
b2b1ae2b33 CB-3584: Something went weird in the repo. This time for real. 2013-06-04 13:59:48 -07:00
Joe Bowser
fbd6b559d4 Merge branch '2.8.x' of https://git-wip-us.apache.org/repos/asf/cordova-android into 2.8.x 2013-05-29 10:46:00 -04:00
Andrew Grieve
89002514f5 [CB-3340] Add copying of the version script to bin/create
(cherry picked from commit 0e572aea36)
2013-05-29 10:24:03 -04:00
Andrew Grieve
a96d340b12 [CB-3468] Add missing license headers found by RAT
(cherry picked from commit 420cee4ee6)
2013-05-28 16:45:13 -04:00
Andrew Grieve
a044e88a1a Revert "Added "DataResource" - allows many plugins to intercept a single request"
This reverts commit 62c3e46529.
Reverting all DataResource changes for the 2.8.0 release.
2013-05-27 22:22:18 -04:00
Andrew Grieve
56587bfb46 Revert "Changed all usages of FileHelper to use the new DataResource mechanism."
This reverts commit 867358ea81.
Reverting all DataResource changes for the 2.8.0 release.
2013-05-27 22:22:16 -04:00
Andrew Grieve
0264019c87 Revert "DataRequest code cleaned up."
This reverts commit a001d8cfb7.
Reverting all DataResource changes for the 2.8.0 release.
2013-05-27 22:22:14 -04:00
Andrew Grieve
fbeba54740 Revert "DataResource bugfix WebviewClient logs error for http urls."
This reverts commit 8f91ebf194.
Reverting all DataResource changes for the 2.8.0 release.
2013-05-27 22:21:50 -04:00
Andrew Grieve
338216beca Revert "CB-3496: Fixed streaming audio, this is pretty important for mobile spec"
This reverts commit aa81966e0b.

Going to revert all DataResource changes for on the 2.8.x branch.
2013-05-27 22:20:01 -04:00
Joe Bowser
d36b1cc89d Merge branch '2.8.x' of https://git-wip-us.apache.org/repos/asf/cordova-android into 2.8.x 2013-05-26 16:13:50 -07:00
Joe Bowser
6b5535e91e Merge branch '2.8.x' of https://git-wip-us.apache.org/repos/asf/cordova-android into 2.8.x 2013-05-24 11:31:16 -07:00
David Kemp
f64cd2ee8a CB-3480: update now uses cordova.js not cordova-<ver>.js 2013-05-24 11:30:50 -07:00
Joe Bowser
aa81966e0b CB-3496: Fixed streaming audio, this is pretty important for mobile spec 2013-05-24 11:30:35 -07:00
David Kemp
f5232f4c26 CB-3480: update now uses cordova.js not cordova-<ver>.js 2013-05-23 14:19:35 -04:00
Andrew Grieve
38b769a2c5 Set VERSION to 2.8.0rc1 2013-05-23 00:06:25 -04:00
Andrew Grieve
d7e962dba0 Update JS snapshot to version 2.8.0rc1 2013-05-23 00:00:49 -04:00
42 changed files with 1570 additions and 1915 deletions

View File

@@ -34,6 +34,7 @@ Requires
- Java JDK 1.5 or greater
- Apache ANT 1.8.0 or greater
- Android SDK [http://developer.android.com](http://developer.android.com)
- Apache Commons Codec [http://commons.apache.org/codec/](http://commons.apache.org/codec/)
Cordova Android Developer Tools
@@ -52,6 +53,7 @@ the dependencies:
General Commands
./bin/create [path package activity] ... create the ./example app or a cordova android project
./bin/bench ............................ generate a bench proj
./bin/autotest ......................... test the cli tools
./bin/test ............................. run mobile-spec
@@ -101,7 +103,11 @@ Note: The Developer Tools handle this. This is only to be done if the tooling f
you are developing directly against the framework.
To create your `cordova.jar` file, run in the framework directory:
To create your `cordova.jar` file, copy the commons codec:
mv commons-codec-1.7.jar framework/libs
then run in the framework directory:
android update project -p . -t android-17
ant jar

View File

@@ -1 +1 @@
2.9.0
2.8.0

View File

@@ -99,6 +99,16 @@ then
# update the cordova-android framework for the desired target
"$ANDROID_BIN" update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
if [ ! -e "$BUILD_PATH"/framework/libs/commons-codec-1.7.jar ]; then
# Use curl to get the jar (TODO: Support Apache Mirrors)
curl -OL http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip &> /dev/null
unzip commons-codec-1.7-bin.zip &> /dev/null
mkdir -p "$BUILD_PATH"/framework/libs
cp commons-codec-1.7/commons-codec-1.7.jar "$BUILD_PATH"/framework/libs
# cleanup yo
rm commons-codec-1.7-bin.zip && rm -rf commons-codec-1.7
fi
# compile cordova.js and cordova.jar
pushd "$BUILD_PATH"/framework > /dev/null
ant jar > /dev/null
@@ -144,6 +154,7 @@ cp "$BUILD_PATH"/bin/templates/cordova/clean "$PROJECT_PATH"/cordova/clean
cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log
cp "$BUILD_PATH"/bin/templates/cordova/run "$PROJECT_PATH"/cordova/run
cp "$BUILD_PATH"/bin/templates/cordova/version "$PROJECT_PATH"/cordova/version
cp "$BUILD_PATH"/bin/templates/cordova/lib/cordova "$PROJECT_PATH"/cordova/lib/cordova
cp "$BUILD_PATH"/bin/templates/cordova/lib/install-device "$PROJECT_PATH"/cordova/lib/install-device
cp "$BUILD_PATH"/bin/templates/cordova/lib/install-emulator "$PROJECT_PATH"/cordova/lib/install-emulator
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-devices "$PROJECT_PATH"/cordova/lib/list-devices

View File

@@ -106,6 +106,60 @@ function createAppInfoJar() {
}
}
function cleanup() {
// Cleanup
// if(fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
// fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6.jar');
// fso.DeleteFolder(ROOT + '\\framework\\libs', true);
// }
if(fso.FileExists(ROOT + '\\framework\\cordova-'+VERSION+'.jar')) {
fso.DeleteFile(ROOT + '\\framework\\cordova-'+VERSION+'.jar');
}
if(fso.FileExists(ROOT + '\\framework\\assets\\www\\cordova-'+VERSION+'.js')) {
fso.DeleteFile(ROOT + '\\framework\\assets\\www\\cordova-'+VERSION+'.js');
}
}
function downloadCommonsCodec() {
if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.7.jar')) {
// We need the .jar
var url = 'http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip';
var libsPath = ROOT + '\\framework\\libs';
var savePath = libsPath + '\\commons-codec-1.7-bin.zip';
if (!fso.FileExists(savePath)) {
if(!fso.FolderExists(ROOT + '\\framework\\libs')) {
fso.CreateFolder(libsPath);
}
// We need the zip to get the jar
var xhr = WScript.CreateObject('MSXML2.XMLHTTP');
xhr.open('GET', url, false);
xhr.send();
if (xhr.status == 200) {
var stream = WScript.CreateObject('ADODB.Stream');
stream.Open();
stream.Type = 1;
stream.Write(xhr.ResponseBody);
stream.Position = 0;
stream.SaveToFile(savePath);
stream.Close();
} else {
Log('Could not retrieve the commons-codec. Please download it yourself and put into the framework/libs directory. This process may fail now. Sorry.');
}
}
var app = WScript.CreateObject('Shell.Application');
var source = app.NameSpace(savePath).Items();
var target = app.NameSpace(ROOT + '\\framework\\libs');
target.CopyHere(source, 256);
// Move the jar into libs
fso.MoveFile(ROOT + '\\framework\\libs\\commons-codec-1.7\\commons-codec-1.7.jar', ROOT + '\\framework\\libs\\commons-codec-1.7.jar');
// Clean up
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.7-bin.zip');
fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.7', true);
}
}
// working dir
var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
if (args.Count() > 0) {
@@ -152,6 +206,8 @@ if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
Log("Building jar and js files...");
// update the cordova framework project to a target that exists on this machine
exec('android.bat update project --target "'+TARGET+'" --path "'+ROOT+'\\framework"');
// pull down commons codec if necessary
downloadCommonsCodec();
exec('ant.bat -f "'+ ROOT +'\\framework\\build.xml" jar');
}
@@ -198,7 +254,6 @@ exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\clean.bat" "' + PROJ
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\build.bat" "' + PROJECT_PATH + '\\cordova\\build.bat" /Y');
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\log.bat" "' + PROJECT_PATH + '\\cordova\\log.bat" /Y');
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\run.bat" "' + PROJECT_PATH + '\\cordova\\run.bat" /Y');
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\version.bat" "' + PROJECT_PATH + '\\cordova\\version.bat" /Y');
// interpolate the activity name and package
Log("Updating AndroidManifest.xml and Main Activity...");
@@ -207,4 +262,6 @@ replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE);
replaceInFile(MANIFEST_PATH, /__ACTIVITY__/, ACTIVITY);
replaceInFile(MANIFEST_PATH, /__PACKAGE__/, PACKAGE);
replaceInFile(MANIFEST_PATH, /__APILEVEL__/, API_LEVEL);
replaceInFile(MANIFEST_PATH, /__APILEVEL__/, API_LEVEL);
cleanup();

View File

@@ -16,24 +16,8 @@
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_PATH=$( cd "$DIR/.." && pwd )
set -e
if [[ "$#" -eq 1 ]] ; then
if [[ $1 == "--debug" ]] ; then
$DIR/clean
ant debug -f "$PROJECT_PATH"/build.xml
elif [[ $1 == "--release" ]] ; then
$DIR/clean
ant release -f "$PROJECT_PATH"/build.xml
elif [[ $1 == "--nobuild" ]] ; then
echo "Skipping build..."
else
echo "Error : Build command '$1' not recognized."
exit 2
fi
else
echo "Warning : [ --debug | --release | --nobuild ] not specified, defaulting to --debug"
$DIR/clean
ant debug -f "$PROJECT_PATH"/build.xml
fi
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_PATH"/lib/cordova build "$@"

View File

@@ -16,7 +16,8 @@
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_PATH=$( cd "$DIR/.." && pwd )
echo "Cleaning project..."
ant -f "$PROJECT_PATH/build.xml" clean
set -e
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_PATH"/lib/cordova clean "$@"

386
bin/templates/cordova/lib/cordova Executable file
View File

@@ -0,0 +1,386 @@
#!/bin/bash
# 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.
PROJECT_PATH=$( cd "$( dirname "$0" )/../.." && pwd )
function list_devices {
IFS=$'\n'
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep -v 'emulator'`
device_list=($devices)
if [[ ${#device_list[@]} > 0 ]] ; then
for i in ${devices[@]}
do
# remove space and 'device'
echo ${i/[^a-zA-Z0-9._]device/}
done
else
echo "No devices found."
exit 2
fi
}
function list_started_emulators {
IFS=$'\n'
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep 'emulator'`
emulator_list=($devices)
if [[ ${#emulator_list[@]} > 0 ]] ; then
for i in ${emulator_list[@]}
do
# remove space and 'device'
echo ${i/[^a-zA-Z0-9._]device/}
done
else
echo "No started emulators found, you can start an emulator by using the command"
echo " 'cordova/lib/start-emulator'"
exit 2
fi
}
function list_emulator_images {
emulator_images=`android list avds | grep "Name:" | cut -f 2 -d ":"`
emulator_list=($emulator_images)
if [[ ${#emulator_list[@]} > 0 ]] ; then
for i in ${emulator_list[@]}
do
echo ${i/[^a-zA-Z0-9._]/}
done
else
echo "No emulators found, if you would like to create an emulator follow the instructions"
echo " provided here : http://developer.android.com/tools/devices/index.html"
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
exit 2
fi
}
function start_emulator {
emulator_images=`android list avds | grep "Name:" | cut -f 2 -d ":"`
# if target emulator is provided
if [[ "$#" -eq 1 ]] ; then
# check that it exists
if [[ $emulator_images =~ $1 ]] ; then
#xterm -e emulator -avd $1 &
emulator -avd $1 1> /dev/null 2>&1 &
else
echo "Could not find the provided emulator, make sure the emulator exists"
echo " by checking 'cordova/lib/list-emulator-images'"
exit 2
fi
else
# start first emulator
emulator_list=($emulator_images)
if [[ ${#emulator_list[@]} > 0 ]] ; then
#xterm -e emulator -avd ${emulator_list[0]} &
emulator -avd ${emulator_list[0]/[^a-zA-Z0-9._]/} 1> /dev/null 2>&1 &
else
echo "No emulators found, if you would like to create an emulator follow the instructions"
echo " provided here : http://developer.android.com/tools/devices/index.html"
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
exit 2
fi
fi
}
function install_device {
IFS=$'\n'
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep -v 'emulator'`
device_list=($devices)
if [[ ${#device_list[@]} > 0 ]] ; then
apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
apk_list=($apks)
if [[ ${#apk_list[@]} > 0 ]] ; then
local target
# handle target emulator
if [[ "$#" -eq 1 ]] ; then
# deploy to given target
target=${1/--target=/}
else
# delete trailing space and 'device' after device ID
target=${device_list[0]/[^a-zA-Z0-9._]device/}
fi
echo "Installing ${apk_list[0]} onto device $target..."
adb -s $target install -r ${apk_list[0]};
echo "Launching application..."
local launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
else
echo "Application package not found, could not install to device"
echo " make sure your application is built before deploying."
exit 2
fi
else
echo "No devices found to deploy to. Please make sure your device is connected"
echo " and you can view it using the 'cordova/lib/list-devices' command."
exit 2
fi
}
function install_emulator {
IFS=$'\n'
# check that there is an emulator to deploy to
emulator_string=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'emulator'`
emulator_list=($emulator_string)
if [[ ${#emulator_list[@]} > 0 ]] ; then
apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
apk_list=($apks)
if [[ ${#apk_list[@]} > 0 ]] ; then
local target
# handle target emulator
if [[ "$#" -eq 1 ]] ; then
# deploy to given target
target=${1/--target=/}
else
# delete trailing space and 'device' after emulator ID
target=${emulator_list[0]/[^a-zA-Z0-9._]device/}
fi
echo "Installing ${apk_list[0]} onto $target..."
adb -s $target install -r ${apk_list[0]};
echo "Launching application..."
local launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
else
echo "Application package not found, could not install to device"
echo " make sure your application is built before deploying."
exit 2
fi
else
echo "No emulators found to deploy to. Please make sure your emulator is started"
echo " and you can view it using the 'cordova/lib/list-started-emulators' command."
exit 2
fi
}
# cleans the project
function clean {
echo "Cleaning project..."
ant clean
}
# has to be used independently and not in conjunction with other commands
function log {
# filter out nativeGetEnabledTags spam from latest sdk bug.
adb logcat | grep -v nativeGetEnabledTags
}
function build {
if [[ "$#" -eq 1 ]] ; then
if [[ $1 == "--debug" ]] ; then
clean
ant debug -f "$PROJECT_PATH"/build.xml
elif [[ $1 == "--release" ]] ; then
clean
ant release -f "$PROJECT_PATH"/build.xml
elif [[ $1 == "--nobuild" ]] ; then
echo "Skipping build..."
else
echo "Error : Build command '$1' not recognized."
exit 2
fi
else
echo "Warning : [ --debug | --release | --nobuild ] not specified, defaulting to --debug"
clean
ant debug -f "$PROJECT_PATH"/build.xml
fi
}
function wait_for_emulator {
emulator_string=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep 'emulator'`
old_started=($emulator_string)
local new_started
local new_emulator_name
local i="0"
echo -n "Waiting for emulator..."
while [ $i -lt 300 ]
do
emulator_string=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep 'emulator'`
new_started=($emulator_string)
if [[ ${#new_started[@]} > ${#old_started[@]} && -z "$new_emulator_name" ]] ; then
# get the name of the started emulator
local count="0"
if [[ ${#old_started[@]} == 0 ]] ; then
new_emulator_name=${new_started[$count]/[^a-zA-Z0-9._]device/}
else
for count in {0...${#old_started[@]}}
do
if [[ ! ${new_started[$count]} == ${old_started[$count]} ]] ; then
new_emulator_name=${new_started[$count]/[^a-zA-Z0-9._]device/}
fi
done
if [[ -z "$new_emulator_name" ]] ; then
count=$[count+1]
new_emulator_name=${new_started[$count]/[^a-zA-Z0-9._]device/}
fi
fi
elif [[ "$new_emulator_name" ]] ; then
boot_anim=`adb -s $new_emulator_name shell getprop init.svc.bootanim`
if [[ $boot_anim =~ "stopped" ]] ; then
break
else
sleep 1
i=$[i+1]
echo -n "."
fi
else
sleep 1
i=$[i+1]
echo -n "."
fi
done
# Device timeout: emulator has not started in time
if [ $i -eq 300 ]
then
echo "emulator timeout!"
exit 69
else
echo "connected!"
fi
}
function run {
IFS=$'\n'
if [[ "$#" -eq 2 ]] ; then
build $2
if [[ $1 == "--device" ]] ; then
install_device
elif [[ $1 == "--emulator" ]] ; then
install_emulator
elif [[ $1 =~ "--target=" ]]; then
install_device $1
else
echo "Error : '$1' is not recognized as an install option"
fi
elif [[ "$#" -eq 1 ]] ; then
if [[ $1 == "--debug" || $1 == "--release" || $1 == "--nobuild" ]] ; then
build $1
elif [[ $1 == "--device" ]] ; then
install_device
elif [[ $1 == "--emulator" ]] ; then
install_emulator
elif [[ $1 =~ "--target=" ]]; then
install_device $1
else
echo "Error : '$1' is not recognized as an install option"
fi
else
echo "Warning : [ --device | --emulate | --target=<targetID> ] not specified, using defaults."
build
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep -v 'emulator'`
device_list=($devices)
emulator_string=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep 'emulator'`
emulator_list=($emulator_string)
if [[ ${#device_list[@]} > 0 ]] ; then
install_device
elif [[ ${#emulator_list[@]} > 0 ]] ; then
install_emulator
else
emulator_images=`android list avds | grep "Name:" | cut -f 2 -d ":"`
echo $emulator_images
emulator_image_list=($emulator_images)
if [[ ${#emulator_image_list[@]} > 0 ]] ; then
echo "Starting emulator : ${emulator_image_list[0]}"
emulator -avd ${emulator_image_list[0]/[^.\w]/} 1> /dev/null 2>&1 &
wait_for_emulator
install_emulator
else
# TODO : look for emulator images and start one if it's availible
echo "Error : there are no availible devices or emulators to deploy to."
echo " create an emulator or connect your device to run this command."
echo "If you would like to create an emulator follow the instructions"
echo " provided here : http://developer.android.com/tools/devices/index.html"
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
exit 2
fi
fi
fi
}
# parse command line arguments
if [[ $# > 3 ]] ; then
echo "Error : too many arguments."
exit 2
elif [[ $# == 3 ]] ; then
if [[ $1 == "run" ]] ; then
run $2 $3
else
echo "Error : too many arguments for '$1'"
exit 2
fi
elif [[ $# == 2 ]] ; then
if [[ $1 == "run" ]] ; then
if [[ $2 == "--emulator" || $2 == "--device" || $2 =~ "--target=" ]] ; then
run $2 ''
elif [[ $2 == "--debug" || $2 == "--release" || $2 == "--nobuild" ]] ; then
run '' $2
else
echo "Error : '$2' is not recognized as a run option."
exit 2
fi
elif [[ $1 == "build" ]] ; then
build $2
elif [[ $1 == "start-emulator" ]] ; then
start_emulator $2
elif [[ $1 == "install-device" ]] ; then
if [[ $2 =~ "--target=" ]] ; then
install_device $2
else
echo "Error : '$2' is not recognized as an install option"
exit 2
fi
elif [[ $1 == "install-emulator" ]] ; then
if [[ $2 =~ "--target=" ]] ; then
install_emulator $2
else
echo "Error : '$2' is not recognized as an install option"
exit 2
fi
else
echo "Error : '$1' is not recognized as an option that takes arguments"
exit 2
fi
elif [[ $# == 1 ]] ; then
if [[ $1 == "run" ]] ; then
run
elif [[ $1 == "build" ]]; then
build
elif [[ $1 == "clean" ]]; then
clean
elif [[ $1 == "log" ]]; then
log
elif [[ $1 == "list-devices" ]]; then
list_devices
elif [[ $1 == "list-emulator-images" ]]; then
list_emulator_images
elif [[ $1 == "list-started-emulators" ]]; then
list_started_emulators
elif [[ $1 == "install-device" ]]; then
install_device
elif [[ $1 == "install-emulator" ]]; then
install_emulator
elif [[ $1 == "start-emulator" ]]; then
start_emulator
else
echo "Error : '$1' is not recognized as a tooling command."
exit 2
fi
else
echo "Error : No command recieved, exiting..."
exit 2
fi

View File

@@ -18,21 +18,6 @@
var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\cordova.js').join(''),
shell = WScript.CreateObject("WScript.Shell"),
fso = WScript.CreateObject('Scripting.FileSystemObject');
//device_id for targeting specific device
var device_id;
//build types
var NONE = 0,
DEBUG = '--debug',
RELEASE = '--release',
NO_BUILD = '--nobuild';
var build_type = NONE;
//deploy tpyes
var NONE = 0,
EMULATOR = 1,
DEVICE = 2,
TARGET = 3;
var deploy_type = NONE;
// log to stdout or stderr
@@ -101,25 +86,6 @@ function exec_verbose(command) {
}
}
function version(path) {
var cordovajs_path = path + "\\assets\\www\\cordova.js";
if(fso.FileExists(cordovajs_path)) {
var f = fso.OpenTextFile(cordovajs_path, 1,2);
var cordovajs = f.ReadAll();
f.Close();
var version_regex = /^.*CORDOVA_JS_BUILD_LABEL.*$/m;
var version_line = cordovajs.match(version_regex) + "";
var version = version_line.match(/(\d+)\.(\d+)\.(\d+)(rc\d)?/) + "";
// TODO : figure out why this isn't matching properly so we can remove this substring workaround.
Log(version.substr(0, ((version.length/2) -1)));
} else {
Log("Error : Could not find cordova js.", true);
Log("Expected Location : " + cordovajs_path, true);
WScript.Quit(2);
}
}
function get_devices() {
var device_list = []
var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll();
@@ -151,18 +117,38 @@ function list_devices() {
}
function get_emulator_images() {
// discription contains all data recieved squashed onto one line
var add_description = true;
var avd_list = [];
var local_emulators = shell.Exec("%comspec% /c android list avds").StdOut.ReadAll();
if (local_emulators.match(/Name\:/)) {
emulators = local_emulators.split('\n');
//format (ID DESCRIPTION)
var count = 0;
var output = '';
for (i in emulators) {
// Find the line with the emulator name.
if (emulators[i].match(/Name\:/)) {
// strip description
var emulator_name = emulators[i].replace(/\s*Name\:\s/, '') + ' ';
avd_list.push(emulator_name);
if (add_description) {
count = 1;
output += emulator_name
}
else {
avd_list.push(emulator_name);
}
}
// add description if indicated (all data squeezed onto one line)
if (count > 0) {
var emulator_description = emulators[i].replace(/\s*/g, '');
if (count > 4) {
avd_list.push(output + emulator_description);
count = 0;
output = '';
}
else {
count++;
output += emulator_description + ' '
}
}
}
}
@@ -206,21 +192,8 @@ function list_started_emulators() {
}
}
else {
Log('No started emulators found, if you would like to start an emulator call ');
Log('\'list-emulator-images\'');
Log(' to get the name of an emulator and then start the emulator with');
Log('\'start-emulator <Name>\'');
}
}
function create_emulator() {
//get targets
var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s\d+/g);
if(targets) {
exec('%comspec% /c android create avd --name cordova_emulator --target ' + targets[targets.length - 1].replace(/id: /, ""));
} else {
Log("You do not have any android targets setup. Please create at least one target with the `android` command so that an emulator can be created.", true);
WScript.Quit(69);
Log('No started emulators found, if you would like to start an emulator call \'list-emulator-images\'');
Log(' to get the name of an emulator and then start the emulator with \'start-emulator <Name>\'');
}
}
@@ -234,14 +207,14 @@ function start_emulator(name) {
for (i in emulators) {
if (emulators[i].substr(0,name.length) == name) {
Log("Starting emulator : " + name);
shell.Exec("%comspec% /c emulator -avd " + name + " &");
shell.Run("%comspec% /c start cmd /c emulator -avd " + name);
//shell.Run("%comspec% /c start cmd /c emulator -cpu-delay 0 -no-boot-anim -cache %Temp%\cache -avd " + name);
started = true;
}
}
}
else {
if (emulators.length > 0 && started_emulators.length == 0) {
if (emulators.length > 0 && started_emulators < 1) {
emulator_name = emulators[0].split(' ', 1)[0];
start_emulator(emulator_name);
return;
@@ -257,16 +230,15 @@ function start_emulator(name) {
Log("Error : unable to start emulator, ensure you have emulators availible by checking \'list-emulator-images\'", true);
WScript.Quit(2);
}
else {
// wait for emulator to get the ID
Log('Waiting for emulator...');
else { // wait for emulator to boot before returning
WScript.Stdout.Write('Booting up emulator..');
var boot_anim = null;
var emulator_ID = null;
var new_started = null;
var new_started = get_started_emulators();
var i = 0;
while(emulator_ID == null && i < 10) {
new_started = get_started_emulators();
if(new_started.length > started_emulators.length) {
// use boot animation property to tell when boot is complete.
while ((boot_anim == null || !boot_anim.output.match(/stopped/)) && i < 100) {
if (new_started.length > started_emulators.length && emulator_ID == null) {
// find new emulator that was just started to get it's ID
for(var i = 0; i < new_started.length; i++) {
if (new_started[i] != started_emulators[i]) {
@@ -276,25 +248,18 @@ function start_emulator(name) {
}
}
}
}
if (i == 10) {
Log('\nEmulator start timed out.');
WScript.Quit(2);
}
i = 0;
WScript.Stdout.Write('Booting up emulator (this may take a while).');
// use boot animation property to tell when boot is complete.
while (!boot_anim.output.match(/stopped/) && i < 100) {
boot_anim = exec_out('%comspec% /c adb -s ' + emulator_ID + ' shell getprop init.svc.bootanim');
else if (boot_anim == null) {
new_started = get_started_emulators();
}
else {
boot_anim = exec_out('%comspec% /c adb -s ' + emulator_ID + ' shell getprop init.svc.bootanim');
}
i++;
WScript.Stdout.Write('.');
WScript.Sleep(2000);
}
if (i < 100) {
Log('\nBoot Complete!');
// Unlock the device
shell.Exec("%comspec% /c adb -s " + emulator_ID + " shell input keyevent 82");
} else {
Log('\nEmulator boot timed out. Failed to load emulator');
WScript.Quit(2);
@@ -302,11 +267,34 @@ function start_emulator(name) {
}
}
function get_apk(path) {
function install_device(target) {
var devices = get_devices();
var use_target = false;
if (devices.length < 1) {
Log("Error : No devices found to install to, make sure there are devices", true);
Log(" availible by checking \'<project_dir>\\cordova\\lib\\list-devices\'", true);
WScript.Quit(2);
}
if (target) {
var exists = false;
for (i in devices) {
if (devices[i].substr(0,target.length) == target)
{
exists = true;
break;
}
}
if (!exists) {
Log("Error : Unable to find target " + target, true);
Log("Please ensure the target exists by checking \'<project>\\cordova\\lib\\list-devices'");
WScript.Quit(2);
}
use_target = true;
}
// check if file .apk has been created
if (fso.FolderExists(path + '\\bin')) {
if (fso.FolderExists(ROOT + '\\bin')) {
var path_to_apk;
var out_folder = fso.GetFolder(path + '\\bin');
var out_folder = fso.GetFolder(ROOT + '\\bin');
var out_files = new Enumerator(out_folder.Files);
for (;!out_files.atEnd(); out_files.moveNext()) {
var path = out_files.item() + '';
@@ -316,7 +304,38 @@ function get_apk(path) {
}
}
if (path_to_apk) {
return path_to_apk;
var launch_name = exec_out("%comspec% /c java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml");
if (launch_name.error) {
Log("Failed to get application name from appinfo.jar + AndroidManifest : ", true);
Log("Output : " + launch_name.output, true);
WScript.Quit(2);
}
// install on device (-d)
Log("Installing app on device...");
var cmd;
if (use_target) {
cmd = '%comspec% /c adb -s ' + target + ' install -r ' + path_to_apk;
} else {
cmd = '%comspec% /c adb -s ' + devices[0].split(' ', 1)[0] + ' install -r ' + path_to_apk;
}
var install = exec_out(cmd);
if ( install.error && install.output.match(/Failure/)) {
Log("Error : Could not install apk to device : ", true);
Log(install.output, true);
WScript.Quit(2);
}
else {
Log(install.output);
}
// run on device
Log("Launching application...");
cmd;
if (use_target) {
cmd = '%comspec% /c adb -s ' + target + ' shell am start -W -a android.intent.action.MAIN -n ' + launch_name.output;
} else {
cmd = '%comspec% /c adb -s ' + devices[0].split(' ', 1)[0] + ' shell am start -W -a android.intent.action.MAIN -n ' + launch_name.output;
}
exec_verbose(cmd);
}
else {
Log('Failed to find apk, make sure you project is built and there is an ', true);
@@ -326,18 +345,7 @@ function get_apk(path) {
}
}
function install_device(path) {
var devices = get_devices();
var use_target = false;
if (devices.length < 1) {
Log("Error : No devices found to install to, make sure there are devices", true);
Log(" availible by checking \'<project_dir>\\cordova\\lib\\list-devices\'", true);
WScript.Quit(2);
}
launch(path, devices[0].split(' ', 1)[0], true);
}
function install_emulator(path) {
function install_emulator(target) {
var emulators = get_started_emulators();
var use_target = false;
if (emulators.length < 1) {
@@ -345,59 +353,46 @@ function install_emulator(path) {
Log(" availible by checking \'<project_dir>\\cordova\\lib\\list-started-emulators\'", true);
WScript.Quit(2);
}
launch(path, emulators[0].split(' ', 1)[0], false);
}
function install_target(path) {
if(device_id) {
var device = false;
var emulators = get_started_emulators();
var devices = get_devices();
if (target) {
var exists = false;
for (i in emulators) {
if (emulators[i].substr(0,device_id.length) == device_id) {
if (emulators[i].substr(0,target.length) == target)
{
exists = true;
break;
}
}
for (i in devices) {
if (devices[i].substr(0,device_id.length) == device_id) {
exists = true;
device = true
break;
}
}
if (!exists) {
Log("Error : Unable to find target " + device_id, true);
Log("Please ensure the target exists by checking \'<project>\\cordova\\lib\\list-started-emulators'");
Log(" Or \'<project>\\cordova\\lib\\list-devices'");
Log("Error : Unable to find target " + target, true);
Log("Please ensure the target exists by checking \'<project>\\cordova\\lib\\list-started-emulators'")
}
launch(path, device_id, device);
use_target = true;
} else {
target = emulators[0].split(' ', 1)[0];
Log("Deploying to emulator : " + target);
}
else {
Log("You cannot install to a target without providing a valid target ID.", true);
WScript.Quit(2);
}
}
function launch(path, id, device) {
if(id) {
var path_to_apk = get_apk(path);
// check if file .apk has been created
if (fso.FolderExists(ROOT + '\\bin')) {
var path_to_apk;
var out_folder = fso.GetFolder(ROOT + '\\bin');
var out_files = new Enumerator(out_folder.Files);
for (;!out_files.atEnd(); out_files.moveNext()) {
var path = out_files.item() + '';
if (fso.GetExtensionName(path) == 'apk' && !path.match(/unaligned/)) {
path_to_apk = out_files.item();
break;
}
}
if (path_to_apk) {
var launch_name = exec_out("%comspec% /c java -jar "+path+"\\cordova\\appinfo.jar "+path+"\\AndroidManifest.xml");
var launch_name = exec_out("%comspec% /c java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml");
if (launch_name.error) {
Log("Failed to get application name from appinfo.jar + AndroidManifest : ", true);
Log("Output : " + launch_name.output, true);
WScript.Quit(2);
}
if (device) {
// install on device (-d)
Log("Installing app on device...");
} else {
// install on emulator (-e)
Log("Installing app on emulator...");
}
var cmd = '%comspec% /c adb -s ' + id + ' install -r ' + path_to_apk;
// install on emulator (-e)
Log("Installing app on emulator...");
var cmd = '%comspec% /c adb -s ' + target + ' install -r ' + path_to_apk;
var install = exec_out(cmd);
if ( install.error && install.output.match(/Failure/)) {
Log("Error : Could not install apk to emulator : ", true);
@@ -407,9 +402,14 @@ function launch(path, id, device) {
else {
Log(install.output);
}
// launch the application
// run on emulator
Log("Launching application...");
cmd = '%comspec% /c adb -s ' + id + ' shell am start -W -a android.intent.action.MAIN -n ' + launch_name.output;
cmd;
if (use_target) {
cmd = '%comspec% /c adb -s ' + target + ' shell am start -W -a android.intent.action.MAIN -n ' + launch_name.output;
} else {
cmd = '%comspec% /c adb -s ' + emulators[0].split(' ', 1)[0] + ' shell am start -W -a android.intent.action.MAIN -n ' + launch_name.output
}
exec_verbose(cmd);
}
else {
@@ -419,14 +419,43 @@ function launch(path, id, device) {
}
}
else {
Log("You cannot install to a target without providing a valid target ID.", true);
Log('Failed to find apk, make sure you project is built and there is an ', true);
Log(' apk in <project>\\bin\\. To build your project use \'<project>\\cordova\\build\'', true);
WScript.Quit(2);
}
}
function clean(path) {
function clean() {
Log("Cleaning project...");
exec("%comspec% /c ant.bat clean -f "+path+"\\build.xml 2>&1");
exec("%comspec% /c ant.bat clean -f "+ROOT+"\\build.xml 2>&1");
}
function build(build_type) {
if (build_type) {
switch (build_type) {
case "--debug" :
clean();
Log("Building project...");
exec_verbose("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
break;
case "--release" :
clean();
Log("Building project...");
exec_verbose("%comspec% /c ant.bat release -f "+ROOT+"\\build.xml 2>&1");
break;
case "--nobuild" :
Log("Skipping build process.");
break;
default :
Log("Build option not recognized: " + build_type, true);
WScript.Quit(2);
break;
}
}
else {
Log("WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug.");
exec_verbose("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
}
}
function log() {
@@ -434,176 +463,131 @@ function log() {
shell.Run("%comspec% /c adb logcat | grep -v nativeGetEnabledTags");
}
function build(path) {
switch (build_type) {
case DEBUG :
clean(path);
Log("Building project...");
exec_verbose("%comspec% /c ant.bat debug -f "+path+"\\build.xml 2>&1");
break;
case RELEASE :
clean(path);
Log("Building project...");
exec_verbose("%comspec% /c ant.bat release -f "+path+"\\build.xml 2>&1");
break;
case NO_BUILD :
Log("Skipping build process.");
break;
case NONE :
clean(path);
Log("WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug.");
exec_verbose("%comspec% /c ant.bat debug -f "+path+"\\build.xml 2>&1");
break;
default :
Log("Build option not recognized: " + build_type, true);
WScript.Quit(2);
break;
function run(target, build_type) {
var use_target = false;
if (!target) {
Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, using defaults");
}
}
function run(path) {
switch(deploy_type) {
case EMULATOR :
build(path);
if(get_started_emulators().length == 0) {
start_emulator();
}
//TODO : Start emulator if one isn't started, and create one if none exists.
install_emulator(path);
break;
case DEVICE :
build(path);
install_device(path);
break;
case TARGET :
build(path);
install_target(path);
break;
case NONE :
if (get_devices().length > 0) {
Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --device");
deploy_type = DEVICE;
// build application
build(build_type);
// attempt to deploy to connected device
var devices = get_devices();
if (devices.length > 0 || target == "--device") {
if (target) {
if (target.substr(0,9) == "--target=") {
install_device(target.split('--target=').join(''))
} else if (target == "--device") {
install_device();
} else {
Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
deploy_type = EMULATOR;
Log("Did not regognize " + target + " as a run option.", true);
WScript.Quit(2);
}
run(path);
break;
default :
Log("Deploy option not recognized: " + deploy_type, true);
WScript.Quit(2);
break;
}
else {
Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, using defaults");
install_device();
}
}
else {
var emulators = get_started_emulators();
if (emulators.length > 0) {
install_emulator();
}
else {
var emulator_images = get_emulator_images();
if (emulator_images.length < 1) {
Log('No emulators found, if you would like to create an emulator follow the instructions', true);
Log(' provided here : http://developer.android.com/tools/devices/index.html', true);
Log(' Or run \'android create avd --name <name> --target <targetID>\' in on the command line.', true);
WScript.Quit(2);
}
start_emulator(emulator_images[0].split(' ')[0]);
emulators = get_started_emulators();
if (emulators.length > 0) {
install_emulator();
}
else {
Log("Error : emulator failed to start.", true);
WScript.Quit(2);
}
}
}
}
var args = WScript.Arguments;
if (args.count() == 0) {
Log("Error: no args provided.");
WScript.Quit(2);
}
else {
// parse command
switch(args(0)) {
case "version" :
version(ROOT);
break;
case "build" :
if(args.Count() > 1) {
if (args(1) == "--release") {
build_type = RELEASE;
}
else if (args(1) == "--debug") {
build_type = DEBUG;
}
else if (args(1) == "--nobuild") {
build_type = NO_BUILD;
}
else {
Log('Error: \"' + args(i) + '\" is not recognized as a build option', true);
WScript.Quit(2);
}
}
build(ROOT);
break;
case "clean" :
clean();
break;
case "list-devices" :
list_devices();
break;
case "list-emulator-images" :
list_emulator_images();
break;
case "list-started-emulators" :
list_started_emulators();
break;
case "start-emulator" :
if (args.Count() > 1) {
start_emulator(args(1))
if (args(0) == "build") {
if (args.Count() > 1) {
build(args(1))
} else {
build();
}
} else if (args(0) == "clean") {
clean();
} else if (args(0) == "list-devices") {
list_devices();
} else if (args(0) == "list-emulator-images") {
list_emulator_images();
} else if (args(0) == "list-started-emulators") {
list_started_emulators();
} else if (args(0) == "start-emulator") {
if (args.Count() > 1) {
start_emulator(args(1))
} else {
start_emulator();
}
} else if (args(0) == "log") {
log();
} else if (args(0) == "install-emulator") {
if (args.Count() == 2) {
if (args(1).substr(0,9) == "--target=") {
install_emulator(args(1).split('--target=').join(''));
} else {
start_emulator();
Log('Error: \"' + args(1) + '\" is not recognized as an install option', true);
WScript.Quit(2);
}
break;
case "install-emulator" :
if (args.Count() == 2) {
if (args(1).substr(0,9) == "--target=") {
device_id = args(1).split('--target=').join('');
install_emulator(ROOT);
} else {
Log('Error: \"' + args(1) + '\" is not recognized as an install option', true);
WScript.Quit(2);
}
} else {
install_emulator();
}
} else if (args(0) == "install-device") {
if (args.Count() == 2) {
if (args(1).substr(0,9) == "--target=") {
install_device(args(1).split('--target=').join(''));
} else {
install_emulator(ROOT);
Log('Error: \"' + args(1) + '\" is not recognized as an install option', true);
WScript.Quit(2);
}
break;
case "install-device" :
if (args.Count() == 2) {
if (args(1).substr(0,9) == "--target=") {
device_id = args(1).split('--target=').join('');
install_target(ROOT);
} else {
Log('Error: \"' + args(1) + '\" is not recognized as an install option', true);
WScript.Quit(2);
}
} else {
install_device();
}
} else if (args(0) == "run") {
if (args.Count() == 3) {
run(args(1), args(2));
}
else if (args.Count() == 2) {
if (args(1).substr(0,9) == "--target=" ||
args(1) == "--emulator" ||
args(1) == "--device") {
run(args(1));
} else if (args(1) == "--debug" ||
args(1) == "--release" ||
args(1) == "--nobuild") {
run(null, args(1))
} else {
install_device(ROOT);
Log('Error: \"' + args(1) + '\" is not recognized as a run option', true);
WScript.Quit(2);
}
break;
case "run" :
//parse args
for(var i = 1; i < args.Count(); i++) {
if (args(i) == "--release") {
build_type = RELEASE;
}
else if (args(i) == "--debug") {
build_type = DEBUG;
}
else if (args(i) == "--nobuild") {
build_type = NO_BUILD;
}
else if (args(i) == "--emulator" || args(i) == "-e") {
deploy_type = EMULATOR;
}
else if (args(i) == "--device" || args(i) == "-d") {
deploy_type = DEVICE;
}
else if (args(i).substr(0,9) == "--target=") {
device_id = args(i).split("--target=").join("");
deploy_type = TARGET;
}
else {
Log('Error: \"' + args(i) + '\" is not recognized as a run option', true);
WScript.Quit(2);
}
}
run(ROOT);
break;
default :
Log("Cordova does not regognize the command " + args(0), true);
WScript.Quit(2);
break;
}
else {
run();
}
} else {
Log('Error: \"' + args(0) + '\" is not recognized as a tooling command', true);
WScript.Quit(2);
}
}

View File

@@ -16,34 +16,8 @@
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_PATH=$( cd "$DIR/../.." && pwd )
device_list=$("$DIR/list-devices")
if [ $? != 0 ]; then
echo "No devices found to deploy to. Please make sure your device is connected"
echo " and you can view it using the 'cordova/lib/list-devices' command."
exit 2
fi
set -e
apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
apk_list=($apks)
if [[ ${#apk_list[@]} > 0 ]] ; then
# handle target
read -ra device_array <<< "$device_list"
if [[ "$#" -eq 1 ]] ; then
# deploy to given target
target=${1/--target=/}
else
# delete trailing space and 'device' after device ID
target=${device_array[0]}
fi
echo "Installing ${apk_list[0]} onto device $target..."
adb -s $target install -r ${apk_list[0]};
echo "Launching application..."
launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
else
echo "Application package not found, could not install to device"
echo " make sure your application is built before deploying."
exit 2
fi
CORDOVA_LIB_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_LIB_PATH"/cordova install-device "$@"

View File

@@ -16,35 +16,8 @@
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_PATH=$( cd "$DIR/../.." && pwd )
emulator_list=$("$DIR/list-started-emulators")
if [ $? != 0 ]; then
echo "No emulators found to deploy to. Please make sure your emulator is started"
echo " You can view it using the 'cordova/lib/list-started-emulators' command."
echo " You can view created emulator images using the 'cordova/lib/list-emulator-images' command."
echo " You can start an emulator image using the 'cordova/lib/start-emulator' command."
exit 2
fi
set -e
apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
apk_list=($apks)
if [[ ${#apk_list[@]} > 0 ]] ; then
# handle target emulator
if [[ "$#" -eq 1 ]] ; then
# deploy to given target
target=${1/--target=/}
else
# delete trailing space and 'device' after emulator ID
target=${emulator_list[0]}
fi
echo "Installing ${apk_list[0]} onto emulator $target..."
adb -s $target install -r ${apk_list[0]};
echo "Launching application..."
launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
else
echo "Application package not found, could not install to device"
echo " make sure your application is built before deploying."
exit 2
fi
CORDOVA_LIB_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_LIB_PATH"/cordova install-emulator "$@"

View File

@@ -16,15 +16,8 @@
# specific language governing permissions and limitations
# under the License.
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep -v 'emulator' | awk '{ print $1; }'`
device_list=($devices)
if [[ ${#device_list[@]} > 0 ]] ; then
for i in ${devices[@]}
do
echo $i
done
exit 0
else
echo "No devices found."
exit 2
fi
set -e
CORDOVA_LIB_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_LIB_PATH"/cordova list-devices

View File

@@ -16,17 +16,8 @@
# specific language governing permissions and limitations
# under the License.
emulator_images=`android list avds | grep "Name:" | cut -f 2 -d ":"`
emulator_list=($emulator_images)
if [[ ${#emulator_list[@]} > 0 ]] ; then
for i in ${emulator_list[@]}
do
echo $i
done
exit 0
else
echo "No emulators found, if you would like to create an emulator follow the instructions"
echo " provided here : http://developer.android.com/tools/devices/index.html"
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
exit 2
fi
set -e
CORDOVA_LIB_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_LIB_PATH"/cordova list-emulator-images

View File

@@ -16,17 +16,8 @@
# specific language governing permissions and limitations
# under the License.
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print $1;}}' | grep 'emulator' | grep -v 'offline'`
read -ra emulator_list <<< "$devices"
if [[ ${#emulator_list[@]} > 0 ]] ; then
for i in ${emulator_list[@]}
do
# remove space and 'device'
echo $i
done
exit 0
else
echo "No started emulators found (it may still be booting up), you can start an emulator by using the command"
echo " 'cordova/lib/start-emulator'"
exit 2
fi
set -e
CORDOVA_LIB_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_LIB_PATH"/cordova list-started-emulators

View File

@@ -16,76 +16,8 @@
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_PATH=$( cd "$( dirname "$0" )/../.." && pwd )
set -e
function dot {
sleep 1
echo -n "."
}
CORDOVA_LIB_PATH=$( cd "$( dirname "$0" )" && pwd )
function wait_for_emulator {
local i="0"
echo -n "Waiting for emulator"
emulator_string=$($DIR/list-started-emulators)
while [ $? != 0 ]
do
dot
i=$[i+1]
emulator_string=$($DIR/list-started-emulators)
done
read -ra target <<< "$emulator_string"
echo ""
echo -n "Waiting for it to boot up (this can take a while)"
while [ $i -lt 300 ]
do
boot_anim=$(adb -s $target shell getprop init.svc.bootanim 2>&1)
if [[ "$boot_anim" =~ "stopped" ]] ; then
break
else
i=$[i+1]
dot
fi
done
# Device timeout: emulator has not started in time
if [ $i -eq 300 ]
then
echo ""
echo "Emulator timeout!"
exit 69
else
echo ""
echo "Connected!"
fi
# Unlock the device
adb -s $target shell input keyevent 82
exit 0
}
emulator_images=$("$DIR/list-emulator-images")
if [ $? != 0 ]; then
echo "No emulators found, if you would like to create an emulator follow the instructions"
echo " provided here : http://developer.android.com/tools/devices/index.html"
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
exit 2
fi
# if target emulator is provided
if [[ "$#" -eq 1 ]] ; then
# check that it exists
if [[ $emulator_images =~ $1 ]] ; then
#xterm -e emulator -avd $1 &
emulator -avd $1 1> /dev/null 2>&1 &
else
echo "Could not find the provided emulator '$1', make sure the emulator exists"
echo " by checking 'cordova/lib/list-emulator-images'"
exit 2
fi
else
# start first emulator
read -ra emulator_list <<< "$emulator_images"
#xterm -e emulator -avd ${emulator_list[0]} &
emulator -avd ${emulator_list[0]} 1> /dev/null 2>&1 &
fi
wait_for_emulator
bash "$CORDOVA_LIB_PATH"/cordova start-emulator "$@"

View File

@@ -16,5 +16,8 @@
# specific language governing permissions and limitations
# under the License.
# filter out nativeGetEnabledTags spam from latest sdk bug.
adb logcat | grep -v nativeGetEnabledTags
set -e
CORDOVA_PATH=$( cd "$( dirname "$0" )/.." && pwd )
bash "$CORDOVA_PATH"/cordova/lib/cordova log "$@"

View File

@@ -16,66 +16,8 @@
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_PATH=$( cd "$DIR/.." && pwd )
set -e
function run_on_device_or_emulator {
devices=`$DIR/lib/list-devices`
if [ $? = 0 ]; then
$DIR/lib/install-device
else
run_on_emulator
fi
}
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
function run_on_emulator {
emulators=`$DIR/lib/list-started-emulators`
if [ $? = 0 ] ; then
$DIR/lib/install-emulator
else
images=`$DIR/lib/list-emulator-images`
if [ $? = 0 ] ; then
$DIR/lib/start-emulator
$DIR/lib/install-emulator
else
echo "No devices/emulators started nor images available to start. How are we supposed to do this, then?"
exit 2
fi
fi
}
if [[ "$#" -eq 2 ]] ; then
# TODO: the order of arguments here may be reversed from the assumption below
$DIR/build $2
if [[ $1 == "--device" ]] ; then
$DIR/lib/install-device
elif [[ $1 == "--emulator" ]] ; then
run_on_emulator
elif [[ $1 =~ "--target=" ]]; then
$DIR/lib/install-device $1
else
echo "Error : '$1' is not recognized as an install option"
fi
elif [[ "$#" -eq 1 ]] ; then
if [[ $1 == "--debug" || $1 == "--release" || $1 == "--nobuild" ]] ; then
$DIR/build $1
run_on_device_or_emulator
elif [[ $1 == "--device" ]] ; then
$DIR/build
$DIR/lib/install-device
elif [[ $1 == "--emulator" ]] ; then
$DIR/build
run_on_emulator
elif [[ $1 =~ "--target=" ]]; then
$DIR/build
$DIR/lib/install-device $1
else
echo "Error : '$1' is not recognized as an install option"
fi
else
echo "Warning : [ --device | --emulate | --target=<targetID> ] not specified, using defaults."
$DIR/build
run_on_device_or_emulator
fi
bash "$CORDOVA_PATH"/lib/cordova run "$@"

View File

@@ -24,7 +24,7 @@ PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
VERSION_FILE_PATH="$PROJECT_PATH/assets/www/cordova.js"
if [ -f "$VERSION_FILE_PATH" ]; then
JSVersion=$(sed -n '2,2p' $VERSION_FILE_PATH)
JSVersion=$(sed -n '2,2p' assets/www/cordova.js)
echo $JSVersion | sed -e 's/\/\/ //'| cut -f 1 -d '-'
else
echo "The file \"$VERSION_FILE_PATH\" does not exist."

View File

@@ -1,18 +0,0 @@
:: 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.
@ECHO OFF
%~dp0\cordova.bat version %*

View File

@@ -64,6 +64,8 @@ function createAppInfoJar {
function on_error {
echo "An unexpected error occurred: $previous_command exited with $?"
echo "Deleting project..."
[ -d "$PROJECT_PATH" ] && rm -rf "$PROJECT_PATH"
exit 1
}

View File

@@ -96,6 +96,46 @@ function cleanup() {
}
}
function downloadCommonsCodec() {
if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.7.jar')) {
// We need the .jar
var url = 'http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip';
var libsPath = ROOT + '\\framework\\libs';
var savePath = libsPath + '\\commons-codec-1.7-bin.zip';
if (!fso.FileExists(savePath)) {
if(!fso.FolderExists(ROOT + '\\framework\\libs')) {
fso.CreateFolder(libsPath);
}
// We need the zip to get the jar
var xhr = WScript.CreateObject('MSXML2.XMLHTTP');
xhr.open('GET', url, false);
xhr.send();
if (xhr.status == 200) {
var stream = WScript.CreateObject('ADODB.Stream');
stream.Open();
stream.Type = 1;
stream.Write(xhr.ResponseBody);
stream.Position = 0;
stream.SaveToFile(savePath);
stream.Close();
} else {
WScript.Echo('Could not retrieve the commons-codec. Please download it yourself and put into the framework/libs directory. This process may fail now. Sorry.');
}
}
var app = WScript.CreateObject('Shell.Application');
var source = app.NameSpace(savePath).Items();
var target = app.NameSpace(ROOT + '\\framework\\libs');
target.CopyHere(source, 256);
// Move the jar into libs
fso.MoveFile(ROOT + '\\framework\\libs\\commons-codec-1.7\\commons-codec-1.7.jar', ROOT + '\\framework\\libs\\commons-codec-1.7.jar');
// Clean up
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.7-bin.zip');
fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.7', true);
}
}
var args = WScript.Arguments, PROJECT_PATH="example",
shell=WScript.CreateObject("WScript.Shell");
@@ -121,6 +161,8 @@ if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
WScript.Echo("Building jar and js files...");
// update the cordova framework project to a target that exists on this machine
exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
// pull down commons codec if necessary
downloadCommonsCodec();
exec('ant.bat -f \"'+ ROOT +'\\framework\\build.xml\" jar');
}

View File

@@ -3,6 +3,7 @@
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="libs/commons-codec-1.7.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@@ -1,5 +1,5 @@
// Platform: android
// 2.9.0-0-g83dc4bd
// 2.8.0-0-g6208c95
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
var CORDOVA_JS_BUILD_LABEL = '2.9.0-0-g83dc4bd';
var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
// file: lib/scripts/require.js
var require,
@@ -3059,31 +3059,9 @@ FileWriter.prototype.abort = function() {
/**
* Writes data to the file
*
* @param data text or blob to be written
* @param text to be written
*/
FileWriter.prototype.write = function(data) {
var isBinary = false;
// If we don't have Blob or ArrayBuffer support, don't bother.
if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
// Check to see if the incoming data is a blob
if (data instanceof Blob) {
var that=this;
var fileReader = new FileReader();
fileReader.onload = function() {
// Call this method again, with the arraybuffer as argument
FileWriter.prototype.write.call(that, this.result);
};
fileReader.readAsArrayBuffer(data);
return;
}
// Mark data type for safer transport over the binary bridge
isBinary = (data instanceof ArrayBuffer);
}
FileWriter.prototype.write = function(text) {
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw new FileError(FileError.INVALID_STATE_ERR);
@@ -3149,7 +3127,7 @@ FileWriter.prototype.write = function(data) {
if (typeof me.onwriteend === "function") {
me.onwriteend(new ProgressEvent("writeend", {"target":me}));
}
}, "File", "write", [this.fileName, data, this.position, isBinary]);
}, "File", "write", [this.fileName, text, this.position]);
};
/**
@@ -3335,9 +3313,6 @@ InAppBrowser.prototype = {
close: function (eventname) {
exec(null, null, "InAppBrowser", "close", []);
},
show: function (eventname) {
exec(null, null, "InAppBrowser", "show", []);
},
addEventListener: function (eventname,f) {
if (eventname in this.channels) {
this.channels[eventname].subscribe(f);
@@ -6801,21 +6776,11 @@ require('cordova/channel').onNativeReady.fire();
}
}
function scriptErrorCallback(err) {
// Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
// this is currently just continuing.
scriptCounter--;
if (scriptCounter === 0) {
onScriptLoadingComplete && onScriptLoadingComplete();
}
}
// Helper function to inject a <script> tag.
function injectScript(path) {
scriptCounter++;
var script = document.createElement("script");
script.onload = scriptLoadedCallback;
script.onerror = scriptErrorCallback;
script.src = path;
document.head.appendChild(script);
}
@@ -6827,10 +6792,10 @@ require('cordova/channel').onNativeReady.fire();
context.cordova.require('cordova/channel').onPluginsReady.fire();
}
// Handler for the cordova_plugins.js content.
// Handler for the cordova_plugins.json content.
// See plugman's plugin_loader.js for the details of this object.
// This function is only called if the really is a plugins array that isn't empty.
// Otherwise the onerror response handler will just call finishPluginLoading().
// Otherwise the XHR response handler will just call finishPluginLoading().
function handlePluginsObject(modules, path) {
// First create the callback for when all plugins are loaded.
var mapper = context.cordova.require('cordova/modulemapper');
@@ -6838,31 +6803,26 @@ require('cordova/channel').onNativeReady.fire();
// Loop through all the plugins and then through their clobbers and merges.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
if (module) {
try {
if (module.clobbers && module.clobbers.length) {
for (var j = 0; j < module.clobbers.length; j++) {
mapper.clobbers(module.id, module.clobbers[j]);
}
}
if (!module) continue;
if (module.merges && module.merges.length) {
for (var k = 0; k < module.merges.length; k++) {
mapper.merges(module.id, module.merges[k]);
}
}
if (module.clobbers && module.clobbers.length) {
for (var j = 0; j < module.clobbers.length; j++) {
mapper.clobbers(module.id, module.clobbers[j]);
}
}
// Finally, if runs is truthy we want to simply require() the module.
// This can be skipped if it had any merges or clobbers, though,
// since the mapper will already have required the module.
if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
context.cordova.require(module.id);
}
}
catch(err) {
// error with module, most likely clobbers, should we continue?
if (module.merges && module.merges.length) {
for (var k = 0; k < module.merges.length; k++) {
mapper.merges(module.id, module.merges[k]);
}
}
// Finally, if runs is truthy we want to simply require() the module.
// This can be skipped if it had any merges or clobbers, though,
// since the mapper will already have required the module.
if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
context.cordova.require(module.id);
}
}
finishPluginLoading();
@@ -6885,33 +6845,6 @@ require('cordova/channel').onNativeReady.fire();
break;
}
}
var plugins_json = path + 'cordova_plugins.json';
var plugins_js = path + 'cordova_plugins.js';
// One some phones (Windows) this xhr.open throws an Access Denied exception
// So lets keep trying, but with a script tag injection technique instead of XHR
var injectPluginScript = function injectPluginScript() {
try {
var script = document.createElement("script");
script.onload = function(){
var list = cordova.require("cordova/plugin_list");
handlePluginsObject(list,path);
};
script.onerror = function() {
// Error loading cordova_plugins.js, file not found or something
// this is an acceptable error, pre-3.0.0, so we just move on.
finishPluginLoading();
};
script.src = plugins_js;
document.head.appendChild(script);
} catch(err){
finishPluginLoading();
}
}
// Try to XHR the cordova_plugins.json file asynchronously.
var xhr = new XMLHttpRequest();
xhr.onload = function() {
@@ -6930,16 +6863,14 @@ require('cordova/channel').onNativeReady.fire();
}
};
xhr.onerror = function() {
// In this case, the json file was not present, but XHR was allowed,
// so we should still try the script injection technique with the js file
// in case that is there.
injectPluginScript();
finishPluginLoading();
};
var plugins_json = path + 'cordova_plugins.json';
try { // we commented we were going to try, so let us actually try and catch
xhr.open('GET', plugins_json, true); // Async
xhr.send();
} catch(err){
injectPluginScript();
finishPluginLoading();
}
}(window));

View File

@@ -31,6 +31,22 @@
<fail message="The required minimum version of ant is 1.8.0, you have ${ant.version}"
unless="thisantversion" />
<!-- check that commons codec is available. You should copy the codec jar to
framework/libs, as it is not included in the Cordova distribution.
The name of the jar file in framework/libs does not matter. -->
<available classname="org.apache.commons.codec.binary.Base64"
property="exists.base64"
ignoresystemclasses="true">
<classpath>
<pathelement path="${classpath}" />
<fileset dir="libs">
<include name="*.jar" />
</fileset>
</classpath>
</available>
<fail message="You need to put a copy of Apache Commons Codec jar in the framework/libs directory"
unless="exists.base64" />
<!-- The local.properties file is created and updated by the 'android'
tool. (For example "sdkdir/tools/android update project -p ." inside
of this directory where the AndroidManifest.xml file exists. This

View File

@@ -30,7 +30,7 @@ import org.json.JSONObject;
import java.util.HashMap;
/**
* This class exposes methods in Cordova that can be called from JavaScript.
* This class exposes methods in DroidGap that can be called from JavaScript.
*/
public class App extends CordovaPlugin {
@@ -104,7 +104,7 @@ public class App extends CordovaPlugin {
* Load the url into the webview.
*
* @param url
* @param props Properties that can be passed in to the Cordova activity (i.e. loadingDialog, wait, ...)
* @param props Properties that can be passed in to the DroidGap activity (i.e. loadingDialog, wait, ...)
* @throws JSONException
*/
public void loadUrl(String url, JSONObject props) throws JSONException {
@@ -198,7 +198,7 @@ public class App extends CordovaPlugin {
* @param override T=override, F=cancel override
*/
public void overrideButton(String button, boolean override) {
LOG.i("App", "WARNING: Volume Button Default Behaviour will be overridden. The volume event will be fired!");
LOG.i("DroidGap", "WARNING: Volume Button Default Behaviour will be overridden. The volume event will be fired!");
webView.bindButton(button, override);
}

View File

@@ -26,6 +26,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.codec.binary.Base64;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.LOG;
@@ -47,7 +48,6 @@ import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;
/**
@@ -761,7 +761,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
try {
if (bitmap.compress(CompressFormat.JPEG, mQuality, jpeg_data)) {
byte[] code = jpeg_data.toByteArray();
byte[] output = Base64.encode(code, Base64.DEFAULT);
byte[] output = Base64.encodeBase64(code);
String js_out = new String(output);
this.callbackContext.success(js_out);
js_out = null;

View File

@@ -64,10 +64,11 @@ import android.widget.LinearLayout;
* As an example:
*
* package org.apache.cordova.examples;
* import android.app.Activity;
* import android.os.Bundle;
* import org.apache.cordova.*;
*
* public class Example extends CordovaActivity {
* public class Examples extends DroidGap {
* @Override
* public void onCreate(Bundle savedInstanceState) {
* super.onCreate(savedInstanceState);
@@ -76,6 +77,9 @@ import android.widget.LinearLayout;
* super.setStringProperty("loadingDialog", "Title,Message"); // show loading dialog
* super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); // if error loading file in super.loadUrl().
*
* // Initialize activity
* super.init();
*
* // Clear cache if you want
* super.appView.clearCache(true);
*
@@ -117,7 +121,7 @@ import android.widget.LinearLayout;
* Cordova.xml configuration:
* Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
*
* Approved list of URLs that can be loaded into Cordova
* Approved list of URLs that can be loaded into DroidGap
* <access origin="http://server regexp" subdomains="true" />
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
* <log level="DEBUG" />
@@ -134,7 +138,7 @@ import android.widget.LinearLayout;
* </plugins>
*/
public class CordovaActivity extends Activity implements CordovaInterface {
public static String TAG = "CordovaActivity";
public static String TAG = "DroidGap";
// The webview for our app
protected CordovaWebView appView;
@@ -259,7 +263,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
@Override
public void onCreate(Bundle savedInstanceState) {
Config.init(this);
LOG.d(TAG, "CordovaActivity.onCreate()");
LOG.d(TAG, "DroidGap.onCreate()");
super.onCreate(savedInstanceState);
if(savedInstanceState != null)
@@ -332,7 +336,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
*/
@SuppressLint("NewApi")
public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
LOG.d(TAG, "CordovaActivity.init()");
LOG.d(TAG, "DroidGap.init()");
// Set up web container
this.appView = webView;
@@ -595,7 +599,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* @param value
*/
public void setBooleanProperty(String name, boolean value) {
Log.d(TAG, "Setting boolean properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
Log.d(TAG, "Setting boolean properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
this.getIntent().putExtra(name, value);
}
@@ -606,7 +610,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* @param value
*/
public void setIntegerProperty(String name, int value) {
Log.d(TAG, "Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
Log.d(TAG, "Setting integer properties in DroidGap will be deprecated in 3.1 on August 2013, please use config.xml");
this.getIntent().putExtra(name, value);
}
@@ -617,7 +621,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* @param value
*/
public void setStringProperty(String name, String value) {
Log.d(TAG, "Setting string properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
Log.d(TAG, "Setting string properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
this.getIntent().putExtra(name, value);
}
@@ -628,7 +632,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* @param value
*/
public void setDoubleProperty(String name, double value) {
Log.d(TAG, "Setting double properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
Log.d(TAG, "Setting double properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
this.getIntent().putExtra(name, value);
}
@@ -712,7 +716,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* The final call you receive before your activity is destroyed.
*/
public void onDestroy() {
LOG.d(TAG, "CordovaActivity.onDestroy()");
LOG.d(TAG, "onDestroy()");
super.onDestroy();
// hide the splash screen to avoid leaking a window
@@ -852,13 +856,18 @@ public class CordovaActivity extends Activity implements CordovaInterface {
mUploadMessage = null;
}
CordovaPlugin callback = this.activityResultCallback;
if(callback == null && initCallbackClass != null) {
// The application was restarted, but had defined an initial callback
// before being shut down.
this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
callback = this.activityResultCallback;
if(callback == null)
{
if(initCallbackClass != null)
{
this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
callback = activityResultCallback;
LOG.d(TAG, "We have a callback to send this result to");
callback.onActivityResult(requestCode, resultCode, intent);
}
}
if(callback != null) {
else
{
LOG.d(TAG, "We have a callback to send this result to");
callback.onActivityResult(requestCode, resultCode, intent);
}
@@ -952,7 +961,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
}
/*
* Hook in Cordova for menu plugins
* Hook in DroidGap for menu plugins
*
*/
@Override
@@ -991,7 +1000,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* @param url The url to load.
* @param openExternal Load url in browser instead of Cordova webview.
* @param clearHistory Clear the history stack, so new page becomes top of history
* @param params Parameters for new app
* @param params DroidGap parameters for new app
*/
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
if (this.appView != null) {

View File

@@ -222,7 +222,6 @@ public class CordovaChromeClient extends WebChromeClient {
result.confirm(r == null ? "" : r);
} catch (JSONException e) {
e.printStackTrace();
return false;
}
}
@@ -287,7 +286,7 @@ public class CordovaChromeClient extends WebChromeClient {
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
{
LOG.d(TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
LOG.d(TAG, "DroidGap: onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
if (estimatedSize < MAX_QUOTA)
{

View File

@@ -485,7 +485,7 @@ public class CordovaWebView extends WebView {
// If first page, then show splashscreen
else {
LOG.d(TAG, "loadUrlIntoView(%s, %d)", url, time);
LOG.d(TAG, "DroidGap.loadUrl(%s, %d)", url, time);
// Send message to show splashscreen now if desired
this.postMessage("splashscreen", "show");
@@ -555,7 +555,7 @@ public class CordovaWebView extends WebView {
* @param url The url to load.
* @param openExternal Load url in browser instead of Cordova webview.
* @param clearHistory Clear the history stack, so new page becomes top of history
* @param params Parameters for new app
* @param params DroidGap parameters for new app
*/
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);
@@ -601,7 +601,7 @@ public class CordovaWebView extends WebView {
/**
* Check configuration parameters from Config.
* Approved list of URLs that can be loaded into Cordova
* Approved list of URLs that can be loaded into DroidGap
* <access origin="http://server regexp" subdomains="true" />
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
* <log level="DEBUG" />
@@ -806,7 +806,7 @@ public class CordovaWebView extends WebView {
{
// Send destroy event to JavaScript
// Since baseUrl is set in loadUrlIntoView, if user hit Back button before loadUrl was called, we'll get an NPE on baseUrl (CB-2458)
this.loadUrl("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
this.loadUrlIntoView("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
// Load blank page so that JavaScript onunload is called
this.loadUrl("about:blank");

View File

@@ -188,17 +188,6 @@ public class CordovaWebViewClient extends WebViewClient {
LOG.e(TAG, "Error sending sms " + url + ":" + e.toString());
}
}
//Android Market
else if(url.startsWith("market:")) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
this.cordova.getActivity().startActivity(intent);
} catch (android.content.ActivityNotFoundException e) {
LOG.e(TAG, "Error loading Google Play Store: " + url, e);
}
}
// All else
else {
@@ -222,7 +211,35 @@ public class CordovaWebViewClient extends WebViewClient {
}
return true;
}
/**
* Check for intercepting any requests for resources.
* This includes images and scripts and so on, not just top-level pages.
* @param view The WebView.
* @param url The URL to be loaded.
* @return Either null to proceed as normal, or a WebResourceResponse.
*/
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
//If something isn't whitelisted, just send a blank response
if(!Config.isUrlWhiteListed(url) && (url.startsWith("http://") || url.startsWith("https://")))
{
return getWhitelistResponse();
}
if (this.appView.pluginManager != null) {
return this.appView.pluginManager.shouldInterceptRequest(url);
}
return null;
}
private WebResourceResponse getWhitelistResponse()
{
WebResourceResponse emptyResponse;
String empty = "";
ByteArrayInputStream data = new ByteArrayInputStream(empty.getBytes());
return new WebResourceResponse("text/plain", "UTF-8", data);
}
/**
* On received http auth request.
* The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination

View File

@@ -38,7 +38,7 @@ import android.telephony.TelephonyManager;
public class Device extends CordovaPlugin {
public static final String TAG = "Device";
public static String cordovaVersion = "2.9.0"; // Cordova version
public static String cordovaVersion = "2.8.0rc1"; // Cordova version
public static String platform = "Android"; // Device OS
public static String uuid; // Device UUID
@@ -101,7 +101,7 @@ public class Device extends CordovaPlugin {
/**
* Listen for telephony events: RINGING, OFFHOOK and IDLE
* Send these events to all plugins using
* CordovaActivity.onMessage("telephone", "ringing" | "offhook" | "idle")
* DroidGap.onMessage("telephone", "ringing" | "offhook" | "idle")
*/
private void initTelephonyReceiver() {
IntentFilter intentFilter = new IntentFilter();

View File

@@ -93,18 +93,10 @@ public class FileHelper {
if (uriString.startsWith("content")) {
Uri uri = Uri.parse(uriString);
return cordova.getActivity().getContentResolver().openInputStream(uri);
} else if (uriString.startsWith("file://")) {
int question = uriString.indexOf("?");
if (question > -1) {
uriString = uriString.substring(0,question);
}
if (uriString.startsWith("file:///android_asset/")) {
Uri uri = Uri.parse(uriString);
String relativePath = uri.getPath().substring(15);
return cordova.getActivity().getAssets().open(relativePath);
} else {
return new FileInputStream(getRealPath(uriString, cordova));
}
} else if (uriString.startsWith("file:///android_asset/")) {
Uri uri = Uri.parse(uriString);
String relativePath = uri.getPath().substring(15);
return cordova.getActivity().getAssets().open(relativePath);
} else {
return new FileInputStream(getRealPath(uriString, cordova));
}

View File

@@ -855,15 +855,20 @@ public class FileTransfer extends CordovaPlugin {
* @throws FileNotFoundException
*/
private InputStream getPathFromUri(String path) throws FileNotFoundException {
try {
InputStream stream = FileHelper.getInputStreamFromUriString(path, cordova);
if (stream == null) {
return new FileInputStream(path);
if (path.startsWith("content:")) {
Uri uri = Uri.parse(path);
return cordova.getActivity().getContentResolver().openInputStream(uri);
}
else if (path.startsWith("file://")) {
int question = path.indexOf("?");
if (question == -1) {
return new FileInputStream(path.substring(7));
} else {
return stream;
return new FileInputStream(path.substring(7, question));
}
} catch (IOException e) {
throw new FileNotFoundException();
}
else {
return new FileInputStream(path);
}
}

View File

@@ -22,9 +22,9 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;
import org.apache.commons.codec.binary.Base64;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
@@ -134,7 +134,7 @@ public class FileUtils extends CordovaPlugin {
this.readFileAs(args.getString(0), start, end, callbackContext, null, PluginResult.MESSAGE_TYPE_BINARYSTRING);
}
else if (action.equals("write")) {
long fileSize = this.write(args.getString(0), args.getString(1), args.getInt(2), args.getBoolean(3));
long fileSize = this.write(args.getString(0), args.getString(1), args.getInt(2));
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, fileSize));
}
else if (action.equals("truncate")) {
@@ -950,7 +950,7 @@ public class FileUtils extends CordovaPlugin {
break;
default: // Base64.
String contentType = FileHelper.getMimeType(filename, cordova);
byte[] base64 = Base64.encode(bytes, Base64.DEFAULT);
byte[] base64 = Base64.encodeBase64(bytes);
String s = "data:" + contentType + ";base64," + new String(base64, "US-ASCII");
result = new PluginResult(PluginResult.Status.OK, s);
}
@@ -999,12 +999,11 @@ public class FileUtils extends CordovaPlugin {
* @param filename The name of the file.
* @param data The contents of the file.
* @param offset The position to begin writing the file.
* @param isBinary True if the file contents are base64-encoded binary data
* @throws FileNotFoundException, IOException
* @throws NoModificationAllowedException
*/
/**/
public long write(String filename, String data, int offset, boolean isBinary) throws FileNotFoundException, IOException, NoModificationAllowedException {
public long write(String filename, String data, int offset) throws FileNotFoundException, IOException, NoModificationAllowedException {
if (filename.startsWith("content://")) {
throw new NoModificationAllowedException("Couldn't write to file given its content URI");
}
@@ -1017,12 +1016,7 @@ public class FileUtils extends CordovaPlugin {
append = true;
}
byte[] rawData;
if (isBinary) {
rawData = Base64.decode(data, Base64.DEFAULT);
} else {
rawData = data.getBytes();
}
byte[] rawData = data.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(rawData);
FileOutputStream out = new FileOutputStream(filename, append);
byte buff[] = new byte[rawData.length];

View File

@@ -260,13 +260,12 @@ public class Globalization extends CordovaPlugin {
String fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); //default SHORT date/time format. ex. dd/MM/yyyy h:mm a
//get Date value + options (if available)
boolean test = options.getJSONObject(0).has(OPTIONS);
if (options.getJSONObject(0).has(OPTIONS)){
if (options.getJSONObject(0).length() > 1){
//options were included
JSONObject innerOptions = options.getJSONObject(0).getJSONObject(OPTIONS);
//get formatLength option
if (!innerOptions.isNull(FORMATLENGTH)){
String fmtOpt = innerOptions.getString(FORMATLENGTH);
if (!((JSONObject)options.getJSONObject(0).get(OPTIONS)).isNull(FORMATLENGTH)){
String fmtOpt = (String)((JSONObject)options.getJSONObject(0).get(OPTIONS)).get(FORMATLENGTH);
if (fmtOpt.equalsIgnoreCase(MEDIUM)){//medium
fmtDate = (SimpleDateFormat)android.text.format.DateFormat.getMediumDateFormat(this.cordova.getActivity());
}else if (fmtOpt.equalsIgnoreCase(LONG) || fmtOpt.equalsIgnoreCase(FULL)){ //long/full
@@ -276,8 +275,8 @@ public class Globalization extends CordovaPlugin {
//return pattern type
fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern();
if (!innerOptions.isNull(SELECTOR)){
String selOpt = innerOptions.getString(SELECTOR);
if (!((JSONObject)options.getJSONObject(0).get(OPTIONS)).isNull(SELECTOR)){
String selOpt = (String)((JSONObject)options.getJSONObject(0).get(OPTIONS)).get(SELECTOR);
if (selOpt.equalsIgnoreCase(DATE)){
fmt = fmtDate.toLocalizedPattern();
}else if (selOpt.equalsIgnoreCase(TIME)){

View File

@@ -18,7 +18,6 @@
*/
package org.apache.cordova;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -46,27 +45,11 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
//Check if plugins intercept the request
WebResourceResponse ret = super.shouldInterceptRequest(view, url);
if(!Config.isUrlWhiteListed(url) && (url.startsWith("http://") || url.startsWith("https://")))
{
ret = getWhitelistResponse();
}
else if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpecialsInAssetUrlFix(url))){
if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){
ret = generateWebResourceResponse(url);
}
else if (ret == null && this.appView.pluginManager != null) {
ret = this.appView.pluginManager.shouldInterceptRequest(url);
}
return ret;
}
private WebResourceResponse getWhitelistResponse()
{
WebResourceResponse emptyResponse;
String empty = "";
ByteArrayInputStream data = new ByteArrayInputStream(empty.getBytes());
return new WebResourceResponse("text/plain", "UTF-8", data);
}
private WebResourceResponse generateWebResourceResponse(String url) {
if (url.startsWith("file:///android_asset/")) {
@@ -82,8 +65,8 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
}
return null;
}
private static boolean needsIceCreamSpecialsInAssetUrlFix(String url) {
private static boolean needsIceCreamSpaceInAssetUrlFix(String url) {
if (!url.contains("%20")){
return false;
}

View File

@@ -69,9 +69,8 @@ public class InAppBrowser extends CordovaPlugin {
private static final String SELF = "_self";
private static final String SYSTEM = "_system";
// private static final String BLANK = "_blank";
private static final String EXIT_EVENT = "exit";
private static final String LOCATION = "location";
private static final String HIDDEN = "hidden";
private static final String EXIT_EVENT = "exit";
private static final String LOAD_START_EVENT = "loadstart";
private static final String LOAD_STOP_EVENT = "loadstop";
private static final String LOAD_ERROR_EVENT = "loaderror";
@@ -81,9 +80,8 @@ public class InAppBrowser extends CordovaPlugin {
private Dialog dialog;
private WebView inAppWebView;
private EditText edittext;
private CallbackContext callbackContext;
private boolean showLocationBar = true;
private boolean openWindowHidden = false;
private CallbackContext callbackContext;
private String buttonLabel = "Done";
/**
@@ -187,16 +185,6 @@ public class InAppBrowser extends CordovaPlugin {
}
injectDeferredObject(args.getString(0), jsWrapper);
}
else if (action.equals("show")) {
Runnable runnable = new Runnable() {
@Override
public void run() {
dialog.show();
}
};
this.cordova.getActivity().runOnUiThread(runnable);
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
else {
return false;
}
@@ -373,16 +361,11 @@ public class InAppBrowser extends CordovaPlugin {
public String showWebPage(final String url, HashMap<String, Boolean> features) {
// Determine if we should hide the location bar.
showLocationBar = true;
openWindowHidden = false;
if (features != null) {
Boolean show = features.get(LOCATION);
if (show != null) {
showLocationBar = show.booleanValue();
}
Boolean hidden = features.get(HIDDEN);
if(hidden != null) {
openWindowHidden = hidden.booleanValue();
}
}
final CordovaWebView thatWebView = this.webView;
@@ -566,11 +549,6 @@ public class InAppBrowser extends CordovaPlugin {
dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
// the goal of openhidden is to load the url and not display it
// Show() needs to be called to cause the URL to be loaded
if(openWindowHidden) {
dialog.hide();
}
}
};
this.cordova.getActivity().runOnUiThread(runnable);

View File

@@ -24,7 +24,7 @@ import android.content.Intent;
import java.util.concurrent.ExecutorService;
/**
* The Activity interface that is implemented by CordovaActivity.
* The Cordova activity abstract class that is extended by DroidGap.
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
*/
public interface CordovaInterface {

View File

@@ -1,177 +0,0 @@
/*
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.api;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Legacy Plugin class. This acts as a shim to support the old execute() signature.
* New plugins should extend CordovaPlugin directly.
*/
@Deprecated
public abstract class Plugin extends CordovaPlugin {
public LegacyContext ctx; // LegacyContext object
public abstract PluginResult execute(String action, JSONArray args, String callbackId);
public boolean isSynch(String action) {
return false;
}
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
this.setContext(cordova);
this.setView(webView);
}
/**
* Sets the context of the Plugin. This can then be used to do things like
* get file paths associated with the Activity.
*
* @param ctx The context of the main Activity.
*/
public void setContext(CordovaInterface ctx) {
this.cordova = ctx;
this.ctx = new LegacyContext(cordova);
}
/**
* Sets the main View of the application, this is the WebView within which
* a Cordova app runs.
*
* @param webView The Cordova WebView
*/
public void setView(CordovaWebView webView) {
this.webView = webView;
}
@Override
public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
final String callbackId = callbackContext.getCallbackId();
boolean runAsync = !isSynch(action);
if (runAsync) {
// Run this on a different thread so that this one can return back to JS
cordova.getThreadPool().execute(new Runnable() {
public void run() {
PluginResult cr;
try {
cr = execute(action, args, callbackId);
} catch (Throwable e) {
cr = new PluginResult(PluginResult.Status.ERROR, e.getMessage());
}
sendPluginResult(cr, callbackId);
}
});
} else {
PluginResult cr = execute(action, args, callbackId);
// Interpret a null response as NO_RESULT, which *does* clear the callbacks on the JS side.
if (cr == null) {
cr = new PluginResult(PluginResult.Status.NO_RESULT);
}
callbackContext.sendPluginResult(cr);
}
return true;
}
/**
* Send generic JavaScript statement back to JavaScript.
* sendPluginResult() should be used instead where possible.
*/
public void sendJavascript(String statement) {
this.webView.sendJavascript(statement);
}
/**
* Send generic JavaScript statement back to JavaScript.
*/
public void sendPluginResult(PluginResult pluginResult, String callbackId) {
this.webView.sendPluginResult(pluginResult, callbackId);
}
/**
* Call the JavaScript success callback for this plugin.
*
* This can be used if the execute code for the plugin is asynchronous meaning
* that execute should return null and the callback from the async operation can
* call success(...) or error(...)
*
* @param pluginResult The result to return.
* @param callbackId The callback id used when calling back into JavaScript.
*/
public void success(PluginResult pluginResult, String callbackId) {
this.webView.sendPluginResult(pluginResult, callbackId);
}
/**
* Helper for success callbacks that just returns the Status.OK by default
*
* @param message The message to add to the success result.
* @param callbackId The callback id used when calling back into JavaScript.
*/
public void success(JSONObject message, String callbackId) {
this.webView.sendPluginResult(new PluginResult(PluginResult.Status.OK, message), callbackId);
}
/**
* Helper for success callbacks that just returns the Status.OK by default
*
* @param message The message to add to the success result.
* @param callbackId The callback id used when calling back into JavaScript.
*/
public void success(String message, String callbackId) {
this.webView.sendPluginResult(new PluginResult(PluginResult.Status.OK, message), callbackId);
}
/**
* Call the JavaScript error callback for this plugin.
*
* @param pluginResult The result to return.
* @param callbackId The callback id used when calling back into JavaScript.
*/
public void error(PluginResult pluginResult, String callbackId) {
this.webView.sendPluginResult(pluginResult, callbackId);
}
/**
* Helper for error callbacks that just returns the Status.ERROR by default
*
* @param message The message to add to the error result.
* @param callbackId The callback id used when calling back into JavaScript.
*/
public void error(JSONObject message, String callbackId) {
this.webView.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, message), callbackId);
}
/**
* Helper for error callbacks that just returns the Status.ERROR by default
*
* @param message The message to add to the error result.
* @param callbackId The callback id used when calling back into JavaScript.
*/
public void error(String message, String callbackId) {
this.webView.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, message), callbackId);
}
}

View File

@@ -73,7 +73,7 @@ public class PluginManager {
public void init() {
LOG.d(TAG, "init()");
// If first time, then load plugins from config.xml file
// If first time, then load plugins from plugins.xml file
if (this.firstRun) {
this.loadPlugins();
this.firstRun = false;
@@ -91,7 +91,7 @@ public class PluginManager {
}
/**
* Load plugins from res/xml/config.xml
* Load plugins from res/xml/plugins.xml
*/
public void loadPlugins() {
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
@@ -396,7 +396,7 @@ public class PluginManager {
private void pluginConfigurationMissing() {
LOG.e(TAG, "=====================================================================================");
LOG.e(TAG, "ERROR: config.xml is missing. Add res/xml/plugins.xml to your project.");
LOG.e(TAG, "ERROR: plugin.xml is missing. Add res/xml/plugins.xml to your project.");
LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
LOG.e(TAG, "=====================================================================================");
}

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,8 @@
Apache Cordova Team
</author>
<access origin="*.apache.org"/>
<access origin="*"/>
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />
@@ -41,9 +42,6 @@
<preference name="useBrowserHistory" value="true" />
<preference name="exit-on-suspend" value="false" />
<feature name="Activity">
<param name="android-package" value="org.apache.cordova.test.ActivityPlugin" />
</feature>
<feature name="App">
<param name="android-package" value="org.apache.cordova.App"/>
</feature>

View File

@@ -97,6 +97,7 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
super.onDestroy();
if (cordovaWebView != null) {
// Send destroy event to JavaScript
cordovaWebView.loadUrl("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
cordovaWebView.handleDestroy();
}
}