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,366 @@
|
|
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 org.apache.cordova.api.CordovaInterface;
|
22
|
+
import org.apache.cordova.api.Plugin;
|
23
|
+
import org.apache.cordova.api.PluginResult;
|
24
|
+
import org.json.JSONArray;
|
25
|
+
import org.json.JSONException;
|
26
|
+
import android.app.AlertDialog;
|
27
|
+
import android.app.ProgressDialog;
|
28
|
+
import android.content.Context;
|
29
|
+
import android.content.DialogInterface;
|
30
|
+
import android.media.Ringtone;
|
31
|
+
import android.media.RingtoneManager;
|
32
|
+
import android.net.Uri;
|
33
|
+
import android.os.Vibrator;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* This class provides access to notifications on the device.
|
37
|
+
*/
|
38
|
+
public class Notification extends Plugin {
|
39
|
+
|
40
|
+
public int confirmResult = -1;
|
41
|
+
public ProgressDialog spinnerDialog = null;
|
42
|
+
public ProgressDialog progressDialog = null;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Constructor.
|
46
|
+
*/
|
47
|
+
public Notification() {
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Executes the request and returns PluginResult.
|
52
|
+
*
|
53
|
+
* @param action The action to execute.
|
54
|
+
* @param args JSONArry of arguments for the plugin.
|
55
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
56
|
+
* @return A PluginResult object with a status and message.
|
57
|
+
*/
|
58
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
59
|
+
PluginResult.Status status = PluginResult.Status.OK;
|
60
|
+
String result = "";
|
61
|
+
|
62
|
+
try {
|
63
|
+
if (action.equals("beep")) {
|
64
|
+
this.beep(args.getLong(0));
|
65
|
+
}
|
66
|
+
else if (action.equals("vibrate")) {
|
67
|
+
this.vibrate(args.getLong(0));
|
68
|
+
}
|
69
|
+
else if (action.equals("alert")) {
|
70
|
+
this.alert(args.getString(0),args.getString(1),args.getString(2), callbackId);
|
71
|
+
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
|
72
|
+
r.setKeepCallback(true);
|
73
|
+
return r;
|
74
|
+
}
|
75
|
+
else if (action.equals("confirm")) {
|
76
|
+
this.confirm(args.getString(0),args.getString(1),args.getString(2), callbackId);
|
77
|
+
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
|
78
|
+
r.setKeepCallback(true);
|
79
|
+
return r;
|
80
|
+
}
|
81
|
+
else if (action.equals("activityStart")) {
|
82
|
+
this.activityStart(args.getString(0),args.getString(1));
|
83
|
+
}
|
84
|
+
else if (action.equals("activityStop")) {
|
85
|
+
this.activityStop();
|
86
|
+
}
|
87
|
+
else if (action.equals("progressStart")) {
|
88
|
+
this.progressStart(args.getString(0),args.getString(1));
|
89
|
+
}
|
90
|
+
else if (action.equals("progressValue")) {
|
91
|
+
this.progressValue(args.getInt(0));
|
92
|
+
}
|
93
|
+
else if (action.equals("progressStop")) {
|
94
|
+
this.progressStop();
|
95
|
+
}
|
96
|
+
return new PluginResult(status, result);
|
97
|
+
} catch (JSONException e) {
|
98
|
+
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Identifies if action to be executed returns a value and should be run synchronously.
|
104
|
+
*
|
105
|
+
* @param action The action to execute
|
106
|
+
* @return T=returns value
|
107
|
+
*/
|
108
|
+
public boolean isSynch(String action) {
|
109
|
+
if (action.equals("alert")) {
|
110
|
+
return true;
|
111
|
+
}
|
112
|
+
else if (action.equals("confirm")) {
|
113
|
+
return true;
|
114
|
+
}
|
115
|
+
else if (action.equals("activityStart")) {
|
116
|
+
return true;
|
117
|
+
}
|
118
|
+
else if (action.equals("activityStop")) {
|
119
|
+
return true;
|
120
|
+
}
|
121
|
+
else if (action.equals("progressStart")) {
|
122
|
+
return true;
|
123
|
+
}
|
124
|
+
else if (action.equals("progressValue")) {
|
125
|
+
return true;
|
126
|
+
}
|
127
|
+
else if (action.equals("progressStop")) {
|
128
|
+
return true;
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
//--------------------------------------------------------------------------
|
136
|
+
// LOCAL METHODS
|
137
|
+
//--------------------------------------------------------------------------
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Beep plays the default notification ringtone.
|
141
|
+
*
|
142
|
+
* @param count Number of times to play notification
|
143
|
+
*/
|
144
|
+
public void beep(long count) {
|
145
|
+
Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
146
|
+
Ringtone notification = RingtoneManager.getRingtone(this.ctx.getContext(), ringtone);
|
147
|
+
|
148
|
+
// If phone is not set to silent mode
|
149
|
+
if (notification != null) {
|
150
|
+
for (long i = 0; i < count; ++i) {
|
151
|
+
notification.play();
|
152
|
+
long timeout = 5000;
|
153
|
+
while (notification.isPlaying() && (timeout > 0)) {
|
154
|
+
timeout = timeout - 100;
|
155
|
+
try {
|
156
|
+
Thread.sleep(100);
|
157
|
+
} catch (InterruptedException e) {
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Vibrates the device for the specified amount of time.
|
166
|
+
*
|
167
|
+
* @param time Time to vibrate in ms.
|
168
|
+
*/
|
169
|
+
public void vibrate(long time){
|
170
|
+
// Start the vibration, 0 defaults to half a second.
|
171
|
+
if (time == 0) {
|
172
|
+
time = 500;
|
173
|
+
}
|
174
|
+
Vibrator vibrator = (Vibrator) this.ctx.getSystemService(Context.VIBRATOR_SERVICE);
|
175
|
+
vibrator.vibrate(time);
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Builds and shows a native Android alert with given Strings
|
180
|
+
* @param message The message the alert should display
|
181
|
+
* @param title The title of the alert
|
182
|
+
* @param buttonLabel The label of the button
|
183
|
+
* @param callbackId The callback id
|
184
|
+
*/
|
185
|
+
public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
|
186
|
+
|
187
|
+
final CordovaInterface ctx = this.ctx;
|
188
|
+
final Notification notification = this;
|
189
|
+
|
190
|
+
Runnable runnable = new Runnable() {
|
191
|
+
public void run() {
|
192
|
+
|
193
|
+
AlertDialog.Builder dlg = new AlertDialog.Builder(ctx.getContext());
|
194
|
+
dlg.setMessage(message);
|
195
|
+
dlg.setTitle(title);
|
196
|
+
dlg.setCancelable(false);
|
197
|
+
dlg.setPositiveButton(buttonLabel,
|
198
|
+
new AlertDialog.OnClickListener() {
|
199
|
+
public void onClick(DialogInterface dialog, int which) {
|
200
|
+
dialog.dismiss();
|
201
|
+
notification.success(new PluginResult(PluginResult.Status.OK, 0), callbackId);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
dlg.create();
|
205
|
+
dlg.show();
|
206
|
+
};
|
207
|
+
};
|
208
|
+
this.ctx.runOnUiThread(runnable);
|
209
|
+
}
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Builds and shows a native Android confirm dialog with given title, message, buttons.
|
213
|
+
* This dialog only shows up to 3 buttons. Any labels after that will be ignored.
|
214
|
+
* The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
|
215
|
+
*
|
216
|
+
* @param message The message the dialog should display
|
217
|
+
* @param title The title of the dialog
|
218
|
+
* @param buttonLabels A comma separated list of button labels (Up to 3 buttons)
|
219
|
+
* @param callbackId The callback id
|
220
|
+
*/
|
221
|
+
public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
|
222
|
+
|
223
|
+
final CordovaInterface ctx = this.ctx;
|
224
|
+
final Notification notification = this;
|
225
|
+
final String[] fButtons = buttonLabels.split(",");
|
226
|
+
|
227
|
+
Runnable runnable = new Runnable() {
|
228
|
+
public void run() {
|
229
|
+
AlertDialog.Builder dlg = new AlertDialog.Builder(ctx.getContext());
|
230
|
+
dlg.setMessage(message);
|
231
|
+
dlg.setTitle(title);
|
232
|
+
dlg.setCancelable(false);
|
233
|
+
|
234
|
+
// First button
|
235
|
+
if (fButtons.length > 0) {
|
236
|
+
dlg.setPositiveButton(fButtons[0],
|
237
|
+
new AlertDialog.OnClickListener() {
|
238
|
+
public void onClick(DialogInterface dialog, int which) {
|
239
|
+
dialog.dismiss();
|
240
|
+
notification.success(new PluginResult(PluginResult.Status.OK, 1), callbackId);
|
241
|
+
}
|
242
|
+
});
|
243
|
+
}
|
244
|
+
|
245
|
+
// Second button
|
246
|
+
if (fButtons.length > 1) {
|
247
|
+
dlg.setNeutralButton(fButtons[1],
|
248
|
+
new AlertDialog.OnClickListener() {
|
249
|
+
public void onClick(DialogInterface dialog, int which) {
|
250
|
+
dialog.dismiss();
|
251
|
+
notification.success(new PluginResult(PluginResult.Status.OK, 2), callbackId);
|
252
|
+
}
|
253
|
+
});
|
254
|
+
}
|
255
|
+
|
256
|
+
// Third button
|
257
|
+
if (fButtons.length > 2) {
|
258
|
+
dlg.setNegativeButton(fButtons[2],
|
259
|
+
new AlertDialog.OnClickListener() {
|
260
|
+
public void onClick(DialogInterface dialog, int which) {
|
261
|
+
dialog.dismiss();
|
262
|
+
notification.success(new PluginResult(PluginResult.Status.OK, 3), callbackId);
|
263
|
+
}
|
264
|
+
}
|
265
|
+
);
|
266
|
+
}
|
267
|
+
|
268
|
+
dlg.create();
|
269
|
+
dlg.show();
|
270
|
+
};
|
271
|
+
};
|
272
|
+
this.ctx.runOnUiThread(runnable);
|
273
|
+
}
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Show the spinner.
|
277
|
+
*
|
278
|
+
* @param title Title of the dialog
|
279
|
+
* @param message The message of the dialog
|
280
|
+
*/
|
281
|
+
public synchronized void activityStart(final String title, final String message) {
|
282
|
+
if (this.spinnerDialog != null) {
|
283
|
+
this.spinnerDialog.dismiss();
|
284
|
+
this.spinnerDialog = null;
|
285
|
+
}
|
286
|
+
final Notification notification = this;
|
287
|
+
final CordovaInterface ctx = this.ctx;
|
288
|
+
Runnable runnable = new Runnable() {
|
289
|
+
public void run() {
|
290
|
+
notification.spinnerDialog = ProgressDialog.show(ctx.getContext(), title , message, true, true,
|
291
|
+
new DialogInterface.OnCancelListener() {
|
292
|
+
public void onCancel(DialogInterface dialog) {
|
293
|
+
notification.spinnerDialog = null;
|
294
|
+
}
|
295
|
+
});
|
296
|
+
}
|
297
|
+
};
|
298
|
+
this.ctx.runOnUiThread(runnable);
|
299
|
+
}
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Stop spinner.
|
303
|
+
*/
|
304
|
+
public synchronized void activityStop() {
|
305
|
+
if (this.spinnerDialog != null) {
|
306
|
+
this.spinnerDialog.dismiss();
|
307
|
+
this.spinnerDialog = null;
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
/**
|
312
|
+
* Show the progress dialog.
|
313
|
+
*
|
314
|
+
* @param title Title of the dialog
|
315
|
+
* @param message The message of the dialog
|
316
|
+
*/
|
317
|
+
public synchronized void progressStart(final String title, final String message) {
|
318
|
+
if (this.progressDialog != null) {
|
319
|
+
this.progressDialog.dismiss();
|
320
|
+
this.progressDialog = null;
|
321
|
+
}
|
322
|
+
final Notification notification = this;
|
323
|
+
final CordovaInterface ctx = this.ctx;
|
324
|
+
Runnable runnable = new Runnable() {
|
325
|
+
public void run() {
|
326
|
+
notification.progressDialog = new ProgressDialog(ctx.getContext());
|
327
|
+
notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
328
|
+
notification.progressDialog.setTitle(title);
|
329
|
+
notification.progressDialog.setMessage(message);
|
330
|
+
notification.progressDialog.setCancelable(true);
|
331
|
+
notification.progressDialog.setMax(100);
|
332
|
+
notification.progressDialog.setProgress(0);
|
333
|
+
notification.progressDialog.setOnCancelListener(
|
334
|
+
new DialogInterface.OnCancelListener() {
|
335
|
+
public void onCancel(DialogInterface dialog) {
|
336
|
+
notification.progressDialog = null;
|
337
|
+
}
|
338
|
+
});
|
339
|
+
notification.progressDialog.show();
|
340
|
+
}
|
341
|
+
};
|
342
|
+
this.ctx.runOnUiThread(runnable);
|
343
|
+
}
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Set value of progress bar.
|
347
|
+
*
|
348
|
+
* @param value 0-100
|
349
|
+
*/
|
350
|
+
public synchronized void progressValue(int value) {
|
351
|
+
if (this.progressDialog != null) {
|
352
|
+
this.progressDialog.setProgress(value);
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* Stop progress dialog.
|
358
|
+
*/
|
359
|
+
public synchronized void progressStop() {
|
360
|
+
if (this.progressDialog != null) {
|
361
|
+
this.progressDialog.dismiss();
|
362
|
+
this.progressDialog = null;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
}
|
@@ -0,0 +1,34 @@
|
|
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
|
+
// represents the <preference> element from the W3C config.xml spec
|
22
|
+
// see http://www.w3.org/TR/widgets/#the-preference-element-and-its-attributes
|
23
|
+
public class PreferenceNode {
|
24
|
+
public String name;
|
25
|
+
public String value;
|
26
|
+
public boolean readonly;
|
27
|
+
|
28
|
+
// constructor
|
29
|
+
public PreferenceNode(String name, String value, boolean readonly) {
|
30
|
+
this.name = name;
|
31
|
+
this.value = value;
|
32
|
+
this.readonly = readonly;
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,62 @@
|
|
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.HashSet;
|
22
|
+
|
23
|
+
import org.apache.cordova.PreferenceNode;
|
24
|
+
|
25
|
+
|
26
|
+
public class PreferenceSet {
|
27
|
+
private HashSet<PreferenceNode> innerSet;
|
28
|
+
|
29
|
+
public PreferenceSet() {
|
30
|
+
this.innerSet = new HashSet<PreferenceNode>();
|
31
|
+
}
|
32
|
+
|
33
|
+
public void add(PreferenceNode node) {
|
34
|
+
this.innerSet.add(node);
|
35
|
+
}
|
36
|
+
|
37
|
+
public int size() {
|
38
|
+
return this.innerSet.size();
|
39
|
+
}
|
40
|
+
|
41
|
+
public void clear() {
|
42
|
+
this.innerSet.clear();
|
43
|
+
}
|
44
|
+
|
45
|
+
public String pref(String prefName) {
|
46
|
+
for (PreferenceNode n : innerSet)
|
47
|
+
if (prefName.equals(n.name))
|
48
|
+
return n.value;
|
49
|
+
|
50
|
+
return null;
|
51
|
+
}
|
52
|
+
|
53
|
+
public boolean prefMatches(String prefName, String prefValue) {
|
54
|
+
String value = pref(prefName);
|
55
|
+
|
56
|
+
if (value == null) {
|
57
|
+
return false;
|
58
|
+
} else {
|
59
|
+
return value.equals(prefValue);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,35 @@
|
|
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.lang.reflect.Field;
|
22
|
+
|
23
|
+
import android.app.Activity;
|
24
|
+
import android.os.Bundle;
|
25
|
+
|
26
|
+
public class StandAlone extends DroidGap {
|
27
|
+
|
28
|
+
@Override
|
29
|
+
public void onCreate(Bundle savedInstanceState) {
|
30
|
+
super.onCreate(savedInstanceState);
|
31
|
+
|
32
|
+
super.loadUrl("file:///android_asset/www/index.html");
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|