Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f53ea4c6a9 |
@@ -1,35 +0,0 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
PLATFORM: windows-10-store
|
||||
JUST_BUILD: --justBuild
|
||||
matrix:
|
||||
- nodejs_version: "8"
|
||||
- nodejs_version: "10"
|
||||
- nodejs_version: "12"
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
install:
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
- node --version
|
||||
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
|
||||
- npm install -g cordova
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%
|
||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1 +0,0 @@
|
||||
* text eol=lf
|
||||
42
.github/ISSUE_TEMPLATE.md
vendored
42
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,42 +0,0 @@
|
||||
<!--
|
||||
Please have a look at the issue templates you get when you click "New issue" in the GitHub UI.
|
||||
We very much prefer issues created by using one of these templates.
|
||||
-->
|
||||
|
||||
### Issue Type
|
||||
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
|
||||
|
||||
- [ ] Bug Report
|
||||
- [ ] Feature Request
|
||||
- [ ] Support Question
|
||||
|
||||
## Description
|
||||
|
||||
## Information
|
||||
<!-- Include all relevant information that might help understand and reproduce the problem -->
|
||||
|
||||
### Command or Code
|
||||
<!-- What command or code is needed to reproduce the problem? -->
|
||||
|
||||
### Environment, Platform, Device
|
||||
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
|
||||
|
||||
|
||||
|
||||
### Version information
|
||||
<!--
|
||||
What are relevant versions you are using?
|
||||
For example:
|
||||
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
|
||||
Other Frameworks: Ionic Framework and CLI version
|
||||
Operating System, Android Studio, Xcode etc.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Checklist
|
||||
<!-- Please check the boxes by putting an `x` in the `[ ]` like so: `[x]` -->
|
||||
|
||||
- [ ] I searched for already existing GitHub issues about this
|
||||
- [ ] I updated all Cordova tooling to their most recent version
|
||||
- [ ] I included all the necessary information above
|
||||
50
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
50
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
@@ -1,50 +0,0 @@
|
||||
---
|
||||
name: 🐛 Bug Report
|
||||
about: If something isn't working as expected.
|
||||
|
||||
---
|
||||
|
||||
# Bug Report
|
||||
|
||||
## Problem
|
||||
|
||||
### What is expected to happen?
|
||||
|
||||
|
||||
|
||||
### What does actually happen?
|
||||
|
||||
|
||||
|
||||
## Information
|
||||
<!-- Include all relevant information that might help understand and reproduce the problem -->
|
||||
|
||||
|
||||
|
||||
### Command or Code
|
||||
<!-- What command or code is needed to reproduce the problem? -->
|
||||
|
||||
|
||||
|
||||
### Environment, Platform, Device
|
||||
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
|
||||
|
||||
|
||||
|
||||
### Version information
|
||||
<!--
|
||||
What are relevant versions you are using?
|
||||
For example:
|
||||
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
|
||||
Other Frameworks: Ionic Framework and CLI version
|
||||
Operating System, Android Studio, Xcode etc.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Checklist
|
||||
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
|
||||
|
||||
- [ ] I searched for existing GitHub issues
|
||||
- [ ] I updated all Cordova tooling to most recent version
|
||||
- [ ] I included all the necessary information above
|
||||
29
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
29
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
@@ -1,29 +0,0 @@
|
||||
---
|
||||
name: 🚀 Feature Request
|
||||
about: A suggestion for a new functionality
|
||||
|
||||
---
|
||||
|
||||
# Feature Request
|
||||
|
||||
## Motivation Behind Feature
|
||||
<!-- Why should this feature be implemented? What problem does it solve? -->
|
||||
|
||||
|
||||
|
||||
## Feature Description
|
||||
<!--
|
||||
Describe your feature request in detail
|
||||
Please provide any code examples or screenshots of what this feature would look like
|
||||
Are there any drawbacks? Will this break anything for existing users?
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Alternatives or Workarounds
|
||||
<!--
|
||||
Describe alternatives or workarounds you are currently using
|
||||
Are there ways to do this with existing functionality?
|
||||
-->
|
||||
|
||||
|
||||
27
.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md
vendored
27
.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md
vendored
@@ -1,27 +0,0 @@
|
||||
---
|
||||
name: 💬 Support Question
|
||||
about: If you have a question, please check out our Slack or StackOverflow!
|
||||
|
||||
---
|
||||
|
||||
<!------------^ Click "Preview" for a nicer view! -->
|
||||
|
||||
Apache Cordova uses GitHub Issues as a feature request and bug tracker _only_.
|
||||
For usage and support questions, please check out the resources below. Thanks!
|
||||
|
||||
---
|
||||
|
||||
You can get answers to your usage and support questions about **Apache Cordova** on:
|
||||
|
||||
* Slack Community Chat: https://cordova.slack.com (you can sign-up at http://slack.cordova.io/)
|
||||
* StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova`
|
||||
|
||||
---
|
||||
|
||||
If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:
|
||||
|
||||
* **Ionic Framework**
|
||||
* [Ionic Community Forum](https://forum.ionicframework.com/)
|
||||
* [Ionic Worldwide Slack](https://ionicworldwide.herokuapp.com/)
|
||||
* **PhoneGap**
|
||||
* [PhoneGap Developer Community](https://forums.adobe.com/community/phonegap)
|
||||
35
.github/PULL_REQUEST_TEMPLATE.md
vendored
35
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,35 +0,0 @@
|
||||
<!--
|
||||
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
|
||||
|
||||
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. -->
|
||||
|
||||
|
||||
|
||||
### Description
|
||||
<!-- Describe your changes in detail -->
|
||||
|
||||
|
||||
|
||||
### Testing
|
||||
<!-- Please describe in detail how you tested your changes. -->
|
||||
|
||||
|
||||
|
||||
### Checklist
|
||||
|
||||
- [ ] I've run the tests to see all new and existing tests pass
|
||||
- [ ] I added automated test coverage as appropriate for this change
|
||||
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
|
||||
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
||||
- [ ] I've updated the documentation if necessary
|
||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1,15 +0,0 @@
|
||||
#If ignorance is bliss, then somebody knock the smile off my face
|
||||
|
||||
*.csproj.user
|
||||
*.suo
|
||||
*.cache
|
||||
Thumbs.db
|
||||
*.DS_Store
|
||||
|
||||
*.bak
|
||||
*.cache
|
||||
*.log
|
||||
*.swp
|
||||
*.user
|
||||
|
||||
node_modules
|
||||
16
.jshintrc
16
.jshintrc
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"browser": true
|
||||
, "devel": true
|
||||
, "bitwise": true
|
||||
, "undef": true
|
||||
, "trailing": true
|
||||
, "quotmark": false
|
||||
, "indent": 4
|
||||
, "unused": "vars"
|
||||
, "latedef": "nofunc"
|
||||
, "globals": {
|
||||
"module": false,
|
||||
"exports": false,
|
||||
"require": false
|
||||
}
|
||||
}
|
||||
16
.npmignore
16
.npmignore
@@ -1,16 +0,0 @@
|
||||
# CI service configurations
|
||||
.travis.yml
|
||||
.appveyor.yml
|
||||
appveyor.yml
|
||||
|
||||
# Testing, code coverage, and linting
|
||||
.eslintignore
|
||||
.eslintrc.yml
|
||||
|
||||
# Git
|
||||
.git
|
||||
.gitattributes
|
||||
.gitignore
|
||||
|
||||
# Github
|
||||
.github
|
||||
119
.travis.yml
119
.travis.yml
@@ -1,119 +0,0 @@
|
||||
# This Travis configuration file is built after a Cordova Paramedic
|
||||
# specific template with minimal modifications and adaptations:
|
||||
# https://github.com/apache/cordova-paramedic/blob/master/.travis.yml
|
||||
|
||||
sudo: false
|
||||
|
||||
addons:
|
||||
jwt:
|
||||
# SAUCE_ACCESS_KEY
|
||||
secure: Rd/wGSUWGWbc0Y/vqPgI29nybq+j/zWilEIOCBJeRQVwfubdbJNZUIb5DFlSSVzMEavkxZ0PYJ45h21iXyWo3aOoxUJwhkO7QZNzW2MsYzy9qpiKK1jOESXMrpboRWoxg+BL85YbaDF3u1XRy+Xm1nraStT6mDfx5LlUG1Lac6A=
|
||||
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION=8
|
||||
- ANDROID_API_LEVEL=28
|
||||
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
|
||||
|
||||
language: node_js
|
||||
node_js: 8
|
||||
|
||||
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
|
||||
|
||||
_ios: &_ios
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
|
||||
_android: &_android
|
||||
language: android
|
||||
os: linux
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
|
||||
- android-$ANDROID_API_LEVEL
|
||||
licenses:
|
||||
- 'android-sdk-preview-license-.+'
|
||||
- 'android-sdk-license-.+'
|
||||
- 'google-gdk-license-.+'
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# local tests, without saucelabs
|
||||
- env: PLATFORM=local/browser
|
||||
<<: *_ios
|
||||
- env: PLATFORM=local/ios-10.0
|
||||
<<: *_ios
|
||||
|
||||
# many tests with saucelabs
|
||||
- env: PLATFORM=browser-chrome
|
||||
- env: PLATFORM=browser-firefox
|
||||
- env: PLATFORM=browser-safari
|
||||
- env: PLATFORM=browser-edge
|
||||
|
||||
- env: PLATFORM=ios-11.3
|
||||
<<: *_ios
|
||||
- env: PLATFORM=ios-12.0
|
||||
<<: *_ios
|
||||
- env: PLATFORM=ios-12.2
|
||||
<<: *_ios
|
||||
|
||||
- env: PLATFORM=android-5.1
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-6.0
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-7.0
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-7.1
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-8.0
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-8.1
|
||||
<<: *_android
|
||||
- env: PLATFORM=android-9.0
|
||||
<<: *_android
|
||||
|
||||
before_install:
|
||||
# manually install Node for `language: android`
|
||||
- if [[ "$PLATFORM" =~ android ]]; then nvm install $TRAVIS_NODE_VERSION; fi
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- npm install -g cordova
|
||||
# install paramedic if not running on paramedic repo
|
||||
- if ! [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then npm install -g github:apache/cordova-paramedic; fi
|
||||
|
||||
install:
|
||||
- npm install
|
||||
|
||||
before_script:
|
||||
- |
|
||||
if [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then
|
||||
# when used in the cordova-paramedic repo
|
||||
TEST_COMMAND="npm run eslint"
|
||||
PARAMEDIC_PLUGIN_TO_TEST="./spec/testable-plugin/"
|
||||
PARAMEDIC_COMMAND="node main.js"
|
||||
else
|
||||
# when used in any other (plugin) repo
|
||||
TEST_COMMAND="npm test"
|
||||
PARAMEDIC_PLUGIN_TO_TEST=$(pwd)
|
||||
PARAMEDIC_COMMAND="cordova-paramedic"
|
||||
fi
|
||||
- PARAMEDIC_BUILDNAME=travis-$TRAVIS_REPO_SLUG-$TRAVIS_JOB_NUMBER
|
||||
- |
|
||||
echo "Variables now are set to:"
|
||||
echo "TEST_COMMAND=$TEST_COMMAND"
|
||||
echo "ADDITIONAL_TESTS=$ADDITIONAL_TESTS"
|
||||
echo "PARAMEDIC_COMMAND=$PARAMEDIC_COMMAND"
|
||||
echo "PLATFORM=$PLATFORM"
|
||||
echo "PARAMEDIC_PLUGIN_TO_TEST=$PARAMEDIC_PLUGIN_TO_TEST"
|
||||
echo "PARAMEDIC_BUILDNAME=$PARAMEDIC_BUILDNAME"
|
||||
script:
|
||||
- $TEST_COMMAND
|
||||
- if [[ "$ADDITIONAL_TESTS_DIR" != "" ]]; then
|
||||
cd $ADDITIONAL_TESTS_DIR && npm install && npm test;
|
||||
else
|
||||
$PARAMEDIC_COMMAND --config ./pr/$PLATFORM --plugin $PARAMEDIC_PLUGIN_TO_TEST --buildName $PARAMEDIC_BUILDNAME;
|
||||
fi
|
||||
@@ -1,37 +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.
|
||||
#
|
||||
-->
|
||||
|
||||
# Contributing to Apache Cordova
|
||||
|
||||
Anyone can contribute to Cordova. And we need your contributions.
|
||||
|
||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||
contribute code.
|
||||
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||
- Have a Jira issue open that corresponds to your contribution.
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
||||
202
LICENSE
202
LICENSE
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
||||
5
NOTICE
5
NOTICE
@@ -1,5 +0,0 @@
|
||||
Apache Cordova
|
||||
Copyright 2012 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
336
README.md
336
README.md
@@ -1,321 +1,23 @@
|
||||
---
|
||||
title: Statusbar
|
||||
description: Control the device status bar.
|
||||
---
|
||||
<!---
|
||||
# license: 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.
|
||||
license: 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.
|
||||
-->
|
||||
|
||||
|AppVeyor|Travis CI|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-statusbar)|[](https://travis-ci.org/apache/cordova-plugin-statusbar)|
|
||||
# org.apache.cordova.statusbar
|
||||
|
||||
# cordova-plugin-statusbar
|
||||
|
||||
> The `StatusBar` object provides some functions to customize the iOS and Android StatusBar.
|
||||
|
||||
## Installation
|
||||
|
||||
This installation method requires cordova 5.0+
|
||||
|
||||
cordova plugin add cordova-plugin-statusbar
|
||||
Older versions of cordova can still install via the __deprecated__ id
|
||||
|
||||
cordova plugin add org.apache.cordova.statusbar
|
||||
It is also possible to install via repo url directly ( unstable )
|
||||
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git
|
||||
|
||||
|
||||
Preferences
|
||||
-----------
|
||||
|
||||
#### config.xml
|
||||
|
||||
- __StatusBarOverlaysWebView__ (boolean, defaults to true). Make the statusbar overlay or not overlay the WebView at startup.
|
||||
|
||||
<preference name="StatusBarOverlaysWebView" value="true" />
|
||||
|
||||
##### Android Quirks
|
||||
|
||||
Only supported on Android 5 or later. Earlier versions will ignore this preference.
|
||||
|
||||
- __StatusBarBackgroundColor__ (color hex string, no default value). Set the background color of the statusbar by a hex string (#RRGGBB) at startup. If this value is not set, the background color will be transparent.
|
||||
|
||||
<preference name="StatusBarBackgroundColor" value="#000000" />
|
||||
|
||||
- __StatusBarStyle__ (status bar style, defaults to lightcontent). Set the status bar style (e.g. text color). Available options: default, lightcontent, blacktranslucent, blackopaque.
|
||||
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
|
||||
- __StatusBarDefaultScrollToTop__ (boolean, defaults to false). On iOS, allows the Cordova WebView to use default scroll-to-top behavior. Defaults to false so you can listen to the "statusTap" event (described below) and customize the behavior instead.
|
||||
|
||||
<preference name="StatusBarDefaultScrollToTop" value="false" />
|
||||
|
||||
### Android Quirks
|
||||
The Android 5+ guidelines specify using a different color for the statusbar than your main app color (unlike the uniform statusbar color of many iOS apps), so you may want to set the statusbar color at runtime instead via `StatusBar.backgroundColorByHexString` or `StatusBar.backgroundColorByName`. One way to do that would be:
|
||||
```js
|
||||
if (cordova.platformId == 'android') {
|
||||
StatusBar.backgroundColorByHexString("#333");
|
||||
}
|
||||
```
|
||||
|
||||
It is also possible to make the status bar semi-transparent. Android uses hexadecimal ARGB values, which are formatted as #AARRGGBB. That first pair of letters, the AA, represent the alpha channel. You must convert your decimal opacity values to a hexadecimal value. You can read more about it [here](https://stackoverflow.com/questions/5445085/understanding-colors-on-android-six-characters/11019879#11019879).
|
||||
|
||||
For example, a black status bar with 20% opacity:
|
||||
```js
|
||||
if (cordova.platformId == 'android') {
|
||||
StatusBar.overlaysWebView(true);
|
||||
StatusBar.backgroundColorByHexString('#33000000');
|
||||
}
|
||||
```
|
||||
|
||||
Hiding at startup
|
||||
-----------
|
||||
|
||||
During runtime you can use the StatusBar.hide function below, but if you want the StatusBar to be hidden at app startup on iOS, you must modify your app's Info.plist file.
|
||||
|
||||
Add/edit these two attributes if not present. Set **"Status bar is initially hidden"** to **"YES"** and set **"View controller-based status bar appearance"** to **"NO"**. If you edit it manually without Xcode, the keys and values are:
|
||||
|
||||
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
This plugin defines global `StatusBar` object.
|
||||
|
||||
Although in the global scope, it is not available until after the `deviceready` event.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(StatusBar);
|
||||
}
|
||||
|
||||
- StatusBar.overlaysWebView
|
||||
- StatusBar.styleDefault
|
||||
- StatusBar.styleLightContent
|
||||
- StatusBar.styleBlackTranslucent
|
||||
- StatusBar.styleBlackOpaque
|
||||
- StatusBar.backgroundColorByName
|
||||
- StatusBar.backgroundColorByHexString
|
||||
- StatusBar.hide
|
||||
- StatusBar.show
|
||||
|
||||
Properties
|
||||
--------
|
||||
|
||||
- StatusBar.isVisible
|
||||
|
||||
Events
|
||||
------
|
||||
|
||||
- statusTap
|
||||
|
||||
StatusBar.overlaysWebView
|
||||
=================
|
||||
|
||||
Make the statusbar overlay or not overlay the WebView.
|
||||
|
||||
StatusBar.overlaysWebView(true);
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Set to true to make the statusbar overlay on top of your app. Ensure that you adjust your styling accordingly so that your app's title bar or content is not covered. Set to false to make the statusbar solid and not overlay your app. You can then set the style and background color to suit using the other functions.
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS 7+
|
||||
- Android 5+
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
StatusBar.overlaysWebView(true);
|
||||
StatusBar.overlaysWebView(false);
|
||||
|
||||
StatusBar.styleDefault
|
||||
=================
|
||||
|
||||
Use the default statusbar (dark text, for light backgrounds).
|
||||
|
||||
StatusBar.styleDefault();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
StatusBar.styleLightContent
|
||||
=================
|
||||
|
||||
Use the lightContent statusbar (light text, for dark backgrounds).
|
||||
|
||||
StatusBar.styleLightContent();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
StatusBar.styleBlackTranslucent
|
||||
=================
|
||||
|
||||
Use the blackTranslucent statusbar (light text, for dark backgrounds).
|
||||
|
||||
StatusBar.styleBlackTranslucent();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
StatusBar.styleBlackOpaque
|
||||
=================
|
||||
|
||||
Use the blackOpaque statusbar (light text, for dark backgrounds).
|
||||
|
||||
StatusBar.styleBlackOpaque();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
|
||||
StatusBar.backgroundColorByName
|
||||
=================
|
||||
|
||||
On iOS, when you set StatusBar.overlaysWebView to false, you can set the background color of the statusbar by color name.
|
||||
|
||||
StatusBar.backgroundColorByName("red");
|
||||
|
||||
Supported color names are:
|
||||
|
||||
black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 5+
|
||||
- Windows
|
||||
|
||||
StatusBar.backgroundColorByHexString
|
||||
=================
|
||||
|
||||
Sets the background color of the statusbar by a hex string.
|
||||
|
||||
StatusBar.backgroundColorByHexString("#C0C0C0");
|
||||
|
||||
CSS shorthand properties are also supported.
|
||||
|
||||
StatusBar.backgroundColorByHexString("#333"); // => #333333
|
||||
StatusBar.backgroundColorByHexString("#FAB"); // => #FFAABB
|
||||
|
||||
On iOS, when you set StatusBar.overlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB).
|
||||
|
||||
On Android, when StatusBar.overlaysWebView is true, and on WP7&8, you can also specify values as #AARRGGBB, where AA is an alpha value.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 5+
|
||||
- Windows
|
||||
|
||||
StatusBar.hide
|
||||
=================
|
||||
|
||||
Hide the statusbar.
|
||||
|
||||
StatusBar.hide();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android
|
||||
- Windows
|
||||
|
||||
StatusBar.show
|
||||
=================
|
||||
|
||||
Shows the statusbar.
|
||||
|
||||
StatusBar.show();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android
|
||||
- Windows
|
||||
|
||||
StatusBar.isVisible
|
||||
=================
|
||||
|
||||
Read this property to see if the statusbar is visible or not.
|
||||
|
||||
if (StatusBar.isVisible) {
|
||||
// do something
|
||||
}
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android
|
||||
- Windows
|
||||
|
||||
statusTap
|
||||
=========
|
||||
|
||||
Listen for this event to know if the statusbar was tapped.
|
||||
|
||||
window.addEventListener('statusTap', function() {
|
||||
// scroll-up with document.body.scrollTop = 0; or do whatever you want
|
||||
});
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
Plugin documentation: [doc/index.md](doc/index.md)
|
||||
This is `dev` - the deprecated development branch of this plugin; development of this plugin has moved to the `master` branch
|
||||
|
||||
191
RELEASENOTES.md
191
RELEASENOTES.md
@@ -1,191 +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.
|
||||
#
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 2.4.3 (Jun 19, 2019)
|
||||
|
||||
- docs: Improved documentation and removed text that implies iOS only ([#130](https://github.com/apache/cordova-plugin-statusbar/issues/130)) ([`33e410a`](https://github.com/apache/cordova-plugin-statusbar/commit/33e410a), [`14b1513`](https://github.com/apache/cordova-plugin-statusbar/commit/14b1513))
|
||||
- docs: Alpha example doesn't match description ([#100](https://github.com/apache/cordova-plugin-statusbar/issues/100)) ([`5b77cae`](https://github.com/apache/cordova-plugin-statusbar/commit/5b77cae), [`9b5baa2`](https://github.com/apache/cordova-plugin-statusbar/commit/9b5baa2))
|
||||
- chore(types): remove version from types ([`fade76b`](https://github.com/apache/cordova-plugin-statusbar/commit/fade76b))
|
||||
- chore: fix github issues link ([`288bd71`](https://github.com/apache/cordova-plugin-statusbar/commit/288bd71))
|
||||
- docs: remove outdated translations ([`8dacefa`](https://github.com/apache/cordova-plugin-statusbar/commit/8dacefa))
|
||||
- build: add `.npmignore` to remove unneeded files from npm package ([`84081de`](https://github.com/apache/cordova-plugin-statusbar/commit/84081de))
|
||||
- build: add `.gitattributes` to force LF (instead of possible CRLF on Windows) ([`da6c2a8`](https://github.com/apache/cordova-plugin-statusbar/commit/da6c2a8))
|
||||
- ci(travis): Update Travis CI configuration for new paramedic ([#139](https://github.com/apache/cordova-plugin-statusbar/issues/139)) ([`a538bfe`](https://github.com/apache/cordova-plugin-statusbar/commit/a538bfe))
|
||||
- feat: update typings ([#132](https://github.com/apache/cordova-plugin-statusbar/issues/132)) ([`003fa61`](https://github.com/apache/cordova-plugin-statusbar/commit/003fa61))
|
||||
- chore: drop Node.js v4 support ([#124](https://github.com/apache/cordova-plugin-statusbar/issues/124)) ([`a07612a`](https://github.com/apache/cordova-plugin-statusbar/commit/a07612a))
|
||||
- chore(github): Add or update GitHub pull request and issue template ([`727eea3`](https://github.com/apache/cordova-plugin-statusbar/commit/727eea3))
|
||||
- docs: remove JIRA link ([`adcee9f`](https://github.com/apache/cordova-plugin-statusbar/commit/adcee9f))
|
||||
- ci(travis): also accept terms for android sdk `android-27` ([`c8a13b8`](https://github.com/apache/cordova-plugin-statusbar/commit/c8a13b8))
|
||||
- docs: remove second title headline ([`ecf8ccd`](https://github.com/apache/cordova-plugin-statusbar/commit/ecf8ccd))
|
||||
- docs: Add Android overlay support to README ([#97](https://github.com/apache/cordova-plugin-statusbar/issues/97)) ([`e0256b2`](https://github.com/apache/cordova-plugin-statusbar/commit/e0256b2), [`053a902`](https://github.com/apache/cordova-plugin-statusbar/commit/053a902))
|
||||
|
||||
|
||||
### 2.4.2 (Apr 12, 2018)
|
||||
* [CB-12679](https://issues.apache.org/jira/browse/CB-12679) Remove Permissions section
|
||||
|
||||
### 2.4.1 (Dec 27, 2017)
|
||||
* [CB-13712](https://issues.apache.org/jira/browse/CB-13712) (iOS): fix overlaysWebView reset on rotation (#92)
|
||||
|
||||
### 2.4.0 (Dec 15, 2017)
|
||||
* [CB-13623](https://issues.apache.org/jira/browse/CB-13623) (iOS): Remove **iOS** 6-7 code
|
||||
|
||||
### 2.3.0 (Nov 06, 2017)
|
||||
* [CB-13476](https://issues.apache.org/jira/browse/CB-13476) (iOS): handle double size statusbar on SDK 10 for **iOS 11**
|
||||
* [CB-13394](https://issues.apache.org/jira/browse/CB-13394) (iOS): fix `iPhone X` StatusBar rendering in landscape
|
||||
* [CB-11858](https://issues.apache.org/jira/browse/CB-11858) (android) Add `StatusBarStyle` feature support for **Android M+**
|
||||
* [CB-13311](https://issues.apache.org/jira/browse/CB-13311) (iOS) Statusbar does not overlay correctly on `iPhone X`
|
||||
* [CB-13028](https://issues.apache.org/jira/browse/CB-13028) (CI) **Browser** builds on Travis and AppVeyor
|
||||
* [CB-12812](https://issues.apache.org/jira/browse/CB-12812) (browser) Fix statusbar plugin with **Browser** platform
|
||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
||||
|
||||
### 2.2.3 (Apr 27, 2017)
|
||||
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README`
|
||||
* [CB-10879](https://issues.apache.org/jira/browse/CB-10879) Enable overlaysWebView on **Android** API 21+
|
||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
||||
|
||||
### 2.2.2 (Feb 28, 2017)
|
||||
* [CB-12188](https://issues.apache.org/jira/browse/CB-12188) Status Bar is not changing in some specific **Android** phone (Red MI 3s Prime)
|
||||
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
|
||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
||||
* [CB-12196](https://issues.apache.org/jira/browse/CB-12196) **iOS** fix Status Bar Not Hiding
|
||||
* [CB-12141](https://issues.apache.org/jira/browse/CB-12141) **iOS** fix white app screen after camera overlay shown on iPad
|
||||
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed **Windows 8.1** build badges
|
||||
|
||||
### 2.2.1 (Dec 07, 2016)
|
||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 2.2.1
|
||||
* [CB-10288](https://issues.apache.org/jira/browse/CB-10288) statusbar plugin interaction with iOS multitasking
|
||||
* [CB-10158](https://issues.apache.org/jira/browse/CB-10158) (ios) fix StatusBar issue when recovering from fullscreen video
|
||||
* [CB-10341](https://issues.apache.org/jira/browse/CB-10341) ios, document statusTap event
|
||||
* [CB-11191](https://issues.apache.org/jira/browse/CB-11191) Statusbar plugin causing issues with webview size
|
||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
|
||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
||||
|
||||
### 2.2.0 (Sep 08, 2016)
|
||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
||||
* Handle extended status bar on **iOS**
|
||||
* Plugin uses `Android Log class` and not `Cordova LOG class`
|
||||
* [CB-11287](https://issues.apache.org/jira/browse/CB-11287) (**ios**) - fix webview resize after modal on **iPhones**
|
||||
* [CB-11485](https://issues.apache.org/jira/browse/CB-11485) fix resize on rotation with popover
|
||||
* Add badges for paramedic builds on Jenkins
|
||||
* [CB-11197](https://issues.apache.org/jira/browse/CB-11197) Keep status bar hidden when keyboard pops up
|
||||
* Add pull request template.
|
||||
* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine info to `package.json`
|
||||
* patched missing `_ready` method, and changed the way the proxy is installed
|
||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to `README.md`
|
||||
|
||||
### 2.1.3 (Apr 15, 2016)
|
||||
* [CB-11018](https://issues.apache.org/jira/browse/CB-11018) Fix statusbar with `inappbrowser` causing incorrect orientation on **iOS8**
|
||||
* [CB-10884](https://issues.apache.org/jira/browse/CB-10884) `Inappbrowser` breaks UI while Screen orientation changes from landscape to portrait on **iOS**
|
||||
|
||||
### 2.1.2 (Mar 09, 2016)
|
||||
* [CB-10752](https://issues.apache.org/jira/browse/CB-10752) for for status bar overlays the webview on **iOS** 6 in some cases
|
||||
* [CB-10683](https://issues.apache.org/jira/browse/CB-10683) Fix wrong StatusBar.isVisible initial value on **Windows**
|
||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins
|
||||
* [CB-10047](https://issues.apache.org/jira/browse/CB-10047) fix **iOS** 8 deprecated warnings
|
||||
|
||||
### 2.1.1 (Feb 09, 2016)
|
||||
* [CB-10102](https://issues.apache.org/jira/browse/CB-10102) The removeObserver code was wrong and it might crash on plugin deallocation
|
||||
|
||||
### 2.1.0 (Jan 15, 2016)
|
||||
* [CB-9513](https://issues.apache.org/jira/browse/CB-9513) Allow to show/hide status bar in fullscreen mode.
|
||||
* [CB-8720](https://issues.apache.org/jira/browse/CB-8720) Fix status bar position when app started upside down on **iOS 7**.
|
||||
* [CB-10118](https://issues.apache.org/jira/browse/CB-10118) Fixes plugin loading error for **Browser** platform
|
||||
|
||||
### 2.0.0 (Nov 18, 2015)
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
||||
* Added `weakSelf` reference for block use
|
||||
* Fixes [CB-4712](https://issues.apache.org/jira/browse/CB-4712), [CB-5439](https://issues.apache.org/jira/browse/CB-5439) statusbar issues
|
||||
* Fixing contribute link.
|
||||
* [CB-7965](https://issues.apache.org/jira/browse/CB-7965) Add cordova-plugin-statusbar support for **Browser** platform
|
||||
* Don't use `IsAtLeastiOSVersion` macro to determine height
|
||||
* Use correct statusbar height for landscape orientation in iOS >= 8
|
||||
* remove travis-ci
|
||||
* [CB-9202](https://issues.apache.org/jira/browse/CB-9202) updated repo url to github mirror in package.json
|
||||
* Added verbose install text for users on < cordova 5.0
|
||||
* update docs for `StatusBarBackgroundColor`
|
||||
|
||||
### 1.0.1 (Jun 17, 2015)
|
||||
* add auto-tests for basic api
|
||||
* [CB-9180](https://issues.apache.org/jira/browse/CB-9180) Add correct supported check for **Windows 8.1** desktop
|
||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-statusbar documentation translation: cordova-plugin-statusbar
|
||||
* fix npm md issue
|
||||
|
||||
### 1.0.0 (Apr 15, 2015)
|
||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
||||
* - Use StatusBarBackgroundColor instead of AndroidStatusBarBackgroundColor, and added a quirk to the readme.
|
||||
* - Add support for StatusBar.backgroundColorByHexString (and StatusBar.backgroundColorByName) on Android 5 and up
|
||||
* Allow setting the statusbar backgroundcolor on Android
|
||||
* [CB-8575](https://issues.apache.org/jira/browse/CB-8575) Integrate TravisCI
|
||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-statusbar documentation translation: cordova-plugin-statusbar
|
||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
||||
|
||||
### 0.1.10 (Feb 04, 2015)
|
||||
* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension
|
||||
|
||||
### 0.1.9 (Dec 02, 2014)
|
||||
* Fix onload attribute within <feature> to be a <param>
|
||||
* [CB-8010](https://issues.apache.org/jira/browse/CB-8010) - Statusbar colour does not change to orange
|
||||
* added checks for running on windows when StatusBar is NOT available
|
||||
* [CB-7986](https://issues.apache.org/jira/browse/CB-7986) Add cordova-plugin-statusbar support for **Windows Phone 8.1**
|
||||
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
|
||||
* [CB-7979](https://issues.apache.org/jira/browse/CB-7979) Each plugin doc should have a ## Installation section
|
||||
* Inserting leading space after # for consistency
|
||||
* [CB-7549](https://issues.apache.org/jira/browse/CB-7549) - (Re-fix) `StatusBar` **iOS 8** Landscape issue (closes #15)
|
||||
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-statusbar documentation translation: cordova-plugin-statusbar
|
||||
* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin
|
||||
|
||||
### 0.1.8 (Sep 17, 2014)
|
||||
* [CB-7549](https://issues.apache.org/jira/browse/CB-7549) [StatusBar][iOS 8] Landscape issue
|
||||
* [CB-7486](https://issues.apache.org/jira/browse/CB-7486) Remove StatusBarBackgroundColor intial preference (black background) so background will be initially transparent
|
||||
* Renamed test dir, added nested plugin.xml
|
||||
* added documentation for manual tests, moved background color test below overlay test
|
||||
* [CB-7195](https://issues.apache.org/jira/browse/CB-7195) ported statusbar tests to framework
|
||||
|
||||
### 0.1.7 (Aug 06, 2014)
|
||||
* Add LICENSE and NOTICE
|
||||
* Update statusbar.js
|
||||
* Update backgroundColorByHexString function
|
||||
* ios: Use a persistent callbackId instead of calling sendJs
|
||||
* [CB-6626](https://issues.apache.org/jira/browse/CB-6626) ios: Add a JS event for tapping on statusbar
|
||||
* ios: Fix hide to adjust webview's frame only when status bar is not overlaying webview
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
||||
* android: Fix StatusBar.initialize() not running on UI thread
|
||||
|
||||
### 0.1.6 (Jun 05, 2014)
|
||||
* [CB-6783](https://issues.apache.org/jira/browse/CB-6783) - added StatusBarStyle config preference, updated docs (closes #9)
|
||||
* [CB-6812](https://issues.apache.org/jira/browse/CB-6812) Add license
|
||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
||||
* [CB-6264](https://issues.apache.org/jira/browse/CB-6264) minor formatting issue
|
||||
* Update docs with recent WP changes, remove 'clear' from the loist of named colors in documentation
|
||||
* [CB-6513](https://issues.apache.org/jira/browse/CB-6513) - Statusbar plugin for Android is not compiling
|
||||
|
||||
### 0.1.5 (Apr 17, 2014) (First release as a core Cordova Plugin)
|
||||
* [CB-6316](https://issues.apache.org/jira/browse/CB-6316): Added README.md which point to the new location for docs
|
||||
* [CB-6316](https://issues.apache.org/jira/browse/CB-6316): Added license header to the documentation. Added README.md which point to the new location for docs
|
||||
* [CB-6316](https://issues.apache.org/jira/browse/CB-6316): Moved StatusBar plugin documentation to docs folder
|
||||
* [CB-6314](https://issues.apache.org/jira/browse/CB-6314): [android] Add StatusBar.isVisible support to Android
|
||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
||||
48
package.json
48
package.json
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"name": "cordova-plugin-statusbar",
|
||||
"version": "2.4.4-dev",
|
||||
"description": "Cordova StatusBar Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-statusbar",
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios",
|
||||
"windows"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-statusbar"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/cordova-plugin-statusbar/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"statusbar",
|
||||
"ecosystem:cordova",
|
||||
"cordova-android",
|
||||
"cordova-ios",
|
||||
"cordova-windows"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run jshint",
|
||||
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
|
||||
},
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
"0.1.0": {
|
||||
"cordova": ">=3.0.0"
|
||||
},
|
||||
"3.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
},
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.6.0"
|
||||
}
|
||||
}
|
||||
74
plugin.xml
74
plugin.xml
@@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-statusbar"
|
||||
version="2.4.4-dev">
|
||||
<name>StatusBar</name>
|
||||
<description>Cordova StatusBar Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
<keywords>cordova,statusbar</keywords>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0.0" />
|
||||
</engines>
|
||||
|
||||
<js-module src="www/statusbar.js" name="statusbar">
|
||||
<clobbers target="window.StatusBar" />
|
||||
</js-module>
|
||||
|
||||
<platform name="android">
|
||||
<source-file src="src/android/StatusBar.java" target-dir="src/org/apache/cordova/statusbar" />
|
||||
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="StatusBar">
|
||||
<param name="android-package" value="org.apache.cordova.statusbar.StatusBar" />
|
||||
<param name="onload" value="true" />
|
||||
</feature>
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
<platform name="browser">
|
||||
<js-module src="src/browser/StatusBarProxy.js" name="StatusBarProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
<platform name="ios">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="StatusBar">
|
||||
<param name="ios-package" value="CDVStatusBar" />
|
||||
<param name="onload" value="true" />
|
||||
</feature>
|
||||
<preference name="StatusBarOverlaysWebView" value="true" />
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
</config-file>
|
||||
|
||||
<header-file src="src/ios/CDVStatusBar.h" />
|
||||
<source-file src="src/ios/CDVStatusBar.m" />
|
||||
</platform>
|
||||
|
||||
<platform name="windows">
|
||||
<js-module src="src/windows/StatusBarProxy.js" name="StatusBarProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
</plugin>
|
||||
@@ -1,292 +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.
|
||||
*
|
||||
*/
|
||||
package org.apache.cordova.statusbar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaArgs;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.LOG;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StatusBar extends CordovaPlugin {
|
||||
private static final String TAG = "StatusBar";
|
||||
|
||||
/**
|
||||
* Sets the context of the Command. This can then be used to do things like
|
||||
* get file paths associated with the Activity.
|
||||
*
|
||||
* @param cordova The context of the main Activity.
|
||||
* @param webView The CordovaWebView Cordova is running in.
|
||||
*/
|
||||
@Override
|
||||
public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
|
||||
LOG.v(TAG, "StatusBar: initialization");
|
||||
super.initialize(cordova, webView);
|
||||
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
|
||||
// by the Cordova.
|
||||
Window window = cordova.getActivity().getWindow();
|
||||
// 添加的内容开始
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
// window.addFlags(WindowManager.LayoutParams
|
||||
// .FLAG_TRANSLUCENT_NAVIGATION);
|
||||
window.addFlags(WindowManager.LayoutParams
|
||||
.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
// window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||
// 添加的内容结束
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
|
||||
// Read 'StatusBarBackgroundColor' from config.xml, default is #000000.
|
||||
setStatusBarBackgroundColor(preferences.getString("StatusBarBackgroundColor", "#000000"));
|
||||
|
||||
// Read 'StatusBarStyle' from config.xml, default is 'lightcontent'.
|
||||
setStatusBarStyle(preferences.getString("StatusBarStyle", "lightcontent"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||
* @return True if the action was valid, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
|
||||
LOG.v(TAG, "Executing action: " + action);
|
||||
final Activity activity = this.cordova.getActivity();
|
||||
final Window window = activity.getWindow();
|
||||
|
||||
if ("_ready".equals(action)) {
|
||||
boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
|
||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("show".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
|
||||
// use KitKat here to be aligned with "Fullscreen" preference
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
int uiOptions = window.getDecorView().getSystemUiVisibility();
|
||||
uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||
uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
|
||||
// CB-11197 We still need to update LayoutParams to force status bar
|
||||
// to be hidden when entering e.g. text fields
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("hide".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
|
||||
// use KitKat here to be aligned with "Fullscreen" preference
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
int uiOptions = window.getDecorView().getSystemUiVisibility()
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
|
||||
// CB-11197 We still need to update LayoutParams to force status bar
|
||||
// to be hidden when entering e.g. text fields
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("backgroundColorByHexString".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setStatusBarBackgroundColor(args.getString(0));
|
||||
} catch (JSONException ignore) {
|
||||
LOG.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("overlaysWebView".equals(action)) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setStatusBarTransparent(args.getBoolean(0));
|
||||
} catch (JSONException ignore) {
|
||||
LOG.e(TAG, "Invalid boolean argument");
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else return args.getBoolean(0) == false;
|
||||
}
|
||||
|
||||
if ("styleDefault".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setStatusBarStyle("default");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("styleLightContent".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setStatusBarStyle("lightcontent");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("styleBlackTranslucent".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setStatusBarStyle("blacktranslucent");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("styleBlackOpaque".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setStatusBarStyle("blackopaque");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setStatusBarBackgroundColor(final String colorPref) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
if (colorPref != null && !colorPref.isEmpty()) {
|
||||
final Window window = cordova.getActivity().getWindow();
|
||||
// Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
|
||||
window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
try {
|
||||
// Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
|
||||
window.getClass().getMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref));
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
LOG.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
|
||||
} catch (Exception ignore) {
|
||||
// this should not happen, only in case Android removes this method in a version > 21
|
||||
LOG.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setStatusBarTransparent(final boolean transparent) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
final Window window = cordova.getActivity().getWindow();
|
||||
if (transparent) {
|
||||
// cordova.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
else {
|
||||
// cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setStatusBarStyle(final String style) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (style != null && !style.isEmpty()) {
|
||||
View decorView = cordova.getActivity().getWindow().getDecorView();
|
||||
int uiOptions = decorView.getSystemUiVisibility();
|
||||
|
||||
String[] darkContentStyles = {
|
||||
"default",
|
||||
};
|
||||
|
||||
String[] lightContentStyles = {
|
||||
"lightcontent",
|
||||
"blacktranslucent",
|
||||
"blackopaque",
|
||||
};
|
||||
|
||||
if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
|
||||
decorView.setSystemUiVisibility(uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
|
||||
decorView.setSystemUiVisibility(uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.e(TAG, "Invalid style, must be either 'default', 'lightcontent' or the deprecated 'blacktranslucent' and 'blackopaque'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
function notSupported(win,fail) {
|
||||
//
|
||||
console.log('StatusBar is not supported');
|
||||
setTimeout(function(){
|
||||
if (win) {
|
||||
win();
|
||||
}
|
||||
// note that while it is not explicitly supported, it does not fail
|
||||
// this is really just here to allow developers to test their code in the browser
|
||||
// and if we fail, then their app might as well. -jm
|
||||
},0);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isVisible: false,
|
||||
styleBlackTranslucent:notSupported,
|
||||
styleDefault:notSupported,
|
||||
styleLightContent:notSupported,
|
||||
styleBlackOpaque:notSupported,
|
||||
overlaysWebView:notSupported,
|
||||
styleLightContect: notSupported,
|
||||
backgroundColorByName: notSupported,
|
||||
backgroundColorByHexString: notSupported,
|
||||
hide: notSupported,
|
||||
show: notSupported,
|
||||
_ready:notSupported
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("StatusBar", module.exports);
|
||||
|
||||
@@ -1,50 +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.
|
||||
*/
|
||||
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
#import <Cordova/CDVInvokedUrlCommand.h>
|
||||
|
||||
@interface CDVStatusBar : CDVPlugin {
|
||||
@protected
|
||||
BOOL _statusBarOverlaysWebView;
|
||||
UIView* _statusBarBackgroundView;
|
||||
BOOL _uiviewControllerBasedStatusBarAppearance;
|
||||
UIColor* _statusBarBackgroundColor;
|
||||
NSString* _eventsCallbackId;
|
||||
}
|
||||
|
||||
@property (atomic, assign) BOOL statusBarOverlaysWebView;
|
||||
@property (atomic, assign) BOOL statusBarVisible;
|
||||
|
||||
- (void) overlaysWebView:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void) styleDefault:(CDVInvokedUrlCommand*)command;
|
||||
- (void) styleLightContent:(CDVInvokedUrlCommand*)command;
|
||||
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command;
|
||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command;
|
||||
- (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void) hide:(CDVInvokedUrlCommand*)command;
|
||||
- (void) show:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void) _ready:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
@@ -1,483 +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.
|
||||
*/
|
||||
|
||||
/*
|
||||
NOTE: plugman/cordova cli should have already installed this,
|
||||
but you need the value UIViewControllerBasedStatusBarAppearance
|
||||
in your Info.plist as well to set the styles in iOS 7
|
||||
*/
|
||||
|
||||
#import "CDVStatusBar.h"
|
||||
#import <objc/runtime.h>
|
||||
#import <Cordova/CDVViewController.h>
|
||||
|
||||
static const void *kHideStatusBar = &kHideStatusBar;
|
||||
static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
@interface CDVViewController (StatusBar)
|
||||
|
||||
@property (nonatomic, retain) id sb_hideStatusBar;
|
||||
@property (nonatomic, retain) id sb_statusBarStyle;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CDVViewController (StatusBar)
|
||||
|
||||
@dynamic sb_hideStatusBar;
|
||||
@dynamic sb_statusBarStyle;
|
||||
|
||||
- (id)sb_hideStatusBar {
|
||||
return objc_getAssociatedObject(self, kHideStatusBar);
|
||||
}
|
||||
|
||||
- (void)setSb_hideStatusBar:(id)newHideStatusBar {
|
||||
objc_setAssociatedObject(self, kHideStatusBar, newHideStatusBar, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (id)sb_statusBarStyle {
|
||||
return objc_getAssociatedObject(self, kStatusBarStyle);
|
||||
}
|
||||
|
||||
- (void)setSb_statusBarStyle:(id)newStatusBarStyle {
|
||||
objc_setAssociatedObject(self, kStatusBarStyle, newStatusBarStyle, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (BOOL) prefersStatusBarHidden {
|
||||
return [self.sb_hideStatusBar boolValue];
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
return (UIStatusBarStyle)[self.sb_statusBarStyle intValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface CDVStatusBar () <UIScrollViewDelegate>
|
||||
- (void)fireTappedEvent;
|
||||
- (void)updateIsVisible:(BOOL)visible;
|
||||
@end
|
||||
|
||||
@implementation CDVStatusBar
|
||||
|
||||
- (id)settingForKey:(NSString*)key
|
||||
{
|
||||
return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
|
||||
{
|
||||
if ([keyPath isEqual:@"statusBarHidden"]) {
|
||||
NSNumber* newValue = [change objectForKey:NSKeyValueChangeNewKey];
|
||||
[self updateIsVisible:![newValue boolValue]];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)cordovaViewWillAppear:(NSNotification*)notification
|
||||
{
|
||||
//add a small delay ( 0.1 seconds ) or statusbar size will be wrong
|
||||
__weak CDVStatusBar* weakSelf = self;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||
[weakSelf resizeWebView];
|
||||
});
|
||||
}
|
||||
|
||||
-(void)statusBarDidChangeFrame:(NSNotification*)notification
|
||||
{
|
||||
//add a small delay ( 0.1 seconds ) or statusbar size will be wrong
|
||||
__weak CDVStatusBar* weakSelf = self;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||
[weakSelf resizeStatusBarBackgroundView];
|
||||
[weakSelf resizeWebView];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
// init
|
||||
NSNumber* uiviewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
|
||||
_uiviewControllerBasedStatusBarAppearance = (uiviewControllerBasedStatusBarAppearance == nil || [uiviewControllerBasedStatusBarAppearance boolValue]);
|
||||
|
||||
// observe the statusBarHidden property
|
||||
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew context:NULL];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarDidChangeFrame:) name: UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cordovaViewWillAppear:) name: @"CDVViewWillAppearNotification" object:nil];
|
||||
|
||||
_statusBarOverlaysWebView = YES; // default
|
||||
|
||||
[self initializeStatusBarBackgroundView];
|
||||
|
||||
self.viewController.view.autoresizesSubviews = YES;
|
||||
|
||||
NSString* setting;
|
||||
|
||||
setting = @"StatusBarBackgroundColor";
|
||||
if ([self settingForKey:setting]) {
|
||||
[self _backgroundColorByHexString:[self settingForKey:setting]];
|
||||
}
|
||||
|
||||
setting = @"StatusBarStyle";
|
||||
if ([self settingForKey:setting]) {
|
||||
[self setStatusBarStyle:[self settingForKey:setting]];
|
||||
}
|
||||
|
||||
setting = @"StatusBarDefaultScrollToTop";
|
||||
if ([self settingForKey:setting]) {
|
||||
self.webView.scrollView.scrollsToTop = [(NSNumber*)[self settingForKey:setting] boolValue];
|
||||
} else {
|
||||
self.webView.scrollView.scrollsToTop = NO;
|
||||
}
|
||||
|
||||
// blank scroll view to intercept status bar taps
|
||||
UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
||||
fakeScrollView.delegate = self;
|
||||
fakeScrollView.scrollsToTop = YES;
|
||||
[self.viewController.view addSubview:fakeScrollView]; // Add scrollview to the view heirarchy so that it will begin accepting status bar taps
|
||||
[self.viewController.view sendSubviewToBack:fakeScrollView]; // Send it to the very back of the view heirarchy
|
||||
fakeScrollView.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height * 2.0f); // Make the scroll view longer than the screen itself
|
||||
fakeScrollView.contentOffset = CGPointMake(0.0f, UIScreen.mainScreen.bounds.size.height); // Scroll down so a tap will take scroll view back to the top
|
||||
|
||||
_statusBarVisible = ![UIApplication sharedApplication].isStatusBarHidden;
|
||||
}
|
||||
|
||||
- (void)onReset {
|
||||
_eventsCallbackId = nil;
|
||||
}
|
||||
|
||||
- (void)fireTappedEvent {
|
||||
if (_eventsCallbackId == nil) {
|
||||
return;
|
||||
}
|
||||
NSDictionary* payload = @{@"type": @"tap"};
|
||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:payload];
|
||||
[result setKeepCallbackAsBool:YES];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:_eventsCallbackId];
|
||||
}
|
||||
|
||||
- (void)updateIsVisible:(BOOL)visible {
|
||||
if (_eventsCallbackId == nil) {
|
||||
return;
|
||||
}
|
||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:visible];
|
||||
[result setKeepCallbackAsBool:YES];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:_eventsCallbackId];
|
||||
}
|
||||
|
||||
- (void) _ready:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
_eventsCallbackId = command.callbackId;
|
||||
[self updateIsVisible:![UIApplication sharedApplication].statusBarHidden];
|
||||
NSString* setting = @"StatusBarOverlaysWebView";
|
||||
if ([self settingForKey:setting]) {
|
||||
self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue];
|
||||
if (self.statusBarOverlaysWebView) {
|
||||
[self resizeWebView];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) initializeStatusBarBackgroundView
|
||||
{
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
if ([[UIApplication sharedApplication]statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown &&
|
||||
statusBarFrame.size.height + statusBarFrame.origin.y == [self.viewController.view.window bounds].size.height) {
|
||||
|
||||
// When started in upside-down orientation on iOS 7, status bar will be bound to lower edge of the
|
||||
// screen (statusBarFrame.origin.y will be somewhere around screen height). In this case we need to
|
||||
// correct frame's coordinates
|
||||
statusBarFrame.origin.y = 0;
|
||||
}
|
||||
|
||||
_statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
|
||||
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
||||
_statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
|
||||
_statusBarBackgroundView.autoresizesSubviews = YES;
|
||||
}
|
||||
|
||||
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
||||
{
|
||||
// we only care about the latest iOS version or a change in setting
|
||||
if (statusBarOverlaysWebView == _statusBarOverlaysWebView) {
|
||||
return;
|
||||
}
|
||||
|
||||
_statusBarOverlaysWebView = statusBarOverlaysWebView;
|
||||
|
||||
[self resizeWebView];
|
||||
|
||||
if (statusBarOverlaysWebView) {
|
||||
|
||||
[_statusBarBackgroundView removeFromSuperview];
|
||||
|
||||
} else {
|
||||
|
||||
[self initializeStatusBarBackgroundView];
|
||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (BOOL) statusBarOverlaysWebView
|
||||
{
|
||||
return _statusBarOverlaysWebView;
|
||||
}
|
||||
|
||||
- (void) overlaysWebView:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
id value = [command argumentAtIndex:0];
|
||||
if (!([value isKindOfClass:[NSNumber class]])) {
|
||||
value = [NSNumber numberWithBool:YES];
|
||||
}
|
||||
|
||||
self.statusBarOverlaysWebView = [value boolValue];
|
||||
}
|
||||
|
||||
- (void) refreshStatusBarAppearance
|
||||
{
|
||||
SEL sel = NSSelectorFromString(@"setNeedsStatusBarAppearanceUpdate");
|
||||
if ([self.viewController respondsToSelector:sel]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
[self.viewController performSelector:sel withObject:nil];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setStyleForStatusBar:(UIStatusBarStyle)style
|
||||
{
|
||||
if (_uiviewControllerBasedStatusBarAppearance) {
|
||||
CDVViewController* vc = (CDVViewController*)self.viewController;
|
||||
vc.sb_statusBarStyle = [NSNumber numberWithInt:style];
|
||||
[self refreshStatusBarAppearance];
|
||||
|
||||
} else {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:style];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setStatusBarStyle:(NSString*)statusBarStyle
|
||||
{
|
||||
// default, lightContent, blackTranslucent, blackOpaque
|
||||
NSString* lcStatusBarStyle = [statusBarStyle lowercaseString];
|
||||
|
||||
if ([lcStatusBarStyle isEqualToString:@"default"]) {
|
||||
[self styleDefault:nil];
|
||||
} else if ([lcStatusBarStyle isEqualToString:@"lightcontent"]) {
|
||||
[self styleLightContent:nil];
|
||||
} else if ([lcStatusBarStyle isEqualToString:@"blacktranslucent"]) {
|
||||
[self styleBlackTranslucent:nil];
|
||||
} else if ([lcStatusBarStyle isEqualToString:@"blackopaque"]) {
|
||||
[self styleBlackOpaque:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) styleDefault:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setStyleForStatusBar:UIStatusBarStyleDefault];
|
||||
}
|
||||
|
||||
- (void) styleLightContent:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
id value = [command argumentAtIndex:0];
|
||||
if (!([value isKindOfClass:[NSString class]])) {
|
||||
value = @"black";
|
||||
}
|
||||
|
||||
SEL selector = NSSelectorFromString([value stringByAppendingString:@"Color"]);
|
||||
if ([UIColor respondsToSelector:selector]) {
|
||||
_statusBarBackgroundView.backgroundColor = [UIColor performSelector:selector];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _backgroundColorByHexString:(NSString*)hexString
|
||||
{
|
||||
unsigned int rgbValue = 0;
|
||||
NSScanner* scanner = [NSScanner scannerWithString:hexString];
|
||||
[scanner setScanLocation:1];
|
||||
[scanner scanHexInt:&rgbValue];
|
||||
|
||||
_statusBarBackgroundColor = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
|
||||
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
||||
}
|
||||
|
||||
- (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString* value = [command argumentAtIndex:0];
|
||||
if (!([value isKindOfClass:[NSString class]])) {
|
||||
value = @"#000000";
|
||||
}
|
||||
|
||||
if (![value hasPrefix:@"#"] || [value length] < 7) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self _backgroundColorByHexString:value];
|
||||
}
|
||||
|
||||
- (void) hideStatusBar
|
||||
{
|
||||
if (_uiviewControllerBasedStatusBarAppearance) {
|
||||
CDVViewController* vc = (CDVViewController*)self.viewController;
|
||||
vc.sb_hideStatusBar = [NSNumber numberWithBool:YES];
|
||||
[self refreshStatusBarAppearance];
|
||||
|
||||
} else {
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
[app setStatusBarHidden:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) hide:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
_statusBarVisible = NO;
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
|
||||
if (!app.isStatusBarHidden)
|
||||
{
|
||||
|
||||
[self hideStatusBar];
|
||||
|
||||
[_statusBarBackgroundView removeFromSuperview];
|
||||
|
||||
[self resizeWebView];
|
||||
|
||||
_statusBarBackgroundView.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) showStatusBar
|
||||
{
|
||||
if (_uiviewControllerBasedStatusBarAppearance) {
|
||||
CDVViewController* vc = (CDVViewController*)self.viewController;
|
||||
vc.sb_hideStatusBar = [NSNumber numberWithBool:NO];
|
||||
[self refreshStatusBarAppearance];
|
||||
|
||||
} else {
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
[app setStatusBarHidden:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) show:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
_statusBarVisible = YES;
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
|
||||
if (app.isStatusBarHidden)
|
||||
{
|
||||
[self showStatusBar];
|
||||
[self resizeWebView];
|
||||
|
||||
if (!self.statusBarOverlaysWebView) {
|
||||
|
||||
// there is a possibility that when the statusbar was hidden, it was in a different orientation
|
||||
// from the current one. Therefore we need to expand the statusBarBackgroundView as well to the
|
||||
// statusBar's current size
|
||||
[self resizeStatusBarBackgroundView];
|
||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||
|
||||
}
|
||||
|
||||
_statusBarBackgroundView.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)resizeStatusBarBackgroundView {
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
CGRect sbBgFrame = _statusBarBackgroundView.frame;
|
||||
sbBgFrame.size = statusBarFrame.size;
|
||||
_statusBarBackgroundView.frame = sbBgFrame;
|
||||
}
|
||||
|
||||
-(void)resizeWebView
|
||||
{
|
||||
BOOL isIOS11 = (IsAtLeastiOSVersion(@"11.0"));
|
||||
|
||||
CGRect bounds = [self.viewController.view.window bounds];
|
||||
if (CGRectEqualToRect(bounds, CGRectZero)) {
|
||||
bounds = [[UIScreen mainScreen] bounds];
|
||||
}
|
||||
|
||||
self.viewController.view.frame = bounds;
|
||||
|
||||
self.webView.frame = bounds;
|
||||
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
CGRect frame = self.webView.frame;
|
||||
CGFloat height = statusBarFrame.size.height;
|
||||
|
||||
if (!self.statusBarOverlaysWebView) {
|
||||
frame.origin.y = height;
|
||||
} else {
|
||||
frame.origin.y = height >= 20 ? height - 20 : 0;
|
||||
if (isIOS11) {
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(iOS 11.0, *)) {
|
||||
float safeAreaTop = self.webView.safeAreaInsets.top;
|
||||
if (height >= safeAreaTop && safeAreaTop >0) {
|
||||
// Sometimes when in-call/recording/hotspot larger status bar is present, the safeAreaTop is 40 but we want frame.origin.y to be 20
|
||||
frame.origin.y = safeAreaTop == 40 ? 20 : height - safeAreaTop;
|
||||
} else {
|
||||
frame.origin.y = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
frame.size.height -= frame.origin.y;
|
||||
self.webView.frame = frame;
|
||||
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[UIApplication sharedApplication] removeObserver:self forKeyPath:@"statusBarHidden"];
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UIScrollViewDelegate
|
||||
|
||||
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
|
||||
{
|
||||
[self fireTappedEvent];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,114 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* global Windows */
|
||||
|
||||
var _supported = null; // set to null so we can check first time
|
||||
|
||||
function isSupported() {
|
||||
// if not checked before, run check
|
||||
if (_supported === null) {
|
||||
var viewMan = Windows.UI.ViewManagement;
|
||||
_supported = (viewMan.StatusBar && viewMan.StatusBar.getForCurrentView);
|
||||
}
|
||||
return _supported;
|
||||
}
|
||||
|
||||
function getViewStatusBar() {
|
||||
if (!isSupported()) {
|
||||
throw new Error("Status bar is not supported");
|
||||
}
|
||||
return Windows.UI.ViewManagement.StatusBar.getForCurrentView();
|
||||
}
|
||||
|
||||
function hexToRgb(hex) {
|
||||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
||||
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
||||
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
|
||||
return r + r + g + g + b + b;
|
||||
});
|
||||
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
_ready: function(win, fail) {
|
||||
if(isSupported()) {
|
||||
var statusBar = getViewStatusBar();
|
||||
win(statusBar.occludedRect.height !== 0);
|
||||
}
|
||||
},
|
||||
overlaysWebView: function () {
|
||||
// not supported
|
||||
},
|
||||
|
||||
styleDefault: function () {
|
||||
// dark text ( to be used on a light background )
|
||||
if (isSupported()) {
|
||||
getViewStatusBar().foregroundColor = { a: 0, r: 0, g: 0, b: 0 };
|
||||
}
|
||||
},
|
||||
|
||||
styleLightContent: function () {
|
||||
// light text ( to be used on a dark background )
|
||||
if (isSupported()) {
|
||||
getViewStatusBar().foregroundColor = { a: 0, r: 255, g: 255, b: 255 };
|
||||
}
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
return module.exports.styleLightContent();
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
return module.exports.styleLightContent();
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (win, fail, args) {
|
||||
var rgb = hexToRgb(args[0]);
|
||||
if(isSupported()) {
|
||||
var statusBar = getViewStatusBar();
|
||||
statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
|
||||
statusBar.backgroundOpacity = 1;
|
||||
}
|
||||
},
|
||||
|
||||
show: function (win, fail) {
|
||||
// added support check so no error thrown, when calling this method
|
||||
if (isSupported()) {
|
||||
getViewStatusBar().showAsync().done(win, fail);
|
||||
}
|
||||
},
|
||||
|
||||
hide: function (win, fail) {
|
||||
// added support check so no error thrown, when calling this method
|
||||
if (isSupported()) {
|
||||
getViewStatusBar().hideAsync().done(win, fail);
|
||||
}
|
||||
}
|
||||
};
|
||||
require("cordova/exec/proxy").add("StatusBar", module.exports);
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "cordova-plugin-statusbar-tests",
|
||||
"version": "2.4.4-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-statusbar-tests",
|
||||
"platforms": []
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:cordova"
|
||||
],
|
||||
"author": "",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-statusbar-tests"
|
||||
version="2.4.4-dev">
|
||||
<name>Cordova StatusBar Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
<js-module src="tests.js" name="tests">
|
||||
</js-module>
|
||||
</plugin>
|
||||
151
tests/tests.js
151
tests/tests.js
@@ -1,151 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint jasmine: true */
|
||||
/* global StatusBar */
|
||||
|
||||
exports.defineAutoTests = function () {
|
||||
describe("StatusBar", function () {
|
||||
it("statusbar.spec.1 should exist", function() {
|
||||
expect(window.StatusBar).toBeDefined();
|
||||
});
|
||||
|
||||
it("statusbar.spec.2 should have show|hide methods", function() {
|
||||
expect(window.StatusBar.show).toBeDefined();
|
||||
expect(typeof window.StatusBar.show).toBe("function");
|
||||
|
||||
expect(window.StatusBar.hide).toBeDefined();
|
||||
expect(typeof window.StatusBar.hide).toBe("function");
|
||||
});
|
||||
|
||||
it("statusbar.spec.3 should have set backgroundColor methods", function() {
|
||||
expect(window.StatusBar.backgroundColorByName).toBeDefined();
|
||||
expect(typeof window.StatusBar.backgroundColorByName).toBe("function");
|
||||
|
||||
expect(window.StatusBar.backgroundColorByHexString).toBeDefined();
|
||||
expect(typeof window.StatusBar.backgroundColorByHexString).toBe("function");
|
||||
});
|
||||
|
||||
it("statusbar.spec.4 should have set style methods", function() {
|
||||
expect(window.StatusBar.styleBlackTranslucent).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleBlackTranslucent).toBe("function");
|
||||
|
||||
expect(window.StatusBar.styleDefault).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleDefault).toBe("function");
|
||||
|
||||
expect(window.StatusBar.styleLightContent).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleLightContent).toBe("function");
|
||||
|
||||
expect(window.StatusBar.styleBlackOpaque).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleBlackOpaque).toBe("function");
|
||||
|
||||
expect(window.StatusBar.overlaysWebView).toBeDefined();
|
||||
expect(typeof window.StatusBar.overlaysWebView).toBe("function");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
function log(msg) {
|
||||
var el = document.getElementById("info");
|
||||
var logLine = document.createElement('div');
|
||||
logLine.innerHTML = msg;
|
||||
el.appendChild(logLine);
|
||||
}
|
||||
|
||||
function doShow() {
|
||||
StatusBar.show();
|
||||
log('StatusBar.isVisible=' + StatusBar.isVisible);
|
||||
}
|
||||
|
||||
function doHide() {
|
||||
StatusBar.hide();
|
||||
log('StatusBar.isVisible=' + StatusBar.isVisible);
|
||||
}
|
||||
|
||||
function doColor1() {
|
||||
log('set color=red');
|
||||
StatusBar.backgroundColorByName('red');
|
||||
}
|
||||
|
||||
function doColor2() {
|
||||
log('set style=translucent black');
|
||||
StatusBar.styleBlackTranslucent();
|
||||
}
|
||||
|
||||
function doColor3() {
|
||||
log('set style=default');
|
||||
StatusBar.styleDefault();
|
||||
}
|
||||
|
||||
var showOverlay = true;
|
||||
function doOverlay() {
|
||||
showOverlay = !showOverlay;
|
||||
StatusBar.overlaysWebView(showOverlay);
|
||||
log('Set overlay=' + showOverlay);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
contentEl.innerHTML = '<div id="info"></div>' +
|
||||
'Also: tapping bar on iOS should emit a log.' +
|
||||
'<div id="action-show"></div>' +
|
||||
'Expected result: Status bar will be visible' +
|
||||
'</p> <div id="action-hide"></div>' +
|
||||
'Expected result: Status bar will be hidden' +
|
||||
'</p> <div id="action-color2"></div>' +
|
||||
'Expected result: Status bar text will be a light (white) color' +
|
||||
'</p> <div id="action-color3"></div>' +
|
||||
'Expected result: Status bar text will be a dark (black) color' +
|
||||
'</p> <div id="action-overlays"></div>' +
|
||||
'Expected result:<br>Overlay true = status bar will lay on top of web view content<br>Overlay false = status bar will be separate from web view and will not cover content' +
|
||||
'</p> <div id="action-color1"></div>' +
|
||||
'Expected result: If overlay false, background color for status bar will be red';
|
||||
|
||||
log('StatusBar.isVisible=' + StatusBar.isVisible);
|
||||
window.addEventListener('statusTap', function () {
|
||||
log('tap!');
|
||||
}, false);
|
||||
|
||||
createActionButton("Show", function () {
|
||||
doShow();
|
||||
}, 'action-show');
|
||||
|
||||
createActionButton("Hide", function () {
|
||||
doHide();
|
||||
}, 'action-hide');
|
||||
|
||||
createActionButton("Style=red (background)", function () {
|
||||
doColor1();
|
||||
}, 'action-color1');
|
||||
|
||||
createActionButton("Style=translucent black", function () {
|
||||
doColor2();
|
||||
}, 'action-color2');
|
||||
|
||||
createActionButton("Style=default", function () {
|
||||
doColor3();
|
||||
}, 'action-color3');
|
||||
|
||||
createActionButton("Toggle Overlays", function () {
|
||||
doOverlay();
|
||||
}, 'action-overlays');
|
||||
};
|
||||
81
types/index.d.ts
vendored
81
types/index.d.ts
vendored
@@ -1,81 +0,0 @@
|
||||
// Type definitions for cordova-plugin-statusbar
|
||||
// Project: https://github.com/apache/cordova-plugin-statusbar
|
||||
// Definitions by: Xinkai Chen <https://github.com/Xinkai>
|
||||
// Tim Brust <https://github.com/timbru31>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Global object StatusBar.
|
||||
*/
|
||||
interface Window {
|
||||
StatusBar: StatusBar;
|
||||
addEventListener(type: "statusTap", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The StatusBar object provides some functions to customize the iOS and Android StatusBar.
|
||||
*/
|
||||
interface StatusBar {
|
||||
/**
|
||||
* On iOS 7, make the statusbar overlay or not overlay the WebView.
|
||||
*
|
||||
* @param isOverlay - On iOS 7, set to false to make the statusbar appear like iOS 6.
|
||||
* Set the style and background color to suit using the other functions.
|
||||
*/
|
||||
overlaysWebView(isOverlay: boolean): void;
|
||||
|
||||
/**
|
||||
* Use the default statusbar (dark text, for light backgrounds).
|
||||
*/
|
||||
styleDefault(): void;
|
||||
|
||||
/**
|
||||
* Use the lightContent statusbar (light text, for dark backgrounds).
|
||||
*/
|
||||
styleLightContent(): void;
|
||||
|
||||
/**
|
||||
* Use the blackTranslucent statusbar (light text, for dark backgrounds).
|
||||
*/
|
||||
styleBlackTranslucent(): void;
|
||||
|
||||
/**
|
||||
* Use the blackOpaque statusbar (light text, for dark backgrounds).
|
||||
*/
|
||||
styleBlackOpaque(): void;
|
||||
|
||||
/**
|
||||
* On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false,
|
||||
* you can set the background color of the statusbar by color name.
|
||||
*
|
||||
* @param color - Supported color names are:
|
||||
* black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown
|
||||
*/
|
||||
backgroundColorByName(color: string): void;
|
||||
|
||||
/**
|
||||
* Sets the background color of the statusbar by a hex string.
|
||||
*
|
||||
* @param color - CSS shorthand properties are also supported.
|
||||
* On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB).
|
||||
* On WP7 and WP8 you can also specify values as #AARRGGBB, where AA is an alpha value
|
||||
*/
|
||||
backgroundColorByHexString(color: string): void;
|
||||
|
||||
/**
|
||||
* Hide the statusbar.
|
||||
*/
|
||||
hide(): void;
|
||||
|
||||
/**
|
||||
* Show the statusbar.
|
||||
*/
|
||||
show(): void;
|
||||
|
||||
/**
|
||||
* Read this property to see if the statusbar is visible or not.
|
||||
*/
|
||||
isVisible: boolean;
|
||||
}
|
||||
|
||||
declare var StatusBar: StatusBar;
|
||||
113
www/statusbar.js
113
www/statusbar.js
@@ -1,113 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* global cordova */
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var namedColors = {
|
||||
"black": "#000000",
|
||||
"darkGray": "#A9A9A9",
|
||||
"lightGray": "#D3D3D3",
|
||||
"white": "#FFFFFF",
|
||||
"gray": "#808080",
|
||||
"red": "#FF0000",
|
||||
"green": "#00FF00",
|
||||
"blue": "#0000FF",
|
||||
"cyan": "#00FFFF",
|
||||
"yellow": "#FFFF00",
|
||||
"magenta": "#FF00FF",
|
||||
"orange": "#FFA500",
|
||||
"purple": "#800080",
|
||||
"brown": "#A52A2A"
|
||||
};
|
||||
|
||||
var StatusBar = {
|
||||
|
||||
isVisible: true,
|
||||
|
||||
overlaysWebView: function (doOverlay) {
|
||||
exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
|
||||
},
|
||||
|
||||
styleDefault: function () {
|
||||
// dark text ( to be used on a light background )
|
||||
exec(null, null, "StatusBar", "styleDefault", []);
|
||||
},
|
||||
|
||||
styleLightContent: function () {
|
||||
// light text ( to be used on a dark background )
|
||||
exec(null, null, "StatusBar", "styleLightContent", []);
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackTranslucent", []);
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackOpaque", []);
|
||||
},
|
||||
|
||||
backgroundColorByName: function (colorname) {
|
||||
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (hexString) {
|
||||
if (hexString.charAt(0) !== "#") {
|
||||
hexString = "#" + hexString;
|
||||
}
|
||||
|
||||
if (hexString.length === 4) {
|
||||
var split = hexString.split("");
|
||||
hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
|
||||
}
|
||||
|
||||
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
exec(null, null, "StatusBar", "hide", []);
|
||||
StatusBar.isVisible = false;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
exec(null, null, "StatusBar", "show", []);
|
||||
StatusBar.isVisible = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// prime it. setTimeout so that proxy gets time to init
|
||||
window.setTimeout(function () {
|
||||
exec(function (res) {
|
||||
if (typeof res == 'object') {
|
||||
if (res.type == 'tap') {
|
||||
cordova.fireWindowEvent('statusTap');
|
||||
}
|
||||
} else {
|
||||
StatusBar.isVisible = res;
|
||||
}
|
||||
}, null, "StatusBar", "_ready", []);
|
||||
}, 0);
|
||||
|
||||
module.exports = StatusBar;
|
||||
Reference in New Issue
Block a user