This commit is contained in:
Anis Kadri 2012-02-03 19:36:27 -08:00
commit 1c7626aba2
97 changed files with 702 additions and 699 deletions

8
.gitignore vendored
View File

@ -1,14 +1,16 @@
.DS_Store
default.properties
gen
assets/www/phonegap.js
assets/www/cordova.js
local.properties
framework/proguard.cfg
framework/phonegap.jar
framework/cordova.jar
framework/cordova-*.jar
framework/phonegap-*.jar
framework/bin
framework/test/com/phonegap/*.class
framework/test/org/apache/cordova/*.class
framework/assets/www/.DS_Store
framework/assets/www/cordova-*.js
framework/assets/www/phonegap-*.js
example
./test

View File

@ -23,7 +23,7 @@ Requires
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
ant jar
@ -45,9 +45,9 @@ Project Commands
These commands live in a generated Cordova Android project.
./phonegap/debug [path] ..................... install to first device
./phonegap/emulate .......................... start avd (emulator) named default
./phonegap/log .............................. starts logcat
./cordovap/debug [path] ..................... install to first device
./cordova/emulate .......................... start avd (emulator) named default
./cordova/log .............................. starts logcat
Running the Example Project
---
@ -60,11 +60,11 @@ Create the example project and build it to the first device:
./bin/create
cd example
./phonegap/debug
./cordova/debug
Start adb logcat (console.log calls output here):
./phonegap/log
./cordova/log
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...
2. Android > Android Project
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
6. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)

View File

@ -1,4 +1,4 @@
#! /bin/sh
./bin/create
cd ./example && ./phonegap/debug && ./phonegap/log
cd ./example && ./cordova/debug && ./cordova/log

View File

@ -1,6 +1,6 @@
#! /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
# ./bin/bench
@ -13,17 +13,17 @@ then
fi
# 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
git clone git@github.com:brianleroux/phonegap-bench.git
git clone git@github.com:brianleroux/cordova-bench.git
# copy it into the app
cat ./phonegap-bench/www/index.html > ./bench/assets/www/index.html
#cat ~/Desktop/phonegap-bench/www/index.html > ./bench/assets/www/index.html
cat ./cordova-bench/www/index.html > ./bench/assets/www/index.html
#cat ~/Desktop/cordova-bench/www/index.html > ./bench/assets/www/index.html
# clean up
rm -rf ./phonegap-bench
rm -rf ./cordova-bench
# launch to the first device found
./bin/debug ./bench

View File

@ -1,6 +1,6 @@
#! /bin/sh
#
# create a phonegap/android project
# create a cordova/android project
#
# USAGE
# ./create [path package activity]
@ -8,8 +8,8 @@
set -e
PROJECT_PATH=${1:-"./example"}
PACKAGE=${2:-"com.phonegap.example"}
ACTIVITY=${3:-"PhoneGapExample"}
PACKAGE=${2:-"org.apache.cordova.example"}
ACTIVITY=${3:-"cordovaExample"}
TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]*\).*/\1/g' | tail -1)
VERSION=$(cat ./VERSION)
@ -19,23 +19,23 @@ then
rm -rf $PROJECT_PATH
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
# compile phonegap.js and phonegap.jar
# compile cordova.js and cordova.jar
cd ./framework && ant jar && cd ../
# copy all the bin scripts etc in there
cp -R ./bin/templates/project/ $PROJECT_PATH
# copy in phonegap.js
cp ./framework/assets/www/phonegap-$VERSION.js $PROJECT_PATH/.phonegap/android/phonegap-$VERSION.js
# copy in cordova.js
cp ./framework/assets/www/cordova-$VERSION.js $PROJECT_PATH/.cordova/android/cordova-$VERSION.js
# copy in phonegap.jar
cp ./framework/phonegap-$VERSION.jar $PROJECT_PATH/.phonegap/android/phonegap-$VERSION.jar
# copy in cordova.jar
cp ./framework/cordova-$VERSION.jar $PROJECT_PATH/.cordova/android/cordova-$VERSION.jar
# app properties
cat > $PROJECT_PATH/.phonegap/config <<eom
cat > $PROJECT_PATH/.cordova/config <<eom
VERSION=$VERSION
PROJECT_PATH=$PROJECT_PATH
PACKAGE=$PACKAGE
@ -43,4 +43,4 @@ ACTIVITY=$ACTIVITY
TARGET=$TARGET
eom
(cd $PROJECT_PATH && ./phonegap/create)
(cd $PROJECT_PATH && ./cordova/create)

View File

@ -1,5 +1,5 @@
/*
* create a phonegap/android project
* create a cordova/android project
*
* USAGE
* ./create [path package activity]
@ -26,7 +26,7 @@ function exec(s) {
}
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");
if (args.Count() == 3) {
@ -54,10 +54,10 @@ fi
// create the project
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');
// 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
// update your android tools or install an additional Android platform version
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
exec('cmd /c xcopy bin\\templates\\project '+PROJECT_PATH+' /S /Y');
// copy in phonegap.js
exec('cmd /c copy framework\\assets\\www\\phonegap-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\phonegap-'+VERSION+'.js /Y');
// copy in cordova.js
exec('cmd /c copy framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
// copy in phonegap.jar
exec('cmd /c copy framework\\phonegap-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\phonegap-'+VERSION+'.jar /Y');
// copy in cordova.jar
exec('cmd /c copy framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
// copy in default activity
exec('cmd /c copy bin\\templates\\Activity.java '+ACTIVITY_PATH+' /Y');

View File

@ -1,9 +1,9 @@
<?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="package" value="com.phonegap.example"/>
<property name="activity" value="PhoneGapExample"/>
<property name="package" value="org.apache.cordova.example"/>
<property name="activity" value="cordovaExample"/>
<target name="create">
@ -50,7 +50,7 @@
<arg line="update project --target ${target} --path ${basedir}/framework"/>
</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
// update your android tools or install an additional Android platform version -->
<ant antfile="${basedir}/framework/build.xml" useNativeBasedir="true" inheritAll="false" />
@ -60,11 +60,11 @@
<fileset dir="${basedir}/bin/templates/project"/>
</copy>
<!-- copy in phonegap.js -->
<copy file="${basedir}/framework/assets/www/phonegap-${version}.js" todir="${project.path}/assets/www/" />
<!-- copy in cordova.js -->
<copy file="${basedir}/framework/assets/www/cordova-${version}.js" todir="${project.path}/assets/www/" />
<!-- copy in phonegap.jar -->
<copy file="${basedir}/framework/phonegap-${version}.jar" todir="${project.path}/libs/" />
<!-- copy in cordova.jar -->
<copy file="${basedir}/framework/cordova-${version}.jar" todir="${project.path}/libs/" />
<!-- copy in default activity -->
<copy file="${basedir}/bin/templates/Activity.java" tofile="${activity.path}" overwrite="true" />

View File

@ -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
appreciated here!

View File

@ -1,13 +1,13 @@
#! /bin/sh
#
# create a phonegap/android project
# create a cordova/android project
#
# USAGE
# ./create [path package activity]
#
# load up the config
. ./.phonegap/config
. ./.cordova/config
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
ACTIVITY_PATH=./src/$PACKAGE_AS_PATH/$ACTIVITY.java
@ -16,17 +16,17 @@ MANIFEST_PATH=./AndroidManifest.xml
# create the project
android create project --target $TARGET --path . --package $PACKAGE --activity $ACTIVITY
# copy all the phonegap scripts etc in there
cp -R ./phonegap/templates/project/* .
# copy all the cordova scripts etc in there
cp -R ./cordova/templates/project/* .
# copy in phonegap.js
cp ./.phonegap/android/phonegap-$VERSION.js ./assets/www
# copy in cordova.js
cp ./.cordova/android/cordova-$VERSION.js ./assets/www
# copy in phonegap.jar
cp ./.phonegap/android/phonegap-$VERSION.jar ./libs
# copy in cordova.jar
cp ./.cordova/android/cordova-$VERSION.jar ./libs
# copy in default activity
cat ./phonegap/templates/Activity.java > $ACTIVITY_PATH
cat ./cordova/templates/Activity.java > $ACTIVITY_PATH
# interpolate the acivity name and package
find "$ACTIVITY_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i -e "s/__ACTIVITY__/${ACTIVITY}/g"

View File

@ -1,6 +1,6 @@
#! /bin/sh
. ./.phonegap/config
. ./.cordova/config
# if there are no devices listed then emulate

View File

@ -2,7 +2,7 @@ package __ID__;
import android.app.Activity;
import android.os.Bundle;
import com.phonegap.*;
import org.apache.cordova.*;
public class __ACTIVITY__ extends DroidGap
{

View File

@ -39,7 +39,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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">
<intent-filter>
</intent-filter>

View File

@ -5,7 +5,7 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="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>
</head>

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<phonegap>
<cordova>
<access origin="http://127.0.0.1*"/>
<log level="DEBUG"/>
</phonegap>
</cordova>

View File

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

View File

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

View File

@ -13,14 +13,14 @@ then
fi
# 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
rm -rf ./test/assets/www
mv ./callback-test ./test/assets/www
# copy in phonegap.js since www dir was replaced above
cp ./framework/assets/www/phonegap-$VERSION.js ./test/assets/www/phonegap-$VERSION.js
# copy in cordova.js since www dir was replaced above
cp ./framework/assets/www/cordova-$VERSION.js ./test/assets/www/cordova-$VERSION.js
# build it, launch it and start logging on stdout
cd ./test && ./phonegap/debug && ./phonegap/log
cd ./test && ./cordova/debug && ./cordova/log

View File

@ -8,14 +8,14 @@ exports['default example project is generated'] = (test) ->
test.ok true, "this assertion should pass" unless error?
test.done()
exports['default example project has a ./.phonegap folder'] = (test) ->
exports['default example project has a ./.cordova folder'] = (test) ->
test.expect 1
path.exists './example/.phonegap', (exists) ->
test.ok exists, 'the phonegap folder exists'
path.exists './example/.cordova', (exists) ->
test.ok exists, 'the cordova folder exists'
test.done()
exports['default example project has a /phonegap folder'] = (test) ->
exports['default example project has a /cordova folder'] = (test) ->
test.expect 1
path.exists './example/phonegap', (exists) ->
test.ok exists, 'the other phonegap folder exists'
path.exists './example/cordova', (exists) ->
test.ok exists, 'the other cordova folder exists'
test.done()

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PhoneGap</name>
<name>Cordova</name>
<comment></comment>
<projects>
</projects>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<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
android:largeScreens="true"
android:normalScreens="true"
@ -39,7 +39,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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">
<intent-filter>
</intent-filter>

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("accelerometer")) {
PhoneGap.addResource("accelerometer");
if (!Cordova.hasResource("accelerometer")) {
Cordova.addResource("accelerometer");
/** @constructor */
var Acceleration = function(x, y, z) {
@ -69,7 +69,7 @@ Accelerometer.prototype.getCurrentAcceleration = function(successCallback, error
}
// 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
PhoneGap.exec(
Cordova.exec(
function(timeout) {
if (timeout < (frequency + 10000)) {
PhoneGap.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
Cordova.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
}
},
function(e) { }, "Accelerometer", "getTimeout", []);
// Start watch timer
var id = PhoneGap.createUUID();
var id = Cordova.createUUID();
navigator.accelerometer.timers[id] = setInterval(function() {
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
Cordova.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
}, (frequency ? frequency : 1));
return id;
@ -129,7 +129,7 @@ Accelerometer.prototype.clearWatch = function(id) {
}
};
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
if (typeof navigator.accelerometer === "undefined") {
navigator.accelerometer = new Accelerometer();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("app")) {
PhoneGap.addResource("app");
if (!Cordova.hasResource("app")) {
Cordova.addResource("app");
(function() {
/**
@ -31,7 +31,7 @@ var App = function() {};
* Clear the resource cache.
*/
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});
*/
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.
*/
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.
*/
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.
*/
App.prototype.backHistory = function() {
PhoneGap.exec(null, null, "App", "backHistory", []);
Cordova.exec(null, null, "App", "backHistory", []);
};
/**
* Exit and terminate the application.
*/
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();
});
}());

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("battery")) {
PhoneGap.addResource("battery");
if (!Cordova.hasResource("battery")) {
Cordova.addResource("battery");
/**
* This class contains information about the current battery status.
@ -44,7 +44,7 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
if (add) {
// 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) {
PhoneGap.exec(me._status, me._error, "Battery", "start", []);
Cordova.exec(me._status, me._error, "Battery", "start", []);
}
// 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 (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;
if (me._level !== level || me._isPlugged !== info.isPlugged) {
// Fire batterystatus event
PhoneGap.fireWindowEvent("batterystatus", info);
Cordova.fireWindowEvent("batterystatus", info);
// Fire low battery event
if (level === 20 || level === 5) {
if (level === 20) {
PhoneGap.fireWindowEvent("batterylow", info);
Cordova.fireWindowEvent("batterylow", info);
}
else {
PhoneGap.fireWindowEvent("batterycritical", info);
Cordova.fireWindowEvent("batterycritical", info);
}
}
}
@ -123,12 +123,12 @@ Battery.prototype._error = function(e) {
console.log("Error initializing Battery: " + e);
};
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
if (typeof navigator.battery === "undefined") {
navigator.battery = new Battery();
PhoneGap.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
PhoneGap.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
PhoneGap.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
Cordova.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
Cordova.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
Cordova.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
}
});
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("camera")) {
PhoneGap.addResource("camera");
if (!Cordova.hasResource("camera")) {
Cordova.addResource("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") {
navigator.camera = new Camera();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("capture")) {
PhoneGap.addResource("capture");
if (!Cordova.hasResource("capture")) {
Cordova.addResource("capture");
/**
* Represents a single file.
@ -44,7 +44,7 @@ var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
* @param {Function} errorCB
*/
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
*/
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
*/
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
*/
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;
};
PhoneGap.addConstructor(function(){
Cordova.addConstructor(function(){
if (typeof navigator.device.capture === "undefined") {
navigator.device.capture = window.device.capture = new Capture();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("compass")) {
PhoneGap.addResource("compass");
if (!Cordova.hasResource("compass")) {
Cordova.addResource("compass");
var CompassError = function(){
this.code = null;
@ -75,7 +75,7 @@ Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, o
}
// 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
PhoneGap.exec(
Cordova.exec(
function(timeout) {
if (timeout < (frequency + 10000)) {
PhoneGap.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
Cordova.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
}
},
function(e) { }, "Compass", "getTimeout", []);
// Start watch timer to get headings
var id = PhoneGap.createUUID();
var id = Cordova.createUUID();
navigator.compass.timers[id] = setInterval(
function() {
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
}, (frequency ? frequency : 1));
return id;
@ -145,7 +145,7 @@ Compass.prototype._castDate = function(pluginResult) {
return pluginResult;
};
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
if (typeof navigator.compass === "undefined") {
navigator.compass = new Compass();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("contact")) {
PhoneGap.addResource("contact");
if (!Cordova.hasResource("contact")) {
Cordova.addResource("contact");
/**
* Contains information about a single contact.
@ -89,7 +89,7 @@ Contact.prototype.remove = function(successCB, errorCB) {
errorCB(errorObj);
}
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
*/
Contact.prototype.clone = function() {
var clonedContact = PhoneGap.clone(this);
var clonedContact = Cordova.clone(this);
var i;
clonedContact.id = null;
clonedContact.rawId = null;
@ -153,7 +153,7 @@ Contact.prototype.clone = function() {
* @param errorCB error callback
*/
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});
}
} 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.
*/
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
if(typeof navigator.contacts === "undefined") {
navigator.contacts = new Contacts();
}

View File

@ -17,26 +17,24 @@
* under the License.
*/
// Version 1.2.0
if (typeof PhoneGap === "undefined") {
if (typeof Cordova === "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.
* window.onload Body onload event.
* onNativeReady Internal event that indicates the PhoneGap native side is ready.
* onPhoneGapInit Internal event that kicks off creation of all PhoneGap JavaScript objects (runs constructors).
* onPhoneGapReady Internal event fired when all PhoneGap JavaScript objects have been created
* onPhoneGapInfoReady Internal event fired when device properties are available
* onDeviceReady User event fired to indicate that PhoneGap is ready
* onNativeReady Internal event that indicates the Cordova native side is ready.
* onCordovaInit Internal event that kicks off creation of all Cordova JavaScript objects (runs constructors).
* onCordovaReady Internal event fired when all Cordova JavaScript objects have been created
* onCordovaInfoReady Internal event fired when device properties are available
* onDeviceReady User event fired to indicate that Cordova is ready
* onResume User event fired to indicate a start/resume 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).
*
* The only PhoneGap events that user code should register for are:
* deviceready PhoneGap native code is initialized and PhoneGap APIs can be called from JavaScript
* The only Cordova events that user code should register for are:
* deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
* pause App has moved to background
* 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
* information about the state of PhoneGap.
* This represents the Cordova API itself, and provides a global namespace for accessing
* information about the state of Cordova.
* @class
*/
var PhoneGap = {
var Cordova = {
documentEventHandler: {}, // Collection of custom document 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.
*/
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
* @return
*/
PhoneGap.hasResource = function(name) {
return PhoneGap.resources[name];
Cordova.hasResource = function(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
*/
PhoneGap.addResource = function(name) {
PhoneGap.resources[name] = true;
Cordova.addResource = function(name) {
Cordova.resources[name] = true;
};
/**
* Custom pub-sub channel that can have functions subscribed to it
* @constructor
*/
PhoneGap.Channel = function (type)
Cordova.Channel = function (type)
{
this.type = type;
this.handlers = {};
@ -105,12 +103,12 @@ PhoneGap.Channel = function (type)
* and a guid that can be used to stop subscribing to the channel.
* Returns the guid.
*/
PhoneGap.Channel.prototype.subscribe = function(f, c, g) {
Cordova.Channel.prototype.subscribe = function(f, c, g) {
// need a function to call
if (f === null) { return; }
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++;
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
* auto-unsubscribes itself.
*/
PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
Cordova.Channel.prototype.subscribeOnce = function(f, c) {
var g = null;
var _this = this;
var m = function() {
@ -131,7 +129,7 @@ PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
_this.unsubscribe(g);
};
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);
} else {
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.
*/
PhoneGap.Channel.prototype.unsubscribe = function(g) {
Cordova.Channel.prototype.unsubscribe = function(g) {
if (typeof g === "function") { g = g.observer_guid; }
this.handlers[g] = null;
delete this.handlers[g];
@ -151,7 +149,7 @@ PhoneGap.Channel.prototype.unsubscribe = function(g) {
/**
* Calls all functions subscribed to this channel.
*/
PhoneGap.Channel.prototype.fire = function(e) {
Cordova.Channel.prototype.fire = function(e) {
if (this.enabled) {
var fail = false;
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
* have been fired.
*/
PhoneGap.Channel.join = function(h, c) {
Cordova.Channel.join = function(h, c) {
var i = c.length;
var f = function() {
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
* application constructors only once PhoneGap has been initialized.
* @param {Function} func The function callback you want run once PhoneGap is initialized
* application constructors only once Cordova has been initialized.
* @param {Function} func The function callback you want run once Cordova is initialized
*/
PhoneGap.addConstructor = function(func) {
PhoneGap.onPhoneGapInit.subscribeOnce(function() {
Cordova.addConstructor = function(func) {
Cordova.onCordovaInit.subscribeOnce(function() {
try {
func();
} catch(e) {
@ -226,7 +224,7 @@ if (!window.plugins) {
* @param name The plugin name
* @param obj The plugin object
*/
PhoneGap.addPlugin = function(name, obj) {
Cordova.addPlugin = function(name, obj) {
if (!window.plugins[name]) {
window.plugins[name] = obj;
}
@ -239,78 +237,78 @@ PhoneGap.addPlugin = function(name, obj) {
* onDOMContentLoaded channel is fired when the DOM content
* 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.
*/
PhoneGap.onNativeReady = new PhoneGap.Channel('onNativeReady');
Cordova.onNativeReady = new Cordova.Channel('onNativeReady');
/**
* onPhoneGapInit channel is fired when the web page is fully loaded and
* PhoneGap native code has been initialized.
* onCordovaInit channel is fired when the web page is fully loaded and
* 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.
*/
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.
*/
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.
* Window.onunload should be used by the user.
*/
PhoneGap.onDestroy = new PhoneGap.Channel('onDestroy');
PhoneGap.onDestroy.subscribeOnce(function() {
PhoneGap.shuttingDown = true;
Cordova.onDestroy = new Cordova.Channel('onDestroy');
Cordova.onDestroy.subscribeOnce(function() {
Cordova.shuttingDown = true;
});
PhoneGap.shuttingDown = false;
Cordova.shuttingDown = false;
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
// it may be called before any PhoneGap JS is ready.
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
// it may be called before any Cordova JS is ready.
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.
*/
PhoneGap.onDeviceReady = new PhoneGap.Channel('onDeviceReady');
Cordova.onDeviceReady = new Cordova.Channel('onDeviceReady');
// 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
PhoneGap.deviceReadyChannelsMap = {};
Cordova.deviceReadyChannelsMap = {};
/**
* 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
* and PhoneGap.initComplete(feature) is called.
* This holds up Cordova's "deviceready" event until the feature has been initialized
* and Cordova.initComplete(feature) is called.
*
* @param feature {String} The unique feature name
*/
PhoneGap.waitForInitialization = function(feature) {
Cordova.waitForInitialization = function(feature) {
if (feature) {
var channel = new PhoneGap.Channel(feature);
PhoneGap.deviceReadyChannelsMap[feature] = channel;
PhoneGap.deviceReadyChannelsArray.push(channel);
var channel = new Cordova.Channel(feature);
Cordova.deviceReadyChannelsMap[feature] = channel;
Cordova.deviceReadyChannelsArray.push(channel);
}
};
@ -319,64 +317,64 @@ PhoneGap.waitForInitialization = function(feature) {
*
* @param feature {String} The unique feature name
*/
PhoneGap.initializationComplete = function(feature) {
var channel = PhoneGap.deviceReadyChannelsMap[feature];
Cordova.initializationComplete = function(feature) {
var channel = Cordova.deviceReadyChannelsMap[feature];
if (channel) {
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
setTimeout(function() {
if (PhoneGap.UsePolling) {
PhoneGap.JSCallbackPolling();
if (Cordova.UsePolling) {
Cordova.JSCallbackPolling();
}
else {
var polling = prompt("usePolling", "gap_callbackServer:");
PhoneGap.UsePolling = polling;
Cordova.UsePolling = polling;
if (polling == "true") {
PhoneGap.UsePolling = true;
PhoneGap.JSCallbackPolling();
Cordova.UsePolling = true;
Cordova.JSCallbackPolling();
}
else {
PhoneGap.UsePolling = false;
PhoneGap.JSCallback();
Cordova.UsePolling = false;
Cordova.JSCallback();
}
}
}, 1);
// Run PhoneGap constructors
PhoneGap.onPhoneGapInit.fire();
// Run Cordova constructors
Cordova.onCordovaInit.fire();
// 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.
PhoneGap.Channel.join(function() {
Cordova.Channel.join(function() {
// Let native code know we are inited on JS side
prompt("", "gap_init:");
PhoneGap.onDeviceReady.fire();
}, PhoneGap.deviceReadyChannelsArray);
Cordova.onDeviceReady.fire();
}, Cordova.deviceReadyChannelsArray);
}, [ PhoneGap.onDOMContentLoaded, PhoneGap.onNativeReady ]);
}, [ Cordova.onDOMContentLoaded, Cordova.onNativeReady ]);
// Listen for DOMContentLoaded and notify our channel subscribers
document.addEventListener('DOMContentLoaded', function() {
PhoneGap.onDOMContentLoaded.fire();
Cordova.onDOMContentLoaded.fire();
}, false);
// 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
PhoneGap.m_window_addEventListener = window.addEventListener;
Cordova.m_window_addEventListener = window.addEventListener;
/**
* 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 {Function} callback The event handler
*/
PhoneGap.addWindowEventHandler = function(event, callback) {
PhoneGap.windowEventHandler[event] = callback;
Cordova.addWindowEventHandler = function(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 {Function} callback The event handler
*/
PhoneGap.addDocumentEventHandler = function(event, callback) {
PhoneGap.documentEventHandler[event] = callback;
Cordova.addDocumentEventHandler = function(event, callback) {
Cordova.documentEventHandler[event] = callback;
};
/**
@ -408,22 +406,22 @@ PhoneGap.addDocumentEventHandler = function(event, callback) {
document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (e === 'deviceready') {
PhoneGap.onDeviceReady.subscribeOnce(handler);
Cordova.onDeviceReady.subscribeOnce(handler);
}
else {
// If subscribing to Android 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
else if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
if (PhoneGap.documentEventHandler[e](e, handler, true)) {
else if (typeof Cordova.documentEventHandler[e] !== "undefined") {
if (Cordova.documentEventHandler[e](e, handler, true)) {
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();
// If subscribing to an event that is handled by a plugin
if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
if (PhoneGap.windowEventHandler[e](e, handler, true)) {
if (typeof Cordova.windowEventHandler[e] !== "undefined") {
if (Cordova.windowEventHandler[e](e, handler, true)) {
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
// are generated by PhoneGap native code
PhoneGap.m_document_removeEventListener = document.removeEventListener;
// are generated by Cordova native code
Cordova.m_document_removeEventListener = document.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
@ -466,17 +464,17 @@ document.removeEventListener = function(evt, handler, capture) {
// If unsubscribing to Android 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 (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
if (PhoneGap.documentEventHandler[e](e, handler, false)) {
if (typeof Cordova.documentEventHandler[e] !== "undefined") {
if (Cordova.documentEventHandler[e](e, handler, false)) {
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();
// If unsubcribing from an event that is handled by a plugin
if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
if (PhoneGap.windowEventHandler[e](e, handler, false)) {
if (typeof Cordova.windowEventHandler[e] !== "undefined") {
if (Cordova.windowEventHandler[e](e, handler, false)) {
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 {Object} data Data to send with event
*/
PhoneGap.fireDocumentEvent = function(type, data) {
Cordova.fireDocumentEvent = function(type, data) {
var e = document.createEvent('Events');
e.initEvent(type);
if (data) {
@ -522,7 +520,7 @@ PhoneGap.fireDocumentEvent = function(type, data) {
* @param {String} type The event type to fire
* @param {Object} data Data to send with event
*/
PhoneGap.fireWindowEvent = function(type, data) {
Cordova.fireWindowEvent = function(type, data) {
var e = document.createEvent('Events');
e.initEvent(type);
if (data) {
@ -539,7 +537,7 @@ PhoneGap.fireWindowEvent = function(type, data) {
* @param obj
* @return {Object}
*/
PhoneGap.clone = function(obj) {
Cordova.clone = function(obj) {
var i, retVal;
if(!obj) {
return obj;
@ -548,7 +546,7 @@ PhoneGap.clone = function(obj) {
if(obj instanceof Array){
retVal = [];
for(i = 0; i < obj.length; ++i){
retVal.push(PhoneGap.clone(obj[i]));
retVal.push(Cordova.clone(obj[i]));
}
return retVal;
}
@ -568,15 +566,15 @@ PhoneGap.clone = function(obj) {
retVal = {};
for(i in obj){
if(!(i in retVal) || retVal[i] !== obj[i]) {
retVal[i] = PhoneGap.clone(obj[i]);
retVal[i] = Cordova.clone(obj[i]);
}
}
return retVal;
};
PhoneGap.callbackId = 0;
PhoneGap.callbacks = {};
PhoneGap.callbackStatus = {
Cordova.callbackId = 0;
Cordova.callbacks = {};
Cordova.callbackStatus = {
NO_RESULT: 0,
OK: 1,
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:
* Synchronous: PluginResult object as a JSON 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.
*
* @param {Function} success The success callback
* @param {Function} fail The fail callback
* @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
*/
PhoneGap.exec = function(success, fail, service, action, args) {
Cordova.exec = function(success, fail, service, action, args) {
try {
var callbackId = service + PhoneGap.callbackId++;
var callbackId = service + Cordova.callbackId++;
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]));
@ -618,7 +616,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
eval("var v="+r+";");
// 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
// returned value
@ -631,18 +629,18 @@ PhoneGap.exec = function(success, fail, service, action, args) {
// Clear callback if not expecting any more results
if (!v.keepCallback) {
delete PhoneGap.callbacks[callbackId];
delete Cordova.callbacks[callbackId];
}
}
return v.message;
}
// 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
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
if (!v.keepCallback) {
delete PhoneGap.callbacks[callbackId];
delete Cordova.callbacks[callbackId];
}
}
return null;
@ -678,14 +676,14 @@ PhoneGap.exec = function(success, fail, service, action, args) {
* @param callbackId
* @param args
*/
PhoneGap.callbackSuccess = function(callbackId, args) {
if (PhoneGap.callbacks[callbackId]) {
Cordova.callbackSuccess = function(callbackId, args) {
if (Cordova.callbacks[callbackId]) {
// If result is to be sent to callback
if (args.status === PhoneGap.callbackStatus.OK) {
if (args.status === Cordova.callbackStatus.OK) {
try {
if (PhoneGap.callbacks[callbackId].success) {
PhoneGap.callbacks[callbackId].success(args.message);
if (Cordova.callbacks[callbackId].success) {
Cordova.callbacks[callbackId].success(args.message);
}
}
catch (e) {
@ -695,7 +693,7 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
// Clear callback if not expecting any more results
if (!args.keepCallback) {
delete PhoneGap.callbacks[callbackId];
delete Cordova.callbacks[callbackId];
}
}
};
@ -706,11 +704,11 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
* @param callbackId
* @param args
*/
PhoneGap.callbackError = function(callbackId, args) {
if (PhoneGap.callbacks[callbackId]) {
Cordova.callbackError = function(callbackId, args) {
if (Cordova.callbacks[callbackId]) {
try {
if (PhoneGap.callbacks[callbackId].fail) {
PhoneGap.callbacks[callbackId].fail(args.message);
if (Cordova.callbacks[callbackId].fail) {
Cordova.callbacks[callbackId].fail(args.message);
}
}
catch (e) {
@ -719,31 +717,31 @@ PhoneGap.callbackError = function(callbackId, args) {
// Clear callback if not expecting any more results
if (!args.keepCallback) {
delete PhoneGap.callbacks[callbackId];
delete Cordova.callbacks[callbackId];
}
}
};
PhoneGap.JSCallbackPort = null;
PhoneGap.JSCallbackToken = null;
Cordova.JSCallbackPort = null;
Cordova.JSCallbackToken = null;
/**
* 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
* Java to JavaScript.
*/
PhoneGap.JSCallback = function() {
Cordova.JSCallback = function() {
// Exit if shutting down app
if (PhoneGap.shuttingDown) {
if (Cordova.shuttingDown) {
return;
}
// If polling flag was changed, start using polling from now on
if (PhoneGap.UsePolling) {
PhoneGap.JSCallbackPolling();
if (Cordova.UsePolling) {
Cordova.JSCallbackPolling();
return;
}
@ -754,7 +752,7 @@ PhoneGap.JSCallback = function() {
if(xmlhttp.readyState === 4){
// Exit if shutting down app
if (PhoneGap.shuttingDown) {
if (Cordova.shuttingDown) {
return;
}
@ -773,12 +771,12 @@ PhoneGap.JSCallback = function() {
console.log("JSCallback Error: "+e);
}
}, 1);
setTimeout(PhoneGap.JSCallback, 1);
setTimeout(Cordova.JSCallback, 1);
}
// If callback ping (used to keep XHR request from timing out)
else if (xmlhttp.status === 404) {
setTimeout(PhoneGap.JSCallback, 10);
setTimeout(Cordova.JSCallback, 10);
}
// If security error
@ -799,19 +797,19 @@ PhoneGap.JSCallback = function() {
// If error, revert to polling
else {
console.log("JSCallback Error: Request failed.");
PhoneGap.UsePolling = true;
PhoneGap.JSCallbackPolling();
Cordova.UsePolling = true;
Cordova.JSCallbackPolling();
}
}
};
if (PhoneGap.JSCallbackPort === null) {
PhoneGap.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
if (Cordova.JSCallbackPort === null) {
Cordova.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
}
if (PhoneGap.JSCallbackToken === null) {
PhoneGap.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
if (Cordova.JSCallbackToken === null) {
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();
};
@ -819,30 +817,30 @@ PhoneGap.JSCallback = function() {
* The polling period to use with JSCallbackPolling.
* 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.
*/
PhoneGap.UsePolling = false; // T=use polling, F=use XHR
Cordova.UsePolling = false; // T=use polling, F=use XHR
/**
* 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
* Java to JavaScript.
*/
PhoneGap.JSCallbackPolling = function() {
Cordova.JSCallbackPolling = function() {
// Exit if shutting down app
if (PhoneGap.shuttingDown) {
if (Cordova.shuttingDown) {
return;
}
// If polling flag was changed, stop using polling from now on
if (!PhoneGap.UsePolling) {
PhoneGap.JSCallback();
if (!Cordova.UsePolling) {
Cordova.JSCallback();
return;
}
@ -857,10 +855,10 @@ PhoneGap.JSCallbackPolling = function() {
console.log("JSCallbackPolling Error: "+e);
}
}, 1);
setTimeout(PhoneGap.JSCallbackPolling, 1);
setTimeout(Cordova.JSCallbackPolling, 1);
}
else {
setTimeout(PhoneGap.JSCallbackPolling, PhoneGap.JSCallbackPollingPeriod);
setTimeout(Cordova.JSCallbackPolling, Cordova.JSCallbackPollingPeriod);
}
};
@ -869,15 +867,15 @@ PhoneGap.JSCallbackPolling = function() {
*
* @return {String}
*/
PhoneGap.createUUID = function() {
return PhoneGap.UUIDcreatePart(4) + '-' +
PhoneGap.UUIDcreatePart(2) + '-' +
PhoneGap.UUIDcreatePart(2) + '-' +
PhoneGap.UUIDcreatePart(2) + '-' +
PhoneGap.UUIDcreatePart(6);
Cordova.createUUID = function() {
return Cordova.UUIDcreatePart(4) + '-' +
Cordova.UUIDcreatePart(2) + '-' +
Cordova.UUIDcreatePart(2) + '-' +
Cordova.UUIDcreatePart(2) + '-' +
Cordova.UUIDcreatePart(6);
};
PhoneGap.UUIDcreatePart = function(length) {
Cordova.UUIDcreatePart = function(length) {
var uuidpart = "";
var i, uuidchar;
for (i=0; i<length; i++) {
@ -890,7 +888,7 @@ PhoneGap.UUIDcreatePart = function(length) {
return uuidpart;
};
PhoneGap.close = function(context, func, params) {
Cordova.close = function(context, func, params) {
if (typeof params === 'undefined') {
return function() {
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 {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 el = document.createElement('script');
el.type = 'text/javascript';

View File

@ -19,8 +19,8 @@
// TODO: Needs to be commented
if (!PhoneGap.hasResource("crypto")) {
PhoneGap.addResource("crypto");
if (!Cordova.hasResource("crypto")) {
Cordova.addResource("crypto");
/**
* @constructor
@ -30,12 +30,12 @@ var Crypto = function() {
Crypto.prototype.encrypt = function(seed, string, 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) {
this.decryptWin = callback;
PhoneGap.exec(null, null, "Crypto", "decrypt", [seed, string]);
Cordova.exec(null, null, "Crypto", "decrypt", [seed, string]);
};
Crypto.prototype.gotCryptedString = function(string) {
@ -46,7 +46,7 @@ Crypto.prototype.getPlainString = function(string) {
this.decryptWin(string);
};
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
if (typeof navigator.Crypto === "undefined") {
navigator.Crypto = new Crypto();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("device")) {
PhoneGap.addResource("device");
if (!Cordova.hasResource("device")) {
Cordova.addResource("device");
/**
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
@ -26,12 +26,12 @@ PhoneGap.addResource("device");
* @constructor
*/
var Device = function() {
this.available = PhoneGap.available;
this.available = Cordova.available;
this.platform = null;
this.version = null;
this.name = null;
this.uuid = null;
this.phonegap = null;
this.cordova = null;
var me = this;
this.getInfo(
@ -41,13 +41,13 @@ var Device = function() {
me.version = info.version;
me.name = info.name;
me.uuid = info.uuid;
me.phonegap = info.phonegap;
PhoneGap.onPhoneGapInfoReady.fire();
me.cordova = info.cordova;
Cordova.onCordovaInfoReady.fire();
},
function(e) {
me.available = false;
console.log("Error initializing PhoneGap: " + e);
alert("Error initializing PhoneGap: "+e);
console.log("Error initializing Cordova: " + e);
alert("Error initializing Cordova: "+e);
});
};
@ -72,10 +72,10 @@ Device.prototype.getInfo = function(successCallback, errorCallback) {
}
// 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") {
navigator.device = window.device = new Device();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("file")) {
PhoneGap.addResource("file");
if (!Cordova.hasResource("file")) {
Cordova.addResource("file");
/**
* This class provides some useful information about a file.
@ -162,7 +162,7 @@ FileReader.prototype.readAsText = function(file, encoding) {
var me = this;
// Read file
PhoneGap.exec(
Cordova.exec(
// Success callback
function(r) {
var evt;
@ -241,7 +241,7 @@ FileReader.prototype.readAsDataURL = function(file) {
var me = this;
// Read file
PhoneGap.exec(
Cordova.exec(
// Success callback
function(r) {
var evt;
@ -412,7 +412,7 @@ FileWriter.prototype.write = function(text) {
}
// Write file
PhoneGap.exec(
Cordova.exec(
// Success callback
function(r) {
var evt;
@ -523,7 +523,7 @@ FileWriter.prototype.truncate = function(size) {
}
// Write file
PhoneGap.exec(
Cordova.exec(
// Success callback
function(r) {
var evt;
@ -624,7 +624,7 @@ var DirectoryReader = function(fullPath){
* @param {Function} errorCallback is called with a FileError
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
FileEntry.prototype.file = function(successCallback, errorCallback) {
PhoneGap.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
Cordova.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
};
/** @constructor */
@ -892,7 +892,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
}
}
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
*/
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.
*/
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
var pgLocalFileSystem = new LocalFileSystem();
// Needed for cast methods
if (typeof window.localFileSystem === "undefined") {

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("filetransfer")) {
PhoneGap.addResource("filetransfer");
if (!Cordova.hasResource("filetransfer")) {
Cordova.addResource("filetransfer");
/**
* 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
*/
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
};
/**

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("geolocation")) {
PhoneGap.addResource("geolocation");
if (!Cordova.hasResource("geolocation")) {
Cordova.addResource("geolocation");
/**
* 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 };
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;
}
}
var id = PhoneGap.createUUID();
var id = Cordova.createUUID();
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;
};
@ -173,19 +173,19 @@ Geolocation.prototype.fail = function(id, code, msg) {
* @param {String} id The ID of the watch returned from #watchPosition
*/
Geolocation.prototype.clearWatch = function(id) {
PhoneGap.exec(null, null, "Geolocation", "stop", [id]);
Cordova.exec(null, null, "Geolocation", "stop", [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.usePhoneGap = function() {
if (Geolocation.usingPhoneGap) {
Geolocation.usingCordova = false;
Geolocation.useCordova = function() {
if (Geolocation.usingCordova) {
return;
}
Geolocation.usingPhoneGap = true;
Geolocation.usingCordova = true;
// Set built-in geolocation methods to our own implementations
// (Cannot replace entire geolocation, but can replace individual methods)
@ -197,13 +197,13 @@ Geolocation.usePhoneGap = function() {
navigator.geolocation.stop = navigator._geo.stop;
};
PhoneGap.addConstructor(function() {
Cordova.addConstructor(function() {
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') {
navigator.geolocation = navigator._geo;
Geolocation.usingPhoneGap = true;
Geolocation.usingCordova = true;
}
});
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("media")) {
PhoneGap.addResource("media");
if (!Cordova.hasResource("media")) {
Cordova.addResource("media");
/**
* 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;
}
this.id = PhoneGap.createUUID();
PhoneGap.mediaObjects[this.id] = this;
this.id = Cordova.createUUID();
Cordova.mediaObjects[this.id] = this;
this.src = src;
this.successCallback = successCallback;
this.errorCallback = errorCallback;
@ -105,28 +105,28 @@ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
* Start or resume playing audio file.
*/
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.
*/
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..
*/
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.
*/
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.
*/
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.
*/
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.
*/
Media.prototype.stopRecord = function() {
PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
Cordova.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
};
/**
* Release the resources.
*/
Media.prototype.release = function() {
PhoneGap.exec(null, null, "Media", "release", [this.id]);
Cordova.exec(null, null, "Media", "release", [this.id]);
};
/**
* Adjust the 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.
* PRIVATE
*/
PhoneGap.mediaObjects = {};
Cordova.mediaObjects = {};
/**
* Object that receives native callbacks.
* PRIVATE
* @constructor
*/
PhoneGap.Media = function() {};
Cordova.Media = function() {};
/**
* Get the media object.
@ -193,8 +193,8 @@ PhoneGap.Media = function() {};
*
* @param id The media object id (string)
*/
PhoneGap.Media.getMediaObject = function(id) {
return PhoneGap.mediaObjects[id];
Cordova.Media.getMediaObject = function(id) {
return Cordova.mediaObjects[id];
};
/**
@ -205,8 +205,8 @@ PhoneGap.Media.getMediaObject = function(id) {
* @param status The status code (int)
* @param msg The status message (string)
*/
PhoneGap.Media.onStatus = function(id, msg, value) {
var media = PhoneGap.mediaObjects[id];
Cordova.Media.onStatus = function(id, msg, value) {
var media = Cordova.mediaObjects[id];
// If state update
if (msg === Media.MEDIA_STATE) {
if (value === Media.MEDIA_STOPPED) {

View File

@ -18,8 +18,8 @@
*/
if (!PhoneGap.hasResource("network")) {
PhoneGap.addResource("network");
if (!Cordova.hasResource("network")) {
Cordova.addResource("network");
/**
* 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
me._timer = setTimeout(function(){
me.type = type;
PhoneGap.fireDocumentEvent('offline');
Cordova.fireDocumentEvent('offline');
me._timer = null;
}, me.timeout);
} else {
@ -49,21 +49,21 @@ var Connection = function() {
me._timer = null;
}
me.type = type;
PhoneGap.fireDocumentEvent('online');
Cordova.fireDocumentEvent('online');
}
// should only fire this once
if (me._firstRun) {
me._firstRun = false;
PhoneGap.onPhoneGapConnectionReady.fire();
Cordova.onCordovaConnectionReady.fire();
}
},
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.
if (me._firstRun) {
me._firstRun = false;
PhoneGap.onPhoneGapConnectionReady.fire();
Cordova.onCordovaConnectionReady.fire();
}
console.log("Error initializing Network Connection: " + e);
});
@ -85,11 +85,11 @@ Connection.NONE = "none";
*/
Connection.prototype.getInfo = function(successCallback, errorCallback) {
// 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") {
navigator.network = {};
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("notification")) {
PhoneGap.addResource("notification");
if (!Cordova.hasResource("notification")) {
Cordova.addResource("notification");
/**
* This class provides access to notifications on the device.
@ -38,7 +38,7 @@ var Notification = function() {
Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
var _title = (title || "Alert");
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) {
var _title = (title || "Confirm");
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
*/
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
*/
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.
*/
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
*/
Notification.prototype.progressValue = function(value) {
PhoneGap.exec(null, null, "Notification", "progressValue", [value]);
Cordova.exec(null, null, "Notification", "progressValue", [value]);
};
/**
* Close the progress dialog.
*/
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.
*/
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.
*/
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") {
navigator.notification = new Notification();
}

View File

@ -17,8 +17,8 @@
* under the License.
*/
if (!PhoneGap.hasResource("position")) {
PhoneGap.addResource("position");
if (!Cordova.hasResource("position")) {
Cordova.addResource("position");
/**
* This class contains position information.

View File

@ -23,8 +23,8 @@
* most manufacturers ship with Android 1.5 and do not do OTA Updates, this is required
*/
if (!PhoneGap.hasResource("storage")) {
PhoneGap.addResource("storage");
if (!Cordova.hasResource("storage")) {
Cordova.addResource("storage");
/**
* SQL result set object
@ -153,7 +153,7 @@ DroidDB.prototype.fail = function(reason, id) {
var DroidDB_Query = function(tx) {
// Set the id of the query
this.id = PhoneGap.createUUID();
this.id = Cordova.createUUID();
// Add this query to the queue
droiddb.queryQueue[this.id] = this;
@ -181,7 +181,7 @@ var DroidDB_Query = function(tx) {
var DroidDB_Tx = function() {
// Set the id of the transaction
this.id = PhoneGap.createUUID();
this.id = Cordova.createUUID();
// Callbacks
this.successCallback = null;
@ -266,7 +266,7 @@ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCa
query.errorCallback = errorCallback;
// 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() {
@ -308,7 +308,7 @@ DatabaseShell.prototype.transaction = function(process, errorCallback, successCa
* @return Database object
*/
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();
return db;
};
@ -340,7 +340,7 @@ var CupcakeLocalStorage = function() {
storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
}
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() {
navigator.openDatabase = window.openDatabase = DroidDB_openDatabase;
window.droiddb = new DroidDB();
@ -433,7 +433,7 @@ PhoneGap.addConstructor(function() {
if ((typeof window.localStorage == "undefined") || (window.localStorage == null)) {
navigator.localStorage = window.localStorage = new CupcakeLocalStorage();
PhoneGap.waitForInitialization("cupcakeStorage");
Cordova.waitForInitialization("cupcakeStorage");
}
});
}

View File

@ -1,7 +1,7 @@
<html>
<head>
<title></title>
<script src="phonegap-1.4.1.js"></script>
<script src="cordova-1.4.1.js"></script>
</head>
<body>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="PhoneGap" default="jar">
<project name="Cordova" default="jar">
<!-- LOAD VERSION -->
<loadfile property="version" srcFile="../VERSION">
@ -95,12 +95,12 @@
<delete dir="assets/lib"/>
<mkdir dir="assets/lib"/>
<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">
<include name="lint.js" />
</fileset>
<fileset dir="assets/www">
<include name="phonegap-${version}.js" />
<include name="cordova-${version}.js" />
</fileset>
</concat>
@ -111,57 +111,57 @@
<arg value="${basedir}/util/js.jar"/>
<arg value="org.mozilla.javascript.tools.shell.Main"/>
<arg value="${basedir}/util/jslint.js"/>
<arg value="${basedir}/js/lib/phonegap-lint.js"/>
<arg value="${basedir}/js/lib/cordova-lint.js"/>
</exec>
<exec executable="java" os="Mac OS X">
<arg value="-cp"/>
<arg value="../util/js.jar"/>
<arg value="org.mozilla.javascript.tools.shell.Main"/>
<arg value="../util/jslint.js"/>
<arg value="assets/lib/phonegap-lint.js"/>
<arg value="assets/lib/cordova-lint.js"/>
</exec>
</target>
<!-- Combine JavaScript files into one phonegap-uncompressed.js file. -->
<!-- Combine JavaScript files into one cordova-uncompressed.js file. -->
<target name="build-javascript">
<!-- Clean up existing files -->
<!--<delete file="assets/www/phonegap_${version}.js"/>-->
<!--<delete file="assets/www/cordova_${version}.js"/>-->
<!-- Create uncompressed JS file -->
<concat destfile="assets/www/phonegap-${version}.js">
<filelist dir="assets/js" files="phonegap.js.base,device.js"/>
<fileset dir="assets/js" includes="*.js" excludes="phonegap.js.base,device.js"/>
<concat destfile="assets/www/cordova-${version}.js">
<filelist dir="assets/js" files="cordova.js.base,device.js"/>
<fileset dir="assets/js" includes="*.js" excludes="cordova.js.base,device.js"/>
</concat>
<!-- update project files to reference phonegap-x.x.x.min.js -->
<replaceregexp match="phonegap(.*)\.js" replace="phonegap-${version}.js" byline="true">
<!-- update project files to reference cordova-x.x.x.min.js -->
<replaceregexp match="cordova(.*)\.js" replace="cordova-${version}.js" byline="true">
<fileset file="assets/www/index.html" />
<!-- <fileset file="../bin/templates/project/assets/www/index.html" /> -->
</replaceregexp>
<!-- This is sketchy, but it works, ${dblQuote} does not -->
<replaceregexp match="phonegapVersion = [\u0022].*[\u0022];" replace='phonegapVersion = ${dblQuote}${version}${dblQuote};' byline="true">
<fileset file="src/com/phonegap/Device.java" />
<replaceregexp match="cordovaVersion = [\u0022].*[\u0022];" replace='cordovaVersion = ${dblQuote}${version}${dblQuote};' byline="true">
<fileset file="src/org/apache/cordova/Device.java" />
</replaceregexp>
<!-- Delete temp file -->
<!--<delete file="assets/www/phonegap-tmp.js"/>-->
<!--<delete file="assets/www/cordova-tmp.js"/>-->
</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.
-->
<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>
<!-- 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">
<!-- requires both junit and phonegap -->
<!-- requires both junit and cordova -->
<pathelement location="libs/junit-4.10.jar" />
<pathelement location="phonegap-${version}.jar" />
<pathelement location="cordova-${version}.jar" />
<pathelement location="${test.dir}" />
</path>
@ -184,10 +184,10 @@
</junit>
</target>
<target name="phonegap_debug" depends="build-javascript, debug">
<target name="cordova_debug" depends="build-javascript, debug">
</target>
<target name="phonegap_release" depends="build-javascript, release">
<target name="cordova_release" depends="build-javascript, release">
</target>
</project>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PhoneGap</string>
<string name="app_name">Cordova</string>
<string name="go">Snap</string>
</resources>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<phonegap>
<cordova>
<!--
access elements control the Android whitelist.
Domains are assumed blocked unless set otherwise
@ -13,7 +13,7 @@
<log level="DEBUG"/>
<preference name="classicRender" value="true" />
</phonegap>
</cordova>

View File

@ -1,19 +1,19 @@
<?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="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"/>
<plugin name="Battery" value="com.phonegap.BatteryListener"/>
<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>

View File

@ -16,17 +16,17 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
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.JSONException;
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.SensorEvent;
@ -72,7 +72,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
*
* @param ctx The context of the main Activity.
*/
public void setContext(PhonegapActivity ctx) {
public void setContext(CordovaActivity ctx) {
super.setContext(ctx);
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
}

View File

@ -17,14 +17,14 @@
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.JSONException;
import org.json.JSONObject;
import com.phonegap.api.LOG;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import java.util.HashMap;
/**

View File

@ -16,22 +16,23 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import android.content.Context;
import android.media.AudioManager;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
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.JSONException;
import com.phonegap.api.LOG;
import java.util.HashMap;
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.
*
* Audio formats supported (tested):

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import android.media.AudioManager;
import android.media.MediaPlayer;
@ -31,8 +31,8 @@ import java.io.File;
import java.io.IOException;
/**
* This class implements the audio playback and recording capabilities used by PhoneGap.
* It is called by the AudioHandler PhoneGap class.
* This class implements the audio playback and recording capabilities used by Cordova.
* It is called by the AudioHandler Cordova class.
* Only one file can be played or recorded per class instance.
*
* 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) {
if (this.mPlayer != null) {
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
@ -137,11 +137,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
} catch (IOException e) {
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 {
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) {
if (this.recorder != null) {
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
@ -228,7 +228,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
}
catch (Exception e) {
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 {
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) {
this.mPlayer.seekTo(milliseconds);
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 {
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 {
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() {
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
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;
}
else {
@ -384,7 +384,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
this.prepareOnly = false;
// 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();
// 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;
}
@ -424,7 +424,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
*/
private void setState(int 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;

View File

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

View File

@ -16,14 +16,14 @@
specific language governing permissions and limitations
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.JSONException;
import org.json.JSONObject;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import android.content.BroadcastReceiver;
import android.content.Context;

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@ -31,7 +31,7 @@ import java.util.LinkedList;
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
* 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.
*
* 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.
*
* @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) {
//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.
*
* @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) {
this.stopServer();

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -26,13 +26,13 @@ import java.io.IOException;
import java.io.OutputStream;
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.JSONException;
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.content.ContentValues;
@ -143,7 +143,7 @@ public class CameraLauncher extends Plugin {
/**
* Take a picture with the camera.
* 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.
* To display base64 string in an img tag, set the source to:

View File

@ -16,12 +16,15 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.File;
import java.io.IOException;
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.JSONException;
import org.json.JSONObject;
@ -35,13 +38,11 @@ import android.media.MediaPlayer;
import android.net.Uri;
import android.util.Log;
import com.phonegap.api.LOG;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
public class Capture extends Plugin {
private static final String VIDEO_3GPP = "video/3gpp";
private static final String VIDEO_MP4 = "video/mp4";
private static final String AUDIO_3GPP = "audio/3gpp";
private static final String IMAGE_JPEG = "image/jpeg";
@ -128,7 +129,7 @@ public class Capture extends Plugin {
else if (mimeType.endsWith(AUDIO_3GPP)) {
obj = getAudioVideoData(filePath, obj, false);
}
else if (mimeType.equals(VIDEO_3GPP)) {
else if (mimeType.equals(VIDEO_3GPP) || mimeType.equals(VIDEO_MP4)) {
obj = getAudioVideoData(filePath, obj, true);
}
}
@ -167,7 +168,7 @@ public class Capture extends Plugin {
try {
player.setDataSource(filePath);
player.prepare();
obj.put("duration", player.getDuration());
obj.put("duration", player.getDuration()/1000);
if (video) {
obj.put("height", player.getVideoHeight());
obj.put("width", player.getVideoWidth());

View File

@ -16,17 +16,17 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
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.JSONException;
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.SensorEvent;
@ -69,7 +69,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
*
* @param ctx The context of the main Activity.
*/
public void setContext(PhonegapActivity ctx) {
public void setContext(CordovaActivity ctx) {
super.setContext(ctx);
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.util.HashMap;

View File

@ -17,7 +17,7 @@
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;

View File

@ -16,13 +16,13 @@
specific language governing permissions and limitations
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.JSONException;
import org.json.JSONObject;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import android.util.Log;
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
* 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.")) {
JSONObject res = null;

View File

@ -16,11 +16,11 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import org.apache.cordova.api.LOG;
import org.json.JSONArray;
import org.json.JSONException;
import com.phonegap.api.LOG;
import android.app.AlertDialog;
import android.content.Context;
@ -42,7 +42,7 @@ import android.widget.EditText;
public class CordovaChromeClient extends WebChromeClient {
private String TAG = "PhoneGapLog";
private String TAG = "CordovaLog";
private long MAX_QUOTA = 100 * 1024 * 1024;
private DroidGap ctx;
@ -213,7 +213,7 @@ public class CordovaChromeClient extends WebChromeClient {
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)
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
ctx.appView.setVisibility(View.VISIBLE);

View File

@ -16,9 +16,9 @@
specific language governing permissions and limitations
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.pm.ApplicationInfo;
@ -135,7 +135,7 @@ public class CordovaWebViewClient extends WebViewClient {
// All 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.
if (url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || ctx.isUrlWhiteListed(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
// from the JS side when the JS gets to that code.
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) {
Thread t = new Thread(new Runnable() {
public void run() {

View File

@ -16,16 +16,17 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
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.JSONException;
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.Context;
@ -37,7 +38,7 @@ import android.telephony.TelephonyManager;
public class Device extends Plugin {
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 uuid; // Device UUID
@ -55,7 +56,7 @@ public class Device extends Plugin {
*
* @param ctx The context of the main Activity.
*/
public void setContext(PhonegapActivity ctx) {
public void setContext(CordovaActivity ctx) {
super.setContext(ctx);
Device.uuid = getUuid();
this.initTelephonyReceiver();
@ -80,10 +81,10 @@ public class Device extends Plugin {
r.put("version", this.getOSVersion());
r.put("platform", Device.platform);
r.put("name", this.getProductName());
r.put("phonegap", Device.phonegapVersion);
r.put("cordova", Device.cordovaVersion);
//JSONObject pg = new JSONObject();
//pg.put("version", Device.phonegapVersion);
//r.put("phonegap", pg);
//pg.put("version", Device.CordovaVersion);
//r.put("cordova", pg);
return new PluginResult(status, r);
}
return new PluginResult(status, result);
@ -124,7 +125,7 @@ public class Device extends Plugin {
private void initTelephonyReceiver() {
IntentFilter intentFilter = new IntentFilter() ;
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
final PhonegapActivity myctx = this.ctx;
final CordovaActivity myctx = this.ctx;
this.telephonyReceiver = new BroadcastReceiver() {
@Override
@ -175,12 +176,12 @@ public class Device extends Plugin {
}
/**
* Get the PhoneGap version.
* Get the Cordova version.
*
* @return
*/
public String getPhonegapVersion() {
return Device.phonegapVersion;
public String getCordovaVersion() {
return Device.cordovaVersion;
}
public String getModel() {

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.File;

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.IOException;
import java.util.ArrayList;
@ -27,6 +27,12 @@ import java.util.Stack;
import java.util.regex.Matcher;
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.JSONException;
import org.xmlpull.v1.XmlPullParserException;
@ -70,25 +76,19 @@ import android.webkit.WebViewClient;
import android.widget.EditText;
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
* html file that contains the application.
*
* As an example:
*
* package com.phonegap.examples;
* package org.apache.cordova.examples;
* import android.app.Activity;
* import android.os.Bundle;
* import com.phonegap.*;
* import org.apache.cordova.*;
*
* public class Examples extends DroidGap {
* @Override
@ -140,26 +140,26 @@ import com.phonegap.PreferenceSet;
* // Enable app to keep running in background. (Boolean - default=true)
* super.setBooleanProperty("keepRunning", false);
*
* Phonegap.xml configuration:
* PhoneGap uses a configuration file at res/xml/phonegap.xml to specify the following settings.
* Cordova.xml configuration:
* Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
*
* Approved list of URLs that can be loaded into DroidGap
* <access origin="http://server regexp" subdomains="true" />
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
* <log level="DEBUG" />
*
* Phonegap plugins:
* PhoneGap uses a file at res/xml/plugins.xml to list all plugins that are installed.
* Cordova plugins:
* 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.
* 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.
*
* <plugins>
* <plugin name="App" value="com.phonegap.App"/>
* <plugin name="App" value="org.apache.cordova.App"/>
* ...
* </plugins>
*/
public class DroidGap extends PhonegapActivity {
public class DroidGap extends CordovaActivity {
public static String TAG = "DroidGap";
// The webview for our app
@ -223,7 +223,7 @@ public class DroidGap extends PhonegapActivity {
// when another application (activity) is started.
protected boolean keepRunning = true;
// preferences read from phonegap.xml
// preferences read from cordova.xml
protected PreferenceSet preferences;
private boolean classicRender;
@ -319,7 +319,7 @@ public class DroidGap extends PhonegapActivity {
public void onCreate(Bundle savedInstanceState) {
preferences = new PreferenceSet();
// Load PhoneGap configuration:
// Load Cordova configuration:
// white list of allowed URLs
// debug setting
this.loadConfiguration();
@ -847,7 +847,7 @@ public class DroidGap extends PhonegapActivity {
}
// 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
this.pluginManager.onPause(this.keepRunning);
@ -888,7 +888,7 @@ public class DroidGap extends PhonegapActivity {
}
// 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
this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);
@ -918,7 +918,7 @@ public class DroidGap extends PhonegapActivity {
// 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
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.
*
* @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 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 (this.bound) {
this.appView.loadUrl("javascript:PhoneGap.fireDocumentEvent('backbutton');");
this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('backbutton');");
return true;
}
@ -1102,13 +1102,13 @@ public class DroidGap extends PhonegapActivity {
// If menu key
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);
}
// If search key
else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
this.appView.loadUrl("javascript:PhoneGap.fireDocumentEvent('searchbutton');");
this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('searchbutton');");
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
* <access origin="http://server regexp" subdomains="true" />
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
* <log level="DEBUG" />
*/
private void loadConfiguration() {
int id = getResources().getIdentifier("phonegap", "xml", getPackageName());
int id = getResources().getIdentifier("cordova", "xml", getPackageName());
if (id == 0) {
LOG.i("PhoneGapLog", "phonegap.xml missing. Ignoring...");
LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
return;
}
XmlResourceParser xml = getResources().getXml(id);
@ -1269,7 +1269,7 @@ public class DroidGap extends PhonegapActivity {
}
else if (strNode.equals("log")) {
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) {
LOG.setLogLevel(level);
}
@ -1282,7 +1282,7 @@ public class DroidGap extends PhonegapActivity {
boolean readonly = (readonlyString != null &&
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));
}

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.IOException;

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -41,6 +41,8 @@ import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -49,8 +51,6 @@ import android.net.Uri;
import android.util.Log;
import android.webkit.CookieManager;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
public class FileTransfer extends Plugin {
@ -67,7 +67,7 @@ public class FileTransfer extends Plugin {
private HostnameVerifier defaultHostnameVerifier = null;
/* (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
public PluginResult execute(String action, JSONArray args, String callbackId) {

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import org.json.JSONException;
import org.json.JSONObject;

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.*;
import java.net.MalformedURLException;
@ -25,6 +25,14 @@ import java.net.URLDecoder;
import java.nio.channels.FileChannel;
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.JSONException;
import org.json.JSONObject;
@ -36,14 +44,6 @@ import android.provider.MediaStore;
import android.util.Log;
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.
@ -1014,7 +1014,7 @@ public class FileUtils extends Plugin {
* @param ctx the current applicaiton context
* @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 };
Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(_DATA);

View File

@ -16,16 +16,16 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.util.HashMap;
import java.util.Map.Entry;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
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.

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import android.content.Context;
import android.location.Location;

View File

@ -17,9 +17,9 @@
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.location.Location;
@ -33,7 +33,7 @@ import android.os.Bundle;
*/
public class GpsListener implements LocationListener {
private PhonegapActivity mCtx; // PhonegapActivity object
private CordovaActivity mCtx; // CordovaActivity object
private LocationManager mLocMan; // Location manager object
private GeoListener owner; // Geolistener object (parent)
@ -49,7 +49,7 @@ public class GpsListener implements LocationListener {
* @param interval
* @param m
*/
public GpsListener(PhonegapActivity ctx, int interval, GeoListener m) {
public GpsListener(CordovaActivity ctx, int interval, GeoListener m) {
this.owner = m;
this.mCtx = ctx;
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.FileOutputStream;
import java.io.IOException;

View File

@ -16,8 +16,8 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
import com.phonegap.api.LOG;
package org.apache.cordova;
import org.apache.cordova.api.LOG;
import android.content.Context;
import android.view.View.MeasureSpec;
@ -87,13 +87,13 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
// gone away.
else if (height > oldHeight) {
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
// been displayed.
else if (height < oldHeight) {
if(app != null)
app.sendJavascript("PhoneGap.fireDocumentEvent('showkeyboard');");
app.sendJavascript("Cordova.fireDocumentEvent('showkeyboard');");
}
// Update the old height for the next event

View File

@ -16,9 +16,9 @@
specific language governing permissions and limitations
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.location.Location;
@ -28,13 +28,13 @@ import android.os.Bundle;
public class NetworkListener implements LocationListener {
private PhonegapActivity mCtx; // PhonegapActivity object
private CordovaActivity mCtx; // CordovaActivity object
private LocationManager mLocMan; // Location manager object
private GeoListener owner; // Geolistener object (parent)
private boolean hasData = false; // Flag indicates if location data is available in cLoc
private Location cLoc; // Last recieved location
private boolean running = false; // Flag indicates if listener is running
private LocationManager mLocMan; // Location manager object
private GeoListener owner; // Geolistener object (parent)
private boolean hasData = false; // Flag indicates if location data is available in cLoc
private Location cLoc; // Last recieved location
private boolean running = false; // Flag indicates if listener is running
/**
* Constructor.
@ -44,7 +44,7 @@ public class NetworkListener implements LocationListener {
* @param interval
* @param m
*/
public NetworkListener(PhonegapActivity ctx, int interval, GeoListener m) {
public NetworkListener(CordovaActivity ctx, int interval, GeoListener m) {
this.owner = m;
this.mCtx = ctx;
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
@ -115,7 +115,7 @@ public class NetworkListener implements LocationListener {
this.hasData = true;
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.
if (!this.owner.mGps.hasLocation()) {
this.owner.success(location);

View File

@ -16,13 +16,13 @@
specific language governing permissions and limitations
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 com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -87,7 +87,7 @@ public class NetworkManager extends Plugin {
*
* @param ctx The context of the main Activity.
*/
public void setContext(PhonegapActivity ctx) {
public void setContext(CordovaActivity ctx) {
super.setContext(ctx);
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
this.connectionCallbackId = null;

View File

@ -16,13 +16,13 @@
specific language governing permissions and limitations
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.JSONException;
import com.phonegap.api.Plugin;
import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.PluginResult;
import android.app.AlertDialog;
import android.app.ProgressDialog;
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) {
final PhonegapActivity ctx = this.ctx;
final CordovaActivity ctx = this.ctx;
final Notification notification = this;
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) {
final PhonegapActivity ctx = this.ctx;
final CordovaActivity ctx = this.ctx;
final Notification notification = this;
final String[] fButtons = buttonLabels.split(",");
@ -284,7 +284,7 @@ public class Notification extends Plugin {
this.spinnerDialog = null;
}
final Notification notification = this;
final PhonegapActivity ctx = this.ctx;
final CordovaActivity ctx = this.ctx;
Runnable runnable = new Runnable() {
public void run() {
notification.spinnerDialog = ProgressDialog.show(ctx, title , message, true, true,
@ -320,7 +320,7 @@ public class Notification extends Plugin {
this.progressDialog = null;
}
final Notification notification = this;
final PhonegapActivity ctx = this.ctx;
final CordovaActivity ctx = this.ctx;
Runnable runnable = new Runnable() {
public void run() {
notification.progressDialog = new ProgressDialog(ctx);

View File

@ -1,4 +1,4 @@
package com.phonegap;
package org.apache.cordova;
// represents the <preference> element from the W3C config.xml spec
// see http://www.w3.org/TR/widgets/#the-preference-element-and-its-attributes

View File

@ -1,8 +1,9 @@
package com.phonegap;
package org.apache.cordova;
import java.util.HashSet;
import com.phonegap.PreferenceNode;
import org.apache.cordova.PreferenceNode;
public class PreferenceSet {
private HashSet<PreferenceNode> innerSet;

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.lang.reflect.Field;

View File

@ -16,15 +16,15 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
import java.io.File;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import android.content.Context;
import android.database.Cursor;

View File

@ -16,15 +16,15 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap;
package org.apache.cordova;
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 com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@ -49,7 +49,7 @@ public class TempListener extends Plugin implements SensorEventListener {
*
* @param ctx The context of the main Activity.
*/
public void setContext(PhonegapActivity ctx) {
public void setContext(CordovaActivity ctx) {
super.setContext(ctx);
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
}

View File

@ -16,16 +16,16 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap.api;
package org.apache.cordova.api;
import android.app.Activity;
import android.content.Intent;
/**
* The Phonegap activity abstract class that is extended by DroidGap.
* It is used to isolate plugin development, and remove dependency on entire Phonegap library.
* The Cordova activity abstract class that is extended by DroidGap.
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
*/
public abstract class PhonegapActivity extends Activity {
public abstract class CordovaActivity extends Activity {
/**
* @deprecated
@ -64,7 +64,7 @@ public abstract class PhonegapActivity extends Activity {
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.
*/

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap.api;
package org.apache.cordova.api;
import org.json.JSONArray;
import android.content.Intent;
@ -53,13 +53,13 @@ public interface IPlugin {
*
* @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
* a PhoneGap app runs.
* a Cordova app runs.
*
* @param webView The PhoneGap WebView
* @param webView The Cordova 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.
*
* @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.
*/
boolean onOverrideUrlLoading(String url);

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap.api;
package org.apache.cordova.api;
import android.util.Log;
@ -44,7 +44,7 @@ public class LOG {
*/
public static void setLogLevel(int 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 ("WARN".equals(logLevel)) LOGLEVEL = WARN;
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 + ")");
}
/**

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap.api;
package org.apache.cordova.api;
import org.json.JSONArray;
import org.json.JSONObject;
@ -33,7 +33,7 @@ public abstract class Plugin implements IPlugin {
public String id;
public WebView webView; // WebView object
public PhonegapActivity ctx; // PhonegapActivity object
public CordovaActivity ctx; // CordovaActivity object
/**
* Executes the request and returns PluginResult.
@ -61,15 +61,15 @@ public abstract class Plugin implements IPlugin {
*
* @param ctx The context of the main Activity.
*/
public void setContext(PhonegapActivity ctx) {
public void setContext(CordovaActivity ctx) {
this.ctx = ctx;
}
/**
* 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) {
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.
*
* @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.
*/
public boolean onOverrideUrlLoading(String url) {

View File

@ -1,5 +1,4 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
@ -16,7 +15,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap.api;
package org.apache.cordova.api;
import java.io.IOException;
import java.util.HashMap;
@ -33,7 +32,7 @@ import android.util.Log;
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(...)
* from JavaScript.
@ -43,7 +42,7 @@ public final class PluginManager {
private HashMap<String, IPlugin> plugins = new HashMap<String,IPlugin>();
private HashMap<String, String> services = new HashMap<String,String>();
private final PhonegapActivity ctx;
private final CordovaActivity ctx;
private final WebView app;
// Map URL schemes like foo: to plugins that want to handle those schemes
@ -56,7 +55,7 @@ public final class PluginManager {
* @param app
* @param ctx
*/
public PluginManager(WebView app, PhonegapActivity ctx) {
public PluginManager(WebView app, CordovaActivity ctx) {
this.ctx = ctx;
this.app = app;
this.loadPlugins();
@ -126,8 +125,8 @@ public final class PluginManager {
* @param args An Array literal string containing any arguments needed in the
* plugin execute method.
* @param async Boolean indicating whether the calling JavaScript code is expecting an
* immediate return value. If true, either PhoneGap.callbackSuccess(...) or
* PhoneGap.callbackError(...) is called once the plugin code has executed.
* immediate return value. If true, either Cordova.callbackSuccess(...) or
* Cordova.callbackError(...) is called once the plugin code has executed.
*
* @return JSON encoded string with a response message and status.
*/
@ -138,7 +137,7 @@ public final class PluginManager {
try {
final JSONArray args = new JSONArray(jsonArgs);
final IPlugin plugin = this.getPlugin(service);
final PhonegapActivity ctx = this.ctx;
final CordovaActivity ctx = this.ctx;
if (plugin != null) {
runAsync = async && !plugin.isSynch(action);
if (runAsync) {
@ -213,15 +212,15 @@ public final class PluginManager {
/**
* 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.
* @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")
private boolean isPhoneGapPlugin(Class c) {
private boolean isCordovaPlugin(Class c) {
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;
}
@ -239,7 +238,7 @@ public final class PluginManager {
private IPlugin addPlugin(String pluginName, String className) {
try {
Class c = getClassByName(className);
if (isPhoneGapPlugin(c)) {
if (isCordovaPlugin(c)) {
IPlugin plugin = (IPlugin)c.newInstance();
this.plugins.put(className, plugin);
plugin.setContext(this.ctx);
@ -353,7 +352,7 @@ public final class PluginManager {
private void pluginConfigurationMissing() {
System.err.println("=====================================================================================");
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("=====================================================================================");
}
}

View File

@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
package com.phonegap.api;
package org.apache.cordova.api;
import org.json.JSONArray;
import org.json.JSONObject;
@ -100,16 +100,16 @@ public class PluginResult {
StringBuffer buf = new StringBuffer("");
if (cast != null) {
buf.append("var temp = "+cast+"("+this.getJSONString() + ");\n");
buf.append("PhoneGap.callbackSuccess('"+callbackId+"',temp);");
buf.append("Cordova.callbackSuccess('"+callbackId+"',temp);");
}
else {
buf.append("PhoneGap.callbackSuccess('"+callbackId+"',"+this.getJSONString()+");");
buf.append("Cordova.callbackSuccess('"+callbackId+"',"+this.getJSONString()+");");
}
return buf.toString();
}
public String toErrorCallbackString(String callbackId) {
return "PhoneGap.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
return "Cordova.callbackError('"+callbackId+"', " + this.getJSONString()+ ");";
}
public static String[] StatusMessages = new String[] {

View File

@ -17,7 +17,7 @@
under the License.
*/
package com.phonegap.file;
package org.apache.cordova.file;
public class EncodingException extends Exception {

View File

@ -17,7 +17,7 @@
under the License.
*/
package com.phonegap.file;
package org.apache.cordova.file;
public class FileExistsException extends Exception {

View File

@ -18,7 +18,7 @@
*/
package com.phonegap.file;
package org.apache.cordova.file;
public class InvalidModificationException extends Exception {

View File

@ -17,7 +17,7 @@
under the License.
*/
package com.phonegap.file;
package org.apache.cordova.file;
public class NoModificationAllowedException extends Exception {

View File

@ -18,7 +18,7 @@
*/
package com.phonegap.file;
package org.apache.cordova.file;
public class TypeMismatchException extends Exception {

View File

@ -1,12 +1,12 @@
import org.junit.*;
import static org.junit.Assert.*;
import com.phonegap.PreferenceNode;
import org.apache.cordova.PreferenceNode;
public class PreferenceNodeTest {
@Test
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("false", foo.value);
assertEquals(false, foo.readonly);
@ -14,21 +14,21 @@ public class PreferenceNodeTest {
@Test
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";
assertEquals("widescreen", foo.name);
}
@Test
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";
assertEquals("maybe", foo.value);
}
@Test
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;
assertEquals(true, foo.readonly);
}

View File

@ -1,8 +1,8 @@
import org.junit.*;
import static org.junit.Assert.*;
import com.phonegap.PreferenceNode;
import com.phonegap.PreferenceSet;
import org.apache.cordova.PreferenceNode;
import org.apache.cordova.PreferenceSet;
public class PreferenceSetTest {
private PreferenceSet preferences;