Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbc4862dbd | ||
|
|
4c1507b525 | ||
|
|
62e8a187c1 | ||
|
|
e3138a9f08 | ||
|
|
f1407e7ae5 | ||
|
|
70a421bd25 | ||
|
|
bca70c21e9 | ||
|
|
4988b6fec3 | ||
|
|
8da38f5075 | ||
|
|
6352d80a96 | ||
|
|
caf2ae6605 | ||
|
|
3d614115b8 | ||
|
|
9a976a9744 | ||
|
|
611169c89f | ||
|
|
655f6cb1da | ||
|
|
4642be07a6 | ||
|
|
e41c06334e | ||
|
|
c45331b955 | ||
|
|
cdc9295b30 | ||
|
|
049ac41dad | ||
|
|
241d30fff5 | ||
|
|
ca3da118f0 | ||
|
|
b03a8313ef | ||
|
|
08127bf674 | ||
|
|
fff289c0b8 | ||
|
|
ef5fb5b9e6 | ||
|
|
267ebad1be | ||
|
|
70468157c5 | ||
|
|
b204d2747d | ||
|
|
1bb250788e | ||
|
|
2cd86e63ac | ||
|
|
1ae18933d5 | ||
|
|
0364d4a4f9 | ||
|
|
3d8cff14bd | ||
|
|
92fff60cc7 | ||
|
|
0a3dadfdb0 | ||
|
|
0285cf0a21 | ||
|
|
77a6ae5dfe | ||
|
|
ecf61e7800 | ||
|
|
3f552ed734 | ||
|
|
d980145c98 | ||
|
|
dd879140c4 | ||
|
|
95eb824d0a | ||
|
|
cb1297b0ac | ||
|
|
916cccc2c0 | ||
|
|
995e4fdf9d | ||
|
|
a204f69ffe | ||
|
|
fa57e92c55 | ||
|
|
a120ba1a1f | ||
|
|
834b8cb5fb | ||
|
|
d601f1a143 | ||
|
|
59101557b7 | ||
|
|
a07c24fe78 | ||
|
|
a50208bda2 | ||
|
|
6bfc749f84 | ||
|
|
b7dc5ef7cb | ||
|
|
086234b881 | ||
|
|
2c036c9c91 | ||
|
|
940a8ee920 | ||
|
|
53d0b04ed6 | ||
|
|
ad5f7d912c | ||
|
|
dbc7b29680 | ||
|
|
1d1ac928a8 | ||
|
|
554e65e60f | ||
|
|
f2c49454da | ||
|
|
aca5eceaf9 | ||
|
|
86cfafeaf9 | ||
|
|
8159e1b307 | ||
|
|
f8873fd481 | ||
|
|
cfce729912 | ||
|
|
c34e3a02c2 | ||
|
|
16c653747e | ||
|
|
b448166624 | ||
|
|
fc56eb211f | ||
|
|
259cdb65ef | ||
|
|
c3705fe46e |
28
.appveyor.yml
Normal file
28
.appveyor.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
# 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:
|
||||
nodejs_version: "4"
|
||||
matrix:
|
||||
- PLATFORM: windows-10-store
|
||||
JUST_BUILD: --justBuild
|
||||
install:
|
||||
- npm cache clean -f
|
||||
- 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%
|
||||
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
|
||||
### What does this PR do?
|
||||
|
||||
|
||||
### What testing has been done on this change?
|
||||
|
||||
|
||||
### Checklist
|
||||
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
|
||||
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
|
||||
- [ ] Added automated test coverage as appropriate for this change.
|
||||
88
.travis.yml
88
.travis.yml
@@ -1,4 +1,86 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.2"
|
||||
addons:
|
||||
jwt:
|
||||
secure: Rd/wGSUWGWbc0Y/vqPgI29nybq+j/zWilEIOCBJeRQVwfubdbJNZUIb5DFlSSVzMEavkxZ0PYJ45h21iXyWo3aOoxUJwhkO7QZNzW2MsYzy9qpiKK1jOESXMrpboRWoxg+BL85YbaDF3u1XRy+Xm1nraStT6mDfx5LlUG1Lac6A=
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION="4.2"
|
||||
matrix:
|
||||
include:
|
||||
- env: PLATFORM=browser-chrome
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-firefox
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-safari
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-edge
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-9.3
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-10.0
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=android-4.4
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-5.1
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-6.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-7.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
before_install:
|
||||
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
|
||||
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
|
||||
install $TRAVIS_NODE_VERSION
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26;
|
||||
fi
|
||||
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
|
||||
&& npm install && popd
|
||||
- npm install -g cordova
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- npm test
|
||||
- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
|
||||
--buildName travis-plugin-statusbar-$TRAVIS_JOB_NUMBER
|
||||
44
README.md
44
README.md
@@ -1,3 +1,7 @@
|
||||
---
|
||||
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
|
||||
@@ -17,7 +21,9 @@
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-statusbar)
|
||||
|AppVeyor|Travis CI|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-statusbar)|[](https://travis-ci.org/apache/cordova-plugin-statusbar)|
|
||||
|
||||
# cordova-plugin-statusbar
|
||||
|
||||
@@ -26,7 +32,7 @@ StatusBar
|
||||
|
||||
> The `StatusBar` object provides some functions to customize the iOS and Android StatusBar.
|
||||
|
||||
:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Statusbar%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22cordova-plugin-statusbar%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
|
||||
|
||||
## Installation
|
||||
@@ -59,6 +65,10 @@ Preferences
|
||||
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
|
||||
- __StatusBarDefaultScrollToTop__ (boolean, defaults to false). On iOS 7, 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 7+ 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
|
||||
@@ -107,14 +117,10 @@ Properties
|
||||
|
||||
- StatusBar.isVisible
|
||||
|
||||
Permissions
|
||||
-----------
|
||||
Events
|
||||
------
|
||||
|
||||
#### config.xml
|
||||
|
||||
<feature name="StatusBar">
|
||||
<param name="ios-package" value="CDVStatusBar" onload="true" />
|
||||
</feature>
|
||||
- statusTap
|
||||
|
||||
StatusBar.overlaysWebView
|
||||
=================
|
||||
@@ -152,6 +158,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -168,6 +175,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -184,6 +192,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -200,6 +209,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -304,3 +314,19 @@ Supported Platforms
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -20,9 +20,62 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 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 Fix statusbar with `inappbrowser` causing incorrect orientation on **iOS8**
|
||||
* CB-10884 `Inappbrowser` breaks UI while Screen orientation changes from landscape to portrait on **iOS**
|
||||
* [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
|
||||
@@ -34,9 +87,9 @@
|
||||
* [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 Allow to show/hide status bar in fullscreen mode.
|
||||
* CB-8720 Fix status bar position when app started upside down on **iOS 7**.
|
||||
* CB-10118 Fixes plugin loading error for **Browser** platform
|
||||
* [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
|
||||
@@ -53,7 +106,7 @@
|
||||
|
||||
### 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-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
|
||||
|
||||
|
||||
22
package.json
22
package.json
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "cordova-plugin-statusbar",
|
||||
"version": "2.1.3",
|
||||
"version": "2.4.2",
|
||||
"description": "Cordova StatusBar Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-statusbar",
|
||||
"platforms": [
|
||||
@@ -16,6 +17,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-statusbar"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://issues.apache.org/jira/browse/CB"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"statusbar",
|
||||
@@ -30,14 +34,18 @@
|
||||
"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": [
|
||||
{
|
||||
"name": "cordova",
|
||||
"version": ">=3.0.0"
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
"0.1.0": {
|
||||
"cordova": ">=3.0.0"
|
||||
},
|
||||
"3.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache 2.0",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.6.0"
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-statusbar"
|
||||
version="2.1.3">
|
||||
version="2.4.2">
|
||||
<name>StatusBar</name>
|
||||
<description>Cordova StatusBar Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
@@ -48,8 +48,8 @@
|
||||
</platform>
|
||||
|
||||
<platform name="browser">
|
||||
<js-module src="src/browser/statusbar.js" name="statusbar.Browser">
|
||||
<merges target="window.StatusBar" />
|
||||
<js-module src="src/browser/StatusBarProxy.js" name="StatusBarProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ package org.apache.cordova.statusbar;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
@@ -32,8 +31,10 @@ 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";
|
||||
@@ -47,7 +48,7 @@ public class StatusBar extends CordovaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
|
||||
Log.v(TAG, "StatusBar: initialization");
|
||||
LOG.v(TAG, "StatusBar: initialization");
|
||||
super.initialize(cordova, webView);
|
||||
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@@ -60,6 +61,9 @@ public class StatusBar extends CordovaPlugin {
|
||||
|
||||
// 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"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -74,7 +78,7 @@ public class StatusBar extends CordovaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
|
||||
Log.v(TAG, "Executing action: " + action);
|
||||
LOG.v(TAG, "Executing action: " + action);
|
||||
final Activity activity = this.cordova.getActivity();
|
||||
final Window window = activity.getWindow();
|
||||
|
||||
@@ -96,9 +100,10 @@ public class StatusBar extends CordovaPlugin {
|
||||
uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
@@ -117,9 +122,10 @@ public class StatusBar extends CordovaPlugin {
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
@@ -133,13 +139,70 @@ public class StatusBar extends CordovaPlugin {
|
||||
try {
|
||||
setStatusBarBackgroundColor(args.getString(0));
|
||||
} catch (JSONException ignore) {
|
||||
Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -152,14 +215,62 @@ public class StatusBar extends CordovaPlugin {
|
||||
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().getDeclaredMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref));
|
||||
window.getClass().getMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref));
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
Log.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
|
||||
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);
|
||||
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) {
|
||||
window.getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
else {
|
||||
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'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
function notSupported() {
|
||||
function notSupported(win,fail) {
|
||||
//
|
||||
console.log('StatusBar is not supported');
|
||||
return false;
|
||||
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 = {
|
||||
@@ -34,6 +42,9 @@ module.exports = {
|
||||
backgroundColorByName: notSupported,
|
||||
backgroundColorByHexString: notSupported,
|
||||
hide: notSupported,
|
||||
show: notSupported
|
||||
show: notSupported,
|
||||
_ready:notSupported
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("StatusBar", module.exports);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
}
|
||||
|
||||
@property (atomic, assign) BOOL statusBarOverlaysWebView;
|
||||
@property (atomic, assign) BOOL statusBarVisible;
|
||||
|
||||
- (void) overlaysWebView:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
|
||||
@@ -90,28 +90,34 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)cordovaViewWillAppear:(NSNotification*)notification
|
||||
{
|
||||
[self resizeWebView];
|
||||
}
|
||||
|
||||
-(void)statusBarDidChangeFrame:(NSNotification*)notification
|
||||
{
|
||||
//add a small delay for iOS 7 ( 0.1 seconds )
|
||||
//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
|
||||
{
|
||||
BOOL isiOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
||||
|
||||
// init
|
||||
NSNumber* uiviewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
|
||||
_uiviewControllerBasedStatusBarAppearance = (uiviewControllerBasedStatusBarAppearance == nil || [uiviewControllerBasedStatusBarAppearance boolValue]) && isiOS7;
|
||||
_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];
|
||||
@@ -130,8 +136,14 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
[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
|
||||
self.webView.scrollView.scrollsToTop = NO;
|
||||
UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
||||
fakeScrollView.delegate = self;
|
||||
fakeScrollView.scrollsToTop = YES;
|
||||
@@ -139,6 +151,8 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
[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 {
|
||||
@@ -182,7 +196,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
if ([[UIApplication sharedApplication]statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown &&
|
||||
statusBarFrame.size.height + statusBarFrame.origin.y == [[UIScreen mainScreen] bounds].size.height) {
|
||||
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
|
||||
@@ -190,34 +204,19 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
statusBarFrame.origin.y = 0;
|
||||
}
|
||||
|
||||
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
|
||||
|
||||
_statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
|
||||
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
||||
_statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
|
||||
_statusBarBackgroundView.autoresizesSubviews = YES;
|
||||
}
|
||||
|
||||
- (CGRect) invertFrameIfNeeded:(CGRect)rect {
|
||||
// landscape is where (width > height). On iOS < 8, we need to invert since frames are
|
||||
// always in Portrait context
|
||||
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) && (rect.size.width < rect.size.height)) {
|
||||
CGFloat temp = rect.size.width;
|
||||
rect.size.width = rect.size.height;
|
||||
rect.size.height = temp;
|
||||
rect.origin = CGPointZero;
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
||||
{
|
||||
// we only care about the latest iOS version or a change in setting
|
||||
if (!IsAtLeastiOSVersion(@"7.0") || statusBarOverlaysWebView == _statusBarOverlaysWebView) {
|
||||
if (statusBarOverlaysWebView == _statusBarOverlaysWebView) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_statusBarOverlaysWebView = statusBarOverlaysWebView;
|
||||
|
||||
[self resizeWebView];
|
||||
@@ -301,22 +300,12 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
|
||||
# define TRANSLUCENT_STYLE UIStatusBarStyleBlackTranslucent
|
||||
#else
|
||||
# define TRANSLUCENT_STYLE UIStatusBarStyleLightContent
|
||||
#endif
|
||||
[self setStyleForStatusBar:TRANSLUCENT_STYLE];
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
|
||||
# define OPAQUE_STYLE UIStatusBarStyleBlackOpaque
|
||||
#else
|
||||
# define OPAQUE_STYLE UIStatusBarStyleLightContent
|
||||
#endif
|
||||
[self setStyleForStatusBar:OPAQUE_STYLE];
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command
|
||||
@@ -372,16 +361,15 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
- (void) hide:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
_statusBarVisible = NO;
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
|
||||
if (!app.isStatusBarHidden)
|
||||
{
|
||||
|
||||
|
||||
[self hideStatusBar];
|
||||
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
[_statusBarBackgroundView removeFromSuperview];
|
||||
}
|
||||
[_statusBarBackgroundView removeFromSuperview];
|
||||
|
||||
[self resizeWebView];
|
||||
|
||||
@@ -404,30 +392,21 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
- (void) show:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
_statusBarVisible = YES;
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
|
||||
if (app.isStatusBarHidden)
|
||||
{
|
||||
BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
||||
|
||||
[self showStatusBar];
|
||||
[self resizeWebView];
|
||||
|
||||
if (isIOS7) {
|
||||
if (!self.statusBarOverlaysWebView) {
|
||||
|
||||
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
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
|
||||
CGRect sbBgFrame = _statusBarBackgroundView.frame;
|
||||
sbBgFrame.size = statusBarFrame.size;
|
||||
_statusBarBackgroundView.frame = sbBgFrame;
|
||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||
|
||||
}
|
||||
// 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];
|
||||
|
||||
}
|
||||
|
||||
@@ -435,42 +414,51 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)resizeStatusBarBackgroundView {
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
CGRect sbBgFrame = _statusBarBackgroundView.frame;
|
||||
sbBgFrame.size = statusBarFrame.size;
|
||||
_statusBarBackgroundView.frame = sbBgFrame;
|
||||
}
|
||||
|
||||
-(void)resizeWebView
|
||||
{
|
||||
BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
||||
BOOL isIOS11 = (IsAtLeastiOSVersion(@"11.0"));
|
||||
|
||||
if (isIOS7) {
|
||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
||||
bounds = [self invertFrameIfNeeded:bounds];
|
||||
|
||||
if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
|
||||
self.viewController.view.frame = bounds;
|
||||
} else if (self.viewController.presentedViewController != nil) {
|
||||
// https://issues.apache.org/jira/browse/CB-11018
|
||||
BOOL isIOS8 = (IsAtLeastiOSVersion(@"8.0"));
|
||||
BOOL isIOS9 = (IsAtLeastiOSVersion(@"9.0"));
|
||||
if (isIOS8 && !isIOS9) {
|
||||
// iOS 8
|
||||
bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);
|
||||
} else {
|
||||
// iOS7, iOS9+
|
||||
bounds = CGRectMake(0, 0, bounds.size.height, bounds.size.width);
|
||||
}
|
||||
}
|
||||
self.webView.frame = bounds;
|
||||
|
||||
if (!self.statusBarOverlaysWebView) {
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
|
||||
CGRect frame = self.webView.frame;
|
||||
frame.origin.y = statusBarFrame.size.height;
|
||||
frame.size.height -= statusBarFrame.size.height;
|
||||
self.webView.frame = frame;
|
||||
}
|
||||
} else {
|
||||
CGRect bounds = [[UIScreen mainScreen] applicationFrame];
|
||||
self.viewController.view.frame = bounds;
|
||||
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
|
||||
|
||||
14
tests/package.json
Normal file
14
tests/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "cordova-plugin-statusbar-tests",
|
||||
"version": "2.2.3-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-statusbar-tests",
|
||||
"platforms": []
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:cordova"
|
||||
],
|
||||
"author": "",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-statusbar-tests"
|
||||
version="2.1.3">
|
||||
version="2.4.2">
|
||||
<name>Cordova StatusBar Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
77
types/index.d.ts
vendored
Normal file
77
types/index.d.ts
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
// Type definitions for Apache Cordova StatusBar plugin
|
||||
// Project: https://github.com/apache/cordova-plugin-statusbar
|
||||
// Definitions by: Xinkai Chen <https://github.com/Xinkai>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Global object StatusBar.
|
||||
*/
|
||||
interface Window {
|
||||
StatusBar: StatusBar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
Reference in New Issue
Block a user