diff options
Diffstat (limited to 'Android')
-rw-r--r-- | Android/.classpath | 2 | ||||
-rwxr-xr-x | Android/cordova/appinfo.jar | bin | 0 -> 1574 bytes | |||
-rwxr-xr-x | Android/cordova/build | 39 | ||||
-rwxr-xr-x | Android/cordova/clean | 22 | ||||
-rwxr-xr-x | Android/cordova/lib/cordova | 386 | ||||
-rwxr-xr-x | Android/cordova/lib/install-device | 49 | ||||
-rwxr-xr-x | Android/cordova/lib/install-emulator | 50 | ||||
-rwxr-xr-x | Android/cordova/lib/list-devices | 30 | ||||
-rwxr-xr-x | Android/cordova/lib/list-emulator-images | 32 | ||||
-rwxr-xr-x | Android/cordova/lib/list-started-emulators | 32 | ||||
-rwxr-xr-x | Android/cordova/lib/start-emulator | 91 | ||||
-rwxr-xr-x | Android/cordova/log | 20 | ||||
-rwxr-xr-x | Android/cordova/run | 81 | ||||
-rwxr-xr-x | Android/libs/cordova-2.5.0.jar | bin | 240800 -> 0 bytes | |||
-rwxr-xr-x | Android/libs/cordova-2.9.0.jar | bin | 0 -> 446253 bytes | |||
-rwxr-xr-x | Android/res/xml/config.xml | 164 |
16 files changed, 942 insertions, 56 deletions
diff --git a/Android/.classpath b/Android/.classpath index 18a533a..373a2e7 100644 --- a/Android/.classpath +++ b/Android/.classpath @@ -2,9 +2,9 @@ <classpath> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="lib" path="libs/cordova-2.5.0.jar"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> + <classpathentry exported="true" kind="lib" path="libs/cordova-2.9.0.jar"/> <classpathentry kind="output" path="bin/classes"/> </classpath> diff --git a/Android/cordova/appinfo.jar b/Android/cordova/appinfo.jar Binary files differnew file mode 100755 index 0000000..2faa20e --- /dev/null +++ b/Android/cordova/appinfo.jar diff --git a/Android/cordova/build b/Android/cordova/build new file mode 100755 index 0000000..5ba36c0 --- /dev/null +++ b/Android/cordova/build @@ -0,0 +1,39 @@ +#!/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. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_PATH=$( cd "$DIR/.." && pwd ) + +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 diff --git a/Android/cordova/clean b/Android/cordova/clean new file mode 100755 index 0000000..b943b47 --- /dev/null +++ b/Android/cordova/clean @@ -0,0 +1,22 @@ +#!/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. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_PATH=$( cd "$DIR/.." && pwd ) +echo "Cleaning project..." +ant -f "$PROJECT_PATH/build.xml" clean diff --git a/Android/cordova/lib/cordova b/Android/cordova/lib/cordova new file mode 100755 index 0000000..294df49 --- /dev/null +++ b/Android/cordova/lib/cordova @@ -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
\ No newline at end of file diff --git a/Android/cordova/lib/install-device b/Android/cordova/lib/install-device new file mode 100755 index 0000000..e70bef7 --- /dev/null +++ b/Android/cordova/lib/install-device @@ -0,0 +1,49 @@ +#!/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. + +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 + +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 diff --git a/Android/cordova/lib/install-emulator b/Android/cordova/lib/install-emulator new file mode 100755 index 0000000..d4bffa4 --- /dev/null +++ b/Android/cordova/lib/install-emulator @@ -0,0 +1,50 @@ +#!/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. + +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 + +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 diff --git a/Android/cordova/lib/list-devices b/Android/cordova/lib/list-devices new file mode 100755 index 0000000..86d0054 --- /dev/null +++ b/Android/cordova/lib/list-devices @@ -0,0 +1,30 @@ +#!/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. + +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 diff --git a/Android/cordova/lib/list-emulator-images b/Android/cordova/lib/list-emulator-images new file mode 100755 index 0000000..202d0e5 --- /dev/null +++ b/Android/cordova/lib/list-emulator-images @@ -0,0 +1,32 @@ +#!/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. + +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 diff --git a/Android/cordova/lib/list-started-emulators b/Android/cordova/lib/list-started-emulators new file mode 100755 index 0000000..2aa6e99 --- /dev/null +++ b/Android/cordova/lib/list-started-emulators @@ -0,0 +1,32 @@ +#!/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. + +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 diff --git a/Android/cordova/lib/start-emulator b/Android/cordova/lib/start-emulator new file mode 100755 index 0000000..10e73ce --- /dev/null +++ b/Android/cordova/lib/start-emulator @@ -0,0 +1,91 @@ +#!/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. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_PATH=$( cd "$( dirname "$0" )/../.." && pwd ) + +function dot { + sleep 1 + echo -n "." +} + +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 diff --git a/Android/cordova/log b/Android/cordova/log new file mode 100755 index 0000000..f8df9cc --- /dev/null +++ b/Android/cordova/log @@ -0,0 +1,20 @@ +#!/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. + +# filter out nativeGetEnabledTags spam from latest sdk bug. +adb logcat | grep -v nativeGetEnabledTags diff --git a/Android/cordova/run b/Android/cordova/run new file mode 100755 index 0000000..4772058 --- /dev/null +++ b/Android/cordova/run @@ -0,0 +1,81 @@ +#!/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. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_PATH=$( cd "$DIR/.." && pwd ) + +function run_on_device_or_emulator { + devices=`$DIR/lib/list-devices` + if [ $? = 0 ]; then + $DIR/lib/install-device + else + run_on_emulator + fi +} + +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 diff --git a/Android/libs/cordova-2.5.0.jar b/Android/libs/cordova-2.5.0.jar Binary files differdeleted file mode 100755 index 1c3b9f0..0000000 --- a/Android/libs/cordova-2.5.0.jar +++ /dev/null diff --git a/Android/libs/cordova-2.9.0.jar b/Android/libs/cordova-2.9.0.jar Binary files differnew file mode 100755 index 0000000..ce7c1e8 --- /dev/null +++ b/Android/libs/cordova-2.9.0.jar diff --git a/Android/res/xml/config.xml b/Android/res/xml/config.xml index bacafc9..9b70ae2 100755 --- a/Android/res/xml/config.xml +++ b/Android/res/xml/config.xml @@ -1,59 +1,113 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- - 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. + 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. --> -<cordova> +<widget xmlns = "http://www.w3.org/ns/widgets" + id = "io.cordova.helloCordova" + version = "2.0.0"> + <name>Hello Cordova</name> + + <description> + A sample Apache Cordova application that responds to the deviceready event. + </description> + + <author href="http://cordova.io" email="dev@cordova.apache.org"> + Apache Cordova Team + </author> + + <access origin="*.tile.openstreetmap.org"/> + <access origin="*.tilma.mysociety.org"/> + <access origin="*.virtualearth.net"/> + <access origin="mapit.mysociety.org"/> + <access origin="struan.fixmystreet.dev.mysociety.org"/> + <access origin="192.168.1.13"/> + <access origin="debug.phonegap.com"/> + + <!-- <content src="http://mysite.com/myapp.html" /> for external pages --> + <content src="index.html" /> + + <preference name="loglevel" value="DEBUG" /> <!-- - access elements control the Android whitelist. - Domains are assumed blocked unless set otherwise - --> - - <access origin="http://127.0.0.1*"/> <!-- allow local pages --> - - <!-- <access origin="https://example.com" /> allow any secure requests to example.com --> - <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www --> - <access origin=".*"/> - - <content src="index.html"/> - - <log level="DEBUG"/> - <preference name="useBrowserHistory" value="true" /> - <preference name="exit-on-suspend" value="false" /> -<plugins> - <plugin name="App" value="org.apache.cordova.App"/> - <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/> - <plugin name="Device" value="org.apache.cordova.Device"/> - <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/> - <plugin name="Compass" value="org.apache.cordova.CompassListener"/> - <plugin name="Media" value="org.apache.cordova.AudioHandler"/> - <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="NetworkStatus" value="org.apache.cordova.NetworkManager"/> - <plugin name="Notification" value="org.apache.cordova.Notification"/> - <plugin name="Storage" value="org.apache.cordova.Storage"/> - <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/> - <plugin name="Capture" value="org.apache.cordova.Capture"/> - <plugin name="Battery" value="org.apache.cordova.BatteryListener"/> - <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/> - <plugin name="Echo" value="org.apache.cordova.Echo" /> - <plugin name="Globalization" value="org.apache.cordova.Globalization"/> - <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/> -</plugins> -</cordova> + <preference name="splashscreen" value="resourceName" /> + <preference name="backgroundColor" value="0xFFF" /> + <preference name="loadUrlTimeoutValue" value="20000" /> + <preference name="InAppBrowserStorageEnabled" value="true" /> + <preference name="disallowOverscroll" value="true" /> + --> + <feature name="App"> + <param name="android-package" value="org.apache.cordova.App"/> + </feature> + <feature name="Geolocation"> + <param name="android-package" value="org.apache.cordova.GeoBroker"/> + </feature> + <feature name="Device"> + <param name="android-package" value="org.apache.cordova.Device"/> + </feature> + <feature name="Accelerometer"> + <param name="android-package" value="org.apache.cordova.AccelListener"/> + </feature> + <feature name="Compass"> + <param name="android-package" value="org.apache.cordova.CompassListener"/> + </feature> + <feature name="Media"> + <param name="android-package" value="org.apache.cordova.AudioHandler"/> + </feature> + <feature name="Camera"> + <param name="android-package" value="org.apache.cordova.CameraLauncher"/> + </feature> + <feature name="Contacts"> + <param name="android-package" value="org.apache.cordova.ContactManager"/> + </feature> + <feature name="File"> + <param name="android-package" value="org.apache.cordova.FileUtils"/> + </feature> + <feature name="NetworkStatus"> + <param name="android-package" value="org.apache.cordova.NetworkManager"/> + </feature> + <feature name="Notification"> + <param name="android-package" value="org.apache.cordova.Notification"/> + </feature> + <feature name="Storage"> + <param name="android-package" value="org.apache.cordova.Storage"/> + </feature> + <feature name="FileTransfer"> + <param name="android-package" value="org.apache.cordova.FileTransfer"/> + </feature> + <feature name="Capture"> + <param name="android-package" value="org.apache.cordova.Capture"/> + </feature> + <feature name="Battery"> + <param name="android-package" value="org.apache.cordova.BatteryListener"/> + </feature> + <feature name="SplashScreen"> + <param name="android-package" value="org.apache.cordova.SplashScreen"/> + </feature> + <feature name="Echo"> + <param name="android-package" value="org.apache.cordova.Echo"/> + </feature> + <feature name="Globalization"> + <param name="android-package" value="org.apache.cordova.Globalization"/> + </feature> + <feature name="InAppBrowser"> + <param name="android-package" value="org.apache.cordova.InAppBrowser"/> + </feature> + <!-- Deprecated plugins element. Remove in 3.0 --> + <plugins> + </plugins> +</widget> |