Young преди 6 години
ревизия
7d22468955
променени са 100 файла, в които са добавени 6722 реда и са изтрити 0 реда
  1. 13 0
      .babelrc
  2. 5 0
      .gitignore
  3. 31 0
      README.md
  4. 26 0
      config.xml
  5. 52 0
      package.json
  6. 18 0
      plugins/android.json
  7. 18 0
      plugins/browser.json
  8. 37 0
      plugins/cordova-plugin-battery-status/CONTRIBUTING.md
  9. 202 0
      plugins/cordova-plugin-battery-status/LICENSE
  10. 5 0
      plugins/cordova-plugin-battery-status/NOTICE
  11. 112 0
      plugins/cordova-plugin-battery-status/README.md
  12. 3 0
      plugins/cordova-plugin-battery-status/RELEASENOTES.md
  13. 151 0
      plugins/cordova-plugin-battery-status/doc/de/README.md
  14. 132 0
      plugins/cordova-plugin-battery-status/doc/de/index.md
  15. 151 0
      plugins/cordova-plugin-battery-status/doc/es/README.md
  16. 132 0
      plugins/cordova-plugin-battery-status/doc/es/index.md
  17. 151 0
      plugins/cordova-plugin-battery-status/doc/fr/README.md
  18. 132 0
      plugins/cordova-plugin-battery-status/doc/fr/index.md
  19. 151 0
      plugins/cordova-plugin-battery-status/doc/it/README.md
  20. 132 0
      plugins/cordova-plugin-battery-status/doc/it/index.md
  21. 151 0
      plugins/cordova-plugin-battery-status/doc/ja/README.md
  22. 132 0
      plugins/cordova-plugin-battery-status/doc/ja/index.md
  23. 151 0
      plugins/cordova-plugin-battery-status/doc/ko/README.md
  24. 132 0
      plugins/cordova-plugin-battery-status/doc/ko/index.md
  25. 151 0
      plugins/cordova-plugin-battery-status/doc/pl/README.md
  26. 132 0
      plugins/cordova-plugin-battery-status/doc/pl/index.md
  27. 132 0
      plugins/cordova-plugin-battery-status/doc/ru/index.md
  28. 151 0
      plugins/cordova-plugin-battery-status/doc/zh/README.md
  29. 132 0
      plugins/cordova-plugin-battery-status/doc/zh/index.md
  30. 81 0
      plugins/cordova-plugin-battery-status/package.json
  31. 72 0
      plugins/cordova-plugin-battery-status/plugin.xml
  32. 163 0
      plugins/cordova-plugin-battery-status/src/android/BatteryListener.java
  33. 80 0
      plugins/cordova-plugin-battery-status/src/browser/BatteryProxy.js
  34. 40 0
      plugins/cordova-plugin-battery-status/src/ios/CDVBattery.h
  35. 148 0
      plugins/cordova-plugin-battery-status/src/ios/CDVBattery.m
  36. 125 0
      plugins/cordova-plugin-battery-status/src/windows/BatteryProxy.js
  37. BIN
      plugins/cordova-plugin-battery-status/src/windows/BatteryStatus.winmd
  38. 40 0
      plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus.sln
  39. 3 0
      plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/.npmignore
  40. 104 0
      plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/BatteryStatus.cs
  41. 72 0
      plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/BatteryStatus.csproj
  42. 44 0
      plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/Properties/AssemblyInfo.cs
  43. 14 0
      plugins/cordova-plugin-battery-status/tests/package.json
  44. 31 0
      plugins/cordova-plugin-battery-status/tests/plugin.xml
  45. 556 0
      plugins/cordova-plugin-battery-status/tests/tests.js
  46. 125 0
      plugins/cordova-plugin-battery-status/types/index.d.ts
  47. 109 0
      plugins/cordova-plugin-battery-status/www/battery.js
  48. 37 0
      plugins/cordova-plugin-whitelist/CONTRIBUTING.md
  49. 202 0
      plugins/cordova-plugin-whitelist/LICENSE
  50. 5 0
      plugins/cordova-plugin-whitelist/NOTICE
  51. 163 0
      plugins/cordova-plugin-whitelist/README.md
  52. 75 0
      plugins/cordova-plugin-whitelist/RELEASENOTES.md
  53. 148 0
      plugins/cordova-plugin-whitelist/doc/de/README.md
  54. 148 0
      plugins/cordova-plugin-whitelist/doc/es/README.md
  55. 148 0
      plugins/cordova-plugin-whitelist/doc/fr/README.md
  56. 148 0
      plugins/cordova-plugin-whitelist/doc/it/README.md
  57. 148 0
      plugins/cordova-plugin-whitelist/doc/ja/README.md
  58. 148 0
      plugins/cordova-plugin-whitelist/doc/ko/README.md
  59. 148 0
      plugins/cordova-plugin-whitelist/doc/pl/README.md
  60. 148 0
      plugins/cordova-plugin-whitelist/doc/zh/README.md
  61. 64 0
      plugins/cordova-plugin-whitelist/package.json
  62. 48 0
      plugins/cordova-plugin-whitelist/plugin.xml
  63. 161 0
      plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java
  64. 18 0
      plugins/fetch.json
  65. 11 0
      postcss.config.js
  66. 29 0
      res/README.md
  67. BIN
      res/icon/android/icon-36-ldpi.png
  68. BIN
      res/icon/android/icon-48-mdpi.png
  69. BIN
      res/icon/android/icon-72-hdpi.png
  70. BIN
      res/icon/android/icon-96-xhdpi.png
  71. BIN
      res/icon/bada-wac/icon-48-type5.png
  72. BIN
      res/icon/bada-wac/icon-50-type3.png
  73. BIN
      res/icon/bada-wac/icon-80-type4.png
  74. BIN
      res/icon/bada/icon-128.png
  75. BIN
      res/icon/blackberry/icon-80.png
  76. BIN
      res/icon/blackberry10/icon-80.png
  77. BIN
      res/icon/ios/icon-57-2x.png
  78. BIN
      res/icon/ios/icon-57.png
  79. BIN
      res/icon/ios/icon-72-2x.png
  80. BIN
      res/icon/ios/icon-72.png
  81. BIN
      res/icon/tizen/icon-128.png
  82. BIN
      res/icon/webos/icon-64.png
  83. BIN
      res/icon/windows-phone/icon-173-tile.png
  84. BIN
      res/icon/windows-phone/icon-48.png
  85. BIN
      res/icon/windows-phone/icon-62-tile.png
  86. BIN
      res/screen/android/screen-hdpi-landscape.png
  87. BIN
      res/screen/android/screen-hdpi-portrait.png
  88. BIN
      res/screen/android/screen-ldpi-landscape.png
  89. BIN
      res/screen/android/screen-ldpi-portrait.png
  90. BIN
      res/screen/android/screen-mdpi-landscape.png
  91. BIN
      res/screen/android/screen-mdpi-portrait.png
  92. BIN
      res/screen/android/screen-xhdpi-landscape.png
  93. BIN
      res/screen/android/screen-xhdpi-portrait.png
  94. BIN
      res/screen/bada-wac/screen-type3.png
  95. BIN
      res/screen/bada-wac/screen-type4.png
  96. BIN
      res/screen/bada-wac/screen-type5.png
  97. BIN
      res/screen/bada/screen-portrait.png
  98. BIN
      res/screen/blackberry/screen-225.png
  99. BIN
      res/screen/blackberry10/splash-1280x768.png
  100. 0 0
      res/screen/blackberry10/splash-720x720.png

+ 13 - 0
.babelrc

@@ -0,0 +1,13 @@
1
+{
2
+  "presets": [
3
+    ["es2015", {
4
+      "modules": false
5
+    }]
6
+  ],
7
+  "plugins": [
8
+    ["component", [{
9
+      "libraryName": "mint-ui",
10
+      "style": true
11
+    }]]
12
+  ]
13
+}

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
1
+.cache/
2
+node_modules/
3
+platforms/
4
+package-lock.json
5
+.vscode/

+ 31 - 0
README.md

@@ -0,0 +1,31 @@
1
+# 环境准备
2
+
3
+- nodejs环境
4
+    - npm
5
+    - 全局安装coedova(npm i -g cordova)
6
+- 安卓环境
7
+    - JAVA_HOME (JDK目录)
8
+    - ANDROID_HOME (安卓sdk目录)
9
+
10
+# 使用
11
+## 安装依赖
12
+```
13
+npm install
14
+```
15
+## 添加平台
16
+```
17
+cordova platform add [platform]
18
+
19
+- platform
20
+    - android
21
+    - ios
22
+    - browser
23
+    - ...
24
+```
25
+其他平台不一一列举,可以查看[官方说明](http://cordova.apache.org/docs/en/latest/guide/support/index.html)
26
+## 浏览器运行
27
+
28
+>npm run browser
29
+## 移动端运行
30
+
31
+>npm run android

+ 26 - 0
config.xml

@@ -0,0 +1,26 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<widget id="com.semsx.shoose.system.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
+    <name>Semsx</name>
4
+    <description>
5
+        A sample Apache Cordova application that use vue
6
+    </description>
7
+    <content src="index.html" />
8
+    <plugin name="cordova-plugin-whitelist" spec="1" />
9
+    <access origin="*" />
10
+    <allow-intent href="http://*/*" />
11
+    <allow-intent href="https://*/*" />
12
+    <allow-intent href="tel:*" />
13
+    <allow-intent href="sms:*" />
14
+    <allow-intent href="mailto:*" />
15
+    <allow-intent href="geo:*" />
16
+    <platform name="android">
17
+        <allow-intent href="market:*" />
18
+    </platform>
19
+    <platform name="ios">
20
+        <allow-intent href="itms:*" />
21
+        <allow-intent href="itms-apps:*" />
22
+    </platform>
23
+    <plugin name="cordova-plugin-battery-status" spec="^2.0.1" />
24
+    <engine name="android" spec="^7.1.1" />
25
+    <engine name="browser" spec="^5.0.4" />
26
+</widget>

+ 52 - 0
package.json

@@ -0,0 +1,52 @@
1
+{
2
+    "name": "vue-cordova-template",
3
+    "version": "1.0.0",
4
+    "description": "A sample Apache Cordova application that use vue",
5
+    "scripts": {
6
+        "browser": "cordova run browser",
7
+        "android": "cordova run android",
8
+        "build": "cross-env NODE_ENV=production webpack --config webpack.config.js",
9
+        "dev": "cross-env NODE_ENV=develement webpack-dev-server --config webpack.config.js"
10
+    },
11
+    "author": "imjianjian",
12
+    "license": "SIC",
13
+    "dependencies": {
14
+        "cordova-android": "^7.1.1",
15
+        "cordova-browser": "^5.0.4",
16
+        "cordova-plugin-battery-status": "^2.0.1",
17
+        "cordova-plugin-whitelist": "^1.3.3",
18
+        "mint-ui": "^2.2.13",
19
+        "vue": "^2.5.13",
20
+        "vue-router": "^3.0.1"
21
+    },
22
+    "devDependencies": {
23
+        "babel-preset-env": "^1.6.1",
24
+        "clean-webpack-plugin": "^0.1.18",
25
+        "cross-env": "^5.1.3",
26
+        "css-loader": "^0.28.8",
27
+        "extract-text-webpack-plugin": "^3.0.2",
28
+        "file-loader": "^1.1.11",
29
+        "html-webpack-plugin": "^2.30.1",
30
+        "html-withimg-loader": "^0.1.16",
31
+        "image-webpack-loader": "^3.4.2",
32
+        "node-sass": "^4.7.2",
33
+        "sass-loader": "^6.0.6",
34
+        "style-loader": "^0.19.1",
35
+        "uglifyjs-webpack-plugin": "^1.1.8",
36
+        "url-loader": "^0.6.2",
37
+        "vue-loader": "^14.1.1",
38
+        "vue-template-compiler": "^2.5.13",
39
+        "webpack": "^3.10.0",
40
+        "webpack-dev-server": "^2.11.1"
41
+    },
42
+    "cordova": {
43
+        "plugins": {
44
+            "cordova-plugin-whitelist": {},
45
+            "cordova-plugin-battery-status": {}
46
+        },
47
+        "platforms": [
48
+            "android",
49
+            "browser"
50
+        ]
51
+    }
52
+}

+ 18 - 0
plugins/android.json

@@ -0,0 +1,18 @@
1
+{
2
+  "prepare_queue": {
3
+    "installed": [],
4
+    "uninstalled": []
5
+  },
6
+  "config_munge": {
7
+    "files": {}
8
+  },
9
+  "installed_plugins": {
10
+    "cordova-plugin-battery-status": {
11
+      "PACKAGE_NAME": "io.cordova.hellocordova"
12
+    },
13
+    "cordova-plugin-whitelist": {
14
+      "PACKAGE_NAME": "io.cordova.hellocordova"
15
+    }
16
+  },
17
+  "dependent_plugins": {}
18
+}

+ 18 - 0
plugins/browser.json

@@ -0,0 +1,18 @@
1
+{
2
+  "prepare_queue": {
3
+    "installed": [],
4
+    "uninstalled": []
5
+  },
6
+  "config_munge": {
7
+    "files": {}
8
+  },
9
+  "installed_plugins": {
10
+    "cordova-plugin-battery-status": {
11
+      "PACKAGE_NAME": "io.cordova.hellocordova"
12
+    },
13
+    "cordova-plugin-whitelist": {
14
+      "PACKAGE_NAME": "io.cordova.hellocordova"
15
+    }
16
+  },
17
+  "dependent_plugins": {}
18
+}

+ 37 - 0
plugins/cordova-plugin-battery-status/CONTRIBUTING.md

@@ -0,0 +1,37 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+
22
+# Contributing to Apache Cordova
23
+
24
+Anyone can contribute to Cordova. And we need your contributions.
25
+
26
+There are multiple ways to contribute: report bugs, improve the docs, and
27
+contribute code.
28
+
29
+For instructions on this, start with the 
30
+[contribution overview](http://cordova.apache.org/contribute/).
31
+
32
+The details are explained there, but the important items are:
33
+ - Sign and submit an Apache ICLA (Contributor License Agreement).
34
+ - Have a Jira issue open that corresponds to your contribution.
35
+ - Run the tests so your patch doesn't break existing functionality.
36
+
37
+We look forward to your contributions!

+ 202 - 0
plugins/cordova-plugin-battery-status/LICENSE

@@ -0,0 +1,202 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+
177
+   END OF TERMS AND CONDITIONS
178
+
179
+   APPENDIX: How to apply the Apache License to your work.
180
+
181
+      To apply the Apache License to your work, attach the following
182
+      boilerplate notice, with the fields enclosed by brackets "[]"
183
+      replaced with your own identifying information. (Don't include
184
+      the brackets!)  The text should be enclosed in the appropriate
185
+      comment syntax for the file format. We also recommend that a
186
+      file or class name and description of purpose be included on the
187
+      same "printed page" as the copyright notice for easier
188
+      identification within third-party archives.
189
+
190
+   Copyright [yyyy] [name of copyright owner]
191
+
192
+   Licensed under the Apache License, Version 2.0 (the "License");
193
+   you may not use this file except in compliance with the License.
194
+   You may obtain a copy of the License at
195
+
196
+       http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+   Unless required by applicable law or agreed to in writing, software
199
+   distributed under the License is distributed on an "AS IS" BASIS,
200
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+   See the License for the specific language governing permissions and
202
+   limitations under the License.

+ 5 - 0
plugins/cordova-plugin-battery-status/NOTICE

@@ -0,0 +1,5 @@
1
+Apache Cordova
2
+Copyright 2012 The Apache Software Foundation
3
+
4
+This product includes software developed at
5
+The Apache Software Foundation (http://www.apache.org/).

+ 112 - 0
plugins/cordova-plugin-battery-status/README.md

@@ -0,0 +1,112 @@
1
+---
2
+title: Battery Status
3
+description: Get events for device battery level.
4
+---
5
+<!--
6
+# license: Licensed to the Apache Software Foundation (ASF) under one
7
+#         or more contributor license agreements.  See the NOTICE file
8
+#         distributed with this work for additional information
9
+#         regarding copyright ownership.  The ASF licenses this file
10
+#         to you under the Apache License, Version 2.0 (the
11
+#         "License"); you may not use this file except in compliance
12
+#         with the License.  You may obtain a copy of the License at
13
+#
14
+#           http://www.apache.org/licenses/LICENSE-2.0
15
+#
16
+#         Unless required by applicable law or agreed to in writing,
17
+#         software distributed under the License is distributed on an
18
+#         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+#         KIND, either express or implied.  See the License for the
20
+#         specific language governing permissions and limitations
21
+#         under the License.
22
+-->
23
+
24
+|AppVeyor|Travis CI|
25
+|:-:|:-:|
26
+|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-battery-status?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-battery-status)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-battery-status)|
27
+
28
+# cordova-plugin-battery-status
29
+
30
+This plugin provides an implementation of an old version of the [Battery Status Events API][w3c_spec]. It adds the following three events to the `window` object:
31
+
32
+* batterystatus
33
+* batterycritical
34
+* batterylow
35
+
36
+Applications may use `window.addEventListener` to attach an event listener for any of the above events after the `deviceready` event fires.
37
+
38
+## Installation
39
+
40
+    cordova plugin add cordova-plugin-battery-status
41
+
42
+## Status object
43
+
44
+All events in this plugin return an object with the following properties:
45
+
46
+- __level__: The battery charge percentage (0-100). _(Number)_
47
+- __isPlugged__: A boolean that indicates whether the device is plugged in. _(Boolean)_
48
+
49
+## batterystatus event
50
+
51
+Fires when the battery charge percentage changes by at least 1 percent, or when the device is plugged in or unplugged. Returns an [object][status_object] containing battery status.
52
+
53
+### Example
54
+
55
+    window.addEventListener("batterystatus", onBatteryStatus, false);
56
+
57
+    function onBatteryStatus(status) {
58
+        console.log("Level: " + status.level + " isPlugged: " + status.isPlugged);
59
+    }
60
+
61
+### Supported Platforms
62
+
63
+- iOS
64
+- Android
65
+- Windows
66
+- Browser (Chrome, Firefox, Opera)
67
+
68
+### Quirks: Android
69
+
70
+**Warning**: the Android implementation is greedy and prolonged use will drain the device's battery.
71
+
72
+## batterylow event
73
+
74
+Fires when the battery charge percentage reaches the low charge threshold. This threshold value is device-specific. Returns an [object][status_object] containing battery status.
75
+
76
+### Example
77
+
78
+    window.addEventListener("batterylow", onBatteryLow, false);
79
+
80
+    function onBatteryLow(status) {
81
+        alert("Battery Level Low " + status.level + "%");
82
+    }
83
+
84
+### Supported Platforms
85
+
86
+- iOS
87
+- Android
88
+- Windows
89
+- Browser (Chrome, Firefox, Opera)
90
+
91
+## batterycritical event
92
+
93
+Fires when the battery charge percentage reaches the critical charge threshold. This threshold value is device-specific. Returns an [object][status_object] containing battery status.
94
+
95
+### Example
96
+
97
+    window.addEventListener("batterycritical", onBatteryCritical, false);
98
+
99
+    function onBatteryCritical(status) {
100
+        alert("Battery Level Critical " + status.level + "%\nRecharge Soon!");
101
+    }
102
+
103
+### Supported Platforms
104
+
105
+- iOS
106
+- Android
107
+- Windows
108
+- Browser (Chrome, Firefox, Opera)
109
+
110
+
111
+[w3c_spec]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
112
+[status_object]: #status-object

+ 3 - 0
plugins/cordova-plugin-battery-status/RELEASENOTES.md

@@ -0,0 +1,3 @@
1
+### 2.0.1 (Dec 27, 2017)
2
+* [CB-13700](https://issues.apache.org/jira/browse/CB-13700) Fix to allow 2.0.0 version install (#62)
3
+

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/de/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+Dieses Plugin stellt eine Implementierung einer alten Version der [Batterie-Status-API](http://www.w3.org/TR/2011/WD-battery-status-20110915/) dar..
25
+
26
+Es fügt die folgenden drei `window` Events hinzu:
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## Installation
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Dieses Ereignis wird ausgelöst, wenn sich der Prozentsatz der Akkuladung um mindestens 1 Prozent ändert, oder wenn das Gerät aufgeladen oder vom Netz getrennt wird.
40
+
41
+Dem Batterie-Status-Event-Handler wird ein Objekt übergeben, das zwei Eigenschaften enthält:
42
+
43
+  * **Ebene**: der Prozentsatz der Batterieladung (0-100). *(Anzahl)*
44
+
45
+  * **IsPlugged**: ein boolescher Wert, der angibt, ob das Gerät eingesteckt ist *(boolesch)*
46
+
47
+Anwendungen sollten in der Regel `window.addEventListener` verwenden, um einen Event-Listener hinzuzufügen, nachdem das `deviceready` -Event ausgelöst wurde.
48
+
49
+### Unterstützte Plattformen
50
+
51
+  * Amazon Fire OS
52
+  * iOS
53
+  * Android
54
+  * BlackBerry 10
55
+  * Windows Phone 7 und 8
56
+  * Windows (nur Windows Phone 8.1)
57
+  * Tizen
58
+  * Firefox OS
59
+
60
+### Android und Amazon Fire OS Macken
61
+
62
+  * Warnung: die Android + Fire OS Implementierungen sind gierig und längerem Gebrauch lässt den Benutzer Batterie. 
63
+
64
+### Windows Phone 7 und 8 Eigenarten
65
+
66
+Windows Phone 7 bietet keine systemeigenen APIs um das Batterie-Niveau zu bestimmen, so dass die `level` -Eigenschaft ist nicht verfügbar. Der `isPlugged` -Parameter wird unterstützt.
67
+
68
+### Windows-Eigenheiten
69
+
70
+Windows Phone 8.1 unterstützt keine `IsPlugged` Parameter. `Der Parameter <em>wird</em> unterstützt.`
71
+
72
+### Beispiel
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+Das Ereignis wird ausgelöst, wenn der Prozentsatz der Batterieladung den kritischen Akku-Schwellenwert erreicht hat. Der Wert ist gerätespezifisch.
85
+
86
+Der `batterycritical` Handler übergibt ein Objekt mit zwei Eigenschaften:
87
+
88
+  * **Ebene**: der Prozentsatz der Batterieladung (0-100). *(Anzahl)*
89
+
90
+  * **IsPlugged**: ein boolescher Wert, der angibt, ob das Gerät eingesteckt ist *(boolesch)*
91
+
92
+Anwendungen sollten in der Regel `window.addEventListener` verwenden, um einen Event-Listener hinzuzufügen, nachdem das `deviceready` -Event ausgelöst wurde.
93
+
94
+### Unterstützte Plattformen
95
+
96
+  * Amazon Fire OS
97
+  * iOS
98
+  * Android
99
+  * BlackBerry 10
100
+  * Tizen
101
+  * Firefox OS
102
+  * Windows (nur Windows Phone 8.1)
103
+
104
+### Windows-Eigenheiten
105
+
106
+Windows Phone 8.1 wird `batterycritical` Ereignis unabhängig angeschlossen Zustand ausgelöst, da es nicht unterstützt wird.
107
+
108
+### Beispiel
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+Das Ereignis wird ausgelöst, wenn der Prozentsatz der Batterieladung den kritischen Akku-Schwellenwert erreicht hat. Der Wert ist gerätespezifisch.
121
+
122
+Der `batterylow` Handler übergibt ein Objekt mit zwei Eigenschaften:
123
+
124
+  * **Ebene**: der Prozentsatz der Batterieladung (0-100). *(Anzahl)*
125
+
126
+  * **IsPlugged**: ein boolescher Wert, der angibt, ob das Gerät eingesteckt ist *(boolesch)*
127
+
128
+Anwendungen sollten in der Regel `window.addEventListener` verwenden, um einen Event-Listener hinzuzufügen, nachdem das `deviceready` -Event ausgelöst wurde.
129
+
130
+### Unterstützte Plattformen
131
+
132
+  * Amazon Fire OS
133
+  * iOS
134
+  * Android
135
+  * BlackBerry 10
136
+  * Tizen
137
+  * Firefox OS
138
+  * Windows (nur Windows Phone 8.1)
139
+
140
+### Windows-Eigenheiten
141
+
142
+Windows Phone 8.1 wird `batterylow` Ereignis unabhängig angeschlossen Zustand ausgelöst, da es nicht unterstützt wird.
143
+
144
+### Beispiel
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/de/index.md

@@ -0,0 +1,132 @@
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
+
20
+# org.Apache.Cordova.Battery-status
21
+
22
+Dieses Plugin stellt eine Implementierung einer alten Version der [Batterie-Status-API][1] dar..
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+Es fügt die folgenden drei `window` Events hinzu:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## Installation
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Dieses Ereignis wird ausgelöst, wenn sich der Prozentsatz der Akkuladung um mindestens 1 Prozent ändert, oder wenn das Gerät aufgeladen oder vom Netz getrennt wird.
40
+
41
+Dem Batterie-Status-Event-Handler wird ein Objekt übergeben, das zwei Eigenschaften enthält:
42
+
43
+*   **Ebene**: der Prozentsatz der Batterieladung (0-100). *(Anzahl)*
44
+
45
+*   **IsPlugged**: ein boolescher Wert, der angibt, ob das Gerät eingesteckt ist *(boolesch)*
46
+
47
+Anwendungen sollten in der Regel `window.addEventListener` verwenden, um einen Event-Listener hinzuzufügen, nachdem das `deviceready` -Event ausgelöst wurde.
48
+
49
+### Unterstützte Plattformen
50
+
51
+*   Amazon Fire OS
52
+*   iOS
53
+*   Android
54
+*   BlackBerry 10
55
+*   Windows Phone 7 und 8
56
+*   Tizen
57
+*   Firefox OS
58
+
59
+### Windows Phone 7 und 8 Eigenarten
60
+
61
+Windows Phone 7 bietet keine systemeigenen APIs um das Batterie-Niveau zu bestimmen, so dass die `level` -Eigenschaft ist nicht verfügbar. Der `isPlugged` -Parameter wird unterstützt.
62
+
63
+### Beispiel
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+Das Ereignis wird ausgelöst, wenn der Prozentsatz der Batterieladung den kritischen Akku-Schwellenwert erreicht hat. Der Wert ist gerätespezifisch.
76
+
77
+Der `batterycritical` Handler übergibt ein Objekt mit zwei Eigenschaften:
78
+
79
+*   **Ebene**: der Prozentsatz der Batterieladung (0-100). *(Anzahl)*
80
+
81
+*   **IsPlugged**: ein boolescher Wert, der angibt, ob das Gerät eingesteckt ist *(boolesch)*
82
+
83
+Anwendungen sollten in der Regel `window.addEventListener` verwenden, um einen Event-Listener hinzuzufügen, nachdem das `deviceready` -Event ausgelöst wurde.
84
+
85
+### Unterstützte Plattformen
86
+
87
+*   Amazon Fire OS
88
+*   iOS
89
+*   Android
90
+*   BlackBerry 10
91
+*   Tizen
92
+*   Firefox OS
93
+
94
+### Beispiel
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+Das Ereignis wird ausgelöst, wenn der Prozentsatz der Batterieladung den kritischen Akku-Schwellenwert erreicht hat. Der Wert ist gerätespezifisch.
107
+
108
+Der `batterylow` Handler übergibt ein Objekt mit zwei Eigenschaften:
109
+
110
+*   **Ebene**: der Prozentsatz der Batterieladung (0-100). *(Anzahl)*
111
+
112
+*   **IsPlugged**: ein boolescher Wert, der angibt, ob das Gerät eingesteckt ist *(boolesch)*
113
+
114
+Anwendungen sollten in der Regel `window.addEventListener` verwenden, um einen Event-Listener hinzuzufügen, nachdem das `deviceready` -Event ausgelöst wurde.
115
+
116
+### Unterstützte Plattformen
117
+
118
+*   Amazon Fire OS
119
+*   iOS
120
+*   Android
121
+*   BlackBerry 10
122
+*   Tizen
123
+*   Firefox OS
124
+
125
+### Beispiel
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/es/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+Este plugin proporciona una implementación de una versión antigua de la [Batería estado eventos API](http://www.w3.org/TR/2011/WD-battery-status-20110915/).
25
+
26
+Agrega los siguientes tres `window` eventos:
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## Instalación
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Este evento se desencadena cuando cambia el porcentaje de carga de la batería en menos de 1 por ciento, o si el aparato está enchufado o desenchufado.
40
+
41
+El controlador del estado de batería se pasa un objeto que contiene dos propiedades:
42
+
43
+  * **level**: el porcentaje de carga de la batería (0-100). *(Número)*
44
+
45
+  * **isPlugged**: un valor booleano que indica si el dispositivo está conectado pulg *(Boolean)*
46
+
47
+Las aplicaciones normalmente deben utilizar `window.addEventListener` para conectar un detector de eventos después de la `deviceready` evento incendios.
48
+
49
+### Plataformas soportadas
50
+
51
+  * Amazon fire OS
52
+  * iOS
53
+  * Android
54
+  * BlackBerry 10
55
+  * Windows Phone 7 y 8
56
+  * Windows (sólo Windows Phone 8.1)
57
+  * Tizen
58
+  * Firefox OS
59
+
60
+### Android y Amazon fuego OS caprichos
61
+
62
+  * ADVERTENCIA: el Android + fuego OS implementaciones son codiciosas y uso prolongado agotará la batería del usuario. 
63
+
64
+### Windows Phone 7 y 8 rarezas
65
+
66
+Windows Phone 7 no proporciona una API nativa para determinar el nivel de batería, lo que `level` no está disponible. El `isPlugged` parámetro *es* apoyado.
67
+
68
+### Windows rarezas
69
+
70
+8.1 de Windows Phone no permite `isPlugged` parámetro. El parámetro `level` *es* apoyado.
71
+
72
+### Ejemplo
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+El evento se desencadena cuando el porcentaje de carga de la batería ha alcanzado el umbral crítico de batería. El valor es específica del dispositivo.
85
+
86
+El controlador `batterycritical` se pasa un objeto que contiene dos propiedades:
87
+
88
+  * **level**: el porcentaje de carga de la batería (0-100). *(Número)*
89
+
90
+  * **isPlugged**: un valor booleano que indica si el dispositivo está conectado pulg *(Boolean)*
91
+
92
+Las aplicaciones normalmente deben utilizar `window.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`.
93
+
94
+### Plataformas soportadas
95
+
96
+  * Amazon fire OS
97
+  * iOS
98
+  * Android
99
+  * BlackBerry 10
100
+  * Tizen
101
+  * Firefox OS
102
+  * Windows (sólo Windows Phone 8.1)
103
+
104
+### Windows rarezas
105
+
106
+8.1 de Windows Phone se disparará `batterycritical` evento independientemente del estado tapado porque no es compatible.
107
+
108
+### Ejemplo
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+El evento se desencadena cuando el porcentaje de carga de la batería ha alcanzado el umbral de batería baja, el valor específico del dispositivo.
121
+
122
+El controlador de `batterylow` se pasa un objeto que contiene dos propiedades:
123
+
124
+  * **level**: el porcentaje de carga de la batería (0-100). *(Número)*
125
+
126
+  * **isPlugged**: un valor booleano que indica si el dispositivo está conectado pulg *(Boolean)*
127
+
128
+Las aplicaciones normalmente deben utilizar `window.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`.
129
+
130
+### Plataformas soportadas
131
+
132
+  * Amazon fire OS
133
+  * iOS
134
+  * Android
135
+  * BlackBerry 10
136
+  * Tizen
137
+  * Firefox OS
138
+  * Windows (sólo Windows Phone 8.1)
139
+
140
+### Windows rarezas
141
+
142
+8.1 de Windows Phone se disparará `batterylow` evento independientemente del estado tapado porque no es compatible.
143
+
144
+### Ejemplo
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/es/index.md

@@ -0,0 +1,132 @@
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
+
20
+# cordova-plugin-battery-status
21
+
22
+Este plugin proporciona una implementación de una versión antigua de la [Batería estado eventos API][1].
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+Agrega los siguientes tres `window` eventos:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## Instalación
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Este evento se desencadena cuando cambia el porcentaje de carga de la batería en menos de 1 por ciento, o si el aparato está enchufado o desenchufado.
40
+
41
+El controlador del estado de batería se pasa un objeto que contiene dos propiedades:
42
+
43
+*   **level**: el porcentaje de carga de la batería (0-100). *(Número)*
44
+
45
+*   **isPlugged**: un valor booleano que indica si el dispositivo está conectado pulg *(Boolean)*
46
+
47
+Las aplicaciones normalmente deben utilizar `window.addEventListener` para conectar un detector de eventos después de la `deviceready` evento incendios.
48
+
49
+### Plataformas soportadas
50
+
51
+*   Amazon fire OS
52
+*   iOS
53
+*   Android
54
+*   BlackBerry 10
55
+*   Windows Phone 7 y 8
56
+*   Tizen
57
+*   Firefox OS
58
+
59
+### Windows Phone 7 y 8 rarezas
60
+
61
+Windows Phone 7 no proporciona una API nativa para determinar el nivel de batería, lo que `level` no está disponible. El `isPlugged` parámetro *es* apoyado.
62
+
63
+### Ejemplo
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+El evento se desencadena cuando el porcentaje de carga de la batería ha alcanzado el umbral crítico de batería. El valor es específica del dispositivo.
76
+
77
+El controlador `batterycritical` se pasa un objeto que contiene dos propiedades:
78
+
79
+*   **level**: el porcentaje de carga de la batería (0-100). *(Número)*
80
+
81
+*   **isPlugged**: un valor booleano que indica si el dispositivo está conectado pulg *(Boolean)*
82
+
83
+Las aplicaciones normalmente deben utilizar `window.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`.
84
+
85
+### Plataformas soportadas
86
+
87
+*   Amazon fire OS
88
+*   iOS
89
+*   Android
90
+*   BlackBerry 10
91
+*   Tizen
92
+*   Firefox OS
93
+
94
+### Ejemplo
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+El evento se desencadena cuando el porcentaje de carga de la batería ha alcanzado el umbral de batería baja, el valor específico del dispositivo.
107
+
108
+El controlador de `batterylow` se pasa un objeto que contiene dos propiedades:
109
+
110
+*   **level**: el porcentaje de carga de la batería (0-100). *(Número)*
111
+
112
+*   **isPlugged**: un valor booleano que indica si el dispositivo está conectado pulg *(Boolean)*
113
+
114
+Las aplicaciones normalmente deben utilizar `window.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`.
115
+
116
+### Plataformas soportadas
117
+
118
+*   Amazon fire OS
119
+*   iOS
120
+*   Android
121
+*   BlackBerry 10
122
+*   Tizen
123
+*   Firefox OS
124
+
125
+### Ejemplo
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/fr/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# Cordova-plugin-batterie-statut
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+Ce plugin fournit une implémentation d'une ancienne version de [Batterie Status événements API](http://www.w3.org/TR/2011/WD-battery-status-20110915/).
25
+
26
+Il ajoute les trois `window` des événements :
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## Installation
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+L'évènement se déclenche lorsque le taux de charge de la batterie gagne ou perd au moins un pourcent, ou quand l'appareil est branché ou débranché.
40
+
41
+Le gestionnaire est appelé avec un objet contenant deux propriétés :
42
+
43
+  * **level** : le taux de charge de la batterie (0-100). *(Number)*
44
+
45
+  * **isPlugged** : un booléen indiquant si l'appareil est en cours de chargement ou non. *(Boolean)*
46
+
47
+Les applications doivent généralement utiliser `window.addEventListener` pour attacher un écouteur d'événements après le `deviceready` événement se déclenche.
48
+
49
+### Plates-formes supportées
50
+
51
+  * Amazon Fire OS
52
+  * iOS
53
+  * Android
54
+  * BlackBerry 10
55
+  * Windows Phone 7 et 8
56
+  * Windows (Windows Phone 8.1 uniquement)
57
+  * Paciarelli
58
+  * Firefox OS
59
+
60
+### Android et Amazon Fire OS bizarreries
61
+
62
+  * AVERTISSEMENT : l'Android + feu OS implémentations sont avides et utilisation prolongée s'évacuera pile de l'utilisateur. 
63
+
64
+### Notes au sujet de Windows Phone 7 et 8
65
+
66
+Windows Phone 7 ne fournit pas d'API native pour déterminer le niveau de la batterie, de ce fait la propriété `level` n'est pas disponible. La propriété `isPlugged` *est* quant à elle prise en charge.
67
+
68
+### Bizarreries de Windows
69
+
70
+8.1 de Windows Phone ne prend pas de paramètre `isPlugged` . Le `level` paramètre *is* pris en charge.
71
+
72
+### Exemple
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+L'évènement se déclenche lorsque le pourcentage de charge de la batterie a atteint un seuil critique. Cette valeur est spécifique à l'appareil.
85
+
86
+Le gestionnaire `batterycritical` est appelé avec un objet contenant deux propriétés :
87
+
88
+  * **level** : le taux de charge de la batterie (0-100). *(Number)*
89
+
90
+  * **isPlugged** : un booléen indiquant si l'appareil est en cours de chargement ou non. *(Boolean)*
91
+
92
+Les applications devraient en général utiliser `window.addEventListener` pour attacher un écouteur d'évènements, une fois l'évènement `deviceready` déclenché.
93
+
94
+### Plates-formes supportées
95
+
96
+  * Amazon Fire OS
97
+  * iOS
98
+  * Android
99
+  * BlackBerry 10
100
+  * Paciarelli
101
+  * Firefox OS
102
+  * Windows (Windows Phone 8.1 uniquement)
103
+
104
+### Bizarreries de Windows
105
+
106
+Windows Phone 8.1 tirera `batterycritical` épreuve que l'État branché car il n'est pas supportée.
107
+
108
+### Exemple
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+L'évènement se déclenche lorsque le pourcentage de charge de la batterie a atteint un niveau faible, cette valeur est spécifique à l'appareil.
121
+
122
+Le gestionnaire `batterylow` est appelé avec un objet contenant deux propriétés :
123
+
124
+  * **level** : le taux de charge de la batterie (0-100). *(Number)*
125
+
126
+  * **isPlugged** : un booléen indiquant si l'appareil est en cours de chargement ou non. *(Boolean)*
127
+
128
+Les applications devraient en général utiliser `window.addEventListener` pour attacher un écouteur d'évènements, une fois l'évènement `deviceready` déclenché.
129
+
130
+### Plates-formes supportées
131
+
132
+  * Amazon Fire OS
133
+  * iOS
134
+  * Android
135
+  * BlackBerry 10
136
+  * Paciarelli
137
+  * Firefox OS
138
+  * Windows (Windows Phone 8.1 uniquement)
139
+
140
+### Bizarreries de Windows
141
+
142
+Windows Phone 8.1 tirera `batterylow` épreuve que l'État branché car il n'est pas supportée.
143
+
144
+### Exemple
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/fr/index.md

@@ -0,0 +1,132 @@
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
+
20
+# org.Apache.Cordova.Battery inscrits
21
+
22
+Ce plugin fournit une implémentation d'une ancienne version de [Batterie Status événements API][1].
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+Il ajoute les trois `window` des événements :
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## Installation
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+L'évènement se déclenche lorsque le taux de charge de la batterie gagne ou perd au moins un pourcent, ou quand l'appareil est branché ou débranché.
40
+
41
+Le gestionnaire est appelé avec un objet contenant deux propriétés :
42
+
43
+*   **level** : le taux de charge de la batterie (0-100). *(Number)*
44
+
45
+*   **isPlugged** : un booléen indiquant si l'appareil est en cours de chargement ou non. *(Boolean)*
46
+
47
+Les applications doivent généralement utiliser `window.addEventListener` pour attacher un écouteur d'événements après le `deviceready` événement se déclenche.
48
+
49
+### Plates-formes prises en charge
50
+
51
+*   Amazon Fire OS
52
+*   iOS
53
+*   Android
54
+*   BlackBerry 10
55
+*   Windows Phone 7 et 8
56
+*   Paciarelli
57
+*   Firefox OS
58
+
59
+### Notes au sujet de Windows Phone 7 et 8
60
+
61
+Windows Phone 7 ne fournit pas d'API native pour déterminer le niveau de la batterie, de ce fait la propriété `level` n'est pas disponible. La propriété `isPlugged` *est* quant à elle prise en charge.
62
+
63
+### Exemple
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+L'évènement se déclenche lorsque le pourcentage de charge de la batterie a atteint un seuil critique. Cette valeur est spécifique à l'appareil.
76
+
77
+Le gestionnaire `batterycritical` est appelé avec un objet contenant deux propriétés :
78
+
79
+*   **niveau**: le pourcentage de charge de la batterie (0-100). *(Nombre)*
80
+
81
+*   **isPlugged**: valeur booléenne qui indique si l'appareil n'est branché *(Boolean)*
82
+
83
+Les applications devraient en général utiliser `window.addEventListener` pour attacher un écouteur d'évènements, une fois l'évènement `deviceready` déclenché.
84
+
85
+### Plates-formes prises en charge
86
+
87
+*   Amazon Fire OS
88
+*   iOS
89
+*   Android
90
+*   BlackBerry 10
91
+*   Paciarelli
92
+*   Firefox OS
93
+
94
+### Exemple
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+L'évènement se déclenche lorsque le pourcentage de charge de la batterie a atteint un niveau faible, cette valeur est spécifique à l'appareil.
107
+
108
+Le gestionnaire `batterylow` est appelé avec un objet contenant deux propriétés :
109
+
110
+*   **niveau**: le pourcentage de charge de la batterie (0-100). *(Nombre)*
111
+
112
+*   **isPlugged**: valeur booléenne qui indique si l'appareil n'est branché *(Boolean)*
113
+
114
+Les applications devraient en général utiliser `window.addEventListener` pour attacher un écouteur d'évènements, une fois l'évènement `deviceready` déclenché.
115
+
116
+### Plates-formes prises en charge
117
+
118
+*   Amazon Fire OS
119
+*   iOS
120
+*   Android
121
+*   BlackBerry 10
122
+*   Paciarelli
123
+*   Firefox OS
124
+
125
+### Exemple
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/it/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+Questo plugin fornisce un'implementazione di una vecchia versione dell' [API di eventi lo stato della batteria](http://www.w3.org/TR/2011/WD-battery-status-20110915/).
25
+
26
+Aggiunge i seguenti tre `window` eventi:
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## Installazione
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Questo evento viene generato quando la percentuale di carica della batteria cambia almeno l'1 per cento, o se il dispositivo è collegato o scollegato.
40
+
41
+Il gestore di stato della batteria viene passato un oggetto che contiene due proprietà:
42
+
43
+  * **livello**: la percentuale di carica della batteria (0-100). *(Numero)*
44
+
45
+  * **isPlugged**: un valore booleano che indica se il dispositivo è collegato poll *(Boolean)*
46
+
47
+Applicazioni in genere è necessario utilizzare `window.addEventListener` per fissare un listener di eventi dopo il `deviceready` evento incendi.
48
+
49
+### Piattaforme supportate
50
+
51
+  * Amazon fuoco OS
52
+  * iOS
53
+  * Android
54
+  * BlackBerry 10
55
+  * Windows Phone 7 e 8
56
+  * Windows (solo Windows Phone 8.1)
57
+  * Tizen
58
+  * Firefox OS
59
+
60
+### Android e Amazon fuoco OS stranezze
61
+
62
+  * Avviso: il Android + fuoco OS implementazioni sono avide e uso prolungato si scaricherà la batteria dell'utente. 
63
+
64
+### Windows Phone 7 e 8 stranezze
65
+
66
+Windows Phone 7 non fornisce le API native per determinare il livello della batteria, così la `level` proprietà non è disponibile. Il `isPlugged` parametro *è* supportato.
67
+
68
+### Stranezze di Windows
69
+
70
+8.1 di Windows Phone non supporta il parametro `isPlugged` . Il `level` parametro *is* supportata.
71
+
72
+### Esempio
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+L'evento viene generato quando la percentuale di carica della batteria ha raggiunto la soglia critica di batteria. Il valore è specifico del dispositivo.
85
+
86
+Il `batterycritical` gestore viene passato un oggetto che contiene due proprietà:
87
+
88
+  * **livello**: la percentuale di carica della batteria (0-100). *(Numero)*
89
+
90
+  * **isPlugged**: un valore booleano che indica se il dispositivo è collegato poll *(Boolean)*
91
+
92
+Applicazioni in genere è necessario utilizzare `window.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi.
93
+
94
+### Piattaforme supportate
95
+
96
+  * Amazon fuoco OS
97
+  * iOS
98
+  * Android
99
+  * BlackBerry 10
100
+  * Tizen
101
+  * Firefox OS
102
+  * Windows (solo Windows Phone 8.1)
103
+
104
+### Stranezze di Windows
105
+
106
+Windows Phone 8.1 vengano attivati `batterycritical` evento indipendentemente dallo stato tappato, come non è supportato.
107
+
108
+### Esempio
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+L'evento viene generato quando la percentuale di carica della batteria ha raggiunto la soglia di batteria scarica, il valore specifico del dispositivo.
121
+
122
+Il `batterylow` gestore viene passato un oggetto che contiene due proprietà:
123
+
124
+  * **livello**: la percentuale di carica della batteria (0-100). *(Numero)*
125
+
126
+  * **isPlugged**: un valore booleano che indica se il dispositivo è collegato poll *(Boolean)*
127
+
128
+Applicazioni in genere è necessario utilizzare `window.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi.
129
+
130
+### Piattaforme supportate
131
+
132
+  * Amazon fuoco OS
133
+  * iOS
134
+  * Android
135
+  * BlackBerry 10
136
+  * Tizen
137
+  * Firefox OS
138
+  * Windows (solo Windows Phone 8.1)
139
+
140
+### Stranezze di Windows
141
+
142
+Windows Phone 8.1 vengano attivati `batterylow` evento indipendentemente dallo stato tappato, come non è supportato.
143
+
144
+### Esempio
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/it/index.md

@@ -0,0 +1,132 @@
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
+
20
+# org.apache.Cordova.Battery-status
21
+
22
+Questo plugin fornisce un'implementazione di una vecchia versione dell' [API di eventi lo stato della batteria][1].
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+Aggiunge i seguenti tre `window` eventi:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## Installazione
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Questo evento viene generato quando la percentuale di carica della batteria cambia almeno l'1 per cento, o se il dispositivo è collegato o scollegato.
40
+
41
+Il gestore di stato della batteria viene passato un oggetto che contiene due proprietà:
42
+
43
+*   **livello**: la percentuale di carica della batteria (0-100). *(Numero)*
44
+
45
+*   **isPlugged**: un valore booleano che indica se il dispositivo è collegato poll *(Boolean)*
46
+
47
+Applicazioni in genere è necessario utilizzare `window.addEventListener` per fissare un listener di eventi dopo il `deviceready` evento incendi.
48
+
49
+### Piattaforme supportate
50
+
51
+*   Amazon fuoco OS
52
+*   iOS
53
+*   Android
54
+*   BlackBerry 10
55
+*   Windows Phone 7 e 8
56
+*   Tizen
57
+*   Firefox OS
58
+
59
+### Windows Phone 7 e 8 stranezze
60
+
61
+Windows Phone 7 non fornisce le API native per determinare il livello della batteria, così la `level` proprietà non è disponibile. Il `isPlugged` parametro *è* supportato.
62
+
63
+### Esempio
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+L'evento viene generato quando la percentuale di carica della batteria ha raggiunto la soglia critica di batteria. Il valore è specifico del dispositivo.
76
+
77
+Il `batterycritical` gestore viene passato un oggetto che contiene due proprietà:
78
+
79
+*   **livello**: la percentuale di carica della batteria (0-100). *(Numero)*
80
+
81
+*   **isPlugged**: un valore booleano che indica se il dispositivo è collegato poll *(Boolean)*
82
+
83
+Applicazioni in genere è necessario utilizzare `window.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi.
84
+
85
+### Piattaforme supportate
86
+
87
+*   Amazon fuoco OS
88
+*   iOS
89
+*   Android
90
+*   BlackBerry 10
91
+*   Tizen
92
+*   Firefox OS
93
+
94
+### Esempio
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+L'evento viene generato quando la percentuale di carica della batteria ha raggiunto la soglia di batteria scarica, il valore specifico del dispositivo.
107
+
108
+Il `batterylow` gestore viene passato un oggetto che contiene due proprietà:
109
+
110
+*   **livello**: la percentuale di carica della batteria (0-100). *(Numero)*
111
+
112
+*   **isPlugged**: un valore booleano che indica se il dispositivo è collegato poll *(Boolean)*
113
+
114
+Applicazioni in genere è necessario utilizzare `window.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi.
115
+
116
+### Piattaforme supportate
117
+
118
+*   Amazon fuoco OS
119
+*   iOS
120
+*   Android
121
+*   BlackBerry 10
122
+*   Tizen
123
+*   Firefox OS
124
+
125
+### Esempio
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/ja/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+このプラグインは、[バッテリ ステータス イベント API](http://www.w3.org/TR/2011/WD-battery-status-20110915/)の旧バージョンの実装を提供します.
25
+
26
+次の 3 つを追加します `window` イベント。
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## インストール
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+バッテリーの充電の割合 1% 以上によって変更されたとき、またはデバイス接続している場合に発生します。
40
+
41
+バッテリ状態ハンドラーは 2 つのプロパティを格納しているオブジェクトに渡されます。
42
+
43
+  * **レベル**: バッテリーの充電量 (0-100) の割合。*(数)*
44
+
45
+  * **起こしたり**: デバイスが接続されてインチ*(ブール値)*かどうかを示すブール値
46
+
47
+通常アプリケーションに使用する必要があります `window.addEventListener` 後のイベント リスナーをアタッチする、 `deviceready` イベントが発生します。
48
+
49
+### サポートされているプラットフォーム
50
+
51
+  * アマゾン火 OS
52
+  * iOS
53
+  * アンドロイド
54
+  * ブラックベリー 10
55
+  * Windows Phone 7 と 8
56
+  * Windows (Windows Phone 8.1 のみ)
57
+  * Tizen
58
+  * Firefox の OS
59
+
60
+### アンドロイドとアマゾン火 OS 癖
61
+
62
+  * 警告: Android + 火 OS 実装は欲張りな長期使用ユーザーのバッテリーを排出するでしょう。 
63
+
64
+### Windows Phone 7 と 8 癖
65
+
66
+Windows Phone 7 は、バッテリーのレベルを決定するネイティブ Api を提供しませんので、 `level` プロパティは使用できません。`isPlugged`パラメーター*が*サポートされています。
67
+
68
+### Windows の癖
69
+
70
+Windows Phone 8.1`isPlugged`パラメーターをサポートしていません。 `level`のパラメーター*is*サポートされています。
71
+
72
+### 例
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+バッテリーの充電の割合がバッテリ切れのしきい値に達したときに発生します。値は、デバイス固有です。
85
+
86
+`batterycritical`ハンドラーは 2 つのプロパティを格納しているオブジェクトに渡されます。
87
+
88
+  * **レベル**: バッテリーの充電量 (0-100) の割合。*(数)*
89
+
90
+  * **起こしたり**: デバイスが接続されてインチ*(ブール値)*かどうかを示すブール値
91
+
92
+通常アプリケーションに使用する必要があります `window.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。
93
+
94
+### サポートされているプラットフォーム
95
+
96
+  * アマゾン火 OS
97
+  * iOS
98
+  * アンドロイド
99
+  * ブラックベリー 10
100
+  * Tizen
101
+  * Firefox の OS
102
+  * Windows (Windows Phone 8.1 のみ)
103
+
104
+### Windows の癖
105
+
106
+それはサポートされていないために、Windows Phone 8.1 は接続状態に関係なく`batterycritical`イベントを発生します。
107
+
108
+### 例
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+バッテリーの充電の割合がバッテリ低下しきい値、デバイス固有の値に達したときに発生します。
121
+
122
+`batterylow`ハンドラーは 2 つのプロパティを格納しているオブジェクトに渡されます。
123
+
124
+  * **レベル**: バッテリーの充電量 (0-100) の割合。*(数)*
125
+
126
+  * **起こしたり**: デバイスが接続されてインチ*(ブール値)*かどうかを示すブール値
127
+
128
+通常アプリケーションに使用する必要があります `window.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。
129
+
130
+### サポートされているプラットフォーム
131
+
132
+  * アマゾン火 OS
133
+  * iOS
134
+  * アンドロイド
135
+  * ブラックベリー 10
136
+  * Tizen
137
+  * Firefox の OS
138
+  * Windows (Windows Phone 8.1 のみ)
139
+
140
+### Windows の癖
141
+
142
+それはサポートされていないために、Windows Phone 8.1 は接続状態に関係なく`batterylow`イベントを発生します。
143
+
144
+### 例
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/ja/index.md

@@ -0,0 +1,132 @@
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
+
20
+# cordova-plugin-battery ステータス
21
+
22
+このプラグインは、[バッテリ ステータス イベント API][1]の旧バージョンの実装を提供します.
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+次の 3 つを追加します `window` イベント。
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## インストール
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+バッテリーの充電の割合 1% 以上によって変更されたとき、またはデバイス接続している場合に発生します。
40
+
41
+バッテリ状態ハンドラーは 2 つのプロパティを格納しているオブジェクトに渡されます。
42
+
43
+*   **レベル**: バッテリーの充電量 (0-100) の割合。*(数)*
44
+
45
+*   **起こしたり**: デバイスが接続されてインチ*(ブール値)*かどうかを示すブール値
46
+
47
+通常アプリケーションに使用する必要があります `window.addEventListener` 後のイベント リスナーをアタッチする、 `deviceready` イベントが発生します。
48
+
49
+### サポートされているプラットフォーム
50
+
51
+*   アマゾン火 OS
52
+*   iOS
53
+*   アンドロイド
54
+*   ブラックベリー 10
55
+*   Windows Phone 7 と 8
56
+*   Tizen
57
+*   Firefox の OS
58
+
59
+### Windows Phone 7 と 8 癖
60
+
61
+Windows Phone 7 は、バッテリーのレベルを決定するネイティブ Api を提供しませんので、 `level` プロパティは使用できません。`isPlugged`パラメーター*が*サポートされています。
62
+
63
+### 例
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+バッテリーの充電の割合がバッテリ切れのしきい値に達したときに発生します。値は、デバイス固有です。
76
+
77
+`batterycritical`ハンドラーは 2 つのプロパティを格納しているオブジェクトに渡されます。
78
+
79
+*   **レベル**: バッテリーの充電量 (0-100) の割合。*(数)*
80
+
81
+*   **起こしたり**: デバイスが接続されてインチ*(ブール値)*かどうかを示すブール値
82
+
83
+通常アプリケーションに使用する必要があります `window.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。
84
+
85
+### サポートされているプラットフォーム
86
+
87
+*   アマゾン火 OS
88
+*   iOS
89
+*   アンドロイド
90
+*   ブラックベリー 10
91
+*   Tizen
92
+*   Firefox の OS
93
+
94
+### 例
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+バッテリーの充電の割合がバッテリ低下しきい値、デバイス固有の値に達したときに発生します。
107
+
108
+`batterylow`ハンドラーは 2 つのプロパティを格納しているオブジェクトに渡されます。
109
+
110
+*   **レベル**: バッテリーの充電量 (0-100) の割合。*(数)*
111
+
112
+*   **起こしたり**: デバイスが接続されてインチ*(ブール値)*かどうかを示すブール値
113
+
114
+通常アプリケーションに使用する必要があります `window.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。
115
+
116
+### サポートされているプラットフォーム
117
+
118
+*   アマゾン火 OS
119
+*   iOS
120
+*   アンドロイド
121
+*   ブラックベリー 10
122
+*   Tizen
123
+*   Firefox の OS
124
+
125
+### 例
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/ko/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+이 플러그인에서는 [배터리 상태 이벤트 API](http://www.w3.org/TR/2011/WD-battery-status-20110915/) 의 이전 버전의 구현을.
25
+
26
+그것은 다음과 같은 세 가지 추가 `window` 이벤트:
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## 설치
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+이 이벤트는 배터리 충전 비율 1% 이상에 의해 변경 될 때 또는 장치를 연결 하거나 분리 하는 경우 발생 합니다.
40
+
41
+배터리 상태 처리기는 두 개의 속성이 포함 된 개체에 전달 됩니다.
42
+
43
+  * **수준**: 배터리 충전 (0-100)의 비율. *(수)*
44
+
45
+  * **isPlugged**: 장치 연결된 인치 *(부울)* 인지 여부를 나타내는 부울 값
46
+
47
+일반적으로 응용 프로그램을 사용 해야 합니다 `window.addEventListener` 후 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다.
48
+
49
+### 지원 되는 플랫폼
50
+
51
+  * 아마존 화재 운영 체제
52
+  * iOS
53
+  * 안 드 로이드
54
+  * 블랙베리 10
55
+  * Windows Phone 7과 8
56
+  * 윈도 (Windows Phone 8.1만)
57
+  * Tizen
58
+  * Firefox 운영 체제
59
+
60
+### 안 드 로이드와 아마존 화재 OS 단점이
61
+
62
+  * 경고: 안 드 로이드 + 화재 OS 구현 욕심이 있으며 장기간된 사용 사용자의 배터리를 배출 합니다. 
63
+
64
+### Windows Phone 7, 8 특수
65
+
66
+Windows Phone 7 배터리 수준을 확인 하려면 네이티브 Api를 제공 하지 않습니다 때문에 `level` 속성은 사용할 수 없습니다. `isPlugged`매개 변수는 *는* 지원.
67
+
68
+### 윈도우 특수
69
+
70
+Windows Phone 8.1 `isPlugged` 매개 변수를 지원 하지 않습니다. `level` 매개 변수는 *는* 지원.
71
+
72
+### 예를 들어
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+이벤트 발생 때 배터리 충전 비율 배터리 위험 임계값에 도달 했습니다. 값은 장치 마다 다릅니다.
85
+
86
+`batterycritical`처리기는 두 개의 속성이 포함 된 개체에 전달 됩니다:
87
+
88
+  * **수준**: 배터리 충전 (0-100)의 비율. *(수)*
89
+
90
+  * **isPlugged**: 장치 연결된 인치 *(부울)* 인지 여부를 나타내는 부울 값
91
+
92
+일반적으로 응용 프로그램을 사용 해야 합니다 `window.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다.
93
+
94
+### 지원 되는 플랫폼
95
+
96
+  * 아마존 화재 운영 체제
97
+  * iOS
98
+  * 안 드 로이드
99
+  * 블랙베리 10
100
+  * Tizen
101
+  * Firefox 운영 체제
102
+  * 윈도 (Windows Phone 8.1만)
103
+
104
+### 윈도우 특수
105
+
106
+으로 지원 되지 않습니다 Windows Phone 8.1 연결된 상태 `batterycritical` 이벤트를 발생 합니다.
107
+
108
+### 예를 들어
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+이벤트 발생 때 배터리 충전 비율 낮은 배터리 임계값, 특정 값에 도달 했습니다.
121
+
122
+`batterylow`처리기는 두 개의 속성이 포함 된 개체에 전달 됩니다:
123
+
124
+  * **수준**: 배터리 충전 (0-100)의 비율. *(수)*
125
+
126
+  * **isPlugged**: 장치 연결된 인치 *(부울)* 인지 여부를 나타내는 부울 값
127
+
128
+일반적으로 응용 프로그램을 사용 해야 합니다 `window.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다.
129
+
130
+### 지원 되는 플랫폼
131
+
132
+  * 아마존 화재 운영 체제
133
+  * iOS
134
+  * 안 드 로이드
135
+  * 블랙베리 10
136
+  * Tizen
137
+  * Firefox 운영 체제
138
+  * 윈도 (Windows Phone 8.1만)
139
+
140
+### 윈도우 특수
141
+
142
+으로 지원 되지 않습니다 Windows Phone 8.1 연결된 상태 `batterylow` 이벤트를 발생 합니다.
143
+
144
+### 예를 들어
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/ko/index.md

@@ -0,0 +1,132 @@
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
+
20
+# cordova-plugin-battery 상태
21
+
22
+이 플러그인에서는 [배터리 상태 이벤트 API][1] 의 이전 버전의 구현을.
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+그것은 다음과 같은 세 가지 추가 `window` 이벤트:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## 설치
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+이 이벤트는 배터리 충전 비율 1% 이상에 의해 변경 될 때 또는 장치를 연결 하거나 분리 하는 경우 발생 합니다.
40
+
41
+배터리 상태 처리기는 두 개의 속성이 포함 된 개체에 전달 됩니다.
42
+
43
+*   **수준**: 배터리 충전 (0-100)의 비율. *(수)*
44
+
45
+*   **isPlugged**: 장치 연결된 인치 *(부울)* 인지 여부를 나타내는 부울 값
46
+
47
+일반적으로 응용 프로그램을 사용 해야 합니다 `window.addEventListener` 후 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다.
48
+
49
+### 지원 되는 플랫폼
50
+
51
+*   아마존 화재 운영 체제
52
+*   iOS
53
+*   안 드 로이드
54
+*   블랙베리 10
55
+*   Windows Phone 7과 8
56
+*   Tizen
57
+*   Firefox 운영 체제
58
+
59
+### Windows Phone 7, 8 특수
60
+
61
+Windows Phone 7 배터리 수준을 확인 하려면 네이티브 Api를 제공 하지 않습니다 때문에 `level` 속성은 사용할 수 없습니다. `isPlugged`매개 변수는 *는* 지원.
62
+
63
+### 예를 들어
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+이벤트 발생 때 배터리 충전 비율 배터리 위험 임계값에 도달 했습니다. 값은 장치 마다 다릅니다.
76
+
77
+`batterycritical`처리기는 두 개의 속성이 포함 된 개체에 전달 됩니다:
78
+
79
+*   **수준**: 배터리 충전 (0-100)의 비율. *(수)*
80
+
81
+*   **isPlugged**: 장치 연결된 인치 *(부울)* 인지 여부를 나타내는 부울 값
82
+
83
+일반적으로 응용 프로그램을 사용 해야 합니다 `window.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다.
84
+
85
+### 지원 되는 플랫폼
86
+
87
+*   아마존 화재 운영 체제
88
+*   iOS
89
+*   안 드 로이드
90
+*   블랙베리 10
91
+*   Tizen
92
+*   Firefox 운영 체제
93
+
94
+### 예를 들어
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+이벤트 발생 때 배터리 충전 비율 낮은 배터리 임계값, 특정 값에 도달 했습니다.
107
+
108
+`batterylow`처리기는 두 개의 속성이 포함 된 개체에 전달 됩니다:
109
+
110
+*   **수준**: 배터리 충전 (0-100)의 비율. *(수)*
111
+
112
+*   **isPlugged**: 장치 연결된 인치 *(부울)* 인지 여부를 나타내는 부울 값
113
+
114
+일반적으로 응용 프로그램을 사용 해야 합니다 `window.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다.
115
+
116
+### 지원 되는 플랫폼
117
+
118
+*   아마존 화재 운영 체제
119
+*   iOS
120
+*   안 드 로이드
121
+*   블랙베리 10
122
+*   Tizen
123
+*   Firefox 운영 체제
124
+
125
+### 예를 들어
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/pl/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+Wtyczka stanowi implementację starą wersję [API zdarzeń stanu baterii](http://www.w3.org/TR/2011/WD-battery-status-20110915/).
25
+
26
+To dodaje następujące trzy `window` zdarzenia:
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## Instalacja
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+To zdarzenie fires po zmianie procent naładowania baterii, przez co najmniej 1 procent, lub jeśli urządzenie jest podłączone lub odłączony.
40
+
41
+Obsługi stan baterii jest przekazywany obiekt, który zawiera dwie właściwości:
42
+
43
+  * **poziom**: procent naładowania baterii (0-100). *(Liczba)*
44
+
45
+  * **isPlugged**: boolean, która wskazuje, czy urządzenie jest podłączony *(Boolean)*
46
+
47
+Aplikacje zwykle należy użyć `window.addEventListener` Aby dołączyć słuchacza po `deviceready` pożary zdarzenia.
48
+
49
+### Obsługiwane platformy
50
+
51
+  * Amazon Fire OS
52
+  * iOS
53
+  * Android
54
+  * BlackBerry 10
55
+  * Windows Phone 7 i 8
56
+  * Windows (tylko Windows Phone 8.1)
57
+  * Tizen
58
+  * Firefox OS
59
+
60
+### Android i Amazon ogień OS dziwactwa
61
+
62
+  * Ostrzeżenie: Android + ogień OS implementacje są chciwi i długotrwałe stosowanie drenażu użytkownika baterii. 
63
+
64
+### Windows Phone 7 i 8 dziwactwa
65
+
66
+Windows Phone 7 nie zapewniają native API do określenia poziomu baterii, więc `level` Właściwość jest niedostępny. `isPlugged`Parametr *jest* obsługiwany.
67
+
68
+### Windows dziwactwa
69
+
70
+Windows Phone 8.1 obsługuje parametr `isPlugged` . `Parametr <em>jest</em> obsługiwany.`
71
+
72
+### Przykład
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+Zdarzenie odpala gdy procent naładowania baterii osiągnie próg rozładowanej baterii. Wartość jest specyficzne dla urządzenia.
85
+
86
+`batterycritical`Obsługi jest przekazywany obiekt, który zawiera dwie właściwości:
87
+
88
+  * **poziom**: procent naładowania baterii (0-100). *(Liczba)*
89
+
90
+  * **isPlugged**: boolean, która wskazuje, czy urządzenie jest podłączony *(Boolean)*
91
+
92
+Aplikacje zwykle należy użyć `window.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia.
93
+
94
+### Obsługiwane platformy
95
+
96
+  * Amazon Fire OS
97
+  * iOS
98
+  * Android
99
+  * BlackBerry 10
100
+  * Tizen
101
+  * Firefox OS
102
+  * Windows (tylko Windows Phone 8.1)
103
+
104
+### Windows dziwactwa
105
+
106
+Windows Phone 8.1 będzie ogień `batterycritical` imprezy niezależnie od stanu podłączony, jak nie jest obsługiwany.
107
+
108
+### Przykład
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+Zdarzenie odpala gdy procent naładowania baterii osiągnie próg niskiego poziomu baterii, wartości specyficzne dla urządzenia.
121
+
122
+`batterylow`Obsługi jest przekazywany obiekt, który zawiera dwie właściwości:
123
+
124
+  * **poziom**: procent naładowania baterii (0-100). *(Liczba)*
125
+
126
+  * **isPlugged**: boolean, która wskazuje, czy urządzenie jest podłączony *(Boolean)*
127
+
128
+Aplikacje zwykle należy użyć `window.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia.
129
+
130
+### Obsługiwane platformy
131
+
132
+  * Amazon Fire OS
133
+  * iOS
134
+  * Android
135
+  * BlackBerry 10
136
+  * Tizen
137
+  * Firefox OS
138
+  * Windows (tylko Windows Phone 8.1)
139
+
140
+### Windows dziwactwa
141
+
142
+Windows Phone 8.1 będzie ogień `batterylow` imprezy niezależnie od stanu podłączony, jak nie jest obsługiwany.
143
+
144
+### Przykład
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/pl/index.md

@@ -0,0 +1,132 @@
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
+
20
+# org.Apache.Cordova.Battery stan
21
+
22
+Wtyczka stanowi implementację starą wersję [API zdarzeń stanu baterii][1].
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+To dodaje następujące trzy `window` zdarzenia:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## Instalacja
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+To zdarzenie fires po zmianie procent naładowania baterii, przez co najmniej 1 procent, lub jeśli urządzenie jest podłączone lub odłączony.
40
+
41
+Obsługi stan baterii jest przekazywany obiekt, który zawiera dwie właściwości:
42
+
43
+*   **poziom**: procent naładowania baterii (0-100). *(Liczba)*
44
+
45
+*   **isPlugged**: boolean, która wskazuje, czy urządzenie jest podłączony *(Boolean)*
46
+
47
+Aplikacje zwykle należy użyć `window.addEventListener` Aby dołączyć słuchacza po `deviceready` pożary zdarzenia.
48
+
49
+### Obsługiwane platformy
50
+
51
+*   Amazon Fire OS
52
+*   iOS
53
+*   Android
54
+*   BlackBerry 10
55
+*   Windows Phone 7 i 8
56
+*   Tizen
57
+*   Firefox OS
58
+
59
+### Windows Phone 7 i 8 dziwactwa
60
+
61
+Windows Phone 7 nie zapewniają native API do określenia poziomu baterii, więc `level` Właściwość jest niedostępny. `isPlugged`Parametr *jest* obsługiwany.
62
+
63
+### Przykład
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+Zdarzenie odpala gdy procent naładowania baterii osiągnie próg rozładowanej baterii. Wartość jest specyficzne dla urządzenia.
76
+
77
+`batterycritical`Obsługi jest przekazywany obiekt, który zawiera dwie właściwości:
78
+
79
+*   **poziom**: procent naładowania baterii (0-100). *(Liczba)*
80
+
81
+*   **isPlugged**: boolean, która wskazuje, czy urządzenie jest podłączony *(logiczna)*
82
+
83
+Aplikacje zwykle należy użyć `window.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia.
84
+
85
+### Obsługiwane platformy
86
+
87
+*   Amazon Fire OS
88
+*   iOS
89
+*   Android
90
+*   BlackBerry 10
91
+*   Tizen
92
+*   Firefox OS
93
+
94
+### Przykład
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+Zdarzenie odpala gdy procent naładowania baterii osiągnie próg niskiego poziomu baterii, wartości specyficzne dla urządzenia.
107
+
108
+`batterylow`Obsługi jest przekazywany obiekt, który zawiera dwie właściwości:
109
+
110
+*   **poziom**: procent naładowania baterii (0-100). *(Liczba)*
111
+
112
+*   **isPlugged**: boolean, która wskazuje, czy urządzenie jest podłączony *(logiczna)*
113
+
114
+Aplikacje zwykle należy użyć `window.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia.
115
+
116
+### Obsługiwane platformy
117
+
118
+*   Amazon Fire OS
119
+*   iOS
120
+*   Android
121
+*   BlackBerry 10
122
+*   Tizen
123
+*   Firefox OS
124
+
125
+### Przykład
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/ru/index.md

@@ -0,0 +1,132 @@
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
+
20
+# cordova-plugin-battery-status
21
+
22
+Этот плагин предоставляет реализацию старой версии [API Событий Статуса Батареи][1].
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+API добавляет следующие три события для объекта `window`:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## Установка
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+Это событие возникает при изменении процент заряда батареи по крайней мере на 1%, или если устройство подключается или отключается от заряжающего устройства.
40
+
41
+Обработчику события batterystatus передается объект, содержащий два свойства:
42
+
43
+*   **level**: процент заряда батареи (0-100). *(Число)*
44
+
45
+*   **isPlugged**: логическое значение, указывающее, подключено ли устройство к заряжающему устройству *(Boolean)*
46
+
47
+Приложения обычно должны использовать `window.addEventListener` прикрепить прослушиватель событий после `deviceready` пожаров события.
48
+
49
+### Поддерживаемые платформы
50
+
51
+*   Amazon Fire OS
52
+*   iOS
53
+*   Android
54
+*   BlackBerry 10
55
+*   Windows Phone 7 и 8
56
+*   Tizen
57
+*   Firefox OS
58
+
59
+### Особенности Windows Phone 7 и 8
60
+
61
+Windows Phone 7 не обеспечивает API, чтобы определить уровень заряда батареи, так что свойство `level` недоступно. Параметр `isPlugged` *поддерживается*.
62
+
63
+### Пример
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+Событие возникает, когда процент заряда батареи почти достиг порога полной разрядки батареи. Значение этого порога зависит от конкретного устройства.
76
+
77
+Обработчику события `batterycritical` передается объект, содержащий два свойства:
78
+
79
+*   **level**: процент заряда батареи (0-100). *(Число)*
80
+
81
+*   **isPlugged**: логическое значение, указывающее, подключено ли устройство к заряжающему устройству *(Boolean)*
82
+
83
+Приложения обычно должны использовать `window.addEventListener` чтобы добавить обработчик события после того как произойдет событие `deviceready`.
84
+
85
+### Поддерживаемые платформы
86
+
87
+*   Amazon Fire OS
88
+*   iOS
89
+*   Android
90
+*   BlackBerry 10
91
+*   Tizen
92
+*   Firefox OS
93
+
94
+### Пример
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+Событие возникает, когда процент заряда батареи достигает порога низкого заряда батареи, это значение зависит от конкретного устройства.
107
+
108
+Обработчику события `batterylow` передается объект, содержащий два свойства:
109
+
110
+*   **level**: процент заряда батареи (0-100). *(Число)*
111
+
112
+*   **isPlugged**: логическое значение, указывающее, подключено ли устройство к заряжающему устройству *(Boolean)*
113
+
114
+Приложения обычно должны использовать `window.addEventListener` чтобы добавить обработчик события после того как произойдет событие `deviceready`.
115
+
116
+### Поддерживаемые платформы
117
+
118
+*   Amazon Fire OS
119
+*   iOS
120
+*   Android
121
+*   BlackBerry 10
122
+*   Tizen
123
+*   Firefox OS
124
+
125
+### Пример
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 151 - 0
plugins/cordova-plugin-battery-status/doc/zh/README.md

@@ -0,0 +1,151 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-battery-status
21
+
22
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-battery-status.svg)](https://travis-ci.org/apache/cordova-plugin-battery-status)
23
+
24
+這個外掛程式提供的舊版本的[電池狀態事件 API](http://www.w3.org/TR/2011/WD-battery-status-20110915/)實現的.
25
+
26
+它將添加以下三 `window` 事件:
27
+
28
+  * batterystatus
29
+  * batterycritical
30
+  * batterylow
31
+
32
+## 安裝
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+當電池計量的百分比改變了至少 1%,或如果在插入或拔出該設備會觸發此事件。
40
+
41
+電池狀態處理常式傳遞一個物件,包含兩個屬性:
42
+
43
+  * **級別**: 電池充電 (0-100) 的百分比。*(人數)*
44
+
45
+  * **isPlugged**: 一個布林值,該值指示設備是否插*(布林值)*
46
+
47
+應用程式通常應使用 `window.addEventListener` 將附加一個事件攔截器後的 `deviceready` 事件觸發。
48
+
49
+### 支援的平臺
50
+
51
+  * 亞馬遜火 OS
52
+  * iOS
53
+  * Android 系統
54
+  * 黑莓 10
55
+  * Windows Phone 7 和 8
56
+  * Windows (僅限於 Windows Phone 8.1)
57
+  * Tizen
58
+  * 火狐瀏覽器作業系統
59
+
60
+### 安卓和亞馬遜火 OS 怪癖
61
+
62
+  * 警告: Android + 火 OS 實現都是貪婪和長時間的使用會流失使用者的電池。 
63
+
64
+### Windows Phone 7 和 8 怪癖
65
+
66
+Windows Phone 7 並不提供本機 Api 來確定電池計量水準,所以 `level` 是不可用的屬性。`isPlugged`參數**支援的。
67
+
68
+### Windows 的怪癖
69
+
70
+Windows Phone 8.1 不支援`isPlugged`參數。 `水準`參數**支援。
71
+
72
+### 示例
73
+
74
+    window.addEventListener("batterystatus", onBatteryStatus, false);
75
+    
76
+    function onBatteryStatus(info) {
77
+        // Handle the online event
78
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
79
+    }
80
+    
81
+
82
+## batterycritical
83
+
84
+當電池計量的百分比已達到關鍵電池閾值時,將觸發該事件。值是特定于設備。
85
+
86
+`batterycritical`處理常式傳遞一個物件,包含兩個屬性:
87
+
88
+  * **級別**: 電池充電 (0-100) 的百分比。*(人數)*
89
+
90
+  * **isPlugged**: 一個布林值,該值指示設備是否插*(布林值)*
91
+
92
+應用程式通常應使用 `window.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。
93
+
94
+### 支援的平臺
95
+
96
+  * 亞馬遜火 OS
97
+  * iOS
98
+  * Android 系統
99
+  * 黑莓 10
100
+  * Tizen
101
+  * 火狐瀏覽器作業系統
102
+  * Windows (僅限於 Windows Phone 8.1)
103
+
104
+### Windows 的怪癖
105
+
106
+Windows Phone 8.1 會觸發`batterycritical`事件任何堵塞狀態,因為它不支援。
107
+
108
+### 示例
109
+
110
+    window.addEventListener("batterycritical", onBatteryCritical, false);
111
+    
112
+    function onBatteryCritical(info) {
113
+        // Handle the battery critical event
114
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
115
+    }
116
+    
117
+
118
+## batterylow
119
+
120
+當電池計量的百分比已達到電池計量低門檻,設備特定值時,將觸發該事件。
121
+
122
+`batterylow`處理常式傳遞一個物件,包含兩個屬性:
123
+
124
+  * **級別**: 電池充電 (0-100) 的百分比。*(人數)*
125
+
126
+  * **isPlugged**: 一個布林值,該值指示設備是否插*(布林值)*
127
+
128
+應用程式通常應使用 `window.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。
129
+
130
+### 支援的平臺
131
+
132
+  * 亞馬遜火 OS
133
+  * iOS
134
+  * Android 系統
135
+  * 黑莓 10
136
+  * Tizen
137
+  * 火狐瀏覽器作業系統
138
+  * Windows (僅限於 Windows Phone 8.1)
139
+
140
+### Windows 的怪癖
141
+
142
+Windows Phone 8.1 會觸發`batterylow`事件任何堵塞狀態,因為它不支援。
143
+
144
+### 示例
145
+
146
+    window.addEventListener("batterylow", onBatteryLow, false);
147
+    
148
+    function onBatteryLow(info) {
149
+        // Handle the battery low event
150
+        alert("Battery Level Low " + info.level + "%");
151
+    }

+ 132 - 0
plugins/cordova-plugin-battery-status/doc/zh/index.md

@@ -0,0 +1,132 @@
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
+
20
+# cordova-plugin-battery-地位
21
+
22
+這個外掛程式提供的舊版本的[電池狀態事件 API][1]實現的.
23
+
24
+ [1]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
25
+
26
+它將添加以下三 `window` 事件:
27
+
28
+*   batterystatus
29
+*   batterycritical
30
+*   batterylow
31
+
32
+## 安裝
33
+
34
+    cordova plugin add cordova-plugin-battery-status
35
+    
36
+
37
+## batterystatus
38
+
39
+當電池計量的百分比改變了至少 1%,或如果在插入或拔出該設備會觸發此事件。
40
+
41
+電池狀態處理常式傳遞一個物件,包含兩個屬性:
42
+
43
+*   **級別**: 電池充電 (0-100) 的百分比。*(人數)*
44
+
45
+*   **isPlugged**: 一個布林值,該值指示設備是否插*(布林值)*
46
+
47
+應用程式通常應使用 `window.addEventListener` 將附加一個事件攔截器後的 `deviceready` 事件觸發。
48
+
49
+### 支援的平臺
50
+
51
+*   亞馬遜火 OS
52
+*   iOS
53
+*   Android 系統
54
+*   黑莓 10
55
+*   Windows Phone 7 和 8
56
+*   Tizen
57
+*   火狐瀏覽器作業系統
58
+
59
+### Windows Phone 7 和 8 怪癖
60
+
61
+Windows Phone 7 並不提供本機 Api 來確定電池計量水準,所以 `level` 是不可用的屬性。`isPlugged`參數**支援的。
62
+
63
+### 示例
64
+
65
+    window.addEventListener("batterystatus", onBatteryStatus, false);
66
+    
67
+    function onBatteryStatus(info) {
68
+        // Handle the online event
69
+        console.log("Level: " + info.level + " isPlugged: " + info.isPlugged);
70
+    }
71
+    
72
+
73
+## batterycritical
74
+
75
+當電池計量的百分比已達到關鍵電池閾值時,將觸發該事件。值是特定于設備。
76
+
77
+`batterycritical`處理常式傳遞一個物件,包含兩個屬性:
78
+
79
+*   **級別**: 電池充電 (0-100) 的百分比。*(人數)*
80
+
81
+*   **isPlugged**: 一個布林值,該值指示設備是否插*(布林值)*
82
+
83
+應用程式通常應使用 `window.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。
84
+
85
+### 支援的平臺
86
+
87
+*   亞馬遜火 OS
88
+*   iOS
89
+*   Android 系統
90
+*   黑莓 10
91
+*   Tizen
92
+*   火狐瀏覽器作業系統
93
+
94
+### 示例
95
+
96
+    window.addEventListener("batterycritical", onBatteryCritical, false);
97
+    
98
+    function onBatteryCritical(info) {
99
+        // Handle the battery critical event
100
+        alert("Battery Level Critical " + info.level + "%\nRecharge Soon!");
101
+    }
102
+    
103
+
104
+## batterylow
105
+
106
+當電池計量的百分比已達到電池計量低門檻,設備特定值時,將觸發該事件。
107
+
108
+`batterylow`處理常式傳遞一個物件,包含兩個屬性:
109
+
110
+*   **級別**: 電池充電 (0-100) 的百分比。*(人數)*
111
+
112
+*   **isPlugged**: 一個布林值,該值指示設備是否插*(布林值)*
113
+
114
+應用程式通常應使用 `window.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。
115
+
116
+### 支援的平臺
117
+
118
+*   亞馬遜火 OS
119
+*   iOS
120
+*   Android 系統
121
+*   黑莓 10
122
+*   Tizen
123
+*   火狐瀏覽器作業系統
124
+
125
+### 示例
126
+
127
+    window.addEventListener("batterylow", onBatteryLow, false);
128
+    
129
+    function onBatteryLow(info) {
130
+        // Handle the battery low event
131
+        alert("Battery Level Low " + info.level + "%");
132
+    }

+ 81 - 0
plugins/cordova-plugin-battery-status/package.json

@@ -0,0 +1,81 @@
1
+{
2
+  "_from": "cordova-plugin-battery-status",
3
+  "_id": "cordova-plugin-battery-status@2.0.1",
4
+  "_inBundle": false,
5
+  "_integrity": "sha1-m/6dqpr5whPeL9ixEz+eC61TwEg=",
6
+  "_location": "/cordova-plugin-battery-status",
7
+  "_phantomChildren": {},
8
+  "_requested": {
9
+    "type": "tag",
10
+    "registry": true,
11
+    "raw": "cordova-plugin-battery-status",
12
+    "name": "cordova-plugin-battery-status",
13
+    "escapedName": "cordova-plugin-battery-status",
14
+    "rawSpec": "",
15
+    "saveSpec": null,
16
+    "fetchSpec": "latest"
17
+  },
18
+  "_requiredBy": [
19
+    "#USER",
20
+    "/"
21
+  ],
22
+  "_resolved": "https://registry.npmjs.org/cordova-plugin-battery-status/-/cordova-plugin-battery-status-2.0.1.tgz",
23
+  "_shasum": "9bfe9daa9af9c213de2fd8b1133f9e0bad53c048",
24
+  "_spec": "cordova-plugin-battery-status",
25
+  "_where": "D:\\myData\\projectTest\\cordovaTest",
26
+  "author": {
27
+    "name": "Apache Software Foundation"
28
+  },
29
+  "bugs": {
30
+    "url": "https://issues.apache.org/jira/browse/CB"
31
+  },
32
+  "bundleDependencies": false,
33
+  "cordova": {
34
+    "id": "cordova-plugin-battery-status",
35
+    "platforms": [
36
+      "android",
37
+      "ios",
38
+      "browser",
39
+      "windows"
40
+    ]
41
+  },
42
+  "deprecated": false,
43
+  "description": "Cordova Battery Plugin",
44
+  "devDependencies": {
45
+    "eslint": "^3.19.0",
46
+    "eslint-config-semistandard": "^11.0.0",
47
+    "eslint-config-standard": "^10.2.1",
48
+    "eslint-plugin-import": "^2.3.0",
49
+    "eslint-plugin-node": "^5.0.0",
50
+    "eslint-plugin-promise": "^3.5.0",
51
+    "eslint-plugin-standard": "^3.0.1",
52
+    "jshint": "^2.6.0"
53
+  },
54
+  "engines": {
55
+    "cordovaDependencies": {
56
+      "3.0.0": {
57
+        "cordova": ">100"
58
+      }
59
+    }
60
+  },
61
+  "homepage": "https://github.com/apache/cordova-plugin-battery-status#readme",
62
+  "keywords": [
63
+    "cordova",
64
+    "battery",
65
+    "ecosystem:cordova",
66
+    "cordova-android",
67
+    "cordova-ios"
68
+  ],
69
+  "license": "Apache-2.0",
70
+  "name": "cordova-plugin-battery-status",
71
+  "repository": {
72
+    "type": "git",
73
+    "url": "git+https://github.com/apache/cordova-plugin-battery-status.git"
74
+  },
75
+  "scripts": {
76
+    "eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests",
77
+    "test": "npm run eslint"
78
+  },
79
+  "types": "./types/index.d.ts",
80
+  "version": "2.0.1"
81
+}

+ 72 - 0
plugins/cordova-plugin-battery-status/plugin.xml

@@ -0,0 +1,72 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+  Licensed to the Apache Software Foundation (ASF) under one
4
+  or more contributor license agreements.  See the NOTICE file
5
+  distributed with this work for additional information
6
+  regarding copyright ownership.  The ASF licenses this file
7
+  to you under the Apache License, Version 2.0 (the
8
+  "License"); you may not use this file except in compliance
9
+  with the License.  You may obtain a copy of the License at
10
+
11
+    http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+  Unless required by applicable law or agreed to in writing,
14
+  software distributed under the License is distributed on an
15
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+  KIND, either express or implied.  See the License for the
17
+  specific language governing permissions and limitations
18
+  under the License.
19
+-->
20
+
21
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
22
+      id="cordova-plugin-battery-status"
23
+      version="2.0.1">
24
+    <name>Battery</name>
25
+    <description>Cordova Battery Plugin</description>
26
+    <license>Apache 2.0</license>
27
+    <keywords>cordova,battery</keywords>
28
+    <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status.git</repo>
29
+    <issue>https://issues.apache.org/jira/browse/CB/component/12320643</issue>
30
+
31
+    <js-module src="www/battery.js" name="battery">
32
+        <clobbers target="navigator.battery" />
33
+    </js-module>
34
+
35
+    <!-- android -->
36
+    <platform name="android">
37
+        <config-file target="res/xml/config.xml" parent="/*">
38
+            <feature name="Battery" >
39
+                <param name="android-package" value="org.apache.cordova.batterystatus.BatteryListener"/>
40
+            </feature>
41
+        </config-file>
42
+
43
+        <source-file src="src/android/BatteryListener.java" target-dir="src/org/apache/cordova/batterystatus" />
44
+    </platform>
45
+
46
+    <!-- ios -->
47
+    <platform name="ios">
48
+        <config-file target="config.xml" parent="/*">
49
+            <feature name="Battery">
50
+                <param name="ios-package" value="CDVBattery" />
51
+            </feature>
52
+        </config-file>
53
+        <header-file src="src/ios/CDVBattery.h" />
54
+	    <source-file src="src/ios/CDVBattery.m" />
55
+    </platform>
56
+
57
+    <!-- windows -->
58
+    <platform name="windows">
59
+        <js-module src="src/windows/BatteryProxy.js" name="Battery">
60
+            <runs />
61
+        </js-module>
62
+
63
+        <framework src="src/windows/BatteryStatus.winmd" custom="true" target="phone"/>
64
+    </platform>
65
+
66
+    <!-- browser -->
67
+    <platform name="browser">
68
+        <js-module src="src/browser/BatteryProxy.js" name="Battery">
69
+            <runs />
70
+        </js-module>
71
+    </platform>
72
+</plugin>

+ 163 - 0
plugins/cordova-plugin-battery-status/src/android/BatteryListener.java

@@ -0,0 +1,163 @@
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.batterystatus;
20
+
21
+import org.apache.cordova.CallbackContext;
22
+import org.apache.cordova.CordovaPlugin;
23
+import org.apache.cordova.LOG;
24
+import org.apache.cordova.PluginResult;
25
+import org.json.JSONArray;
26
+import org.json.JSONException;
27
+import org.json.JSONObject;
28
+
29
+import android.content.BroadcastReceiver;
30
+import android.content.Context;
31
+import android.content.Intent;
32
+import android.content.IntentFilter;
33
+
34
+public class BatteryListener extends CordovaPlugin {
35
+
36
+    private static final String LOG_TAG = "BatteryManager";
37
+
38
+    BroadcastReceiver receiver;
39
+
40
+    private CallbackContext batteryCallbackContext = null;
41
+
42
+    /**
43
+     * Constructor.
44
+     */
45
+    public BatteryListener() {
46
+        this.receiver = null;
47
+    }
48
+
49
+    /**
50
+     * Executes the request.
51
+     *
52
+     * @param action        	The action to execute.
53
+     * @param args          	JSONArry of arguments for the plugin.
54
+     * @param callbackContext 	The callback context used when calling back into JavaScript.
55
+     * @return              	True if the action was valid, false if not.
56
+     */
57
+    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
58
+        if (action.equals("start")) {
59
+            if (this.batteryCallbackContext != null) {
60
+                callbackContext.error( "Battery listener already running.");
61
+                return true;
62
+            }
63
+            this.batteryCallbackContext = callbackContext;
64
+
65
+            // We need to listen to power events to update battery status
66
+            IntentFilter intentFilter = new IntentFilter();
67
+            intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
68
+            if (this.receiver == null) {
69
+                this.receiver = new BroadcastReceiver() {
70
+                    @Override
71
+                    public void onReceive(Context context, Intent intent) {
72
+                        updateBatteryInfo(intent);
73
+                    }
74
+                };
75
+                webView.getContext().registerReceiver(this.receiver, intentFilter);
76
+            }
77
+
78
+            // Don't return any result now, since status results will be sent when events come in from broadcast receiver
79
+            PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
80
+            pluginResult.setKeepCallback(true);
81
+            callbackContext.sendPluginResult(pluginResult);
82
+            return true;
83
+        }
84
+
85
+        else if (action.equals("stop")) {
86
+            removeBatteryListener();
87
+            this.sendUpdate(new JSONObject(), false); // release status callback in JS side
88
+            this.batteryCallbackContext = null;
89
+            callbackContext.success();
90
+            return true;
91
+        }
92
+
93
+        return false;
94
+    }
95
+
96
+    /**
97
+     * Stop battery receiver.
98
+     */
99
+    public void onDestroy() {
100
+        removeBatteryListener();
101
+    }
102
+
103
+    /**
104
+     * Stop battery receiver.
105
+     */
106
+    public void onReset() {
107
+        removeBatteryListener();
108
+    }
109
+
110
+    /**
111
+     * Stop the battery receiver and set it to null.
112
+     */
113
+    private void removeBatteryListener() {
114
+        if (this.receiver != null) {
115
+            try {
116
+                webView.getContext().unregisterReceiver(this.receiver);
117
+                this.receiver = null;
118
+            } catch (Exception e) {
119
+                LOG.e(LOG_TAG, "Error unregistering battery receiver: " + e.getMessage(), e);
120
+            }
121
+        }
122
+    }
123
+
124
+    /**
125
+     * Creates a JSONObject with the current battery information
126
+     *
127
+     * @param batteryIntent the current battery information
128
+     * @return a JSONObject containing the battery status information
129
+     */
130
+    private JSONObject getBatteryInfo(Intent batteryIntent) {
131
+        JSONObject obj = new JSONObject();
132
+        try {
133
+            obj.put("level", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, 0));
134
+            obj.put("isPlugged", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_PLUGGED, -1) > 0 ? true : false);
135
+        } catch (JSONException e) {
136
+            LOG.e(LOG_TAG, e.getMessage(), e);
137
+        }
138
+        return obj;
139
+    }
140
+
141
+    /**
142
+     * Updates the JavaScript side whenever the battery changes
143
+     *
144
+     * @param batteryIntent the current battery information
145
+     * @return
146
+     */
147
+    private void updateBatteryInfo(Intent batteryIntent) {
148
+        sendUpdate(this.getBatteryInfo(batteryIntent), true);
149
+    }
150
+
151
+    /**
152
+     * Create a new plugin result and send it back to JavaScript
153
+     *
154
+     * @param connection the network info to set as navigator.connection
155
+     */
156
+    private void sendUpdate(JSONObject info, boolean keepCallback) {
157
+        if (this.batteryCallbackContext != null) {
158
+            PluginResult result = new PluginResult(PluginResult.Status.OK, info);
159
+            result.setKeepCallback(keepCallback);
160
+            this.batteryCallbackContext.sendPluginResult(result);
161
+        }
162
+    }
163
+}

+ 80 - 0
plugins/cordova-plugin-battery-status/src/browser/BatteryProxy.js

@@ -0,0 +1,80 @@
1
+/*
2
+ *
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements.  See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership.  The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License.  You may obtain a copy of the License at
10
+ *
11
+ *   http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied.  See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+var w3cBattery;
23
+var winCallBack;
24
+
25
+function success () {
26
+    winCallBack({ level: w3cBattery.level * 100, isPlugged: w3cBattery.charging });
27
+}
28
+
29
+var Battery = {
30
+    start: function (win, fail, args, env) {
31
+        try {
32
+            var subscribe = function (battery) {
33
+                w3cBattery = battery;
34
+                winCallBack = win;
35
+
36
+                success();
37
+
38
+                if (typeof w3cBattery.addEventListener === 'function') {
39
+                    w3cBattery.addEventListener('levelchange', success, false);
40
+                    w3cBattery.addEventListener('chargingchange', success, false);
41
+                } else {
42
+                    w3cBattery.onlevelchange = success;
43
+                    w3cBattery.onchargingchange = success;
44
+                }
45
+            };
46
+
47
+            if (typeof navigator.getBattery === 'function') {
48
+                navigator.getBattery().then(function (battery) {
49
+                    subscribe(battery);
50
+                });
51
+            } else {
52
+                var origBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery'); // eslint-disable-line no-undef
53
+
54
+                if (origBattery) {
55
+                    subscribe(origBattery);
56
+                } else {
57
+                    fail('Not supported');
58
+                }
59
+            }
60
+        } catch (e) {
61
+            fail(e);
62
+        }
63
+    },
64
+
65
+    stop: function () {
66
+        try {
67
+            if (typeof w3cBattery.removeEventListener === 'function') {
68
+                w3cBattery.removeEventListener('levelchange', success, false);
69
+                w3cBattery.removeEventListener('chargingchange', success, false);
70
+            } else {
71
+                w3cBattery.onlevelchange = null;
72
+                w3cBattery.onchargingchange = null;
73
+            }
74
+        } catch (e) {
75
+            console.warn('Error occured while trying to stop battery: ' + JSON.stringify(e));
76
+        }
77
+    }
78
+};
79
+
80
+require('cordova/exec/proxy').add('Battery', Battery);

+ 40 - 0
plugins/cordova-plugin-battery-status/src/ios/CDVBattery.h

@@ -0,0 +1,40 @@
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
+
20
+#import <Foundation/Foundation.h>
21
+#import <Cordova/CDVPlugin.h>
22
+
23
+@interface CDVBattery : CDVPlugin {
24
+    UIDeviceBatteryState state;
25
+    float level;
26
+    bool isPlugged;
27
+    NSString* callbackId;
28
+}
29
+
30
+@property (nonatomic) UIDeviceBatteryState state;
31
+@property (nonatomic) float level;
32
+@property (nonatomic) bool isPlugged;
33
+@property (strong) NSString* callbackId;
34
+
35
+- (void)updateBatteryStatus:(NSNotification*)notification;
36
+- (NSDictionary*)getBatteryStatus;
37
+- (void)start:(CDVInvokedUrlCommand*)command;
38
+- (void)stop:(CDVInvokedUrlCommand*)command;
39
+- (void)dealloc;
40
+@end

+ 148 - 0
plugins/cordova-plugin-battery-status/src/ios/CDVBattery.m

@@ -0,0 +1,148 @@
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
+
20
+#import "CDVBattery.h"
21
+
22
+@interface CDVBattery (PrivateMethods)
23
+- (void)updateOnlineStatus;
24
+@end
25
+
26
+@implementation CDVBattery
27
+
28
+@synthesize state, level, callbackId, isPlugged;
29
+
30
+/*  determining type of event occurs on JavaScript side
31
+- (void) updateBatteryLevel:(NSNotification*)notification
32
+{
33
+    // send batterylow event for less than 25% battery
34
+    // send batterycritical  event for less than 10% battery
35
+    // W3c says to send batteryStatus event when batterylevel changes by more than 1% (iOS seems to notify each 5%)
36
+    // always update the navigator.device.battery info
37
+    float currentLevel = [[UIDevice currentDevice] batteryLevel];
38
+    NSString* type = @"";
39
+    // no check for level == -1 since this api is only called when monitoring is enabled so level should be valid
40
+    if (currentLevel < 0.10){
41
+        type = @"batterycritical";
42
+    } else if (currentLevel < 0.25) {
43
+        type = @"batterylow";
44
+    } else {
45
+        float onePercent = 0.1;
46
+        if (self.level >= 0 ){
47
+            onePercent = self.level * 0.01;
48
+        }
49
+        if (fabsf(currentLevel - self.level) > onePercent){
50
+            // issue batteryStatus event
51
+            type = @"batterystatus";
52
+        }
53
+    }
54
+    // update the battery info and fire event
55
+    NSString* jsString = [NSString stringWithFormat:@"navigator.device.battery._status(\"%@\", %@)", type,[[self getBatteryStatus] JSONRepresentation]];
56
+    [super writeJavascript:jsString];
57
+}
58
+ */
59
+
60
+- (void)updateBatteryStatus:(NSNotification*)notification
61
+{
62
+    NSDictionary* batteryData = [self getBatteryStatus];
63
+
64
+    if (self.callbackId) {
65
+        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:batteryData];
66
+        [result setKeepCallbackAsBool:YES];
67
+        [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
68
+    }
69
+}
70
+
71
+/* Get the current battery status and level.  Status will be unknown and level will be -1.0 if
72
+ * monitoring is turned off.
73
+ */
74
+- (NSDictionary*)getBatteryStatus
75
+{
76
+    UIDevice* currentDevice = [UIDevice currentDevice];
77
+    UIDeviceBatteryState currentState = [currentDevice batteryState];
78
+
79
+    isPlugged = FALSE; // UIDeviceBatteryStateUnknown or UIDeviceBatteryStateUnplugged
80
+    if ((currentState == UIDeviceBatteryStateCharging) || (currentState == UIDeviceBatteryStateFull)) {
81
+        isPlugged = TRUE;
82
+    }
83
+    float currentLevel = [currentDevice batteryLevel];
84
+
85
+    if ((currentLevel != self.level) || (currentState != self.state)) {
86
+        self.level = currentLevel;
87
+        self.state = currentState;
88
+    }
89
+
90
+    // W3C spec says level must be null if it is unknown
91
+    NSObject* w3cLevel = nil;
92
+    if ((currentState == UIDeviceBatteryStateUnknown) || (currentLevel == -1.0)) {
93
+        w3cLevel = [NSNull null];
94
+    } else {
95
+        w3cLevel = [NSNumber numberWithFloat:(currentLevel * 100)];
96
+    }
97
+    NSMutableDictionary* batteryData = [NSMutableDictionary dictionaryWithCapacity:2];
98
+    [batteryData setObject:[NSNumber numberWithBool:isPlugged] forKey:@"isPlugged"];
99
+    [batteryData setObject:w3cLevel forKey:@"level"];
100
+    return batteryData;
101
+}
102
+
103
+/* turn on battery monitoring*/
104
+- (void)start:(CDVInvokedUrlCommand*)command
105
+{
106
+    self.callbackId = command.callbackId;
107
+
108
+    if ([UIDevice currentDevice].batteryMonitoringEnabled == NO) {
109
+        [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
110
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
111
+                                                     name:UIDeviceBatteryStateDidChangeNotification object:nil];
112
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
113
+                                                     name:UIDeviceBatteryLevelDidChangeNotification object:nil];
114
+    }
115
+}
116
+
117
+/* turn off battery monitoring */
118
+- (void)stop:(CDVInvokedUrlCommand*)command
119
+{
120
+    // callback one last time to clear the callback function on JS side
121
+    if (self.callbackId) {
122
+        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getBatteryStatus]];
123
+        [result setKeepCallbackAsBool:NO];
124
+        [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
125
+    }
126
+    self.callbackId = nil;
127
+    [[UIDevice currentDevice] setBatteryMonitoringEnabled:NO];
128
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
129
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryLevelDidChangeNotification object:nil];
130
+}
131
+
132
+- (void)pluginInitialize
133
+{
134
+    self.state = UIDeviceBatteryStateUnknown;
135
+    self.level = -1.0;
136
+}
137
+
138
+- (void)dealloc
139
+{
140
+    [self stop:nil];
141
+}
142
+
143
+- (void)onReset
144
+{
145
+    [self stop:nil];
146
+}
147
+
148
+@end

+ 125 - 0
plugins/cordova-plugin-battery-status/src/windows/BatteryProxy.js

@@ -0,0 +1,125 @@
1
+/*
2
+ *
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements.  See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership.  The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License.  You may obtain a copy of the License at
10
+ *
11
+ *   http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied.  See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+/* global Windows, WinJS, BatteryStatus */
23
+
24
+var PowerManager = Windows && Windows.System &&
25
+    Windows.System.Power && Windows.System.Power.PowerManager;
26
+
27
+if (PowerManager) {
28
+    var pluginCallback;
29
+    var reportStatus = function () {
30
+        if (!pluginCallback) {
31
+            return;
32
+        }
33
+
34
+        pluginCallback({
35
+            level: PowerManager.remainingChargePercent,
36
+            isPlugged: PowerManager.powerSupplyStatus !== Windows.System.Power.PowerSupplyStatus.notPresent
37
+        }, { keepCallback: true });
38
+    };
39
+
40
+    var BatteryWin10 = {
41
+        start: function (win, fail) {
42
+            pluginCallback = win;
43
+            PowerManager.addEventListener('remainingchargepercentchanged', reportStatus);
44
+            PowerManager.addEventListener('powersupplystatuschanged', reportStatus);
45
+
46
+            reportStatus();
47
+        },
48
+
49
+        stop: function () {
50
+            if (pluginCallback) {
51
+                PowerManager.removeEventListener('remainingchargepercentchanged', reportStatus);
52
+                PowerManager.removeEventListener('powersupplystatuschanged', reportStatus);
53
+            }
54
+
55
+            pluginCallback = null;
56
+        }
57
+    };
58
+
59
+    require('cordova/exec/proxy').add('Battery', BatteryWin10);
60
+
61
+} else {
62
+
63
+    var stopped;
64
+
65
+    var handleResponse = function (successCb, errorCb, jsonResponse) {
66
+        var info = JSON.parse(jsonResponse);
67
+
68
+        if (info.hasOwnProperty('exceptionMessage')) {
69
+            errorCb(info.exceptionMessage);
70
+            return;
71
+        }
72
+
73
+        successCb(info, { keepCallback: true });
74
+    };
75
+
76
+    var Battery = {
77
+        start: function (win, fail, args, env) {
78
+            function getBatteryStatus (success, error) {
79
+                handleResponse(success, error, BatteryStatus.BatteryStatus.start());
80
+            }
81
+
82
+            function getBatteryStatusLevelChangeEvent (success, error) {
83
+                return BatteryStatus.BatteryStatus.getBatteryStatusChangeEvent().done(function (result) {
84
+                    if (stopped) {
85
+                        return;
86
+                    }
87
+
88
+                    handleResponse(success, error, result);
89
+
90
+                    setTimeout(function () { getBatteryStatusLevelChangeEvent(success, error); }, 0);
91
+                }, function (err) {
92
+                    fail(err);
93
+                });
94
+            }
95
+
96
+            // Battery API supported on Phone devices only so in case of
97
+            // desktop/tablet the only one choice is to fail with appropriate message.
98
+            if (!WinJS.Utilities.isPhone) {
99
+                fail('The operation is not supported on Windows Desktop devices.');
100
+                return;
101
+            }
102
+
103
+            stopped = false;
104
+            try {
105
+                getBatteryStatus(win, fail);
106
+                getBatteryStatusLevelChangeEvent(win, fail);
107
+            } catch (e) {
108
+                fail(e);
109
+            }
110
+        },
111
+
112
+        stop: function () {
113
+            // Battery API supported on Phone devices only so in case of
114
+            // desktop/tablet device we don't need for any actions.
115
+            if (!WinJS.Utilities.isPhone) {
116
+                return;
117
+            }
118
+
119
+            stopped = true;
120
+            BatteryStatus.BatteryStatus.stop();
121
+        }
122
+    };
123
+
124
+    require('cordova/exec/proxy').add('Battery', Battery);
125
+}

BIN
plugins/cordova-plugin-battery-status/src/windows/BatteryStatus.winmd


+ 40 - 0
plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus.sln

@@ -0,0 +1,40 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio 2013
4
+VisualStudioVersion = 12.0.30723.0
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+#
7
+# Licensed to the Apache Software Foundation (ASF) under one
8
+# or more contributor license agreements.  See the NOTICE file
9
+# distributed with this work for additional information
10
+# regarding copyright ownership.  The ASF licenses this file
11
+# to you under the Apache License, Version 2.0 (the
12
+# "License"); you may not use this file except in compliance
13
+# with the License.  You may obtain a copy of the License at
14
+#
15
+# http://www.apache.org/licenses/LICENSE-2.0
16
+#
17
+# Unless required by applicable law or agreed to in writing,
18
+# software distributed under the License is distributed on an
19
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+#  KIND, either express or implied.  See the License for the
21
+# specific language governing permissions and limitations
22
+# under the License.
23
+#
24
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BatteryStatus", "BatteryStatus\BatteryStatus.csproj", "{9749E0FB-CDCF-4D80-8953-AAB577B44234}"
25
+EndProject
26
+Global
27
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
28
+		Debug|Any CPU = Debug|Any CPU
29
+		Release|Any CPU = Release|Any CPU
30
+	EndGlobalSection
31
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
32
+		{9749E0FB-CDCF-4D80-8953-AAB577B44234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33
+		{9749E0FB-CDCF-4D80-8953-AAB577B44234}.Debug|Any CPU.Build.0 = Debug|Any CPU
34
+		{9749E0FB-CDCF-4D80-8953-AAB577B44234}.Release|Any CPU.ActiveCfg = Release|Any CPU
35
+		{9749E0FB-CDCF-4D80-8953-AAB577B44234}.Release|Any CPU.Build.0 = Release|Any CPU
36
+	EndGlobalSection
37
+	GlobalSection(SolutionProperties) = preSolution
38
+		HideSolutionNode = FALSE
39
+	EndGlobalSection
40
+EndGlobal

+ 3 - 0
plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/.npmignore

@@ -0,0 +1,3 @@
1
+/bin/
2
+/obj/
3
+*.suo

+ 104 - 0
plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/BatteryStatus.cs

@@ -0,0 +1,104 @@
1
+/*
2
+    Licensed under the Apache License, Version 2.0 (the "License");
3
+    you may not use this file except in compliance with the License.
4
+    You may obtain a copy of the License at
5
+
6
+    http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+    Unless required by applicable law or agreed to in writing, software
9
+    distributed under the License is distributed on an "AS IS" BASIS,
10
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+    See the License for the specific language governing permissions and
12
+    limitations under the License.
13
+*/
14
+
15
+using System;
16
+using System.IO;
17
+using System.Runtime.Serialization;
18
+using System.Runtime.Serialization.Json;
19
+using System.Threading;
20
+using System.Threading.Tasks;
21
+using Windows.Foundation;
22
+using Windows.Phone.Devices.Power;
23
+
24
+namespace BatteryStatus
25
+{
26
+    public sealed class BatteryStatus
27
+    {
28
+        private static Battery battery = Battery.GetDefault();
29
+        private static TaskCompletionSource<string> levelCompletionSource = new TaskCompletionSource<string>();
30
+
31
+        public static string start()
32
+        {
33
+            battery.RemainingChargePercentChanged += BatteryOnRemainingChargePercentChanged;
34
+
35
+            return getBatteryStatus();
36
+        }
37
+
38
+        public static void stop()
39
+        {
40
+            battery.RemainingChargePercentChanged -= BatteryOnRemainingChargePercentChanged;
41
+        }
42
+
43
+        public static string getBatteryStatus()
44
+        {
45
+            try
46
+            {
47
+                return Serialize(typeof(BatteryInfo), new BatteryInfo
48
+                {
49
+                    Level = battery.RemainingChargePercent
50
+                });
51
+            }
52
+            catch (Exception ex)
53
+            {
54
+                return Serialize(typeof(ExceptionInfo), new ExceptionInfo { Message = ex.Message });
55
+            }
56
+        }
57
+
58
+        public static IAsyncOperation<string> getBatteryStatusChangeEvent()
59
+        {
60
+            return GetBatteryStatusChangeEvent().AsAsyncOperation();
61
+        }
62
+
63
+        private static async Task<string> GetBatteryStatusChangeEvent()
64
+        {
65
+            levelCompletionSource = new TaskCompletionSource<string>();
66
+
67
+            return await levelCompletionSource.Task;
68
+        }
69
+
70
+        private static void BatteryOnRemainingChargePercentChanged(object sender, object o)
71
+        {
72
+            levelCompletionSource.SetResult(getBatteryStatus());
73
+        }
74
+
75
+        private static string Serialize(Type type, object obj)
76
+        {
77
+            using (var stream = new MemoryStream())
78
+            {
79
+                var jsonSer = new DataContractJsonSerializer(type);
80
+                jsonSer.WriteObject(stream, obj);
81
+                stream.Position = 0;
82
+                return new StreamReader(stream).ReadToEnd();
83
+            }
84
+        }
85
+
86
+        [DataContract]
87
+        private class BatteryInfo
88
+        {
89
+            [DataMember(Name = "level")]
90
+            public int Level;
91
+
92
+            // Not supported by native API
93
+            [DataMember(Name = "isPlugged")]
94
+            public string IsPlugged;
95
+        };
96
+
97
+        [DataContract]
98
+        private class ExceptionInfo
99
+        {
100
+            [DataMember(Name = "exceptionMessage")]
101
+            public string Message = string.Empty;
102
+        };
103
+    }
104
+}

+ 72 - 0
plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/BatteryStatus.csproj

@@ -0,0 +1,72 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!--
3
+       Licensed to the Apache Software Foundation (ASF) under one
4
+       or more contributor license agreements.  See the NOTICE file
5
+       distributed with this work for additional information
6
+       regarding copyright ownership.  The ASF licenses this file
7
+       to you under the Apache License, Version 2.0 (the
8
+       "License"); you may not use this file except in compliance
9
+       with the License.  You may obtain a copy of the License at
10
+
11
+         http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+       Unless required by applicable law or agreed to in writing,
14
+       software distributed under the License is distributed on an
15
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+       KIND, either express or implied.  See the License for the
17
+       specific language governing permissions and limitations
18
+       under the License.
19
+-->
20
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
21
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
22
+  <PropertyGroup>
23
+    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
24
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
25
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
26
+    <ProjectGuid>{9749E0FB-CDCF-4D80-8953-AAB577B44234}</ProjectGuid>
27
+    <OutputType>winmdobj</OutputType>
28
+    <AppDesignerFolder>Properties</AppDesignerFolder>
29
+    <RootNamespace>BatteryStatus</RootNamespace>
30
+    <AssemblyName>BatteryStatus</AssemblyName>
31
+    <DefaultLanguage>en-US</DefaultLanguage>
32
+    <FileAlignment>512</FileAlignment>
33
+    <ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
34
+    <TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
35
+    <TargetPlatformVersion>8.1</TargetPlatformVersion>
36
+  </PropertyGroup>
37
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
38
+    <DebugSymbols>true</DebugSymbols>
39
+    <DebugType>full</DebugType>
40
+    <Optimize>false</Optimize>
41
+    <OutputPath>bin\Debug\</OutputPath>
42
+    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
43
+    <ErrorReport>prompt</ErrorReport>
44
+    <WarningLevel>4</WarningLevel>
45
+  </PropertyGroup>
46
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
47
+    <DebugType>pdbonly</DebugType>
48
+    <Optimize>true</Optimize>
49
+    <OutputPath>bin\Release\</OutputPath>
50
+    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
51
+    <ErrorReport>prompt</ErrorReport>
52
+    <WarningLevel>4</WarningLevel>
53
+  </PropertyGroup>
54
+  <ItemGroup>
55
+    <!-- A reference to the entire .NET Framework is automatically included -->
56
+  </ItemGroup>
57
+  <ItemGroup>
58
+    <Compile Include="BatteryStatus.cs" />
59
+    <Compile Include="Properties\AssemblyInfo.cs" />
60
+  </ItemGroup>
61
+  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
62
+  <PropertyGroup>
63
+    <PostBuildEvent>xcopy /Y /Q "$(TargetPath)" "$(SolutionDir).."</PostBuildEvent>
64
+  </PropertyGroup>
65
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
66
+       Other similar extension points exist, see Microsoft.Common.targets.
67
+  <Target Name="BeforeBuild">
68
+  </Target>
69
+  <Target Name="AfterBuild">
70
+  </Target>
71
+  -->
72
+</Project>

+ 44 - 0
plugins/cordova-plugin-battery-status/src/windows/BatteryStatus/BatteryStatus/Properties/AssemblyInfo.cs

@@ -0,0 +1,44 @@
1
+/*
2
+    Licensed under the Apache License, Version 2.0 (the "License");
3
+    you may not use this file except in compliance with the License.
4
+    You may obtain a copy of the License at
5
+
6
+    http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+    Unless required by applicable law or agreed to in writing, software
9
+    distributed under the License is distributed on an "AS IS" BASIS,
10
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+    See the License for the specific language governing permissions and
12
+    limitations under the License.
13
+*/
14
+
15
+using System.Resources;
16
+using System.Reflection;
17
+using System.Runtime.CompilerServices;
18
+using System.Runtime.InteropServices;
19
+
20
+// General Information about an assembly is controlled through the following 
21
+// set of attributes. Change these attribute values to modify the information
22
+// associated with an assembly.
23
+[assembly: AssemblyTitle("BatteryStatus")]
24
+[assembly: AssemblyDescription("")]
25
+[assembly: AssemblyConfiguration("")]
26
+[assembly: AssemblyCompany("")]
27
+[assembly: AssemblyProduct("BatteryStatus")]
28
+[assembly: AssemblyCopyright("Copyright ©  2014")]
29
+[assembly: AssemblyTrademark("")]
30
+[assembly: AssemblyCulture("")]
31
+[assembly: NeutralResourcesLanguage("en")]
32
+
33
+// Version information for an assembly consists of the following four values:
34
+//
35
+//      Major Version
36
+//      Minor Version 
37
+//      Build Number
38
+//      Revision
39
+//
40
+// You can specify all the values or you can default the Build and Revision Numbers 
41
+// by using the '*' as shown below:
42
+// [assembly: AssemblyVersion("1.0.*")]
43
+[assembly: AssemblyVersion("1.0.0.0")]
44
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 14 - 0
plugins/cordova-plugin-battery-status/tests/package.json

@@ -0,0 +1,14 @@
1
+{
2
+  "name": "cordova-plugin-battery-status-tests",
3
+  "version": "1.2.4-dev",
4
+  "description": "",
5
+  "cordova": {
6
+    "id": "cordova-plugin-battery-status-tests",
7
+    "platforms": []
8
+  },
9
+  "keywords": [
10
+    "ecosystem:cordova"
11
+  ],
12
+  "author": "",
13
+  "license": "Apache 2.0"
14
+}

+ 31 - 0
plugins/cordova-plugin-battery-status/tests/plugin.xml

@@ -0,0 +1,31 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+  Licensed to the Apache Software Foundation (ASF) under one
4
+  or more contributor license agreements.  See the NOTICE file
5
+  distributed with this work for additional information
6
+  regarding copyright ownership.  The ASF licenses this file
7
+  to you under the Apache License, Version 2.0 (the
8
+  "License"); you may not use this file except in compliance
9
+  with the License.  You may obtain a copy of the License at
10
+
11
+    http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+  Unless required by applicable law or agreed to in writing,
14
+  software distributed under the License is distributed on an
15
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+  KIND, either express or implied.  See the License for the
17
+  specific language governing permissions and limitations
18
+  under the License.
19
+-->
20
+
21
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
22
+    xmlns:rim="http://www.blackberry.com/ns/widgets"
23
+    xmlns:android="http://schemas.android.com/apk/res/android"
24
+    id="cordova-plugin-battery-status-tests"
25
+    version="2.0.1">
26
+    <name>Cordova Battery Plugin Tests</name>
27
+    <license>Apache 2.0</license>
28
+
29
+    <js-module src="tests.js" name="tests">
30
+    </js-module>
31
+</plugin>

+ 556 - 0
plugins/cordova-plugin-battery-status/tests/tests.js

@@ -0,0 +1,556 @@
1
+/*
2
+ *
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements.  See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership.  The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License.  You may obtain a copy of the License at
10
+ *
11
+ *   http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied.  See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+/* eslint-env jasmine */
23
+/* global Windows, WinJS */
24
+
25
+exports.defineAutoTests = function () {
26
+    var hasPowerManagerAPI = cordova.platformId === 'windows' && // eslint-disable-line no-undef
27
+        Windows && Windows.System && Windows.System.Power &&
28
+        Windows.System.Power.PowerManager;
29
+
30
+    var batteryStatusUnsupported = (cordova.platformId === 'windows8' || // eslint-disable-line no-undef
31
+        // We don't test battery status on Windows when there is no corresponding APIs available
32
+        cordova.platformId === 'windows') && !(hasPowerManagerAPI || WinJS.Utilities.isPhone); // eslint-disable-line no-undef
33
+
34
+    var onEvent;
35
+
36
+    describe('Battery (navigator.battery)', function () {
37
+
38
+        it('battery.spec.1 should exist', function () {
39
+            if (batteryStatusUnsupported) {
40
+                pending('Battery status is not supported on windows store');
41
+            }
42
+
43
+            expect(navigator.battery).toBeDefined();
44
+        });
45
+    });
46
+
47
+    describe('Battery Events', function () {
48
+
49
+        describe('batterystatus', function () {
50
+
51
+            afterEach(function () {
52
+                if (!batteryStatusUnsupported) {
53
+                    try {
54
+                        window.removeEventListener('batterystatus', onEvent, false);
55
+                    } catch (e) {
56
+                        console.error('Error removing batterystatus event listener: ' + e);
57
+                    }
58
+                }
59
+            });
60
+
61
+            it('battery.spec.2 should fire batterystatus events', function (done) {
62
+                if (batteryStatusUnsupported) {
63
+                    pending('Battery status is not supported on windows store');
64
+                }
65
+
66
+                onEvent = jasmine.createSpy('BatteryStatus');
67
+
68
+                // batterystatus -> 30
69
+                window.addEventListener('batterystatus', onEvent, false);
70
+
71
+                navigator.battery._status({
72
+                    level: 30,
73
+                    isPlugged: false
74
+                });
75
+
76
+                setTimeout(function () {
77
+                    expect(onEvent).toHaveBeenCalled();
78
+                    done();
79
+                }, 100);
80
+
81
+            });
82
+        });
83
+
84
+        describe('batterylow', function () {
85
+
86
+            afterEach(function () {
87
+                if (!batteryStatusUnsupported) {
88
+                    try {
89
+                        window.removeEventListener('batterylow', onEvent, false);
90
+                    } catch (e) {
91
+                        console.error('Error removing batterylow event listener: ' + e);
92
+                    }
93
+                }
94
+            });
95
+
96
+            it('battery.spec.3 should fire batterylow event (30 -> 20)', function (done) {
97
+                if (batteryStatusUnsupported) {
98
+                    pending('Battery status is not supported on windows store');
99
+                }
100
+
101
+                onEvent = jasmine.createSpy('BatteryLow');
102
+
103
+                // batterylow 30 -> 20
104
+                window.addEventListener('batterylow', onEvent, false);
105
+
106
+                navigator.battery._status({
107
+                    level: 30,
108
+                    isPlugged: false
109
+                });
110
+
111
+                navigator.battery._status({
112
+                    level: 20,
113
+                    isPlugged: false
114
+                });
115
+
116
+                setTimeout(function () {
117
+                    expect(onEvent).toHaveBeenCalled();
118
+                    done();
119
+                }, 100);
120
+
121
+            });
122
+
123
+            it('battery.spec.3.1 should fire batterylow event (30 -> 19)', function (done) {
124
+                if (batteryStatusUnsupported) {
125
+                    pending('Battery status is not supported on windows store');
126
+                }
127
+
128
+                onEvent = jasmine.createSpy('BatteryLow');
129
+
130
+                // batterylow 30 -> 19
131
+                window.addEventListener('batterylow', onEvent, false);
132
+
133
+                navigator.battery._status({
134
+                    level: 30,
135
+                    isPlugged: false
136
+                });
137
+
138
+                navigator.battery._status({
139
+                    level: 19,
140
+                    isPlugged: false
141
+                });
142
+
143
+                setTimeout(function () {
144
+                    expect(onEvent).toHaveBeenCalled();
145
+                    done();
146
+                }, 100);
147
+            });
148
+
149
+            it('battery.spec.3.2 should not fire batterylow event (5 -> 20)', function (done) {
150
+                if (batteryStatusUnsupported) {
151
+                    pending('Battery status is not supported on windows store');
152
+                }
153
+
154
+                onEvent = jasmine.createSpy('BatteryLow');
155
+
156
+                // batterylow should not fire when level increases (5->20) ( CB-4519 )
157
+                window.addEventListener('batterylow', onEvent, false);
158
+
159
+                navigator.battery._status({
160
+                    level: 5,
161
+                    isPlugged: false
162
+                });
163
+
164
+                navigator.battery._status({
165
+                    level: 20,
166
+                    isPlugged: false
167
+                });
168
+
169
+                setTimeout(function () {
170
+                    expect(onEvent).not.toHaveBeenCalled();
171
+                    done();
172
+                }, 100);
173
+            });
174
+
175
+            it('battery.spec.3.3 batterylow event(21 -> 20) should not fire if charging', function (done) {
176
+                if (batteryStatusUnsupported) {
177
+                    pending('Battery status is not supported on windows store');
178
+                }
179
+
180
+                onEvent = jasmine.createSpy('BatteryLow');
181
+
182
+                // batterylow should NOT fire if we are charging   ( CB-4520 )
183
+                window.addEventListener('batterylow', onEvent, false);
184
+
185
+                navigator.battery._status({
186
+                    level: 21,
187
+                    isPlugged: true
188
+                });
189
+
190
+                navigator.battery._status({
191
+                    level: 20,
192
+                    isPlugged: true
193
+                });
194
+
195
+                setTimeout(function () {
196
+                    expect(onEvent).not.toHaveBeenCalled();
197
+                    done();
198
+                }, 100);
199
+            });
200
+        });
201
+
202
+        describe('batterycritical', function () {
203
+
204
+            afterEach(function () {
205
+                if (!batteryStatusUnsupported) {
206
+                    try {
207
+                        window.removeEventListener('batterycritical', onEvent, false);
208
+                    } catch (e) {
209
+                        console.error('Error removing batterycritical event listener: ' + e);
210
+                    }
211
+                }
212
+            });
213
+
214
+            it('battery.spec.4 should fire batterycritical event (19 -> 5)', function (done) {
215
+                if (batteryStatusUnsupported) {
216
+                    pending('Battery status is not supported on windows store');
217
+                }
218
+
219
+                onEvent = jasmine.createSpy('BatteryCritical');
220
+
221
+                // batterycritical 19->5
222
+                window.addEventListener('batterycritical', onEvent, false);
223
+
224
+                navigator.battery._status({
225
+                    level: 19,
226
+                    isPlugged: false
227
+                });
228
+
229
+                navigator.battery._status({
230
+                    level: 5,
231
+                    isPlugged: false
232
+                });
233
+
234
+                setTimeout(function () {
235
+                    expect(onEvent).toHaveBeenCalled();
236
+                    done();
237
+                }, 100);
238
+
239
+            });
240
+
241
+            it('battery.spec.4.1 should fire batterycritical event (19 -> 4)', function (done) {
242
+                if (batteryStatusUnsupported) {
243
+                    pending('Battery status is not supported on windows store');
244
+                }
245
+
246
+                onEvent = jasmine.createSpy('BatteryCritical');
247
+
248
+                // batterycritical 19->4
249
+                window.addEventListener('batterycritical', onEvent, false);
250
+
251
+                navigator.battery._status({
252
+                    level: 19,
253
+                    isPlugged: false
254
+                });
255
+
256
+                navigator.battery._status({
257
+                    level: 4,
258
+                    isPlugged: false
259
+                });
260
+
261
+                setTimeout(function () {
262
+                    expect(onEvent).toHaveBeenCalled();
263
+                    done();
264
+                }, 100);
265
+
266
+            });
267
+
268
+            it('battery.spec.4.2 should fire batterycritical event (100 -> 4) when decreases', function (done) {
269
+                if (batteryStatusUnsupported) {
270
+                    pending('Battery status is not supported on windows store');
271
+                }
272
+
273
+                onEvent = jasmine.createSpy('BatteryCritical');
274
+
275
+                // setup: batterycritical should fire when level decreases (100->4) ( CB-4519 )
276
+                window.addEventListener('batterycritical', onEvent, false);
277
+
278
+                navigator.battery._status({
279
+                    level: 100,
280
+                    isPlugged: false
281
+                });
282
+
283
+                navigator.battery._status({
284
+                    level: 4,
285
+                    isPlugged: false
286
+                });
287
+
288
+                setTimeout(function () {
289
+                    expect(onEvent).toHaveBeenCalled();
290
+                    done();
291
+                }, 100);
292
+            });
293
+
294
+            it('battery.spec.4.3 should not fire batterycritical event (4 -> 5) when increasing', function (done) {
295
+                if (batteryStatusUnsupported) {
296
+                    pending('Battery status is not supported on windows store');
297
+                }
298
+
299
+                onEvent = jasmine.createSpy('BatteryCritical');
300
+
301
+                window.addEventListener('batterycritical', onEvent, false);
302
+
303
+                // batterycritical should not fire when level increases (4->5)( CB-4519 )
304
+                navigator.battery._status({
305
+                    level: 4,
306
+                    isPlugged: false
307
+                });
308
+
309
+                navigator.battery._status({
310
+                    level: 5,
311
+                    isPlugged: false
312
+                });
313
+
314
+                setTimeout(function () {
315
+                    expect(onEvent.calls.count()).toBeLessThan(2);
316
+                    done();
317
+                }, 100);
318
+            });
319
+
320
+            it('battery.spec.4.4 should not fire batterycritical event (6 -> 5) if charging', function (done) {
321
+                if (batteryStatusUnsupported) {
322
+                    pending('Battery status is not supported on windows store');
323
+                }
324
+
325
+                onEvent = jasmine.createSpy('BatteryCritical');
326
+
327
+                window.addEventListener('batterycritical', onEvent, false);
328
+
329
+                // batterycritical should NOT fire if we are charging   ( CB-4520 )
330
+                navigator.battery._status({
331
+                    level: 6,
332
+                    isPlugged: true
333
+                });
334
+
335
+                navigator.battery._status({
336
+                    level: 5,
337
+                    isPlugged: true
338
+                });
339
+
340
+                setTimeout(function () {
341
+                    expect(onEvent).not.toHaveBeenCalled();
342
+                    done();
343
+                }, 100);
344
+            });
345
+        });
346
+    });
347
+};
348
+
349
+//* *****************************************************************************************
350
+//* **************************************Manual Tests***************************************
351
+//* *****************************************************************************************
352
+
353
+exports.defineManualTests = function (contentEl, createActionButton) {
354
+
355
+    /* Battery */
356
+    function updateInfo (info) {
357
+        document.getElementById('levelValue').innerText = info.level;
358
+        document.getElementById('pluggedValue').innerText = info.isPlugged;
359
+        if (info.level > 5) {
360
+            document.getElementById('criticalValue').innerText = 'false';
361
+        }
362
+        if (info.level > 20) {
363
+            document.getElementById('lowValue').innerText = 'false';
364
+        }
365
+    }
366
+
367
+    function batteryLow (info) {
368
+        document.getElementById('lowValue').innerText = 'true';
369
+    }
370
+
371
+    function batteryCritical (info) {
372
+        document.getElementById('criticalValue').innerText = 'true';
373
+    }
374
+
375
+    function addBattery () {
376
+        window.addEventListener('batterystatus', updateInfo, false);
377
+    }
378
+
379
+    function removeBattery () {
380
+        window.removeEventListener('batterystatus', updateInfo, false);
381
+    }
382
+
383
+    function addLow () {
384
+        window.addEventListener('batterylow', batteryLow, false);
385
+    }
386
+
387
+    function removeLow () {
388
+        window.removeEventListener('batterylow', batteryLow, false);
389
+    }
390
+
391
+    function addCritical () {
392
+        window.addEventListener('batterycritical', batteryCritical, false);
393
+    }
394
+
395
+    function removeCritical () {
396
+        window.removeEventListener('batterycritical', batteryCritical, false);
397
+    }
398
+
399
+    // Generate Dynamic Table
400
+    function generateTable (tableId, rows, cells, elements) {
401
+        var table = document.createElement('table');
402
+        for (var r = 0; r < rows; r++) {
403
+            var row = table.insertRow(r);
404
+            for (var c = 0; c < cells; c++) {
405
+                var cell = row.insertCell(c);
406
+                cell.setAttribute('align', 'center');
407
+                for (var e in elements) {
408
+                    if (elements[e].position.row === r && elements[e].position.cell === c) {
409
+                        var htmlElement = document.createElement(elements[e].tag);
410
+                        var content;
411
+
412
+                        if (elements[e].content !== '') {
413
+                            content = document.createTextNode(elements[e].content);
414
+                            htmlElement.appendChild(content);
415
+                        }
416
+                        if (elements[e].type) {
417
+                            htmlElement.type = elements[e].type;
418
+                        }
419
+                        htmlElement.setAttribute('id', elements[e].id);
420
+                        cell.appendChild(htmlElement);
421
+                    }
422
+                }
423
+            }
424
+        }
425
+        table.setAttribute('align', 'center');
426
+        table.setAttribute('id', tableId);
427
+        return table;
428
+    }
429
+    // Battery Elements
430
+    var batteryElements =
431
+        [{
432
+            id: 'statusTag',
433
+            content: 'Status:',
434
+            tag: 'div',
435
+            position: {
436
+                row: 0,
437
+                cell: 0
438
+            }
439
+        }, {
440
+            id: 'statusValue',
441
+            content: '',
442
+            tag: 'div',
443
+            position: {
444
+                row: 0,
445
+                cell: 1
446
+            }
447
+        }, {
448
+            id: 'levelTag',
449
+            content: 'Level:',
450
+            tag: 'div',
451
+            position: {
452
+                row: 1,
453
+                cell: 0
454
+            }
455
+        }, {
456
+            id: 'levelValue',
457
+            content: '',
458
+            tag: 'div',
459
+            position: {
460
+                row: 1,
461
+                cell: 1
462
+            }
463
+        }, {
464
+            id: 'pluggedTag',
465
+            content: 'Plugged:',
466
+            tag: 'div',
467
+            position: {
468
+                row: 2,
469
+                cell: 0
470
+            }
471
+        }, {
472
+            id: 'pluggedValue',
473
+            content: '',
474
+            tag: 'div',
475
+            position: {
476
+                row: 2,
477
+                cell: 1
478
+            }
479
+        }, {
480
+            id: 'lowTag',
481
+            content: 'Low:',
482
+            tag: 'div',
483
+            position: {
484
+                row: 3,
485
+                cell: 0
486
+            }
487
+        }, {
488
+            id: 'lowValue',
489
+            content: '',
490
+            tag: 'div',
491
+            position: {
492
+                row: 3,
493
+                cell: 1
494
+            }
495
+        }, {
496
+            id: 'criticalTag',
497
+            content: 'Critical:',
498
+            tag: 'div',
499
+            position: {
500
+                row: 4,
501
+                cell: 0
502
+            }
503
+        }, {
504
+            id: 'criticalValue',
505
+            content: '',
506
+            tag: 'div',
507
+            position: {
508
+                row: 4,
509
+                cell: 1
510
+            }
511
+        }
512
+        ];
513
+
514
+    // Title audio results
515
+    var div = document.createElement('h2');
516
+    div.appendChild(document.createTextNode('Battery Status'));
517
+    div.setAttribute('align', 'center');
518
+    contentEl.appendChild(div);
519
+
520
+    var batteryTable = generateTable('info', 5, 3, batteryElements);
521
+    contentEl.appendChild(batteryTable);
522
+
523
+    div = document.createElement('h2');
524
+    div.appendChild(document.createTextNode('Actions'));
525
+    div.setAttribute('align', 'center');
526
+    contentEl.appendChild(div);
527
+
528
+    contentEl.innerHTML += '<h3>Battery Status Tests</h3>' +
529
+        'Will update values for level and plugged when they change. If battery low and critical values are false, they will get updated in status box, but only once' +
530
+        '<div id="addBS"></div><div id="remBs"></div>' +
531
+        '<h3>Battery Low Tests</h3>' +
532
+        '</p> Will update value for battery low to true when battery is below 20%' +
533
+        '<div id="addBl"></div><div id="remBl"></div>' +
534
+        '<h3>Battery Critical Tests</h3>' +
535
+        '</p> Will update value for battery critical to true when battery is below 5%' +
536
+        '<div id="addBc"></div><div id="remBc"></div>';
537
+
538
+    createActionButton('Add "batterystatus" listener', function () {
539
+        addBattery();
540
+    }, 'addBS');
541
+    createActionButton('Remove "batterystatus" listener', function () {
542
+        removeBattery();
543
+    }, 'remBs');
544
+    createActionButton('Add "batterylow" listener', function () {
545
+        addLow();
546
+    }, 'addBl');
547
+    createActionButton('Remove "batterylow" listener', function () {
548
+        removeLow();
549
+    }, 'remBl');
550
+    createActionButton('Add "batterycritical" listener', function () {
551
+        addCritical();
552
+    }, 'addBc');
553
+    createActionButton('Remove "batterycritical" listener', function () {
554
+        removeCritical();
555
+    }, 'remBc');
556
+};

+ 125 - 0
plugins/cordova-plugin-battery-status/types/index.d.ts

@@ -0,0 +1,125 @@
1
+// Type definitions for Apache Cordova BatteryStatus plugin
2
+// Project: https://github.com/apache/cordova-plugin-battery-status
3
+// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
4
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+// 
6
+// Copyright (c) Microsoft Open Technologies Inc
7
+// Licensed under the MIT license. 
8
+
9
+interface Window {
10
+    onbatterystatus: (type: BatteryStatusEvent) => void;
11
+    onbatterycritical: (type: BatteryStatusEvent) => void;
12
+    onbatterylow: (type: BatteryStatusEvent) => void;
13
+    /**
14
+     * Adds a listener for an event from the BatteryStatus plugin.
15
+     * @param type      the event to listen for
16
+     *                  batterystatus: event fires when the percentage of battery charge
17
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
18
+     *                  batterycritical: event fires when the percentage of battery charge has reached
19
+     *                  the critical battery threshold. The value is device-specific.
20
+     *                  batterylow: event fires when the percentage of battery charge has
21
+     *                  reached the low battery threshold, device-specific value.
22
+     * @param listener  the function that executes when the event fires. The function is
23
+     *                  passed an BatteryStatusEvent object as a parameter.
24
+     */
25
+    addEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
26
+    /**
27
+     * Adds a listener for an event from the BatteryStatus plugin.
28
+     * @param type      the event to listen for
29
+     *                  batterystatus: event fires when the percentage of battery charge
30
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
31
+     *                  batterycritical: event fires when the percentage of battery charge has reached
32
+     *                  the critical battery threshold. The value is device-specific.
33
+     *                  batterylow: event fires when the percentage of battery charge has
34
+     *                  reached the low battery threshold, device-specific value.
35
+     * @param listener  the function that executes when the event fires. The function is
36
+     *                  passed an BatteryStatusEvent object as a parameter.
37
+     */
38
+    addEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
39
+    /**
40
+     * Adds a listener for an event from the BatteryStatus plugin.
41
+     * @param type      the event to listen for
42
+     *                  batterystatus: event fires when the percentage of battery charge
43
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
44
+     *                  batterycritical: event fires when the percentage of battery charge has reached
45
+     *                  the critical battery threshold. The value is device-specific.
46
+     *                  batterylow: event fires when the percentage of battery charge has
47
+     *                  reached the low battery threshold, device-specific value.
48
+     * @param listener  the function that executes when the event fires. The function is
49
+     *                  passed an BatteryStatusEvent object as a parameter.
50
+     */
51
+    addEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
52
+    /**
53
+     * Adds a listener for an event from the BatteryStatus plugin.
54
+     * @param type      the event to listen for
55
+     *                  batterystatus: event fires when the percentage of battery charge
56
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
57
+     *                  batterycritical: event fires when the percentage of battery charge has reached
58
+     *                  the critical battery threshold. The value is device-specific.
59
+     *                  batterylow: event fires when the percentage of battery charge has
60
+     *                  reached the low battery threshold, device-specific value.
61
+     * @param listener  the function that executes when the event fires. The function is
62
+     *                  passed an BatteryStatusEvent object as a parameter.
63
+     */
64
+    addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
65
+    /**
66
+     * Removes a listener for an event from the BatteryStatus plugin.
67
+     * @param type      The event to stop listening for.
68
+     *                  batterystatus: event fires when the percentage of battery charge
69
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
70
+     *                  batterycritical: event fires when the percentage of battery charge has reached
71
+     *                  the critical battery threshold. The value is device-specific.
72
+     *                  batterylow: event fires when the percentage of battery charge has
73
+     *                  reached the low battery threshold, device-specific value.
74
+     * @param callback  the function that executes when the event fires. The function is
75
+     *                  passed an BatteryStatusEvent object as a parameter.
76
+     */
77
+    removeEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
78
+    /**
79
+     * Removes a listener for an event from the BatteryStatus plugin.
80
+     * @param type      The event to stop listening for.
81
+     *                  batterystatus: event fires when the percentage of battery charge
82
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
83
+     *                  batterycritical: event fires when the percentage of battery charge has reached
84
+     *                  the critical battery threshold. The value is device-specific.
85
+     *                  batterylow: event fires when the percentage of battery charge has
86
+     *                  reached the low battery threshold, device-specific value.
87
+     * @param callback  the function that executes when the event fires. The function is
88
+     *                  passed an BatteryStatusEvent object as a parameter.
89
+     */
90
+    removeEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
91
+    /**
92
+     * Removes a listener for an event from the BatteryStatus plugin.
93
+     * @param type      The event to stop listening for.
94
+     *                  batterystatus: event fires when the percentage of battery charge
95
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
96
+     *                  batterycritical: event fires when the percentage of battery charge has reached
97
+     *                  the critical battery threshold. The value is device-specific.
98
+     *                  batterylow: event fires when the percentage of battery charge has
99
+     *                  reached the low battery threshold, device-specific value.
100
+     * @param callback  the function that executes when the event fires. The function is
101
+     *                  passed an BatteryStatusEvent object as a parameter.
102
+     */
103
+    removeEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
104
+    /**
105
+     * Removes a listener for an event from the BatteryStatus plugin.
106
+     * @param type      The event to stop listening for.
107
+     *                  batterystatus: event fires when the percentage of battery charge
108
+     *                  changes by at least 1 percent, or if the device is plugged in or unplugged.
109
+     *                  batterycritical: event fires when the percentage of battery charge has reached
110
+     *                  the critical battery threshold. The value is device-specific.
111
+     *                  batterylow: event fires when the percentage of battery charge has
112
+     *                  reached the low battery threshold, device-specific value.
113
+     * @param callback  the function that executes when the event fires. The function is
114
+     *                  passed an BatteryStatusEvent object as a parameter.
115
+     */
116
+    removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
117
+}
118
+
119
+/** Object, that passed into battery event listener */
120
+interface BatteryStatusEvent extends Event {
121
+	/* The percentage of battery charge (0-100). */
122
+    level: number;
123
+	/* A boolean that indicates whether the device is plugged in. */
124
+    isPlugged: boolean;
125
+}

+ 109 - 0
plugins/cordova-plugin-battery-status/www/battery.js

@@ -0,0 +1,109 @@
1
+/*
2
+ *
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements.  See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership.  The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License.  You may obtain a copy of the License at
10
+ *
11
+ *   http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied.  See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+*/
21
+
22
+/**
23
+ * This class contains information about the current battery status.
24
+ * @constructor
25
+ */
26
+var cordova = require('cordova');
27
+var exec = require('cordova/exec');
28
+
29
+var STATUS_CRITICAL = 5;
30
+var STATUS_LOW = 20;
31
+
32
+var Battery = function () {
33
+    this._level = null;
34
+    this._isPlugged = null;
35
+    // Create new event handlers on the window (returns a channel instance)
36
+    this.channels = {
37
+        batterystatus: cordova.addWindowEventHandler('batterystatus'),
38
+        batterylow: cordova.addWindowEventHandler('batterylow'),
39
+        batterycritical: cordova.addWindowEventHandler('batterycritical')
40
+    };
41
+    for (var key in this.channels) {
42
+        this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
43
+    }
44
+};
45
+
46
+function handlers () {
47
+    return battery.channels.batterystatus.numHandlers +
48
+        battery.channels.batterylow.numHandlers +
49
+        battery.channels.batterycritical.numHandlers;
50
+}
51
+
52
+/**
53
+ * Event handlers for when callbacks get registered for the battery.
54
+ * Keep track of how many handlers we have so we can start and stop the native battery listener
55
+ * appropriately (and hopefully save on battery life!).
56
+ */
57
+Battery.onHasSubscribersChange = function () {
58
+  // If we just registered the first handler, make sure native listener is started.
59
+    if (this.numHandlers === 1 && handlers() === 1) {
60
+        exec(battery._status, battery._error, 'Battery', 'start', []);
61
+    } else if (handlers() === 0) {
62
+        exec(null, null, 'Battery', 'stop', []);
63
+    }
64
+};
65
+
66
+/**
67
+ * Callback for battery status
68
+ *
69
+ * @param {Object} info            keys: level, isPlugged
70
+ */
71
+Battery.prototype._status = function (info) {
72
+
73
+    if (info) {
74
+        if (battery._level !== info.level || battery._isPlugged !== info.isPlugged) {
75
+
76
+            if (info.level === null && battery._level !== null) {
77
+                return; // special case where callback is called because we stopped listening to the native side.
78
+            }
79
+
80
+            // Something changed. Fire batterystatus event
81
+            cordova.fireWindowEvent('batterystatus', info);
82
+
83
+            if (!info.isPlugged) { // do not fire low/critical if we are charging. issue: CB-4520
84
+                // note the following are NOT exact checks, as we want to catch a transition from
85
+                // above the threshold to below. issue: CB-4519
86
+                if (battery._level > STATUS_CRITICAL && info.level <= STATUS_CRITICAL) {
87
+                    // Fire critical battery event
88
+                    cordova.fireWindowEvent('batterycritical', info);
89
+                } else if (battery._level > STATUS_LOW && info.level <= STATUS_LOW) {
90
+                    // Fire low battery event
91
+                    cordova.fireWindowEvent('batterylow', info);
92
+                }
93
+            }
94
+            battery._level = info.level;
95
+            battery._isPlugged = info.isPlugged;
96
+        }
97
+    }
98
+};
99
+
100
+/**
101
+ * Error callback for battery start
102
+ */
103
+Battery.prototype._error = function (e) {
104
+    console.log('Error initializing Battery: ' + e);
105
+};
106
+
107
+var battery = new Battery(); // jshint ignore:line
108
+
109
+module.exports = battery;

+ 37 - 0
plugins/cordova-plugin-whitelist/CONTRIBUTING.md

@@ -0,0 +1,37 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+
22
+# Contributing to Apache Cordova
23
+
24
+Anyone can contribute to Cordova. And we need your contributions.
25
+
26
+There are multiple ways to contribute: report bugs, improve the docs, and
27
+contribute code.
28
+
29
+For instructions on this, start with the
30
+[contribution overview](http://cordova.apache.org/contribute/).
31
+
32
+The details are explained there, but the important items are:
33
+ - Sign and submit an Apache ICLA (Contributor License Agreement).
34
+ - Have a Jira issue open that corresponds to your contribution.
35
+ - Run the tests so your patch doesn't break existing functionality.
36
+
37
+We look forward to your contributions!

+ 202 - 0
plugins/cordova-plugin-whitelist/LICENSE

@@ -0,0 +1,202 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+
177
+   END OF TERMS AND CONDITIONS
178
+
179
+   APPENDIX: How to apply the Apache License to your work.
180
+
181
+      To apply the Apache License to your work, attach the following
182
+      boilerplate notice, with the fields enclosed by brackets "[]"
183
+      replaced with your own identifying information. (Don't include
184
+      the brackets!)  The text should be enclosed in the appropriate
185
+      comment syntax for the file format. We also recommend that a
186
+      file or class name and description of purpose be included on the
187
+      same "printed page" as the copyright notice for easier
188
+      identification within third-party archives.
189
+
190
+   Copyright [yyyy] [name of copyright owner]
191
+
192
+   Licensed under the Apache License, Version 2.0 (the "License");
193
+   you may not use this file except in compliance with the License.
194
+   You may obtain a copy of the License at
195
+
196
+       http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+   Unless required by applicable law or agreed to in writing, software
199
+   distributed under the License is distributed on an "AS IS" BASIS,
200
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+   See the License for the specific language governing permissions and
202
+   limitations under the License.

+ 5 - 0
plugins/cordova-plugin-whitelist/NOTICE

@@ -0,0 +1,5 @@
1
+Apache Cordova
2
+Copyright 2012 The Apache Software Foundation
3
+
4
+This product includes software developed at
5
+The Apache Software Foundation (http://www.apache.org/).

+ 163 - 0
plugins/cordova-plugin-whitelist/README.md

@@ -0,0 +1,163 @@
1
+---
2
+title: Whitelist
3
+description: Whitelist external content accessible by your app.
4
+---
5
+<!--
6
+# license: Licensed to the Apache Software Foundation (ASF) under one
7
+#         or more contributor license agreements.  See the NOTICE file
8
+#         distributed with this work for additional information
9
+#         regarding copyright ownership.  The ASF licenses this file
10
+#         to you under the Apache License, Version 2.0 (the
11
+#         "License"); you may not use this file except in compliance
12
+#         with the License.  You may obtain a copy of the License at
13
+#
14
+#           http://www.apache.org/licenses/LICENSE-2.0
15
+#
16
+#         Unless required by applicable law or agreed to in writing,
17
+#         software distributed under the License is distributed on an
18
+#         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+#         KIND, either express or implied.  See the License for the
20
+#         specific language governing permissions and limitations
21
+#         under the License.
22
+-->
23
+
24
+# cordova-plugin-whitelist
25
+
26
+This plugin implements a whitelist policy for navigating the application webview on Cordova 4.0
27
+
28
+:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Whitelist%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
29
+
30
+## Installation
31
+
32
+You can install whitelist plugin with Cordova CLI, from npm:
33
+
34
+```
35
+$ cordova plugin add cordova-plugin-whitelist
36
+$ cordova prepare
37
+```
38
+
39
+## Supported Cordova Platforms
40
+
41
+* Android 4.0.0 or above
42
+
43
+## Navigation Whitelist
44
+Controls which URLs the WebView itself can be navigated to. Applies to
45
+top-level navigations only.
46
+
47
+Quirks: on Android it also applies to iframes for non-http(s) schemes.
48
+
49
+By default, navigations only to `file://` URLs, are allowed. To allow others URLs, you must add `<allow-navigation>` tags to your `config.xml`:
50
+
51
+    <!-- Allow links to example.com -->
52
+    <allow-navigation href="http://example.com/*" />
53
+
54
+    <!-- Wildcards are allowed for the protocol, as a prefix
55
+         to the host, or as a suffix to the path -->
56
+    <allow-navigation href="*://*.example.com/*" />
57
+
58
+    <!-- A wildcard can be used to whitelist the entire network,
59
+         over HTTP and HTTPS.
60
+         *NOT RECOMMENDED* -->
61
+    <allow-navigation href="*" />
62
+
63
+    <!-- The above is equivalent to these three declarations -->
64
+    <allow-navigation href="http://*/*" />
65
+    <allow-navigation href="https://*/*" />
66
+    <allow-navigation href="data:*" />
67
+
68
+## Intent Whitelist
69
+Controls which URLs the app is allowed to ask the system to open.
70
+By default, no external URLs are allowed.
71
+
72
+On Android, this equates to sending an intent of type BROWSEABLE.
73
+
74
+This whitelist does not apply to plugins, only hyperlinks and calls to `window.open()`.
75
+
76
+In `config.xml`, add `<allow-intent>` tags, like this:
77
+
78
+    <!-- Allow links to web pages to open in a browser -->
79
+    <allow-intent href="http://*/*" />
80
+    <allow-intent href="https://*/*" />
81
+
82
+    <!-- Allow links to example.com to open in a browser -->
83
+    <allow-intent href="http://example.com/*" />
84
+
85
+    <!-- Wildcards are allowed for the protocol, as a prefix
86
+         to the host, or as a suffix to the path -->
87
+    <allow-intent href="*://*.example.com/*" />
88
+
89
+    <!-- Allow SMS links to open messaging app -->
90
+    <allow-intent href="sms:*" />
91
+
92
+    <!-- Allow tel: links to open the dialer -->
93
+    <allow-intent href="tel:*" />
94
+
95
+    <!-- Allow geo: links to open maps -->
96
+    <allow-intent href="geo:*" />
97
+
98
+    <!-- Allow all unrecognized URLs to open installed apps
99
+         *NOT RECOMMENDED* -->
100
+    <allow-intent href="*" />
101
+
102
+## Network Request Whitelist
103
+Controls which network requests (images, XHRs, etc) are allowed to be made (via cordova native hooks).
104
+
105
+Note: We suggest you use a Content Security Policy (see below), which is more secure.  This whitelist is mostly historical for webviews which do not support CSP.
106
+
107
+In `config.xml`, add `<access>` tags, like this:
108
+
109
+    <!-- Allow images, xhrs, etc. to google.com -->
110
+    <access origin="http://google.com" />
111
+    <access origin="https://google.com" />
112
+
113
+    <!-- Access to the subdomain maps.google.com -->
114
+    <access origin="http://maps.google.com" />
115
+
116
+    <!-- Access to all the subdomains on google.com -->
117
+    <access origin="http://*.google.com" />
118
+
119
+    <!-- Enable requests to content: URLs -->
120
+    <access origin="content:///*" />
121
+
122
+    <!-- Don't block any requests -->
123
+    <access origin="*" />
124
+
125
+Without any `<access>` tags, only requests to `file://` URLs are allowed. However, the default Cordova application includes `<access origin="*">` by default.
126
+
127
+
128
+Note: Whitelist cannot block network redirects from a whitelisted remote website (i.e. http or https) to a non-whitelisted website. Use CSP rules to mitigate redirects to non-whitelisted websites for webviews that support CSP.
129
+
130
+Quirk: Android also allows requests to https://ssl.gstatic.com/accessibility/javascript/android/ by default, since this is required for TalkBack to function properly.
131
+
132
+### Content Security Policy
133
+Controls which network requests (images, XHRs, etc) are allowed to be made (via webview directly).
134
+
135
+On Android and iOS, the network request whitelist (see above) is not able to filter all types of requests (e.g. `<video>` & WebSockets are not blocked). So, in addition to the whitelist, you should use a [Content Security Policy](http://content-security-policy.com/) `<meta>` tag on all of your pages.
136
+
137
+On Android, support for CSP within the system webview starts with KitKat (but is available on all versions using Crosswalk WebView).
138
+
139
+Here are some example CSP declarations for your `.html` pages:
140
+
141
+    <!-- Good default declaration:
142
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
143
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
144
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
145
+            * Enable inline JS: add 'unsafe-inline' to default-src
146
+            * Enable eval(): add 'unsafe-eval' to default-src
147
+    -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
149
+
150
+    <!-- Allow everything but only from the same origin and foo.com -->
151
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
152
+
153
+    <!-- This policy allows everything (eg CSS, AJAX, object, frame, media, etc) except that 
154
+        * CSS only from the same origin and inline styles,
155
+        * scripts only from the same origin and inline styles, and eval()
156
+    -->
157
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
158
+
159
+    <!-- Allows XHRs only over HTTPS on the same domain. -->
160
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
161
+
162
+    <!-- Allow iframe to https://cordova.apache.org/ -->
163
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 75 - 0
plugins/cordova-plugin-whitelist/RELEASENOTES.md

@@ -0,0 +1,75 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+# Release Notes
22
+
23
+### 1.3.3 (Nov 06, 2017)
24
+* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
25
+
26
+### 1.3.2 (Feb 28, 2017)
27
+* [CB-12236](https://issues.apache.org/jira/browse/CB-12236) Fixed `RELEASENOTES` for `cordova-plugin-whitelist`
28
+
29
+### 1.3.1 (Dec 07, 2016)
30
+* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.3.1
31
+* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
32
+* Edit package.json license to match SPDX id
33
+* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
34
+
35
+### 1.3.0 (Sep 08, 2016)
36
+* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
37
+* Updated installation section
38
+* Plugin uses `Android Log class` and not `Cordova LOG class`
39
+* Add pull request template.
40
+* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine info to `package.json`
41
+* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
42
+
43
+### 1.2.2 (Apr 15, 2016)
44
+* add note about redirects
45
+* [CB-10624](https://issues.apache.org/jira/browse/CB-10624) remove error message from `whitelist.js`, which leaves it empty
46
+
47
+### 1.2.1 (Jan 15, 2016)
48
+* [CB-10194](https://issues.apache.org/jira/browse/CB-10194) info tag prints for ios when not applicable
49
+
50
+### 1.2.0 (Nov 18, 2015)
51
+* removed **iOS** engine check from `plugin.xml`
52
+* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
53
+* [CB-9972](https://issues.apache.org/jira/browse/CB-9972) - Remove **iOS** whitelist
54
+* Updated the text, it should read 4.0.x and greater, since this plugin will be required for `cordova-android 5.0`
55
+* Fixing contribute link.
56
+* Updated `plugin.xml <info>` tag to remove warning about not needing this plugin if you are using the **iOS 9 SDK**
57
+* [CB-9738](https://issues.apache.org/jira/browse/CB-9738) - Disable whitelist use when runtime environment is **iOS 9**
58
+* [CB-9740](https://issues.apache.org/jira/browse/CB-9740) - Add `<info>` tag describing whitelist plugin not needed on `cordova-ios` and cordova-android 3.x`
59
+* [CB-9568](https://issues.apache.org/jira/browse/CB-9568) - Update whitelist plugin to allow all network access by default
60
+* [CB-9337](https://issues.apache.org/jira/browse/CB-9337) - enable use of `<access>` tags for native code network requests
61
+
62
+### 1.1.0 (Jun 17, 2015)
63
+* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-whitelist documentation translation: cordova-plugin-whitelist
64
+* fix npm md issue
65
+* Usage of CDVURLRequestFilter protocol.
66
+* [CB-9089](https://issues.apache.org/jira/browse/CB-9089) - iOS whitelist plugin does not compile
67
+* [CB-9090](https://issues.apache.org/jira/browse/CB-9090) - Enable whitelist plugin for cordova-ios 4.0.0
68
+* Fixed error in Content-Security-Policy example
69
+
70
+### 1.0.0 (Mar 25, 2015)
71
+* [CB-8739](https://issues.apache.org/jira/browse/CB-8739) added missing license headers
72
+* Add @Override to CustomConfigXmlParser methods
73
+* Change ID to cordova-plugin-whitelist rather than reverse-DNS-style
74
+* Tweak CSP examples in README
75
+* [CB-8660](https://issues.apache.org/jira/browse/CB-8660) remove extra commas from package.json

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/de/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+Dieses Plugin implementiert eine Whitelist-Politik für die Navigation in der Anwendung Webview Cordova 4.0
23
+
24
+## Cordova unterstützte Plattformen
25
+
26
+  * Android 4.0.0 oder höher
27
+  * iOS 4.0.0 oder höher
28
+
29
+## Navigation-Whitelist
30
+
31
+Steuert, welche URLs die WebView selbst zu navigiert werden kann. Bezieht sich auf der obersten Ebene Navigationen nur.
32
+
33
+Macken: auf Android es gilt auch für Iframes für nicht-http(s) Systeme.
34
+
35
+In der Standardeinstellung Navigationen nur auf `file://` URLs, sind zulässig. Wenn andere andere URLs zulassen möchten, müssen Sie Ihre `"config.xml"` `<allow-navigation>` Markierungen hinzufügen:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Vorsatz-Whitelist
56
+
57
+Steuert, welche URLs die app zulässig ist, um das System zu öffnen Fragen. Standardmäßig dürfen keine externe URLs.
58
+
59
+Das entspricht auf Android eine Absicht des Typs BROWSEABLE senden.
60
+
61
+Diese Whitelist gilt nicht für Plugins, nur Hyperlinks und Aufrufe von `window.open()`.
62
+
63
+Fügen Sie in `"config.xml"` `<allow-intent>` Tags hinzu, wie folgt:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Netzwerk-Anforderung-Whitelist
91
+
92
+Steuert, welche-Anforderungen Netzwerk (Bilder, XHRs, etc.) dürfen (über Cordova native Haken) erfolgen.
93
+
94
+Hinweis: Wir empfehlen Ihnen eine Content Security Policy (siehe unten), das ist sicherer. Diese Whitelist ist vor allem historisch für Webansichten für die CSP nicht unterstützen.
95
+
96
+Fügen Sie in `"config.xml"` `<access>` Tags hinzu, wie folgt:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Ohne `<access>` -Tags dürfen nur Anforderungen an `file://` URLs. Enthält jedoch die Standardanwendung Cordova `<access origin="*">` standardmäßig.
116
+
117
+Eigenart: Android kann auch Anforderungen an https://ssl.gstatic.com/accessibility/javascript/android/ standardmäßig, da dies für TalkBack ordnungsgemäß erforderlich ist.
118
+
119
+### Content-Security-Policy
120
+
121
+Steuert, welche-Anforderungen Netzwerk (Bilder, XHRs, etc.) dürfen (über Webview direkt) erfolgen.
122
+
123
+Auf Android und iOS ist die Netzwerk Anfrage Whitelist (s.o.) nicht in der Lage, alle Arten von Anfragen (z.B. `< video >` & WebSockets nicht blockiert) filtern. Also, sollten Sie neben der Whitelist, [Content Security Policy](http://content-security-policy.com/) `< Meta >` -Tags auf allen Ihren Seiten verwenden.
124
+
125
+Auf Android Unterstützung für CSP innerhalb der System-Webview beginnt mit KitKat (aber ist in allen Versionen mit Crosswalk WebView verfügbar).
126
+
127
+Hier sind einige Beispiel-CSP-Deklarationen für Ihre `HTML` -Seiten:
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/es/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+Este plugin implementa una política de lista blanca para navegar la aplicación webview en Cordova 4.0
23
+
24
+## Plataformas soportadas Cordova
25
+
26
+  * Android 4.0 o superior
27
+  * iOS 4.0.0 o superior
28
+
29
+## Lista blanca de navegación
30
+
31
+Controla que las URLs del WebView se puede navegar a. Se aplica a nivel superior navegaciones solo.
32
+
33
+Peculiaridades: en Android también se aplica a iframes para esquemas que son de http (s).
34
+
35
+Por defecto, navegaciones solo a direcciones URL `file://` , son permitidas. Para permitir que otros otras URL, debe agregar `< allow-navegación >` etiquetas en el `archivo config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Intención de lista blanca
56
+
57
+Controla qué URLs de la aplicación se permite hacer el sistema para abrir. De forma predeterminada, se permiten ninguÌ n external URLs.
58
+
59
+En Android, esto equivale a enviar una intención de tipo BROWSEABLE.
60
+
61
+Esta lista blanca no se aplica a plugins, sólo los hipervínculos y las llamadas a `window.Open)`.
62
+
63
+En `config.xml`, agregar etiquetas `< allow-intent >` , como este:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Solicitud de red blanca
91
+
92
+Controles que las peticiones de la red (imágenes, XHRs, etc.) se les permite hacer (a través de ganchos nativa de Córdoba).
93
+
94
+Nota: Le sugerimos que utilice una política de seguridad de contenido (véase abajo), que es más seguro. Esta lista blanca es sobre todo histórico para webviews que no admiten la CSP.
95
+
96
+En `config.xml`, agregue etiquetas de `< access >` , como este:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Sin las etiquetas `< access >` , se admiten sólo las solicitudes a direcciones URL `file://` . Sin embargo, la aplicación por defecto de Cordova incluye `< access origin = "*" >` por defecto.
116
+
117
+Quirk: Android también permite las solicitudes de https://ssl.gstatic.com/accessibility/javascript/android/ por defecto, puesto que es necesario para TalkBack funcionar correctamente.
118
+
119
+### Política de seguridad de contenido
120
+
121
+Controles que las peticiones de la red (imágenes, XHRs, etc.) se les permite hacer (vía webview directamente).
122
+
123
+En iOS y Android, la red solicitud lista blanca (véase arriba) no es capaz de filtrar todos los tipos de solicitudes (por ejemplo, `< video >` y WebSockets no estén bloqueadas). Así, además de la lista blanca, usted debe utilizar una etiqueta `< meta >` de [Contenido la política de seguridad](http://content-security-policy.com/) en todas las páginas.
124
+
125
+En Android, soporte para CSP en el sistema webview comienza con KitKat (pero está disponible en todas las versiones con WebView de paso de peatones).
126
+
127
+Aquí están algunas declaraciones de CSP de ejemplo para las páginas `.html` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/fr/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+Ce plugin met en œuvre une politique de liste blanche pour naviguer le webview application sur Cordova 4.0
23
+
24
+## Plates-formes prises en charge Cordova
25
+
26
+  * 4.0.0 Android ou supérieur
27
+  * iOS 4.0.0 ou supérieur
28
+
29
+## Navigation liste blanche
30
+
31
+Contrôle quels URL le WebView lui-même peut être parcourus à. S'applique à des navigations niveau supérieur seulement.
32
+
33
+Particularités : sur Android il s'applique également aux iframes pour non-schémas http (s).
34
+
35
+Par défaut, navigations qu'aux URL `file://` , sont autorisés. Pour permettre aux autres d'autres URL, vous devez ajouter des balises `<allow-navigation>` à votre `fichier config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Intent Whitelist
56
+
57
+Contrôle quels URL l'app n'est autorisé à poser le système d'ouverture. Par défaut, aucun external URL est autorisés.
58
+
59
+Sur Android, cela équivaut à envoyer une intention de type BROWSEABLE.
60
+
61
+Cette autorisation ne s'applique pas aux plugins, uniquement les liens hypertexte et les appels à `window.open()`.
62
+
63
+Dans le `fichier config.xml`, ajouter des balises `<allow-intent>` , comme ceci :
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Réseau demande liste blanche
91
+
92
+Les contrôles dont les demandes de réseau (images, XHRs, etc.) sont autorisés à effectuer (via cordova natif crochets).
93
+
94
+Remarque : Nous vous suggérons de qu'utiliser un contenu politique de sécurité (voir ci-dessous), qui est plus sûr. Cette liste blanche est surtout historique pour webviews qui ne prennent pas en charge les CSP.
95
+
96
+Dans le `fichier config.xml`, ajouter des balises `<access>` , comme ceci :
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Sans les balises `<access>` , seules les demandes d'URL `file://` sont autorisés. Toutefois, l'application de Cordoue par défaut inclut `<access origin="*" >` par défaut.
116
+
117
+Bizarrerie : Android permet également aux requêtes à https://ssl.gstatic.com/accessibility/javascript/android/ par défaut, puisque c'est nécessaire pour TalkBack fonctionner correctement.
118
+
119
+### Politique de sécurité du contenu
120
+
121
+Les contrôles dont les demandes de réseau (images, XHRs, etc.) sont autorisés à effectuer (via webview directement).
122
+
123
+Sur Android et iOS, la réseau demande liste blanche (voir ci-dessus) n'est pas en mesure de filtrer tous les types de demandes (p. ex. `< video >` & WebSockets ne sont pas bloquées). Ainsi, en plus de la liste blanche, vous devez utiliser une balise `< meta >` de [Contenu politique de sécurité](http://content-security-policy.com/) sur toutes vos pages.
124
+
125
+Sur Android, support pour le CSP dans le système webview commence par KitKat (mais n'est disponible sur toutes les versions à l'aide du tableau de concordance WebView).
126
+
127
+Voici quelques exemples de déclarations de CSP pour vos pages `.html` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/it/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+Questo plugin attua una politica di whitelist per spostarsi all'interno dell'applicazione webview in Cordova 4.0
23
+
24
+## Piattaforme supportate Cordova
25
+
26
+  * Android 4.0.0 o superiore
27
+  * iOS 4.0.0 o superiore
28
+
29
+## Navigazione Whitelist
30
+
31
+Controlla quali URL WebView stessa può essere esplorato. Si applica al solo primo livello navigazioni.
32
+
33
+Stranezze: su Android vale anche per gli iframe per non-schemi di http (s).
34
+
35
+Per impostazione predefinita, navigazioni solo agli URL `file://` , sono ammessi. Per consentire altri altri URL, è necessario aggiungere `<allow-navigation>` tag per il tuo `config. XML`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Whitelist intento
56
+
57
+Controlla quali URL app è consentito richiedere il sistema di apertura. Per impostazione predefinita, nessun esterno URL sono ammessi.
58
+
59
+Su Android, ciò equivale all'invio di un intento di tipo BROWSEABLE.
60
+
61
+Questa whitelist non si applica ai plugin, solo i collegamenti ipertestuali e chiamate a `Window`.
62
+
63
+In `config. XML`, aggiungere tag `<allow-intent>` , simile al seguente:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Rete richiesta Whitelist
91
+
92
+Controlli che le richieste di rete (immagini, XHRs, ecc.) sono consentiti (tramite ganci nativo di cordova).
93
+
94
+Nota: Si consiglia di che utilizzare un criterio di protezione contenuti (Vedi sotto), che è più sicuro. La whitelist è principalmente storico per visualizzazioni Web che non supportano la CSP.
95
+
96
+In `config. XML`, aggiungere tag `< access >` , simile al seguente:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Senza qualsiasi tag `< access >` , sono consentite solo le richieste di URL `file://` . Tuttavia, l'applicazione di Cordova predefinito include `< access origin = "*" >` per impostazione predefinita.
116
+
117
+Stranezza: Android consente anche alle richieste di https://ssl.gstatic.com/accessibility/javascript/android/ per impostazione predefinita, poiché questa operazione è necessaria per TalkBack funzionare correttamente.
118
+
119
+### Politica di sicurezza del contenuto
120
+
121
+Controlli che le richieste di rete (immagini, XHRs, ecc.) possono essere effettuate (via webview direttamente).
122
+
123
+Su Android e iOS, la rete richiesta whitelist (Vedi sopra) non è in grado di filtrare tutti i tipi di richieste (ad esempio non sono bloccate `< video >` & WebSockets). Così, oltre alla whitelist, è necessario utilizzare un tag `< meta >` [Content Security Policy](http://content-security-policy.com/) su tutte le pagine.
124
+
125
+Su Android, supporto per CSP all'interno webview sistema inizia con KitKat (ma è disponibile su tutte le versioni usando Crosswalk WebView).
126
+
127
+Ecco alcuni esempi di dichiarazioni di CSP per le pagine `HTML` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/ja/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+このプラグイン実装コルドバ 4.0 アプリケーション webview をナビゲートするためのホワイト リスト ポリシー
23
+
24
+## サポートされているコルドバのプラットフォーム
25
+
26
+  * アンドロイド 4.0.0 以上
27
+  * iOS 4.0.0 以上
28
+
29
+## ナビゲーションのホワイト リスト
30
+
31
+WebView 自体に移動に Url を制御します。最上位ナビゲーションのみに適用されます。
32
+
33
+癖: Android にもに適用されますの iframe 非-[http スキーム。
34
+
35
+既定では、ナビゲーション、 `file://`の Url にのみ許可されます。その他の他の Url を許可するように、 `config.xml`に`<allow-navigation>`タグを追加する必要があります。
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## インテントのホワイト リスト
56
+
57
+どの Url を開くようにシステムを聞いて、アプリに許可を制御します。 既定では、外部 Url 許可されません。
58
+
59
+人造人間、これは型 BROWSEABLE の意図を送信することに相当します。
60
+
61
+このホワイト リストはプラグインのみハイパーリンクおよび`window.open()`への呼び出しには適用されません。.
62
+
63
+`Config.xml`内の`<allow-intent>`タグは、このようなを追加します。
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## ネットワーク要求のホワイト リスト
91
+
92
+ネットワーク要求コントロール (画像、XHRs 等) (コルドバ ネイティブ フック) を介して行われることが。
93
+
94
+注: より安全なコンテンツ セキュリティ ポリシー (下記参照) を使用してお勧めします。 このホワイト リストほとんどの CSP をサポートしていない web 表示のために歴史的です。
95
+
96
+`Config.xml`内のこのような`<access>`タグを追加します。
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+`<access>`タグ、なし`file://` Url に要求のみを許可します。 ただし、既定のコルドバ アプリケーションが含まれています`<access origin="*">`デフォルトで。
116
+
117
+気まぐれ: アンドロイドも要求できます https://ssl.gstatic.com/accessibility/javascript/android/デフォルトでは、トークが正常に機能するために必要ですので。
118
+
119
+### コンテンツのセキュリティ ポリシー
120
+
121
+ネットワーク要求コントロール (画像、XHRs 等) (直接 webview) を介して行われることが。
122
+
123
+Android と iOS は、ネットワーク要求ホワイト リスト (上記参照) はすべての種類の要求 (例: `< ビデオ >` & Websocket がふさがれていない) をフィルター処理できません。 だから、ホワイト リストに加えてすべてのページに[コンテンツ セキュリティ ポリシー](http://content-security-policy.com/) `< meta >`タグを使用する必要があります。
124
+
125
+Android 上システム webview 内 CSP サポート キットカットから始まります (しかし横断歩道 WebView を使用してすべてのバージョンで利用可能です)。
126
+
127
+`.Html`ページのいくつかの例 CSP の宣言は次のとおりです。
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/ko/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+이 플러그인 구현 코르도바 4.0 응용 프로그램 webview를 탐색에 대 한 허용 정책
23
+
24
+## 지원된 코르도바 플랫폼
25
+
26
+  * 안 드 로이드 4.0.0 이상
27
+  * iOS 4.0.0 이상
28
+
29
+## 탐색 허용
30
+
31
+WebView 자체가 탐색할 수 있는 Url을 제어 합니다. 최상위 탐색에만 적용 됩니다.
32
+
33
+단점: 안 드 로이드에도 적용 됩니다 iframe에 대 한 비-프로토콜인 계획.
34
+
35
+기본적으로 탐색 `file://` Url에만 사용할 수 있습니다. 다른 다른 Url을 허용 하려면 `config.xml`에 `< allow-navigation >` 태그를 추가 해야 합니다.
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## 의도 허용
56
+
57
+App 시스템 열을 게 허용 되는 Url을 제어 합니다. 기본적으로 외부 Url은 사용할 수 있습니다.
58
+
59
+안 드 로이드에이 형식의 BROWSEABLE 의도 보내는 것 같습니다.
60
+
61
+이 허용 된 플러그인, 하이퍼링크 및 `window.open ()` 호출에 적용 되지 않습니다..
62
+
63
+`Config.xml`에이 같은 `< allow-intent >` 태그를 추가 합니다.
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## 네트워크 요청 허용
91
+
92
+요청을 네트워크 컨트롤 (이미지, XHRs, 등) (코르도바 네이티브 후크)를 통해 할 수 있습니다.
93
+
94
+참고: 당신이 사용 콘텐츠 보안 정책 (아래 참조), 더 안전한 것이 좋습니다. 이 허용은 CSP를 지원 하지 않는 webviews에 대 한 역사적.
95
+
96
+`Config.xml`에이 같은 `< access >` 태그를 추가 합니다.
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+어떤 `< access >` 태그 없이 요청 `file://` Url 사용할 수 있습니다. 그러나 기본 코르도바 응용 프로그램을 포함 하는, `< access origin="*" >` 기본적으로.
116
+
117
+특질: 안 드 로이드 또한 수 있습니다 요청을 https://ssl.gstatic.com/accessibility/javascript/android/ 기본적으로 필요 제대로 작동 하려면 의견 이므로.
118
+
119
+### 콘텐츠 보안 정책
120
+
121
+요청을 네트워크 컨트롤 (이미지, XHRs, 등) (webview 직접)를 통해 할 수 있습니다.
122
+
123
+안 드 로이드와 iOS에 네트워크 요청 허용 (위 참조)는 모든 종류의 요청 (예: `< 비디오 >` & WebSockets 차단 되지 않습니다)를 필터링 할 수 없습니다. 그래서, 허용, 뿐만 아니라 귀하의 모든 페이지에 [콘텐츠 보안 정책](http://content-security-policy.com/) `< meta >` 태그를 사용 해야 합니다.
124
+
125
+안 드 로이드, 시스템 webview 내에서 CSP에 대 한 지원을 KitKat 시작 (하지만 횡단 보도 WebView를 사용 하 여 모든 버전에서 사용할 수).
126
+
127
+다음은 `.html` 페이지에 대 한 몇 가지 예제 CSP 선언입니다.
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/pl/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+Ten plugin wdraża polityki białej nawigacja widoku sieci Web aplikacji na Cordova 4.0
23
+
24
+## Cordova obsługiwanych platform
25
+
26
+  * Android 4.0.0 lub powyżej
27
+  * iOS 4.0.0 lub powyżej
28
+
29
+## Biała lista nawigacji
30
+
31
+Kontroluje, których adresy URL widoku sieci Web, samej można nawigować do. Dotyczy tylko najwyższego poziomu nawigacje.
32
+
33
+Dziwactwa: na Android to dotyczy także IFRAME do nie-http (s) systemów.
34
+
35
+Domyślnie, nawigacje tylko do URLi `file://` , są dozwolone. Aby zezwolić na inne adresy URL, należy dodać Tagi `< allow-navigation >` do pliku `config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Zamiarem biała
56
+
57
+Kontroluje, których adresy URL aplikacji jest możliwość zapytać systemem otwierania. Domyślnie nie ma zewnętrznych adresów URL są dozwolone.
58
+
59
+Na Android to przyrównuje do wysyłania zamiarem typu BROWSEABLE.
60
+
61
+Ta biała nie ma zastosowania do pluginów, tylko hiperłącza i wywołania `window.open()`.
62
+
63
+W `pliku config.xml`dodawanie tagów `< allow-intent >` , jak to:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Sieci wniosek biała
91
+
92
+Formanty, które sieci żądań (obrazy, XHRs, itp.) mogą być wykonane (za pośrednictwem cordova rodzimych haki).
93
+
94
+Uwaga: Zalecamy, że używasz treści polityki bezpieczeństwa (patrz poniżej), który jest bardziej bezpieczne. Ta Biała jest głównie historyczne dla webviews, które nie obsługują CSP.
95
+
96
+W `pliku config.xml`dodawanie tagów `< access >` , jak to:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Bez żadnych tagów `< access >` dozwolone są tylko żądania do URLi `file://` . Jednak domyślnie Cordova aplikacja zawiera `< access origin = "*" >` domyślnie.
116
+
117
+Cokół: Android pozwala również żądania do https://ssl.gstatic.com/accessibility/javascript/android/ domyślnie, ponieważ jest to wymagane dla TalkBack wobec funkcja poprawnie.
118
+
119
+### Zasady zabezpieczeń zawartości
120
+
121
+Formanty, które sieci żądań (obrazy, XHRs, itp.) mogą być wykonane (za pomocą widoku sieci Web bezpośrednio).
122
+
123
+Na Androida i iOS biała żądanie sieci (patrz wyżej) nie jest w stanie filtrować wszystkie rodzaje wniosków (np. `< video >` & WebSockets nie są zablokowane). Tak oprócz białej listy, należy użyć tagu `< meta >` [Treści polityki bezpieczeństwa](http://content-security-policy.com/) na wszystkich stronach.
124
+
125
+Na Android wsparcie dla CSP w ramach systemu widoku sieci Web zaczyna KitKat (ale jest dostępne we wszystkich wersjach przy użyciu widoku sieci Web przejście dla pieszych).
126
+
127
+Oto niektóre przykład CSP deklaracje dla strony `HTML` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/zh/README.md

@@ -0,0 +1,148 @@
1
+<!--
2
+# license: 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
+
20
+# cordova-plugin-whitelist
21
+
22
+這個外掛程式實現一個用於導航在科爾多瓦 4.0 應用程式 web 視圖的白名單策略
23
+
24
+## 支援的科爾多瓦平臺
25
+
26
+  * Android 4.0.0 或以上
27
+  * iOS 4.0.0 或以上
28
+
29
+## 導航白名單
30
+
31
+控制 web 視圖本身可以導航到的 Url。適用于頂級導航只。
32
+
33
+怪癖: 在 Android 上它也適用于 iframe 的非-結計畫。
34
+
35
+預設情況下,只有到`file://` Url 導航允許。若要允許其他其他 Url,必須將`<allow-navigation>`標籤添加到您的`config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## 科爾多瓦-外掛程式-白名單
56
+
57
+控制應用程式允許讓系統打開的 Url。 預設情況下,沒有外部 Url 允許。
58
+
59
+在 android 系統,這相當於發送類型 BROWSEABLE 的意圖。
60
+
61
+此白名單並不適用于只超連結和對`window.open ()`調用的外掛程式.
62
+
63
+在`config.xml`中添加`<allow-intent>`標籤,像這樣:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## 網路請求白名單
91
+
92
+網路請求的控制項 (圖像,XHRs 等) 允許 (通過科爾多瓦本機掛鉤)。
93
+
94
+注意: 我們建議你使用內容的安全性原則 (見下文),這是更安全。 此白名單大多是為 webviews 不支援 CSP 的歷史。
95
+
96
+在`config.xml`中添加`<access>`標記,像這樣:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+沒有任何`<access>`標籤,只到`file://` Url 允許請求。 但是,預設的科爾多瓦應用程式包括`<access origin="*">` ,預設情況。
116
+
117
+怪癖: Android 還允許對 HTTPs://ssl.gstatic.com/accessibility/javascript/android/ 請求預設情況下,因為這是對講正常所需。
118
+
119
+### 內容安全政策
120
+
121
+網路請求的控制項 (圖像,XHRs 等) 允許 (通過 web 視圖直接)。
122
+
123
+對 Android 和 iOS,網路請求白名單 (見上文) 是不能夠過濾所有類型的請求 (例如`<video>` & Websocket 未被阻止)。 那麼,除了白名單中,你應使用[內容安全性原則](http://content-security-policy.com/) `< 元 >`標記您的所有頁面。
124
+
125
+在 android 系統,對 CSP 系統 web 視圖的支援開始奇巧 (但是是上使用 web 視圖人行橫道上的所有版本可用)。
126
+
127
+下面是一些示例 CSP 聲明為`.html`頁面:
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 64 - 0
plugins/cordova-plugin-whitelist/package.json

@@ -0,0 +1,64 @@
1
+{
2
+  "_from": "cordova-plugin-whitelist@1",
3
+  "_id": "cordova-plugin-whitelist@1.3.3",
4
+  "_inBundle": false,
5
+  "_integrity": "sha1-tehezbv+Wu3tQKG/TuI3LmfZb7Q=",
6
+  "_location": "/cordova-plugin-whitelist",
7
+  "_phantomChildren": {},
8
+  "_requested": {
9
+    "type": "range",
10
+    "registry": true,
11
+    "raw": "cordova-plugin-whitelist@1",
12
+    "name": "cordova-plugin-whitelist",
13
+    "escapedName": "cordova-plugin-whitelist",
14
+    "rawSpec": "1",
15
+    "saveSpec": null,
16
+    "fetchSpec": "1"
17
+  },
18
+  "_requiredBy": [
19
+    "#USER",
20
+    "/"
21
+  ],
22
+  "_resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.3.tgz",
23
+  "_shasum": "b5e85ecdbbfe5aeded40a1bf4ee2372e67d96fb4",
24
+  "_spec": "cordova-plugin-whitelist@1",
25
+  "_where": "E:\\myData\\projectTest\\cordovaTest",
26
+  "author": {
27
+    "name": "Apache Software Foundation"
28
+  },
29
+  "bugs": {
30
+    "url": "https://issues.apache.org/jira/browse/CB"
31
+  },
32
+  "bundleDependencies": false,
33
+  "cordova": {
34
+    "platforms": [
35
+      "android"
36
+    ]
37
+  },
38
+  "deprecated": false,
39
+  "description": "Cordova Whitelist Plugin",
40
+  "engines": {
41
+    "cordovaDependencies": {
42
+      "0.0.0": {
43
+        "cordova-android": ">=4.0.0"
44
+      },
45
+      "2.0.0": {
46
+        "cordova": ">100"
47
+      }
48
+    }
49
+  },
50
+  "homepage": "https://github.com/apache/cordova-plugin-whitelist#readme",
51
+  "keywords": [
52
+    "cordova",
53
+    "whitelist",
54
+    "ecosystem:cordova",
55
+    "cordova-android"
56
+  ],
57
+  "license": "Apache-2.0",
58
+  "name": "cordova-plugin-whitelist",
59
+  "repository": {
60
+    "type": "git",
61
+    "url": "git+https://github.com/apache/cordova-plugin-whitelist.git"
62
+  },
63
+  "version": "1.3.3"
64
+}

+ 48 - 0
plugins/cordova-plugin-whitelist/plugin.xml

@@ -0,0 +1,48 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+  Licensed to the Apache Software Foundation (ASF) under one
4
+  or more contributor license agreements.  See the NOTICE file
5
+  distributed with this work for additional information
6
+  regarding copyright ownership.  The ASF licenses this file
7
+  to you under the Apache License, Version 2.0 (the
8
+  "License"); you may not use this file except in compliance
9
+  with the License.  You may obtain a copy of the License at
10
+
11
+    http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+  Unless required by applicable law or agreed to in writing,
14
+  software distributed under the License is distributed on an
15
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+  KIND, either express or implied.  See the License for the
17
+  specific language governing permissions and limitations
18
+  under the License.
19
+-->
20
+
21
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
22
+           id="cordova-plugin-whitelist"
23
+      version="1.3.3">
24
+    <name>Whitelist</name>
25
+    <description>Cordova Network Whitelist Plugin</description>
26
+    <license>Apache 2.0</license>
27
+    <keywords>cordova,whitelist,policy</keywords>
28
+
29
+    <engines>
30
+      <engine name="cordova-android" version=">=4.0.0" />
31
+    </engines>
32
+
33
+    <platform name="android">
34
+        <config-file target="res/xml/config.xml" parent="/*">
35
+            <feature name="Whitelist" >
36
+                <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin"/>
37
+                <param name="onload" value="true" />
38
+            </feature>
39
+        </config-file>
40
+
41
+        <source-file src="src/android/WhitelistPlugin.java" target-dir="src/org/apache/cordova/whitelist" />
42
+
43
+        	<info>
44
+               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
45
+          </info>
46
+    </platform>
47
+
48
+</plugin>

+ 161 - 0
plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java

@@ -0,0 +1,161 @@
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
+
20
+package org.apache.cordova.whitelist;
21
+
22
+import org.apache.cordova.CordovaPlugin;
23
+import org.apache.cordova.ConfigXmlParser;
24
+import org.apache.cordova.LOG;
25
+import org.apache.cordova.Whitelist;
26
+import org.xmlpull.v1.XmlPullParser;
27
+
28
+import android.content.Context;
29
+
30
+public class WhitelistPlugin extends CordovaPlugin {
31
+    private static final String LOG_TAG = "WhitelistPlugin";
32
+    private Whitelist allowedNavigations;
33
+    private Whitelist allowedIntents;
34
+    private Whitelist allowedRequests;
35
+
36
+    // Used when instantiated via reflection by PluginManager
37
+    public WhitelistPlugin() {
38
+    }
39
+    // These can be used by embedders to allow Java-configuration of whitelists.
40
+    public WhitelistPlugin(Context context) {
41
+        this(new Whitelist(), new Whitelist(), null);
42
+        new CustomConfigXmlParser().parse(context);
43
+    }
44
+    public WhitelistPlugin(XmlPullParser xmlParser) {
45
+        this(new Whitelist(), new Whitelist(), null);
46
+        new CustomConfigXmlParser().parse(xmlParser);
47
+    }
48
+    public WhitelistPlugin(Whitelist allowedNavigations, Whitelist allowedIntents, Whitelist allowedRequests) {
49
+        if (allowedRequests == null) {
50
+            allowedRequests = new Whitelist();
51
+            allowedRequests.addWhiteListEntry("file:///*", false);
52
+            allowedRequests.addWhiteListEntry("data:*", false);
53
+        }
54
+        this.allowedNavigations = allowedNavigations;
55
+        this.allowedIntents = allowedIntents;
56
+        this.allowedRequests = allowedRequests;
57
+    }
58
+    @Override
59
+    public void pluginInitialize() {
60
+        if (allowedNavigations == null) {
61
+            allowedNavigations = new Whitelist();
62
+            allowedIntents = new Whitelist();
63
+            allowedRequests = new Whitelist();
64
+            new CustomConfigXmlParser().parse(webView.getContext());
65
+        }
66
+    }
67
+
68
+    private class CustomConfigXmlParser extends ConfigXmlParser {
69
+        @Override
70
+        public void handleStartTag(XmlPullParser xml) {
71
+            String strNode = xml.getName();
72
+            if (strNode.equals("content")) {
73
+                String startPage = xml.getAttributeValue(null, "src");
74
+                allowedNavigations.addWhiteListEntry(startPage, false);
75
+            } else if (strNode.equals("allow-navigation")) {
76
+                String origin = xml.getAttributeValue(null, "href");
77
+                if ("*".equals(origin)) {
78
+                    allowedNavigations.addWhiteListEntry("http://*/*", false);
79
+                    allowedNavigations.addWhiteListEntry("https://*/*", false);
80
+                    allowedNavigations.addWhiteListEntry("data:*", false);
81
+                } else {
82
+                    allowedNavigations.addWhiteListEntry(origin, false);
83
+                }
84
+            } else if (strNode.equals("allow-intent")) {
85
+                String origin = xml.getAttributeValue(null, "href");
86
+                allowedIntents.addWhiteListEntry(origin, false);
87
+            } else if (strNode.equals("access")) {
88
+                String origin = xml.getAttributeValue(null, "origin");
89
+                String subdomains = xml.getAttributeValue(null, "subdomains");
90
+                boolean external = (xml.getAttributeValue(null, "launch-external") != null);
91
+                if (origin != null) {
92
+                    if (external) {
93
+                        LOG.w(LOG_TAG, "Found <access launch-external> within config.xml. Please use <allow-intent> instead.");
94
+                        allowedIntents.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
95
+                    } else {
96
+                        if ("*".equals(origin)) {
97
+                            allowedRequests.addWhiteListEntry("http://*/*", false);
98
+                            allowedRequests.addWhiteListEntry("https://*/*", false);
99
+                        } else {
100
+                            allowedRequests.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
101
+                        }
102
+                    }
103
+                }
104
+            }
105
+        }
106
+        @Override
107
+        public void handleEndTag(XmlPullParser xml) {
108
+        }
109
+    }
110
+
111
+    @Override
112
+    public Boolean shouldAllowNavigation(String url) {
113
+        if (allowedNavigations.isUrlWhiteListed(url)) {
114
+            return true;
115
+        }
116
+        return null; // Default policy
117
+    }
118
+
119
+    @Override
120
+    public Boolean shouldAllowRequest(String url) {
121
+        if (Boolean.TRUE == shouldAllowNavigation(url)) {
122
+            return true;
123
+        }
124
+        if (allowedRequests.isUrlWhiteListed(url)) {
125
+            return true;
126
+        }
127
+        return null; // Default policy
128
+    }
129
+
130
+    @Override
131
+    public Boolean shouldOpenExternalUrl(String url) {
132
+        if (allowedIntents.isUrlWhiteListed(url)) {
133
+            return true;
134
+        }
135
+        return null; // Default policy
136
+    }
137
+
138
+    public Whitelist getAllowedNavigations() {
139
+        return allowedNavigations;
140
+    }
141
+
142
+    public void setAllowedNavigations(Whitelist allowedNavigations) {
143
+        this.allowedNavigations = allowedNavigations;
144
+    }
145
+
146
+    public Whitelist getAllowedIntents() {
147
+        return allowedIntents;
148
+    }
149
+
150
+    public void setAllowedIntents(Whitelist allowedIntents) {
151
+        this.allowedIntents = allowedIntents;
152
+    }
153
+
154
+    public Whitelist getAllowedRequests() {
155
+        return allowedRequests;
156
+    }
157
+
158
+    public void setAllowedRequests(Whitelist allowedRequests) {
159
+        this.allowedRequests = allowedRequests;
160
+    }
161
+}

+ 18 - 0
plugins/fetch.json

@@ -0,0 +1,18 @@
1
+{
2
+  "cordova-plugin-whitelist": {
3
+    "source": {
4
+      "type": "registry",
5
+      "id": "cordova-plugin-whitelist@1"
6
+    },
7
+    "is_top_level": true,
8
+    "variables": {}
9
+  },
10
+  "cordova-plugin-battery-status": {
11
+    "source": {
12
+      "type": "registry",
13
+      "id": "cordova-plugin-battery-status"
14
+    },
15
+    "is_top_level": true,
16
+    "variables": {}
17
+  }
18
+}

+ 11 - 0
postcss.config.js

@@ -0,0 +1,11 @@
1
+module.exports = {
2
+    plugins: [
3
+        require('autoprefixer')({
4
+            browsers: [
5
+                'last 20 versions',
6
+                'IE 9',
7
+                'iOS >= 8'
8
+            ]
9
+        })
10
+    ]
11
+}

+ 29 - 0
res/README.md

@@ -0,0 +1,29 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+
22
+Note that these image resources are not copied into a project when a project
23
+is created with the CLI. Although there are default image resources in a
24
+newly-created project, those come from the platform-specific project template,
25
+which can generally be found in the platform's `template` directory. Until
26
+icon and splashscreen support is added to the CLI, these image resources
27
+aren't used directly.
28
+
29
+See https://issues.apache.org/jira/browse/CB-5145

BIN
res/icon/android/icon-36-ldpi.png


BIN
res/icon/android/icon-48-mdpi.png


BIN
res/icon/android/icon-72-hdpi.png


BIN
res/icon/android/icon-96-xhdpi.png


BIN
res/icon/bada-wac/icon-48-type5.png


BIN
res/icon/bada-wac/icon-50-type3.png


BIN
res/icon/bada-wac/icon-80-type4.png


BIN
res/icon/bada/icon-128.png


BIN
res/icon/blackberry/icon-80.png


BIN
res/icon/blackberry10/icon-80.png


BIN
res/icon/ios/icon-57-2x.png


BIN
res/icon/ios/icon-57.png


BIN
res/icon/ios/icon-72-2x.png


BIN
res/icon/ios/icon-72.png


BIN
res/icon/tizen/icon-128.png


BIN
res/icon/webos/icon-64.png


BIN
res/icon/windows-phone/icon-173-tile.png


BIN
res/icon/windows-phone/icon-48.png


BIN
res/icon/windows-phone/icon-62-tile.png


BIN
res/screen/android/screen-hdpi-landscape.png


BIN
res/screen/android/screen-hdpi-portrait.png


BIN
res/screen/android/screen-ldpi-landscape.png


BIN
res/screen/android/screen-ldpi-portrait.png


BIN
res/screen/android/screen-mdpi-landscape.png


BIN
res/screen/android/screen-mdpi-portrait.png


BIN
res/screen/android/screen-xhdpi-landscape.png


BIN
res/screen/android/screen-xhdpi-portrait.png


BIN
res/screen/bada-wac/screen-type3.png


BIN
res/screen/bada-wac/screen-type4.png


BIN
res/screen/bada-wac/screen-type5.png


BIN
res/screen/bada/screen-portrait.png


BIN
res/screen/blackberry/screen-225.png


BIN
res/screen/blackberry10/splash-1280x768.png


+ 0 - 0
res/screen/blackberry10/splash-720x720.png


Някои файлове не бяха показани, защото твърде много файлове са промени