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.
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
@@ -19,7 +19,7 @@
19
19
  <html>
20
20
  <head>
21
21
  <title></title>
22
- <script src="cordova-1.5.0.js"></script>
22
+ <script src="cordova-1.7.0.js"></script>
23
23
  </head>
24
24
  <body>
25
25
 
@@ -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
- <!-- <fileset file="../bin/templates/project/assets/www/index.html" /> -->
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
@@ -10,5 +10,5 @@
10
10
  # Indicates whether an apk should be generated for each density.
11
11
  split.density=false
12
12
  # Project target.
13
- target=Google Inc.:Google APIs:15
13
+ target=android-15
14
14
  apk-configurations=
@@ -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="Network Status" value="org.apache.cordova.NetworkManager"/>
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>
@@ -1,4 +1,5 @@
1
1
  /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
2
3
  or more contributor license agreements. See the NOTICE file
3
4
  distributed with this work for additional information
4
5
  regarding copyright ownership. The ASF licenses this file
@@ -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
- else {
219
- this.mPlayer.setDataSource("/sdcard/" + file);
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 + "', "+MEDIA_ERROR+", "+arg1+");");
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
- map.put("name", true);
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 ("home".equals(string.toLowerCase())) {
1653
- return ContactsContract.CommonDataKinds.Phone.TYPE_HOME;
1654
- }
1655
- else if ("mobile".equals(string.toLowerCase())) {
1656
- return ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE;
1657
- }
1658
- else if ("work".equals(string.toLowerCase())) {
1659
- return ContactsContract.CommonDataKinds.Phone.TYPE_WORK;
1660
- }
1661
- else if ("work fax".equals(string.toLowerCase())) {
1662
- return ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK;
1663
- }
1664
- else if ("home fax".equals(string.toLowerCase())) {
1665
- return ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME;
1666
- }
1667
- else if ("fax".equals(string.toLowerCase())) {
1668
- return ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK;
1669
- }
1670
- else if ("pager".equals(string.toLowerCase())) {
1671
- return ContactsContract.CommonDataKinds.Phone.TYPE_PAGER;
1672
- }
1673
- else if ("other".equals(string.toLowerCase())) {
1674
- return ContactsContract.CommonDataKinds.Phone.TYPE_OTHER;
1675
- }
1676
- else if ("car".equals(string.toLowerCase())) {
1677
- return ContactsContract.CommonDataKinds.Phone.TYPE_CAR;
1678
- }
1679
- else if ("company main".equals(string.toLowerCase())) {
1680
- return ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN;
1681
- }
1682
- else if ("isdn".equals(string.toLowerCase())) {
1683
- return ContactsContract.CommonDataKinds.Phone.TYPE_ISDN;
1684
- }
1685
- else if ("main".equals(string.toLowerCase())) {
1686
- return ContactsContract.CommonDataKinds.Phone.TYPE_MAIN;
1687
- }
1688
- else if ("other fax".equals(string.toLowerCase())) {
1689
- return ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX;
1690
- }
1691
- else if ("radio".equals(string.toLowerCase())) {
1692
- return ContactsContract.CommonDataKinds.Phone.TYPE_RADIO;
1693
- }
1694
- else if ("telex".equals(string.toLowerCase())) {
1695
- return ContactsContract.CommonDataKinds.Phone.TYPE_TELEX;
1696
- }
1697
- else if ("work mobile".equals(string.toLowerCase())) {
1698
- return ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE;
1699
- }
1700
- else if ("work pager".equals(string.toLowerCase())) {
1701
- return ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER;
1702
- }
1703
- else if ("assistant".equals(string.toLowerCase())) {
1704
- return ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT;
1705
- }
1706
- else if ("mms".equals(string.toLowerCase())) {
1707
- return ContactsContract.CommonDataKinds.Phone.TYPE_MMS;
1708
- }
1709
- else if ("callback".equals(string.toLowerCase())) {
1710
- return ContactsContract.CommonDataKinds.Phone.TYPE_CALLBACK;
1711
- }
1712
- else if ("tty ttd".equals(string.toLowerCase())) {
1713
- return ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD;
1714
- }
1715
- else if ("custom".equals(string.toLowerCase())) {
1716
- return ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM;
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
- private static final String LOG_TAG = "Contact Query";
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
- 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;
41
+ /**
42
+ * Constructor.
43
+ */
44
+ public ContactManager() {
45
+ }
40
46
 
41
-
42
- /**
43
- * Constructor.
44
- */
45
- public ContactManager() {
46
- }
47
-
48
- /**
49
- * Executes the request and returns PluginResult.
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
- JSONObject res = null;
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
- try {
86
- if (action.equals("search")) {
87
- JSONArray res = contactAccessor.search(args.getJSONArray(0), args.optJSONObject(1));
88
- return new PluginResult(status, res);
89
- }
90
- else if (action.equals("save")) {
91
- String id = contactAccessor.save(args.getJSONObject(0));
92
- if (id != null) {
93
- JSONObject res = contactAccessor.getContactById(id);
94
- if (res != null) {
95
- return new PluginResult(status, res);
96
- }
97
- }
98
- }
99
- else if (action.equals("remove")) {
100
- if (contactAccessor.remove(args.getString(0))) {
101
- return new PluginResult(status, result);
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
  }