mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android into audio
This commit is contained in:
commit
78f0c7b119
21
bin/create
21
bin/create
@ -63,6 +63,19 @@ function on_error {
|
||||
[ -d $PROJECT_PATH ] && rm -rf $PROJECT_PATH
|
||||
}
|
||||
|
||||
function replace {
|
||||
local pattern=$1
|
||||
local filename=$2
|
||||
# Mac OS X requires -i argument
|
||||
if [ $OSTYPE = 'darwin11' ]
|
||||
then
|
||||
sed -i '' -e $pattern $filename
|
||||
elif [ $OSTYPE = 'linux-gnu' ]
|
||||
then
|
||||
sed -i -e $pattern $filename
|
||||
fi
|
||||
}
|
||||
|
||||
# we do not want the script to silently fail
|
||||
trap on_error ERR
|
||||
trap on_exit EXIT
|
||||
@ -116,12 +129,12 @@ fi
|
||||
|
||||
# interpolate the activity name and package
|
||||
cp $BUILD_PATH/bin/templates/project/Activity.java $ACTIVITY_PATH
|
||||
sed -i '' -e "s/__ACTIVITY__/${ACTIVITY}/g" $ACTIVITY_PATH
|
||||
sed -i '' -e "s/__ID__/${PACKAGE}/g" $ACTIVITY_PATH
|
||||
replace "s/__ACTIVITY__/${ACTIVITY}/g" $ACTIVITY_PATH
|
||||
replace "s/__ID__/${PACKAGE}/g" $ACTIVITY_PATH
|
||||
|
||||
cp $BUILD_PATH/bin/templates/project/AndroidManifest.xml $MANIFEST_PATH
|
||||
sed -i '' -e "s/__ACTIVITY__/${ACTIVITY}/g" $MANIFEST_PATH
|
||||
sed -i '' -e "s/__PACKAGE__/${PACKAGE}/g" $MANIFEST_PATH
|
||||
replace "s/__ACTIVITY__/${ACTIVITY}/g" $MANIFEST_PATH
|
||||
replace "s/__PACKAGE__/${PACKAGE}/g" $MANIFEST_PATH
|
||||
|
||||
# creating cordova folder and copying emulate/debug/log/launch scripts
|
||||
mkdir $PROJECT_PATH/cordova
|
||||
|
@ -1,6 +1,6 @@
|
||||
// commit 5647225e12e18e15aefc33b151430d9a3804d9ea
|
||||
// commit 32e35b75c5ea2946dffebbc6cf4d0fbc16c0839e
|
||||
|
||||
// File generated at :: Fri Jun 29 2012 12:32:24 GMT-0400 (EDT)
|
||||
// File generated at :: Thu Jul 12 2012 13:35:26 GMT-0700 (PDT)
|
||||
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
@ -713,7 +713,6 @@ channel.create('onDestroy');
|
||||
|
||||
// Channels that must fire before "deviceready" is fired.
|
||||
channel.waitForInitialization('onCordovaReady');
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
channel.waitForInitialization('onCordovaConnectionReady');
|
||||
|
||||
module.exports = channel;
|
||||
@ -848,6 +847,9 @@ module.exports = {
|
||||
Coordinates: {
|
||||
path: 'cordova/plugin/Coordinates'
|
||||
},
|
||||
device: {
|
||||
path: 'cordova/plugin/device'
|
||||
},
|
||||
DirectoryEntry: {
|
||||
path: 'cordova/plugin/DirectoryEntry'
|
||||
},
|
||||
@ -1114,7 +1116,7 @@ module.exports = {
|
||||
// Let native code know we are all done on the JS side.
|
||||
// Native code will then un-hide the WebView.
|
||||
channel.join(function() {
|
||||
prompt("", "gap_init:");
|
||||
exec(null, null, "App", "show", []);
|
||||
}, [channel.onCordovaReady]);
|
||||
},
|
||||
objects: {
|
||||
@ -1135,9 +1137,6 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
},
|
||||
device:{
|
||||
path: "cordova/plugin/android/device"
|
||||
},
|
||||
File: { // exists natively on Android WebView, override
|
||||
path: "cordova/plugin/File"
|
||||
},
|
||||
@ -1152,6 +1151,9 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
merges: {
|
||||
device: {
|
||||
path: 'cordova/plugin/android/device'
|
||||
},
|
||||
navigator: {
|
||||
children: {
|
||||
notification: {
|
||||
@ -1873,7 +1875,7 @@ var utils = require('cordova/utils'),
|
||||
* {boolean} isDirectory always true (readonly)
|
||||
* {DOMString} name of the directory, excluding the path leading to it (readonly)
|
||||
* {DOMString} fullPath the absolute full path to the directory (readonly)
|
||||
* {FileSystem} filesystem on which the directory resides (readonly)
|
||||
* TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
|
||||
*/
|
||||
var DirectoryEntry = function(name, fullPath) {
|
||||
DirectoryEntry.__super__.constructor.apply(this, [false, true, name, fullPath]);
|
||||
@ -2598,13 +2600,12 @@ var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
|
||||
var FileSystem = function(name, root) {
|
||||
this.name = name || null;
|
||||
if (root) {
|
||||
console.log('root.name ' + name);
|
||||
console.log('root.root ' + root);
|
||||
this.root = new DirectoryEntry(root.name, root.fullPath);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FileSystem;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/FileTransfer.js
|
||||
@ -3768,97 +3769,44 @@ module.exports = callback;
|
||||
define("cordova/plugin/android/device", function(require, exports, module) {
|
||||
var channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec');
|
||||
exec = require('cordova/exec'),
|
||||
app = require('cordova/plugin/android/app');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device() {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.name = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
module.exports = {
|
||||
/*
|
||||
* DEPRECATED
|
||||
* This is only for Android.
|
||||
*
|
||||
* You must explicitly override the back button.
|
||||
*/
|
||||
overrideBackButton:function() {
|
||||
console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
|
||||
app.overrideBackbutton(true);
|
||||
},
|
||||
|
||||
var me = this;
|
||||
/*
|
||||
* DEPRECATED
|
||||
* This is only for Android.
|
||||
*
|
||||
* This resets the back button to the default behaviour
|
||||
*/
|
||||
resetBackButton:function() {
|
||||
console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
|
||||
app.overrideBackbutton(false);
|
||||
},
|
||||
|
||||
channel.onCordovaReady.subscribeOnce(function() {
|
||||
me.getInfo(function(info) {
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.name = info.name;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = info.cordova;
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
utils.alert("[ERROR] Error initializing Cordova: " + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
|
||||
// successCallback required
|
||||
if (typeof successCallback !== "function") {
|
||||
console.log("Device Error: successCallback is not a function");
|
||||
return;
|
||||
/*
|
||||
* DEPRECATED
|
||||
* This is only for Android.
|
||||
*
|
||||
* This terminates the activity!
|
||||
*/
|
||||
exitApp:function() {
|
||||
console.log("Device.exitApp() is deprecated. Use App.exitApp().");
|
||||
app.exitApp();
|
||||
}
|
||||
|
||||
// errorCallback optional
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("Device Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get info
|
||||
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
/*
|
||||
* DEPRECATED
|
||||
* This is only for Android.
|
||||
*
|
||||
* You must explicitly override the back button.
|
||||
*/
|
||||
Device.prototype.overrideBackButton = function() {
|
||||
console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
|
||||
navigator.app.overrideBackbutton(true);
|
||||
};
|
||||
|
||||
/*
|
||||
* DEPRECATED
|
||||
* This is only for Android.
|
||||
*
|
||||
* This resets the back button to the default behaviour
|
||||
*/
|
||||
Device.prototype.resetBackButton = function() {
|
||||
console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
|
||||
navigator.app.overrideBackbutton(false);
|
||||
};
|
||||
|
||||
/*
|
||||
* DEPRECATED
|
||||
* This is only for Android.
|
||||
*
|
||||
* This terminates the activity!
|
||||
*/
|
||||
Device.prototype.exitApp = function() {
|
||||
console.log("Device.exitApp() is deprecated. Use App.exitApp().");
|
||||
navigator.app.exitApp();
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/notification.js
|
||||
@ -4844,6 +4792,74 @@ module.exports = contacts;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/device.js
|
||||
define("cordova/plugin/device", function(require, exports, module) {
|
||||
var channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec');
|
||||
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device() {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.name = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribeOnce(function() {
|
||||
me.getInfo(function(info) {
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.name = info.name;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = info.cordova;
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
utils.alert("[ERROR] Error initializing Cordova: " + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
|
||||
// successCallback required
|
||||
if (typeof successCallback !== "function") {
|
||||
console.log("Device Error: successCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
// errorCallback optional
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("Device Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get info
|
||||
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/geolocation.js
|
||||
define("cordova/plugin/geolocation", function(require, exports, module) {
|
||||
var utils = require('cordova/utils'),
|
||||
|
54
framework/res/xml/config.xml
Normal file
54
framework/res/xml/config.xml
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<cordova>
|
||||
<!--
|
||||
access elements control the Android whitelist.
|
||||
Domains are assumed blocked unless set otherwise
|
||||
-->
|
||||
|
||||
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
|
||||
|
||||
<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
|
||||
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
|
||||
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
|
||||
|
||||
<log level="DEBUG"/>
|
||||
<preference name="useBrowserHistory" value="false" />
|
||||
<plugins>
|
||||
<plugin name="App" value="org.apache.cordova.App"/>
|
||||
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
|
||||
<plugin name="Device" value="org.apache.cordova.Device"/>
|
||||
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
|
||||
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
|
||||
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
|
||||
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
||||
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
|
||||
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
||||
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
|
||||
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
||||
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
||||
<plugin name="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"/>
|
||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
||||
</plugins>
|
||||
</cordova>
|
||||
|
@ -215,7 +215,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
||||
if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
|
||||
|
||||
// Save time that event was received
|
||||
this.timestamp = System.nanoTime();
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.x = event.values[0];
|
||||
this.y = event.values[1];
|
||||
this.z = event.values[2];
|
||||
|
@ -48,7 +48,10 @@ public class App extends Plugin {
|
||||
if (action.equals("clearCache")) {
|
||||
this.clearCache();
|
||||
}
|
||||
else if (action.equals("show")) { // TODO @bc - Not in master branch. When should this be called?
|
||||
else if (action.equals("show")) {
|
||||
// This gets called from JavaScript onCordovaReady to show the webview.
|
||||
// I recommend we change the name of the Message as spinner/stop is not
|
||||
// indicative of what this actually does (shows the webview).
|
||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
webView.postMessage("spinner", "stop");
|
||||
|
@ -596,7 +596,12 @@ public class CordovaWebView extends WebView {
|
||||
* <log level="DEBUG" />
|
||||
*/
|
||||
private void loadConfiguration() {
|
||||
int id = getResources().getIdentifier("cordova", "xml", this.cordova.getActivity().getPackageName());
|
||||
int id = getResources().getIdentifier("config", "xml", this.cordova.getActivity().getPackageName());
|
||||
if(id == 0)
|
||||
{
|
||||
id = getResources().getIdentifier("cordova", "xml", this.cordova.getActivity().getPackageName());
|
||||
Log.i("CordovaLog", "config.xml missing, reverting to cordova.xml");
|
||||
}
|
||||
if (id == 0) {
|
||||
LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
|
||||
return;
|
||||
|
@ -92,9 +92,16 @@ public class PluginManager {
|
||||
* Load plugins from res/xml/plugins.xml
|
||||
*/
|
||||
public void loadPlugins() {
|
||||
int id = this.ctx.getActivity().getResources().getIdentifier("plugins", "xml", this.ctx.getActivity().getPackageName());
|
||||
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
|
||||
if(id == 0)
|
||||
{
|
||||
id = this.ctx.getActivity().getResources().getIdentifier("plugins", "xml", this.ctx.getActivity().getPackageName());
|
||||
LOG.i(TAG, "Using plugins.xml instead of config.xml. plugins.xml will eventually be deprecated");
|
||||
}
|
||||
if (id == 0) {
|
||||
this.pluginConfigurationMissing();
|
||||
//We have the error, we need to exit without crashing!
|
||||
return;
|
||||
}
|
||||
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
|
||||
int eventType = -1;
|
||||
@ -361,9 +368,9 @@ public 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://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
|
||||
System.err.println("=====================================================================================");
|
||||
LOG.e(TAG, "=====================================================================================");
|
||||
LOG.e(TAG, "ERROR: plugin.xml is missing. Add res/xml/plugins.xml to your project.");
|
||||
LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
|
||||
LOG.e(TAG, "=====================================================================================");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user