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.
Files changed (123) hide show
  1. data/lib/mobile_template/version.rb +1 -1
  2. data/mobile_template.gemspec +1 -1
  3. data/templates/assets/Gemfile +1 -1
  4. data/templates/assets/source/javascripts/vendor/cordova.js +2106 -1975
  5. data/templates/assets/source/javascripts/vendor/jquery.js +614 -477
  6. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +519 -378
  7. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +683 -502
  8. data/templates/cordova_android/VERSION +1 -1
  9. data/templates/cordova_android/bin/create +5 -1
  10. data/templates/cordova_android/bin/templates/project/cordova/create +5 -0
  11. data/templates/cordova_android/bin/templates/project/cordova/debug +1 -1
  12. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +18 -25
  13. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +6 -6
  14. data/templates/cordova_android/framework/assets/js/cordova.android.js +2106 -1975
  15. data/templates/cordova_android/framework/assets/www/index.html +1 -1
  16. data/templates/cordova_android/framework/build.xml +2 -42
  17. data/templates/cordova_android/framework/project.properties +1 -1
  18. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  19. data/templates/cordova_android/framework/res/drawable-hdpi/icon.png +0 -0
  20. data/templates/cordova_android/framework/res/drawable-ldpi/icon.png +0 -0
  21. data/templates/cordova_android/framework/res/drawable-mdpi/icon.png +0 -0
  22. data/templates/cordova_android/framework/res/xml/plugins.xml +2 -1
  23. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +1 -0
  24. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +24 -16
  25. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +35 -10
  26. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +2 -1
  27. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +67 -65
  28. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +51 -63
  29. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +3 -0
  30. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +6 -2
  31. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +108 -108
  32. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +110 -77
  33. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +90 -44
  34. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +20 -20
  35. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +2 -2
  36. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +7 -8
  37. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +2 -2
  38. data/templates/cordova_android/framework/src/org/apache/cordova/SplashScreen.java +23 -0
  39. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +3 -3
  40. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +2 -0
  41. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginEntry.java +119 -0
  42. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +260 -258
  43. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +2 -2
  44. data/templates/cordova_android/releasenotes.md +42 -0
  45. data/templates/cordova_android/test/.classpath +8 -0
  46. data/templates/cordova_android/test/.project +33 -0
  47. data/templates/cordova_android/test/AndroidManifest.xml +87 -0
  48. data/templates/cordova_android/test/README.md +23 -0
  49. data/templates/cordova_android/test/ant.properties +17 -0
  50. data/templates/cordova_android/test/assets/www/backbuttonmultipage/index.html +23 -0
  51. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample2.html +23 -0
  52. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample3.html +26 -0
  53. data/templates/cordova_android/test/assets/www/background/index.html +99 -0
  54. data/templates/cordova_android/test/assets/www/background/index2.html +98 -0
  55. data/templates/cordova_android/test/assets/www/cordova-1.6.0.js +4985 -0
  56. data/templates/cordova_android/test/assets/www/cordova.js +2 -0
  57. data/templates/cordova_android/test/assets/www/htmlnotfound/error.html +1 -0
  58. data/templates/cordova_android/test/assets/www/iframe/index.html +33 -0
  59. data/templates/cordova_android/test/assets/www/iframe/index2.html +24 -0
  60. data/templates/cordova_android/test/assets/www/index.html +47 -0
  61. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/index.html +49 -0
  62. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab1.html +29 -0
  63. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab2.html +30 -0
  64. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab3.html +30 -0
  65. data/templates/cordova_android/test/assets/www/lifecycle/index.html +108 -0
  66. data/templates/cordova_android/test/assets/www/lifecycle/index2.html +104 -0
  67. data/templates/cordova_android/test/assets/www/main.js +150 -0
  68. data/templates/cordova_android/test/assets/www/master.css +117 -0
  69. data/templates/cordova_android/test/assets/www/menus/index.html +29 -0
  70. data/templates/cordova_android/test/assets/www/splashscreen/index.html +22 -0
  71. data/templates/cordova_android/test/assets/www/userwebview/index.html +49 -0
  72. data/templates/cordova_android/test/assets/www/whitelist/index.html +29 -0
  73. data/templates/cordova_android/test/assets/www/whitelist/index2.html +23 -0
  74. data/templates/cordova_android/test/assets/www/xhr/index.html +48 -0
  75. data/templates/cordova_android/test/build.xml +85 -0
  76. data/templates/cordova_android/test/libs/cordova-1.6.0.jar +0 -0
  77. data/templates/cordova_android/test/project.properties +11 -0
  78. data/templates/cordova_android/{framework → test}/res/drawable/icon.png +0 -0
  79. data/templates/cordova_android/test/res/drawable/sandy.jpg +0 -0
  80. data/templates/cordova_android/test/res/drawable-hdpi/ic_launcher.png +0 -0
  81. data/templates/cordova_android/test/res/drawable-ldpi/ic_launcher.png +0 -0
  82. data/templates/cordova_android/test/res/drawable-mdpi/ic_launcher.png +0 -0
  83. data/templates/cordova_android/test/res/layout/main.xml +13 -0
  84. data/templates/cordova_android/test/res/values/strings.xml +4 -0
  85. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/cordova.xml +0 -0
  86. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/plugins.xml +1 -1
  87. data/templates/cordova_android/test/src/org/apache/cordova/test/ActivityPlugin.java +81 -0
  88. data/templates/cordova_android/test/src/org/apache/cordova/test/FixWebView.java +43 -0
  89. data/templates/cordova_android/test/src/org/apache/cordova/test/backbuttonmultipage.java +30 -0
  90. data/templates/cordova_android/test/src/org/apache/cordova/test/background.java +34 -0
  91. data/templates/cordova_android/test/src/org/apache/cordova/test/errorurl.java +32 -0
  92. data/templates/cordova_android/test/src/org/apache/cordova/test/htmlnotfound.java +31 -0
  93. data/templates/cordova_android/test/src/org/apache/cordova/test/iframe.java +30 -0
  94. data/templates/cordova_android/test/src/org/apache/cordova/test/jqmtabbackbutton.java +30 -0
  95. data/templates/cordova_android/test/src/org/apache/cordova/test/lifecycle.java +30 -0
  96. data/templates/cordova_android/test/src/org/apache/cordova/test/loading.java +31 -0
  97. data/templates/cordova_android/test/src/org/apache/cordova/test/menus.java +80 -0
  98. data/templates/cordova_android/test/src/org/apache/cordova/test/splashscreen.java +35 -0
  99. data/templates/cordova_android/test/src/org/apache/cordova/test/tests.java +32 -0
  100. data/templates/cordova_android/test/src/org/apache/cordova/test/timeout.java +34 -0
  101. data/templates/cordova_android/test/src/org/apache/cordova/test/userwebview.java +72 -0
  102. data/templates/cordova_android/test/src/org/apache/cordova/test/whitelist.java +51 -0
  103. data/templates/cordova_android/test/src/org/apache/cordova/test/xhr.java +30 -0
  104. metadata +83 -30
  105. data/templates/cordova_android/framework/assets/js/accelerometer.js +0 -137
  106. data/templates/cordova_android/framework/assets/js/app.js +0 -89
  107. data/templates/cordova_android/framework/assets/js/battery.js +0 -134
  108. data/templates/cordova_android/framework/assets/js/camera.js +0 -168
  109. data/templates/cordova_android/framework/assets/js/capture.js +0 -203
  110. data/templates/cordova_android/framework/assets/js/compass.js +0 -168
  111. data/templates/cordova_android/framework/assets/js/contact.js +0 -310
  112. data/templates/cordova_android/framework/assets/js/cordova.js.base +0 -924
  113. data/templates/cordova_android/framework/assets/js/crypto.js +0 -54
  114. data/templates/cordova_android/framework/assets/js/device.js +0 -83
  115. data/templates/cordova_android/framework/assets/js/file.js +0 -1082
  116. data/templates/cordova_android/framework/assets/js/filetransfer.js +0 -125
  117. data/templates/cordova_android/framework/assets/js/geolocation.js +0 -209
  118. data/templates/cordova_android/framework/assets/js/header.txt +0 -19
  119. data/templates/cordova_android/framework/assets/js/media.js +0 -233
  120. data/templates/cordova_android/framework/assets/js/network.js +0 -100
  121. data/templates/cordova_android/framework/assets/js/notification.js +0 -133
  122. data/templates/cordova_android/framework/assets/js/position.js +0 -100
  123. data/templates/cordova_android/framework/assets/js/storage.js +0 -439
@@ -0,0 +1,2 @@
1
+ document.write('<script type="text/javascript" charset="utf-8" src="../cordova-1.6.0.js"></script>');
2
+ document.write('<script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>');
@@ -0,0 +1 @@
1
+ This is an error page.
@@ -0,0 +1,33 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=320; user-scalable=no" />
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Cordova Tests</title>
7
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
8
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="../main.js"></script>
10
+ <script>
11
+ function loadUrl(url) {
12
+ document.getElementById('iframe').src = url;
13
+ }</script>
14
+ </head>
15
+ <body onload="init();" id="stage" class="theme">
16
+ <h1>IFrame</h1>
17
+ <div id="info">
18
+ <h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
19
+ <h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
20
+ <h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
21
+ </span>, Color Depth: <span id="colorDepth"></span></h4>
22
+ </div>
23
+ <div id="info">
24
+ Press the two buttons:<br>
25
+ 1. Google Maps should display in iframe.<br>
26
+ 2. Page 2 replaces current page.<br>
27
+ (NOTE: THIS BEHAVIOR IS WRONG - AND NEEDS TO BE FIXED IN FUTURE RELEASE.)
28
+ </div>
29
+ <iframe id="iframe" src="" width="90%" height="200px"></iframe>
30
+ <a href="javascript:" class="btn large" onclick="loadUrl('http://maps.google.com/maps?output=embed');">Google Maps</a>
31
+ <a href="javascript:" class="btn large" onclick="loadUrl('index2.html');">Page 2</a>
32
+ </body>
33
+ </html>
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=320; user-scalable=no" />
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Cordova Tests</title>
7
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
8
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="../main.js"></script>
10
+ </head>
11
+ <body onload="init();" id="stage" class="theme">
12
+ <h1>IFrame window</h1>
13
+ <div id="info">
14
+ <h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
15
+ <h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
16
+ <h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
17
+ </span>, Color Depth: <span id="colorDepth"></span></h4>
18
+ </div>
19
+ <div id="info">
20
+ This should display a Cordova page inside an iframe. The info above should be filled out.
21
+ (NOTE: THIS DOES NOT WORK AND NEEDS TO BE FIXED IN FUTURE RELEASE.)
22
+ </div>
23
+ </body>
24
+ </html>
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=320; user-scalable=no" />
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Cordova Tests</title>
7
+ <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
8
+ <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="main.js"></script>
10
+ <script>
11
+ function startActivity(className) {
12
+ cordova.exec(function() {console.log("Success");}, function(e) {console.log("Error: "+e);}, "Activity", "start", [className]);
13
+ };
14
+
15
+ localStorage.lifecyclestatus = "";
16
+ localStorage.backgroundstatus = "";
17
+ </script>
18
+
19
+ </head>
20
+ <body onload="init();" id="stage" class="theme">
21
+ <h1>Cordova Android Tests</h1>
22
+ <div id="info">
23
+ <h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
24
+ <h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
25
+ <h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
26
+ </span>, Color Depth: <span id="colorDepth"></span></h4>
27
+ <h4>Cordova Version: <span id="cordova">&nbsp;</span></h4>
28
+ </div>
29
+ <div id="info">
30
+ <h4>Run each of the tests below:</h4>
31
+ </div>
32
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.jqmtabbackbutton');">Backbutton jQM tab</button>
33
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.backbuttonmultipage');">Backbutton with multiple pages</button>
34
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.errorurl');">Error URL</button>
35
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.htmlnotfound');">HTML not found</button>
36
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.iframe');">IFrame</button>
37
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.lifecycle');">Lifecycle</button>
38
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.loading');">Loading indicator</button>
39
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.menus');">Menus</button>
40
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.background');">No multitasking</button>
41
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.splashscreen');">Splash screen</button>
42
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.timeout');">Load timeout</button>
43
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.userwebview');">User WebView/Client/Chrome</button>
44
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.whitelist');">Whitelist</button>
45
+ <button class="btn large" onclick="startActivity('org.apache.cordova.test.xhr');">XHR</button>
46
+ </body>
47
+ </html>
@@ -0,0 +1,49 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <title>Backbutton</title>
5
+
6
+ <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
7
+ <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
8
+ <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
9
+ <script type="text/javascript" src="../cordova.js"></script>
10
+
11
+ <script>
12
+ document.addEventListener("deviceready", onDeviceReady, false);
13
+
14
+ // Without backbutton handler, each tab loaded will be popped off history until history is empty, then it will exit app.
15
+ function handleBackButton() {
16
+ alert("Back Button Pressed! - exiting app");
17
+ navigator.app.exitApp();
18
+ }
19
+
20
+ function onDeviceReady() {
21
+ console.log("onDeviceReady()");
22
+ document.addEventListener("backbutton", handleBackButton, false);
23
+ }
24
+
25
+
26
+ </script>
27
+ </head>
28
+ <body>
29
+ <div data-role="page" id="tabTab">
30
+ <div data-role="header">
31
+ <h1>Main</h1>
32
+ </div>
33
+ <div data-role="content" id="tabContent">
34
+ To test, press several tabs.<br>
35
+ The "backbutton" can be pressed any time to exit app.
36
+ </div>
37
+ <div data-role="footer" data-position="fixed">
38
+ <div data-role="navbar">
39
+ <ul>
40
+ <li><a href="tab1.html" data-transition="none">Tab 1</a>
41
+ </li>
42
+ <li><a href="tab2.html" data-transition="none">Tab 2</a>
43
+ </li>
44
+ <li><a href="tab3.html" data-transition="none">Tab 3</a>
45
+ </li>
46
+ </ul>
47
+ </div>
48
+ </div>
49
+ </div>
@@ -0,0 +1,29 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <title>Tab 1</title>
5
+
6
+ </head>
7
+ <body>
8
+ <div data-role="page" id="tab1Tab">
9
+ <div data-role="header">
10
+ <h1>Tab 1</h1>
11
+ </div>
12
+ <div data-role="content" id="tab1Content">
13
+ Tab 1 content.
14
+ </div>
15
+ <div data-role="footer" data-position="fixed">
16
+ <div data-role="navbar">
17
+ <ul>
18
+ <li><a href="tab1.html" data-transition="none">Tab 1</a>
19
+ </li>
20
+ <li><a href="tab2.html" data-transition="none">Tab 2</a>
21
+ </li>
22
+ <li><a href="tab3.html" data-transition="none">Tab 3</a>
23
+ </li>
24
+ </ul>
25
+ </div>
26
+ <!-- /navbar -->
27
+ </div>
28
+ <!-- /footer -->
29
+ </div>
@@ -0,0 +1,30 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <title>Tab 2</title>
5
+
6
+
7
+ </head>
8
+ <body>
9
+ <div data-role="page" id="tab2Tab">
10
+ <div data-role="header">
11
+ <h1>Tab 2</h1>
12
+ </div>
13
+ <div data-role="content" id="tab2Content">
14
+ Tab 2 content.
15
+ </div>
16
+ <div data-role="footer" data-position="fixed">
17
+ <div data-role="navbar">
18
+ <ul>
19
+ <li><a href="tab1.html" data-transition="none">Tab 1</a>
20
+ </li>
21
+ <li><a href="tab2.html" data-transition="none">Tab 2</a>
22
+ </li>
23
+ <li><a href="tab3.html" data-transition="none">Tab 3</a>
24
+ </li>
25
+ </ul>
26
+ </div>
27
+ <!-- /navbar -->
28
+ </div>
29
+ <!-- /footer -->
30
+ </div>
@@ -0,0 +1,30 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <title>Tab 3</title>
5
+
6
+
7
+ </head>
8
+ <body>
9
+ <div data-role="page" id="tab3Tab">
10
+ <div data-role="header">
11
+ <h1>Tab 3</h1>
12
+ </div>
13
+ <div data-role="content" id="tab3Content">
14
+ Tab 3 content.
15
+ </div>
16
+ <div data-role="footer" data-position="fixed">
17
+ <div data-role="navbar">
18
+ <ul>
19
+ <li><a href="tab1.html" data-transition="none">Tab 1</a>
20
+ </li>
21
+ <li><a href="tab2.html" data-transition="none">Tab 2</a>
22
+ </li>
23
+ <li><a href="tab3.html" data-transition="none">Tab 3</a>
24
+ </li>
25
+ </ul>
26
+ </div>
27
+ <!-- /navbar -->
28
+ </div>
29
+ <!-- /footer -->
30
+ </div>
@@ -0,0 +1,108 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Lifecycle Page 1</title>
7
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
8
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+
12
+ function onLoad() {
13
+ console.log("Page1: onload");
14
+ log("Page1: onload @ " + new Date().toLocaleTimeString());
15
+ document.addEventListener("deviceready", onDeviceReady, false);
16
+ }
17
+
18
+ function onUnLoaded() {
19
+ console.log("Page1: onunload");
20
+ log("Page1: onunload @ " + new Date().toLocaleTimeString());
21
+ }
22
+
23
+ function onDeviceReady() {
24
+ // Register the event listener
25
+ document.getElementById("platform").innerHTML = device.platform;
26
+ document.getElementById("version").innerHTML = device.version;
27
+ document.getElementById("uuid").innerHTML = device.uuid;
28
+ document.getElementById("name").innerHTML = device.name;
29
+ document.getElementById("width").innerHTML = screen.width;
30
+ document.getElementById("height").innerHTML = screen.height;
31
+ document.getElementById("colorDepth").innerHTML = screen.colorDepth;
32
+
33
+ document.addEventListener("pause", onPause, false);
34
+ document.addEventListener("resume", onResume, false);
35
+
36
+ window.setInterval(function() {
37
+ log("Page1: Running");
38
+ }, 2000);
39
+ }
40
+
41
+ function onPause() {
42
+ console.log("Page1: onpause");
43
+ log("Page1: onpause @ " + new Date().toLocaleTimeString());
44
+ }
45
+
46
+ function onResume() {
47
+ console.log("Page1: onresume");
48
+ log("Page1: onresume @ " + new Date().toLocaleTimeString());
49
+ }
50
+
51
+ function log(s) {
52
+ var el = document.getElementById('status');
53
+ var status = el.innerHTML + s + "<br>";
54
+ el.innerHTML = status;
55
+ localStorage.lifecyclestatus = status;
56
+ }
57
+
58
+ function clearStatus() {
59
+ console.log("clear()");
60
+ localStorage.lifecyclestatus = "";
61
+ document.getElementById('status').innerHTML = "";
62
+ }
63
+
64
+ </script>
65
+ </head>
66
+ <body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
67
+ <h1>Events</h1>
68
+ <div id="info">
69
+ <h4>
70
+ Platform: <span id="platform"> &nbsp;</span>, Version: <span
71
+ id="version">&nbsp;</span>
72
+ </h4>
73
+ <h4>
74
+ UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
75
+ </h4>
76
+ <h4>
77
+ Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
78
+ </span>, Color Depth: <span id="colorDepth"></span>
79
+ </h4>
80
+ </div>
81
+ <div id="info">
82
+ <h4>Test 1</h4>
83
+ Press "Home" button, then return to this app to see pause/resume.<br>
84
+ There should be "Running" entries between pause and resume since app continues to run in the background.
85
+ <h4>Test 2</h4>
86
+ Press "Load new page" button to load a new Cordova page.<br>
87
+ When returning, you should see
88
+ <ul>
89
+ <li>Page2: onunload</li>
90
+ <li>Page1: onload</li>
91
+ <li>Page1: Running</li>
92
+ </ul>
93
+ </div>
94
+ <div id="info">
95
+ <h4>Info for event testing:</h4>
96
+ <div id="status"></div>
97
+ </div>
98
+
99
+ <a href="index2.html" class="btn large" >Load new page</a>
100
+ <a href="javascript:" class="btn large" onclick="clearStatus();">Clear status</a>
101
+
102
+ <script>
103
+ document.getElementById('status').innerHTML = localStorage.lifecyclestatus;
104
+ </script>
105
+ </body>
106
+ </html>
107
+
108
+
@@ -0,0 +1,104 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Lifecycle Page 2</title>
7
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
8
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+
12
+ function onLoad() {
13
+ console.log("Page2: onload");
14
+ log("Page2: onload @ " + new Date().toLocaleTimeString());
15
+ document.addEventListener("deviceready", onDeviceReady, false);
16
+ }
17
+
18
+ function onUnLoaded() {
19
+ console.log("Page2: onunload");
20
+ log("Page2: onunload @ " + new Date().toLocaleTimeString());
21
+ }
22
+
23
+ function onDeviceReady() {
24
+ // Register the event listener
25
+ document.getElementById("platform").innerHTML = device.platform;
26
+ document.getElementById("version").innerHTML = device.version;
27
+ document.getElementById("uuid").innerHTML = device.uuid;
28
+ document.getElementById("name").innerHTML = device.name;
29
+ document.getElementById("width").innerHTML = screen.width;
30
+ document.getElementById("height").innerHTML = screen.height;
31
+ document.getElementById("colorDepth").innerHTML = screen.colorDepth;
32
+
33
+ document.addEventListener("pause", onPause, false);
34
+ document.addEventListener("resume", onResume, false);
35
+
36
+ window.setInterval(function() {
37
+ log("Page2: Running");
38
+ }, 2000);
39
+ }
40
+
41
+ function onPause() {
42
+ console.log("Page2: onpause");
43
+ log("Page2: onpause @ " + new Date().toLocaleTimeString());
44
+ }
45
+
46
+ function onResume() {
47
+ console.log("Page2: onresume");
48
+ log("Page2: onresume @ " + new Date().toLocaleTimeString());
49
+ }
50
+
51
+ function log(s) {
52
+ var el = document.getElementById('status');
53
+ var status = el.innerHTML + s + "<br>";
54
+ el.innerHTML = status;
55
+ localStorage.lifecyclestatus = status;
56
+ }
57
+
58
+ function clearStatus() {
59
+ console.log("clear()");
60
+ localStorage.lifecyclestatus = "";
61
+ document.getElementById('status').innerHTML = "";
62
+ }
63
+
64
+ </script>
65
+ </head>
66
+ <body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
67
+ <h1>Events</h1>
68
+ <div id="info">
69
+ <h4>
70
+ Platform: <span id="platform"> &nbsp;</span>, Version: <span
71
+ id="version">&nbsp;</span>
72
+ </h4>
73
+ <h4>
74
+ UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
75
+ </h4>
76
+ <h4>
77
+ Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
78
+ </span>, Color Depth: <span id="colorDepth"></span>
79
+ </h4>
80
+ </div>
81
+ <div id="info">
82
+ You should see<br>
83
+ <ul>
84
+ <li>Page1: onunload</li>
85
+ <li>Page2: onload</li>
86
+ <li>Page2: Running</li>
87
+ </ul>
88
+ Press "backbutton" to return to Page 1.
89
+ </div>
90
+ <div id="info">
91
+ <h4>Info for event testing:</h4>
92
+ <div id="status"></div>
93
+ </div>
94
+
95
+ <a href="index.html" class="btn large" >Load new page</a>
96
+ <a href="javascript:" class="btn large" onclick="clearStatus();">Clear status</a>
97
+
98
+ <script>
99
+ document.getElementById('status').innerHTML = localStorage.lifecyclestatus;
100
+ </script>
101
+ </body>
102
+ </html>
103
+
104
+
@@ -0,0 +1,150 @@
1
+ var deviceInfo = function() {
2
+ document.getElementById("platform").innerHTML = device.platform;
3
+ document.getElementById("version").innerHTML = device.version;
4
+ document.getElementById("uuid").innerHTML = device.uuid;
5
+ document.getElementById("name").innerHTML = device.name;
6
+ document.getElementById("width").innerHTML = screen.width;
7
+ document.getElementById("height").innerHTML = screen.height;
8
+ document.getElementById("colorDepth").innerHTML = screen.colorDepth;
9
+ var el = document.getElementById("cordova");
10
+ if (el) {
11
+ el.innerHTML = device.cordova;
12
+ }
13
+ };
14
+
15
+ var getLocation = function() {
16
+ var suc = function(p) {
17
+ alert(p.coords.latitude + " " + p.coords.longitude);
18
+ };
19
+ var locFail = function() {
20
+ };
21
+ navigator.geolocation.getCurrentPosition(suc, locFail);
22
+ };
23
+
24
+ var beep = function() {
25
+ navigator.notification.beep(2);
26
+ };
27
+
28
+ var vibrate = function() {
29
+ navigator.notification.vibrate(0);
30
+ };
31
+
32
+ function roundNumber(num) {
33
+ var dec = 3;
34
+ var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
35
+ return result;
36
+ }
37
+
38
+ var accelerationWatch = null;
39
+
40
+ function updateAcceleration(a) {
41
+ document.getElementById('x').innerHTML = roundNumber(a.x);
42
+ document.getElementById('y').innerHTML = roundNumber(a.y);
43
+ document.getElementById('z').innerHTML = roundNumber(a.z);
44
+ }
45
+
46
+ var toggleAccel = function() {
47
+ if (accelerationWatch !== null) {
48
+ navigator.accelerometer.clearWatch(accelerationWatch);
49
+ updateAcceleration({
50
+ x : "",
51
+ y : "",
52
+ z : ""
53
+ });
54
+ accelerationWatch = null;
55
+ } else {
56
+ var options = {};
57
+ options.frequency = 1000;
58
+ accelerationWatch = navigator.accelerometer.watchAcceleration(
59
+ updateAcceleration, function(ex) {
60
+ alert("accel fail (" + ex.name + ": " + ex.message + ")");
61
+ }, options);
62
+ }
63
+ };
64
+
65
+ var preventBehavior = function(e) {
66
+ e.preventDefault();
67
+ };
68
+
69
+ function dump_pic(data) {
70
+ var viewport = document.getElementById('viewport');
71
+ console.log(data);
72
+ viewport.style.display = "";
73
+ viewport.style.position = "absolute";
74
+ viewport.style.top = "10px";
75
+ viewport.style.left = "10px";
76
+ document.getElementById("test_img").src = "data:image/jpeg;base64," + data;
77
+ }
78
+
79
+ function fail(msg) {
80
+ alert(msg);
81
+ }
82
+
83
+ function show_pic() {
84
+ navigator.camera.getPicture(dump_pic, fail, {
85
+ quality : 50
86
+ });
87
+ }
88
+
89
+ function close() {
90
+ var viewport = document.getElementById('viewport');
91
+ viewport.style.position = "relative";
92
+ viewport.style.display = "none";
93
+ }
94
+
95
+ function contacts_success(contacts) {
96
+ alert(contacts.length
97
+ + ' contacts returned.'
98
+ + (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
99
+ : ''));
100
+ }
101
+
102
+ function get_contacts() {
103
+ var obj = new ContactFindOptions();
104
+ obj.filter = "";
105
+ obj.multiple = true;
106
+ navigator.contacts.find(
107
+ [ "displayName", "name" ], contacts_success,
108
+ fail, obj);
109
+ }
110
+
111
+ function check_network() {
112
+ var networkState = navigator.network.connection.type;
113
+
114
+ var states = {};
115
+ states[Connection.UNKNOWN] = 'Unknown connection';
116
+ states[Connection.ETHERNET] = 'Ethernet connection';
117
+ states[Connection.WIFI] = 'WiFi connection';
118
+ states[Connection.CELL_2G] = 'Cell 2G connection';
119
+ states[Connection.CELL_3G] = 'Cell 3G connection';
120
+ states[Connection.CELL_4G] = 'Cell 4G connection';
121
+ states[Connection.NONE] = 'No network connection';
122
+
123
+ confirm('Connection type:\n ' + states[networkState]);
124
+ }
125
+
126
+ var watchID = null;
127
+
128
+ function updateHeading(h) {
129
+ document.getElementById('h').innerHTML = h.magneticHeading;
130
+ }
131
+
132
+ function toggleCompass() {
133
+ if (watchID !== null) {
134
+ navigator.compass.clearWatch(watchID);
135
+ watchID = null;
136
+ updateHeading({ magneticHeading : "Off"});
137
+ } else {
138
+ var options = { frequency: 1000 };
139
+ watchID = navigator.compass.watchHeading(updateHeading, function(e) {
140
+ alert('Compass Error: ' + e.code);
141
+ }, options);
142
+ }
143
+ }
144
+
145
+ function init() {
146
+ // the next line makes it impossible to see Contacts on the HTC Evo since it
147
+ // doesn't have a scroll button
148
+ // document.addEventListener("touchmove", preventBehavior, false);
149
+ document.addEventListener("deviceready", deviceInfo, true);
150
+ }