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.
- 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
@@ -94,7 +94,7 @@ public class FileTransfer extends Plugin {
|
|
94
94
|
mimeType = getArgument(args, 4, "image/jpeg");
|
95
95
|
JSONObject params = args.optJSONObject(5);
|
96
96
|
boolean trustEveryone = args.optBoolean(6);
|
97
|
-
boolean chunkedMode = args.optBoolean(7);
|
97
|
+
boolean chunkedMode = args.optBoolean(7) || args.isNull(7); //Always use chunked mode unless set to false as per API
|
98
98
|
FileUploadResult r = upload(source, target, fileKey, fileName, mimeType, params, trustEveryone, chunkedMode);
|
99
99
|
Log.d(LOG_TAG, "****** About to return a result from upload");
|
100
100
|
return new PluginResult(PluginResult.Status.OK, r.toJSONObject());
|
@@ -225,7 +225,7 @@ public class FileTransfer extends Plugin {
|
|
225
225
|
FileUploadResult result = new FileUploadResult();
|
226
226
|
|
227
227
|
// Get a input stream of the file on the phone
|
228
|
-
|
228
|
+
FileInputStream fileInputStream = (FileInputStream) getPathFromUri(file);
|
229
229
|
|
230
230
|
HttpURLConnection conn = null;
|
231
231
|
DataOutputStream dos = null;
|
@@ -276,7 +276,7 @@ public class FileTransfer extends Plugin {
|
|
276
276
|
conn.setRequestMethod("POST");
|
277
277
|
conn.setRequestProperty("Connection", "Keep-Alive");
|
278
278
|
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+BOUNDRY);
|
279
|
-
|
279
|
+
|
280
280
|
// Handle the other headers
|
281
281
|
try {
|
282
282
|
JSONObject headers = params.getJSONObject("headers");
|
@@ -294,35 +294,54 @@ public class FileTransfer extends Plugin {
|
|
294
294
|
if (cookie != null) {
|
295
295
|
conn.setRequestProperty("Cookie", cookie);
|
296
296
|
}
|
297
|
+
|
297
298
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
dos = new DataOutputStream( conn.getOutputStream() );
|
304
|
-
|
305
|
-
// Send any extra parameters
|
299
|
+
/*
|
300
|
+
* Store the non-file portions of the multipart data as a string, so that we can add it
|
301
|
+
* to the contentSize, since it is part of the body of the HTTP request.
|
302
|
+
*/
|
303
|
+
String extraParams = "";
|
306
304
|
try {
|
307
305
|
for (Iterator iter = params.keys(); iter.hasNext();) {
|
308
306
|
Object key = iter.next();
|
309
307
|
if(key.toString() != "headers")
|
310
308
|
{
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
309
|
+
extraParams += LINE_START + BOUNDRY + LINE_END;
|
310
|
+
extraParams += "Content-Disposition: form-data; name=\"" + key.toString() + "\";";
|
311
|
+
extraParams += LINE_END + LINE_END;
|
312
|
+
extraParams += params.getString(key.toString());
|
313
|
+
extraParams += LINE_END;
|
316
314
|
}
|
317
315
|
}
|
318
316
|
} catch (JSONException e) {
|
319
317
|
Log.e(LOG_TAG, e.getMessage(), e);
|
320
318
|
}
|
319
|
+
|
320
|
+
extraParams += LINE_START + BOUNDRY + LINE_END;
|
321
|
+
extraParams += "Content-Disposition: form-data; name=\"" + fileKey + "\";" + " filename=\"";
|
322
|
+
|
323
|
+
String midParams = "\"" + LINE_END + "Content-Type: " + mimeType + LINE_END + LINE_END;
|
324
|
+
String tailParams = LINE_END + LINE_START + BOUNDRY + LINE_START + LINE_END;
|
325
|
+
|
326
|
+
// Should set this up as an option
|
327
|
+
if (chunkedMode) {
|
328
|
+
conn.setChunkedStreamingMode(maxBufferSize);
|
329
|
+
}
|
330
|
+
else
|
331
|
+
{
|
332
|
+
int stringLength = extraParams.length() + midParams.length() + tailParams.length() + fileName.getBytes("UTF-8").length;
|
333
|
+
Log.d(LOG_TAG, "String Length: " + stringLength);
|
334
|
+
int fixedLength = (int) fileInputStream.getChannel().size() + stringLength;
|
335
|
+
Log.d(LOG_TAG, "Content Length: " + fixedLength);
|
336
|
+
conn.setFixedLengthStreamingMode(fixedLength);
|
337
|
+
}
|
338
|
+
|
321
339
|
|
322
|
-
dos
|
323
|
-
dos.writeBytes(
|
324
|
-
|
325
|
-
dos.
|
340
|
+
dos = new DataOutputStream( conn.getOutputStream() );
|
341
|
+
dos.writeBytes(extraParams);
|
342
|
+
//We don't want to chagne encoding, we just want this to write for all Unicode.
|
343
|
+
dos.write(fileName.getBytes("UTF-8"));
|
344
|
+
dos.writeBytes(midParams);
|
326
345
|
|
327
346
|
// create a buffer of maximum size
|
328
347
|
bytesAvailable = fileInputStream.available();
|
@@ -343,8 +362,7 @@ public class FileTransfer extends Plugin {
|
|
343
362
|
}
|
344
363
|
|
345
364
|
// send multipart form data necesssary after file data...
|
346
|
-
dos.writeBytes(
|
347
|
-
dos.writeBytes(LINE_START + BOUNDRY + LINE_START + LINE_END);
|
365
|
+
dos.writeBytes(tailParams);
|
348
366
|
|
349
367
|
// close streams
|
350
368
|
fileInputStream.close();
|
@@ -392,38 +410,53 @@ public class FileTransfer extends Plugin {
|
|
392
410
|
*/
|
393
411
|
public JSONObject download(String source, String target) throws IOException {
|
394
412
|
try {
|
395
|
-
File file =
|
413
|
+
File file = getFileFromPath(target);
|
396
414
|
|
397
415
|
// create needed directories
|
398
416
|
file.getParentFile().mkdirs();
|
399
417
|
|
400
418
|
// connect to server
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
419
|
+
if(this.ctx.isUrlWhiteListed(source))
|
420
|
+
{
|
421
|
+
URL url = new URL(source);
|
422
|
+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
423
|
+
connection.setRequestMethod("GET");
|
424
|
+
|
425
|
+
//Add cookie support
|
426
|
+
String cookie = CookieManager.getInstance().getCookie(source);
|
427
|
+
if(cookie != null)
|
428
|
+
{
|
429
|
+
connection.setRequestProperty("cookie", cookie);
|
430
|
+
}
|
431
|
+
|
432
|
+
connection.connect();
|
433
|
+
|
434
|
+
Log.d(LOG_TAG, "Download file:" + url);
|
435
|
+
|
436
|
+
InputStream inputStream = connection.getInputStream();
|
437
|
+
byte[] buffer = new byte[1024];
|
438
|
+
int bytesRead = 0;
|
439
|
+
|
440
|
+
FileOutputStream outputStream = new FileOutputStream(file);
|
441
|
+
|
442
|
+
// write bytes to file
|
443
|
+
while ( (bytesRead = inputStream.read(buffer)) > 0 ) {
|
416
444
|
outputStream.write(buffer,0, bytesRead);
|
417
|
-
|
445
|
+
}
|
418
446
|
|
419
|
-
|
447
|
+
outputStream.close();
|
420
448
|
|
421
|
-
|
449
|
+
Log.d(LOG_TAG, "Saved file: " + target);
|
422
450
|
|
423
|
-
|
424
|
-
|
451
|
+
// create FileEntry object
|
452
|
+
FileUtils fileUtil = new FileUtils();
|
425
453
|
|
426
|
-
|
454
|
+
return fileUtil.getEntry(file);
|
455
|
+
}
|
456
|
+
else
|
457
|
+
{
|
458
|
+
throw new IOException("Error: Unable to connect to domain");
|
459
|
+
}
|
427
460
|
} catch (Exception e) {
|
428
461
|
Log.d(LOG_TAG, e.getMessage(), e);
|
429
462
|
throw new IOException("Error while downloading");
|
@@ -455,4 +488,17 @@ public class FileTransfer extends Plugin {
|
|
455
488
|
}
|
456
489
|
}
|
457
490
|
|
491
|
+
/**
|
492
|
+
* Get a File object from the passed in path
|
493
|
+
*
|
494
|
+
* @param path
|
495
|
+
* @return
|
496
|
+
*/
|
497
|
+
private File getFileFromPath(String path) {
|
498
|
+
if (path.startsWith("file://")) {
|
499
|
+
return new File(path.substring(7));
|
500
|
+
} else {
|
501
|
+
return new File(path);
|
502
|
+
}
|
503
|
+
}
|
458
504
|
}
|
@@ -142,8 +142,7 @@ public class FileUtils extends Plugin {
|
|
142
142
|
return new PluginResult(status, obj);
|
143
143
|
}
|
144
144
|
else if (action.equals("getMetadata")) {
|
145
|
-
|
146
|
-
return new PluginResult(status, obj);
|
145
|
+
return new PluginResult(status, getMetadata(args.getString(0)));
|
147
146
|
}
|
148
147
|
else if (action.equals("getFileMetadata")) {
|
149
148
|
JSONObject obj = getFileMetadata(args.getString(0));
|
@@ -254,7 +253,12 @@ public class FileUtils extends Plugin {
|
|
254
253
|
URL testUrl = new URL(decoded);
|
255
254
|
|
256
255
|
if (decoded.startsWith("file://")) {
|
257
|
-
|
256
|
+
int questionMark = decoded.indexOf("?");
|
257
|
+
if (questionMark < 0) {
|
258
|
+
fp = new File(decoded.substring(7, decoded.length()));
|
259
|
+
} else {
|
260
|
+
fp = new File(decoded.substring(7, questionMark));
|
261
|
+
}
|
258
262
|
} else {
|
259
263
|
fp = new File(decoded);
|
260
264
|
}
|
@@ -759,21 +763,17 @@ public class FileUtils extends Plugin {
|
|
759
763
|
* Look up metadata about this entry.
|
760
764
|
*
|
761
765
|
* @param filePath to entry
|
762
|
-
* @return a
|
766
|
+
* @return a long
|
763
767
|
* @throws FileNotFoundException
|
764
|
-
* @throws JSONException
|
765
768
|
*/
|
766
|
-
private
|
769
|
+
private long getMetadata(String filePath) throws FileNotFoundException {
|
767
770
|
File file = createFileObject(filePath);
|
768
771
|
|
769
772
|
if (!file.exists()) {
|
770
773
|
throw new FileNotFoundException("Failed to find file in getMetadata");
|
771
774
|
}
|
772
775
|
|
773
|
-
|
774
|
-
metadata.put("modificationTime", file.lastModified());
|
775
|
-
|
776
|
-
return metadata;
|
776
|
+
return file.lastModified();
|
777
777
|
}
|
778
778
|
|
779
779
|
/**
|
@@ -973,23 +973,23 @@ public class FileUtils extends Plugin {
|
|
973
973
|
/**/
|
974
974
|
public long write(String filename, String data, int offset) throws FileNotFoundException, IOException {
|
975
975
|
filename = stripFileProtocol(filename);
|
976
|
-
|
976
|
+
|
977
977
|
boolean append = false;
|
978
978
|
if (offset > 0) {
|
979
979
|
this.truncateFile(filename, offset);
|
980
980
|
append = true;
|
981
981
|
}
|
982
982
|
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
983
|
+
byte [] rawData = data.getBytes();
|
984
|
+
ByteArrayInputStream in = new ByteArrayInputStream(rawData);
|
985
|
+
FileOutputStream out = new FileOutputStream(filename, append);
|
986
|
+
byte buff[] = new byte[rawData.length];
|
987
|
+
in.read(buff, 0, buff.length);
|
988
|
+
out.write(buff, 0, rawData.length);
|
989
|
+
out.flush();
|
990
|
+
out.close();
|
991
991
|
|
992
|
-
return
|
992
|
+
return rawData.length;
|
993
993
|
}
|
994
994
|
|
995
995
|
/**
|
data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
CHANGED
@@ -87,13 +87,13 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
|
|
87
87
|
// gone away.
|
88
88
|
else if (height > oldHeight) {
|
89
89
|
if(app != null)
|
90
|
-
app.sendJavascript("
|
90
|
+
app.sendJavascript("cordova.fireDocumentEvent('hidekeyboard');");
|
91
91
|
}
|
92
92
|
// If the height as gotten smaller then we will assume the soft keyboard has
|
93
93
|
// been displayed.
|
94
94
|
else if (height < oldHeight) {
|
95
95
|
if(app != null)
|
96
|
-
app.sendJavascript("
|
96
|
+
app.sendJavascript("cordova.fireDocumentEvent('showkeyboard');");
|
97
97
|
}
|
98
98
|
|
99
99
|
// Update the old height for the next event
|
@@ -58,7 +58,7 @@ public class NetworkManager extends Plugin {
|
|
58
58
|
public static final String LTE = "lte";
|
59
59
|
public static final String UMB = "umb";
|
60
60
|
public static final String HSPA_PLUS = "hspa+";
|
61
|
-
// return
|
61
|
+
// return type
|
62
62
|
public static final String TYPE_UNKNOWN = "unknown";
|
63
63
|
public static final String TYPE_ETHERNET = "ethernet";
|
64
64
|
public static final String TYPE_WIFI = "wifi";
|
@@ -89,7 +89,7 @@ public class NetworkManager extends Plugin {
|
|
89
89
|
*/
|
90
90
|
public void setContext(CordovaInterface ctx) {
|
91
91
|
super.setContext(ctx);
|
92
|
-
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
92
|
+
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
93
93
|
this.connectionCallbackId = null;
|
94
94
|
|
95
95
|
// We need to listen to connectivity events to update navigator.connection
|
@@ -98,7 +98,7 @@ public class NetworkManager extends Plugin {
|
|
98
98
|
if (this.receiver == null) {
|
99
99
|
this.receiver = new BroadcastReceiver() {
|
100
100
|
@Override
|
101
|
-
public void onReceive(Context context, Intent intent) {
|
101
|
+
public void onReceive(Context context, Intent intent) {
|
102
102
|
updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
|
103
103
|
}
|
104
104
|
};
|
@@ -117,7 +117,7 @@ public class NetworkManager extends Plugin {
|
|
117
117
|
*/
|
118
118
|
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
119
119
|
PluginResult.Status status = PluginResult.Status.INVALID_ACTION;
|
120
|
-
String result = "Unsupported Operation: " + action;
|
120
|
+
String result = "Unsupported Operation: " + action;
|
121
121
|
|
122
122
|
if (action.equals("getConnectionInfo")) {
|
123
123
|
this.connectionCallbackId = callbackId;
|
@@ -137,8 +137,7 @@ public class NetworkManager extends Plugin {
|
|
137
137
|
* @return T=returns value
|
138
138
|
*/
|
139
139
|
public boolean isSynch(String action) {
|
140
|
-
|
141
|
-
return false;
|
140
|
+
return true;
|
142
141
|
}
|
143
142
|
|
144
143
|
/**
|
@@ -182,7 +181,7 @@ public class NetworkManager extends Plugin {
|
|
182
181
|
// If we are not connected to any network set type to none
|
183
182
|
if (!info.isConnected()) {
|
184
183
|
type = TYPE_NONE;
|
185
|
-
}
|
184
|
+
}
|
186
185
|
else {
|
187
186
|
type = getType(info);
|
188
187
|
}
|
@@ -212,7 +211,7 @@ public class NetworkManager extends Plugin {
|
|
212
211
|
*/
|
213
212
|
private String getType(NetworkInfo info) {
|
214
213
|
if (info != null) {
|
215
|
-
String type = info.getTypeName();
|
214
|
+
String type = info.getTypeName();
|
216
215
|
|
217
216
|
if (type.toLowerCase().equals(WIFI)) {
|
218
217
|
return TYPE_WIFI;
|
@@ -233,7 +233,7 @@ public class Notification extends Plugin {
|
|
233
233
|
|
234
234
|
// First button
|
235
235
|
if (fButtons.length > 0) {
|
236
|
-
dlg.
|
236
|
+
dlg.setNegativeButton(fButtons[0],
|
237
237
|
new AlertDialog.OnClickListener() {
|
238
238
|
public void onClick(DialogInterface dialog, int which) {
|
239
239
|
dialog.dismiss();
|
@@ -255,7 +255,7 @@ public class Notification extends Plugin {
|
|
255
255
|
|
256
256
|
// Third button
|
257
257
|
if (fButtons.length > 2) {
|
258
|
-
dlg.
|
258
|
+
dlg.setPositiveButton(fButtons[2],
|
259
259
|
new AlertDialog.OnClickListener() {
|
260
260
|
public void onClick(DialogInterface dialog, int which) {
|
261
261
|
dialog.dismiss();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
package org.apache.cordova;
|
2
|
+
|
3
|
+
import org.apache.cordova.api.Plugin;
|
4
|
+
import org.apache.cordova.api.PluginResult;
|
5
|
+
import org.json.JSONArray;
|
6
|
+
|
7
|
+
public class SplashScreen extends Plugin {
|
8
|
+
|
9
|
+
@Override
|
10
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
11
|
+
PluginResult.Status status = PluginResult.Status.OK;
|
12
|
+
String result = "";
|
13
|
+
|
14
|
+
if (action.equals("hide")) {
|
15
|
+
((DroidGap)this.ctx).removeSplashScreen();
|
16
|
+
}
|
17
|
+
else {
|
18
|
+
status = PluginResult.Status.INVALID_ACTION;
|
19
|
+
}
|
20
|
+
return new PluginResult(status, result);
|
21
|
+
}
|
22
|
+
|
23
|
+
}
|
@@ -162,7 +162,7 @@ public class Storage extends Plugin {
|
|
162
162
|
try {
|
163
163
|
if (isDDL(query)) {
|
164
164
|
this.myDb.execSQL(query);
|
165
|
-
this.sendJavascript("require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
|
165
|
+
this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
|
166
166
|
}
|
167
167
|
else {
|
168
168
|
Cursor myCursor = this.myDb.rawQuery(query, params);
|
@@ -175,7 +175,7 @@ public class Storage extends Plugin {
|
|
175
175
|
System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
|
176
176
|
|
177
177
|
// Send error message back to JavaScript
|
178
|
-
this.sendJavascript("require('cordova/plugin/android/storage').fail('" + ex.getMessage() + "','" + tx_id + "');");
|
178
|
+
this.sendJavascript("cordova.require('cordova/plugin/android/storage').fail('" + ex.getMessage() + "','" + tx_id + "');");
|
179
179
|
}
|
180
180
|
}
|
181
181
|
|
@@ -233,7 +233,7 @@ public class Storage extends Plugin {
|
|
233
233
|
}
|
234
234
|
|
235
235
|
// Let JavaScript know that there are no more rows
|
236
|
-
this.sendJavascript("require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
|
236
|
+
this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
|
237
237
|
}
|
238
238
|
|
239
239
|
}
|
@@ -0,0 +1,119 @@
|
|
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
|
+
package org.apache.cordova.api;
|
20
|
+
|
21
|
+
import android.webkit.WebView;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* This class represents a service entry object.
|
25
|
+
*/
|
26
|
+
public class PluginEntry {
|
27
|
+
|
28
|
+
/**
|
29
|
+
* The name of the service that this plugin implements
|
30
|
+
*/
|
31
|
+
public String service = "";
|
32
|
+
|
33
|
+
/**
|
34
|
+
* The plugin class name that implements the service.
|
35
|
+
*/
|
36
|
+
public String pluginClass = "";
|
37
|
+
|
38
|
+
/**
|
39
|
+
* The plugin object.
|
40
|
+
* Plugin objects are only created when they are called from JavaScript. (see PluginManager.exec)
|
41
|
+
* The exception is if the onload flag is set, then they are created when PluginManager is initialized.
|
42
|
+
*/
|
43
|
+
public IPlugin plugin = null;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Flag that indicates the plugin object should be created when PluginManager is initialized.
|
47
|
+
*/
|
48
|
+
public boolean onload = false;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Constructor
|
52
|
+
*
|
53
|
+
* @param service The name of the service
|
54
|
+
* @param pluginClass The plugin class name
|
55
|
+
* @param onload Create plugin object when HTML page is loaded
|
56
|
+
*/
|
57
|
+
public PluginEntry(String service, String pluginClass, boolean onload) {
|
58
|
+
this.service = service;
|
59
|
+
this.pluginClass = pluginClass;
|
60
|
+
this.onload = onload;
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Create plugin object.
|
65
|
+
* If plugin is already created, then just return it.
|
66
|
+
*
|
67
|
+
* @return The plugin object
|
68
|
+
*/
|
69
|
+
@SuppressWarnings("unchecked")
|
70
|
+
public IPlugin createPlugin(WebView webView, CordovaInterface ctx) {
|
71
|
+
if (this.plugin != null) {
|
72
|
+
return this.plugin;
|
73
|
+
}
|
74
|
+
try {
|
75
|
+
Class c = getClassByName(this.pluginClass);
|
76
|
+
if (isCordovaPlugin(c)) {
|
77
|
+
this.plugin = (IPlugin) c.newInstance();
|
78
|
+
this.plugin.setContext(ctx);
|
79
|
+
this.plugin.setView(webView);
|
80
|
+
return plugin;
|
81
|
+
}
|
82
|
+
} catch (Exception e) {
|
83
|
+
e.printStackTrace();
|
84
|
+
System.out.println("Error adding plugin " + this.pluginClass + ".");
|
85
|
+
}
|
86
|
+
return null;
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Get the class.
|
91
|
+
*
|
92
|
+
* @param clazz
|
93
|
+
* @return
|
94
|
+
* @throws ClassNotFoundException
|
95
|
+
*/
|
96
|
+
@SuppressWarnings("unchecked")
|
97
|
+
private Class getClassByName(final String clazz) throws ClassNotFoundException {
|
98
|
+
Class c = null;
|
99
|
+
if (clazz != null) {
|
100
|
+
c = Class.forName(clazz);
|
101
|
+
}
|
102
|
+
return c;
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Get the interfaces that a class implements and see if it implements the
|
107
|
+
* org.apache.cordova.api.Plugin interface.
|
108
|
+
*
|
109
|
+
* @param c The class to check the interfaces of.
|
110
|
+
* @return Boolean indicating if the class implements org.apache.cordova.api.Plugin
|
111
|
+
*/
|
112
|
+
@SuppressWarnings("unchecked")
|
113
|
+
private boolean isCordovaPlugin(Class c) {
|
114
|
+
if (c != null) {
|
115
|
+
return org.apache.cordova.api.Plugin.class.isAssignableFrom(c) || org.apache.cordova.api.IPlugin.class.isAssignableFrom(c);
|
116
|
+
}
|
117
|
+
return false;
|
118
|
+
}
|
119
|
+
}
|