Compare commits

..
Author SHA1 Message Date
Manuel BeckandGitHub 6131c41399 chore: remove 'Platforms affected' section from PR template
- Removed the 'Platforms affected' section from the PR template, because cordova-android will always be the platform `Android`
2026-05-06 12:28:40 +02:00
24 changed files with 853 additions and 639 deletions
+3 -16
View File
@@ -39,21 +39,8 @@ github:
merge: false
rebase: false
rulesets:
- name: "Default Branch Protection"
type: branch
branches:
includes:
- "~DEFAULT_BRANCH"
- "release/*"
- "rel/*"
excludes: []
bypass_teams:
- root
restrict_deletion: true
restrict_force_push: true
notifications:
commits: commits@cordova.apache.org
issues: issues@cordova.apache.org
pullrequests_status: issues@cordova.apache.org
commits: commits@cordova.apache.org
issues: issues@cordova.apache.org
pullrequests_status: issues@cordova.apache.org
pullrequests_comment: issues@cordova.apache.org
-5
View File
@@ -5,11 +5,6 @@ http://cordova.apache.org/contribute/contribute_guidelines.html
Thanks!
-->
### Platforms affected
### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->
-32
View File
@@ -1,32 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
cooldown:
default-days: 4
schedule:
interval: "daily" # Every weekday, Monday to Friday
- package-ecosystem: "npm"
directory: "/"
cooldown:
default-days: 4
schedule:
interval: "weekly" # By default on a Monday
+30 -62
View File
@@ -25,79 +25,28 @@ on:
branches:
- '*'
permissions:
contents: read
security-events: write
jobs:
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
fetch-depth: 1
- uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0
with:
distribution: 'temurin'
java-version: '17'
# "bin/templates/platform_www/cordova.js" is ignored because it is a generated file.
# It contains mixed content from the npm package "cordova-js" and "./cordova-js-src".
# The report might not be resolvable because of the external package.
# If the report is related to this repository, it would be detected when scanning "./cordova-js-src".
- uses: github/codeql-action/init@99df26d4f13ea111d4ec1a7dddef6063f76b97e9 # v4.37.0
with:
languages: javascript, java-kotlin
queries: security-and-quality
# When 'build-mode' is set to 'none', CodeQL will create a database without
# requiring a build for Java. If Kotlin files are added in the future, build
# will be required.
build-mode: none
config: |
paths-ignore:
- coverage
- node_modules
- templates/project/assets/www/cordova.js
- test/androidx/app/src/main/assets/www/cordova.js
- framework/build/intermediates
- framework/build/outputs
- framework/build/reports
- framework/build/tmp
- test/androidx/build/intermediates
- test/androidx/build/outputs
- test/androidx/build/reports
- test/androidx/build/tmp
- uses: github/codeql-action/analyze@99df26d4f13ea111d4ec1a7dddef6063f76b97e9 # v4.37.0
test:
name: NodeJS ${{ matrix.node-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
node-version: [20.x, 22.x, 24.x, 26.x]
os: [ubuntu-latest, windows-latest, macos-26]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-15]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
fetch-depth: 1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
@@ -108,13 +57,32 @@ jobs:
npm --version
gradle --version
# "bin/templates/platform_www/cordova.js" is ignored because it is a generated file.
# It contains mixed content from the npm package "cordova-js" and "./cordova-js-src".
# The report might not be resolvable because of the external package.
# If the report is related to this repository, it would be detected when scanning "./cordova-js-src".
- uses: github/codeql-action/init@v4
with:
languages: javascript, java-kotlin
queries: security-and-quality
config: |
paths-ignore:
- coverage
- node_modules
- templates/project/assets/www/cordova.js
- test/androidx/app/src/main/assets/www/cordova.js
- name: npm install and test
run: |
npm cit
npm i
npm t
env:
CI: true
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
- uses: github/codeql-action/analyze@v4
# v4.6.0
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238
if: success()
with:
name: ${{ runner.os }} node.js ${{ matrix.node-version }}
+7 -13
View File
@@ -31,16 +31,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
fetch-depth: 1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false
cache: ''
- name: Setup environment variables
run: |
@@ -74,14 +68,14 @@ jobs:
- name: Verify Target Release Version
run: |
PACKAGE_VERSION=$(jq -r '.version' package.json)
if [ "$PACKAGE_VERSION" != "$TARGET_RELEASE_VERSION" ]; then
if [ $PACKAGE_VERSION != "$TARGET_RELEASE_VERSION" ]; then
echo "Mismatch version detected between tag version ($TARGET_RELEASE_VERSION) and package version ($PACKAGE_VERSION)"
exit 1
fi
if [ -f "plugin.xml" ]; then
PLUGIN_VERSION=$(yq -p=xml -o=json '.plugin.+@version' plugin.xml | jq -r .)
if [ "$PLUGIN_VERSION" != "$TARGET_RELEASE_VERSION" ]; then
PLUGIN_VERSION=$(yq -p=xml -o=json '.plugin.+@version' plugin.xml)
if [ $PLUGIN_VERSION != "$TARGET_RELEASE_VERSION" ]; then
echo "Mismatch version detected between tag version ($TARGET_RELEASE_VERSION) and plugin version ($PLUGIN_VERSION)"
exit 1
fi
@@ -89,7 +83,7 @@ jobs:
- name: Generate "tgz" npm convenience package
run: |-
npm ci
npm install
NPM_PKG_NAME=$(npm pack --json | jq -r '.[0].filename')
mv ./.asf-release/$NPM_PKG_NAME ./.asf-release/${NPM_PACKAGE_NAME}.tgz
env:
@@ -148,7 +142,7 @@ jobs:
CORDOVA_GPG_SECRET_KEY: ${{ secrets.CORDOVA_GPG_SECRET_KEY }}
- name: Upload to Apache Trusted Release (ATR)
uses: apache/tooling-actions/upload-to-atr@f5f4c0e7ddfbde6b1f8288cef36324c6def68051
uses: apache/tooling-actions/upload-to-atr@b7e972c11790ee16eca101900af1b3c7fd1b106e
with:
project: ${{ env.REPO_NAME }}
version: ${{ env.TARGET_RELEASE_VERSION }}
+6 -9
View File
@@ -34,16 +34,13 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checkout project
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
fetch-depth: 1
- uses: actions/checkout@v6
# Check license headers
- uses: erisu/apache-rat-action@30c94d10ed21e6f6fd5590dc5c158f58cae7a0dd # v3.0.0
# Check license headers (v2.0.0)
- uses: erisu/apache-rat-action@46fb01ce7d8f76bdcd7ab10e7af46e1ea95ca01c
# Setup environment with node
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/setup-node@v6
with:
node-version: 24
@@ -51,8 +48,8 @@ jobs:
- name: npm install packages
run: npm ci
# Check node package licenses
- uses: erisu/license-checker-action@04511f4c052b5773f11e1c65b42cda88235c62ae # v2.1.0
# Check node package licenses (v2.0.1)
- uses: erisu/license-checker-action@99cffa11264fe545fd0baa6c13bca5a00ae608f2
with:
license-config: 'licence_checker.yml'
include-asf-category-a: true
+2
View File
@@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.
# This file used by ATR
**/*.txt
.git/
coverage/
@@ -1,5 +1,3 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -16,7 +14,14 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
Files from the www folder of the Cordova project will be copied here.
# This file used by release audit workflow
**/*.txt
.git/
coverage/
framework/build/
node_modules/
test/androidx/app/build/
test/androidx/build/
test/androidx/tools/
-64
View File
@@ -21,70 +21,6 @@
## Release Notes for Cordova (Android)
### 15.1.0
**Features:**
* feat: call new method `CordovaPlugin.onRequestPermissionsResult` ([#1855](https://github.com/apache/cordova-android/pull/1855)) [[b66f0f33](https://github.com/apache/cordova-android/commit/b66f0f33)]
* feat: deprecate `PermissionHelper` ([#1857](https://github.com/apache/cordova-android/pull/1857)) [[8c839764](https://github.com/apache/cordova-android/commit/8c839764)]
* feat: remove unused private Method `PermissionHelper.deliverPermissionResult` ([#1858](https://github.com/apache/cordova-android/pull/1858)) [[9c3d8268](https://github.com/apache/cordova-android/commit/9c3d8268)]
**Fixes:**
* fix: webview loses scrollability and creates empty bottom space ([#1924](https://github.com/apache/cordova-android/pull/1924)) [[b91144c0](https://github.com/apache/cordova-android/commit/b91144c0)]
* fix: handle permissions for getUserMedia ([#1895](https://github.com/apache/cordova-android/pull/1895)) [[24502178](https://github.com/apache/cordova-android/commit/24502178)]
* fix: overwritten backbutton not firing on first time by hardware button and never on back gesture ([#1910](https://github.com/apache/cordova-android/pull/1910)) [[0bfbc20b](https://github.com/apache/cordova-android/commit/0bfbc20b)]
* fix(android): use AndroidX `OnBackPressedCallback` instead of `OnBackInvokedCallback` ([#1903](https://github.com/apache/cordova-android/pull/1903)) [[9064bc07](https://github.com/apache/cordova-android/commit/9064bc07)]
* fix(gradle-9): unable to resolve class XmlParser for Groovy 4.x ([#1896](https://github.com/apache/cordova-android/pull/1896)) [[9ae489bd](https://github.com/apache/cordova-android/commit/9ae489bd)]
* fix(statusbar.js): remove trailing whitespace in comment for lint ([#1970](https://github.com/apache/cordova-android/pull/1970)) [[cdbeb603](https://github.com/apache/cordova-android/commit/cdbeb603)]
* fix(statusbar): Properly handle CSS colours ([#1955](https://github.com/apache/cordova-android/pull/1955)) [[dd3fd357](https://github.com/apache/cordova-android/commit/dd3fd357)]
* fix(SystemBarPlugin): remove `canEdgeToEdge` check for `execute` method ([#1971](https://github.com/apache/cordova-android/pull/1971)) [[61ebdcde](https://github.com/apache/cordova-android/commit/61ebdcde)]
* fix(SystemBarPlugin): remove sentinel value `INVALID_COLOR`, use `null` instead ([#1939](https://github.com/apache/cordova-android/pull/1939)) [[f4ecf997](https://github.com/apache/cordova-android/commit/f4ecf997)]
**Others**
* chore: cleanup PermissionHelper ([#1925](https://github.com/apache/cordova-android/pull/1925)) [[7dd7f504](https://github.com/apache/cordova-android/commit/7dd7f504)]
* chore: bump package 15.1.0-dev.0 & update package-lock ([#1964](https://github.com/apache/cordova-android/pull/1964)) [[929f2054](https://github.com/apache/cordova-android/commit/929f2054)]
* chore: remove redundant Hello World template files ([#1926](https://github.com/apache/cordova-android/pull/1926)) [[56e263fe](https://github.com/apache/cordova-android/commit/56e263fe)]
* chore: simplify edge-to-edge preference logic in CordovaActivity and SystemBarPlugin ([#1902](https://github.com/apache/cordova-android/pull/1902)) [[190076ba](https://github.com/apache/cordova-android/commit/190076ba)]
* chore: ignore gradle build artificat `problems-report.html` ([#1912](https://github.com/apache/cordova-android/pull/1912)) [[b1705d83](https://github.com/apache/cordova-android/commit/b1705d83)]
* chore: more license header updates ([#1909](https://github.com/apache/cordova-android/pull/1909)) [[1f70d396](https://github.com/apache/cordova-android/commit/1f70d396)]
* chore: update package-lock ([#1905](https://github.com/apache/cordova-android/pull/1905)) [[af56a003](https://github.com/apache/cordova-android/commit/af56a003)]
* chore(ci): update & clean workflow ([#1966](https://github.com/apache/cordova-android/pull/1966)) [[654b03a3](https://github.com/apache/cordova-android/commit/654b03a3)]
* chore(ci): improve workflows & dependabot ([#1928](https://github.com/apache/cordova-android/pull/1928)) [[08c4fd1e](https://github.com/apache/cordova-android/commit/08c4fd1e)]
* chore(deps-dev): bump js-yaml from 4.1.1 to 4.2.0 ([#1960](https://github.com/apache/cordova-android/pull/1960)) [[ebccedf6](https://github.com/apache/cordova-android/commit/ebccedf6)]
* chore(deps-dev): bump tmp from 0.2.6 to 0.2.7 ([#1956](https://github.com/apache/cordova-android/pull/1956)) [[d90eeecb](https://github.com/apache/cordova-android/commit/d90eeecb)]
* chore(deps-dev): bump tmp from 0.2.5 to 0.2.6 ([#1945](https://github.com/apache/cordova-android/pull/1945)) [[a63c1e18](https://github.com/apache/cordova-android/commit/a63c1e18)]
* chore(deps-dev): bump c8 from 10.1.3 to 11.0.0 ([#1941](https://github.com/apache/cordova-android/pull/1941)) [[74fbbdce](https://github.com/apache/cordova-android/commit/74fbbdce)]
* chore(deps-dev): bump jasmine from 6.1.0 to 6.2.0 ([#1932](https://github.com/apache/cordova-android/pull/1932)) [[90b4b057](https://github.com/apache/cordova-android/commit/90b4b057)]
* chore(deps): bump github/codeql-action/analyze from 4.36.3 to 4.37.0 ([#1973](https://github.com/apache/cordova-android/pull/1973)) [[80658ea4](https://github.com/apache/cordova-android/commit/80658ea4)]
* chore(deps): bump github/codeql-action/init from 4.36.3 to 4.37.0 ([#1972](https://github.com/apache/cordova-android/pull/1972)) [[89771e64](https://github.com/apache/cordova-android/commit/89771e64)]
* chore(deps): bump actions/setup-java from 5.4.0 to 5.5.0 ([#1974](https://github.com/apache/cordova-android/pull/1974)) [[065a99d8](https://github.com/apache/cordova-android/commit/065a99d8)]
* chore(deps): bump github/codeql-action/analyze from 4.36.2 to 4.36.3 ([#1969](https://github.com/apache/cordova-android/pull/1969)) [[d830222e](https://github.com/apache/cordova-android/commit/d830222e)]
* chore(deps): bump github/codeql-action/init from 4.36.2 to 4.36.3 ([#1968](https://github.com/apache/cordova-android/pull/1968)) [[1e2f0ca6](https://github.com/apache/cordova-android/commit/1e2f0ca6)]
* chore(deps): bump codecov/codecov-action from 4.6.0 to 7.0.0 ([#1954](https://github.com/apache/cordova-android/pull/1954)) [[acbc5b48](https://github.com/apache/cordova-android/commit/acbc5b48)]
* chore(deps): bump actions/setup-java from 5.3.0 to 5.4.0 ([#1965](https://github.com/apache/cordova-android/pull/1965)) [[cb52fb8d](https://github.com/apache/cordova-android/commit/cb52fb8d)]
* chore(deps): bump actions/checkout from 6.0.3 to 7.0.0 ([#1959](https://github.com/apache/cordova-android/pull/1959)) [[79771499](https://github.com/apache/cordova-android/commit/79771499)]
* chore(deps): bump actions/setup-java from 5.2.0 to 5.3.0 ([#1958](https://github.com/apache/cordova-android/pull/1958)) [[e53dc373](https://github.com/apache/cordova-android/commit/e53dc373)]
* chore(deps): bump actions/checkout from 6.0.2 to 6.0.3 ([#1952](https://github.com/apache/cordova-android/pull/1952)) [[703ebeae](https://github.com/apache/cordova-android/commit/703ebeae)]
* chore(deps): bump github/codeql-action from 4.36.0 to 4.36.2 ([#1953](https://github.com/apache/cordova-android/pull/1953)) [[363a9a77](https://github.com/apache/cordova-android/commit/363a9a77)]
* chore(deps): bump github/codeql-action from 4.35.5 to 4.36.0 ([#1944](https://github.com/apache/cordova-android/pull/1944)) [[a1f75a3e](https://github.com/apache/cordova-android/commit/a1f75a3e)]
* chore(deps): bump erisu/apache-rat-action from 2.0.0 to 3.0.0 ([#1937](https://github.com/apache/cordova-android/pull/1937)) [[4ce731da](https://github.com/apache/cordova-android/commit/4ce731da)]
* chore(deps): bump semver from 7.7.4 to 7.8.0 ([#1934](https://github.com/apache/cordova-android/pull/1934)) [[c636f8bb](https://github.com/apache/cordova-android/commit/c636f8bb)]
* chore(deps): bump erisu/license-checker-action from 2.0.1 to 2.1.0 ([#1930](https://github.com/apache/cordova-android/pull/1930)) [[0baa901d](https://github.com/apache/cordova-android/commit/0baa901d)]
* chore(deps): bump @xmldom/xmldom from 0.8.12 to 0.8.13 ([#1918](https://github.com/apache/cordova-android/pull/1918)) [[0d6fdd17](https://github.com/apache/cordova-android/commit/0d6fdd17)]
* chore(deps): bump lodash from 4.17.23 to 4.18.1 ([#1914](https://github.com/apache/cordova-android/pull/1914)) [[7b33c5dd](https://github.com/apache/cordova-android/commit/7b33c5dd)]
* chore(deps): bump @xmldom/xmldom from 0.8.11 to 0.8.12 ([#1911](https://github.com/apache/cordova-android/pull/1911)) [[c44a4627](https://github.com/apache/cordova-android/commit/c44a4627)]
* chore(deps): bump picomatch ([#1908](https://github.com/apache/cordova-android/pull/1908)) [[2868f93a](https://github.com/apache/cordova-android/commit/2868f93a)]
* chore(deps): bump minimatch ([#1898](https://github.com/apache/cordova-android/pull/1898)) [[31f3d57c](https://github.com/apache/cordova-android/commit/31f3d57c)]
* chore(gh-action): improve draft-release workflow ([#1906](https://github.com/apache/cordova-android/pull/1906)) [[340eade2](https://github.com/apache/cordova-android/commit/340eade2)]
* chore(INFRA): Set up default protection ruleset for default and release branches ([#1927](https://github.com/apache/cordova-android/pull/1927)) [[f490531d](https://github.com/apache/cordova-android/commit/f490531d)]
* chore(post-release): bump v15.0.1-dev.0 ([#1899](https://github.com/apache/cordova-android/pull/1899)) [[c02d1b03](https://github.com/apache/cordova-android/commit/c02d1b03)]
* doc: improve documentation of `onRequestPermissionResult` and `onRequestPermissionsResult` ([#1920](https://github.com/apache/cordova-android/pull/1920)) [[1d01ea1f](https://github.com/apache/cordova-android/commit/1d01ea1f)]
* doc(CordovaPreferences): Improve documentation for using Long.decode instead of Integer.decode ([#1943](https://github.com/apache/cordova-android/pull/1943)) [[661fadd0](https://github.com/apache/cordova-android/commit/661fadd0)]
* doc(statusbar.js): document `visible` property and `setBackgroundColor` method ([#1961](https://github.com/apache/cordova-android/pull/1961)) [[50ee09e4](https://github.com/apache/cordova-android/commit/50ee09e4)]
* refactor: address warnings in SystemWebChromeClient.java ([#1951](https://github.com/apache/cordova-android/pull/1951)) [[80491e9a](https://github.com/apache/cordova-android/commit/80491e9a)]
### 15.0.0
**Breaking Changes:**
+16 -30
View File
@@ -26,11 +26,6 @@ var statusBar = {};
const statusBarScript = document.createElement('script');
document.head.appendChild(statusBarScript);
/**
* Sets the visibility of the status bar, which will only work if Android EdgeToEdge is disabled.
* If cordova-plugin-statusbar is used, the call will be forwarded to `window.StatusBar.show` or
* `window.StatusBar.hide` of the plugin.
*/
Object.defineProperty(statusBar, 'visible', {
configurable: false,
enumerable: true,
@@ -57,14 +52,6 @@ Object.defineProperty(statusBar, 'visible', {
}
});
/**
* Sets the background color of the visible status bar.
* Supports valid CSS color values, e.g. `rebeccapurple`, `#RRGGBBAA`, `rgb(255 0 153)`.
*
* If cordova-plugin-statusbar is installed, calls are forwarded to the plugin API:
* `window.StatusBar.backgroundColorByHexString`
* See {@link https://s.apache.org/cdv-plugin-statusbar} for cordova-plugin-statusbar details.
*/
Object.defineProperty(statusBar, 'setBackgroundColor', {
configurable: false,
enumerable: false,
@@ -73,29 +60,28 @@ Object.defineProperty(statusBar, 'setBackgroundColor', {
statusBarScript.style.color = value;
var rgbStr = window.getComputedStyle(statusBarScript).getPropertyValue('color');
if (!rgbStr.match(/^rgb/)) {
return;
}
if (!rgbStr.match(/^rgb/)) { return; }
var rgbVals = rgbStr.match(/\d+/g).map(function (v) { return parseInt(v, 10); });
var rgbVals = rgbStr.match(/[\d.]+/g).map(function (v, i) { return (i < 3) ? parseInt(v, 10) : parseFloat(v); });
if (rgbVals.length < 3) {
return;
} else if (rgbVals.length === 3) {
rgbVals = [255].concat(rgbVals);
}
// TODO: Use `padStart(2, '0')` once SDK 24 is dropped.
const padRgb = (val) => {
const hex = val.toString(16);
return hex.length === 1 ? '0' + hex : hex;
};
const a = padRgb(rgbVals[0]);
const r = padRgb(rgbVals[1]);
const g = padRgb(rgbVals[2]);
const b = padRgb(rgbVals[3]);
const hexStr = '#' + a + r + g + b;
if (window.StatusBar) {
// try to let the StatusBar plugin handle it
// TODO: Use `padStart(2, '0')` once SDK 24 is dropped.
const padRgb = (val) => {
const hex = val.toString(16);
return hex.length === 1 ? '0' + hex : hex;
};
const r = padRgb(rgbVals[0]);
const g = padRgb(rgbVals[1]);
const b = padRgb(rgbVals[2]);
const a = padRgb(255 * (rgbVals[3] !== undefined ? rgbVals[3] : 1.0));
const hexStr = '#' + a + r + g + b;
window.StatusBar.backgroundColorByHexString(hexStr);
} else {
exec(null, null, 'SystemBarPlugin', 'setStatusBarBackgroundColor', rgbVals);
@@ -225,22 +225,13 @@ public class CordovaActivity extends AppCompatActivity {
boolean isStatusBarVisible = statusBarView.getVisibility() != View.GONE;
int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ? bars.top : 0;
int bottom = !canEdgeToEdge && !isFullScreen ? bars.bottom : 0;
int left = !canEdgeToEdge && !isFullScreen ? bars.left : 0;
int right = !canEdgeToEdge && !isFullScreen ? bars.right : 0;
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
// When in fullscreen mode, we ignore bottom system insets (like the navigation bar)
// to allow the WebView to span the entire screen and avoid being pushed up.
int bottom = isFullScreen ? 0 : canEdgeToEdge ? imeInsets.bottom : Math.max(bars.bottom, imeInsets.bottom);
FrameLayout.LayoutParams webViewParams = (FrameLayout.LayoutParams) webView.getLayoutParams();
// Only update layout margins if the values have actually changed.
// This prevents redundant layout passes and potential infinite layout loops
if (webViewParams.leftMargin != left || webViewParams.topMargin != top
|| webViewParams.rightMargin != right || webViewParams.bottomMargin != bottom) {
webViewParams.setMargins(left, top, right, bottom);
webView.setLayoutParams(webViewParams);
}
webViewParams.setMargins(left, top, right, bottom);
webView.setLayoutParams(webViewParams);
FrameLayout.LayoutParams statusBarParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
@@ -416,14 +416,7 @@ public class CordovaPlugin {
}
/**
* Forwarded system call to the plugin when the user grants permissions,
* denies them or the request was interrupted.
* This is a legacy method and should not be used anymore.
* Instead {@link #onRequestPermissionsResult} should be used.
*
* Note: The system calls {@link CordovaActivity#onRequestPermissionsResult(int, String[], int[])},
* which calls {@link CordovaInterfaceImpl#onRequestPermissionsResult(int, String[], int[])},
* and finally this method.
* Called by the system when the user grants permissions
*
* @param requestCode
* @param permissions
@@ -437,17 +430,11 @@ public class CordovaPlugin {
}
/**
* Forwarded system call to the plugin when the user grants permissions,
* denies them or the request was interrupted.
*
* Note: The system calls {@link CordovaActivity#onRequestPermissionsResult(int, String[], int[])},
* which calls {@link CordovaInterfaceImpl#onRequestPermissionsResult(int, String[], int[])},
* and finally this method.
* Called by the system when the user grants permissions
*
* @param requestCode
* @param permissions
* @param grantResults
* @see https://developer.android.com/reference/android/app/Activity#onRequestPermissionsResult(int,%20java.lang.String[],%20int[])
*/
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) throws JSONException {
@@ -74,10 +74,7 @@ public class CordovaPreferences {
name = name.toLowerCase(Locale.ENGLISH);
String value = prefs.get(name);
if (value != null) {
// Some 32-bit hex values (for example, 0x80000000) are valid int bit patterns
// but exceed Integer.MAX_VALUE when read as positive numbers. Integer.decode()
// rejects such values with NumberFormatException, so decode as long first and
// cast to int to preserve the intended 32-bit value.
// Use Integer.decode() can't handle it if the highest bit is set.
return (int)(long)Long.decode(value);
}
return defaultValue;
@@ -33,7 +33,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
* are not expected to implement it.
*/
public interface CordovaWebView {
public static final String CORDOVA_VERSION = "15.1.0";
public static final String CORDOVA_VERSION = "15.0.0";
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
@@ -18,6 +18,12 @@
*/
package org.apache.cordova;
import java.util.Arrays;
import org.json.JSONException;
import android.content.pm.PackageManager;
/**
* This class is permission helper class when compiling against older versions of cordova-android pre 5.0.0
* and provides reflective methods for permission requesting and checking so that plugins
@@ -32,7 +38,6 @@ package org.apache.cordova;
* @deprecated As of cordova-android 5.0.0, this class is no longer needed and will be removed in a future release.
* You can call directly into {@link CordovaInterface} methods instead with {@link CordovaPlugin#cordova}.
*/
@Deprecated
public class PermissionHelper {
/**
* Requests a "dangerous" permission for the application at runtime. This is a helper method
@@ -43,9 +48,8 @@ public class PermissionHelper {
* @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult()
* along with the result of the permission request
* @param permission The permission to be requested
* @deprecated As of cordova-android 5.0.0, use {@link CordovaInterface#requestPermission(CordovaPlugin, int, String)} instead.
* @deprecated As of cordova-android 5.0.0, use {@link CordovaInterface#requestPermission()} instead.
*/
@Deprecated
public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) {
PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission});
}
@@ -59,9 +63,8 @@ public class PermissionHelper {
* @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult()
* along with the result of the permissions request
* @param permissions The permissions to be requested
* @deprecated As of cordova-android 5.0.0, use {@link CordovaInterface#requestPermissions(CordovaPlugin, int, String[])} instead.
* @deprecated As of cordova-android 5.0.0, use {@link CordovaInterface#requestPermissions()} instead.
*/
@Deprecated
public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) {
plugin.cordova.requestPermissions(plugin, requestCode, permissions);
}
@@ -74,9 +77,8 @@ public class PermissionHelper {
* @param plugin The plugin the permission is being checked against
* @param permission The permission to be checked
* @return True if the permission has already been granted and false otherwise
* @deprecated As of cordova-android 5.0.0, use {@link CordovaInterface#hasPermission(String)} instead.
* @deprecated As of cordova-android 5.0.0, use {@link CordovaInterface#hasPermission()} instead.
*/
@Deprecated
public static boolean hasPermission(CordovaPlugin plugin, String permission) {
return plugin.cordova.hasPermission(permission);
}
@@ -39,15 +39,15 @@ import androidx.core.view.WindowInsetsControllerCompat;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.Objects;
public class SystemBarPlugin extends CordovaPlugin {
static final String PLUGIN_NAME = "SystemBarPlugin";
static final int INVALID_COLOR = -1;
// Internal variables
private Context context;
private Resources resources;
private Integer overrideStatusBarBackgroundColor = null;
private int overrideStatusBarBackgroundColor = INVALID_COLOR;
private boolean canEdgeToEdge = false;
@@ -80,6 +80,10 @@ public class SystemBarPlugin extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if(canEdgeToEdge) {
return false;
}
if ("setStatusBarVisible".equals(action)) {
boolean visible = args.getBoolean(0);
cordova.getActivity().runOnUiThread(() -> setStatusBarVisible(visible));
@@ -117,16 +121,20 @@ public class SystemBarPlugin extends CordovaPlugin {
* If the supplied ARGB is invalid or fails to parse, it will silently ignore
* the change request.
*
* @param argbVals {R, G, B, A}
* @param argbVals {A, R, G, B}
*/
private void setStatusBarBackgroundColor(JSONArray argbVals) {
try {
int r = argbVals.getInt(0);
int g = argbVals.getInt(1);
int b = argbVals.getInt(2);
int a = Math.round(255 * (float)argbVals.optDouble(3, 1.0));
int a = argbVals.getInt(0);
int r = argbVals.getInt(1);
int g = argbVals.getInt(2);
int b = argbVals.getInt(3);
String hexColor = String.format("#%02X%02X%02X%02X", a, r, g, b);
overrideStatusBarBackgroundColor = Color.argb(a, r, g, b);
int parsedColor = parseColorFromString(hexColor);
if (parsedColor == INVALID_COLOR) return;
overrideStatusBarBackgroundColor = parsedColor;
updateStatusBar(overrideStatusBarBackgroundColor);
} catch (JSONException e) {
// Silently skip
@@ -137,26 +145,26 @@ public class SystemBarPlugin extends CordovaPlugin {
* Attempt to update all system bars (status, navigation and gesture bars) in various points
* of the apps life cycle.
* For example:
* 1. Device configurations between (E.g. between dark and light mode)
* 2. User resumes the app
* 3. App transitions from SplashScreen Theme to App's Theme
* 1. Device configurations between (E.g. between dark and light mode)
* 2. User resumes the app
* 3. App transitions from SplashScreen Theme to App's Theme
*/
private void updateSystemBars() {
// Update Root View Background Color
Integer rootViewBackgroundColor = getPreferenceBackgroundColor();
if (rootViewBackgroundColor == null) {
int rootViewBackgroundColor = getPreferenceBackgroundColor();
if (rootViewBackgroundColor == INVALID_COLOR) {
rootViewBackgroundColor = canEdgeToEdge ? Color.TRANSPARENT : getUiModeColor();
}
updateRootView(rootViewBackgroundColor);
// Update StatusBar Background Color
Integer statusBarBackgroundColor;
if (overrideStatusBarBackgroundColor != null) {
int statusBarBackgroundColor;
if (overrideStatusBarBackgroundColor != INVALID_COLOR) {
statusBarBackgroundColor = overrideStatusBarBackgroundColor;
} else if (preferences.contains("StatusBarBackgroundColor")) {
statusBarBackgroundColor = getPreferenceStatusBarBackgroundColor();
} else if (preferences.contains("BackgroundColor")) {
statusBarBackgroundColor = rootViewBackgroundColor;
} else if(preferences.contains("BackgroundColor")){
statusBarBackgroundColor = rootViewBackgroundColor;
} else {
statusBarBackgroundColor = canEdgeToEdge ? Color.TRANSPARENT : getUiModeColor();
}
@@ -253,31 +261,34 @@ public class SystemBarPlugin extends CordovaPlugin {
}
/**
* Returns the StatusBarBackgroundColor preference value or {@link #getUiModeColor()} as fallback.
* Returns the StatusBarBackgroundColor preference value.
* If the value is missing or fails to parse, it will attempt to try to guess the background
* color by extracting from the apps R.color.cdv_background_color or determine from the uiModes.
* If all fails, the color normally used in light mode is returned.
*
* @return Integer
* @return int
*/
private Integer getPreferenceStatusBarBackgroundColor() {
private int getPreferenceStatusBarBackgroundColor() {
String colorString = preferences.getString("StatusBarBackgroundColor", null);
return Objects.requireNonNullElse(parseColorFromString(colorString), getUiModeColor());
int parsedColor = parseColorFromString(colorString);
if (parsedColor != INVALID_COLOR) return parsedColor;
return getUiModeColor(); // fallback
}
/**
* Returns the BackgroundColor preference value.
* If the value is missing or fails to decode, null is returned.
* If missing or fails to decode, it will return INVALID_COLOR (-1).
*
* @return Integer|null
* @return int
*/
private Integer getPreferenceBackgroundColor() {
if (!preferences.contains("BackgroundColor")) {
return null;
}
private int getPreferenceBackgroundColor() {
try {
return preferences.getInteger("BackgroundColor", 0);
return preferences.getInteger("BackgroundColor", INVALID_COLOR);
} catch (NumberFormatException e) {
LOG.e(PLUGIN_NAME, "Invalid background color argument. Example valid string: '0x00000000'");
return null;
return INVALID_COLOR;
}
}
@@ -343,20 +354,20 @@ public class SystemBarPlugin extends CordovaPlugin {
}
/**
* Parses a color string provided by app developers.
* If the color string is empty or unable to parse, null is returned.
* Parse color string that would be provided by app developers.
* If the color string is empty or unable to parse, it will return INVALID_COLOR (-1).
*
* @param colorPref hex string value, #AARRGGBB or #RRGGBB
* @return Integer|null
* @return int
*/
private Integer parseColorFromString(final String colorPref) {
if (colorPref == null || colorPref.isEmpty()) return null;
private int parseColorFromString(final String colorPref) {
if (colorPref.isEmpty()) return INVALID_COLOR;
try {
return Color.parseColor(colorPref);
} catch (IllegalArgumentException ignore) {
LOG.e(PLUGIN_NAME, "Invalid color hex code. Valid format: #RRGGBB or #AARRGGBB");
return null;
return INVALID_COLOR;
}
}
}
@@ -73,16 +73,22 @@ public class SystemWebChromeClient extends WebChromeClient {
private PermissionListener permissionListener;
private static final int FILECHOOSER_RESULTCODE = 5173;
private static final String LOG_TAG = "SystemWebChromeClient";
private long MAX_QUOTA = 100 * 1024 * 1024;
protected final SystemWebViewEngine parentEngine;
// the video progress view
private View mVideoProgressView;
private final CordovaDialogsHelper dialogsHelper;
private CordovaDialogsHelper dialogsHelper;
private Context appContext;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private View mCustomView;
public SystemWebChromeClient(SystemWebViewEngine parentEngine) {
this.parentEngine = parentEngine;
dialogsHelper = new CordovaDialogsHelper(parentEngine.webView.getContext());
appContext = parentEngine.webView.getContext();
dialogsHelper = new CordovaDialogsHelper(appContext);
permissionLauncher = parentEngine.cordova.getActivity().registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), isGranted -> {
if (permissionListener != null) {
boolean granted = true;
@@ -99,11 +105,13 @@ public class SystemWebChromeClient extends WebChromeClient {
*/
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
dialogsHelper.showAlert(message, (success, value) -> {
if (success) {
result.confirm();
} else {
result.cancel();
dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() {
@Override public void gotResult(boolean success, String value) {
if (success) {
result.confirm();
} else {
result.cancel();
}
}
});
return true;
@@ -114,11 +122,14 @@ public class SystemWebChromeClient extends WebChromeClient {
*/
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
dialogsHelper.showConfirm(message, (success, value) -> {
if (success) {
result.confirm();
} else {
result.cancel();
dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() {
@Override
public void gotResult(boolean success, String value) {
if (success) {
result.confirm();
} else {
result.cancel();
}
}
});
return true;
@@ -139,11 +150,14 @@ public class SystemWebChromeClient extends WebChromeClient {
if (handledRet != null) {
result.confirm(handledRet);
} else {
dialogsHelper.showPrompt(message, defaultValue, (success, value) -> {
if (success) {
result.confirm(value);
} else {
result.cancel();
dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
@Override
public void gotResult(boolean success, String value) {
if (success) {
result.confirm(value);
} else {
result.cancel();
}
}
});
}
@@ -159,7 +173,6 @@ public class SystemWebChromeClient extends WebChromeClient {
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
{
LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
long MAX_QUOTA = 100 * 1024 * 1024;
quotaUpdater.updateQuota(MAX_QUOTA);
}
@@ -168,8 +181,8 @@ public class SystemWebChromeClient extends WebChromeClient {
*
* <p>This also checks for the Geolocation Plugin and requests permission from the application to use Geolocation.</p>
*
* @param origin The origin of the web content attempting to use the Geolocation API.
* @param callback The callback to use to set the permission state for the origin.
* @param origin
* @param callback
*/
@Override
public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
@@ -283,7 +296,7 @@ public class SystemWebChromeClient extends WebChromeClient {
// Handle result
Uri[] result = null;
if (resultCode == Activity.RESULT_OK) {
List<Uri> uris = new ArrayList<>();
List<Uri> uris = new ArrayList<Uri>();
if (intent != null && intent.getData() != null) { // single file
LOG.v(LOG_TAG, "Adding file (single): " + intent.getData());
@@ -304,8 +317,8 @@ public class SystemWebChromeClient extends WebChromeClient {
}
if (!uris.isEmpty()) {
LOG.d(LOG_TAG, "Receive file chooser URL: " + uris);
result = uris.toArray(new Uri[0]);
LOG.d(LOG_TAG, "Receive file chooser URL: " + uris.toString());
result = uris.toArray(new Uri[uris.size()]);
}
}
filePathsCallback.onReceiveValue(result);
@@ -320,12 +333,14 @@ public class SystemWebChromeClient extends WebChromeClient {
private File createTempFile(Context context) throws IOException {
// Create an image file name
return File.createTempFile("temp", ".jpg", context.getCacheDir());
File tempFile = File.createTempFile("temp", ".jpg", context.getCacheDir());
return tempFile;
}
private Uri createUriForFile(Context context, File tempFile) throws IOException {
String appId = context.getPackageName();
return FileProvider.getUriForFile(context, appId + ".cdv.core.file.provider", tempFile);
Uri uri = FileProvider.getUriForFile(context, appId + ".cdv.core.file.provider", tempFile);
return uri;
}
@Override
+458 -300
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "cordova-android",
"version": "15.1.0",
"version": "15.0.1-dev.0",
"description": "cordova-android release",
"types": "./types/index.d.ts",
"main": "lib/Api.js",
@@ -39,7 +39,7 @@
},
"devDependencies": {
"@cordova/eslint-config": "^6.0.1",
"c8": "^11.0.0",
"c8": "^10.1.3",
"cordova-js": "^6.1.0",
"elementtree": "^0.1.7",
"jasmine": "^6.0.0",
+115
View File
@@ -0,0 +1,115 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
* {
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
}
body {
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
background-color:#E4E4E4;
background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, #A7A7A7),
color-stop(0.51, #E4E4E4)
);
background-attachment:fixed;
font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
font-size:12px;
height:100%;
margin:0px;
padding:0px;
text-transform:uppercase;
width:100%;
}
/* Portrait layout (default) */
.app {
background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
position:absolute; /* position in the center of the screen */
left:50%;
top:50%;
height:50px; /* text area height */
width:225px; /* text area width */
text-align:center;
padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
/* offset horizontal: half of text area width */
}
/* Landscape layout (with min-width) */
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
.app {
background-position:left center;
padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
margin:-90px 0px 0px -198px; /* offset vertical: half of image height */
/* offset horizontal: half of image width and text area width */
}
}
h1 {
font-size:24px;
font-weight:normal;
margin:0px;
overflow:visible;
padding:0px;
text-align:center;
}
.event {
border-radius:4px;
-webkit-border-radius:4px;
color:#FFFFFF;
font-size:12px;
margin:0px 30px;
padding:2px 0px;
}
.event.listening {
background-color:#333333;
display:block;
}
.event.received {
background-color:#4B946A;
display:none;
}
@keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.4; }
to { opacity: 1.0; }
}
@-webkit-keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.4; }
to { opacity: 1.0; }
}
.blink {
animation:fade 3000ms infinite;
-webkit-animation:fade 3000ms infinite;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+49
View File
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<!--
Customize this policy to fit your own app's needs. For more guidance, see:
https://cordova.apache.org/docs/en/latest/
Some notes:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
+51
View File
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var app = {
// Application Constructor
initialize: function () {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function () {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function () {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function (id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();