mobile_template 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mobile_template/version.rb +1 -1
- data/mobile_template.gemspec +1 -1
- data/templates/assets/Gemfile +1 -1
- data/templates/assets/source/javascripts/vendor/cordova.js +2106 -1975
- data/templates/assets/source/javascripts/vendor/jquery.js +614 -477
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +519 -378
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +683 -502
- data/templates/cordova_android/VERSION +1 -1
- data/templates/cordova_android/bin/create +5 -1
- data/templates/cordova_android/bin/templates/project/cordova/create +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +1 -1
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +18 -25
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +6 -6
- data/templates/cordova_android/framework/assets/js/cordova.android.js +2106 -1975
- data/templates/cordova_android/framework/assets/www/index.html +1 -1
- data/templates/cordova_android/framework/build.xml +2 -42
- data/templates/cordova_android/framework/project.properties +1 -1
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/drawable-hdpi/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable-ldpi/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable-mdpi/icon.png +0 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +2 -1
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +1 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +24 -16
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +35 -10
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +2 -1
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +67 -65
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +51 -63
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +3 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +6 -2
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +108 -108
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +110 -77
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +90 -44
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +20 -20
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +2 -2
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +7 -8
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +2 -2
- data/templates/cordova_android/framework/src/org/apache/cordova/SplashScreen.java +23 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +3 -3
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +2 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginEntry.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +260 -258
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +2 -2
- data/templates/cordova_android/releasenotes.md +42 -0
- data/templates/cordova_android/test/.classpath +8 -0
- data/templates/cordova_android/test/.project +33 -0
- data/templates/cordova_android/test/AndroidManifest.xml +87 -0
- data/templates/cordova_android/test/README.md +23 -0
- data/templates/cordova_android/test/ant.properties +17 -0
- data/templates/cordova_android/test/assets/www/backbuttonmultipage/index.html +23 -0
- data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample2.html +23 -0
- data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample3.html +26 -0
- data/templates/cordova_android/test/assets/www/background/index.html +99 -0
- data/templates/cordova_android/test/assets/www/background/index2.html +98 -0
- data/templates/cordova_android/test/assets/www/cordova-1.6.0.js +4985 -0
- data/templates/cordova_android/test/assets/www/cordova.js +2 -0
- data/templates/cordova_android/test/assets/www/htmlnotfound/error.html +1 -0
- data/templates/cordova_android/test/assets/www/iframe/index.html +33 -0
- data/templates/cordova_android/test/assets/www/iframe/index2.html +24 -0
- data/templates/cordova_android/test/assets/www/index.html +47 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/index.html +49 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab1.html +29 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab2.html +30 -0
- data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab3.html +30 -0
- data/templates/cordova_android/test/assets/www/lifecycle/index.html +108 -0
- data/templates/cordova_android/test/assets/www/lifecycle/index2.html +104 -0
- data/templates/cordova_android/test/assets/www/main.js +150 -0
- data/templates/cordova_android/test/assets/www/master.css +117 -0
- data/templates/cordova_android/test/assets/www/menus/index.html +29 -0
- data/templates/cordova_android/test/assets/www/splashscreen/index.html +22 -0
- data/templates/cordova_android/test/assets/www/userwebview/index.html +49 -0
- data/templates/cordova_android/test/assets/www/whitelist/index.html +29 -0
- data/templates/cordova_android/test/assets/www/whitelist/index2.html +23 -0
- data/templates/cordova_android/test/assets/www/xhr/index.html +48 -0
- data/templates/cordova_android/test/build.xml +85 -0
- data/templates/cordova_android/test/libs/cordova-1.6.0.jar +0 -0
- data/templates/cordova_android/test/project.properties +11 -0
- data/templates/cordova_android/{framework → test}/res/drawable/icon.png +0 -0
- data/templates/cordova_android/test/res/drawable/sandy.jpg +0 -0
- data/templates/cordova_android/test/res/drawable-hdpi/ic_launcher.png +0 -0
- data/templates/cordova_android/test/res/drawable-ldpi/ic_launcher.png +0 -0
- data/templates/cordova_android/test/res/drawable-mdpi/ic_launcher.png +0 -0
- data/templates/cordova_android/test/res/layout/main.xml +13 -0
- data/templates/cordova_android/test/res/values/strings.xml +4 -0
- data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/cordova.xml +0 -0
- data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/plugins.xml +1 -1
- data/templates/cordova_android/test/src/org/apache/cordova/test/ActivityPlugin.java +81 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/FixWebView.java +43 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/backbuttonmultipage.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/background.java +34 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/errorurl.java +32 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/htmlnotfound.java +31 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/iframe.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/jqmtabbackbutton.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/lifecycle.java +30 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/loading.java +31 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/menus.java +80 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/splashscreen.java +35 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/tests.java +32 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/timeout.java +34 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/userwebview.java +72 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/whitelist.java +51 -0
- data/templates/cordova_android/test/src/org/apache/cordova/test/xhr.java +30 -0
- metadata +83 -30
- data/templates/cordova_android/framework/assets/js/accelerometer.js +0 -137
- data/templates/cordova_android/framework/assets/js/app.js +0 -89
- data/templates/cordova_android/framework/assets/js/battery.js +0 -134
- data/templates/cordova_android/framework/assets/js/camera.js +0 -168
- data/templates/cordova_android/framework/assets/js/capture.js +0 -203
- data/templates/cordova_android/framework/assets/js/compass.js +0 -168
- data/templates/cordova_android/framework/assets/js/contact.js +0 -310
- data/templates/cordova_android/framework/assets/js/cordova.js.base +0 -924
- data/templates/cordova_android/framework/assets/js/crypto.js +0 -54
- data/templates/cordova_android/framework/assets/js/device.js +0 -83
- data/templates/cordova_android/framework/assets/js/file.js +0 -1082
- data/templates/cordova_android/framework/assets/js/filetransfer.js +0 -125
- data/templates/cordova_android/framework/assets/js/geolocation.js +0 -209
- data/templates/cordova_android/framework/assets/js/header.txt +0 -19
- data/templates/cordova_android/framework/assets/js/media.js +0 -233
- data/templates/cordova_android/framework/assets/js/network.js +0 -100
- data/templates/cordova_android/framework/assets/js/notification.js +0 -133
- data/templates/cordova_android/framework/assets/js/position.js +0 -100
- data/templates/cordova_android/framework/assets/js/storage.js +0 -439
@@ -216,6 +216,9 @@ public class CordovaChromeClient extends WebChromeClient {
|
|
216
216
|
// Cordova JS has initialized, so show webview
|
217
217
|
// (This solves white flash seen when rendering HTML)
|
218
218
|
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
|
219
|
+
if (ctx.splashscreen != 0) {
|
220
|
+
ctx.root.setBackgroundResource(0);
|
221
|
+
}
|
219
222
|
ctx.appView.setVisibility(View.VISIBLE);
|
220
223
|
ctx.spinnerStop();
|
221
224
|
result.confirm("OK");
|
@@ -64,7 +64,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
|
64
64
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
65
65
|
|
66
66
|
// First give any plugins the chance to handle the url themselves
|
67
|
-
if (this.ctx.pluginManager.onOverrideUrlLoading(url)) {
|
67
|
+
if ((this.ctx.pluginManager != null) && this.ctx.pluginManager.onOverrideUrlLoading(url)) {
|
68
68
|
}
|
69
69
|
|
70
70
|
// If dialing phone (tel:5551212)
|
@@ -217,7 +217,8 @@ public class CordovaWebViewClient extends WebViewClient {
|
|
217
217
|
// not loaded yet then just set a flag so that the onNativeReady can be fired
|
218
218
|
// from the JS side when the JS gets to that code.
|
219
219
|
if (!url.equals("about:blank")) {
|
220
|
-
ctx.appView.loadUrl("javascript:try{ require('cordova/channel').onNativeReady.fire();}catch(e){_nativeReady = true;}");
|
220
|
+
ctx.appView.loadUrl("javascript:try{ cordova.require('cordova/channel').onNativeReady.fire();}catch(e){_nativeReady = true;}");
|
221
|
+
this.ctx.postMessage("onNativeReady", null);
|
221
222
|
}
|
222
223
|
|
223
224
|
// Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
|
@@ -228,6 +229,9 @@ public class CordovaWebViewClient extends WebViewClient {
|
|
228
229
|
Thread.sleep(2000);
|
229
230
|
ctx.runOnUiThread(new Runnable() {
|
230
231
|
public void run() {
|
232
|
+
if (ctx.splashscreen != 0) {
|
233
|
+
ctx.root.setBackgroundResource(0);
|
234
|
+
}
|
231
235
|
ctx.appView.setVisibility(View.VISIBLE);
|
232
236
|
ctx.spinnerStop();
|
233
237
|
}
|
@@ -38,73 +38,73 @@ import android.telephony.TelephonyManager;
|
|
38
38
|
public class Device extends Plugin {
|
39
39
|
public static final String TAG = "Device";
|
40
40
|
|
41
|
-
public static String cordovaVersion = "1.
|
42
|
-
|
43
|
-
|
41
|
+
public static String cordovaVersion = "1.7.0"; // Cordova version
|
42
|
+
public static String platform = "Android"; // Device OS
|
43
|
+
public static String uuid; // Device UUID
|
44
44
|
|
45
45
|
BroadcastReceiver telephonyReceiver = null;
|
46
46
|
|
47
47
|
/**
|
48
48
|
* Constructor.
|
49
49
|
*/
|
50
|
-
|
50
|
+
public Device() {
|
51
51
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Sets the context of the Command. This can then be used to do things like
|
55
|
+
* get file paths associated with the Activity.
|
56
|
+
*
|
57
|
+
* @param ctx The context of the main Activity.
|
58
|
+
*/
|
59
|
+
public void setContext(CordovaInterface ctx) {
|
60
|
+
super.setContext(ctx);
|
61
61
|
Device.uuid = getUuid();
|
62
62
|
this.initTelephonyReceiver();
|
63
|
-
|
63
|
+
}
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
65
|
+
/**
|
66
|
+
* Executes the request and returns PluginResult.
|
67
|
+
*
|
68
|
+
* @param action The action to execute.
|
69
|
+
* @param args JSONArry of arguments for the plugin.
|
70
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
71
|
+
* @return A PluginResult object with a status and message.
|
72
|
+
*/
|
73
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
74
|
+
PluginResult.Status status = PluginResult.Status.OK;
|
75
|
+
String result = "";
|
76
|
+
|
77
|
+
try {
|
78
|
+
if (action.equals("getDeviceInfo")) {
|
79
|
+
JSONObject r = new JSONObject();
|
80
|
+
r.put("uuid", Device.uuid);
|
81
|
+
r.put("version", this.getOSVersion());
|
82
|
+
r.put("platform", Device.platform);
|
83
|
+
r.put("name", this.getProductName());
|
84
|
+
r.put("cordova", Device.cordovaVersion);
|
85
|
+
//JSONObject pg = new JSONObject();
|
86
|
+
//pg.put("version", Device.CordovaVersion);
|
87
|
+
//r.put("cordova", pg);
|
88
|
+
return new PluginResult(status, r);
|
89
|
+
}
|
90
|
+
return new PluginResult(status, result);
|
91
|
+
} catch (JSONException e) {
|
92
|
+
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
93
|
+
}
|
94
|
+
}
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
/**
|
97
|
+
* Identifies if action to be executed returns a value and should be run synchronously.
|
98
|
+
*
|
99
|
+
* @param action The action to execute
|
100
|
+
* @return T=returns value
|
101
|
+
*/
|
102
|
+
public boolean isSynch(String action) {
|
103
|
+
if (action.equals("getDeviceInfo")) {
|
104
|
+
return true;
|
105
|
+
}
|
106
|
+
return false;
|
107
|
+
}
|
108
108
|
|
109
109
|
/**
|
110
110
|
* Unregister receiver.
|
@@ -156,59 +156,59 @@ public class Device extends Plugin {
|
|
156
156
|
this.ctx.registerReceiver(this.telephonyReceiver, intentFilter);
|
157
157
|
}
|
158
158
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
159
|
+
/**
|
160
|
+
* Get the OS name.
|
161
|
+
*
|
162
|
+
* @return
|
163
|
+
*/
|
164
|
+
public String getPlatform() {
|
165
|
+
return Device.platform;
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Get the device's Universally Unique Identifier (UUID).
|
170
|
+
*
|
171
|
+
* @return
|
172
|
+
*/
|
173
|
+
public String getUuid() {
|
174
|
+
String uuid = Settings.Secure.getString(this.ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
175
|
+
return uuid;
|
176
|
+
}
|
177
177
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
178
|
+
/**
|
179
|
+
* Get the Cordova version.
|
180
|
+
*
|
181
|
+
* @return
|
182
|
+
*/
|
183
|
+
public String getCordovaVersion() {
|
184
|
+
return Device.cordovaVersion;
|
185
|
+
}
|
186
|
+
|
187
|
+
public String getModel() {
|
188
|
+
String model = android.os.Build.MODEL;
|
189
|
+
return model;
|
190
|
+
}
|
191
|
+
|
192
|
+
public String getProductName() {
|
193
|
+
String productname = android.os.Build.PRODUCT;
|
194
|
+
return productname;
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Get the OS version.
|
199
|
+
*
|
200
|
+
* @return
|
201
|
+
*/
|
202
|
+
public String getOSVersion() {
|
203
|
+
String osversion = android.os.Build.VERSION.RELEASE;
|
204
|
+
return osversion;
|
205
|
+
}
|
206
|
+
|
207
|
+
public String getSDKVersion() {
|
208
|
+
String sdkversion = android.os.Build.VERSION.SDK;
|
209
|
+
return sdkversion;
|
210
|
+
}
|
211
|
+
|
212
212
|
|
213
213
|
public String getTimeZoneID() {
|
214
214
|
TimeZone tz = TimeZone.getDefault();
|
@@ -37,17 +37,18 @@ import org.xmlpull.v1.XmlPullParserException;
|
|
37
37
|
|
38
38
|
import android.app.Activity;
|
39
39
|
import android.app.AlertDialog;
|
40
|
+
import android.app.Dialog;
|
40
41
|
import android.app.ProgressDialog;
|
41
42
|
import android.content.Context;
|
42
43
|
import android.content.DialogInterface;
|
43
44
|
import android.content.Intent;
|
44
45
|
import android.content.res.Configuration;
|
45
46
|
import android.content.res.XmlResourceParser;
|
46
|
-
import android.database.Cursor;
|
47
47
|
import android.graphics.Color;
|
48
48
|
import android.media.AudioManager;
|
49
49
|
import android.net.Uri;
|
50
50
|
import android.os.Bundle;
|
51
|
+
import android.os.Handler;
|
51
52
|
import android.view.Display;
|
52
53
|
import android.view.KeyEvent;
|
53
54
|
import android.view.Menu;
|
@@ -56,6 +57,7 @@ import android.view.View;
|
|
56
57
|
import android.view.ViewGroup;
|
57
58
|
import android.view.Window;
|
58
59
|
import android.view.WindowManager;
|
60
|
+
import android.webkit.WebChromeClient;
|
59
61
|
import android.webkit.WebSettings;
|
60
62
|
import android.webkit.WebSettings.LayoutAlgorithm;
|
61
63
|
import android.webkit.WebView;
|
@@ -345,22 +347,33 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
345
347
|
}
|
346
348
|
|
347
349
|
/**
|
348
|
-
* Create and initialize web container.
|
350
|
+
* Create and initialize web container with default web view objects.
|
349
351
|
*/
|
350
352
|
public void init() {
|
353
|
+
this.init(new WebView(DroidGap.this), new CordovaWebViewClient(this), new CordovaChromeClient(DroidGap.this));
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* Initialize web container with web view objects.
|
358
|
+
*
|
359
|
+
* @param webView
|
360
|
+
* @param webViewClient
|
361
|
+
* @param webChromeClient
|
362
|
+
*/
|
363
|
+
public void init(WebView webView, WebViewClient webViewClient, WebChromeClient webChromeClient) {
|
351
364
|
LOG.d(TAG, "DroidGap.init()");
|
352
365
|
|
353
|
-
//
|
354
|
-
|
366
|
+
// Set up web container
|
367
|
+
this.appView = webView;
|
355
368
|
this.appView.setId(100);
|
356
|
-
|
369
|
+
|
357
370
|
this.appView.setLayoutParams(new LinearLayout.LayoutParams(
|
358
371
|
ViewGroup.LayoutParams.FILL_PARENT,
|
359
372
|
ViewGroup.LayoutParams.FILL_PARENT,
|
360
373
|
1.0F));
|
361
374
|
|
362
|
-
|
363
|
-
|
375
|
+
this.appView.setWebChromeClient(webChromeClient);
|
376
|
+
this.setWebViewClient(this.appView, webViewClient);
|
364
377
|
|
365
378
|
this.appView.setInitialScale(0);
|
366
379
|
this.appView.setVerticalScrollBarEnabled(false);
|
@@ -393,6 +406,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
393
406
|
|
394
407
|
// Clear cancel flag
|
395
408
|
this.cancelLoadUrl = false;
|
409
|
+
|
410
|
+
// Create plugin manager
|
411
|
+
this.pluginManager = new PluginManager(this.appView, this);
|
396
412
|
}
|
397
413
|
|
398
414
|
/**
|
@@ -418,9 +434,6 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
418
434
|
|
419
435
|
// If spashscreen
|
420
436
|
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
|
421
|
-
if ((this.urls.size() == 0) && (this.splashscreen != 0)) {
|
422
|
-
root.setBackgroundResource(this.splashscreen);
|
423
|
-
}
|
424
437
|
|
425
438
|
// If loadUrlTimeoutValue
|
426
439
|
int timeout = this.getIntegerProperty("loadUrlTimeoutValue", 0);
|
@@ -498,12 +511,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
498
511
|
else {
|
499
512
|
me.callbackServer.reinit(url);
|
500
513
|
}
|
501
|
-
|
502
|
-
me.pluginManager = new PluginManager(me.appView, me);
|
503
|
-
}
|
504
|
-
else {
|
505
|
-
me.pluginManager.reinit();
|
506
|
-
}
|
514
|
+
me.pluginManager.init();
|
507
515
|
|
508
516
|
// If loadingDialog property, then show the App loading dialog for first page of app
|
509
517
|
String loading = null;
|
@@ -598,38 +606,12 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
598
606
|
if (!url.startsWith("javascript:")) {
|
599
607
|
LOG.d(TAG, "DroidGap.loadUrl(%s, %d)", url, time);
|
600
608
|
}
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
me.init();
|
608
|
-
}
|
609
|
-
me.handleActivityParameters();
|
610
|
-
}
|
611
|
-
});
|
612
|
-
|
613
|
-
Runnable runnable = new Runnable() {
|
614
|
-
public void run() {
|
615
|
-
try {
|
616
|
-
synchronized(this) {
|
617
|
-
this.wait(time);
|
618
|
-
}
|
619
|
-
} catch (InterruptedException e) {
|
620
|
-
e.printStackTrace();
|
621
|
-
}
|
622
|
-
if (!me.cancelLoadUrl) {
|
623
|
-
me.loadUrlIntoView(url);
|
624
|
-
}
|
625
|
-
else{
|
626
|
-
me.cancelLoadUrl = false;
|
627
|
-
LOG.d(TAG, "Aborting loadUrl(%s): Another URL was loaded before timer expired.", url);
|
628
|
-
}
|
629
|
-
}
|
630
|
-
};
|
631
|
-
Thread thread = new Thread(runnable);
|
632
|
-
thread.start();
|
609
|
+
|
610
|
+
this.handleActivityParameters();
|
611
|
+
if (this.splashscreen != 0) {
|
612
|
+
this.showSplashScreen(time);
|
613
|
+
}
|
614
|
+
this.loadUrlIntoView(url);
|
633
615
|
}
|
634
616
|
|
635
617
|
/**
|
@@ -831,11 +813,13 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
831
813
|
}
|
832
814
|
|
833
815
|
// Send pause event to JavaScript
|
834
|
-
this.appView.loadUrl("javascript:try{require('cordova/channel').onPause.fire();}catch(e){console.log('exception firing pause event from native');};");
|
816
|
+
this.appView.loadUrl("javascript:try{cordova.require('cordova/channel').onPause.fire();}catch(e){console.log('exception firing pause event from native');};");
|
835
817
|
|
836
818
|
// Forward to plugins
|
837
|
-
this.pluginManager
|
838
|
-
|
819
|
+
if (this.pluginManager != null) {
|
820
|
+
this.pluginManager.onPause(this.keepRunning);
|
821
|
+
}
|
822
|
+
|
839
823
|
// If app doesn't want to run in background
|
840
824
|
if (!this.keepRunning) {
|
841
825
|
|
@@ -852,7 +836,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
852
836
|
super.onNewIntent(intent);
|
853
837
|
|
854
838
|
//Forward to plugins
|
855
|
-
this.pluginManager
|
839
|
+
if (this.pluginManager != null) {
|
840
|
+
this.pluginManager.onNewIntent(intent);
|
841
|
+
}
|
856
842
|
}
|
857
843
|
|
858
844
|
@Override
|
@@ -872,11 +858,13 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
872
858
|
}
|
873
859
|
|
874
860
|
// Send resume event to JavaScript
|
875
|
-
this.appView.loadUrl("javascript:try{require('cordova/channel').onResume.fire();}catch(e){console.log('exception firing resume event from native');};");
|
861
|
+
this.appView.loadUrl("javascript:try{cordova.require('cordova/channel').onResume.fire();}catch(e){console.log('exception firing resume event from native');};");
|
876
862
|
|
877
863
|
// Forward to plugins
|
878
|
-
this.pluginManager
|
879
|
-
|
864
|
+
if (this.pluginManager != null) {
|
865
|
+
this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);
|
866
|
+
}
|
867
|
+
|
880
868
|
// If app doesn't want to run in background
|
881
869
|
if (!this.keepRunning || this.activityResultKeepRunning) {
|
882
870
|
|
@@ -902,7 +890,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
902
890
|
|
903
891
|
|
904
892
|
// Send destroy event to JavaScript
|
905
|
-
this.appView.loadUrl("javascript:try{require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
|
893
|
+
this.appView.loadUrl("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
|
906
894
|
|
907
895
|
// Load blank page so that JavaScript onunload is called
|
908
896
|
this.appView.loadUrl("about:blank");
|
@@ -942,7 +930,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
942
930
|
*/
|
943
931
|
@Deprecated
|
944
932
|
public void addService(String serviceType, String className) {
|
945
|
-
this.pluginManager
|
933
|
+
if (this.pluginManager != null) {
|
934
|
+
this.pluginManager.addService(serviceType, className);
|
935
|
+
}
|
946
936
|
}
|
947
937
|
|
948
938
|
/**
|
@@ -952,7 +942,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
952
942
|
* @param message
|
953
943
|
*/
|
954
944
|
public void sendJavascript(String statement) {
|
955
|
-
|
945
|
+
//We need to check for the null case on the Kindle Fire beacuse it changes the width and height on load
|
946
|
+
if(this.callbackServer != null)
|
947
|
+
this.callbackServer.sendJavascript(statement);
|
956
948
|
}
|
957
949
|
|
958
950
|
/**
|
@@ -1052,51 +1044,46 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
1052
1044
|
}
|
1053
1045
|
|
1054
1046
|
/**
|
1055
|
-
* Called when a key is pressed.
|
1047
|
+
* Called when a key is de-pressed. (Key UP)
|
1056
1048
|
*
|
1057
1049
|
* @param keyCode
|
1058
1050
|
* @param event
|
1059
1051
|
*/
|
1060
1052
|
@Override
|
1061
|
-
public boolean
|
1053
|
+
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
1062
1054
|
if (this.appView == null) {
|
1063
|
-
return super.
|
1055
|
+
return super.onKeyUp(keyCode, event);
|
1064
1056
|
}
|
1065
1057
|
|
1066
1058
|
// If back key
|
1067
1059
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
1068
|
-
|
1069
1060
|
// If back key is bound, then send event to JavaScript
|
1070
1061
|
if (this.bound) {
|
1071
|
-
this.appView.loadUrl("javascript:
|
1062
|
+
this.appView.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
|
1072
1063
|
return true;
|
1073
|
-
}
|
1074
|
-
|
1075
|
-
// If not bound
|
1076
|
-
else {
|
1077
|
-
|
1064
|
+
} else {
|
1065
|
+
// If not bound
|
1078
1066
|
// Go to previous page in webview if it is possible to go back
|
1079
1067
|
if (this.backHistory()) {
|
1080
1068
|
return true;
|
1081
1069
|
}
|
1082
|
-
|
1083
1070
|
// If not, then invoke behavior of super class
|
1084
1071
|
else {
|
1085
1072
|
this.activityState = ACTIVITY_EXITING;
|
1086
|
-
return super.
|
1073
|
+
return super.onKeyUp(keyCode, event);
|
1087
1074
|
}
|
1088
1075
|
}
|
1089
1076
|
}
|
1090
1077
|
|
1091
1078
|
// If menu key
|
1092
1079
|
else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
1093
|
-
this.appView.loadUrl("javascript:
|
1094
|
-
return super.
|
1080
|
+
this.appView.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');");
|
1081
|
+
return super.onKeyUp(keyCode, event);
|
1095
1082
|
}
|
1096
1083
|
|
1097
1084
|
// If search key
|
1098
1085
|
else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
1099
|
-
this.appView.loadUrl("javascript:
|
1086
|
+
this.appView.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');");
|
1100
1087
|
return true;
|
1101
1088
|
}
|
1102
1089
|
|
@@ -1185,13 +1172,16 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
1185
1172
|
}
|
1186
1173
|
});
|
1187
1174
|
}
|
1188
|
-
|
1189
1175
|
// If not, then display error dialog
|
1190
1176
|
else {
|
1177
|
+
final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
|
1191
1178
|
me.runOnUiThread(new Runnable() {
|
1192
1179
|
public void run() {
|
1193
|
-
|
1194
|
-
|
1180
|
+
if(exit)
|
1181
|
+
{
|
1182
|
+
me.appView.setVisibility(View.GONE);
|
1183
|
+
me.displayError("Application Error", description + " ("+failingUrl+")", "OK", exit);
|
1184
|
+
}
|
1195
1185
|
}
|
1196
1186
|
});
|
1197
1187
|
}
|
@@ -1328,7 +1318,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
1328
1318
|
* @param url
|
1329
1319
|
* @return
|
1330
1320
|
*/
|
1331
|
-
boolean isUrlWhiteListed(String url) {
|
1321
|
+
public boolean isUrlWhiteListed(String url) {
|
1332
1322
|
|
1333
1323
|
// Check to see if we have matched url previously
|
1334
1324
|
if (whiteListCache.get(url) != null) {
|
@@ -1414,4 +1404,47 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|
1414
1404
|
return this.bound;
|
1415
1405
|
}
|
1416
1406
|
|
1407
|
+
protected Dialog splashDialog;
|
1408
|
+
|
1409
|
+
/**
|
1410
|
+
* Removes the Dialog that displays the splash screen
|
1411
|
+
*/
|
1412
|
+
public void removeSplashScreen() {
|
1413
|
+
if (splashDialog != null) {
|
1414
|
+
splashDialog.dismiss();
|
1415
|
+
splashDialog = null;
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
/**
|
1420
|
+
* Shows the splash screen over the full Activity
|
1421
|
+
*/
|
1422
|
+
protected void showSplashScreen(int time) {
|
1423
|
+
// Get reference to display
|
1424
|
+
Display display = getWindowManager().getDefaultDisplay();
|
1425
|
+
|
1426
|
+
// Create the layout for the dialog
|
1427
|
+
LinearLayout root = new LinearLayout(this);
|
1428
|
+
root.setMinimumHeight(display.getHeight());
|
1429
|
+
root.setMinimumWidth(display.getWidth());
|
1430
|
+
root.setOrientation(LinearLayout.VERTICAL);
|
1431
|
+
root.setBackgroundColor(this.getIntegerProperty("backgroundColor", Color.BLACK));
|
1432
|
+
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
1433
|
+
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
|
1434
|
+
root.setBackgroundResource(this.splashscreen);
|
1435
|
+
|
1436
|
+
// Create and show the dialog
|
1437
|
+
splashDialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
|
1438
|
+
splashDialog.setContentView(root);
|
1439
|
+
splashDialog.setCancelable(false);
|
1440
|
+
splashDialog.show();
|
1441
|
+
|
1442
|
+
// Set Runnable to remove splash screen just in case
|
1443
|
+
final Handler handler = new Handler();
|
1444
|
+
handler.postDelayed(new Runnable() {
|
1445
|
+
public void run() {
|
1446
|
+
removeSplashScreen();
|
1447
|
+
}
|
1448
|
+
}, time);
|
1449
|
+
}
|
1417
1450
|
}
|