mobile_template 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mobile_template/version.rb +1 -1
- data/mobile_template.gemspec +1 -1
- data/templates/assets/Gemfile +1 -1
- data/templates/assets/source/javascripts/vendor/cordova.js +2106 -1975
- data/templates/assets/source/javascripts/vendor/jquery.js +614 -477
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +519 -378
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +683 -502
- data/templates/cordova_android/VERSION +1 -1
- data/templates/cordova_android/bin/create +5 -1
- data/templates/cordova_android/bin/templates/project/cordova/create +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +1 -1
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +18 -25
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +6 -6
- data/templates/cordova_android/framework/assets/js/cordova.android.js +2106 -1975
- data/templates/cordova_android/framework/assets/www/index.html +1 -1
- data/templates/cordova_android/framework/build.xml +2 -42
- data/templates/cordova_android/framework/project.properties +1 -1
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/drawable-hdpi/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable-ldpi/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable-mdpi/icon.png +0 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +2 -1
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +1 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +24 -16
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +35 -10
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +2 -1
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +67 -65
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +51 -63
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +3 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +6 -2
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +108 -108
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +110 -77
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +90 -44
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +20 -20
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +2 -2
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +7 -8
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +2 -2
- data/templates/cordova_android/framework/src/org/apache/cordova/SplashScreen.java +23 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +3 -3
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +2 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginEntry.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +260 -258
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +2 -2
- data/templates/cordova_android/releasenotes.md +42 -0
- data/templates/cordova_android/test/.classpath +8 -0
- data/templates/cordova_android/test/.project +33 -0
- data/templates/cordova_android/test/AndroidManifest.xml +87 -0
- data/templates/cordova_android/test/README.md +23 -0
- data/templates/cordova_android/test/ant.properties +17 -0
- data/templates/cordova_android/test/assets/www/backbuttonmultipage/index.html +23 -0
- data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample2.html +23 -0
- data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample3.html +26 -0
- data/templates/cordova_android/test/assets/www/background/index.html +99 -0
- data/templates/cordova_android/test/assets/www/background/index2.html +98 -0
- data/templates/cordova_android/test/assets/www/cordova-1.6.0.js +4985 -0
- data/templates/cordova_android/test/assets/www/cordova.js +2 -0
- data/templates/cordova_android/test/assets/www/htmlnotfound/error.html +1 -0
- data/templates/cordova_android/test/assets/www/iframe/index.html +33 -0
- data/templates/cordova_android/test/assets/www/iframe/index2.html +24 -0
- data/templates/cordova_android/test/assets/www/index.html +47 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/index.html +49 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab1.html +29 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab2.html +30 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab3.html +30 -0
- data/templates/cordova_android/test/assets/www/lifecycle/index.html +108 -0
- data/templates/cordova_android/test/assets/www/lifecycle/index2.html +104 -0
- data/templates/cordova_android/test/assets/www/main.js +150 -0
- data/templates/cordova_android/test/assets/www/master.css +117 -0
- data/templates/cordova_android/test/assets/www/menus/index.html +29 -0
- data/templates/cordova_android/test/assets/www/splashscreen/index.html +22 -0
- data/templates/cordova_android/test/assets/www/userwebview/index.html +49 -0
- data/templates/cordova_android/test/assets/www/whitelist/index.html +29 -0
- data/templates/cordova_android/test/assets/www/whitelist/index2.html +23 -0
- data/templates/cordova_android/test/assets/www/xhr/index.html +48 -0
- data/templates/cordova_android/test/build.xml +85 -0
- data/templates/cordova_android/test/libs/cordova-1.6.0.jar +0 -0
- data/templates/cordova_android/test/project.properties +11 -0
- data/templates/cordova_android/{framework → test}/res/drawable/icon.png +0 -0
- data/templates/cordova_android/test/res/drawable/sandy.jpg +0 -0
- data/templates/cordova_android/test/res/drawable-hdpi/ic_launcher.png +0 -0
- data/templates/cordova_android/test/res/drawable-ldpi/ic_launcher.png +0 -0
- data/templates/cordova_android/test/res/drawable-mdpi/ic_launcher.png +0 -0
- data/templates/cordova_android/test/res/layout/main.xml +13 -0
- data/templates/cordova_android/test/res/values/strings.xml +4 -0
- data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/cordova.xml +0 -0
- data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/plugins.xml +1 -1
- data/templates/cordova_android/test/src/org/apache/cordova/test/ActivityPlugin.java +81 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/FixWebView.java +43 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/backbuttonmultipage.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/background.java +34 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/errorurl.java +32 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/htmlnotfound.java +31 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/iframe.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/jqmtabbackbutton.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/lifecycle.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/loading.java +31 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/menus.java +80 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/splashscreen.java +35 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/tests.java +32 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/timeout.java +34 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/userwebview.java +72 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/whitelist.java +51 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/xhr.java +30 -0
- metadata +83 -30
- data/templates/cordova_android/framework/assets/js/accelerometer.js +0 -137
- data/templates/cordova_android/framework/assets/js/app.js +0 -89
- data/templates/cordova_android/framework/assets/js/battery.js +0 -134
- data/templates/cordova_android/framework/assets/js/camera.js +0 -168
- data/templates/cordova_android/framework/assets/js/capture.js +0 -203
- data/templates/cordova_android/framework/assets/js/compass.js +0 -168
- data/templates/cordova_android/framework/assets/js/contact.js +0 -310
- data/templates/cordova_android/framework/assets/js/cordova.js.base +0 -924
- data/templates/cordova_android/framework/assets/js/crypto.js +0 -54
- data/templates/cordova_android/framework/assets/js/device.js +0 -83
- data/templates/cordova_android/framework/assets/js/file.js +0 -1082
- data/templates/cordova_android/framework/assets/js/filetransfer.js +0 -125
- data/templates/cordova_android/framework/assets/js/geolocation.js +0 -209
- data/templates/cordova_android/framework/assets/js/header.txt +0 -19
- data/templates/cordova_android/framework/assets/js/media.js +0 -233
- data/templates/cordova_android/framework/assets/js/network.js +0 -100
- data/templates/cordova_android/framework/assets/js/notification.js +0 -133
- data/templates/cordova_android/framework/assets/js/position.js +0 -100
- data/templates/cordova_android/framework/assets/js/storage.js +0 -439
@@ -1,125 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
|
20
|
-
if (!Cordova.hasResource("filetransfer")) {
|
21
|
-
Cordova.addResource("filetransfer");
|
22
|
-
|
23
|
-
/**
|
24
|
-
* FileTransfer uploads a file to a remote server.
|
25
|
-
* @constructor
|
26
|
-
*/
|
27
|
-
var FileTransfer = function() {};
|
28
|
-
|
29
|
-
/**
|
30
|
-
* FileUploadResult
|
31
|
-
* @constructor
|
32
|
-
*/
|
33
|
-
var FileUploadResult = function() {
|
34
|
-
this.bytesSent = 0;
|
35
|
-
this.responseCode = null;
|
36
|
-
this.response = null;
|
37
|
-
};
|
38
|
-
|
39
|
-
/**
|
40
|
-
* FileTransferError
|
41
|
-
* @constructor
|
42
|
-
*/
|
43
|
-
var FileTransferError = function() {
|
44
|
-
this.code = null;
|
45
|
-
};
|
46
|
-
|
47
|
-
FileTransferError.FILE_NOT_FOUND_ERR = 1;
|
48
|
-
FileTransferError.INVALID_URL_ERR = 2;
|
49
|
-
FileTransferError.CONNECTION_ERR = 3;
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Given an absolute file path, uploads a file on the device to a remote server
|
53
|
-
* using a multipart HTTP request.
|
54
|
-
* @param filePath {String} Full path of the file on the device
|
55
|
-
* @param server {String} URL of the server to receive the file
|
56
|
-
* @param successCallback (Function} Callback to be invoked when upload has completed
|
57
|
-
* @param errorCallback {Function} Callback to be invoked upon error
|
58
|
-
* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
|
59
|
-
*/
|
60
|
-
FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, debug) {
|
61
|
-
|
62
|
-
// check for options
|
63
|
-
var fileKey = null;
|
64
|
-
var fileName = null;
|
65
|
-
var mimeType = null;
|
66
|
-
var params = null;
|
67
|
-
var chunkedMode = true;
|
68
|
-
if (options) {
|
69
|
-
fileKey = options.fileKey;
|
70
|
-
fileName = options.fileName;
|
71
|
-
mimeType = options.mimeType;
|
72
|
-
if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
|
73
|
-
chunkedMode = options.chunkedMode;
|
74
|
-
}
|
75
|
-
if (options.params) {
|
76
|
-
params = options.params;
|
77
|
-
}
|
78
|
-
else {
|
79
|
-
params = {};
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
|
84
|
-
};
|
85
|
-
|
86
|
-
/**
|
87
|
-
* Downloads a file form a given URL and saves it to the specified directory.
|
88
|
-
* @param source {String} URL of the server to receive the file
|
89
|
-
* @param target {String} Full path of the file on the device
|
90
|
-
* @param successCallback (Function} Callback to be invoked when upload has completed
|
91
|
-
* @param errorCallback {Function} Callback to be invoked upon error
|
92
|
-
*/
|
93
|
-
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
|
94
|
-
var win = function(result) {
|
95
|
-
var entry = null;
|
96
|
-
if (result.isDirectory) {
|
97
|
-
entry = new DirectoryEntry();
|
98
|
-
}
|
99
|
-
else if (result.isFile) {
|
100
|
-
entry = new FileEntry();
|
101
|
-
}
|
102
|
-
entry.isDirectory = result.isDirectory;
|
103
|
-
entry.isFile = result.isFile;
|
104
|
-
entry.name = result.name;
|
105
|
-
entry.fullPath = result.fullPath;
|
106
|
-
successCallback(entry);
|
107
|
-
};
|
108
|
-
Cordova.exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
|
109
|
-
};
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Options to customize the HTTP request used to upload files.
|
113
|
-
* @constructor
|
114
|
-
* @param fileKey {String} Name of file request parameter.
|
115
|
-
* @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
|
116
|
-
* @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
|
117
|
-
* @param params {Object} Object with key: value params to send to the server.
|
118
|
-
*/
|
119
|
-
var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
|
120
|
-
this.fileKey = fileKey || null;
|
121
|
-
this.fileName = fileName || null;
|
122
|
-
this.mimeType = mimeType || null;
|
123
|
-
this.params = params || null;
|
124
|
-
};
|
125
|
-
}
|
@@ -1,209 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
|
20
|
-
if (!Cordova.hasResource("geolocation")) {
|
21
|
-
Cordova.addResource("geolocation");
|
22
|
-
|
23
|
-
/**
|
24
|
-
* This class provides access to device GPS data.
|
25
|
-
* @constructor
|
26
|
-
*/
|
27
|
-
var Geolocation = function() {
|
28
|
-
|
29
|
-
// The last known GPS position.
|
30
|
-
this.lastPosition = null;
|
31
|
-
|
32
|
-
// Geolocation listeners
|
33
|
-
this.listeners = {};
|
34
|
-
};
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Position error object
|
38
|
-
*
|
39
|
-
* @constructor
|
40
|
-
* @param code
|
41
|
-
* @param message
|
42
|
-
*/
|
43
|
-
var PositionError = function(code, message) {
|
44
|
-
this.code = code;
|
45
|
-
this.message = message;
|
46
|
-
};
|
47
|
-
|
48
|
-
PositionError.PERMISSION_DENIED = 1;
|
49
|
-
PositionError.POSITION_UNAVAILABLE = 2;
|
50
|
-
PositionError.TIMEOUT = 3;
|
51
|
-
|
52
|
-
/**
|
53
|
-
* Asynchronously aquires the current position.
|
54
|
-
*
|
55
|
-
* @param {Function} successCallback The function to call when the position data is available
|
56
|
-
* @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
|
57
|
-
* @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
|
58
|
-
*/
|
59
|
-
Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options) {
|
60
|
-
if (navigator._geo.listeners.global) {
|
61
|
-
console.log("Geolocation Error: Still waiting for previous getCurrentPosition() request.");
|
62
|
-
try {
|
63
|
-
errorCallback(new PositionError(PositionError.TIMEOUT, "Geolocation Error: Still waiting for previous getCurrentPosition() request."));
|
64
|
-
} catch (e) {
|
65
|
-
}
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
var maximumAge = 10000;
|
69
|
-
var enableHighAccuracy = false;
|
70
|
-
var timeout = 10000;
|
71
|
-
if (typeof options !== "undefined") {
|
72
|
-
if (typeof options.maximumAge !== "undefined") {
|
73
|
-
maximumAge = options.maximumAge;
|
74
|
-
}
|
75
|
-
if (typeof options.enableHighAccuracy !== "undefined") {
|
76
|
-
enableHighAccuracy = options.enableHighAccuracy;
|
77
|
-
}
|
78
|
-
if (typeof options.timeout !== "undefined") {
|
79
|
-
timeout = options.timeout;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
navigator._geo.listeners.global = {"success" : successCallback, "fail" : errorCallback };
|
83
|
-
Cordova.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
84
|
-
};
|
85
|
-
|
86
|
-
/**
|
87
|
-
* Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
|
88
|
-
* the successCallback is called with the new location.
|
89
|
-
*
|
90
|
-
* @param {Function} successCallback The function to call each time the location data is available
|
91
|
-
* @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
|
92
|
-
* @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
|
93
|
-
* @return String The watch id that must be passed to #clearWatch to stop watching.
|
94
|
-
*/
|
95
|
-
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) {
|
96
|
-
var maximumAge = 10000;
|
97
|
-
var enableHighAccuracy = false;
|
98
|
-
var timeout = 10000;
|
99
|
-
if (typeof options !== "undefined") {
|
100
|
-
if (typeof options.frequency !== "undefined") {
|
101
|
-
maximumAge = options.frequency;
|
102
|
-
}
|
103
|
-
if (typeof options.maximumAge !== "undefined") {
|
104
|
-
maximumAge = options.maximumAge;
|
105
|
-
}
|
106
|
-
if (typeof options.enableHighAccuracy !== "undefined") {
|
107
|
-
enableHighAccuracy = options.enableHighAccuracy;
|
108
|
-
}
|
109
|
-
if (typeof options.timeout !== "undefined") {
|
110
|
-
timeout = options.timeout;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
var id = Cordova.createUUID();
|
114
|
-
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
|
115
|
-
Cordova.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
116
|
-
return id;
|
117
|
-
};
|
118
|
-
|
119
|
-
/*
|
120
|
-
* Native callback when watch position has a new position.
|
121
|
-
* PRIVATE METHOD
|
122
|
-
*
|
123
|
-
* @param {String} id
|
124
|
-
* @param {Number} lat
|
125
|
-
* @param {Number} lng
|
126
|
-
* @param {Number} alt
|
127
|
-
* @param {Number} altacc
|
128
|
-
* @param {Number} head
|
129
|
-
* @param {Number} vel
|
130
|
-
* @param {Number} stamp
|
131
|
-
*/
|
132
|
-
Geolocation.prototype.success = function(id, lat, lng, alt, altacc, head, vel, stamp) {
|
133
|
-
var coords = new Coordinates(lat, lng, alt, altacc, head, vel);
|
134
|
-
var loc = new Position(coords, stamp);
|
135
|
-
try {
|
136
|
-
if (lat === "undefined" || lng === "undefined") {
|
137
|
-
navigator._geo.listeners[id].fail(new PositionError(PositionError.POSITION_UNAVAILABLE, "Lat/Lng are undefined."));
|
138
|
-
}
|
139
|
-
else {
|
140
|
-
navigator._geo.lastPosition = loc;
|
141
|
-
navigator._geo.listeners[id].success(loc);
|
142
|
-
}
|
143
|
-
}
|
144
|
-
catch (e) {
|
145
|
-
console.log("Geolocation Error: Error calling success callback function.");
|
146
|
-
}
|
147
|
-
|
148
|
-
if (id === "global") {
|
149
|
-
delete navigator._geo.listeners.global;
|
150
|
-
}
|
151
|
-
};
|
152
|
-
|
153
|
-
/**
|
154
|
-
* Native callback when watch position has an error.
|
155
|
-
* PRIVATE METHOD
|
156
|
-
*
|
157
|
-
* @param {String} id The ID of the watch
|
158
|
-
* @param {Number} code The error code
|
159
|
-
* @param {String} msg The error message
|
160
|
-
*/
|
161
|
-
Geolocation.prototype.fail = function(id, code, msg) {
|
162
|
-
try {
|
163
|
-
navigator._geo.listeners[id].fail(new PositionError(code, msg));
|
164
|
-
}
|
165
|
-
catch (e) {
|
166
|
-
console.log("Geolocation Error: Error calling error callback function.");
|
167
|
-
}
|
168
|
-
};
|
169
|
-
|
170
|
-
/**
|
171
|
-
* Clears the specified heading watch.
|
172
|
-
*
|
173
|
-
* @param {String} id The ID of the watch returned from #watchPosition
|
174
|
-
*/
|
175
|
-
Geolocation.prototype.clearWatch = function(id) {
|
176
|
-
Cordova.exec(null, null, "Geolocation", "stop", [id]);
|
177
|
-
delete navigator._geo.listeners[id];
|
178
|
-
};
|
179
|
-
|
180
|
-
/**
|
181
|
-
* Force the Cordova geolocation to be used instead of built-in.
|
182
|
-
*/
|
183
|
-
Geolocation.usingCordova = false;
|
184
|
-
Geolocation.useCordova = function() {
|
185
|
-
if (Geolocation.usingCordova) {
|
186
|
-
return;
|
187
|
-
}
|
188
|
-
Geolocation.usingCordova = true;
|
189
|
-
|
190
|
-
// Set built-in geolocation methods to our own implementations
|
191
|
-
// (Cannot replace entire geolocation, but can replace individual methods)
|
192
|
-
navigator.geolocation.setLocation = navigator._geo.setLocation;
|
193
|
-
navigator.geolocation.getCurrentPosition = navigator._geo.getCurrentPosition;
|
194
|
-
navigator.geolocation.watchPosition = navigator._geo.watchPosition;
|
195
|
-
navigator.geolocation.clearWatch = navigator._geo.clearWatch;
|
196
|
-
navigator.geolocation.start = navigator._geo.start;
|
197
|
-
navigator.geolocation.stop = navigator._geo.stop;
|
198
|
-
};
|
199
|
-
|
200
|
-
Cordova.addConstructor(function() {
|
201
|
-
navigator._geo = new Geolocation();
|
202
|
-
|
203
|
-
// No native geolocation object for Android 1.x, so use Cordova geolocation
|
204
|
-
if (typeof navigator.geolocation === 'undefined') {
|
205
|
-
navigator.geolocation = navigator._geo;
|
206
|
-
Geolocation.usingCordova = true;
|
207
|
-
}
|
208
|
-
});
|
209
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
|
@@ -1,233 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
|
20
|
-
if (!Cordova.hasResource("media")) {
|
21
|
-
Cordova.addResource("media");
|
22
|
-
|
23
|
-
/**
|
24
|
-
* This class provides access to the device media, interfaces to both sound and video
|
25
|
-
*
|
26
|
-
* @constructor
|
27
|
-
* @param src The file name or url to play
|
28
|
-
* @param successCallback The callback to be called when the file is done playing or recording.
|
29
|
-
* successCallback() - OPTIONAL
|
30
|
-
* @param errorCallback The callback to be called if there is an error.
|
31
|
-
* errorCallback(int errorCode) - OPTIONAL
|
32
|
-
* @param statusCallback The callback to be called when media status has changed.
|
33
|
-
* statusCallback(int statusCode) - OPTIONAL
|
34
|
-
* @param positionCallback The callback to be called when media position has changed.
|
35
|
-
* positionCallback(long position) - OPTIONAL
|
36
|
-
*/
|
37
|
-
var Media = function(src, successCallback, errorCallback, statusCallback, positionCallback) {
|
38
|
-
|
39
|
-
// successCallback optional
|
40
|
-
if (successCallback && (typeof successCallback !== "function")) {
|
41
|
-
console.log("Media Error: successCallback is not a function");
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
|
45
|
-
// errorCallback optional
|
46
|
-
if (errorCallback && (typeof errorCallback !== "function")) {
|
47
|
-
console.log("Media Error: errorCallback is not a function");
|
48
|
-
return;
|
49
|
-
}
|
50
|
-
|
51
|
-
// statusCallback optional
|
52
|
-
if (statusCallback && (typeof statusCallback !== "function")) {
|
53
|
-
console.log("Media Error: statusCallback is not a function");
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
|
57
|
-
// statusCallback optional
|
58
|
-
if (positionCallback && (typeof positionCallback !== "function")) {
|
59
|
-
console.log("Media Error: positionCallback is not a function");
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
|
63
|
-
this.id = Cordova.createUUID();
|
64
|
-
Cordova.mediaObjects[this.id] = this;
|
65
|
-
this.src = src;
|
66
|
-
this.successCallback = successCallback;
|
67
|
-
this.errorCallback = errorCallback;
|
68
|
-
this.statusCallback = statusCallback;
|
69
|
-
this.positionCallback = positionCallback;
|
70
|
-
this._duration = -1;
|
71
|
-
this._position = -1;
|
72
|
-
};
|
73
|
-
|
74
|
-
// Media messages
|
75
|
-
Media.MEDIA_STATE = 1;
|
76
|
-
Media.MEDIA_DURATION = 2;
|
77
|
-
Media.MEDIA_POSITION = 3;
|
78
|
-
Media.MEDIA_ERROR = 9;
|
79
|
-
|
80
|
-
// Media states
|
81
|
-
Media.MEDIA_NONE = 0;
|
82
|
-
Media.MEDIA_STARTING = 1;
|
83
|
-
Media.MEDIA_RUNNING = 2;
|
84
|
-
Media.MEDIA_PAUSED = 3;
|
85
|
-
Media.MEDIA_STOPPED = 4;
|
86
|
-
Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
|
87
|
-
|
88
|
-
// TODO: Will MediaError be used?
|
89
|
-
/**
|
90
|
-
* This class contains information about any Media errors.
|
91
|
-
* @constructor
|
92
|
-
*/
|
93
|
-
var MediaError = function() {
|
94
|
-
this.code = null;
|
95
|
-
this.message = "";
|
96
|
-
};
|
97
|
-
|
98
|
-
MediaError.MEDIA_ERR_NONE_ACTIVE = 0;
|
99
|
-
MediaError.MEDIA_ERR_ABORTED = 1;
|
100
|
-
MediaError.MEDIA_ERR_NETWORK = 2;
|
101
|
-
MediaError.MEDIA_ERR_DECODE = 3;
|
102
|
-
MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Start or resume playing audio file.
|
106
|
-
*/
|
107
|
-
Media.prototype.play = function() {
|
108
|
-
Cordova.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
109
|
-
};
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Stop playing audio file.
|
113
|
-
*/
|
114
|
-
Media.prototype.stop = function() {
|
115
|
-
return Cordova.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
116
|
-
};
|
117
|
-
|
118
|
-
/**
|
119
|
-
* Seek or jump to a new time in the track..
|
120
|
-
*/
|
121
|
-
Media.prototype.seekTo = function(milliseconds) {
|
122
|
-
Cordova.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
|
123
|
-
};
|
124
|
-
|
125
|
-
/**
|
126
|
-
* Pause playing audio file.
|
127
|
-
*/
|
128
|
-
Media.prototype.pause = function() {
|
129
|
-
Cordova.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
|
130
|
-
};
|
131
|
-
|
132
|
-
/**
|
133
|
-
* Get duration of an audio file.
|
134
|
-
* The duration is only set for audio that is playing, paused or stopped.
|
135
|
-
*
|
136
|
-
* @return duration or -1 if not known.
|
137
|
-
*/
|
138
|
-
Media.prototype.getDuration = function() {
|
139
|
-
return this._duration;
|
140
|
-
};
|
141
|
-
|
142
|
-
/**
|
143
|
-
* Get position of audio.
|
144
|
-
*/
|
145
|
-
Media.prototype.getCurrentPosition = function(success, fail) {
|
146
|
-
Cordova.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
147
|
-
};
|
148
|
-
|
149
|
-
/**
|
150
|
-
* Start recording audio file.
|
151
|
-
*/
|
152
|
-
Media.prototype.startRecord = function() {
|
153
|
-
Cordova.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
154
|
-
};
|
155
|
-
|
156
|
-
/**
|
157
|
-
* Stop recording audio file.
|
158
|
-
*/
|
159
|
-
Media.prototype.stopRecord = function() {
|
160
|
-
Cordova.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
161
|
-
};
|
162
|
-
|
163
|
-
/**
|
164
|
-
* Release the resources.
|
165
|
-
*/
|
166
|
-
Media.prototype.release = function() {
|
167
|
-
Cordova.exec(null, null, "Media", "release", [this.id]);
|
168
|
-
};
|
169
|
-
|
170
|
-
/**
|
171
|
-
* Adjust the volume.
|
172
|
-
*/
|
173
|
-
Media.prototype.setVolume = function(volume) {
|
174
|
-
Cordova.exec(null, null, "Media", "setVolume", [this.id, volume]);
|
175
|
-
};
|
176
|
-
|
177
|
-
/**
|
178
|
-
* List of media objects.
|
179
|
-
* PRIVATE
|
180
|
-
*/
|
181
|
-
Cordova.mediaObjects = {};
|
182
|
-
|
183
|
-
/**
|
184
|
-
* Object that receives native callbacks.
|
185
|
-
* PRIVATE
|
186
|
-
* @constructor
|
187
|
-
*/
|
188
|
-
Cordova.Media = function() {};
|
189
|
-
|
190
|
-
/**
|
191
|
-
* Get the media object.
|
192
|
-
* PRIVATE
|
193
|
-
*
|
194
|
-
* @param id The media object id (string)
|
195
|
-
*/
|
196
|
-
Cordova.Media.getMediaObject = function(id) {
|
197
|
-
return Cordova.mediaObjects[id];
|
198
|
-
};
|
199
|
-
|
200
|
-
/**
|
201
|
-
* Audio has status update.
|
202
|
-
* PRIVATE
|
203
|
-
*
|
204
|
-
* @param id The media object id (string)
|
205
|
-
* @param status The status code (int)
|
206
|
-
* @param msg The status message (string)
|
207
|
-
*/
|
208
|
-
Cordova.Media.onStatus = function(id, msg, value) {
|
209
|
-
var media = Cordova.mediaObjects[id];
|
210
|
-
// If state update
|
211
|
-
if (msg === Media.MEDIA_STATE) {
|
212
|
-
if (value === Media.MEDIA_STOPPED) {
|
213
|
-
if (media.successCallback) {
|
214
|
-
media.successCallback();
|
215
|
-
}
|
216
|
-
}
|
217
|
-
if (media.statusCallback) {
|
218
|
-
media.statusCallback(value);
|
219
|
-
}
|
220
|
-
}
|
221
|
-
else if (msg === Media.MEDIA_DURATION) {
|
222
|
-
media._duration = value;
|
223
|
-
}
|
224
|
-
else if (msg === Media.MEDIA_ERROR) {
|
225
|
-
if (media.errorCallback) {
|
226
|
-
media.errorCallback({"code":value});
|
227
|
-
}
|
228
|
-
}
|
229
|
-
else if (msg === Media.MEDIA_POSITION) {
|
230
|
-
media._position = value;
|
231
|
-
}
|
232
|
-
};
|
233
|
-
}
|
@@ -1,100 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
|
20
|
-
|
21
|
-
if (!Cordova.hasResource("network")) {
|
22
|
-
Cordova.addResource("network");
|
23
|
-
|
24
|
-
/**
|
25
|
-
* This class contains information about the current network Connection.
|
26
|
-
* @constructor
|
27
|
-
*/
|
28
|
-
var Connection = function() {
|
29
|
-
this.type = null;
|
30
|
-
this._firstRun = true;
|
31
|
-
this._timer = null;
|
32
|
-
this.timeout = 500;
|
33
|
-
|
34
|
-
var me = this;
|
35
|
-
this.getInfo(
|
36
|
-
function(type) {
|
37
|
-
// Need to send events if we are on or offline
|
38
|
-
if (type === "none") {
|
39
|
-
// set a timer if still offline at the end of timer send the offline event
|
40
|
-
me._timer = setTimeout(function(){
|
41
|
-
me.type = type;
|
42
|
-
Cordova.fireDocumentEvent('offline');
|
43
|
-
me._timer = null;
|
44
|
-
}, me.timeout);
|
45
|
-
} else {
|
46
|
-
// If there is a current offline event pending clear it
|
47
|
-
if (me._timer !== null) {
|
48
|
-
clearTimeout(me._timer);
|
49
|
-
me._timer = null;
|
50
|
-
}
|
51
|
-
me.type = type;
|
52
|
-
Cordova.fireDocumentEvent('online');
|
53
|
-
}
|
54
|
-
|
55
|
-
// should only fire this once
|
56
|
-
if (me._firstRun) {
|
57
|
-
me._firstRun = false;
|
58
|
-
Cordova.onCordovaConnectionReady.fire();
|
59
|
-
}
|
60
|
-
},
|
61
|
-
function(e) {
|
62
|
-
// If we can't get the network info we should still tell Cordova
|
63
|
-
// to fire the deviceready event.
|
64
|
-
if (me._firstRun) {
|
65
|
-
me._firstRun = false;
|
66
|
-
Cordova.onCordovaConnectionReady.fire();
|
67
|
-
}
|
68
|
-
console.log("Error initializing Network Connection: " + e);
|
69
|
-
});
|
70
|
-
};
|
71
|
-
|
72
|
-
Connection.UNKNOWN = "unknown";
|
73
|
-
Connection.ETHERNET = "ethernet";
|
74
|
-
Connection.WIFI = "wifi";
|
75
|
-
Connection.CELL_2G = "2g";
|
76
|
-
Connection.CELL_3G = "3g";
|
77
|
-
Connection.CELL_4G = "4g";
|
78
|
-
Connection.NONE = "none";
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Get connection info
|
82
|
-
*
|
83
|
-
* @param {Function} successCallback The function to call when the Connection data is available
|
84
|
-
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
|
85
|
-
*/
|
86
|
-
Connection.prototype.getInfo = function(successCallback, errorCallback) {
|
87
|
-
// Get info
|
88
|
-
Cordova.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
|
89
|
-
};
|
90
|
-
|
91
|
-
|
92
|
-
Cordova.addConstructor(function() {
|
93
|
-
if (typeof navigator.network === "undefined") {
|
94
|
-
navigator.network = {};
|
95
|
-
}
|
96
|
-
if (typeof navigator.network.connection === "undefined") {
|
97
|
-
navigator.network.connection = new Connection();
|
98
|
-
}
|
99
|
-
});
|
100
|
-
}
|