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
|
@@ -108,40 +108,6 @@
|
|
|
108
108
|
-->
|
|
109
109
|
<import file="${sdk.dir}/tools/ant/build.xml" />
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
<target name="check-javascript" depends="build-javascript">
|
|
113
|
-
<!--
|
|
114
|
-
<delete dir="assets/lib"/>
|
|
115
|
-
<mkdir dir="assets/lib"/>
|
|
116
|
-
<echo file="assets/lib/lint.js">var alert=function(){},device={},Element={},debug={};</echo>
|
|
117
|
-
<concat destfile="assets/lib/cordova-lint.js" append="true">
|
|
118
|
-
<fileset dir="assets/lib">
|
|
119
|
-
<include name="lint.js" />
|
|
120
|
-
</fileset>
|
|
121
|
-
<fileset dir="assets/www">
|
|
122
|
-
<include name="cordova-${version}.js" />
|
|
123
|
-
</fileset>
|
|
124
|
-
</concat>
|
|
125
|
-
|
|
126
|
-
<exec executable="cmd" os="Windows 7">
|
|
127
|
-
<arg value="/c"/>
|
|
128
|
-
<arg value="java"/>
|
|
129
|
-
<arg value="-cp"/>
|
|
130
|
-
<arg value="${basedir}/util/js.jar"/>
|
|
131
|
-
<arg value="org.mozilla.javascript.tools.shell.Main"/>
|
|
132
|
-
<arg value="${basedir}/util/jslint.js"/>
|
|
133
|
-
<arg value="${basedir}/js/lib/cordova-lint.js"/>
|
|
134
|
-
</exec>
|
|
135
|
-
<exec executable="java" os="Mac OS X">
|
|
136
|
-
<arg value="-cp"/>
|
|
137
|
-
<arg value="../util/js.jar"/>
|
|
138
|
-
<arg value="org.mozilla.javascript.tools.shell.Main"/>
|
|
139
|
-
<arg value="../util/jslint.js"/>
|
|
140
|
-
<arg value="assets/lib/cordova-lint.js"/>
|
|
141
|
-
</exec>
|
|
142
|
-
-->
|
|
143
|
-
</target>
|
|
144
|
-
|
|
145
111
|
<!-- Combine JavaScript files into one cordova-uncompressed.js file. -->
|
|
146
112
|
<target name="build-javascript" depends="clean">
|
|
147
113
|
|
|
@@ -151,24 +117,18 @@
|
|
|
151
117
|
<!-- Create uncompressed JS file -->
|
|
152
118
|
<concat destfile="assets/www/cordova-${version}.js">
|
|
153
119
|
<filelist dir="assets/js" files="cordova.android.js"/>
|
|
154
|
-
<!--
|
|
155
|
-
<filelist dir="assets/js" files="cordova.js.base,device.js"/>
|
|
156
|
-
<fileset dir="assets/js" includes="*.js" excludes="cordova.js.base,device.js"/>
|
|
157
|
-
-->
|
|
158
120
|
</concat>
|
|
159
121
|
|
|
160
122
|
<!-- update project files to reference cordova-x.x.x.min.js -->
|
|
161
123
|
<replaceregexp match="cordova(.*)\.js" replace="cordova-${version}.js" byline="true">
|
|
162
124
|
<fileset file="assets/www/index.html" />
|
|
163
|
-
|
|
125
|
+
<fileset file="../bin/templates/project/cordova/templates/project/assets/www/index.html" />
|
|
164
126
|
</replaceregexp>
|
|
127
|
+
|
|
165
128
|
<!-- This is sketchy, but it works, ${dblQuote} does not -->
|
|
166
129
|
<replaceregexp match="cordovaVersion = [\u0022].*[\u0022];" replace='cordovaVersion = ${dblQuote}${version}${dblQuote};' byline="true">
|
|
167
130
|
<fileset file="src/org/apache/cordova/Device.java" />
|
|
168
131
|
</replaceregexp>
|
|
169
|
-
|
|
170
|
-
<!-- Delete temp file -->
|
|
171
|
-
<!--<delete file="assets/www/cordova-tmp.js"/>-->
|
|
172
132
|
</target>
|
|
173
133
|
|
|
174
134
|
<!-- Build Cordova jar file that includes all native code, and Cordova JS file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
|
28
28
|
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
|
|
29
29
|
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
|
30
|
-
<plugin name="
|
|
30
|
+
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
|
|
31
31
|
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
|
32
32
|
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
|
33
33
|
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>
|
|
34
34
|
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
|
35
35
|
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
|
36
36
|
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
|
37
|
+
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
|
37
38
|
</plugins>
|
|
@@ -28,6 +28,7 @@ import android.os.Environment;
|
|
|
28
28
|
import android.util.Log;
|
|
29
29
|
|
|
30
30
|
import java.io.File;
|
|
31
|
+
import java.io.FileInputStream;
|
|
31
32
|
import java.io.IOException;
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -116,7 +117,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
116
117
|
public void startRecording(String file) {
|
|
117
118
|
if (this.mPlayer != null) {
|
|
118
119
|
Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
|
|
119
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
|
120
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// Make sure we're not already recording
|
|
@@ -137,11 +138,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
137
138
|
} catch (IOException e) {
|
|
138
139
|
e.printStackTrace();
|
|
139
140
|
}
|
|
140
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
|
141
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
|
|
141
142
|
}
|
|
142
143
|
else {
|
|
143
144
|
Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
|
|
144
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
|
145
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
|
|
@@ -183,7 +184,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
183
184
|
public void startPlaying(String file) {
|
|
184
185
|
if (this.recorder != null) {
|
|
185
186
|
Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
|
|
186
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
|
187
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
// If this is a new request to play audio, or stopped
|
|
@@ -215,9 +216,16 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
215
216
|
android.content.res.AssetFileDescriptor fd = this.handler.ctx.getBaseContext().getAssets().openFd(f);
|
|
216
217
|
this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
else {
|
|
220
|
+
File fp = new File(file);
|
|
221
|
+
if (fp.exists()) {
|
|
222
|
+
FileInputStream fileInputStream = new FileInputStream(file);
|
|
223
|
+
this.mPlayer.setDataSource(fileInputStream.getFD());
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
this.mPlayer.setDataSource("/sdcard/" + file);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
221
229
|
this.setState(MEDIA_STARTING);
|
|
222
230
|
this.mPlayer.setOnPreparedListener(this);
|
|
223
231
|
this.mPlayer.prepare();
|
|
@@ -228,7 +236,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
228
236
|
}
|
|
229
237
|
catch (Exception e) {
|
|
230
238
|
e.printStackTrace();
|
|
231
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
|
239
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
|
|
232
240
|
}
|
|
233
241
|
}
|
|
234
242
|
|
|
@@ -242,7 +250,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
242
250
|
}
|
|
243
251
|
else {
|
|
244
252
|
Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state);
|
|
245
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
|
253
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
256
|
}
|
|
@@ -254,7 +262,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
254
262
|
if (this.mPlayer != null) {
|
|
255
263
|
this.mPlayer.seekTo(milliseconds);
|
|
256
264
|
Log.d(LOG_TAG, "Send a onStatus update for the new seek");
|
|
257
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
|
|
265
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
|
|
@@ -270,7 +278,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
270
278
|
}
|
|
271
279
|
else {
|
|
272
280
|
Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state);
|
|
273
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
|
281
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_NONE_ACTIVE+"});");
|
|
274
282
|
}
|
|
275
283
|
}
|
|
276
284
|
|
|
@@ -284,7 +292,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
284
292
|
}
|
|
285
293
|
else {
|
|
286
294
|
Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);
|
|
287
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
|
295
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_NONE_ACTIVE+"});");
|
|
288
296
|
}
|
|
289
297
|
}
|
|
290
298
|
|
|
@@ -305,7 +313,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
305
313
|
public long getCurrentPosition() {
|
|
306
314
|
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
|
|
307
315
|
int curPos = this.mPlayer.getCurrentPosition();
|
|
308
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
|
|
316
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
|
|
309
317
|
return curPos;
|
|
310
318
|
}
|
|
311
319
|
else {
|
|
@@ -384,7 +392,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
384
392
|
this.prepareOnly = false;
|
|
385
393
|
|
|
386
394
|
// Send status notification to JavaScript
|
|
387
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
|
|
395
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
|
|
388
396
|
|
|
389
397
|
}
|
|
390
398
|
|
|
@@ -413,7 +421,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
413
421
|
this.mPlayer.release();
|
|
414
422
|
|
|
415
423
|
// Send error notification to JavaScript
|
|
416
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "
|
|
424
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', { \"code\":"+arg1+"});");
|
|
417
425
|
return false;
|
|
418
426
|
}
|
|
419
427
|
|
|
@@ -424,7 +432,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|
|
424
432
|
*/
|
|
425
433
|
private void setState(int state) {
|
|
426
434
|
if (this.state != state) {
|
|
427
|
-
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
|
|
435
|
+
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
|
|
428
436
|
}
|
|
429
437
|
|
|
430
438
|
this.state = state;
|
|
@@ -31,14 +31,13 @@ import org.apache.cordova.api.Plugin;
|
|
|
31
31
|
import org.apache.cordova.api.PluginResult;
|
|
32
32
|
import org.json.JSONArray;
|
|
33
33
|
import org.json.JSONException;
|
|
34
|
-
import org.json.JSONObject;
|
|
35
|
-
|
|
36
34
|
|
|
37
35
|
import android.app.Activity;
|
|
38
36
|
import android.content.ContentValues;
|
|
39
37
|
import android.content.Intent;
|
|
40
38
|
import android.database.Cursor;
|
|
41
39
|
import android.graphics.Bitmap;
|
|
40
|
+
import android.graphics.Matrix;
|
|
42
41
|
import android.graphics.Bitmap.CompressFormat;
|
|
43
42
|
import android.net.Uri;
|
|
44
43
|
import android.provider.MediaStore;
|
|
@@ -114,6 +113,7 @@ public class CameraLauncher extends Plugin {
|
|
|
114
113
|
this.targetWidth = args.getInt(3);
|
|
115
114
|
this.targetHeight = args.getInt(4);
|
|
116
115
|
this.encodingType = args.getInt(5);
|
|
116
|
+
this.mediaType = args.getInt(6);
|
|
117
117
|
|
|
118
118
|
if (srcType == CAMERA) {
|
|
119
119
|
this.takePicture(destType, encodingType);
|
|
@@ -272,19 +272,24 @@ public class CameraLauncher extends Plugin {
|
|
|
272
272
|
// Get src and dest types from request code
|
|
273
273
|
int srcType = (requestCode/16) - 1;
|
|
274
274
|
int destType = (requestCode % 16) - 1;
|
|
275
|
+
int rotate = 0;
|
|
275
276
|
|
|
277
|
+
// Create an ExifHelper to save the exif data that is lost during compression
|
|
278
|
+
ExifHelper exif = new ExifHelper();
|
|
279
|
+
try {
|
|
280
|
+
if (this.encodingType == JPEG) {
|
|
281
|
+
exif.createInFile(DirectoryManager.getTempDirectoryPath(ctx.getContext()) + "/Pic.jpg");
|
|
282
|
+
exif.readExifData();
|
|
283
|
+
}
|
|
284
|
+
} catch (IOException e) {
|
|
285
|
+
e.printStackTrace();
|
|
286
|
+
}
|
|
287
|
+
|
|
276
288
|
// If CAMERA
|
|
277
289
|
if (srcType == CAMERA) {
|
|
278
290
|
// If image available
|
|
279
291
|
if (resultCode == Activity.RESULT_OK) {
|
|
280
292
|
try {
|
|
281
|
-
// Create an ExifHelper to save the exif data that is lost during compression
|
|
282
|
-
ExifHelper exif = new ExifHelper();
|
|
283
|
-
if (this.encodingType == JPEG) {
|
|
284
|
-
exif.createInFile(DirectoryManager.getTempDirectoryPath(ctx.getContext()) + "/Pic.jpg");
|
|
285
|
-
exif.readExifData();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
293
|
// Read in bitmap of captured image
|
|
289
294
|
Bitmap bitmap;
|
|
290
295
|
try {
|
|
@@ -375,6 +380,20 @@ public class CameraLauncher extends Plugin {
|
|
|
375
380
|
if (destType == DATA_URL) {
|
|
376
381
|
try {
|
|
377
382
|
Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
|
|
383
|
+
String[] cols = { MediaStore.Images.Media.ORIENTATION };
|
|
384
|
+
Cursor cursor = this.ctx.getContentResolver().query(intent.getData(),
|
|
385
|
+
cols,
|
|
386
|
+
null, null, null);
|
|
387
|
+
if (cursor != null) {
|
|
388
|
+
cursor.moveToPosition(0);
|
|
389
|
+
rotate = cursor.getInt(0);
|
|
390
|
+
cursor.close();
|
|
391
|
+
}
|
|
392
|
+
if (rotate != 0) {
|
|
393
|
+
Matrix matrix = new Matrix();
|
|
394
|
+
matrix.setRotate(rotate);
|
|
395
|
+
bitmap = bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
|
396
|
+
}
|
|
378
397
|
bitmap = scaleBitmap(bitmap);
|
|
379
398
|
this.processPicture(bitmap);
|
|
380
399
|
bitmap.recycle();
|
|
@@ -399,6 +418,12 @@ public class CameraLauncher extends Plugin {
|
|
|
399
418
|
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
|
|
400
419
|
os.close();
|
|
401
420
|
|
|
421
|
+
// Restore exif data to file
|
|
422
|
+
if (this.encodingType == JPEG) {
|
|
423
|
+
exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.ctx));
|
|
424
|
+
exif.writeExifData();
|
|
425
|
+
}
|
|
426
|
+
|
|
402
427
|
bitmap.recycle();
|
|
403
428
|
bitmap = null;
|
|
404
429
|
|
|
@@ -497,4 +522,4 @@ public class CameraLauncher extends Plugin {
|
|
|
497
522
|
public void failPicture(String err) {
|
|
498
523
|
this.error(new PluginResult(PluginResult.Status.ERROR, err), this.callbackId);
|
|
499
524
|
}
|
|
500
|
-
}
|
|
525
|
+
}
|
|
@@ -84,7 +84,8 @@ public abstract class ContactAccessor {
|
|
|
84
84
|
map.put("displayName", true);
|
|
85
85
|
}
|
|
86
86
|
else if (key.startsWith("name")) {
|
|
87
|
-
|
|
87
|
+
map.put("displayName", true);
|
|
88
|
+
map.put("name", true);
|
|
88
89
|
}
|
|
89
90
|
else if (key.startsWith("nickname")) {
|
|
90
91
|
map.put("nickname", true);
|
|
@@ -1649,71 +1649,73 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
|
|
1649
1649
|
*/
|
|
1650
1650
|
private int getPhoneType(String string) {
|
|
1651
1651
|
int type = ContactsContract.CommonDataKinds.Phone.TYPE_OTHER;
|
|
1652
|
-
if (
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1652
|
+
if (string != null) {
|
|
1653
|
+
if ("home".equals(string.toLowerCase())) {
|
|
1654
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_HOME;
|
|
1655
|
+
}
|
|
1656
|
+
else if ("mobile".equals(string.toLowerCase())) {
|
|
1657
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE;
|
|
1658
|
+
}
|
|
1659
|
+
else if ("work".equals(string.toLowerCase())) {
|
|
1660
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_WORK;
|
|
1661
|
+
}
|
|
1662
|
+
else if ("work fax".equals(string.toLowerCase())) {
|
|
1663
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK;
|
|
1664
|
+
}
|
|
1665
|
+
else if ("home fax".equals(string.toLowerCase())) {
|
|
1666
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME;
|
|
1667
|
+
}
|
|
1668
|
+
else if ("fax".equals(string.toLowerCase())) {
|
|
1669
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK;
|
|
1670
|
+
}
|
|
1671
|
+
else if ("pager".equals(string.toLowerCase())) {
|
|
1672
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_PAGER;
|
|
1673
|
+
}
|
|
1674
|
+
else if ("other".equals(string.toLowerCase())) {
|
|
1675
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_OTHER;
|
|
1676
|
+
}
|
|
1677
|
+
else if ("car".equals(string.toLowerCase())) {
|
|
1678
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_CAR;
|
|
1679
|
+
}
|
|
1680
|
+
else if ("company main".equals(string.toLowerCase())) {
|
|
1681
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN;
|
|
1682
|
+
}
|
|
1683
|
+
else if ("isdn".equals(string.toLowerCase())) {
|
|
1684
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_ISDN;
|
|
1685
|
+
}
|
|
1686
|
+
else if ("main".equals(string.toLowerCase())) {
|
|
1687
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_MAIN;
|
|
1688
|
+
}
|
|
1689
|
+
else if ("other fax".equals(string.toLowerCase())) {
|
|
1690
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX;
|
|
1691
|
+
}
|
|
1692
|
+
else if ("radio".equals(string.toLowerCase())) {
|
|
1693
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_RADIO;
|
|
1694
|
+
}
|
|
1695
|
+
else if ("telex".equals(string.toLowerCase())) {
|
|
1696
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_TELEX;
|
|
1697
|
+
}
|
|
1698
|
+
else if ("work mobile".equals(string.toLowerCase())) {
|
|
1699
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE;
|
|
1700
|
+
}
|
|
1701
|
+
else if ("work pager".equals(string.toLowerCase())) {
|
|
1702
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER;
|
|
1703
|
+
}
|
|
1704
|
+
else if ("assistant".equals(string.toLowerCase())) {
|
|
1705
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT;
|
|
1706
|
+
}
|
|
1707
|
+
else if ("mms".equals(string.toLowerCase())) {
|
|
1708
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_MMS;
|
|
1709
|
+
}
|
|
1710
|
+
else if ("callback".equals(string.toLowerCase())) {
|
|
1711
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_CALLBACK;
|
|
1712
|
+
}
|
|
1713
|
+
else if ("tty ttd".equals(string.toLowerCase())) {
|
|
1714
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD;
|
|
1715
|
+
}
|
|
1716
|
+
else if ("custom".equals(string.toLowerCase())) {
|
|
1717
|
+
return ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM;
|
|
1718
|
+
}
|
|
1717
1719
|
}
|
|
1718
1720
|
return type;
|
|
1719
1721
|
}
|
|
@@ -26,52 +26,42 @@ import org.json.JSONObject;
|
|
|
26
26
|
import android.util.Log;
|
|
27
27
|
|
|
28
28
|
public class ContactManager extends Plugin {
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
private ContactAccessor contactAccessor;
|
|
31
|
-
|
|
31
|
+
private static final String LOG_TAG = "Contact Query";
|
|
32
|
+
|
|
33
|
+
public static final int UNKNOWN_ERROR = 0;
|
|
34
|
+
public static final int INVALID_ARGUMENT_ERROR = 1;
|
|
35
|
+
public static final int TIMEOUT_ERROR = 2;
|
|
36
|
+
public static final int PENDING_OPERATION_ERROR = 3;
|
|
37
|
+
public static final int IO_ERROR = 4;
|
|
38
|
+
public static final int NOT_SUPPORTED_ERROR = 5;
|
|
39
|
+
public static final int PERMISSION_DENIED_ERROR = 20;
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
public static final int NOT_SUPPORTED_ERROR = 5;
|
|
39
|
-
public static final int PERMISSION_DENIED_ERROR = 20;
|
|
41
|
+
/**
|
|
42
|
+
* Constructor.
|
|
43
|
+
*/
|
|
44
|
+
public ContactManager() {
|
|
45
|
+
}
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
* @param action The action to execute.
|
|
52
|
-
* @param args JSONArry of arguments for the plugin.
|
|
53
|
-
* @param callbackId The callback id used when calling back into JavaScript.
|
|
54
|
-
* @return A PluginResult object with a status and message.
|
|
55
|
-
*/
|
|
56
|
-
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
|
47
|
+
/**
|
|
48
|
+
* Executes the request and returns PluginResult.
|
|
49
|
+
*
|
|
50
|
+
* @param action The action to execute.
|
|
51
|
+
* @param args JSONArry of arguments for the plugin.
|
|
52
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
|
53
|
+
* @return A PluginResult object with a status and message.
|
|
54
|
+
*/
|
|
55
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
|
57
56
|
PluginResult.Status status = PluginResult.Status.OK;
|
|
58
|
-
String result = "";
|
|
57
|
+
String result = "";
|
|
59
58
|
|
|
60
59
|
/**
|
|
61
60
|
* Check to see if we are on an Android 1.X device. If we are return an error as we
|
|
62
61
|
* do not support this as of Cordova 1.0.
|
|
63
62
|
*/
|
|
64
63
|
if (android.os.Build.VERSION.RELEASE.startsWith("1.")) {
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
res = new JSONObject();
|
|
68
|
-
res.put("code", NOT_SUPPORTED_ERROR);
|
|
69
|
-
res.put("message", "Contacts are not supported in Android 1.X devices");
|
|
70
|
-
} catch (JSONException e) {
|
|
71
|
-
// This should never happen
|
|
72
|
-
Log.e(LOG_TAG, e.getMessage(), e);
|
|
73
|
-
}
|
|
74
|
-
return new PluginResult(PluginResult.Status.ERROR, res);
|
|
64
|
+
return new PluginResult(PluginResult.Status.ERROR, ContactManager.NOT_SUPPORTED_ERROR);
|
|
75
65
|
}
|
|
76
66
|
|
|
77
67
|
/**
|
|
@@ -81,33 +71,31 @@ public class ContactManager extends Plugin {
|
|
|
81
71
|
if (this.contactAccessor == null) {
|
|
82
72
|
this.contactAccessor = new ContactAccessorSdk5(this.webView, this.ctx.getContext());
|
|
83
73
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (action.equals("search")) {
|
|
77
|
+
JSONArray res = contactAccessor.search(args.getJSONArray(0), args.optJSONObject(1));
|
|
78
|
+
return new PluginResult(status, res);
|
|
79
|
+
}
|
|
80
|
+
else if (action.equals("save")) {
|
|
81
|
+
String id = contactAccessor.save(args.getJSONObject(0));
|
|
82
|
+
if (id != null) {
|
|
83
|
+
JSONObject res = contactAccessor.getContactById(id);
|
|
84
|
+
if (res != null) {
|
|
85
|
+
return new PluginResult(status, res);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (action.equals("remove")) {
|
|
90
|
+
if (contactAccessor.remove(args.getString(0))) {
|
|
91
|
+
return new PluginResult(status, result);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// If we get to this point an error has occurred
|
|
95
|
+
return new PluginResult(PluginResult.Status.ERROR, ContactManager.UNKNOWN_ERROR);
|
|
96
|
+
} catch (JSONException e) {
|
|
97
|
+
Log.e(LOG_TAG, e.getMessage(), e);
|
|
98
|
+
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
|
102
99
|
}
|
|
103
|
-
}
|
|
104
|
-
// If we get to this point an error has occurred
|
|
105
|
-
JSONObject r = new JSONObject();
|
|
106
|
-
r.put("code", UNKNOWN_ERROR);
|
|
107
|
-
return new PluginResult(PluginResult.Status.ERROR, r);
|
|
108
|
-
} catch (JSONException e) {
|
|
109
|
-
Log.e(LOG_TAG, e.getMessage(), e);
|
|
110
|
-
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
|
111
100
|
}
|
|
112
|
-
}
|
|
113
101
|
}
|