mobile_template 0.0.1
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
|
@@ -0,0 +1,239 @@
|
|
|
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;
|
|
20
|
+
|
|
21
|
+
import java.io.File;
|
|
22
|
+
|
|
23
|
+
import org.apache.cordova.api.Plugin;
|
|
24
|
+
import org.apache.cordova.api.PluginResult;
|
|
25
|
+
import org.json.JSONArray;
|
|
26
|
+
import org.json.JSONException;
|
|
27
|
+
import org.json.JSONObject;
|
|
28
|
+
|
|
29
|
+
import android.content.Context;
|
|
30
|
+
import android.database.Cursor;
|
|
31
|
+
import android.database.sqlite.*;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This class implements the HTML5 database support to work around a bug for
|
|
35
|
+
* Android 3.0 devices. It is not used for other versions of Android, since
|
|
36
|
+
* HTML5 database is built in to the browser.
|
|
37
|
+
*/
|
|
38
|
+
public class Storage extends Plugin {
|
|
39
|
+
|
|
40
|
+
// Data Definition Language
|
|
41
|
+
private static final String ALTER = "alter";
|
|
42
|
+
private static final String CREATE = "create";
|
|
43
|
+
private static final String DROP = "drop";
|
|
44
|
+
private static final String TRUNCATE = "truncate";
|
|
45
|
+
|
|
46
|
+
SQLiteDatabase myDb = null; // Database object
|
|
47
|
+
String path = null; // Database path
|
|
48
|
+
String dbName = null; // Database name
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Constructor.
|
|
52
|
+
*/
|
|
53
|
+
public Storage() {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Executes the request and returns PluginResult.
|
|
58
|
+
*
|
|
59
|
+
* @param action
|
|
60
|
+
* The action to execute.
|
|
61
|
+
* @param args
|
|
62
|
+
* JSONArry of arguments for the plugin.
|
|
63
|
+
* @param callbackId
|
|
64
|
+
* The callback id used when calling back into JavaScript.
|
|
65
|
+
* @return A PluginResult object with a status and message.
|
|
66
|
+
*/
|
|
67
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
|
68
|
+
PluginResult.Status status = PluginResult.Status.OK;
|
|
69
|
+
String result = "";
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
if (action.equals("openDatabase")) {
|
|
73
|
+
this.openDatabase(args.getString(0), args.getString(1),
|
|
74
|
+
args.getString(2), args.getLong(3));
|
|
75
|
+
} else if (action.equals("executeSql")) {
|
|
76
|
+
String[] s = null;
|
|
77
|
+
if (args.isNull(1)) {
|
|
78
|
+
s = new String[0];
|
|
79
|
+
} else {
|
|
80
|
+
JSONArray a = args.getJSONArray(1);
|
|
81
|
+
int len = a.length();
|
|
82
|
+
s = new String[len];
|
|
83
|
+
for (int i = 0; i < len; i++) {
|
|
84
|
+
s[i] = a.getString(i);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.executeSql(args.getString(0), s, args.getString(2));
|
|
88
|
+
}
|
|
89
|
+
return new PluginResult(status, result);
|
|
90
|
+
} catch (JSONException e) {
|
|
91
|
+
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Identifies if action to be executed returns a value and should be run
|
|
97
|
+
* synchronously.
|
|
98
|
+
*
|
|
99
|
+
* @param action
|
|
100
|
+
* The action to execute
|
|
101
|
+
* @return T=returns value
|
|
102
|
+
*/
|
|
103
|
+
public boolean isSynch(String action) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Clean up and close database.
|
|
109
|
+
*/
|
|
110
|
+
@Override
|
|
111
|
+
public void onDestroy() {
|
|
112
|
+
if (this.myDb != null) {
|
|
113
|
+
this.myDb.close();
|
|
114
|
+
this.myDb = null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// --------------------------------------------------------------------------
|
|
119
|
+
// LOCAL METHODS
|
|
120
|
+
// --------------------------------------------------------------------------
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Open database.
|
|
124
|
+
*
|
|
125
|
+
* @param db
|
|
126
|
+
* The name of the database
|
|
127
|
+
* @param version
|
|
128
|
+
* The version
|
|
129
|
+
* @param display_name
|
|
130
|
+
* The display name
|
|
131
|
+
* @param size
|
|
132
|
+
* The size in bytes
|
|
133
|
+
*/
|
|
134
|
+
public void openDatabase(String db, String version, String display_name,
|
|
135
|
+
long size) {
|
|
136
|
+
|
|
137
|
+
// If database is open, then close it
|
|
138
|
+
if (this.myDb != null) {
|
|
139
|
+
this.myDb.close();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// If no database path, generate from application package
|
|
143
|
+
if (this.path == null) {
|
|
144
|
+
this.path = this.ctx.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.dbName = this.path + File.pathSeparator + db + ".db";
|
|
148
|
+
this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Execute SQL statement.
|
|
153
|
+
*
|
|
154
|
+
* @param query
|
|
155
|
+
* The SQL query
|
|
156
|
+
* @param params
|
|
157
|
+
* Parameters for the query
|
|
158
|
+
* @param tx_id
|
|
159
|
+
* Transaction id
|
|
160
|
+
*/
|
|
161
|
+
public void executeSql(String query, String[] params, String tx_id) {
|
|
162
|
+
try {
|
|
163
|
+
if (isDDL(query)) {
|
|
164
|
+
this.myDb.execSQL(query);
|
|
165
|
+
this.sendJavascript("require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
Cursor myCursor = this.myDb.rawQuery(query, params);
|
|
169
|
+
this.processResults(myCursor, tx_id);
|
|
170
|
+
myCursor.close();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (SQLiteException ex) {
|
|
174
|
+
ex.printStackTrace();
|
|
175
|
+
System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
|
|
176
|
+
|
|
177
|
+
// Send error message back to JavaScript
|
|
178
|
+
this.sendJavascript("require('cordova/plugin/android/storage').fail('" + ex.getMessage() + "','" + tx_id + "');");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Checks to see the the query is a Data Definintion command
|
|
184
|
+
*
|
|
185
|
+
* @param query to be executed
|
|
186
|
+
* @return true if it is a DDL command, false otherwise
|
|
187
|
+
*/
|
|
188
|
+
private boolean isDDL(String query) {
|
|
189
|
+
String cmd = query.toLowerCase();
|
|
190
|
+
if (cmd.startsWith(DROP) || cmd.startsWith(CREATE) || cmd.startsWith(ALTER) || cmd.startsWith(TRUNCATE)) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Process query results.
|
|
198
|
+
*
|
|
199
|
+
* @param cur
|
|
200
|
+
* Cursor into query results
|
|
201
|
+
* @param tx_id
|
|
202
|
+
* Transaction id
|
|
203
|
+
*/
|
|
204
|
+
public void processResults(Cursor cur, String tx_id) {
|
|
205
|
+
|
|
206
|
+
String result = "[]";
|
|
207
|
+
// If query result has rows
|
|
208
|
+
|
|
209
|
+
if (cur.moveToFirst()) {
|
|
210
|
+
JSONArray fullresult = new JSONArray();
|
|
211
|
+
String key = "";
|
|
212
|
+
String value = "";
|
|
213
|
+
int colCount = cur.getColumnCount();
|
|
214
|
+
|
|
215
|
+
// Build up JSON result object for each row
|
|
216
|
+
do {
|
|
217
|
+
JSONObject row = new JSONObject();
|
|
218
|
+
try {
|
|
219
|
+
for (int i = 0; i < colCount; ++i) {
|
|
220
|
+
key = cur.getColumnName(i);
|
|
221
|
+
value = cur.getString(i);
|
|
222
|
+
row.put(key, value);
|
|
223
|
+
}
|
|
224
|
+
fullresult.put(row);
|
|
225
|
+
|
|
226
|
+
} catch (JSONException e) {
|
|
227
|
+
e.printStackTrace();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
} while (cur.moveToNext());
|
|
231
|
+
|
|
232
|
+
result = fullresult.toString();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Let JavaScript know that there are no more rows
|
|
236
|
+
this.sendJavascript("require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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;
|
|
20
|
+
|
|
21
|
+
import java.util.List;
|
|
22
|
+
|
|
23
|
+
import org.apache.cordova.api.CordovaInterface;
|
|
24
|
+
import org.apache.cordova.api.Plugin;
|
|
25
|
+
import org.apache.cordova.api.PluginResult;
|
|
26
|
+
import org.json.JSONArray;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
import android.hardware.Sensor;
|
|
30
|
+
import android.hardware.SensorEvent;
|
|
31
|
+
import android.hardware.SensorEventListener;
|
|
32
|
+
import android.hardware.SensorManager;
|
|
33
|
+
import android.content.Context;
|
|
34
|
+
|
|
35
|
+
public class TempListener extends Plugin implements SensorEventListener {
|
|
36
|
+
|
|
37
|
+
Sensor mSensor;
|
|
38
|
+
private SensorManager sensorManager;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Constructor.
|
|
42
|
+
*/
|
|
43
|
+
public TempListener() {
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sets the context of the Command. This can then be used to do things like
|
|
48
|
+
* get file paths associated with the Activity.
|
|
49
|
+
*
|
|
50
|
+
* @param ctx The context of the main Activity.
|
|
51
|
+
*/
|
|
52
|
+
public void setContext(CordovaInterface ctx) {
|
|
53
|
+
super.setContext(ctx);
|
|
54
|
+
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Executes the request and returns PluginResult.
|
|
59
|
+
*
|
|
60
|
+
* @param action The action to execute.
|
|
61
|
+
* @param args JSONArry of arguments for the plugin.
|
|
62
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
|
63
|
+
* @return A PluginResult object with a status and message.
|
|
64
|
+
*/
|
|
65
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
|
66
|
+
PluginResult.Status status = PluginResult.Status.OK;
|
|
67
|
+
String result = "";
|
|
68
|
+
|
|
69
|
+
if (action.equals("start")) {
|
|
70
|
+
this.start();
|
|
71
|
+
}
|
|
72
|
+
else if (action.equals("stop")) {
|
|
73
|
+
this.stop();
|
|
74
|
+
}
|
|
75
|
+
return new PluginResult(status, result);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Called by AccelBroker when listener is to be shut down.
|
|
80
|
+
* Stop listener.
|
|
81
|
+
*/
|
|
82
|
+
public void onDestroy() {
|
|
83
|
+
this.stop();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//--------------------------------------------------------------------------
|
|
87
|
+
// LOCAL METHODS
|
|
88
|
+
//--------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
public void start() {
|
|
91
|
+
List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_TEMPERATURE);
|
|
92
|
+
if (list.size() > 0) {
|
|
93
|
+
this.mSensor = list.get(0);
|
|
94
|
+
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public void stop() {
|
|
99
|
+
this.sensorManager.unregisterListener(this);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
103
|
+
// TODO Auto-generated method stub
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public void onSensorChanged(SensorEvent event) {
|
|
107
|
+
// We want to know what temp this is.
|
|
108
|
+
float temp = event.values[0];
|
|
109
|
+
this.sendJavascript("gotTemp(" + temp + ");");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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 java.util.HashMap;
|
|
22
|
+
|
|
23
|
+
import android.app.Activity;
|
|
24
|
+
import android.app.Service;
|
|
25
|
+
import android.content.BroadcastReceiver;
|
|
26
|
+
import android.content.ContentResolver;
|
|
27
|
+
import android.content.Context;
|
|
28
|
+
import android.content.Intent;
|
|
29
|
+
import android.content.IntentFilter;
|
|
30
|
+
import android.content.res.AssetManager;
|
|
31
|
+
import android.content.res.Resources;
|
|
32
|
+
import android.database.Cursor;
|
|
33
|
+
import android.hardware.SensorManager;
|
|
34
|
+
import android.net.Uri;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The Cordova activity abstract class that is extended by DroidGap.
|
|
39
|
+
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
|
|
40
|
+
*/
|
|
41
|
+
public interface CordovaInterface {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated
|
|
45
|
+
* Add services to res/xml/plugins.xml instead.
|
|
46
|
+
*
|
|
47
|
+
* Add a class that implements a service.
|
|
48
|
+
*
|
|
49
|
+
* @param serviceType
|
|
50
|
+
* @param className
|
|
51
|
+
*/
|
|
52
|
+
@Deprecated
|
|
53
|
+
abstract public void addService(String serviceType, String className);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Send JavaScript statement back to JavaScript.
|
|
57
|
+
*
|
|
58
|
+
* @param message
|
|
59
|
+
*/
|
|
60
|
+
abstract public void sendJavascript(String statement);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Launch an activity for which you would like a result when it finished. When this activity exits,
|
|
64
|
+
* your onActivityResult() method will be called.
|
|
65
|
+
*
|
|
66
|
+
* @param command The command object
|
|
67
|
+
* @param intent The intent to start
|
|
68
|
+
* @param requestCode The request code that is passed to callback to identify the activity
|
|
69
|
+
*/
|
|
70
|
+
abstract public void startActivityForResult(IPlugin command, Intent intent, int requestCode);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Launch an activity for which you would not like a result when it finished.
|
|
74
|
+
*
|
|
75
|
+
* @param intent The intent to start
|
|
76
|
+
*/
|
|
77
|
+
abstract public void startActivity(Intent intent);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Set the plugin to be called when a sub-activity exits.
|
|
81
|
+
*
|
|
82
|
+
* @param plugin The plugin on which onActivityResult is to be called
|
|
83
|
+
*/
|
|
84
|
+
abstract public void setActivityResultCallback(IPlugin plugin);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Load the specified URL in the Cordova webview.
|
|
88
|
+
*
|
|
89
|
+
* @param url The URL to load.
|
|
90
|
+
*/
|
|
91
|
+
abstract public void loadUrl(String url);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Send a message to all plugins.
|
|
95
|
+
*
|
|
96
|
+
* @param id The message id
|
|
97
|
+
* @param data The message data
|
|
98
|
+
*/
|
|
99
|
+
abstract public void postMessage(String id, Object data);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
public abstract Resources getResources();
|
|
103
|
+
|
|
104
|
+
public abstract String getPackageName();
|
|
105
|
+
|
|
106
|
+
public abstract Object getSystemService(String service);
|
|
107
|
+
|
|
108
|
+
public abstract Context getContext();
|
|
109
|
+
|
|
110
|
+
public abstract Context getBaseContext();
|
|
111
|
+
|
|
112
|
+
public abstract Intent registerReceiver(BroadcastReceiver receiver,
|
|
113
|
+
IntentFilter intentFilter);
|
|
114
|
+
|
|
115
|
+
public abstract ContentResolver getContentResolver();
|
|
116
|
+
|
|
117
|
+
public abstract void unregisterReceiver(BroadcastReceiver receiver);
|
|
118
|
+
|
|
119
|
+
public abstract Cursor managedQuery(Uri uri, String[] projection, String selection,
|
|
120
|
+
String[] selectionArgs, String sortOrder);
|
|
121
|
+
|
|
122
|
+
public abstract void runOnUiThread(Runnable runnable);
|
|
123
|
+
|
|
124
|
+
public abstract AssetManager getAssets();
|
|
125
|
+
|
|
126
|
+
public abstract void clearCache();
|
|
127
|
+
|
|
128
|
+
public abstract void clearHistory();
|
|
129
|
+
|
|
130
|
+
public abstract boolean backHistory();
|
|
131
|
+
|
|
132
|
+
//public abstract void addWhiteListEntry(String origin, boolean subdomains);
|
|
133
|
+
|
|
134
|
+
public abstract void bindBackButton(boolean override);
|
|
135
|
+
|
|
136
|
+
public abstract boolean isBackButtonBound();
|
|
137
|
+
|
|
138
|
+
public abstract void cancelLoadUrl();
|
|
139
|
+
|
|
140
|
+
public abstract void showWebPage(String url, boolean openExternal,
|
|
141
|
+
boolean clearHistory, HashMap<String, Object> params);
|
|
142
|
+
|
|
143
|
+
public abstract Context getApplicationContext();
|
|
144
|
+
|
|
145
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 org.json.JSONArray;
|
|
22
|
+
import android.content.Intent;
|
|
23
|
+
import android.webkit.WebView;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Plugin interface must be implemented by any plugin classes.
|
|
27
|
+
*
|
|
28
|
+
* The execute method is called by the PluginManager.
|
|
29
|
+
*/
|
|
30
|
+
public interface IPlugin {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Executes the request and returns PluginResult.
|
|
34
|
+
*
|
|
35
|
+
* @param action The action to execute.
|
|
36
|
+
* @param args JSONArry of arguments for the plugin.
|
|
37
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
|
38
|
+
* @return A PluginResult object with a status and message.
|
|
39
|
+
*/
|
|
40
|
+
PluginResult execute(String action, JSONArray args, String callbackId);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Identifies if action to be executed returns a value and should be run synchronously.
|
|
44
|
+
*
|
|
45
|
+
* @param action The action to execute
|
|
46
|
+
* @return T=returns value
|
|
47
|
+
*/
|
|
48
|
+
public boolean isSynch(String action);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Sets the context of the Plugin. This can then be used to do things like
|
|
52
|
+
* get file paths associated with the Activity.
|
|
53
|
+
*
|
|
54
|
+
* @param ctx The context of the main Activity.
|
|
55
|
+
*/
|
|
56
|
+
void setContext(CordovaInterface ctx);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sets the main View of the application, this is the WebView within which
|
|
60
|
+
* a Cordova app runs.
|
|
61
|
+
*
|
|
62
|
+
* @param webView The Cordova WebView
|
|
63
|
+
*/
|
|
64
|
+
void setView(WebView webView);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Called when the system is about to start resuming a previous activity.
|
|
68
|
+
*
|
|
69
|
+
* @param multitasking Flag indicating if multitasking is turned on for app
|
|
70
|
+
*/
|
|
71
|
+
void onPause(boolean multitasking);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Called when the activity will start interacting with the user.
|
|
75
|
+
*
|
|
76
|
+
* @param multitasking Flag indicating if multitasking is turned on for app
|
|
77
|
+
*/
|
|
78
|
+
void onResume(boolean multitasking);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Called when the activity receives a new intent.
|
|
82
|
+
*/
|
|
83
|
+
void onNewIntent(Intent intent);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The final call you receive before your activity is destroyed.
|
|
87
|
+
*/
|
|
88
|
+
void onDestroy();
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Called when a message is sent to plugin.
|
|
92
|
+
*
|
|
93
|
+
* @param id The message id
|
|
94
|
+
* @param data The message data
|
|
95
|
+
*/
|
|
96
|
+
public void onMessage(String id, Object data);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Called when an activity you launched exits, giving you the requestCode you started it with,
|
|
100
|
+
* the resultCode it returned, and any additional data from it.
|
|
101
|
+
*
|
|
102
|
+
* @param requestCode The request code originally supplied to startActivityForResult(),
|
|
103
|
+
* allowing you to identify who this result came from.
|
|
104
|
+
* @param resultCode The integer result code returned by the child activity through its setResult().
|
|
105
|
+
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
|
|
106
|
+
*/
|
|
107
|
+
void onActivityResult(int requestCode, int resultCode, Intent intent);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
|
|
111
|
+
*
|
|
112
|
+
* @param url The URL that is trying to be loaded in the Cordova webview.
|
|
113
|
+
* @return Return true to prevent the URL from loading. Default is false.
|
|
114
|
+
*/
|
|
115
|
+
boolean onOverrideUrlLoading(String url);
|
|
116
|
+
}
|