mobile_template 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/lib/mobile_template/version.rb +1 -1
  2. data/mobile_template.gemspec +1 -1
  3. data/templates/assets/Gemfile +1 -1
  4. data/templates/assets/source/javascripts/vendor/cordova.js +2106 -1975
  5. data/templates/assets/source/javascripts/vendor/jquery.js +614 -477
  6. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +519 -378
  7. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +683 -502
  8. data/templates/cordova_android/VERSION +1 -1
  9. data/templates/cordova_android/bin/create +5 -1
  10. data/templates/cordova_android/bin/templates/project/cordova/create +5 -0
  11. data/templates/cordova_android/bin/templates/project/cordova/debug +1 -1
  12. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +18 -25
  13. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +6 -6
  14. data/templates/cordova_android/framework/assets/js/cordova.android.js +2106 -1975
  15. data/templates/cordova_android/framework/assets/www/index.html +1 -1
  16. data/templates/cordova_android/framework/build.xml +2 -42
  17. data/templates/cordova_android/framework/project.properties +1 -1
  18. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  19. data/templates/cordova_android/framework/res/drawable-hdpi/icon.png +0 -0
  20. data/templates/cordova_android/framework/res/drawable-ldpi/icon.png +0 -0
  21. data/templates/cordova_android/framework/res/drawable-mdpi/icon.png +0 -0
  22. data/templates/cordova_android/framework/res/xml/plugins.xml +2 -1
  23. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +1 -0
  24. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +24 -16
  25. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +35 -10
  26. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +2 -1
  27. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +67 -65
  28. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +51 -63
  29. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +3 -0
  30. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +6 -2
  31. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +108 -108
  32. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +110 -77
  33. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +90 -44
  34. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +20 -20
  35. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +2 -2
  36. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +7 -8
  37. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +2 -2
  38. data/templates/cordova_android/framework/src/org/apache/cordova/SplashScreen.java +23 -0
  39. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +3 -3
  40. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +2 -0
  41. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginEntry.java +119 -0
  42. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +260 -258
  43. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +2 -2
  44. data/templates/cordova_android/releasenotes.md +42 -0
  45. data/templates/cordova_android/test/.classpath +8 -0
  46. data/templates/cordova_android/test/.project +33 -0
  47. data/templates/cordova_android/test/AndroidManifest.xml +87 -0
  48. data/templates/cordova_android/test/README.md +23 -0
  49. data/templates/cordova_android/test/ant.properties +17 -0
  50. data/templates/cordova_android/test/assets/www/backbuttonmultipage/index.html +23 -0
  51. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample2.html +23 -0
  52. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample3.html +26 -0
  53. data/templates/cordova_android/test/assets/www/background/index.html +99 -0
  54. data/templates/cordova_android/test/assets/www/background/index2.html +98 -0
  55. data/templates/cordova_android/test/assets/www/cordova-1.6.0.js +4985 -0
  56. data/templates/cordova_android/test/assets/www/cordova.js +2 -0
  57. data/templates/cordova_android/test/assets/www/htmlnotfound/error.html +1 -0
  58. data/templates/cordova_android/test/assets/www/iframe/index.html +33 -0
  59. data/templates/cordova_android/test/assets/www/iframe/index2.html +24 -0
  60. data/templates/cordova_android/test/assets/www/index.html +47 -0
  61. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/index.html +49 -0
  62. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab1.html +29 -0
  63. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab2.html +30 -0
  64. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab3.html +30 -0
  65. data/templates/cordova_android/test/assets/www/lifecycle/index.html +108 -0
  66. data/templates/cordova_android/test/assets/www/lifecycle/index2.html +104 -0
  67. data/templates/cordova_android/test/assets/www/main.js +150 -0
  68. data/templates/cordova_android/test/assets/www/master.css +117 -0
  69. data/templates/cordova_android/test/assets/www/menus/index.html +29 -0
  70. data/templates/cordova_android/test/assets/www/splashscreen/index.html +22 -0
  71. data/templates/cordova_android/test/assets/www/userwebview/index.html +49 -0
  72. data/templates/cordova_android/test/assets/www/whitelist/index.html +29 -0
  73. data/templates/cordova_android/test/assets/www/whitelist/index2.html +23 -0
  74. data/templates/cordova_android/test/assets/www/xhr/index.html +48 -0
  75. data/templates/cordova_android/test/build.xml +85 -0
  76. data/templates/cordova_android/test/libs/cordova-1.6.0.jar +0 -0
  77. data/templates/cordova_android/test/project.properties +11 -0
  78. data/templates/cordova_android/{framework → test}/res/drawable/icon.png +0 -0
  79. data/templates/cordova_android/test/res/drawable/sandy.jpg +0 -0
  80. data/templates/cordova_android/test/res/drawable-hdpi/ic_launcher.png +0 -0
  81. data/templates/cordova_android/test/res/drawable-ldpi/ic_launcher.png +0 -0
  82. data/templates/cordova_android/test/res/drawable-mdpi/ic_launcher.png +0 -0
  83. data/templates/cordova_android/test/res/layout/main.xml +13 -0
  84. data/templates/cordova_android/test/res/values/strings.xml +4 -0
  85. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/cordova.xml +0 -0
  86. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/plugins.xml +1 -1
  87. data/templates/cordova_android/test/src/org/apache/cordova/test/ActivityPlugin.java +81 -0
  88. data/templates/cordova_android/test/src/org/apache/cordova/test/FixWebView.java +43 -0
  89. data/templates/cordova_android/test/src/org/apache/cordova/test/backbuttonmultipage.java +30 -0
  90. data/templates/cordova_android/test/src/org/apache/cordova/test/background.java +34 -0
  91. data/templates/cordova_android/test/src/org/apache/cordova/test/errorurl.java +32 -0
  92. data/templates/cordova_android/test/src/org/apache/cordova/test/htmlnotfound.java +31 -0
  93. data/templates/cordova_android/test/src/org/apache/cordova/test/iframe.java +30 -0
  94. data/templates/cordova_android/test/src/org/apache/cordova/test/jqmtabbackbutton.java +30 -0
  95. data/templates/cordova_android/test/src/org/apache/cordova/test/lifecycle.java +30 -0
  96. data/templates/cordova_android/test/src/org/apache/cordova/test/loading.java +31 -0
  97. data/templates/cordova_android/test/src/org/apache/cordova/test/menus.java +80 -0
  98. data/templates/cordova_android/test/src/org/apache/cordova/test/splashscreen.java +35 -0
  99. data/templates/cordova_android/test/src/org/apache/cordova/test/tests.java +32 -0
  100. data/templates/cordova_android/test/src/org/apache/cordova/test/timeout.java +34 -0
  101. data/templates/cordova_android/test/src/org/apache/cordova/test/userwebview.java +72 -0
  102. data/templates/cordova_android/test/src/org/apache/cordova/test/whitelist.java +51 -0
  103. data/templates/cordova_android/test/src/org/apache/cordova/test/xhr.java +30 -0
  104. metadata +83 -30
  105. data/templates/cordova_android/framework/assets/js/accelerometer.js +0 -137
  106. data/templates/cordova_android/framework/assets/js/app.js +0 -89
  107. data/templates/cordova_android/framework/assets/js/battery.js +0 -134
  108. data/templates/cordova_android/framework/assets/js/camera.js +0 -168
  109. data/templates/cordova_android/framework/assets/js/capture.js +0 -203
  110. data/templates/cordova_android/framework/assets/js/compass.js +0 -168
  111. data/templates/cordova_android/framework/assets/js/contact.js +0 -310
  112. data/templates/cordova_android/framework/assets/js/cordova.js.base +0 -924
  113. data/templates/cordova_android/framework/assets/js/crypto.js +0 -54
  114. data/templates/cordova_android/framework/assets/js/device.js +0 -83
  115. data/templates/cordova_android/framework/assets/js/file.js +0 -1082
  116. data/templates/cordova_android/framework/assets/js/filetransfer.js +0 -125
  117. data/templates/cordova_android/framework/assets/js/geolocation.js +0 -209
  118. data/templates/cordova_android/framework/assets/js/header.txt +0 -19
  119. data/templates/cordova_android/framework/assets/js/media.js +0 -233
  120. data/templates/cordova_android/framework/assets/js/network.js +0 -100
  121. data/templates/cordova_android/framework/assets/js/notification.js +0 -133
  122. data/templates/cordova_android/framework/assets/js/position.js +0 -100
  123. data/templates/cordova_android/framework/assets/js/storage.js +0 -439
@@ -1,168 +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("camera")) {
21
- Cordova.addResource("camera");
22
-
23
- /**
24
- * This class provides access to the device camera.
25
- *
26
- * @constructor
27
- */
28
- var Camera = function() {
29
- this.successCallback = null;
30
- this.errorCallback = null;
31
- this.options = null;
32
- };
33
-
34
- /**
35
- * Format of image that returned from getPicture.
36
- *
37
- * Example: navigator.camera.getPicture(success, fail,
38
- * { quality: 80,
39
- * destinationType: Camera.DestinationType.DATA_URL,
40
- * sourceType: Camera.PictureSourceType.PHOTOLIBRARY})
41
- */
42
- Camera.DestinationType = {
43
- DATA_URL: 0, // Return base64 encoded string
44
- FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
45
- };
46
- Camera.prototype.DestinationType = Camera.DestinationType;
47
-
48
- /**
49
- * Encoding of image returned from getPicture.
50
- *
51
- * Example: navigator.camera.getPicture(success, fail,
52
- * { quality: 80,
53
- * destinationType: Camera.DestinationType.DATA_URL,
54
- * sourceType: Camera.PictureSourceType.CAMERA,
55
- * encodingType: Camera.EncodingType.PNG})
56
- */
57
- Camera.EncodingType = {
58
- JPEG: 0, // Return JPEG encoded image
59
- PNG: 1 // Return PNG encoded image
60
- };
61
- Camera.prototype.EncodingType = Camera.EncodingType;
62
-
63
- /**
64
- * Type of pictures to select from. Only applicable when
65
- * PictureSourceType is PHOTOLIBRARY or SAVEDPHOTOALBUM
66
- *
67
- * Example: navigator.camera.getPicture(success, fail,
68
- * { quality: 80,
69
- * destinationType: Camera.DestinationType.DATA_URL,
70
- * sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
71
- * mediaType: Camera.MediaType.PICTURE})
72
- */
73
- Camera.MediaType = {
74
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
75
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
76
- ALLMEDIA : 2 // allow selection from all media types
77
- };
78
- Camera.prototype.MediaType = Camera.MediaType;
79
-
80
-
81
- /**
82
- * Source to getPicture from.
83
- *
84
- * Example: navigator.camera.getPicture(success, fail,
85
- * { quality: 80,
86
- * destinationType: Camera.DestinationType.DATA_URL,
87
- * sourceType: Camera.PictureSourceType.PHOTOLIBRARY})
88
- */
89
- Camera.PictureSourceType = {
90
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
91
- CAMERA : 1, // Take picture from camera
92
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
93
- };
94
- Camera.prototype.PictureSourceType = Camera.PictureSourceType;
95
-
96
- /**
97
- * Gets a picture from source defined by "options.sourceType", and returns the
98
- * image as defined by the "options.destinationType" option.
99
-
100
- * The defaults are sourceType=CAMERA and destinationType=DATA_URL.
101
- *
102
- * @param {Function} successCallback
103
- * @param {Function} errorCallback
104
- * @param {Object} options
105
- */
106
- Camera.prototype.getPicture = function(successCallback, errorCallback, options) {
107
-
108
- // successCallback required
109
- if (typeof successCallback !== "function") {
110
- console.log("Camera Error: successCallback is not a function");
111
- return;
112
- }
113
-
114
- // errorCallback optional
115
- if (errorCallback && (typeof errorCallback !== "function")) {
116
- console.log("Camera Error: errorCallback is not a function");
117
- return;
118
- }
119
-
120
- if (options === null || typeof options === "undefined") {
121
- options = {};
122
- }
123
- if (options.quality === null || typeof options.quality === "undefined") {
124
- options.quality = 80;
125
- }
126
- if (options.maxResolution === null || typeof options.maxResolution === "undefined") {
127
- options.maxResolution = 0;
128
- }
129
- if (options.destinationType === null || typeof options.destinationType === "undefined") {
130
- options.destinationType = Camera.DestinationType.FILE_URI;
131
- }
132
- if (options.sourceType === null || typeof options.sourceType === "undefined") {
133
- options.sourceType = Camera.PictureSourceType.CAMERA;
134
- }
135
- if (options.encodingType === null || typeof options.encodingType === "undefined") {
136
- options.encodingType = Camera.EncodingType.JPEG;
137
- }
138
- if (options.mediaType === null || typeof options.mediaType === "undefined") {
139
- options.mediaType = Camera.MediaType.PICTURE;
140
- }
141
- if (options.targetWidth === null || typeof options.targetWidth === "undefined") {
142
- options.targetWidth = -1;
143
- }
144
- else if (typeof options.targetWidth === "string") {
145
- var width = new Number(options.targetWidth);
146
- if (isNaN(width) === false) {
147
- options.targetWidth = width.valueOf();
148
- }
149
- }
150
- if (options.targetHeight === null || typeof options.targetHeight === "undefined") {
151
- options.targetHeight = -1;
152
- }
153
- else if (typeof options.targetHeight === "string") {
154
- var height = new Number(options.targetHeight);
155
- if (isNaN(height) === false) {
156
- options.targetHeight = height.valueOf();
157
- }
158
- }
159
-
160
- Cordova.exec(successCallback, errorCallback, "Camera", "takePicture", [options]);
161
- };
162
-
163
- Cordova.addConstructor(function() {
164
- if (typeof navigator.camera === "undefined") {
165
- navigator.camera = new Camera();
166
- }
167
- });
168
- }
@@ -1,203 +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("capture")) {
21
- Cordova.addResource("capture");
22
-
23
- /**
24
- * Represents a single file.
25
- *
26
- * name {DOMString} name of the file, without path information
27
- * fullPath {DOMString} the full path of the file, including the name
28
- * type {DOMString} mime type
29
- * lastModifiedDate {Date} last modified date
30
- * size {Number} size of the file in bytes
31
- */
32
- var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
33
- this.name = name || null;
34
- this.fullPath = fullPath || null;
35
- this.type = type || null;
36
- this.lastModifiedDate = lastModifiedDate || null;
37
- this.size = size || 0;
38
- };
39
-
40
- /**
41
- * Launch device camera application for recording video(s).
42
- *
43
- * @param {Function} successCB
44
- * @param {Function} errorCB
45
- */
46
- MediaFile.prototype.getFormatData = function(successCallback, errorCallback){
47
- Cordova.exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
48
- };
49
-
50
- /**
51
- * MediaFileData encapsulates format information of a media file.
52
- *
53
- * @param {DOMString} codecs
54
- * @param {long} bitrate
55
- * @param {long} height
56
- * @param {long} width
57
- * @param {float} duration
58
- */
59
- var MediaFileData = function(codecs, bitrate, height, width, duration){
60
- this.codecs = codecs || null;
61
- this.bitrate = bitrate || 0;
62
- this.height = height || 0;
63
- this.width = width || 0;
64
- this.duration = duration || 0;
65
- };
66
-
67
- /**
68
- * The CaptureError interface encapsulates all errors in the Capture API.
69
- */
70
- var CaptureError = function(){
71
- this.code = null;
72
- };
73
-
74
- // Capture error codes
75
- CaptureError.CAPTURE_INTERNAL_ERR = 0;
76
- CaptureError.CAPTURE_APPLICATION_BUSY = 1;
77
- CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
78
- CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
79
- CaptureError.CAPTURE_NOT_SUPPORTED = 20;
80
-
81
- /**
82
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
83
- */
84
- var Capture = function(){
85
- this.supportedAudioModes = [];
86
- this.supportedImageModes = [];
87
- this.supportedVideoModes = [];
88
- };
89
-
90
- /**
91
- * Launch audio recorder application for recording audio clip(s).
92
- *
93
- * @param {Function} successCB
94
- * @param {Function} errorCB
95
- * @param {CaptureAudioOptions} options
96
- */
97
- Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
98
- navigator.device.capture._capture("captureAudio", successCallback, errorCallback, options);
99
- };
100
-
101
- /**
102
- * Launch camera application for taking image(s).
103
- *
104
- * @param {Function} successCB
105
- * @param {Function} errorCB
106
- * @param {CaptureImageOptions} options
107
- */
108
- Capture.prototype.captureImage = function(successCallback, errorCallback, options){
109
- navigator.device.capture._capture("captureImage", successCallback, errorCallback, options);
110
- };
111
-
112
- /**
113
- * Launch device camera application for recording video(s).
114
- *
115
- * @param {Function} successCB
116
- * @param {Function} errorCB
117
- * @param {CaptureVideoOptions} options
118
- */
119
- Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
120
- navigator.device.capture._capture("captureVideo", successCallback, errorCallback, options);
121
- };
122
-
123
- /**
124
- * Launches the correct capture.
125
- *
126
- * @param (DOMString} type
127
- * @param {Function} successCB
128
- * @param {Function} errorCB
129
- * @param {CaptureVideoOptions} options
130
- */
131
- Capture.prototype._capture = function(type, successCallback, errorCallback, options){
132
- var win = function(result) {
133
- var mediaFiles = [];
134
- var i;
135
- for (i = 0; i < pluginResult.message.length; i++) {
136
- var mediaFile = new MediaFile();
137
- mediaFile.name = pluginResult.message[i].name;
138
- mediaFile.fullPath = pluginResult.message[i].fullPath;
139
- mediaFile.type = pluginResult.message[i].type;
140
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
141
- mediaFile.size = pluginResult.message[i].size;
142
- mediaFiles.push(mediaFile);
143
- }
144
- successCallback(mediaFiles);
145
- };
146
- Cordova.exec(win, errorCallback, "Capture", type, [options]);
147
- };
148
-
149
-
150
- /**
151
- * Encapsulates a set of parameters that the capture device supports.
152
- */
153
- var ConfigurationData = function(){
154
- // The ASCII-encoded string in lower case representing the media type.
155
- this.type = null;
156
- // The height attribute represents height of the image or video in pixels.
157
- // In the case of a sound clip this attribute has value 0.
158
- this.height = 0;
159
- // The width attribute represents width of the image or video in pixels.
160
- // In the case of a sound clip this attribute has value 0
161
- this.width = 0;
162
- };
163
-
164
- /**
165
- * Encapsulates all image capture operation configuration options.
166
- */
167
- var CaptureImageOptions = function(){
168
- // Upper limit of images user can take. Value must be equal or greater than 1.
169
- this.limit = 1;
170
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
171
- this.mode = null;
172
- };
173
-
174
- /**
175
- * Encapsulates all video capture operation configuration options.
176
- */
177
- var CaptureVideoOptions = function(){
178
- // Upper limit of videos user can record. Value must be equal or greater than 1.
179
- this.limit = 1;
180
- // Maximum duration of a single video clip in seconds.
181
- this.duration = 0;
182
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
183
- this.mode = null;
184
- };
185
-
186
- /**
187
- * Encapsulates all audio capture operation configuration options.
188
- */
189
- var CaptureAudioOptions = function(){
190
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
191
- this.limit = 1;
192
- // Maximum duration of a single sound clip in seconds.
193
- this.duration = 0;
194
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
195
- this.mode = null;
196
- };
197
-
198
- Cordova.addConstructor(function(){
199
- if (typeof navigator.device.capture === "undefined") {
200
- navigator.device.capture = window.device.capture = new Capture();
201
- }
202
- });
203
- }
@@ -1,168 +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("compass")) {
21
- Cordova.addResource("compass");
22
-
23
- var CompassError = function(){
24
- this.code = null;
25
- };
26
-
27
- // Capture error codes
28
- CompassError.COMPASS_INTERNAL_ERR = 0;
29
- CompassError.COMPASS_NOT_SUPPORTED = 20;
30
-
31
- var CompassHeading = function() {
32
- this.magneticHeading = null;
33
- this.trueHeading = null;
34
- this.headingAccuracy = null;
35
- this.timestamp = null;
36
- };
37
-
38
- /**
39
- * This class provides access to device Compass data.
40
- * @constructor
41
- */
42
- var Compass = function() {
43
- /**
44
- * The last known Compass position.
45
- */
46
- this.lastHeading = null;
47
-
48
- /**
49
- * List of compass watch timers
50
- */
51
- this.timers = {};
52
- };
53
-
54
- Compass.ERROR_MSG = ["Not running", "Starting", "", "Failed to start"];
55
-
56
- /**
57
- * Asynchronously aquires the current heading.
58
- *
59
- * @param {Function} successCallback The function to call when the heading data is available
60
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
61
- * @param {PositionOptions} options The options for getting the heading data such as timeout. (OPTIONAL)
62
- */
63
- Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, options) {
64
-
65
- // successCallback required
66
- if (typeof successCallback !== "function") {
67
- console.log("Compass Error: successCallback is not a function");
68
- return;
69
- }
70
-
71
- // errorCallback optional
72
- if (errorCallback && (typeof errorCallback !== "function")) {
73
- console.log("Compass Error: errorCallback is not a function");
74
- return;
75
- }
76
-
77
- var win = function(result) {
78
- if (result.timestamp) {
79
- var timestamp = new Date(result.timestamp);
80
- result.timestamp = timestamp;
81
- }
82
- successCallback(result);
83
- };
84
-
85
- // Get heading
86
- Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
87
- };
88
-
89
- /**
90
- * Asynchronously aquires the heading repeatedly at a given interval.
91
- *
92
- * @param {Function} successCallback The function to call each time the heading data is available
93
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
94
- * @param {HeadingOptions} options The options for getting the heading data such as timeout and the frequency of the watch. (OPTIONAL)
95
- * @return String The watch id that must be passed to #clearWatch to stop watching.
96
- */
97
- Compass.prototype.watchHeading= function(successCallback, errorCallback, options) {
98
-
99
- // Default interval (100 msec)
100
- var frequency = (options !== undefined) ? options.frequency : 100;
101
-
102
- // successCallback required
103
- if (typeof successCallback !== "function") {
104
- console.log("Compass Error: successCallback is not a function");
105
- return;
106
- }
107
-
108
- // errorCallback optional
109
- if (errorCallback && (typeof errorCallback !== "function")) {
110
- console.log("Compass Error: errorCallback is not a function");
111
- return;
112
- }
113
-
114
- // Make sure compass timeout > frequency + 10 sec
115
- Cordova.exec(
116
- function(timeout) {
117
- if (timeout < (frequency + 10000)) {
118
- Cordova.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
119
- }
120
- },
121
- function(e) { }, "Compass", "getTimeout", []);
122
-
123
- // Start watch timer to get headings
124
- var id = Cordova.createUUID();
125
- navigator.compass.timers[id] = setInterval(
126
- function() {
127
- var win = function(result) {
128
- if (result.timestamp) {
129
- var timestamp = new Date(result.timestamp);
130
- result.timestamp = timestamp;
131
- }
132
- successCallback(result);
133
- };
134
- Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
135
- }, (frequency ? frequency : 1));
136
-
137
- return id;
138
- };
139
-
140
-
141
- /**
142
- * Clears the specified heading watch.
143
- *
144
- * @param {String} id The ID of the watch returned from #watchHeading.
145
- */
146
- Compass.prototype.clearWatch = function(id) {
147
-
148
- // Stop javascript timer & remove from timer list
149
- if (id && navigator.compass.timers[id]) {
150
- clearInterval(navigator.compass.timers[id]);
151
- delete navigator.compass.timers[id];
152
- }
153
- };
154
-
155
- Compass.prototype._castDate = function(pluginResult) {
156
- if (pluginResult.message.timestamp) {
157
- var timestamp = new Date(pluginResult.message.timestamp);
158
- pluginResult.message.timestamp = timestamp;
159
- }
160
- return pluginResult;
161
- };
162
-
163
- Cordova.addConstructor(function() {
164
- if (typeof navigator.compass === "undefined") {
165
- navigator.compass = new Compass();
166
- }
167
- });
168
- }