mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,234 @@
|
|
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.util.Log;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Log to Android logging system.
|
25
|
+
*
|
26
|
+
* Log message can be a string or a printf formatted string with arguments.
|
27
|
+
* See http://developer.android.com/reference/java/util/Formatter.html
|
28
|
+
*/
|
29
|
+
public class LOG {
|
30
|
+
|
31
|
+
public static final int VERBOSE = Log.VERBOSE;
|
32
|
+
public static final int DEBUG = Log.DEBUG;
|
33
|
+
public static final int INFO = Log.INFO;
|
34
|
+
public static final int WARN = Log.WARN;
|
35
|
+
public static final int ERROR = Log.ERROR;
|
36
|
+
|
37
|
+
// Current log level
|
38
|
+
public static int LOGLEVEL = Log.ERROR;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Set the current log level.
|
42
|
+
*
|
43
|
+
* @param logLevel
|
44
|
+
*/
|
45
|
+
public static void setLogLevel(int logLevel) {
|
46
|
+
LOGLEVEL = logLevel;
|
47
|
+
Log.i("CordovaLog", "Changing log level to " + logLevel);
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Set the current log level.
|
52
|
+
*
|
53
|
+
* @param logLevel
|
54
|
+
*/
|
55
|
+
public static void setLogLevel(String logLevel) {
|
56
|
+
if ("VERBOSE".equals(logLevel)) LOGLEVEL = VERBOSE;
|
57
|
+
else if ("DEBUG".equals(logLevel)) LOGLEVEL = DEBUG;
|
58
|
+
else if ("INFO".equals(logLevel)) LOGLEVEL = INFO;
|
59
|
+
else if ("WARN".equals(logLevel)) LOGLEVEL = WARN;
|
60
|
+
else if ("ERROR".equals(logLevel)) LOGLEVEL = ERROR;
|
61
|
+
Log.i("CordovaLog", "Changing log level to " + logLevel + "(" + LOGLEVEL + ")");
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Determine if log level will be logged
|
66
|
+
*
|
67
|
+
* @param logLevel
|
68
|
+
* @return
|
69
|
+
*/
|
70
|
+
public static boolean isLoggable(int logLevel) {
|
71
|
+
return (logLevel >= LOGLEVEL);
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Verbose log message.
|
76
|
+
*
|
77
|
+
* @param tag
|
78
|
+
* @param s
|
79
|
+
*/
|
80
|
+
public static void v(String tag, String s) {
|
81
|
+
if (LOG.VERBOSE >= LOGLEVEL) Log.v(tag, s);
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Debug log message.
|
86
|
+
*
|
87
|
+
* @param tag
|
88
|
+
* @param s
|
89
|
+
*/
|
90
|
+
public static void d(String tag, String s) {
|
91
|
+
if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, s);
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Info log message.
|
96
|
+
*
|
97
|
+
* @param tag
|
98
|
+
* @param s
|
99
|
+
*/
|
100
|
+
public static void i(String tag, String s) {
|
101
|
+
if (LOG.INFO >= LOGLEVEL) Log.i(tag, s);
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Warning log message.
|
106
|
+
*
|
107
|
+
* @param tag
|
108
|
+
* @param s
|
109
|
+
*/
|
110
|
+
public static void w(String tag, String s) {
|
111
|
+
if (LOG.WARN >= LOGLEVEL) Log.w(tag, s);
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Error log message.
|
116
|
+
*
|
117
|
+
* @param tag
|
118
|
+
* @param s
|
119
|
+
*/
|
120
|
+
public static void e(String tag, String s) {
|
121
|
+
if (LOG.ERROR >= LOGLEVEL) Log.e(tag, s);
|
122
|
+
}
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Verbose log message.
|
126
|
+
*
|
127
|
+
* @param tag
|
128
|
+
* @param s
|
129
|
+
* @param e
|
130
|
+
*/
|
131
|
+
public static void v(String tag, String s, Throwable e) {
|
132
|
+
if (LOG.VERBOSE >= LOGLEVEL) Log.v(tag, s, e);
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Debug log message.
|
137
|
+
*
|
138
|
+
* @param tag
|
139
|
+
* @param s
|
140
|
+
* @param e
|
141
|
+
*/
|
142
|
+
public static void d(String tag, String s, Throwable e) {
|
143
|
+
if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, s, e);
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Info log message.
|
148
|
+
*
|
149
|
+
* @param tag
|
150
|
+
* @param s
|
151
|
+
* @param e
|
152
|
+
*/
|
153
|
+
public static void i(String tag, String s, Throwable e) {
|
154
|
+
if (LOG.INFO >= LOGLEVEL) Log.i(tag, s, e);
|
155
|
+
}
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Warning log message.
|
159
|
+
*
|
160
|
+
* @param tag
|
161
|
+
* @param s
|
162
|
+
* @param e
|
163
|
+
*/
|
164
|
+
public static void w(String tag, String s, Throwable e) {
|
165
|
+
if (LOG.WARN >= LOGLEVEL) Log.w(tag, s, e);
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Error log message.
|
170
|
+
*
|
171
|
+
* @param tag
|
172
|
+
* @param s
|
173
|
+
* @param e
|
174
|
+
*/
|
175
|
+
public static void e(String tag, String s, Throwable e) {
|
176
|
+
if (LOG.ERROR >= LOGLEVEL) Log.e(tag, s, e);
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Verbose log message with printf formatting.
|
181
|
+
*
|
182
|
+
* @param tag
|
183
|
+
* @param s
|
184
|
+
* @param args
|
185
|
+
*/
|
186
|
+
public static void v(String tag, String s, Object... args) {
|
187
|
+
if (LOG.VERBOSE >= LOGLEVEL) Log.v(tag, String.format(s, args));
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Debug log message with printf formatting.
|
192
|
+
*
|
193
|
+
* @param tag
|
194
|
+
* @param s
|
195
|
+
* @param args
|
196
|
+
*/
|
197
|
+
public static void d(String tag, String s, Object... args) {
|
198
|
+
if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, String.format(s, args));
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Info log message with printf formatting.
|
203
|
+
*
|
204
|
+
* @param tag
|
205
|
+
* @param s
|
206
|
+
* @param args
|
207
|
+
*/
|
208
|
+
public static void i(String tag, String s, Object... args) {
|
209
|
+
if (LOG.INFO >= LOGLEVEL) Log.i(tag, String.format(s, args));
|
210
|
+
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Warning log message with printf formatting.
|
214
|
+
*
|
215
|
+
* @param tag
|
216
|
+
* @param s
|
217
|
+
* @param args
|
218
|
+
*/
|
219
|
+
public static void w(String tag, String s, Object... args) {
|
220
|
+
if (LOG.WARN >= LOGLEVEL) Log.w(tag, String.format(s, args));
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Error log message with printf formatting.
|
225
|
+
*
|
226
|
+
* @param tag
|
227
|
+
* @param s
|
228
|
+
* @param args
|
229
|
+
*/
|
230
|
+
public static void e(String tag, String s, Object... args) {
|
231
|
+
if (LOG.ERROR >= LOGLEVEL) Log.e(tag, String.format(s, args));
|
232
|
+
}
|
233
|
+
|
234
|
+
}
|
@@ -0,0 +1,210 @@
|
|
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 org.json.JSONObject;
|
23
|
+
|
24
|
+
import android.content.Intent;
|
25
|
+
import android.webkit.WebView;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Plugin interface must be implemented by any plugin classes.
|
29
|
+
*
|
30
|
+
* The execute method is called by the PluginManager.
|
31
|
+
*/
|
32
|
+
public abstract class Plugin implements IPlugin {
|
33
|
+
|
34
|
+
public String id;
|
35
|
+
public WebView webView; // WebView object
|
36
|
+
public CordovaInterface ctx; // CordovaActivity object
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Executes the request and returns PluginResult.
|
40
|
+
*
|
41
|
+
* @param action The action to execute.
|
42
|
+
* @param args JSONArry of arguments for the plugin.
|
43
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
44
|
+
* @return A PluginResult object with a status and message.
|
45
|
+
*/
|
46
|
+
public abstract PluginResult execute(String action, JSONArray args, String callbackId);
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Identifies if action to be executed returns a value and should be run synchronously.
|
50
|
+
*
|
51
|
+
* @param action The action to execute
|
52
|
+
* @return T=returns value
|
53
|
+
*/
|
54
|
+
public boolean isSynch(String action) {
|
55
|
+
return false;
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Sets the context of the Plugin. This can then be used to do things like
|
60
|
+
* get file paths associated with the Activity.
|
61
|
+
*
|
62
|
+
* @param ctx The context of the main Activity.
|
63
|
+
*/
|
64
|
+
public void setContext(CordovaInterface ctx) {
|
65
|
+
this.ctx = ctx;
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Sets the main View of the application, this is the WebView within which
|
70
|
+
* a Cordova app runs.
|
71
|
+
*
|
72
|
+
* @param webView The Cordova WebView
|
73
|
+
*/
|
74
|
+
public void setView(WebView webView) {
|
75
|
+
this.webView = webView;
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Called when the system is about to start resuming a previous activity.
|
80
|
+
*
|
81
|
+
* @param multitasking Flag indicating if multitasking is turned on for app
|
82
|
+
*/
|
83
|
+
public void onPause(boolean multitasking) {
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Called when the activity will start interacting with the user.
|
88
|
+
*
|
89
|
+
* @param multitasking Flag indicating if multitasking is turned on for app
|
90
|
+
*/
|
91
|
+
public void onResume(boolean multitasking) {
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Called when the activity receives a new intent.
|
96
|
+
*/
|
97
|
+
public void onNewIntent(Intent intent) {
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* The final call you receive before your activity is destroyed.
|
102
|
+
*/
|
103
|
+
public void onDestroy() {
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Called when a message is sent to plugin.
|
108
|
+
*
|
109
|
+
* @param id The message id
|
110
|
+
* @param data The message data
|
111
|
+
*/
|
112
|
+
public void onMessage(String id, Object data) {
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Called when an activity you launched exits, giving you the requestCode you started it with,
|
117
|
+
* the resultCode it returned, and any additional data from it.
|
118
|
+
*
|
119
|
+
* @param requestCode The request code originally supplied to startActivityForResult(),
|
120
|
+
* allowing you to identify who this result came from.
|
121
|
+
* @param resultCode The integer result code returned by the child activity through its setResult().
|
122
|
+
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
|
123
|
+
*/
|
124
|
+
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
|
129
|
+
*
|
130
|
+
* @param url The URL that is trying to be loaded in the Cordova webview.
|
131
|
+
* @return Return true to prevent the URL from loading. Default is false.
|
132
|
+
*/
|
133
|
+
public boolean onOverrideUrlLoading(String url) {
|
134
|
+
return false;
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Send generic JavaScript statement back to JavaScript.
|
139
|
+
* success(...) and error(...) should be used instead where possible.
|
140
|
+
*
|
141
|
+
* @param statement
|
142
|
+
*/
|
143
|
+
public void sendJavascript(String statement) {
|
144
|
+
this.ctx.sendJavascript(statement);
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Call the JavaScript success callback for this plugin.
|
149
|
+
*
|
150
|
+
* This can be used if the execute code for the plugin is asynchronous meaning
|
151
|
+
* that execute should return null and the callback from the async operation can
|
152
|
+
* call success(...) or error(...)
|
153
|
+
*
|
154
|
+
* @param pluginResult The result to return.
|
155
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
156
|
+
*/
|
157
|
+
public void success(PluginResult pluginResult, String callbackId) {
|
158
|
+
this.ctx.sendJavascript(pluginResult.toSuccessCallbackString(callbackId));
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Helper for success callbacks that just returns the Status.OK by default
|
163
|
+
*
|
164
|
+
* @param message The message to add to the success result.
|
165
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
166
|
+
*/
|
167
|
+
public void success(JSONObject message, String callbackId) {
|
168
|
+
this.ctx.sendJavascript(new PluginResult(PluginResult.Status.OK, message).toSuccessCallbackString(callbackId));
|
169
|
+
}
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Helper for success callbacks that just returns the Status.OK by default
|
173
|
+
*
|
174
|
+
* @param message The message to add to the success result.
|
175
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
176
|
+
*/
|
177
|
+
public void success(String message, String callbackId) {
|
178
|
+
this.ctx.sendJavascript(new PluginResult(PluginResult.Status.OK, message).toSuccessCallbackString(callbackId));
|
179
|
+
}
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Call the JavaScript error callback for this plugin.
|
183
|
+
*
|
184
|
+
* @param pluginResult The result to return.
|
185
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
186
|
+
*/
|
187
|
+
public void error(PluginResult pluginResult, String callbackId) {
|
188
|
+
this.ctx.sendJavascript(pluginResult.toErrorCallbackString(callbackId));
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Helper for error callbacks that just returns the Status.ERROR by default
|
193
|
+
*
|
194
|
+
* @param message The message to add to the error result.
|
195
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
196
|
+
*/
|
197
|
+
public void error(JSONObject message, String callbackId) {
|
198
|
+
this.ctx.sendJavascript(new PluginResult(PluginResult.Status.ERROR, message).toErrorCallbackString(callbackId));
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Helper for error callbacks that just returns the Status.ERROR by default
|
203
|
+
*
|
204
|
+
* @param message The message to add to the error result.
|
205
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
206
|
+
*/
|
207
|
+
public void error(String message, String callbackId) {
|
208
|
+
this.ctx.sendJavascript(new PluginResult(PluginResult.Status.ERROR, message).toErrorCallbackString(callbackId));
|
209
|
+
}
|
210
|
+
}
|