forked from github/cordova-android
Rename to Cordova
This commit is contained in:
parent
fa4d6d369a
commit
664a061d10
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,14 +1,16 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
default.properties
|
default.properties
|
||||||
gen
|
gen
|
||||||
assets/www/phonegap.js
|
assets/www/cordova.js
|
||||||
local.properties
|
local.properties
|
||||||
framework/proguard.cfg
|
framework/proguard.cfg
|
||||||
framework/phonegap.jar
|
framework/cordova.jar
|
||||||
|
framework/cordova-*.jar
|
||||||
framework/phonegap-*.jar
|
framework/phonegap-*.jar
|
||||||
framework/bin
|
framework/bin
|
||||||
framework/test/com/phonegap/*.class
|
framework/test/org/apache/cordova/*.class
|
||||||
framework/assets/www/.DS_Store
|
framework/assets/www/.DS_Store
|
||||||
|
framework/assets/www/cordova-*.js
|
||||||
framework/assets/www/phonegap-*.js
|
framework/assets/www/phonegap-*.js
|
||||||
example
|
example
|
||||||
./test
|
./test
|
||||||
|
14
README.md
14
README.md
@ -23,7 +23,7 @@ Requires
|
|||||||
Building
|
Building
|
||||||
---
|
---
|
||||||
|
|
||||||
To create your phonegap.jar, run in the framework directory:
|
To create your cordova.jar, run in the framework directory:
|
||||||
|
|
||||||
android update project -p . -t android-15
|
android update project -p . -t android-15
|
||||||
ant jar
|
ant jar
|
||||||
@ -45,9 +45,9 @@ Project Commands
|
|||||||
|
|
||||||
These commands live in a generated Cordova Android project.
|
These commands live in a generated Cordova Android project.
|
||||||
|
|
||||||
./phonegap/debug [path] ..................... install to first device
|
./cordovap/debug [path] ..................... install to first device
|
||||||
./phonegap/emulate .......................... start avd (emulator) named default
|
./cordova/emulate .......................... start avd (emulator) named default
|
||||||
./phonegap/log .............................. starts logcat
|
./cordova/log .............................. starts logcat
|
||||||
|
|
||||||
Running the Example Project
|
Running the Example Project
|
||||||
---
|
---
|
||||||
@ -60,11 +60,11 @@ Create the example project and build it to the first device:
|
|||||||
|
|
||||||
./bin/create
|
./bin/create
|
||||||
cd example
|
cd example
|
||||||
./phonegap/debug
|
./cordova/debug
|
||||||
|
|
||||||
Start adb logcat (console.log calls output here):
|
Start adb logcat (console.log calls output here):
|
||||||
|
|
||||||
./phonegap/log
|
./cordova/log
|
||||||
|
|
||||||
Running the [callback/callback-test](http://github.com/callback/callback-test) tests:
|
Running the [callback/callback-test](http://github.com/callback/callback-test) tests:
|
||||||
---
|
---
|
||||||
@ -82,7 +82,7 @@ Importing a Cordova Android Project into Eclipse
|
|||||||
1. File > New > Project...
|
1. File > New > Project...
|
||||||
2. Android > Android Project
|
2. Android > Android Project
|
||||||
3. Create project from existing source (point to the generated app found in tmp/android)
|
3. Create project from existing source (point to the generated app found in tmp/android)
|
||||||
4. Right click on libs/phonegap.jar and add to build path
|
4. Right click on libs/cordova.jar and add to build path
|
||||||
5. Right click on the project root: Run as > Run Configurations
|
5. Right click on the project root: Run as > Run Configurations
|
||||||
6. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
|
6. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
|
||||||
|
|
||||||
|
2
bin/BOOM
2
bin/BOOM
@ -1,4 +1,4 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
./bin/create
|
./bin/create
|
||||||
cd ./example && ./phonegap/debug && ./phonegap/log
|
cd ./example && ./cordova/debug && ./cordova/log
|
||||||
|
12
bin/bench
12
bin/bench
@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
#
|
#
|
||||||
# Creates an app in `./bench` that posts results to http://phonegap-bench.heroku.com with current PhoneGap/Android sha.
|
# Creates an app in `./bench` that posts results to http://cordova-bench.heroku.com with current cordova/Android sha.
|
||||||
#
|
#
|
||||||
# USAGE
|
# USAGE
|
||||||
# ./bin/bench
|
# ./bin/bench
|
||||||
@ -13,17 +13,17 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# create a benching app
|
# create a benching app
|
||||||
./bin/create ./bench com.phonegap.bench PhoneGapBench
|
./bin/create ./bench org.apache.cordova.bench cordovaBench
|
||||||
|
|
||||||
# grab the latest bench www code
|
# grab the latest bench www code
|
||||||
git clone git@github.com:brianleroux/phonegap-bench.git
|
git clone git@github.com:brianleroux/cordova-bench.git
|
||||||
|
|
||||||
# copy it into the app
|
# copy it into the app
|
||||||
cat ./phonegap-bench/www/index.html > ./bench/assets/www/index.html
|
cat ./cordova-bench/www/index.html > ./bench/assets/www/index.html
|
||||||
#cat ~/Desktop/phonegap-bench/www/index.html > ./bench/assets/www/index.html
|
#cat ~/Desktop/cordova-bench/www/index.html > ./bench/assets/www/index.html
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
rm -rf ./phonegap-bench
|
rm -rf ./cordova-bench
|
||||||
|
|
||||||
# launch to the first device found
|
# launch to the first device found
|
||||||
./bin/debug ./bench
|
./bin/debug ./bench
|
||||||
|
22
bin/create
22
bin/create
@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
#
|
#
|
||||||
# create a phonegap/android project
|
# create a cordova/android project
|
||||||
#
|
#
|
||||||
# USAGE
|
# USAGE
|
||||||
# ./create [path package activity]
|
# ./create [path package activity]
|
||||||
@ -8,8 +8,8 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
PROJECT_PATH=${1:-"./example"}
|
PROJECT_PATH=${1:-"./example"}
|
||||||
PACKAGE=${2:-"com.phonegap.example"}
|
PACKAGE=${2:-"org.apache.cordova.example"}
|
||||||
ACTIVITY=${3:-"PhoneGapExample"}
|
ACTIVITY=${3:-"cordovaExample"}
|
||||||
TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]*\).*/\1/g' | tail -1)
|
TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]*\).*/\1/g' | tail -1)
|
||||||
VERSION=$(cat ./VERSION)
|
VERSION=$(cat ./VERSION)
|
||||||
|
|
||||||
@ -19,23 +19,23 @@ then
|
|||||||
rm -rf $PROJECT_PATH
|
rm -rf $PROJECT_PATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update the phonegap-android framework for the desired target
|
# update the cordova-android framework for the desired target
|
||||||
android update project --target $TARGET --path ./framework
|
android update project --target $TARGET --path ./framework
|
||||||
|
|
||||||
# compile phonegap.js and phonegap.jar
|
# compile cordova.js and cordova.jar
|
||||||
cd ./framework && ant jar && cd ../
|
cd ./framework && ant jar && cd ../
|
||||||
|
|
||||||
# copy all the bin scripts etc in there
|
# copy all the bin scripts etc in there
|
||||||
cp -R ./bin/templates/project/ $PROJECT_PATH
|
cp -R ./bin/templates/project/ $PROJECT_PATH
|
||||||
|
|
||||||
# copy in phonegap.js
|
# copy in cordova.js
|
||||||
cp ./framework/assets/www/phonegap-$VERSION.js $PROJECT_PATH/.phonegap/android/phonegap-$VERSION.js
|
cp ./framework/assets/www/cordova-$VERSION.js $PROJECT_PATH/.cordova/android/cordova-$VERSION.js
|
||||||
|
|
||||||
# copy in phonegap.jar
|
# copy in cordova.jar
|
||||||
cp ./framework/phonegap-$VERSION.jar $PROJECT_PATH/.phonegap/android/phonegap-$VERSION.jar
|
cp ./framework/cordova-$VERSION.jar $PROJECT_PATH/.cordova/android/cordova-$VERSION.jar
|
||||||
|
|
||||||
# app properties
|
# app properties
|
||||||
cat > $PROJECT_PATH/.phonegap/config <<eom
|
cat > $PROJECT_PATH/.cordova/config <<eom
|
||||||
VERSION=$VERSION
|
VERSION=$VERSION
|
||||||
PROJECT_PATH=$PROJECT_PATH
|
PROJECT_PATH=$PROJECT_PATH
|
||||||
PACKAGE=$PACKAGE
|
PACKAGE=$PACKAGE
|
||||||
@ -43,4 +43,4 @@ ACTIVITY=$ACTIVITY
|
|||||||
TARGET=$TARGET
|
TARGET=$TARGET
|
||||||
eom
|
eom
|
||||||
|
|
||||||
(cd $PROJECT_PATH && ./phonegap/create)
|
(cd $PROJECT_PATH && ./cordova/create)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* create a phonegap/android project
|
* create a cordova/android project
|
||||||
*
|
*
|
||||||
* USAGE
|
* USAGE
|
||||||
* ./create [path package activity]
|
* ./create [path package activity]
|
||||||
@ -26,7 +26,7 @@ function exec(s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var args = WScript.Arguments, PROJECT_PATH="example",
|
var args = WScript.Arguments, PROJECT_PATH="example",
|
||||||
PACKAGE="com.phonegap.example", ACTIVITY="PhoneGapExample",
|
PACKAGE="org.apache.cordova.example", ACTIVITY="cordovaExample",
|
||||||
shell=WScript.CreateObject("WScript.Shell");
|
shell=WScript.CreateObject("WScript.Shell");
|
||||||
|
|
||||||
if (args.Count() == 3) {
|
if (args.Count() == 3) {
|
||||||
@ -54,10 +54,10 @@ fi
|
|||||||
// create the project
|
// create the project
|
||||||
exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
|
exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
|
||||||
|
|
||||||
// update the phonegap framework project to a target that exists on this machine
|
// update the cordova framework project to a target that exists on this machine
|
||||||
exec('android.bat update project --target '+TARGET+' --path framework');
|
exec('android.bat update project --target '+TARGET+' --path framework');
|
||||||
|
|
||||||
// compile phonegap.js and phonegap.jar
|
// compile cordova.js and cordova.jar
|
||||||
// if you see an error about "Unable to resolve target" then you may need to
|
// if you see an error about "Unable to resolve target" then you may need to
|
||||||
// update your android tools or install an additional Android platform version
|
// update your android tools or install an additional Android platform version
|
||||||
exec('ant.bat -f framework\\build.xml jar');
|
exec('ant.bat -f framework\\build.xml jar');
|
||||||
@ -65,11 +65,11 @@ exec('ant.bat -f framework\\build.xml jar');
|
|||||||
// copy in the project template
|
// copy in the project template
|
||||||
exec('cmd /c xcopy bin\\templates\\project '+PROJECT_PATH+' /S /Y');
|
exec('cmd /c xcopy bin\\templates\\project '+PROJECT_PATH+' /S /Y');
|
||||||
|
|
||||||
// copy in phonegap.js
|
// copy in cordova.js
|
||||||
exec('cmd /c copy framework\\assets\\www\\phonegap-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\phonegap-'+VERSION+'.js /Y');
|
exec('cmd /c copy framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
|
||||||
|
|
||||||
// copy in phonegap.jar
|
// copy in cordova.jar
|
||||||
exec('cmd /c copy framework\\phonegap-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\phonegap-'+VERSION+'.jar /Y');
|
exec('cmd /c copy framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
|
||||||
|
|
||||||
// copy in default activity
|
// copy in default activity
|
||||||
exec('cmd /c copy bin\\templates\\Activity.java '+ACTIVITY_PATH+' /Y');
|
exec('cmd /c copy bin\\templates\\Activity.java '+ACTIVITY_PATH+' /Y');
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="PhoneGap" default="create" basedir="../">
|
<project name="cordova" default="create" basedir="../">
|
||||||
|
|
||||||
<property name="project.path" value="${basedir}/example"/>
|
<property name="project.path" value="${basedir}/example"/>
|
||||||
<property name="package" value="com.phonegap.example"/>
|
<property name="package" value="org.apache.cordova.example"/>
|
||||||
<property name="activity" value="PhoneGapExample"/>
|
<property name="activity" value="cordovaExample"/>
|
||||||
|
|
||||||
<target name="create">
|
<target name="create">
|
||||||
|
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<arg line="update project --target ${target} --path ${basedir}/framework"/>
|
<arg line="update project --target ${target} --path ${basedir}/framework"/>
|
||||||
</exec>
|
</exec>
|
||||||
|
|
||||||
<!-- compile phonegap.js and phonegap.jar -->
|
<!-- compile cordova.js and cordova.jar -->
|
||||||
<!-- // if you see an error about "Unable to resolve target" then you may need to
|
<!-- // if you see an error about "Unable to resolve target" then you may need to
|
||||||
// update your android tools or install an additional Android platform version -->
|
// update your android tools or install an additional Android platform version -->
|
||||||
<ant antfile="${basedir}/framework/build.xml" useNativeBasedir="true" inheritAll="false" />
|
<ant antfile="${basedir}/framework/build.xml" useNativeBasedir="true" inheritAll="false" />
|
||||||
@ -60,11 +60,11 @@
|
|||||||
<fileset dir="${basedir}/bin/templates/project"/>
|
<fileset dir="${basedir}/bin/templates/project"/>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<!-- copy in phonegap.js -->
|
<!-- copy in cordova.js -->
|
||||||
<copy file="${basedir}/framework/assets/www/phonegap-${version}.js" todir="${project.path}/assets/www/" />
|
<copy file="${basedir}/framework/assets/www/cordova-${version}.js" todir="${project.path}/assets/www/" />
|
||||||
|
|
||||||
<!-- copy in phonegap.jar -->
|
<!-- copy in cordova.jar -->
|
||||||
<copy file="${basedir}/framework/phonegap-${version}.jar" todir="${project.path}/libs/" />
|
<copy file="${basedir}/framework/cordova-${version}.jar" todir="${project.path}/libs/" />
|
||||||
|
|
||||||
<!-- copy in default activity -->
|
<!-- copy in default activity -->
|
||||||
<copy file="${basedir}/bin/templates/Activity.java" tofile="${activity.path}" overwrite="true" />
|
<copy file="${basedir}/bin/templates/Activity.java" tofile="${activity.path}" overwrite="true" />
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
this is local config for phonegap stuff to be eventually moved to
|
this is local config for cordova stuff to be eventually moved to
|
||||||
config.xml ...we think. feedback to @davejohnson/@brianleroux
|
config.xml ...we think. feedback to @davejohnson/@brianleroux
|
||||||
appreciated here!
|
appreciated here!
|
@ -1,13 +1,13 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
#
|
#
|
||||||
# create a phonegap/android project
|
# create a cordova/android project
|
||||||
#
|
#
|
||||||
# USAGE
|
# USAGE
|
||||||
# ./create [path package activity]
|
# ./create [path package activity]
|
||||||
#
|
#
|
||||||
|
|
||||||
# load up the config
|
# load up the config
|
||||||
. ./.phonegap/config
|
. ./.cordova/config
|
||||||
|
|
||||||
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
|
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
|
||||||
ACTIVITY_PATH=./src/$PACKAGE_AS_PATH/$ACTIVITY.java
|
ACTIVITY_PATH=./src/$PACKAGE_AS_PATH/$ACTIVITY.java
|
||||||
@ -16,17 +16,17 @@ MANIFEST_PATH=./AndroidManifest.xml
|
|||||||
# create the project
|
# create the project
|
||||||
android create project --target $TARGET --path . --package $PACKAGE --activity $ACTIVITY
|
android create project --target $TARGET --path . --package $PACKAGE --activity $ACTIVITY
|
||||||
|
|
||||||
# copy all the phonegap scripts etc in there
|
# copy all the cordova scripts etc in there
|
||||||
cp -R ./phonegap/templates/project/* .
|
cp -R ./cordova/templates/project/* .
|
||||||
|
|
||||||
# copy in phonegap.js
|
# copy in cordova.js
|
||||||
cp ./.phonegap/android/phonegap-$VERSION.js ./assets/www
|
cp ./.cordova/android/cordova-$VERSION.js ./assets/www
|
||||||
|
|
||||||
# copy in phonegap.jar
|
# copy in cordova.jar
|
||||||
cp ./.phonegap/android/phonegap-$VERSION.jar ./libs
|
cp ./.cordova/android/cordova-$VERSION.jar ./libs
|
||||||
|
|
||||||
# copy in default activity
|
# copy in default activity
|
||||||
cat ./phonegap/templates/Activity.java > $ACTIVITY_PATH
|
cat ./cordova/templates/Activity.java > $ACTIVITY_PATH
|
||||||
|
|
||||||
# interpolate the acivity name and package
|
# interpolate the acivity name and package
|
||||||
find "$ACTIVITY_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i -e "s/__ACTIVITY__/${ACTIVITY}/g"
|
find "$ACTIVITY_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i -e "s/__ACTIVITY__/${ACTIVITY}/g"
|
@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
. ./.phonegap/config
|
. ./.cordova/config
|
||||||
|
|
||||||
# if there are no devices listed then emulate
|
# if there are no devices listed then emulate
|
||||||
|
|
@ -2,7 +2,7 @@ package __ID__;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.phonegap.*;
|
import org.apache.cordova.*;
|
||||||
|
|
||||||
public class __ACTIVITY__ extends DroidGap
|
public class __ACTIVITY__ extends DroidGap
|
||||||
{
|
{
|
@ -39,7 +39,7 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name"
|
<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden">
|
android:configChanges="orientation|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
</intent-filter>
|
</intent-filter>
|
@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>PhoneGap</title>
|
<title>PhoneGap</title>
|
||||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
|
||||||
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
|
<script type="text/javascript" charset="utf-8" src="cordova-1.4.1.js"></script>
|
||||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<phonegap>
|
<cordova>
|
||||||
<access origin="http://127.0.0.1*"/>
|
<access origin="http://127.0.0.1*"/>
|
||||||
<log level="DEBUG"/>
|
<log level="DEBUG"/>
|
||||||
</phonegap>
|
</cordova>
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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="Network Status" value="org.apache.cordova.NetworkManager"/>
|
||||||
|
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
||||||
|
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
||||||
|
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>
|
||||||
|
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
||||||
|
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
||||||
|
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
||||||
|
</plugins>
|
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<plugins>
|
|
||||||
<plugin name="App" value="com.phonegap.App"/>
|
|
||||||
<plugin name="Geolocation" value="com.phonegap.GeoBroker"/>
|
|
||||||
<plugin name="Device" value="com.phonegap.Device"/>
|
|
||||||
<plugin name="Accelerometer" value="com.phonegap.AccelListener"/>
|
|
||||||
<plugin name="Compass" value="com.phonegap.CompassListener"/>
|
|
||||||
<plugin name="Media" value="com.phonegap.AudioHandler"/>
|
|
||||||
<plugin name="Camera" value="com.phonegap.CameraLauncher"/>
|
|
||||||
<plugin name="Contacts" value="com.phonegap.ContactManager"/>
|
|
||||||
<plugin name="Crypto" value="com.phonegap.CryptoHandler"/>
|
|
||||||
<plugin name="File" value="com.phonegap.FileUtils"/>
|
|
||||||
<plugin name="Network Status" value="com.phonegap.NetworkManager"/>
|
|
||||||
<plugin name="Notification" value="com.phonegap.Notification"/>
|
|
||||||
<plugin name="Storage" value="com.phonegap.Storage"/>
|
|
||||||
<plugin name="Temperature" value="com.phonegap.TempListener"/>
|
|
||||||
<plugin name="FileTransfer" value="com.phonegap.FileTransfer"/>
|
|
||||||
<plugin name="Capture" value="com.phonegap.Capture"/>
|
|
||||||
</plugins>
|
|
8
bin/test
8
bin/test
@ -13,14 +13,14 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# generate a working proj
|
# generate a working proj
|
||||||
./bin/create ./test com.phonegap.test PhoneGapTest
|
./bin/create ./test org.apache.cordova.test CordovaTest
|
||||||
|
|
||||||
# kill the default app and replace it w/ mobile-spec
|
# kill the default app and replace it w/ mobile-spec
|
||||||
rm -rf ./test/assets/www
|
rm -rf ./test/assets/www
|
||||||
mv ./callback-test ./test/assets/www
|
mv ./callback-test ./test/assets/www
|
||||||
|
|
||||||
# copy in phonegap.js since www dir was replaced above
|
# copy in cordova.js since www dir was replaced above
|
||||||
cp ./framework/assets/www/phonegap-$VERSION.js ./test/assets/www/phonegap-$VERSION.js
|
cp ./framework/assets/www/cordova-$VERSION.js ./test/assets/www/cordova-$VERSION.js
|
||||||
|
|
||||||
# build it, launch it and start logging on stdout
|
# build it, launch it and start logging on stdout
|
||||||
cd ./test && ./phonegap/debug && ./phonegap/log
|
cd ./test && ./cordova/debug && ./cordova/log
|
||||||
|
@ -8,14 +8,14 @@ exports['default example project is generated'] = (test) ->
|
|||||||
test.ok true, "this assertion should pass" unless error?
|
test.ok true, "this assertion should pass" unless error?
|
||||||
test.done()
|
test.done()
|
||||||
|
|
||||||
exports['default example project has a ./.phonegap folder'] = (test) ->
|
exports['default example project has a ./.cordova folder'] = (test) ->
|
||||||
test.expect 1
|
test.expect 1
|
||||||
path.exists './example/.phonegap', (exists) ->
|
path.exists './example/.cordova', (exists) ->
|
||||||
test.ok exists, 'the phonegap folder exists'
|
test.ok exists, 'the cordova folder exists'
|
||||||
test.done()
|
test.done()
|
||||||
|
|
||||||
exports['default example project has a /phonegap folder'] = (test) ->
|
exports['default example project has a /cordova folder'] = (test) ->
|
||||||
test.expect 1
|
test.expect 1
|
||||||
path.exists './example/phonegap', (exists) ->
|
path.exists './example/cordova', (exists) ->
|
||||||
test.ok exists, 'the other phonegap folder exists'
|
test.ok exists, 'the other cordova folder exists'
|
||||||
test.done()
|
test.done()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>PhoneGap</name>
|
<name>Cordova</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
|
||||||
package="com.phonegap" android:versionName="1.1" android:versionCode="5">
|
package="org.apache.cordova" android:versionName="1.1" android:versionCode="5">
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:largeScreens="true"
|
android:largeScreens="true"
|
||||||
android:normalScreens="true"
|
android:normalScreens="true"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name"
|
<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden">
|
android:configChanges="orientation|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("accelerometer")) {
|
if (!Cordova.hasResource("accelerometer")) {
|
||||||
PhoneGap.addResource("accelerometer");
|
Cordova.addResource("accelerometer");
|
||||||
|
|
||||||
/** @constructor */
|
/** @constructor */
|
||||||
var Acceleration = function(x, y, z) {
|
var Acceleration = function(x, y, z) {
|
||||||
@ -69,7 +69,7 @@ Accelerometer.prototype.getCurrentAcceleration = function(successCallback, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get acceleration
|
// Get acceleration
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
Cordova.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,18 +98,18 @@ Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure accelerometer timeout > frequency + 10 sec
|
// Make sure accelerometer timeout > frequency + 10 sec
|
||||||
PhoneGap.exec(
|
Cordova.exec(
|
||||||
function(timeout) {
|
function(timeout) {
|
||||||
if (timeout < (frequency + 10000)) {
|
if (timeout < (frequency + 10000)) {
|
||||||
PhoneGap.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
Cordova.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(e) { }, "Accelerometer", "getTimeout", []);
|
function(e) { }, "Accelerometer", "getTimeout", []);
|
||||||
|
|
||||||
// Start watch timer
|
// Start watch timer
|
||||||
var id = PhoneGap.createUUID();
|
var id = Cordova.createUUID();
|
||||||
navigator.accelerometer.timers[id] = setInterval(function() {
|
navigator.accelerometer.timers[id] = setInterval(function() {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
Cordova.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||||
}, (frequency ? frequency : 1));
|
}, (frequency ? frequency : 1));
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
@ -129,7 +129,7 @@ Accelerometer.prototype.clearWatch = function(id) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.accelerometer === "undefined") {
|
if (typeof navigator.accelerometer === "undefined") {
|
||||||
navigator.accelerometer = new Accelerometer();
|
navigator.accelerometer = new Accelerometer();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("app")) {
|
if (!Cordova.hasResource("app")) {
|
||||||
PhoneGap.addResource("app");
|
Cordova.addResource("app");
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ var App = function() {};
|
|||||||
* Clear the resource cache.
|
* Clear the resource cache.
|
||||||
*/
|
*/
|
||||||
App.prototype.clearCache = function() {
|
App.prototype.clearCache = function() {
|
||||||
PhoneGap.exec(null, null, "App", "clearCache", []);
|
Cordova.exec(null, null, "App", "clearCache", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,14 +49,14 @@ App.prototype.clearCache = function() {
|
|||||||
* navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
|
* navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
|
||||||
*/
|
*/
|
||||||
App.prototype.loadUrl = function(url, props) {
|
App.prototype.loadUrl = function(url, props) {
|
||||||
PhoneGap.exec(null, null, "App", "loadUrl", [url, props]);
|
Cordova.exec(null, null, "App", "loadUrl", [url, props]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel loadUrl that is waiting to be loaded.
|
* Cancel loadUrl that is waiting to be loaded.
|
||||||
*/
|
*/
|
||||||
App.prototype.cancelLoadUrl = function() {
|
App.prototype.cancelLoadUrl = function() {
|
||||||
PhoneGap.exec(null, null, "App", "cancelLoadUrl", []);
|
Cordova.exec(null, null, "App", "cancelLoadUrl", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ App.prototype.cancelLoadUrl = function() {
|
|||||||
* Instead of BACK button loading the previous web page, it will exit the app.
|
* Instead of BACK button loading the previous web page, it will exit the app.
|
||||||
*/
|
*/
|
||||||
App.prototype.clearHistory = function() {
|
App.prototype.clearHistory = function() {
|
||||||
PhoneGap.exec(null, null, "App", "clearHistory", []);
|
Cordova.exec(null, null, "App", "clearHistory", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,17 +72,17 @@ App.prototype.clearHistory = function() {
|
|||||||
* This is the same as pressing the backbutton on Android device.
|
* This is the same as pressing the backbutton on Android device.
|
||||||
*/
|
*/
|
||||||
App.prototype.backHistory = function() {
|
App.prototype.backHistory = function() {
|
||||||
PhoneGap.exec(null, null, "App", "backHistory", []);
|
Cordova.exec(null, null, "App", "backHistory", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exit and terminate the application.
|
* Exit and terminate the application.
|
||||||
*/
|
*/
|
||||||
App.prototype.exitApp = function() {
|
App.prototype.exitApp = function() {
|
||||||
return PhoneGap.exec(null, null, "App", "exitApp", []);
|
return Cordova.exec(null, null, "App", "exitApp", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
navigator.app = new App();
|
navigator.app = new App();
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("battery")) {
|
if (!Cordova.hasResource("battery")) {
|
||||||
PhoneGap.addResource("battery");
|
Cordova.addResource("battery");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains information about the current battery status.
|
* This class contains information about the current battery status.
|
||||||
@ -44,7 +44,7 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
|
|||||||
if (add) {
|
if (add) {
|
||||||
// If there are no current registered event listeners start the battery listener on native side.
|
// If there are no current registered event listeners start the battery listener on native side.
|
||||||
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
||||||
PhoneGap.exec(me._status, me._error, "Battery", "start", []);
|
Cordova.exec(me._status, me._error, "Battery", "start", []);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the event listener in the proper array
|
// Register the event listener in the proper array
|
||||||
@ -83,7 +83,7 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
|
|||||||
|
|
||||||
// If there are no more registered event listeners stop the battery listener on native side.
|
// If there are no more registered event listeners stop the battery listener on native side.
|
||||||
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
||||||
PhoneGap.exec(null, null, "Battery", "stop", []);
|
Cordova.exec(null, null, "Battery", "stop", []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -99,15 +99,15 @@ Battery.prototype._status = function(info) {
|
|||||||
var level = info.level;
|
var level = info.level;
|
||||||
if (me._level !== level || me._isPlugged !== info.isPlugged) {
|
if (me._level !== level || me._isPlugged !== info.isPlugged) {
|
||||||
// Fire batterystatus event
|
// Fire batterystatus event
|
||||||
PhoneGap.fireWindowEvent("batterystatus", info);
|
Cordova.fireWindowEvent("batterystatus", info);
|
||||||
|
|
||||||
// Fire low battery event
|
// Fire low battery event
|
||||||
if (level === 20 || level === 5) {
|
if (level === 20 || level === 5) {
|
||||||
if (level === 20) {
|
if (level === 20) {
|
||||||
PhoneGap.fireWindowEvent("batterylow", info);
|
Cordova.fireWindowEvent("batterylow", info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PhoneGap.fireWindowEvent("batterycritical", info);
|
Cordova.fireWindowEvent("batterycritical", info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,12 +123,12 @@ Battery.prototype._error = function(e) {
|
|||||||
console.log("Error initializing Battery: " + e);
|
console.log("Error initializing Battery: " + e);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.battery === "undefined") {
|
if (typeof navigator.battery === "undefined") {
|
||||||
navigator.battery = new Battery();
|
navigator.battery = new Battery();
|
||||||
PhoneGap.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
|
Cordova.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
|
||||||
PhoneGap.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
|
Cordova.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
|
||||||
PhoneGap.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
|
Cordova.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("camera")) {
|
if (!Cordova.hasResource("camera")) {
|
||||||
PhoneGap.addResource("camera");
|
Cordova.addResource("camera");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides access to the device camera.
|
* This class provides access to the device camera.
|
||||||
@ -157,10 +157,10 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Camera", "takePicture", [options]);
|
Cordova.exec(successCallback, errorCallback, "Camera", "takePicture", [options]);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.camera === "undefined") {
|
if (typeof navigator.camera === "undefined") {
|
||||||
navigator.camera = new Camera();
|
navigator.camera = new Camera();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("capture")) {
|
if (!Cordova.hasResource("capture")) {
|
||||||
PhoneGap.addResource("capture");
|
Cordova.addResource("capture");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single file.
|
* Represents a single file.
|
||||||
@ -44,7 +44,7 @@ var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
|
|||||||
* @param {Function} errorCB
|
* @param {Function} errorCB
|
||||||
*/
|
*/
|
||||||
MediaFile.prototype.getFormatData = function(successCallback, errorCallback){
|
MediaFile.prototype.getFormatData = function(successCallback, errorCallback){
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
|
Cordova.exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +95,7 @@ var Capture = function(){
|
|||||||
* @param {CaptureAudioOptions} options
|
* @param {CaptureAudioOptions} options
|
||||||
*/
|
*/
|
||||||
Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
|
Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "captureAudio", [options]);
|
Cordova.exec(successCallback, errorCallback, "Capture", "captureAudio", [options]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +106,7 @@ Capture.prototype.captureAudio = function(successCallback, errorCallback, option
|
|||||||
* @param {CaptureImageOptions} options
|
* @param {CaptureImageOptions} options
|
||||||
*/
|
*/
|
||||||
Capture.prototype.captureImage = function(successCallback, errorCallback, options){
|
Capture.prototype.captureImage = function(successCallback, errorCallback, options){
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "captureImage", [options]);
|
Cordova.exec(successCallback, errorCallback, "Capture", "captureImage", [options]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,7 +140,7 @@ Capture.prototype._castMediaFile = function(pluginResult){
|
|||||||
* @param {CaptureVideoOptions} options
|
* @param {CaptureVideoOptions} options
|
||||||
*/
|
*/
|
||||||
Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
|
Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "captureVideo", [options]);
|
Cordova.exec(successCallback, errorCallback, "Capture", "captureVideo", [options]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,7 +191,7 @@ var CaptureAudioOptions = function(){
|
|||||||
this.mode = null;
|
this.mode = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function(){
|
Cordova.addConstructor(function(){
|
||||||
if (typeof navigator.device.capture === "undefined") {
|
if (typeof navigator.device.capture === "undefined") {
|
||||||
navigator.device.capture = window.device.capture = new Capture();
|
navigator.device.capture = window.device.capture = new Capture();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("compass")) {
|
if (!Cordova.hasResource("compass")) {
|
||||||
PhoneGap.addResource("compass");
|
Cordova.addResource("compass");
|
||||||
|
|
||||||
var CompassError = function(){
|
var CompassError = function(){
|
||||||
this.code = null;
|
this.code = null;
|
||||||
@ -75,7 +75,7 @@ Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get heading
|
// Get heading
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,19 +104,19 @@ Compass.prototype.watchHeading= function(successCallback, errorCallback, options
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure compass timeout > frequency + 10 sec
|
// Make sure compass timeout > frequency + 10 sec
|
||||||
PhoneGap.exec(
|
Cordova.exec(
|
||||||
function(timeout) {
|
function(timeout) {
|
||||||
if (timeout < (frequency + 10000)) {
|
if (timeout < (frequency + 10000)) {
|
||||||
PhoneGap.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
Cordova.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(e) { }, "Compass", "getTimeout", []);
|
function(e) { }, "Compass", "getTimeout", []);
|
||||||
|
|
||||||
// Start watch timer to get headings
|
// Start watch timer to get headings
|
||||||
var id = PhoneGap.createUUID();
|
var id = Cordova.createUUID();
|
||||||
navigator.compass.timers[id] = setInterval(
|
navigator.compass.timers[id] = setInterval(
|
||||||
function() {
|
function() {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||||
}, (frequency ? frequency : 1));
|
}, (frequency ? frequency : 1));
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
@ -145,7 +145,7 @@ Compass.prototype._castDate = function(pluginResult) {
|
|||||||
return pluginResult;
|
return pluginResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.compass === "undefined") {
|
if (typeof navigator.compass === "undefined") {
|
||||||
navigator.compass = new Compass();
|
navigator.compass = new Compass();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("contact")) {
|
if (!Cordova.hasResource("contact")) {
|
||||||
PhoneGap.addResource("contact");
|
Cordova.addResource("contact");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains information about a single contact.
|
* Contains information about a single contact.
|
||||||
@ -89,7 +89,7 @@ Contact.prototype.remove = function(successCB, errorCB) {
|
|||||||
errorCB(errorObj);
|
errorCB(errorObj);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PhoneGap.exec(successCB, errorCB, "Contacts", "remove", [this.id]);
|
Cordova.exec(successCB, errorCB, "Contacts", "remove", [this.id]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ Contact.prototype.remove = function(successCB, errorCB) {
|
|||||||
* @return copy of this Contact
|
* @return copy of this Contact
|
||||||
*/
|
*/
|
||||||
Contact.prototype.clone = function() {
|
Contact.prototype.clone = function() {
|
||||||
var clonedContact = PhoneGap.clone(this);
|
var clonedContact = Cordova.clone(this);
|
||||||
var i;
|
var i;
|
||||||
clonedContact.id = null;
|
clonedContact.id = null;
|
||||||
clonedContact.rawId = null;
|
clonedContact.rawId = null;
|
||||||
@ -153,7 +153,7 @@ Contact.prototype.clone = function() {
|
|||||||
* @param errorCB error callback
|
* @param errorCB error callback
|
||||||
*/
|
*/
|
||||||
Contact.prototype.save = function(successCB, errorCB) {
|
Contact.prototype.save = function(successCB, errorCB) {
|
||||||
PhoneGap.exec(successCB, errorCB, "Contacts", "save", [this]);
|
Cordova.exec(successCB, errorCB, "Contacts", "save", [this]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,7 +259,7 @@ Contacts.prototype.find = function(fields, successCB, errorCB, options) {
|
|||||||
errorCB({"code": ContactError.INVALID_ARGUMENT_ERROR});
|
errorCB({"code": ContactError.INVALID_ARGUMENT_ERROR});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
|
Cordova.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ var ContactFindOptions = function(filter, multiple) {
|
|||||||
/**
|
/**
|
||||||
* Add the contact interface into the browser.
|
* Add the contact interface into the browser.
|
||||||
*/
|
*/
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if(typeof navigator.contacts === "undefined") {
|
if(typeof navigator.contacts === "undefined") {
|
||||||
navigator.contacts = new Contacts();
|
navigator.contacts = new Contacts();
|
||||||
}
|
}
|
||||||
|
@ -17,26 +17,24 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Version 1.2.0
|
if (typeof Cordova === "undefined") {
|
||||||
|
|
||||||
if (typeof PhoneGap === "undefined") {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The order of events during page load and PhoneGap startup is as follows:
|
* The order of events during page load and Cordova startup is as follows:
|
||||||
*
|
*
|
||||||
* onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
|
* onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
|
||||||
* window.onload Body onload event.
|
* window.onload Body onload event.
|
||||||
* onNativeReady Internal event that indicates the PhoneGap native side is ready.
|
* onNativeReady Internal event that indicates the Cordova native side is ready.
|
||||||
* onPhoneGapInit Internal event that kicks off creation of all PhoneGap JavaScript objects (runs constructors).
|
* onCordovaInit Internal event that kicks off creation of all Cordova JavaScript objects (runs constructors).
|
||||||
* onPhoneGapReady Internal event fired when all PhoneGap JavaScript objects have been created
|
* onCordovaReady Internal event fired when all Cordova JavaScript objects have been created
|
||||||
* onPhoneGapInfoReady Internal event fired when device properties are available
|
* onCordovaInfoReady Internal event fired when device properties are available
|
||||||
* onDeviceReady User event fired to indicate that PhoneGap is ready
|
* onDeviceReady User event fired to indicate that Cordova is ready
|
||||||
* onResume User event fired to indicate a start/resume lifecycle event
|
* onResume User event fired to indicate a start/resume lifecycle event
|
||||||
* onPause User event fired to indicate a pause lifecycle event
|
* onPause User event fired to indicate a pause lifecycle event
|
||||||
* onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
|
* onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
|
||||||
*
|
*
|
||||||
* The only PhoneGap events that user code should register for are:
|
* The only Cordova events that user code should register for are:
|
||||||
* deviceready PhoneGap native code is initialized and PhoneGap APIs can be called from JavaScript
|
* deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
|
||||||
* pause App has moved to background
|
* pause App has moved to background
|
||||||
* resume App has returned to foreground
|
* resume App has returned to foreground
|
||||||
*
|
*
|
||||||
@ -51,45 +49,45 @@ if (typeof PhoneGap === "undefined") {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents the PhoneGap API itself, and provides a global namespace for accessing
|
* This represents the Cordova API itself, and provides a global namespace for accessing
|
||||||
* information about the state of PhoneGap.
|
* information about the state of Cordova.
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var PhoneGap = {
|
var Cordova = {
|
||||||
documentEventHandler: {}, // Collection of custom document event handlers
|
documentEventHandler: {}, // Collection of custom document event handlers
|
||||||
windowEventHandler: {} // Collection of custom window event handlers
|
windowEventHandler: {} // Collection of custom window event handlers
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of resource files loaded by PhoneGap.
|
* List of resource files loaded by Cordova.
|
||||||
* This is used to ensure JS and other files are loaded only once.
|
* This is used to ensure JS and other files are loaded only once.
|
||||||
*/
|
*/
|
||||||
PhoneGap.resources = {base: true};
|
Cordova.resources = {base: true};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if resource has been loaded by PhoneGap
|
* Determine if resource has been loaded by Cordova
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PhoneGap.hasResource = function(name) {
|
Cordova.hasResource = function(name) {
|
||||||
return PhoneGap.resources[name];
|
return Cordova.resources[name];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a resource to list of loaded resources by PhoneGap
|
* Add a resource to list of loaded resources by Cordova
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
PhoneGap.addResource = function(name) {
|
Cordova.addResource = function(name) {
|
||||||
PhoneGap.resources[name] = true;
|
Cordova.resources[name] = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom pub-sub channel that can have functions subscribed to it
|
* Custom pub-sub channel that can have functions subscribed to it
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel = function (type)
|
Cordova.Channel = function (type)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.handlers = {};
|
this.handlers = {};
|
||||||
@ -105,12 +103,12 @@ PhoneGap.Channel = function (type)
|
|||||||
* and a guid that can be used to stop subscribing to the channel.
|
* and a guid that can be used to stop subscribing to the channel.
|
||||||
* Returns the guid.
|
* Returns the guid.
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel.prototype.subscribe = function(f, c, g) {
|
Cordova.Channel.prototype.subscribe = function(f, c, g) {
|
||||||
// need a function to call
|
// need a function to call
|
||||||
if (f === null) { return; }
|
if (f === null) { return; }
|
||||||
|
|
||||||
var func = f;
|
var func = f;
|
||||||
if (typeof c === "object" && typeof f === "function") { func = PhoneGap.close(c, f); }
|
if (typeof c === "object" && typeof f === "function") { func = Cordova.close(c, f); }
|
||||||
|
|
||||||
g = g || func.observer_guid || f.observer_guid || this.guid++;
|
g = g || func.observer_guid || f.observer_guid || this.guid++;
|
||||||
func.observer_guid = g;
|
func.observer_guid = g;
|
||||||
@ -123,7 +121,7 @@ PhoneGap.Channel.prototype.subscribe = function(f, c, g) {
|
|||||||
* Like subscribe but the function is only called once and then it
|
* Like subscribe but the function is only called once and then it
|
||||||
* auto-unsubscribes itself.
|
* auto-unsubscribes itself.
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
|
Cordova.Channel.prototype.subscribeOnce = function(f, c) {
|
||||||
var g = null;
|
var g = null;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var m = function() {
|
var m = function() {
|
||||||
@ -131,7 +129,7 @@ PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
|
|||||||
_this.unsubscribe(g);
|
_this.unsubscribe(g);
|
||||||
};
|
};
|
||||||
if (this.fired) {
|
if (this.fired) {
|
||||||
if (typeof c === "object" && typeof f === "function") { f = PhoneGap.close(c, f); }
|
if (typeof c === "object" && typeof f === "function") { f = Cordova.close(c, f); }
|
||||||
f.apply(this, this.fireArgs);
|
f.apply(this, this.fireArgs);
|
||||||
} else {
|
} else {
|
||||||
g = this.subscribe(m);
|
g = this.subscribe(m);
|
||||||
@ -142,7 +140,7 @@ PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
|
|||||||
/**
|
/**
|
||||||
* Unsubscribes the function with the given guid from the channel.
|
* Unsubscribes the function with the given guid from the channel.
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel.prototype.unsubscribe = function(g) {
|
Cordova.Channel.prototype.unsubscribe = function(g) {
|
||||||
if (typeof g === "function") { g = g.observer_guid; }
|
if (typeof g === "function") { g = g.observer_guid; }
|
||||||
this.handlers[g] = null;
|
this.handlers[g] = null;
|
||||||
delete this.handlers[g];
|
delete this.handlers[g];
|
||||||
@ -151,7 +149,7 @@ PhoneGap.Channel.prototype.unsubscribe = function(g) {
|
|||||||
/**
|
/**
|
||||||
* Calls all functions subscribed to this channel.
|
* Calls all functions subscribed to this channel.
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel.prototype.fire = function(e) {
|
Cordova.Channel.prototype.fire = function(e) {
|
||||||
if (this.enabled) {
|
if (this.enabled) {
|
||||||
var fail = false;
|
var fail = false;
|
||||||
var item, handler, rv;
|
var item, handler, rv;
|
||||||
@ -175,7 +173,7 @@ PhoneGap.Channel.prototype.fire = function(e) {
|
|||||||
* Calls the provided function only after all of the channels specified
|
* Calls the provided function only after all of the channels specified
|
||||||
* have been fired.
|
* have been fired.
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel.join = function(h, c) {
|
Cordova.Channel.join = function(h, c) {
|
||||||
var i = c.length;
|
var i = c.length;
|
||||||
var f = function() {
|
var f = function() {
|
||||||
if (!(--i)) {
|
if (!(--i)) {
|
||||||
@ -199,11 +197,11 @@ PhoneGap.Channel.join = function(h, c) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an initialization function to a queue that ensures it will run and initialize
|
* Add an initialization function to a queue that ensures it will run and initialize
|
||||||
* application constructors only once PhoneGap has been initialized.
|
* application constructors only once Cordova has been initialized.
|
||||||
* @param {Function} func The function callback you want run once PhoneGap is initialized
|
* @param {Function} func The function callback you want run once Cordova is initialized
|
||||||
*/
|
*/
|
||||||
PhoneGap.addConstructor = function(func) {
|
Cordova.addConstructor = function(func) {
|
||||||
PhoneGap.onPhoneGapInit.subscribeOnce(function() {
|
Cordova.onCordovaInit.subscribeOnce(function() {
|
||||||
try {
|
try {
|
||||||
func();
|
func();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@ -226,7 +224,7 @@ if (!window.plugins) {
|
|||||||
* @param name The plugin name
|
* @param name The plugin name
|
||||||
* @param obj The plugin object
|
* @param obj The plugin object
|
||||||
*/
|
*/
|
||||||
PhoneGap.addPlugin = function(name, obj) {
|
Cordova.addPlugin = function(name, obj) {
|
||||||
if (!window.plugins[name]) {
|
if (!window.plugins[name]) {
|
||||||
window.plugins[name] = obj;
|
window.plugins[name] = obj;
|
||||||
}
|
}
|
||||||
@ -239,78 +237,78 @@ PhoneGap.addPlugin = function(name, obj) {
|
|||||||
* onDOMContentLoaded channel is fired when the DOM content
|
* onDOMContentLoaded channel is fired when the DOM content
|
||||||
* of the page has been parsed.
|
* of the page has been parsed.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onDOMContentLoaded = new PhoneGap.Channel('onDOMContentLoaded');
|
Cordova.onDOMContentLoaded = new Cordova.Channel('onDOMContentLoaded');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onNativeReady channel is fired when the PhoneGap native code
|
* onNativeReady channel is fired when the Cordova native code
|
||||||
* has been initialized.
|
* has been initialized.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onNativeReady = new PhoneGap.Channel('onNativeReady');
|
Cordova.onNativeReady = new Cordova.Channel('onNativeReady');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onPhoneGapInit channel is fired when the web page is fully loaded and
|
* onCordovaInit channel is fired when the web page is fully loaded and
|
||||||
* PhoneGap native code has been initialized.
|
* Cordova native code has been initialized.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onPhoneGapInit = new PhoneGap.Channel('onPhoneGapInit');
|
Cordova.onCordovaInit = new Cordova.Channel('onCordovaInit');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
|
* onCordovaReady channel is fired when the JS Cordova objects have been created.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onPhoneGapReady = new PhoneGap.Channel('onPhoneGapReady');
|
Cordova.onCordovaReady = new Cordova.Channel('onCordovaReady');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onPhoneGapInfoReady channel is fired when the PhoneGap device properties
|
* onCordovaInfoReady channel is fired when the Cordova device properties
|
||||||
* has been set.
|
* has been set.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onPhoneGapInfoReady = new PhoneGap.Channel('onPhoneGapInfoReady');
|
Cordova.onCordovaInfoReady = new Cordova.Channel('onCordovaInfoReady');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
|
* onCordovaConnectionReady channel is fired when the Cordova connection properties
|
||||||
* has been set.
|
* has been set.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onPhoneGapConnectionReady = new PhoneGap.Channel('onPhoneGapConnectionReady');
|
Cordova.onCordovaConnectionReady = new Cordova.Channel('onCordovaConnectionReady');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onDestroy channel is fired when the PhoneGap native code
|
* onDestroy channel is fired when the Cordova native code
|
||||||
* is destroyed. It is used internally.
|
* is destroyed. It is used internally.
|
||||||
* Window.onunload should be used by the user.
|
* Window.onunload should be used by the user.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onDestroy = new PhoneGap.Channel('onDestroy');
|
Cordova.onDestroy = new Cordova.Channel('onDestroy');
|
||||||
PhoneGap.onDestroy.subscribeOnce(function() {
|
Cordova.onDestroy.subscribeOnce(function() {
|
||||||
PhoneGap.shuttingDown = true;
|
Cordova.shuttingDown = true;
|
||||||
});
|
});
|
||||||
PhoneGap.shuttingDown = false;
|
Cordova.shuttingDown = false;
|
||||||
|
|
||||||
// _nativeReady is global variable that the native side can set
|
// _nativeReady is global variable that the native side can set
|
||||||
// to signify that the native code is ready. It is a global since
|
// to signify that the native code is ready. It is a global since
|
||||||
// it may be called before any PhoneGap JS is ready.
|
// it may be called before any Cordova JS is ready.
|
||||||
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
|
if (typeof _nativeReady !== 'undefined') { Cordova.onNativeReady.fire(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onDeviceReady is fired only after all PhoneGap objects are created and
|
* onDeviceReady is fired only after all Cordova objects are created and
|
||||||
* the device properties are set.
|
* the device properties are set.
|
||||||
*/
|
*/
|
||||||
PhoneGap.onDeviceReady = new PhoneGap.Channel('onDeviceReady');
|
Cordova.onDeviceReady = new Cordova.Channel('onDeviceReady');
|
||||||
|
|
||||||
|
|
||||||
// Array of channels that must fire before "deviceready" is fired
|
// Array of channels that must fire before "deviceready" is fired
|
||||||
PhoneGap.deviceReadyChannelsArray = [ PhoneGap.onPhoneGapReady, PhoneGap.onPhoneGapInfoReady, PhoneGap.onPhoneGapConnectionReady];
|
Cordova.deviceReadyChannelsArray = [ Cordova.onCordovaReady, Cordova.onCordovaInfoReady, Cordova.onCordovaConnectionReady];
|
||||||
|
|
||||||
// Hashtable of user defined channels that must also fire before "deviceready" is fired
|
// Hashtable of user defined channels that must also fire before "deviceready" is fired
|
||||||
PhoneGap.deviceReadyChannelsMap = {};
|
Cordova.deviceReadyChannelsMap = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate that a feature needs to be initialized before it is ready to be used.
|
* Indicate that a feature needs to be initialized before it is ready to be used.
|
||||||
* This holds up PhoneGap's "deviceready" event until the feature has been initialized
|
* This holds up Cordova's "deviceready" event until the feature has been initialized
|
||||||
* and PhoneGap.initComplete(feature) is called.
|
* and Cordova.initComplete(feature) is called.
|
||||||
*
|
*
|
||||||
* @param feature {String} The unique feature name
|
* @param feature {String} The unique feature name
|
||||||
*/
|
*/
|
||||||
PhoneGap.waitForInitialization = function(feature) {
|
Cordova.waitForInitialization = function(feature) {
|
||||||
if (feature) {
|
if (feature) {
|
||||||
var channel = new PhoneGap.Channel(feature);
|
var channel = new Cordova.Channel(feature);
|
||||||
PhoneGap.deviceReadyChannelsMap[feature] = channel;
|
Cordova.deviceReadyChannelsMap[feature] = channel;
|
||||||
PhoneGap.deviceReadyChannelsArray.push(channel);
|
Cordova.deviceReadyChannelsArray.push(channel);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -319,64 +317,64 @@ PhoneGap.waitForInitialization = function(feature) {
|
|||||||
*
|
*
|
||||||
* @param feature {String} The unique feature name
|
* @param feature {String} The unique feature name
|
||||||
*/
|
*/
|
||||||
PhoneGap.initializationComplete = function(feature) {
|
Cordova.initializationComplete = function(feature) {
|
||||||
var channel = PhoneGap.deviceReadyChannelsMap[feature];
|
var channel = Cordova.deviceReadyChannelsMap[feature];
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.fire();
|
channel.fire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create all PhoneGap objects once page has fully loaded and native side is ready.
|
* Create all Cordova objects once page has fully loaded and native side is ready.
|
||||||
*/
|
*/
|
||||||
PhoneGap.Channel.join(function() {
|
Cordova.Channel.join(function() {
|
||||||
|
|
||||||
// Start listening for XHR callbacks
|
// Start listening for XHR callbacks
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (PhoneGap.UsePolling) {
|
if (Cordova.UsePolling) {
|
||||||
PhoneGap.JSCallbackPolling();
|
Cordova.JSCallbackPolling();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var polling = prompt("usePolling", "gap_callbackServer:");
|
var polling = prompt("usePolling", "gap_callbackServer:");
|
||||||
PhoneGap.UsePolling = polling;
|
Cordova.UsePolling = polling;
|
||||||
if (polling == "true") {
|
if (polling == "true") {
|
||||||
PhoneGap.UsePolling = true;
|
Cordova.UsePolling = true;
|
||||||
PhoneGap.JSCallbackPolling();
|
Cordova.JSCallbackPolling();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PhoneGap.UsePolling = false;
|
Cordova.UsePolling = false;
|
||||||
PhoneGap.JSCallback();
|
Cordova.JSCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
// Run PhoneGap constructors
|
// Run Cordova constructors
|
||||||
PhoneGap.onPhoneGapInit.fire();
|
Cordova.onCordovaInit.fire();
|
||||||
|
|
||||||
// Fire event to notify that all objects are created
|
// Fire event to notify that all objects are created
|
||||||
PhoneGap.onPhoneGapReady.fire();
|
Cordova.onCordovaReady.fire();
|
||||||
|
|
||||||
// Fire onDeviceReady event once all constructors have run and PhoneGap info has been
|
// Fire onDeviceReady event once all constructors have run and Cordova info has been
|
||||||
// received from native side, and any user defined initialization channels.
|
// received from native side, and any user defined initialization channels.
|
||||||
PhoneGap.Channel.join(function() {
|
Cordova.Channel.join(function() {
|
||||||
// Let native code know we are inited on JS side
|
// Let native code know we are inited on JS side
|
||||||
prompt("", "gap_init:");
|
prompt("", "gap_init:");
|
||||||
|
|
||||||
PhoneGap.onDeviceReady.fire();
|
Cordova.onDeviceReady.fire();
|
||||||
}, PhoneGap.deviceReadyChannelsArray);
|
}, Cordova.deviceReadyChannelsArray);
|
||||||
|
|
||||||
}, [ PhoneGap.onDOMContentLoaded, PhoneGap.onNativeReady ]);
|
}, [ Cordova.onDOMContentLoaded, Cordova.onNativeReady ]);
|
||||||
|
|
||||||
// Listen for DOMContentLoaded and notify our channel subscribers
|
// Listen for DOMContentLoaded and notify our channel subscribers
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
PhoneGap.onDOMContentLoaded.fire();
|
Cordova.onDOMContentLoaded.fire();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// Intercept calls to document.addEventListener and watch for deviceready
|
// Intercept calls to document.addEventListener and watch for deviceready
|
||||||
PhoneGap.m_document_addEventListener = document.addEventListener;
|
Cordova.m_document_addEventListener = document.addEventListener;
|
||||||
|
|
||||||
// Intercept calls to window.addEventListener
|
// Intercept calls to window.addEventListener
|
||||||
PhoneGap.m_window_addEventListener = window.addEventListener;
|
Cordova.m_window_addEventListener = window.addEventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a custom window event handler.
|
* Add a custom window event handler.
|
||||||
@ -384,8 +382,8 @@ PhoneGap.m_window_addEventListener = window.addEventListener;
|
|||||||
* @param {String} event The event name that callback handles
|
* @param {String} event The event name that callback handles
|
||||||
* @param {Function} callback The event handler
|
* @param {Function} callback The event handler
|
||||||
*/
|
*/
|
||||||
PhoneGap.addWindowEventHandler = function(event, callback) {
|
Cordova.addWindowEventHandler = function(event, callback) {
|
||||||
PhoneGap.windowEventHandler[event] = callback;
|
Cordova.windowEventHandler[event] = callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -394,8 +392,8 @@ PhoneGap.addWindowEventHandler = function(event, callback) {
|
|||||||
* @param {String} event The event name that callback handles
|
* @param {String} event The event name that callback handles
|
||||||
* @param {Function} callback The event handler
|
* @param {Function} callback The event handler
|
||||||
*/
|
*/
|
||||||
PhoneGap.addDocumentEventHandler = function(event, callback) {
|
Cordova.addDocumentEventHandler = function(event, callback) {
|
||||||
PhoneGap.documentEventHandler[event] = callback;
|
Cordova.documentEventHandler[event] = callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -408,22 +406,22 @@ PhoneGap.addDocumentEventHandler = function(event, callback) {
|
|||||||
document.addEventListener = function(evt, handler, capture) {
|
document.addEventListener = function(evt, handler, capture) {
|
||||||
var e = evt.toLowerCase();
|
var e = evt.toLowerCase();
|
||||||
if (e === 'deviceready') {
|
if (e === 'deviceready') {
|
||||||
PhoneGap.onDeviceReady.subscribeOnce(handler);
|
Cordova.onDeviceReady.subscribeOnce(handler);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If subscribing to Android backbutton
|
// If subscribing to Android backbutton
|
||||||
if (e === 'backbutton') {
|
if (e === 'backbutton') {
|
||||||
PhoneGap.exec(null, null, "App", "overrideBackbutton", [true]);
|
Cordova.exec(null, null, "App", "overrideBackbutton", [true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If subscribing to an event that is handled by a plugin
|
// If subscribing to an event that is handled by a plugin
|
||||||
else if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
|
else if (typeof Cordova.documentEventHandler[e] !== "undefined") {
|
||||||
if (PhoneGap.documentEventHandler[e](e, handler, true)) {
|
if (Cordova.documentEventHandler[e](e, handler, true)) {
|
||||||
return; // Stop default behavior
|
return; // Stop default behavior
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
|
Cordova.m_document_addEventListener.call(document, evt, handler, capture);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -438,21 +436,21 @@ window.addEventListener = function(evt, handler, capture) {
|
|||||||
var e = evt.toLowerCase();
|
var e = evt.toLowerCase();
|
||||||
|
|
||||||
// If subscribing to an event that is handled by a plugin
|
// If subscribing to an event that is handled by a plugin
|
||||||
if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
|
if (typeof Cordova.windowEventHandler[e] !== "undefined") {
|
||||||
if (PhoneGap.windowEventHandler[e](e, handler, true)) {
|
if (Cordova.windowEventHandler[e](e, handler, true)) {
|
||||||
return; // Stop default behavior
|
return; // Stop default behavior
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneGap.m_window_addEventListener.call(window, evt, handler, capture);
|
Cordova.m_window_addEventListener.call(window, evt, handler, capture);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Intercept calls to document.removeEventListener and watch for events that
|
// Intercept calls to document.removeEventListener and watch for events that
|
||||||
// are generated by PhoneGap native code
|
// are generated by Cordova native code
|
||||||
PhoneGap.m_document_removeEventListener = document.removeEventListener;
|
Cordova.m_document_removeEventListener = document.removeEventListener;
|
||||||
|
|
||||||
// Intercept calls to window.removeEventListener
|
// Intercept calls to window.removeEventListener
|
||||||
PhoneGap.m_window_removeEventListener = window.removeEventListener;
|
Cordova.m_window_removeEventListener = window.removeEventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intercept removing document event listeners and handle our own
|
* Intercept removing document event listeners and handle our own
|
||||||
@ -466,17 +464,17 @@ document.removeEventListener = function(evt, handler, capture) {
|
|||||||
|
|
||||||
// If unsubscribing to Android backbutton
|
// If unsubscribing to Android backbutton
|
||||||
if (e === 'backbutton') {
|
if (e === 'backbutton') {
|
||||||
PhoneGap.exec(null, null, "App", "overrideBackbutton", [false]);
|
Cordova.exec(null, null, "App", "overrideBackbutton", [false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If unsubcribing from an event that is handled by a plugin
|
// If unsubcribing from an event that is handled by a plugin
|
||||||
if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
|
if (typeof Cordova.documentEventHandler[e] !== "undefined") {
|
||||||
if (PhoneGap.documentEventHandler[e](e, handler, false)) {
|
if (Cordova.documentEventHandler[e](e, handler, false)) {
|
||||||
return; // Stop default behavior
|
return; // Stop default behavior
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneGap.m_document_removeEventListener.call(document, evt, handler, capture);
|
Cordova.m_document_removeEventListener.call(document, evt, handler, capture);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -490,13 +488,13 @@ window.removeEventListener = function(evt, handler, capture) {
|
|||||||
var e = evt.toLowerCase();
|
var e = evt.toLowerCase();
|
||||||
|
|
||||||
// If unsubcribing from an event that is handled by a plugin
|
// If unsubcribing from an event that is handled by a plugin
|
||||||
if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
|
if (typeof Cordova.windowEventHandler[e] !== "undefined") {
|
||||||
if (PhoneGap.windowEventHandler[e](e, handler, false)) {
|
if (Cordova.windowEventHandler[e](e, handler, false)) {
|
||||||
return; // Stop default behavior
|
return; // Stop default behavior
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneGap.m_window_removeEventListener.call(window, evt, handler, capture);
|
Cordova.m_window_removeEventListener.call(window, evt, handler, capture);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -505,7 +503,7 @@ window.removeEventListener = function(evt, handler, capture) {
|
|||||||
* @param {String} type The event type to fire
|
* @param {String} type The event type to fire
|
||||||
* @param {Object} data Data to send with event
|
* @param {Object} data Data to send with event
|
||||||
*/
|
*/
|
||||||
PhoneGap.fireDocumentEvent = function(type, data) {
|
Cordova.fireDocumentEvent = function(type, data) {
|
||||||
var e = document.createEvent('Events');
|
var e = document.createEvent('Events');
|
||||||
e.initEvent(type);
|
e.initEvent(type);
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -522,7 +520,7 @@ PhoneGap.fireDocumentEvent = function(type, data) {
|
|||||||
* @param {String} type The event type to fire
|
* @param {String} type The event type to fire
|
||||||
* @param {Object} data Data to send with event
|
* @param {Object} data Data to send with event
|
||||||
*/
|
*/
|
||||||
PhoneGap.fireWindowEvent = function(type, data) {
|
Cordova.fireWindowEvent = function(type, data) {
|
||||||
var e = document.createEvent('Events');
|
var e = document.createEvent('Events');
|
||||||
e.initEvent(type);
|
e.initEvent(type);
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -539,7 +537,7 @@ PhoneGap.fireWindowEvent = function(type, data) {
|
|||||||
* @param obj
|
* @param obj
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
PhoneGap.clone = function(obj) {
|
Cordova.clone = function(obj) {
|
||||||
var i, retVal;
|
var i, retVal;
|
||||||
if(!obj) {
|
if(!obj) {
|
||||||
return obj;
|
return obj;
|
||||||
@ -548,7 +546,7 @@ PhoneGap.clone = function(obj) {
|
|||||||
if(obj instanceof Array){
|
if(obj instanceof Array){
|
||||||
retVal = [];
|
retVal = [];
|
||||||
for(i = 0; i < obj.length; ++i){
|
for(i = 0; i < obj.length; ++i){
|
||||||
retVal.push(PhoneGap.clone(obj[i]));
|
retVal.push(Cordova.clone(obj[i]));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@ -568,15 +566,15 @@ PhoneGap.clone = function(obj) {
|
|||||||
retVal = {};
|
retVal = {};
|
||||||
for(i in obj){
|
for(i in obj){
|
||||||
if(!(i in retVal) || retVal[i] !== obj[i]) {
|
if(!(i in retVal) || retVal[i] !== obj[i]) {
|
||||||
retVal[i] = PhoneGap.clone(obj[i]);
|
retVal[i] = Cordova.clone(obj[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.callbackId = 0;
|
Cordova.callbackId = 0;
|
||||||
PhoneGap.callbacks = {};
|
Cordova.callbacks = {};
|
||||||
PhoneGap.callbackStatus = {
|
Cordova.callbackStatus = {
|
||||||
NO_RESULT: 0,
|
NO_RESULT: 0,
|
||||||
OK: 1,
|
OK: 1,
|
||||||
CLASS_NOT_FOUND_EXCEPTION: 2,
|
CLASS_NOT_FOUND_EXCEPTION: 2,
|
||||||
@ -591,24 +589,24 @@ PhoneGap.callbackStatus = {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a PhoneGap command. It is up to the native side whether this action is synch or async.
|
* Execute a Cordova command. It is up to the native side whether this action is synch or async.
|
||||||
* The native side can return:
|
* The native side can return:
|
||||||
* Synchronous: PluginResult object as a JSON string
|
* Synchronous: PluginResult object as a JSON string
|
||||||
* Asynchrounous: Empty string ""
|
* Asynchrounous: Empty string ""
|
||||||
* If async, the native side will PhoneGap.callbackSuccess or PhoneGap.callbackError,
|
* If async, the native side will Cordova.callbackSuccess or Cordova.callbackError,
|
||||||
* depending upon the result of the action.
|
* depending upon the result of the action.
|
||||||
*
|
*
|
||||||
* @param {Function} success The success callback
|
* @param {Function} success The success callback
|
||||||
* @param {Function} fail The fail callback
|
* @param {Function} fail The fail callback
|
||||||
* @param {String} service The name of the service to use
|
* @param {String} service The name of the service to use
|
||||||
* @param {String} action Action to be run in PhoneGap
|
* @param {String} action Action to be run in Cordova
|
||||||
* @param {Array.<String>} [args] Zero or more arguments to pass to the method
|
* @param {Array.<String>} [args] Zero or more arguments to pass to the method
|
||||||
*/
|
*/
|
||||||
PhoneGap.exec = function(success, fail, service, action, args) {
|
Cordova.exec = function(success, fail, service, action, args) {
|
||||||
try {
|
try {
|
||||||
var callbackId = service + PhoneGap.callbackId++;
|
var callbackId = service + Cordova.callbackId++;
|
||||||
if (success || fail) {
|
if (success || fail) {
|
||||||
PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
|
Cordova.callbacks[callbackId] = {success:success, fail:fail};
|
||||||
}
|
}
|
||||||
|
|
||||||
var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
|
var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
|
||||||
@ -618,7 +616,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
|||||||
eval("var v="+r+";");
|
eval("var v="+r+";");
|
||||||
|
|
||||||
// If status is OK, then return value back to caller
|
// If status is OK, then return value back to caller
|
||||||
if (v.status === PhoneGap.callbackStatus.OK) {
|
if (v.status === Cordova.callbackStatus.OK) {
|
||||||
|
|
||||||
// If there is a success callback, then call it now with
|
// If there is a success callback, then call it now with
|
||||||
// returned value
|
// returned value
|
||||||
@ -631,18 +629,18 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
|||||||
|
|
||||||
// Clear callback if not expecting any more results
|
// Clear callback if not expecting any more results
|
||||||
if (!v.keepCallback) {
|
if (!v.keepCallback) {
|
||||||
delete PhoneGap.callbacks[callbackId];
|
delete Cordova.callbacks[callbackId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v.message;
|
return v.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no result
|
// If no result
|
||||||
else if (v.status === PhoneGap.callbackStatus.NO_RESULT) {
|
else if (v.status === Cordova.callbackStatus.NO_RESULT) {
|
||||||
|
|
||||||
// Clear callback if not expecting any more results
|
// Clear callback if not expecting any more results
|
||||||
if (!v.keepCallback) {
|
if (!v.keepCallback) {
|
||||||
delete PhoneGap.callbacks[callbackId];
|
delete Cordova.callbacks[callbackId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,7 +659,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
|||||||
|
|
||||||
// Clear callback if not expecting any more results
|
// Clear callback if not expecting any more results
|
||||||
if (!v.keepCallback) {
|
if (!v.keepCallback) {
|
||||||
delete PhoneGap.callbacks[callbackId];
|
delete Cordova.callbacks[callbackId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -678,14 +676,14 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
|||||||
* @param callbackId
|
* @param callbackId
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
PhoneGap.callbackSuccess = function(callbackId, args) {
|
Cordova.callbackSuccess = function(callbackId, args) {
|
||||||
if (PhoneGap.callbacks[callbackId]) {
|
if (Cordova.callbacks[callbackId]) {
|
||||||
|
|
||||||
// If result is to be sent to callback
|
// If result is to be sent to callback
|
||||||
if (args.status === PhoneGap.callbackStatus.OK) {
|
if (args.status === Cordova.callbackStatus.OK) {
|
||||||
try {
|
try {
|
||||||
if (PhoneGap.callbacks[callbackId].success) {
|
if (Cordova.callbacks[callbackId].success) {
|
||||||
PhoneGap.callbacks[callbackId].success(args.message);
|
Cordova.callbacks[callbackId].success(args.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@ -695,7 +693,7 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
|
|||||||
|
|
||||||
// Clear callback if not expecting any more results
|
// Clear callback if not expecting any more results
|
||||||
if (!args.keepCallback) {
|
if (!args.keepCallback) {
|
||||||
delete PhoneGap.callbacks[callbackId];
|
delete Cordova.callbacks[callbackId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -706,11 +704,11 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
|
|||||||
* @param callbackId
|
* @param callbackId
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
PhoneGap.callbackError = function(callbackId, args) {
|
Cordova.callbackError = function(callbackId, args) {
|
||||||
if (PhoneGap.callbacks[callbackId]) {
|
if (Cordova.callbacks[callbackId]) {
|
||||||
try {
|
try {
|
||||||
if (PhoneGap.callbacks[callbackId].fail) {
|
if (Cordova.callbacks[callbackId].fail) {
|
||||||
PhoneGap.callbacks[callbackId].fail(args.message);
|
Cordova.callbacks[callbackId].fail(args.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@ -719,31 +717,31 @@ PhoneGap.callbackError = function(callbackId, args) {
|
|||||||
|
|
||||||
// Clear callback if not expecting any more results
|
// Clear callback if not expecting any more results
|
||||||
if (!args.keepCallback) {
|
if (!args.keepCallback) {
|
||||||
delete PhoneGap.callbacks[callbackId];
|
delete Cordova.callbacks[callbackId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.JSCallbackPort = null;
|
Cordova.JSCallbackPort = null;
|
||||||
PhoneGap.JSCallbackToken = null;
|
Cordova.JSCallbackToken = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is only for Android.
|
* This is only for Android.
|
||||||
*
|
*
|
||||||
* Internal function that uses XHR to call into PhoneGap Java code and retrieve
|
* Internal function that uses XHR to call into Cordova Java code and retrieve
|
||||||
* any JavaScript code that needs to be run. This is used for callbacks from
|
* any JavaScript code that needs to be run. This is used for callbacks from
|
||||||
* Java to JavaScript.
|
* Java to JavaScript.
|
||||||
*/
|
*/
|
||||||
PhoneGap.JSCallback = function() {
|
Cordova.JSCallback = function() {
|
||||||
|
|
||||||
// Exit if shutting down app
|
// Exit if shutting down app
|
||||||
if (PhoneGap.shuttingDown) {
|
if (Cordova.shuttingDown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If polling flag was changed, start using polling from now on
|
// If polling flag was changed, start using polling from now on
|
||||||
if (PhoneGap.UsePolling) {
|
if (Cordova.UsePolling) {
|
||||||
PhoneGap.JSCallbackPolling();
|
Cordova.JSCallbackPolling();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,7 +752,7 @@ PhoneGap.JSCallback = function() {
|
|||||||
if(xmlhttp.readyState === 4){
|
if(xmlhttp.readyState === 4){
|
||||||
|
|
||||||
// Exit if shutting down app
|
// Exit if shutting down app
|
||||||
if (PhoneGap.shuttingDown) {
|
if (Cordova.shuttingDown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,12 +771,12 @@ PhoneGap.JSCallback = function() {
|
|||||||
console.log("JSCallback Error: "+e);
|
console.log("JSCallback Error: "+e);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
setTimeout(PhoneGap.JSCallback, 1);
|
setTimeout(Cordova.JSCallback, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If callback ping (used to keep XHR request from timing out)
|
// If callback ping (used to keep XHR request from timing out)
|
||||||
else if (xmlhttp.status === 404) {
|
else if (xmlhttp.status === 404) {
|
||||||
setTimeout(PhoneGap.JSCallback, 10);
|
setTimeout(Cordova.JSCallback, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If security error
|
// If security error
|
||||||
@ -799,19 +797,19 @@ PhoneGap.JSCallback = function() {
|
|||||||
// If error, revert to polling
|
// If error, revert to polling
|
||||||
else {
|
else {
|
||||||
console.log("JSCallback Error: Request failed.");
|
console.log("JSCallback Error: Request failed.");
|
||||||
PhoneGap.UsePolling = true;
|
Cordova.UsePolling = true;
|
||||||
PhoneGap.JSCallbackPolling();
|
Cordova.JSCallbackPolling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (PhoneGap.JSCallbackPort === null) {
|
if (Cordova.JSCallbackPort === null) {
|
||||||
PhoneGap.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
|
Cordova.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
|
||||||
}
|
}
|
||||||
if (PhoneGap.JSCallbackToken === null) {
|
if (Cordova.JSCallbackToken === null) {
|
||||||
PhoneGap.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
|
Cordova.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
|
||||||
}
|
}
|
||||||
xmlhttp.open("GET", "http://127.0.0.1:"+PhoneGap.JSCallbackPort+"/"+PhoneGap.JSCallbackToken , true);
|
xmlhttp.open("GET", "http://127.0.0.1:"+Cordova.JSCallbackPort+"/"+Cordova.JSCallbackToken , true);
|
||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -819,30 +817,30 @@ PhoneGap.JSCallback = function() {
|
|||||||
* The polling period to use with JSCallbackPolling.
|
* The polling period to use with JSCallbackPolling.
|
||||||
* This can be changed by the application. The default is 50ms.
|
* This can be changed by the application. The default is 50ms.
|
||||||
*/
|
*/
|
||||||
PhoneGap.JSCallbackPollingPeriod = 50;
|
Cordova.JSCallbackPollingPeriod = 50;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag that can be set by the user to force polling to be used or force XHR to be used.
|
* Flag that can be set by the user to force polling to be used or force XHR to be used.
|
||||||
*/
|
*/
|
||||||
PhoneGap.UsePolling = false; // T=use polling, F=use XHR
|
Cordova.UsePolling = false; // T=use polling, F=use XHR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is only for Android.
|
* This is only for Android.
|
||||||
*
|
*
|
||||||
* Internal function that uses polling to call into PhoneGap Java code and retrieve
|
* Internal function that uses polling to call into Cordova Java code and retrieve
|
||||||
* any JavaScript code that needs to be run. This is used for callbacks from
|
* any JavaScript code that needs to be run. This is used for callbacks from
|
||||||
* Java to JavaScript.
|
* Java to JavaScript.
|
||||||
*/
|
*/
|
||||||
PhoneGap.JSCallbackPolling = function() {
|
Cordova.JSCallbackPolling = function() {
|
||||||
|
|
||||||
// Exit if shutting down app
|
// Exit if shutting down app
|
||||||
if (PhoneGap.shuttingDown) {
|
if (Cordova.shuttingDown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If polling flag was changed, stop using polling from now on
|
// If polling flag was changed, stop using polling from now on
|
||||||
if (!PhoneGap.UsePolling) {
|
if (!Cordova.UsePolling) {
|
||||||
PhoneGap.JSCallback();
|
Cordova.JSCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,10 +855,10 @@ PhoneGap.JSCallbackPolling = function() {
|
|||||||
console.log("JSCallbackPolling Error: "+e);
|
console.log("JSCallbackPolling Error: "+e);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
setTimeout(PhoneGap.JSCallbackPolling, 1);
|
setTimeout(Cordova.JSCallbackPolling, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setTimeout(PhoneGap.JSCallbackPolling, PhoneGap.JSCallbackPollingPeriod);
|
setTimeout(Cordova.JSCallbackPolling, Cordova.JSCallbackPollingPeriod);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -869,15 +867,15 @@ PhoneGap.JSCallbackPolling = function() {
|
|||||||
*
|
*
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
PhoneGap.createUUID = function() {
|
Cordova.createUUID = function() {
|
||||||
return PhoneGap.UUIDcreatePart(4) + '-' +
|
return Cordova.UUIDcreatePart(4) + '-' +
|
||||||
PhoneGap.UUIDcreatePart(2) + '-' +
|
Cordova.UUIDcreatePart(2) + '-' +
|
||||||
PhoneGap.UUIDcreatePart(2) + '-' +
|
Cordova.UUIDcreatePart(2) + '-' +
|
||||||
PhoneGap.UUIDcreatePart(2) + '-' +
|
Cordova.UUIDcreatePart(2) + '-' +
|
||||||
PhoneGap.UUIDcreatePart(6);
|
Cordova.UUIDcreatePart(6);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.UUIDcreatePart = function(length) {
|
Cordova.UUIDcreatePart = function(length) {
|
||||||
var uuidpart = "";
|
var uuidpart = "";
|
||||||
var i, uuidchar;
|
var i, uuidchar;
|
||||||
for (i=0; i<length; i++) {
|
for (i=0; i<length; i++) {
|
||||||
@ -890,7 +888,7 @@ PhoneGap.UUIDcreatePart = function(length) {
|
|||||||
return uuidpart;
|
return uuidpart;
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.close = function(context, func, params) {
|
Cordova.close = function(context, func, params) {
|
||||||
if (typeof params === 'undefined') {
|
if (typeof params === 'undefined') {
|
||||||
return function() {
|
return function() {
|
||||||
return func.apply(context, arguments);
|
return func.apply(context, arguments);
|
||||||
@ -908,7 +906,7 @@ PhoneGap.close = function(context, func, params) {
|
|||||||
* @param {String} jsfile The url of the JavaScript file to load.
|
* @param {String} jsfile The url of the JavaScript file to load.
|
||||||
* @param {Function} successCallback The callback to call when the file has been loaded.
|
* @param {Function} successCallback The callback to call when the file has been loaded.
|
||||||
*/
|
*/
|
||||||
PhoneGap.includeJavascript = function(jsfile, successCallback) {
|
Cordova.includeJavascript = function(jsfile, successCallback) {
|
||||||
var id = document.getElementsByTagName("head")[0];
|
var id = document.getElementsByTagName("head")[0];
|
||||||
var el = document.createElement('script');
|
var el = document.createElement('script');
|
||||||
el.type = 'text/javascript';
|
el.type = 'text/javascript';
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
// TODO: Needs to be commented
|
// TODO: Needs to be commented
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("crypto")) {
|
if (!Cordova.hasResource("crypto")) {
|
||||||
PhoneGap.addResource("crypto");
|
Cordova.addResource("crypto");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
@ -30,12 +30,12 @@ var Crypto = function() {
|
|||||||
|
|
||||||
Crypto.prototype.encrypt = function(seed, string, callback) {
|
Crypto.prototype.encrypt = function(seed, string, callback) {
|
||||||
this.encryptWin = callback;
|
this.encryptWin = callback;
|
||||||
PhoneGap.exec(null, null, "Crypto", "encrypt", [seed, string]);
|
Cordova.exec(null, null, "Crypto", "encrypt", [seed, string]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Crypto.prototype.decrypt = function(seed, string, callback) {
|
Crypto.prototype.decrypt = function(seed, string, callback) {
|
||||||
this.decryptWin = callback;
|
this.decryptWin = callback;
|
||||||
PhoneGap.exec(null, null, "Crypto", "decrypt", [seed, string]);
|
Cordova.exec(null, null, "Crypto", "decrypt", [seed, string]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Crypto.prototype.gotCryptedString = function(string) {
|
Crypto.prototype.gotCryptedString = function(string) {
|
||||||
@ -46,7 +46,7 @@ Crypto.prototype.getPlainString = function(string) {
|
|||||||
this.decryptWin(string);
|
this.decryptWin(string);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.Crypto === "undefined") {
|
if (typeof navigator.Crypto === "undefined") {
|
||||||
navigator.Crypto = new Crypto();
|
navigator.Crypto = new Crypto();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("device")) {
|
if (!Cordova.hasResource("device")) {
|
||||||
PhoneGap.addResource("device");
|
Cordova.addResource("device");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||||
@ -26,12 +26,12 @@ PhoneGap.addResource("device");
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
var Device = function() {
|
var Device = function() {
|
||||||
this.available = PhoneGap.available;
|
this.available = Cordova.available;
|
||||||
this.platform = null;
|
this.platform = null;
|
||||||
this.version = null;
|
this.version = null;
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.uuid = null;
|
this.uuid = null;
|
||||||
this.phonegap = null;
|
this.cordova = null;
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
this.getInfo(
|
this.getInfo(
|
||||||
@ -41,13 +41,13 @@ var Device = function() {
|
|||||||
me.version = info.version;
|
me.version = info.version;
|
||||||
me.name = info.name;
|
me.name = info.name;
|
||||||
me.uuid = info.uuid;
|
me.uuid = info.uuid;
|
||||||
me.phonegap = info.phonegap;
|
me.cordova = info.cordova;
|
||||||
PhoneGap.onPhoneGapInfoReady.fire();
|
Cordova.onCordovaInfoReady.fire();
|
||||||
},
|
},
|
||||||
function(e) {
|
function(e) {
|
||||||
me.available = false;
|
me.available = false;
|
||||||
console.log("Error initializing PhoneGap: " + e);
|
console.log("Error initializing Cordova: " + e);
|
||||||
alert("Error initializing PhoneGap: "+e);
|
alert("Error initializing Cordova: "+e);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,10 +72,10 @@ Device.prototype.getInfo = function(successCallback, errorCallback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
Cordova.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.device === "undefined") {
|
if (typeof navigator.device === "undefined") {
|
||||||
navigator.device = window.device = new Device();
|
navigator.device = window.device = new Device();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("file")) {
|
if (!Cordova.hasResource("file")) {
|
||||||
PhoneGap.addResource("file");
|
Cordova.addResource("file");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides some useful information about a file.
|
* This class provides some useful information about a file.
|
||||||
@ -162,7 +162,7 @@ FileReader.prototype.readAsText = function(file, encoding) {
|
|||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// Read file
|
// Read file
|
||||||
PhoneGap.exec(
|
Cordova.exec(
|
||||||
// Success callback
|
// Success callback
|
||||||
function(r) {
|
function(r) {
|
||||||
var evt;
|
var evt;
|
||||||
@ -241,7 +241,7 @@ FileReader.prototype.readAsDataURL = function(file) {
|
|||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// Read file
|
// Read file
|
||||||
PhoneGap.exec(
|
Cordova.exec(
|
||||||
// Success callback
|
// Success callback
|
||||||
function(r) {
|
function(r) {
|
||||||
var evt;
|
var evt;
|
||||||
@ -412,7 +412,7 @@ FileWriter.prototype.write = function(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write file
|
// Write file
|
||||||
PhoneGap.exec(
|
Cordova.exec(
|
||||||
// Success callback
|
// Success callback
|
||||||
function(r) {
|
function(r) {
|
||||||
var evt;
|
var evt;
|
||||||
@ -523,7 +523,7 @@ FileWriter.prototype.truncate = function(size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write file
|
// Write file
|
||||||
PhoneGap.exec(
|
Cordova.exec(
|
||||||
// Success callback
|
// Success callback
|
||||||
function(r) {
|
function(r) {
|
||||||
var evt;
|
var evt;
|
||||||
@ -624,7 +624,7 @@ var DirectoryReader = function(fullPath){
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
|
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -654,7 +654,7 @@ var DirectoryEntry = function() {
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
|
DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -664,7 +664,7 @@ DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, err
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -674,7 +674,7 @@ DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback)
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
|
DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -686,7 +686,7 @@ DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
|
DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -696,7 +696,7 @@ DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, err
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.remove = function(successCallback, errorCallback) {
|
DirectoryEntry.prototype.remove = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -725,7 +725,7 @@ DirectoryEntry.prototype.createReader = function(successCallback, errorCallback)
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
|
DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
|
Cordova.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -737,7 +737,7 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
|
DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
|
Cordova.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -747,7 +747,7 @@ DirectoryEntry.prototype.getFile = function(path, options, successCallback, erro
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
|
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -777,7 +777,7 @@ var FileEntry = function() {
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
|
FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -787,7 +787,7 @@ FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCal
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -797,7 +797,7 @@ FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
FileEntry.prototype.getParent = function(successCallback, errorCallback) {
|
FileEntry.prototype.getParent = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -809,7 +809,7 @@ FileEntry.prototype.getParent = function(successCallback, errorCallback) {
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
|
FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -819,7 +819,7 @@ FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCal
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
FileEntry.prototype.remove = function(successCallback, errorCallback) {
|
FileEntry.prototype.remove = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -863,7 +863,7 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
FileEntry.prototype.file = function(successCallback, errorCallback) {
|
FileEntry.prototype.file = function(successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
|
Cordova.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @constructor */
|
/** @constructor */
|
||||||
@ -892,7 +892,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
|
Cordova.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -903,7 +903,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
LocalFileSystem.prototype.resolveLocalFileSystemURI = function(uri, successCallback, errorCallback) {
|
LocalFileSystem.prototype.resolveLocalFileSystemURI = function(uri, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
|
Cordova.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -986,7 +986,7 @@ LocalFileSystem.prototype._castDate = function(pluginResult) {
|
|||||||
/**
|
/**
|
||||||
* Add the FileSystem interface into the browser.
|
* Add the FileSystem interface into the browser.
|
||||||
*/
|
*/
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
var pgLocalFileSystem = new LocalFileSystem();
|
var pgLocalFileSystem = new LocalFileSystem();
|
||||||
// Needed for cast methods
|
// Needed for cast methods
|
||||||
if (typeof window.localFileSystem === "undefined") {
|
if (typeof window.localFileSystem === "undefined") {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("filetransfer")) {
|
if (!Cordova.hasResource("filetransfer")) {
|
||||||
PhoneGap.addResource("filetransfer");
|
Cordova.addResource("filetransfer");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileTransfer uploads a file to a remote server.
|
* FileTransfer uploads a file to a remote server.
|
||||||
@ -80,7 +80,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
|
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,7 +91,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
|||||||
* @param errorCallback {Function} Callback to be invoked upon error
|
* @param errorCallback {Function} Callback to be invoked upon error
|
||||||
*/
|
*/
|
||||||
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
|
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
|
||||||
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
|
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("geolocation")) {
|
if (!Cordova.hasResource("geolocation")) {
|
||||||
PhoneGap.addResource("geolocation");
|
Cordova.addResource("geolocation");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides access to device GPS data.
|
* This class provides access to device GPS data.
|
||||||
@ -80,7 +80,7 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
navigator._geo.listeners.global = {"success" : successCallback, "fail" : errorCallback };
|
navigator._geo.listeners.global = {"success" : successCallback, "fail" : errorCallback };
|
||||||
PhoneGap.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
Cordova.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,9 +110,9 @@ Geolocation.prototype.watchPosition = function(successCallback, errorCallback, o
|
|||||||
timeout = options.timeout;
|
timeout = options.timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var id = PhoneGap.createUUID();
|
var id = Cordova.createUUID();
|
||||||
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
|
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
|
||||||
PhoneGap.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
Cordova.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -173,19 +173,19 @@ Geolocation.prototype.fail = function(id, code, msg) {
|
|||||||
* @param {String} id The ID of the watch returned from #watchPosition
|
* @param {String} id The ID of the watch returned from #watchPosition
|
||||||
*/
|
*/
|
||||||
Geolocation.prototype.clearWatch = function(id) {
|
Geolocation.prototype.clearWatch = function(id) {
|
||||||
PhoneGap.exec(null, null, "Geolocation", "stop", [id]);
|
Cordova.exec(null, null, "Geolocation", "stop", [id]);
|
||||||
delete navigator._geo.listeners[id];
|
delete navigator._geo.listeners[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force the PhoneGap geolocation to be used instead of built-in.
|
* Force the Cordova geolocation to be used instead of built-in.
|
||||||
*/
|
*/
|
||||||
Geolocation.usingPhoneGap = false;
|
Geolocation.usingCordova = false;
|
||||||
Geolocation.usePhoneGap = function() {
|
Geolocation.useCordova = function() {
|
||||||
if (Geolocation.usingPhoneGap) {
|
if (Geolocation.usingCordova) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Geolocation.usingPhoneGap = true;
|
Geolocation.usingCordova = true;
|
||||||
|
|
||||||
// Set built-in geolocation methods to our own implementations
|
// Set built-in geolocation methods to our own implementations
|
||||||
// (Cannot replace entire geolocation, but can replace individual methods)
|
// (Cannot replace entire geolocation, but can replace individual methods)
|
||||||
@ -197,13 +197,13 @@ Geolocation.usePhoneGap = function() {
|
|||||||
navigator.geolocation.stop = navigator._geo.stop;
|
navigator.geolocation.stop = navigator._geo.stop;
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
navigator._geo = new Geolocation();
|
navigator._geo = new Geolocation();
|
||||||
|
|
||||||
// No native geolocation object for Android 1.x, so use PhoneGap geolocation
|
// No native geolocation object for Android 1.x, so use Cordova geolocation
|
||||||
if (typeof navigator.geolocation === 'undefined') {
|
if (typeof navigator.geolocation === 'undefined') {
|
||||||
navigator.geolocation = navigator._geo;
|
navigator.geolocation = navigator._geo;
|
||||||
Geolocation.usingPhoneGap = true;
|
Geolocation.usingCordova = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("media")) {
|
if (!Cordova.hasResource("media")) {
|
||||||
PhoneGap.addResource("media");
|
Cordova.addResource("media");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides access to the device media, interfaces to both sound and video
|
* This class provides access to the device media, interfaces to both sound and video
|
||||||
@ -60,8 +60,8 @@ var Media = function(src, successCallback, errorCallback, statusCallback, positi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.id = PhoneGap.createUUID();
|
this.id = Cordova.createUUID();
|
||||||
PhoneGap.mediaObjects[this.id] = this;
|
Cordova.mediaObjects[this.id] = this;
|
||||||
this.src = src;
|
this.src = src;
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
@ -105,28 +105,28 @@ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
|
|||||||
* Start or resume playing audio file.
|
* Start or resume playing audio file.
|
||||||
*/
|
*/
|
||||||
Media.prototype.play = function() {
|
Media.prototype.play = function() {
|
||||||
PhoneGap.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
Cordova.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop playing audio file.
|
* Stop playing audio file.
|
||||||
*/
|
*/
|
||||||
Media.prototype.stop = function() {
|
Media.prototype.stop = function() {
|
||||||
return PhoneGap.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
return Cordova.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seek or jump to a new time in the track..
|
* Seek or jump to a new time in the track..
|
||||||
*/
|
*/
|
||||||
Media.prototype.seekTo = function(milliseconds) {
|
Media.prototype.seekTo = function(milliseconds) {
|
||||||
PhoneGap.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
|
Cordova.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause playing audio file.
|
* Pause playing audio file.
|
||||||
*/
|
*/
|
||||||
Media.prototype.pause = function() {
|
Media.prototype.pause = function() {
|
||||||
PhoneGap.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
|
Cordova.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,49 +143,49 @@ Media.prototype.getDuration = function() {
|
|||||||
* Get position of audio.
|
* Get position of audio.
|
||||||
*/
|
*/
|
||||||
Media.prototype.getCurrentPosition = function(success, fail) {
|
Media.prototype.getCurrentPosition = function(success, fail) {
|
||||||
PhoneGap.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
Cordova.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start recording audio file.
|
* Start recording audio file.
|
||||||
*/
|
*/
|
||||||
Media.prototype.startRecord = function() {
|
Media.prototype.startRecord = function() {
|
||||||
PhoneGap.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
Cordova.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop recording audio file.
|
* Stop recording audio file.
|
||||||
*/
|
*/
|
||||||
Media.prototype.stopRecord = function() {
|
Media.prototype.stopRecord = function() {
|
||||||
PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
Cordova.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release the resources.
|
* Release the resources.
|
||||||
*/
|
*/
|
||||||
Media.prototype.release = function() {
|
Media.prototype.release = function() {
|
||||||
PhoneGap.exec(null, null, "Media", "release", [this.id]);
|
Cordova.exec(null, null, "Media", "release", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust the volume.
|
* Adjust the volume.
|
||||||
*/
|
*/
|
||||||
Media.prototype.setVolume = function(volume) {
|
Media.prototype.setVolume = function(volume) {
|
||||||
PhoneGap.exec(null, null, "Media", "setVolume", [this.id, volume]);
|
Cordova.exec(null, null, "Media", "setVolume", [this.id, volume]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of media objects.
|
* List of media objects.
|
||||||
* PRIVATE
|
* PRIVATE
|
||||||
*/
|
*/
|
||||||
PhoneGap.mediaObjects = {};
|
Cordova.mediaObjects = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object that receives native callbacks.
|
* Object that receives native callbacks.
|
||||||
* PRIVATE
|
* PRIVATE
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
PhoneGap.Media = function() {};
|
Cordova.Media = function() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the media object.
|
* Get the media object.
|
||||||
@ -193,8 +193,8 @@ PhoneGap.Media = function() {};
|
|||||||
*
|
*
|
||||||
* @param id The media object id (string)
|
* @param id The media object id (string)
|
||||||
*/
|
*/
|
||||||
PhoneGap.Media.getMediaObject = function(id) {
|
Cordova.Media.getMediaObject = function(id) {
|
||||||
return PhoneGap.mediaObjects[id];
|
return Cordova.mediaObjects[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,8 +205,8 @@ PhoneGap.Media.getMediaObject = function(id) {
|
|||||||
* @param status The status code (int)
|
* @param status The status code (int)
|
||||||
* @param msg The status message (string)
|
* @param msg The status message (string)
|
||||||
*/
|
*/
|
||||||
PhoneGap.Media.onStatus = function(id, msg, value) {
|
Cordova.Media.onStatus = function(id, msg, value) {
|
||||||
var media = PhoneGap.mediaObjects[id];
|
var media = Cordova.mediaObjects[id];
|
||||||
// If state update
|
// If state update
|
||||||
if (msg === Media.MEDIA_STATE) {
|
if (msg === Media.MEDIA_STATE) {
|
||||||
if (value === Media.MEDIA_STOPPED) {
|
if (value === Media.MEDIA_STOPPED) {
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("network")) {
|
if (!Cordova.hasResource("network")) {
|
||||||
PhoneGap.addResource("network");
|
Cordova.addResource("network");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains information about the current network Connection.
|
* This class contains information about the current network Connection.
|
||||||
@ -39,7 +39,7 @@ var Connection = function() {
|
|||||||
// set a timer if still offline at the end of timer send the offline event
|
// set a timer if still offline at the end of timer send the offline event
|
||||||
me._timer = setTimeout(function(){
|
me._timer = setTimeout(function(){
|
||||||
me.type = type;
|
me.type = type;
|
||||||
PhoneGap.fireDocumentEvent('offline');
|
Cordova.fireDocumentEvent('offline');
|
||||||
me._timer = null;
|
me._timer = null;
|
||||||
}, me.timeout);
|
}, me.timeout);
|
||||||
} else {
|
} else {
|
||||||
@ -49,21 +49,21 @@ var Connection = function() {
|
|||||||
me._timer = null;
|
me._timer = null;
|
||||||
}
|
}
|
||||||
me.type = type;
|
me.type = type;
|
||||||
PhoneGap.fireDocumentEvent('online');
|
Cordova.fireDocumentEvent('online');
|
||||||
}
|
}
|
||||||
|
|
||||||
// should only fire this once
|
// should only fire this once
|
||||||
if (me._firstRun) {
|
if (me._firstRun) {
|
||||||
me._firstRun = false;
|
me._firstRun = false;
|
||||||
PhoneGap.onPhoneGapConnectionReady.fire();
|
Cordova.onCordovaConnectionReady.fire();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(e) {
|
function(e) {
|
||||||
// If we can't get the network info we should still tell PhoneGap
|
// If we can't get the network info we should still tell Cordova
|
||||||
// to fire the deviceready event.
|
// to fire the deviceready event.
|
||||||
if (me._firstRun) {
|
if (me._firstRun) {
|
||||||
me._firstRun = false;
|
me._firstRun = false;
|
||||||
PhoneGap.onPhoneGapConnectionReady.fire();
|
Cordova.onCordovaConnectionReady.fire();
|
||||||
}
|
}
|
||||||
console.log("Error initializing Network Connection: " + e);
|
console.log("Error initializing Network Connection: " + e);
|
||||||
});
|
});
|
||||||
@ -85,11 +85,11 @@ Connection.NONE = "none";
|
|||||||
*/
|
*/
|
||||||
Connection.prototype.getInfo = function(successCallback, errorCallback) {
|
Connection.prototype.getInfo = function(successCallback, errorCallback) {
|
||||||
// Get info
|
// Get info
|
||||||
PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
|
Cordova.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.network === "undefined") {
|
if (typeof navigator.network === "undefined") {
|
||||||
navigator.network = {};
|
navigator.network = {};
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("notification")) {
|
if (!Cordova.hasResource("notification")) {
|
||||||
PhoneGap.addResource("notification");
|
Cordova.addResource("notification");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides access to notifications on the device.
|
* This class provides access to notifications on the device.
|
||||||
@ -38,7 +38,7 @@ var Notification = function() {
|
|||||||
Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
|
Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
|
||||||
var _title = (title || "Alert");
|
var _title = (title || "Alert");
|
||||||
var _buttonLabel = (buttonLabel || "OK");
|
var _buttonLabel = (buttonLabel || "OK");
|
||||||
PhoneGap.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
Cordova.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,21 +53,21 @@ Notification.prototype.alert = function(message, completeCallback, title, button
|
|||||||
Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
|
Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
|
||||||
var _title = (title || "Confirm");
|
var _title = (title || "Confirm");
|
||||||
var _buttonLabels = (buttonLabels || "OK,Cancel");
|
var _buttonLabels = (buttonLabels || "OK,Cancel");
|
||||||
PhoneGap.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
|
Cordova.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start spinning the activity indicator on the statusbar
|
* Start spinning the activity indicator on the statusbar
|
||||||
*/
|
*/
|
||||||
Notification.prototype.activityStart = function() {
|
Notification.prototype.activityStart = function() {
|
||||||
PhoneGap.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
|
Cordova.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop spinning the activity indicator on the statusbar, if it's currently spinning
|
* Stop spinning the activity indicator on the statusbar, if it's currently spinning
|
||||||
*/
|
*/
|
||||||
Notification.prototype.activityStop = function() {
|
Notification.prototype.activityStop = function() {
|
||||||
PhoneGap.exec(null, null, "Notification", "activityStop", []);
|
Cordova.exec(null, null, "Notification", "activityStop", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +77,7 @@ Notification.prototype.activityStop = function() {
|
|||||||
* @param {String} message Message to display in the dialog.
|
* @param {String} message Message to display in the dialog.
|
||||||
*/
|
*/
|
||||||
Notification.prototype.progressStart = function(title, message) {
|
Notification.prototype.progressStart = function(title, message) {
|
||||||
PhoneGap.exec(null, null, "Notification", "progressStart", [title, message]);
|
Cordova.exec(null, null, "Notification", "progressStart", [title, message]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,14 +86,14 @@ Notification.prototype.progressStart = function(title, message) {
|
|||||||
* @param {Number} value 0-100
|
* @param {Number} value 0-100
|
||||||
*/
|
*/
|
||||||
Notification.prototype.progressValue = function(value) {
|
Notification.prototype.progressValue = function(value) {
|
||||||
PhoneGap.exec(null, null, "Notification", "progressValue", [value]);
|
Cordova.exec(null, null, "Notification", "progressValue", [value]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the progress dialog.
|
* Close the progress dialog.
|
||||||
*/
|
*/
|
||||||
Notification.prototype.progressStop = function() {
|
Notification.prototype.progressStop = function() {
|
||||||
PhoneGap.exec(null, null, "Notification", "progressStop", []);
|
Cordova.exec(null, null, "Notification", "progressStop", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +112,7 @@ Notification.prototype.blink = function(count, colour) {
|
|||||||
* @param {Integer} mills The number of milliseconds to vibrate for.
|
* @param {Integer} mills The number of milliseconds to vibrate for.
|
||||||
*/
|
*/
|
||||||
Notification.prototype.vibrate = function(mills) {
|
Notification.prototype.vibrate = function(mills) {
|
||||||
PhoneGap.exec(null, null, "Notification", "vibrate", [mills]);
|
Cordova.exec(null, null, "Notification", "vibrate", [mills]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,10 +122,10 @@ Notification.prototype.vibrate = function(mills) {
|
|||||||
* @param {Integer} count The number of beeps.
|
* @param {Integer} count The number of beeps.
|
||||||
*/
|
*/
|
||||||
Notification.prototype.beep = function(count) {
|
Notification.prototype.beep = function(count) {
|
||||||
PhoneGap.exec(null, null, "Notification", "beep", [count]);
|
Cordova.exec(null, null, "Notification", "beep", [count]);
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
if (typeof navigator.notification === "undefined") {
|
if (typeof navigator.notification === "undefined") {
|
||||||
navigator.notification = new Notification();
|
navigator.notification = new Notification();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("position")) {
|
if (!Cordova.hasResource("position")) {
|
||||||
PhoneGap.addResource("position");
|
Cordova.addResource("position");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains position information.
|
* This class contains position information.
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
* most manufacturers ship with Android 1.5 and do not do OTA Updates, this is required
|
* most manufacturers ship with Android 1.5 and do not do OTA Updates, this is required
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PhoneGap.hasResource("storage")) {
|
if (!Cordova.hasResource("storage")) {
|
||||||
PhoneGap.addResource("storage");
|
Cordova.addResource("storage");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL result set object
|
* SQL result set object
|
||||||
@ -153,7 +153,7 @@ DroidDB.prototype.fail = function(reason, id) {
|
|||||||
var DroidDB_Query = function(tx) {
|
var DroidDB_Query = function(tx) {
|
||||||
|
|
||||||
// Set the id of the query
|
// Set the id of the query
|
||||||
this.id = PhoneGap.createUUID();
|
this.id = Cordova.createUUID();
|
||||||
|
|
||||||
// Add this query to the queue
|
// Add this query to the queue
|
||||||
droiddb.queryQueue[this.id] = this;
|
droiddb.queryQueue[this.id] = this;
|
||||||
@ -181,7 +181,7 @@ var DroidDB_Query = function(tx) {
|
|||||||
var DroidDB_Tx = function() {
|
var DroidDB_Tx = function() {
|
||||||
|
|
||||||
// Set the id of the transaction
|
// Set the id of the transaction
|
||||||
this.id = PhoneGap.createUUID();
|
this.id = Cordova.createUUID();
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
this.successCallback = null;
|
this.successCallback = null;
|
||||||
@ -266,7 +266,7 @@ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCa
|
|||||||
query.errorCallback = errorCallback;
|
query.errorCallback = errorCallback;
|
||||||
|
|
||||||
// Call native code
|
// Call native code
|
||||||
PhoneGap.exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
Cordova.exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
var DatabaseShell = function() {
|
var DatabaseShell = function() {
|
||||||
@ -308,7 +308,7 @@ DatabaseShell.prototype.transaction = function(process, errorCallback, successCa
|
|||||||
* @return Database object
|
* @return Database object
|
||||||
*/
|
*/
|
||||||
var DroidDB_openDatabase = function(name, version, display_name, size) {
|
var DroidDB_openDatabase = function(name, version, display_name, size) {
|
||||||
PhoneGap.exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
Cordova.exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
||||||
var db = new DatabaseShell();
|
var db = new DatabaseShell();
|
||||||
return db;
|
return db;
|
||||||
};
|
};
|
||||||
@ -340,7 +340,7 @@ var CupcakeLocalStorage = function() {
|
|||||||
storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
|
storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
|
||||||
}
|
}
|
||||||
setLength(result.rows.length);
|
setLength(result.rows.length);
|
||||||
PhoneGap.initializationComplete("cupcakeStorage");
|
Cordova.initializationComplete("cupcakeStorage");
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -401,7 +401,7 @@ var CupcakeLocalStorage = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
Cordova.addConstructor(function() {
|
||||||
var setupDroidDB = function() {
|
var setupDroidDB = function() {
|
||||||
navigator.openDatabase = window.openDatabase = DroidDB_openDatabase;
|
navigator.openDatabase = window.openDatabase = DroidDB_openDatabase;
|
||||||
window.droiddb = new DroidDB();
|
window.droiddb = new DroidDB();
|
||||||
@ -433,7 +433,7 @@ PhoneGap.addConstructor(function() {
|
|||||||
|
|
||||||
if ((typeof window.localStorage == "undefined") || (window.localStorage == null)) {
|
if ((typeof window.localStorage == "undefined") || (window.localStorage == null)) {
|
||||||
navigator.localStorage = window.localStorage = new CupcakeLocalStorage();
|
navigator.localStorage = window.localStorage = new CupcakeLocalStorage();
|
||||||
PhoneGap.waitForInitialization("cupcakeStorage");
|
Cordova.waitForInitialization("cupcakeStorage");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title></title>
|
<title></title>
|
||||||
<script src="phonegap-1.4.1.js"></script>
|
<script src="cordova-1.4.1.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="PhoneGap" default="jar">
|
<project name="Cordova" default="jar">
|
||||||
|
|
||||||
<!-- LOAD VERSION -->
|
<!-- LOAD VERSION -->
|
||||||
<loadfile property="version" srcFile="../VERSION">
|
<loadfile property="version" srcFile="../VERSION">
|
||||||
@ -95,12 +95,12 @@
|
|||||||
<delete dir="assets/lib"/>
|
<delete dir="assets/lib"/>
|
||||||
<mkdir dir="assets/lib"/>
|
<mkdir dir="assets/lib"/>
|
||||||
<echo file="assets/lib/lint.js">var alert=function(){},device={},Element={},debug={};</echo>
|
<echo file="assets/lib/lint.js">var alert=function(){},device={},Element={},debug={};</echo>
|
||||||
<concat destfile="assets/lib/phonegap-lint.js" append="true">
|
<concat destfile="assets/lib/cordova-lint.js" append="true">
|
||||||
<fileset dir="assets/lib">
|
<fileset dir="assets/lib">
|
||||||
<include name="lint.js" />
|
<include name="lint.js" />
|
||||||
</fileset>
|
</fileset>
|
||||||
<fileset dir="assets/www">
|
<fileset dir="assets/www">
|
||||||
<include name="phonegap-${version}.js" />
|
<include name="cordova-${version}.js" />
|
||||||
</fileset>
|
</fileset>
|
||||||
</concat>
|
</concat>
|
||||||
|
|
||||||
@ -111,57 +111,57 @@
|
|||||||
<arg value="${basedir}/util/js.jar"/>
|
<arg value="${basedir}/util/js.jar"/>
|
||||||
<arg value="org.mozilla.javascript.tools.shell.Main"/>
|
<arg value="org.mozilla.javascript.tools.shell.Main"/>
|
||||||
<arg value="${basedir}/util/jslint.js"/>
|
<arg value="${basedir}/util/jslint.js"/>
|
||||||
<arg value="${basedir}/js/lib/phonegap-lint.js"/>
|
<arg value="${basedir}/js/lib/cordova-lint.js"/>
|
||||||
</exec>
|
</exec>
|
||||||
<exec executable="java" os="Mac OS X">
|
<exec executable="java" os="Mac OS X">
|
||||||
<arg value="-cp"/>
|
<arg value="-cp"/>
|
||||||
<arg value="../util/js.jar"/>
|
<arg value="../util/js.jar"/>
|
||||||
<arg value="org.mozilla.javascript.tools.shell.Main"/>
|
<arg value="org.mozilla.javascript.tools.shell.Main"/>
|
||||||
<arg value="../util/jslint.js"/>
|
<arg value="../util/jslint.js"/>
|
||||||
<arg value="assets/lib/phonegap-lint.js"/>
|
<arg value="assets/lib/cordova-lint.js"/>
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Combine JavaScript files into one phonegap-uncompressed.js file. -->
|
<!-- Combine JavaScript files into one cordova-uncompressed.js file. -->
|
||||||
<target name="build-javascript">
|
<target name="build-javascript">
|
||||||
|
|
||||||
<!-- Clean up existing files -->
|
<!-- Clean up existing files -->
|
||||||
<!--<delete file="assets/www/phonegap_${version}.js"/>-->
|
<!--<delete file="assets/www/cordova_${version}.js"/>-->
|
||||||
|
|
||||||
<!-- Create uncompressed JS file -->
|
<!-- Create uncompressed JS file -->
|
||||||
<concat destfile="assets/www/phonegap-${version}.js">
|
<concat destfile="assets/www/cordova-${version}.js">
|
||||||
<filelist dir="assets/js" files="phonegap.js.base,device.js"/>
|
<filelist dir="assets/js" files="cordova.js.base,device.js"/>
|
||||||
<fileset dir="assets/js" includes="*.js" excludes="phonegap.js.base,device.js"/>
|
<fileset dir="assets/js" includes="*.js" excludes="cordova.js.base,device.js"/>
|
||||||
</concat>
|
</concat>
|
||||||
|
|
||||||
<!-- update project files to reference phonegap-x.x.x.min.js -->
|
<!-- update project files to reference cordova-x.x.x.min.js -->
|
||||||
<replaceregexp match="phonegap(.*)\.js" replace="phonegap-${version}.js" byline="true">
|
<replaceregexp match="cordova(.*)\.js" replace="cordova-${version}.js" byline="true">
|
||||||
<fileset file="assets/www/index.html" />
|
<fileset file="assets/www/index.html" />
|
||||||
<!-- <fileset file="../bin/templates/project/assets/www/index.html" /> -->
|
<!-- <fileset file="../bin/templates/project/assets/www/index.html" /> -->
|
||||||
</replaceregexp>
|
</replaceregexp>
|
||||||
<!-- This is sketchy, but it works, ${dblQuote} does not -->
|
<!-- This is sketchy, but it works, ${dblQuote} does not -->
|
||||||
<replaceregexp match="phonegapVersion = [\u0022].*[\u0022];" replace='phonegapVersion = ${dblQuote}${version}${dblQuote};' byline="true">
|
<replaceregexp match="cordovaVersion = [\u0022].*[\u0022];" replace='cordovaVersion = ${dblQuote}${version}${dblQuote};' byline="true">
|
||||||
<fileset file="src/com/phonegap/Device.java" />
|
<fileset file="src/org/apache/cordova/Device.java" />
|
||||||
</replaceregexp>
|
</replaceregexp>
|
||||||
|
|
||||||
<!-- Delete temp file -->
|
<!-- Delete temp file -->
|
||||||
<!--<delete file="assets/www/phonegap-tmp.js"/>-->
|
<!--<delete file="assets/www/cordova-tmp.js"/>-->
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Build PhoneGap jar file that includes all native code, and PhoneGap JS file
|
<!-- Build Cordova jar file that includes all native code, and Cordova JS file
|
||||||
that includes all JavaScript code.
|
that includes all JavaScript code.
|
||||||
-->
|
-->
|
||||||
<target name="jar" depends="build-javascript, -compile">
|
<target name="jar" depends="build-javascript, -compile">
|
||||||
<jar jarfile="phonegap-${version}.jar" basedir="bin/classes" excludes="com/phonegap/R.class,com/phonegap/R$*.class"/>
|
<jar jarfile="cordova-${version}.jar" basedir="bin/classes" excludes="org/apache/cordova/R.class,org/apache/cordova/R$*.class"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- tests for Java files -->
|
<!-- tests for Java files -->
|
||||||
<property name="test.dir" location="test/com/phonegap" />
|
<property name="test.dir" location="test/org/apache/cordova" />
|
||||||
|
|
||||||
<path id="test.classpath">
|
<path id="test.classpath">
|
||||||
<!-- requires both junit and phonegap -->
|
<!-- requires both junit and cordova -->
|
||||||
<pathelement location="libs/junit-4.10.jar" />
|
<pathelement location="libs/junit-4.10.jar" />
|
||||||
<pathelement location="phonegap-${version}.jar" />
|
<pathelement location="cordova-${version}.jar" />
|
||||||
<pathelement location="${test.dir}" />
|
<pathelement location="${test.dir}" />
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
@ -184,10 +184,10 @@
|
|||||||
</junit>
|
</junit>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="phonegap_debug" depends="build-javascript, debug">
|
<target name="cordova_debug" depends="build-javascript, debug">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="phonegap_release" depends="build-javascript, release">
|
<target name="cordova_release" depends="build-javascript, release">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">PhoneGap</string>
|
<string name="app_name">Cordova</string>
|
||||||
<string name="go">Snap</string>
|
<string name="go">Snap</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<phonegap>
|
<cordova>
|
||||||
<!--
|
<!--
|
||||||
access elements control the Android whitelist.
|
access elements control the Android whitelist.
|
||||||
Domains are assumed blocked unless set otherwise
|
Domains are assumed blocked unless set otherwise
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<log level="DEBUG"/>
|
<log level="DEBUG"/>
|
||||||
<preference name="classicRender" value="true" />
|
<preference name="classicRender" value="true" />
|
||||||
</phonegap>
|
</cordova>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin name="App" value="com.phonegap.App"/>
|
<plugin name="App" value="org.apache.cordova.App"/>
|
||||||
<plugin name="Geolocation" value="com.phonegap.GeoBroker"/>
|
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
|
||||||
<plugin name="Device" value="com.phonegap.Device"/>
|
<plugin name="Device" value="org.apache.cordova.Device"/>
|
||||||
<plugin name="Accelerometer" value="com.phonegap.AccelListener"/>
|
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
|
||||||
<plugin name="Compass" value="com.phonegap.CompassListener"/>
|
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
|
||||||
<plugin name="Media" value="com.phonegap.AudioHandler"/>
|
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
|
||||||
<plugin name="Camera" value="com.phonegap.CameraLauncher"/>
|
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
||||||
<plugin name="Contacts" value="com.phonegap.ContactManager"/>
|
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
|
||||||
<plugin name="File" value="com.phonegap.FileUtils"/>
|
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
||||||
<plugin name="Network Status" value="com.phonegap.NetworkManager"/>
|
<plugin name="Network Status" value="org.apache.cordova.NetworkManager"/>
|
||||||
<plugin name="Notification" value="com.phonegap.Notification"/>
|
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
||||||
<plugin name="Storage" value="com.phonegap.Storage"/>
|
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
||||||
<plugin name="Temperature" value="com.phonegap.TempListener"/>
|
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>
|
||||||
<plugin name="FileTransfer" value="com.phonegap.FileTransfer"/>
|
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
||||||
<plugin name="Capture" value="com.phonegap.Capture"/>
|
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
||||||
<plugin name="Battery" value="com.phonegap.BatteryListener"/>
|
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
@ -72,7 +72,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(PhonegapActivity ctx) {
|
public void setContext(CordovaActivity ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
@ -17,14 +17,14 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
@ -16,22 +16,23 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class called by PhonegapActivity to play and record audio.
|
* This class called by CordovaActivity to play and record audio.
|
||||||
* The file can be local or over a network using http.
|
* The file can be local or over a network using http.
|
||||||
*
|
*
|
||||||
* Audio formats supported (tested):
|
* Audio formats supported (tested):
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
@ -31,8 +31,8 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the audio playback and recording capabilities used by PhoneGap.
|
* This class implements the audio playback and recording capabilities used by Cordova.
|
||||||
* It is called by the AudioHandler PhoneGap class.
|
* It is called by the AudioHandler Cordova class.
|
||||||
* Only one file can be played or recorded per class instance.
|
* Only one file can be played or recorded per class instance.
|
||||||
*
|
*
|
||||||
* Local audio files must reside in one of two places:
|
* Local audio files must reside in one of two places:
|
||||||
@ -116,7 +116,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
public void startRecording(String file) {
|
public void startRecording(String file) {
|
||||||
if (this.mPlayer != null) {
|
if (this.mPlayer != null) {
|
||||||
Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
|
Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we're not already recording
|
// Make sure we're not already recording
|
||||||
@ -137,11 +137,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
|
Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
public void startPlaying(String file) {
|
public void startPlaying(String file) {
|
||||||
if (this.recorder != null) {
|
if (this.recorder != null) {
|
||||||
Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
|
Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a new request to play audio, or stopped
|
// If this is a new request to play audio, or stopped
|
||||||
@ -228,7 +228,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state);
|
Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state);
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
if (this.mPlayer != null) {
|
if (this.mPlayer != null) {
|
||||||
this.mPlayer.seekTo(milliseconds);
|
this.mPlayer.seekTo(milliseconds);
|
||||||
Log.d(LOG_TAG, "Send a onStatus update for the new seek");
|
Log.d(LOG_TAG, "Send a onStatus update for the new seek");
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state);
|
Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state);
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);
|
Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
public long getCurrentPosition() {
|
public long getCurrentPosition() {
|
||||||
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
|
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
|
||||||
int curPos = this.mPlayer.getCurrentPosition();
|
int curPos = this.mPlayer.getCurrentPosition();
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
|
||||||
return curPos;
|
return curPos;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -384,7 +384,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
this.prepareOnly = false;
|
this.prepareOnly = false;
|
||||||
|
|
||||||
// Send status notification to JavaScript
|
// Send status notification to JavaScript
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
this.mPlayer.release();
|
this.mPlayer.release();
|
||||||
|
|
||||||
// Send error notification to JavaScript
|
// Send error notification to JavaScript
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+arg1+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+arg1+");");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
*/
|
*/
|
||||||
private void setState(int state) {
|
private void setState(int state) {
|
||||||
if (this.state != state) {
|
if (this.state != state) {
|
||||||
this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
|
this.handler.sendJavascript("Cordova.Media.onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = state;
|
this.state = state;
|
@ -1,4 +1,4 @@
|
|||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class AuthenticationToken defines the userName and password to be used for authenticating a web resource
|
* The Class AuthenticationToken defines the userName and password to be used for authenticating a web resource
|
@ -16,14 +16,14 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -31,7 +31,7 @@ import java.util.LinkedList;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a way for Java to run JavaScript in the web page that has loaded PhoneGap.
|
* This class provides a way for Java to run JavaScript in the web page that has loaded Cordova.
|
||||||
* The CallbackServer class implements an XHR server and a polling server with a list of JavaScript
|
* The CallbackServer class implements an XHR server and a polling server with a list of JavaScript
|
||||||
* statements that are to be executed on the web page.
|
* statements that are to be executed on the web page.
|
||||||
*
|
*
|
||||||
@ -107,10 +107,10 @@ public class CallbackServer implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Init callback server and start XHR if running local app.
|
* Init callback server and start XHR if running local app.
|
||||||
*
|
*
|
||||||
* If PhoneGap app is loaded from file://, then we can use XHR
|
* If Cordova app is loaded from file://, then we can use XHR
|
||||||
* otherwise we have to use polling due to cross-domain security restrictions.
|
* otherwise we have to use polling due to cross-domain security restrictions.
|
||||||
*
|
*
|
||||||
* @param url The URL of the PhoneGap app being loaded
|
* @param url The URL of the Cordova app being loaded
|
||||||
*/
|
*/
|
||||||
public void init(String url) {
|
public void init(String url) {
|
||||||
//System.out.println("CallbackServer.start("+url+")");
|
//System.out.println("CallbackServer.start("+url+")");
|
||||||
@ -137,7 +137,7 @@ public class CallbackServer implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Re-init when loading a new HTML page into webview.
|
* Re-init when loading a new HTML page into webview.
|
||||||
*
|
*
|
||||||
* @param url The URL of the PhoneGap app being loaded
|
* @param url The URL of the Cordova app being loaded
|
||||||
*/
|
*/
|
||||||
public void reinit(String url) {
|
public void reinit(String url) {
|
||||||
this.stopServer();
|
this.stopServer();
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -26,13 +26,13 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
@ -143,7 +143,7 @@ public class CameraLauncher extends Plugin {
|
|||||||
/**
|
/**
|
||||||
* Take a picture with the camera.
|
* Take a picture with the camera.
|
||||||
* When an image is captured or the camera view is cancelled, the result is returned
|
* When an image is captured or the camera view is cancelled, the result is returned
|
||||||
* in PhonegapActivity.onActivityResult, which forwards the result to this.onActivityResult.
|
* in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
|
||||||
*
|
*
|
||||||
* The image can either be returned as a base64 string or a URI that points to the file.
|
* The image can either be returned as a base64 string or a URI that points to the file.
|
||||||
* To display base64 string in an img tag, set the source to:
|
* To display base64 string in an img tag, set the source to:
|
@ -16,12 +16,15 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -35,9 +38,6 @@ import android.media.MediaPlayer;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
public class Capture extends Plugin {
|
public class Capture extends Plugin {
|
||||||
|
|
@ -16,17 +16,17 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
@ -69,7 +69,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(PhonegapActivity ctx) {
|
public void setContext(CordovaActivity ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
@ -16,13 +16,13 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class ContactManager extends Plugin {
|
public class ContactManager extends Plugin {
|
||||||
@ -59,7 +59,7 @@ public class ContactManager extends Plugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if we are on an Android 1.X device. If we are return an error as we
|
* Check to see if we are on an Android 1.X device. If we are return an error as we
|
||||||
* do not support this as of PhoneGap 1.0.
|
* do not support this as of Cordova 1.0.
|
||||||
*/
|
*/
|
||||||
if (android.os.Build.VERSION.RELEASE.startsWith("1.")) {
|
if (android.os.Build.VERSION.RELEASE.startsWith("1.")) {
|
||||||
JSONObject res = null;
|
JSONObject res = null;
|
@ -16,11 +16,11 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -42,7 +42,7 @@ import android.widget.EditText;
|
|||||||
public class CordovaChromeClient extends WebChromeClient {
|
public class CordovaChromeClient extends WebChromeClient {
|
||||||
|
|
||||||
|
|
||||||
private String TAG = "PhoneGapLog";
|
private String TAG = "CordovaLog";
|
||||||
private long MAX_QUOTA = 100 * 1024 * 1024;
|
private long MAX_QUOTA = 100 * 1024 * 1024;
|
||||||
private DroidGap ctx;
|
private DroidGap ctx;
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ public class CordovaChromeClient extends WebChromeClient {
|
|||||||
result.confirm(r);
|
result.confirm(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PhoneGap JS has initialized, so show webview
|
// Cordova JS has initialized, so show webview
|
||||||
// (This solves white flash seen when rendering HTML)
|
// (This solves white flash seen when rendering HTML)
|
||||||
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
|
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
|
||||||
ctx.appView.setVisibility(View.VISIBLE);
|
ctx.appView.setVisibility(View.VISIBLE);
|
@ -16,9 +16,9 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import com.phonegap.api.LOG;
|
import org.apache.cordova.api.LOG;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
@ -135,7 +135,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
// All else
|
// All else
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// If our app or file:, then load into a new phonegap webview container by starting a new instance of our activity.
|
// If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity.
|
||||||
// Our app continues to run. When BACK is pressed, our app is redisplayed.
|
// Our app continues to run. When BACK is pressed, our app is redisplayed.
|
||||||
if (url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || ctx.isUrlWhiteListed(url)) {
|
if (url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || ctx.isUrlWhiteListed(url)) {
|
||||||
this.ctx.loadUrl(url);
|
this.ctx.loadUrl(url);
|
||||||
@ -218,10 +218,10 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
// not loaded yet then just set a flag so that the onNativeReady can be fired
|
// not loaded yet then just set a flag so that the onNativeReady can be fired
|
||||||
// from the JS side when the JS gets to that code.
|
// from the JS side when the JS gets to that code.
|
||||||
if (!url.equals("about:blank")) {
|
if (!url.equals("about:blank")) {
|
||||||
ctx.appView.loadUrl("javascript:try{ PhoneGap.onNativeReady.fire();}catch(e){_nativeReady = true;}");
|
ctx.appView.loadUrl("javascript:try{ Cordova.onNativeReady.fire();}catch(e){_nativeReady = true;}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make app visible after 2 sec in case there was a JS error and PhoneGap JS never initialized correctly
|
// Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
|
||||||
if (ctx.appView.getVisibility() == View.INVISIBLE) {
|
if (ctx.appView.getVisibility() == View.INVISIBLE) {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
@ -16,16 +16,17 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -37,7 +38,7 @@ import android.telephony.TelephonyManager;
|
|||||||
public class Device extends Plugin {
|
public class Device extends Plugin {
|
||||||
public static final String TAG = "Device";
|
public static final String TAG = "Device";
|
||||||
|
|
||||||
public static String phonegapVersion = "1.4.1"; // PhoneGap version
|
public static String cordovaVersion = "1.4.1"; // Cordova version
|
||||||
public static String platform = "Android"; // Device OS
|
public static String platform = "Android"; // Device OS
|
||||||
public static String uuid; // Device UUID
|
public static String uuid; // Device UUID
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ public class Device extends Plugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(PhonegapActivity ctx) {
|
public void setContext(CordovaActivity ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
Device.uuid = getUuid();
|
Device.uuid = getUuid();
|
||||||
this.initTelephonyReceiver();
|
this.initTelephonyReceiver();
|
||||||
@ -80,10 +81,10 @@ public class Device extends Plugin {
|
|||||||
r.put("version", this.getOSVersion());
|
r.put("version", this.getOSVersion());
|
||||||
r.put("platform", Device.platform);
|
r.put("platform", Device.platform);
|
||||||
r.put("name", this.getProductName());
|
r.put("name", this.getProductName());
|
||||||
r.put("phonegap", Device.phonegapVersion);
|
r.put("cordova", Device.cordovaVersion);
|
||||||
//JSONObject pg = new JSONObject();
|
//JSONObject pg = new JSONObject();
|
||||||
//pg.put("version", Device.phonegapVersion);
|
//pg.put("version", Device.CordovaVersion);
|
||||||
//r.put("phonegap", pg);
|
//r.put("cordova", pg);
|
||||||
return new PluginResult(status, r);
|
return new PluginResult(status, r);
|
||||||
}
|
}
|
||||||
return new PluginResult(status, result);
|
return new PluginResult(status, result);
|
||||||
@ -124,7 +125,7 @@ public class Device extends Plugin {
|
|||||||
private void initTelephonyReceiver() {
|
private void initTelephonyReceiver() {
|
||||||
IntentFilter intentFilter = new IntentFilter() ;
|
IntentFilter intentFilter = new IntentFilter() ;
|
||||||
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||||
final PhonegapActivity myctx = this.ctx;
|
final CordovaActivity myctx = this.ctx;
|
||||||
this.telephonyReceiver = new BroadcastReceiver() {
|
this.telephonyReceiver = new BroadcastReceiver() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -175,12 +176,12 @@ public class Device extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PhoneGap version.
|
* Get the Cordova version.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getPhonegapVersion() {
|
public String getCordovaVersion() {
|
||||||
return Device.phonegapVersion;
|
return Device.cordovaVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModel() {
|
public String getModel() {
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -27,6 +27,12 @@ import java.util.Stack;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.cordova.PreferenceNode;
|
||||||
|
import org.apache.cordova.PreferenceSet;
|
||||||
|
import org.apache.cordova.api.IPlugin;
|
||||||
|
import org.apache.cordova.api.LOG;
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.PluginManager;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
@ -70,25 +76,19 @@ import android.webkit.WebViewClient;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import com.phonegap.api.IPlugin;
|
|
||||||
import com.phonegap.api.LOG;
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.PluginManager;
|
|
||||||
|
|
||||||
import com.phonegap.PreferenceNode;
|
|
||||||
import com.phonegap.PreferenceSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the main Android activity that represents the PhoneGap
|
* This class is the main Android activity that represents the Cordova
|
||||||
* application. It should be extended by the user to load the specific
|
* application. It should be extended by the user to load the specific
|
||||||
* html file that contains the application.
|
* html file that contains the application.
|
||||||
*
|
*
|
||||||
* As an example:
|
* As an example:
|
||||||
*
|
*
|
||||||
* package com.phonegap.examples;
|
* package org.apache.cordova.examples;
|
||||||
* import android.app.Activity;
|
* import android.app.Activity;
|
||||||
* import android.os.Bundle;
|
* import android.os.Bundle;
|
||||||
* import com.phonegap.*;
|
* import org.apache.cordova.*;
|
||||||
*
|
*
|
||||||
* public class Examples extends DroidGap {
|
* public class Examples extends DroidGap {
|
||||||
* @Override
|
* @Override
|
||||||
@ -140,26 +140,26 @@ import com.phonegap.PreferenceSet;
|
|||||||
* // Enable app to keep running in background. (Boolean - default=true)
|
* // Enable app to keep running in background. (Boolean - default=true)
|
||||||
* super.setBooleanProperty("keepRunning", false);
|
* super.setBooleanProperty("keepRunning", false);
|
||||||
*
|
*
|
||||||
* Phonegap.xml configuration:
|
* Cordova.xml configuration:
|
||||||
* PhoneGap uses a configuration file at res/xml/phonegap.xml to specify the following settings.
|
* Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
|
||||||
*
|
*
|
||||||
* Approved list of URLs that can be loaded into DroidGap
|
* Approved list of URLs that can be loaded into DroidGap
|
||||||
* <access origin="http://server regexp" subdomains="true" />
|
* <access origin="http://server regexp" subdomains="true" />
|
||||||
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
|
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
|
||||||
* <log level="DEBUG" />
|
* <log level="DEBUG" />
|
||||||
*
|
*
|
||||||
* Phonegap plugins:
|
* Cordova plugins:
|
||||||
* PhoneGap uses a file at res/xml/plugins.xml to list all plugins that are installed.
|
* Cordova uses a file at res/xml/plugins.xml to list all plugins that are installed.
|
||||||
* Before using a new plugin, a new element must be added to the file.
|
* Before using a new plugin, a new element must be added to the file.
|
||||||
* name attribute is the service name passed to PhoneGap.exec() in JavaScript
|
* name attribute is the service name passed to Cordova.exec() in JavaScript
|
||||||
* value attribute is the Java class name to call.
|
* value attribute is the Java class name to call.
|
||||||
*
|
*
|
||||||
* <plugins>
|
* <plugins>
|
||||||
* <plugin name="App" value="com.phonegap.App"/>
|
* <plugin name="App" value="org.apache.cordova.App"/>
|
||||||
* ...
|
* ...
|
||||||
* </plugins>
|
* </plugins>
|
||||||
*/
|
*/
|
||||||
public class DroidGap extends PhonegapActivity {
|
public class DroidGap extends CordovaActivity {
|
||||||
public static String TAG = "DroidGap";
|
public static String TAG = "DroidGap";
|
||||||
|
|
||||||
// The webview for our app
|
// The webview for our app
|
||||||
@ -223,7 +223,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
// when another application (activity) is started.
|
// when another application (activity) is started.
|
||||||
protected boolean keepRunning = true;
|
protected boolean keepRunning = true;
|
||||||
|
|
||||||
// preferences read from phonegap.xml
|
// preferences read from cordova.xml
|
||||||
protected PreferenceSet preferences;
|
protected PreferenceSet preferences;
|
||||||
|
|
||||||
private boolean classicRender;
|
private boolean classicRender;
|
||||||
@ -319,7 +319,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
preferences = new PreferenceSet();
|
preferences = new PreferenceSet();
|
||||||
|
|
||||||
// Load PhoneGap configuration:
|
// Load Cordova configuration:
|
||||||
// white list of allowed URLs
|
// white list of allowed URLs
|
||||||
// debug setting
|
// debug setting
|
||||||
this.loadConfiguration();
|
this.loadConfiguration();
|
||||||
@ -847,7 +847,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send pause event to JavaScript
|
// Send pause event to JavaScript
|
||||||
this.appView.loadUrl("javascript:try{PhoneGap.fireDocumentEvent('pause');}catch(e){};");
|
this.appView.loadUrl("javascript:try{Cordova.fireDocumentEvent('pause');}catch(e){};");
|
||||||
|
|
||||||
// Forward to plugins
|
// Forward to plugins
|
||||||
this.pluginManager.onPause(this.keepRunning);
|
this.pluginManager.onPause(this.keepRunning);
|
||||||
@ -888,7 +888,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send resume event to JavaScript
|
// Send resume event to JavaScript
|
||||||
this.appView.loadUrl("javascript:try{PhoneGap.fireDocumentEvent('resume');}catch(e){};");
|
this.appView.loadUrl("javascript:try{Cordova.fireDocumentEvent('resume');}catch(e){};");
|
||||||
|
|
||||||
// Forward to plugins
|
// Forward to plugins
|
||||||
this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);
|
this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);
|
||||||
@ -918,7 +918,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
|
|
||||||
|
|
||||||
// Send destroy event to JavaScript
|
// Send destroy event to JavaScript
|
||||||
this.appView.loadUrl("javascript:try{PhoneGap.onDestroy.fire();}catch(e){};");
|
this.appView.loadUrl("javascript:try{Cordova.onDestroy.fire();}catch(e){};");
|
||||||
|
|
||||||
// Load blank page so that JavaScript onunload is called
|
// Load blank page so that JavaScript onunload is called
|
||||||
this.appView.loadUrl("about:blank");
|
this.appView.loadUrl("about:blank");
|
||||||
@ -968,12 +968,12 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the specified URL in the PhoneGap webview or a new browser instance.
|
* Load the specified URL in the Cordova webview or a new browser instance.
|
||||||
*
|
*
|
||||||
* NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
|
* NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
|
||||||
*
|
*
|
||||||
* @param url The url to load.
|
* @param url The url to load.
|
||||||
* @param openExternal Load url in browser instead of PhoneGap webview.
|
* @param openExternal Load url in browser instead of Cordova webview.
|
||||||
* @param clearHistory Clear the history stack, so new page becomes top of history
|
* @param clearHistory Clear the history stack, so new page becomes top of history
|
||||||
* @param params DroidGap parameters for new app
|
* @param params DroidGap parameters for new app
|
||||||
*/
|
*/
|
||||||
@ -1080,7 +1080,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
|
|
||||||
// If back key is bound, then send event to JavaScript
|
// If back key is bound, then send event to JavaScript
|
||||||
if (this.bound) {
|
if (this.bound) {
|
||||||
this.appView.loadUrl("javascript:PhoneGap.fireDocumentEvent('backbutton');");
|
this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('backbutton');");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1102,13 +1102,13 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
|
|
||||||
// If menu key
|
// If menu key
|
||||||
else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
||||||
this.appView.loadUrl("javascript:PhoneGap.fireDocumentEvent('menubutton');");
|
this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('menubutton');");
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If search key
|
// If search key
|
||||||
else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
||||||
this.appView.loadUrl("javascript:PhoneGap.fireDocumentEvent('searchbutton');");
|
this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('searchbutton');");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1243,16 +1243,16 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PhoneGap configuration from res/xml/phonegap.xml.
|
* Load Cordova configuration from res/xml/cordova.xml.
|
||||||
* Approved list of URLs that can be loaded into DroidGap
|
* Approved list of URLs that can be loaded into DroidGap
|
||||||
* <access origin="http://server regexp" subdomains="true" />
|
* <access origin="http://server regexp" subdomains="true" />
|
||||||
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
|
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
|
||||||
* <log level="DEBUG" />
|
* <log level="DEBUG" />
|
||||||
*/
|
*/
|
||||||
private void loadConfiguration() {
|
private void loadConfiguration() {
|
||||||
int id = getResources().getIdentifier("phonegap", "xml", getPackageName());
|
int id = getResources().getIdentifier("cordova", "xml", getPackageName());
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
LOG.i("PhoneGapLog", "phonegap.xml missing. Ignoring...");
|
LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XmlResourceParser xml = getResources().getXml(id);
|
XmlResourceParser xml = getResources().getXml(id);
|
||||||
@ -1269,7 +1269,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
else if (strNode.equals("log")) {
|
else if (strNode.equals("log")) {
|
||||||
String level = xml.getAttributeValue(null, "level");
|
String level = xml.getAttributeValue(null, "level");
|
||||||
LOG.i("PhoneGapLog", "Found log level %s", level);
|
LOG.i("CordovaLog", "Found log level %s", level);
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
LOG.setLogLevel(level);
|
LOG.setLogLevel(level);
|
||||||
}
|
}
|
||||||
@ -1282,7 +1282,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
boolean readonly = (readonlyString != null &&
|
boolean readonly = (readonlyString != null &&
|
||||||
readonlyString.equals("true"));
|
readonlyString.equals("true"));
|
||||||
|
|
||||||
LOG.i("PhoneGapLog", "Found preference for %s", name);
|
LOG.i("CordovaLog", "Found preference for %s", name);
|
||||||
|
|
||||||
preferences.add(new PreferenceNode(name, value, readonly));
|
preferences.add(new PreferenceNode(name, value, readonly));
|
||||||
}
|
}
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -41,6 +41,8 @@ import javax.net.ssl.SSLSocketFactory;
|
|||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -49,8 +51,6 @@ import android.net.Uri;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
public class FileTransfer extends Plugin {
|
public class FileTransfer extends Plugin {
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class FileTransfer extends Plugin {
|
|||||||
private HostnameVerifier defaultHostnameVerifier = null;
|
private HostnameVerifier defaultHostnameVerifier = null;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.phonegap.api.Plugin#execute(java.lang.String, org.json.JSONArray, java.lang.String)
|
* @see org.apache.cordova.api.Plugin#execute(java.lang.String, org.json.JSONArray, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -25,6 +25,14 @@ import java.net.URLDecoder;
|
|||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
|
import org.apache.cordova.file.EncodingException;
|
||||||
|
import org.apache.cordova.file.FileExistsException;
|
||||||
|
import org.apache.cordova.file.InvalidModificationException;
|
||||||
|
import org.apache.cordova.file.NoModificationAllowedException;
|
||||||
|
import org.apache.cordova.file.TypeMismatchException;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -36,14 +44,6 @@ import android.provider.MediaStore;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
import com.phonegap.file.EncodingException;
|
|
||||||
import com.phonegap.file.FileExistsException;
|
|
||||||
import com.phonegap.file.InvalidModificationException;
|
|
||||||
import com.phonegap.file.NoModificationAllowedException;
|
|
||||||
import com.phonegap.file.TypeMismatchException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides SD card file and directory services to JavaScript.
|
* This class provides SD card file and directory services to JavaScript.
|
||||||
@ -1014,7 +1014,7 @@ public class FileUtils extends Plugin {
|
|||||||
* @param ctx the current applicaiton context
|
* @param ctx the current applicaiton context
|
||||||
* @return the full path to the file
|
* @return the full path to the file
|
||||||
*/
|
*/
|
||||||
protected static String getRealPathFromURI(Uri contentUri, PhonegapActivity ctx) {
|
protected static String getRealPathFromURI(Uri contentUri, CordovaActivity ctx) {
|
||||||
String[] proj = { _DATA };
|
String[] proj = { _DATA };
|
||||||
Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null);
|
Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null);
|
||||||
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
@ -16,16 +16,16 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class is the interface to the Geolocation. It's bound to the geo object.
|
* This class is the interface to the Geolocation. It's bound to the geo object.
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
@ -17,9 +17,9 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
@ -33,7 +33,7 @@ import android.os.Bundle;
|
|||||||
*/
|
*/
|
||||||
public class GpsListener implements LocationListener {
|
public class GpsListener implements LocationListener {
|
||||||
|
|
||||||
private PhonegapActivity mCtx; // PhonegapActivity object
|
private CordovaActivity mCtx; // CordovaActivity object
|
||||||
|
|
||||||
private LocationManager mLocMan; // Location manager object
|
private LocationManager mLocMan; // Location manager object
|
||||||
private GeoListener owner; // Geolistener object (parent)
|
private GeoListener owner; // Geolistener object (parent)
|
||||||
@ -49,7 +49,7 @@ public class GpsListener implements LocationListener {
|
|||||||
* @param interval
|
* @param interval
|
||||||
* @param m
|
* @param m
|
||||||
*/
|
*/
|
||||||
public GpsListener(PhonegapActivity ctx, int interval, GeoListener m) {
|
public GpsListener(CordovaActivity ctx, int interval, GeoListener m) {
|
||||||
this.owner = m;
|
this.owner = m;
|
||||||
this.mCtx = ctx;
|
this.mCtx = ctx;
|
||||||
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -16,8 +16,8 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
import com.phonegap.api.LOG;
|
import org.apache.cordova.api.LOG;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View.MeasureSpec;
|
import android.view.View.MeasureSpec;
|
||||||
@ -87,13 +87,13 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
|
|||||||
// gone away.
|
// gone away.
|
||||||
else if (height > oldHeight) {
|
else if (height > oldHeight) {
|
||||||
if(app != null)
|
if(app != null)
|
||||||
app.sendJavascript("PhoneGap.fireDocumentEvent('hidekeyboard');");
|
app.sendJavascript("Cordova.fireDocumentEvent('hidekeyboard');");
|
||||||
}
|
}
|
||||||
// If the height as gotten smaller then we will assume the soft keyboard has
|
// If the height as gotten smaller then we will assume the soft keyboard has
|
||||||
// been displayed.
|
// been displayed.
|
||||||
else if (height < oldHeight) {
|
else if (height < oldHeight) {
|
||||||
if(app != null)
|
if(app != null)
|
||||||
app.sendJavascript("PhoneGap.fireDocumentEvent('showkeyboard');");
|
app.sendJavascript("Cordova.fireDocumentEvent('showkeyboard');");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the old height for the next event
|
// Update the old height for the next event
|
@ -16,9 +16,9 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
@ -28,13 +28,13 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
public class NetworkListener implements LocationListener {
|
public class NetworkListener implements LocationListener {
|
||||||
|
|
||||||
private PhonegapActivity mCtx; // PhonegapActivity object
|
private CordovaActivity mCtx; // CordovaActivity object
|
||||||
|
|
||||||
private LocationManager mLocMan; // Location manager object
|
private LocationManager mLocMan; // Location manager object
|
||||||
private GeoListener owner; // Geolistener object (parent)
|
private GeoListener owner; // Geolistener object (parent)
|
||||||
private boolean hasData = false; // Flag indicates if location data is available in cLoc
|
private boolean hasData = false; // Flag indicates if location data is available in cLoc
|
||||||
private Location cLoc; // Last recieved location
|
private Location cLoc; // Last recieved location
|
||||||
private boolean running = false; // Flag indicates if listener is running
|
private boolean running = false; // Flag indicates if listener is running
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -44,7 +44,7 @@ public class NetworkListener implements LocationListener {
|
|||||||
* @param interval
|
* @param interval
|
||||||
* @param m
|
* @param m
|
||||||
*/
|
*/
|
||||||
public NetworkListener(PhonegapActivity ctx, int interval, GeoListener m) {
|
public NetworkListener(CordovaActivity ctx, int interval, GeoListener m) {
|
||||||
this.owner = m;
|
this.owner = m;
|
||||||
this.mCtx = ctx;
|
this.mCtx = ctx;
|
||||||
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
||||||
@ -115,7 +115,7 @@ public class NetworkListener implements LocationListener {
|
|||||||
this.hasData = true;
|
this.hasData = true;
|
||||||
this.cLoc = location;
|
this.cLoc = location;
|
||||||
|
|
||||||
// The GPS is the primary form of Geolocation in PhoneGap.
|
// The GPS is the primary form of Geolocation in Cordova.
|
||||||
// Only fire the success variables if the GPS is down for some reason.
|
// Only fire the success variables if the GPS is down for some reason.
|
||||||
if (!this.owner.mGps.hasLocation()) {
|
if (!this.owner.mGps.hasLocation()) {
|
||||||
this.owner.success(location);
|
this.owner.success(location);
|
@ -16,13 +16,13 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -87,7 +87,7 @@ public class NetworkManager extends Plugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(PhonegapActivity ctx) {
|
public void setContext(CordovaActivity ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
this.connectionCallbackId = null;
|
this.connectionCallbackId = null;
|
@ -16,13 +16,13 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -184,7 +184,7 @@ public class Notification extends Plugin {
|
|||||||
*/
|
*/
|
||||||
public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
|
public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
|
||||||
|
|
||||||
final PhonegapActivity ctx = this.ctx;
|
final CordovaActivity ctx = this.ctx;
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
|
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@ -220,7 +220,7 @@ public class Notification extends Plugin {
|
|||||||
*/
|
*/
|
||||||
public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
|
public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
|
||||||
|
|
||||||
final PhonegapActivity ctx = this.ctx;
|
final CordovaActivity ctx = this.ctx;
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
final String[] fButtons = buttonLabels.split(",");
|
final String[] fButtons = buttonLabels.split(",");
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ public class Notification extends Plugin {
|
|||||||
this.spinnerDialog = null;
|
this.spinnerDialog = null;
|
||||||
}
|
}
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
final PhonegapActivity ctx = this.ctx;
|
final CordovaActivity ctx = this.ctx;
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
notification.spinnerDialog = ProgressDialog.show(ctx, title , message, true, true,
|
notification.spinnerDialog = ProgressDialog.show(ctx, title , message, true, true,
|
||||||
@ -320,7 +320,7 @@ public class Notification extends Plugin {
|
|||||||
this.progressDialog = null;
|
this.progressDialog = null;
|
||||||
}
|
}
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
final PhonegapActivity ctx = this.ctx;
|
final CordovaActivity ctx = this.ctx;
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
notification.progressDialog = new ProgressDialog(ctx);
|
notification.progressDialog = new ProgressDialog(ctx);
|
@ -1,4 +1,4 @@
|
|||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
// represents the <preference> element from the W3C config.xml spec
|
// represents the <preference> element from the W3C config.xml spec
|
||||||
// see http://www.w3.org/TR/widgets/#the-preference-element-and-its-attributes
|
// see http://www.w3.org/TR/widgets/#the-preference-element-and-its-attributes
|
@ -1,8 +1,9 @@
|
|||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import com.phonegap.PreferenceNode;
|
import org.apache.cordova.PreferenceNode;
|
||||||
|
|
||||||
|
|
||||||
public class PreferenceSet {
|
public class PreferenceSet {
|
||||||
private HashSet<PreferenceNode> innerSet;
|
private HashSet<PreferenceNode> innerSet;
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
@ -16,15 +16,15 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
@ -16,15 +16,15 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cordova.api.CordovaActivity;
|
||||||
|
import org.apache.cordova.api.Plugin;
|
||||||
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
|
||||||
import com.phonegap.api.PhonegapActivity;
|
|
||||||
import com.phonegap.api.Plugin;
|
|
||||||
import com.phonegap.api.PluginResult;
|
|
||||||
|
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
@ -49,7 +49,7 @@ public class TempListener extends Plugin implements SensorEventListener {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(PhonegapActivity ctx) {
|
public void setContext(CordovaActivity ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
@ -16,16 +16,16 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package org.apache.cordova.api;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Phonegap activity abstract class that is extended by DroidGap.
|
* The Cordova activity abstract class that is extended by DroidGap.
|
||||||
* It is used to isolate plugin development, and remove dependency on entire Phonegap library.
|
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
|
||||||
*/
|
*/
|
||||||
public abstract class PhonegapActivity extends Activity {
|
public abstract class CordovaActivity extends Activity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -64,7 +64,7 @@ public abstract class PhonegapActivity extends Activity {
|
|||||||
abstract public void setActivityResultCallback(IPlugin plugin);
|
abstract public void setActivityResultCallback(IPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the specified URL in the PhoneGap webview.
|
* Load the specified URL in the Cordova webview.
|
||||||
*
|
*
|
||||||
* @param url The URL to load.
|
* @param url The URL to load.
|
||||||
*/
|
*/
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package org.apache.cordova.api;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -53,13 +53,13 @@ public interface IPlugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
void setContext(PhonegapActivity ctx);
|
void setContext(CordovaActivity ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the main View of the application, this is the WebView within which
|
* Sets the main View of the application, this is the WebView within which
|
||||||
* a PhoneGap app runs.
|
* a Cordova app runs.
|
||||||
*
|
*
|
||||||
* @param webView The PhoneGap WebView
|
* @param webView The Cordova WebView
|
||||||
*/
|
*/
|
||||||
void setView(WebView webView);
|
void setView(WebView webView);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public interface IPlugin {
|
|||||||
/**
|
/**
|
||||||
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
|
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
|
||||||
*
|
*
|
||||||
* @param url The URL that is trying to be loaded in the PhoneGap webview.
|
* @param url The URL that is trying to be loaded in the Cordova webview.
|
||||||
* @return Return true to prevent the URL from loading. Default is false.
|
* @return Return true to prevent the URL from loading. Default is false.
|
||||||
*/
|
*/
|
||||||
boolean onOverrideUrlLoading(String url);
|
boolean onOverrideUrlLoading(String url);
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package org.apache.cordova.api;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class LOG {
|
|||||||
*/
|
*/
|
||||||
public static void setLogLevel(int logLevel) {
|
public static void setLogLevel(int logLevel) {
|
||||||
LOGLEVEL = logLevel;
|
LOGLEVEL = logLevel;
|
||||||
Log.i("PhoneGapLog", "Changing log level to " + logLevel);
|
Log.i("CordovaLog", "Changing log level to " + logLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +58,7 @@ public class LOG {
|
|||||||
else if ("INFO".equals(logLevel)) LOGLEVEL = INFO;
|
else if ("INFO".equals(logLevel)) LOGLEVEL = INFO;
|
||||||
else if ("WARN".equals(logLevel)) LOGLEVEL = WARN;
|
else if ("WARN".equals(logLevel)) LOGLEVEL = WARN;
|
||||||
else if ("ERROR".equals(logLevel)) LOGLEVEL = ERROR;
|
else if ("ERROR".equals(logLevel)) LOGLEVEL = ERROR;
|
||||||
Log.i("PhoneGapLog", "Changing log level to " + logLevel + "(" + LOGLEVEL + ")");
|
Log.i("CordovaLog", "Changing log level to " + logLevel + "(" + LOGLEVEL + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package org.apache.cordova.api;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -33,7 +33,7 @@ public abstract class Plugin implements IPlugin {
|
|||||||
|
|
||||||
public String id;
|
public String id;
|
||||||
public WebView webView; // WebView object
|
public WebView webView; // WebView object
|
||||||
public PhonegapActivity ctx; // PhonegapActivity object
|
public CordovaActivity ctx; // CordovaActivity object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the request and returns PluginResult.
|
* Executes the request and returns PluginResult.
|
||||||
@ -61,15 +61,15 @@ public abstract class Plugin implements IPlugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(PhonegapActivity ctx) {
|
public void setContext(CordovaActivity ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the main View of the application, this is the WebView within which
|
* Sets the main View of the application, this is the WebView within which
|
||||||
* a PhoneGap app runs.
|
* a Cordova app runs.
|
||||||
*
|
*
|
||||||
* @param webView The PhoneGap WebView
|
* @param webView The Cordova WebView
|
||||||
*/
|
*/
|
||||||
public void setView(WebView webView) {
|
public void setView(WebView webView) {
|
||||||
this.webView = webView;
|
this.webView = webView;
|
||||||
@ -127,7 +127,7 @@ public abstract class Plugin implements IPlugin {
|
|||||||
/**
|
/**
|
||||||
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
|
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
|
||||||
*
|
*
|
||||||
* @param url The URL that is trying to be loaded in the PhoneGap webview.
|
* @param url The URL that is trying to be loaded in the Cordova webview.
|
||||||
* @return Return true to prevent the URL from loading. Default is false.
|
* @return Return true to prevent the URL from loading. Default is false.
|
||||||
*/
|
*/
|
||||||
public boolean onOverrideUrlLoading(String url) {
|
public boolean onOverrideUrlLoading(String url) {
|
@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file
|
||||||
@ -16,7 +15,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package org.apache.cordova.api;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -33,7 +32,7 @@ import android.util.Log;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PluginManager is exposed to JavaScript in the PhoneGap WebView.
|
* PluginManager is exposed to JavaScript in the Cordova WebView.
|
||||||
*
|
*
|
||||||
* Calling native plugin code can be done by calling PluginManager.exec(...)
|
* Calling native plugin code can be done by calling PluginManager.exec(...)
|
||||||
* from JavaScript.
|
* from JavaScript.
|
||||||
@ -43,7 +42,7 @@ public final class PluginManager {
|
|||||||
private HashMap<String, IPlugin> plugins = new HashMap<String,IPlugin>();
|
private HashMap<String, IPlugin> plugins = new HashMap<String,IPlugin>();
|
||||||
private HashMap<String, String> services = new HashMap<String,String>();
|
private HashMap<String, String> services = new HashMap<String,String>();
|
||||||
|
|
||||||
private final PhonegapActivity ctx;
|
private final CordovaActivity ctx;
|
||||||
private final WebView app;
|
private final WebView app;
|
||||||
|
|
||||||
// Map URL schemes like foo: to plugins that want to handle those schemes
|
// Map URL schemes like foo: to plugins that want to handle those schemes
|
||||||
@ -56,7 +55,7 @@ public final class PluginManager {
|
|||||||
* @param app
|
* @param app
|
||||||
* @param ctx
|
* @param ctx
|
||||||
*/
|
*/
|
||||||
public PluginManager(WebView app, PhonegapActivity ctx) {
|
public PluginManager(WebView app, CordovaActivity ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.loadPlugins();
|
this.loadPlugins();
|
||||||
@ -126,8 +125,8 @@ public final class PluginManager {
|
|||||||
* @param args An Array literal string containing any arguments needed in the
|
* @param args An Array literal string containing any arguments needed in the
|
||||||
* plugin execute method.
|
* plugin execute method.
|
||||||
* @param async Boolean indicating whether the calling JavaScript code is expecting an
|
* @param async Boolean indicating whether the calling JavaScript code is expecting an
|
||||||
* immediate return value. If true, either PhoneGap.callbackSuccess(...) or
|
* immediate return value. If true, either Cordova.callbackSuccess(...) or
|
||||||
* PhoneGap.callbackError(...) is called once the plugin code has executed.
|
* Cordova.callbackError(...) is called once the plugin code has executed.
|
||||||
*
|
*
|
||||||
* @return JSON encoded string with a response message and status.
|
* @return JSON encoded string with a response message and status.
|
||||||
*/
|
*/
|
||||||
@ -138,7 +137,7 @@ public final class PluginManager {
|
|||||||
try {
|
try {
|
||||||
final JSONArray args = new JSONArray(jsonArgs);
|
final JSONArray args = new JSONArray(jsonArgs);
|
||||||
final IPlugin plugin = this.getPlugin(service);
|
final IPlugin plugin = this.getPlugin(service);
|
||||||
final PhonegapActivity ctx = this.ctx;
|
final CordovaActivity ctx = this.ctx;
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
runAsync = async && !plugin.isSynch(action);
|
runAsync = async && !plugin.isSynch(action);
|
||||||
if (runAsync) {
|
if (runAsync) {
|
||||||
@ -213,15 +212,15 @@ public final class PluginManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the interfaces that a class implements and see if it implements the
|
* Get the interfaces that a class implements and see if it implements the
|
||||||
* com.phonegap.api.Plugin interface.
|
* org.apache.cordova.api.Plugin interface.
|
||||||
*
|
*
|
||||||
* @param c The class to check the interfaces of.
|
* @param c The class to check the interfaces of.
|
||||||
* @return Boolean indicating if the class implements com.phonegap.api.Plugin
|
* @return Boolean indicating if the class implements org.apache.cordova.api.Plugin
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private boolean isPhoneGapPlugin(Class c) {
|
private boolean isCordovaPlugin(Class c) {
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
return com.phonegap.api.Plugin.class.isAssignableFrom(c) || com.phonegap.api.IPlugin.class.isAssignableFrom(c);
|
return org.apache.cordova.api.Plugin.class.isAssignableFrom(c) || org.apache.cordova.api.IPlugin.class.isAssignableFrom(c);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -239,7 +238,7 @@ public final class PluginManager {
|
|||||||
private IPlugin addPlugin(String pluginName, String className) {
|
private IPlugin addPlugin(String pluginName, String className) {
|
||||||
try {
|
try {
|
||||||
Class c = getClassByName(className);
|
Class c = getClassByName(className);
|
||||||
if (isPhoneGapPlugin(c)) {
|
if (isCordovaPlugin(c)) {
|
||||||
IPlugin plugin = (IPlugin)c.newInstance();
|
IPlugin plugin = (IPlugin)c.newInstance();
|
||||||
this.plugins.put(className, plugin);
|
this.plugins.put(className, plugin);
|
||||||
plugin.setContext(this.ctx);
|
plugin.setContext(this.ctx);
|
||||||
@ -353,7 +352,7 @@ public final class PluginManager {
|
|||||||
private void pluginConfigurationMissing() {
|
private void pluginConfigurationMissing() {
|
||||||
System.err.println("=====================================================================================");
|
System.err.println("=====================================================================================");
|
||||||
System.err.println("ERROR: plugin.xml is missing. Add res/xml/plugins.xml to your project.");
|
System.err.println("ERROR: plugin.xml is missing. Add res/xml/plugins.xml to your project.");
|
||||||
System.err.println("https://raw.github.com/phonegap/phonegap-android/master/framework/res/xml/plugins.xml");
|
System.err.println("https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
|
||||||
System.err.println("=====================================================================================");
|
System.err.println("=====================================================================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package org.apache.cordova.api;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -100,16 +100,16 @@ public class PluginResult {
|
|||||||
StringBuffer buf = new StringBuffer("");
|
StringBuffer buf = new StringBuffer("");
|
||||||
if (cast != null) {
|
if (cast != null) {
|
||||||
buf.append("var temp = "+cast+"("+this.getJSONString() + ");\n");
|
buf.append("var temp = "+cast+"("+this.getJSONString() + ");\n");
|
||||||
buf.append("PhoneGap.callbackSuccess('"+callbackId+"',temp);");
|
buf.append("Cordova.callbackSuccess('"+callbackId+"',temp);");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.append("PhoneGap.callbackSuccess('"+callbackId+"',"+this.getJSONString()+");");
|
buf.append("Cordova.callbackSuccess('"+callbackId+"',"+this.getJSONString()+");");
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toErrorCallbackString(String callbackId) {
|
public String toErrorCallbackString(String callbackId) {
|
||||||
return "PhoneGap.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
|
return "Cordova.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] StatusMessages = new String[] {
|
public static String[] StatusMessages = new String[] {
|
@ -17,7 +17,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap.file;
|
package org.apache.cordova.file;
|
||||||
|
|
||||||
public class EncodingException extends Exception {
|
public class EncodingException extends Exception {
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap.file;
|
package org.apache.cordova.file;
|
||||||
|
|
||||||
public class FileExistsException extends Exception {
|
public class FileExistsException extends Exception {
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.phonegap.file;
|
package org.apache.cordova.file;
|
||||||
|
|
||||||
public class InvalidModificationException extends Exception {
|
public class InvalidModificationException extends Exception {
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.phonegap.file;
|
package org.apache.cordova.file;
|
||||||
|
|
||||||
public class NoModificationAllowedException extends Exception {
|
public class NoModificationAllowedException extends Exception {
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.phonegap.file;
|
package org.apache.cordova.file;
|
||||||
|
|
||||||
public class TypeMismatchException extends Exception {
|
public class TypeMismatchException extends Exception {
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import com.phonegap.PreferenceNode;
|
import org.apache.cordova.PreferenceNode;
|
||||||
|
|
||||||
public class PreferenceNodeTest {
|
public class PreferenceNodeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testConstructor() {
|
public void testConstructor() {
|
||||||
PreferenceNode foo = new com.phonegap.PreferenceNode("fullscreen", "false", false);
|
PreferenceNode foo = new org.apache.cordova.PreferenceNode("fullscreen", "false", false);
|
||||||
assertEquals("fullscreen", foo.name);
|
assertEquals("fullscreen", foo.name);
|
||||||
assertEquals("false", foo.value);
|
assertEquals("false", foo.value);
|
||||||
assertEquals(false, foo.readonly);
|
assertEquals(false, foo.readonly);
|
||||||
@ -14,21 +14,21 @@ public class PreferenceNodeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameAssignment() {
|
public void testNameAssignment() {
|
||||||
PreferenceNode foo = new com.phonegap.PreferenceNode("fullscreen", "false", false);
|
PreferenceNode foo = new org.apache.cordova.PreferenceNode("fullscreen", "false", false);
|
||||||
foo.name = "widescreen";
|
foo.name = "widescreen";
|
||||||
assertEquals("widescreen", foo.name);
|
assertEquals("widescreen", foo.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValueAssignment() {
|
public void testValueAssignment() {
|
||||||
PreferenceNode foo = new com.phonegap.PreferenceNode("fullscreen", "false", false);
|
PreferenceNode foo = new org.apache.cordova.PreferenceNode("fullscreen", "false", false);
|
||||||
foo.value = "maybe";
|
foo.value = "maybe";
|
||||||
assertEquals("maybe", foo.value);
|
assertEquals("maybe", foo.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadonlyAssignment() {
|
public void testReadonlyAssignment() {
|
||||||
PreferenceNode foo = new com.phonegap.PreferenceNode("fullscreen", "false", false);
|
PreferenceNode foo = new org.apache.cordova.PreferenceNode("fullscreen", "false", false);
|
||||||
foo.readonly = true;
|
foo.readonly = true;
|
||||||
assertEquals(true, foo.readonly);
|
assertEquals(true, foo.readonly);
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import com.phonegap.PreferenceNode;
|
import org.apache.cordova.PreferenceNode;
|
||||||
import com.phonegap.PreferenceSet;
|
import org.apache.cordova.PreferenceSet;
|
||||||
|
|
||||||
public class PreferenceSetTest {
|
public class PreferenceSetTest {
|
||||||
private PreferenceSet preferences;
|
private PreferenceSet preferences;
|
Loading…
x
Reference in New Issue
Block a user