Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
655f6cb1da | ||
|
|
4642be07a6 | ||
|
|
e41c06334e | ||
|
|
c45331b955 | ||
|
|
cdc9295b30 | ||
|
|
049ac41dad | ||
|
|
241d30fff5 | ||
|
|
ca3da118f0 | ||
|
|
b03a8313ef | ||
|
|
08127bf674 | ||
|
|
fff289c0b8 | ||
|
|
ef5fb5b9e6 | ||
|
|
267ebad1be | ||
|
|
70468157c5 | ||
|
|
b204d2747d | ||
|
|
1bb250788e | ||
|
|
2cd86e63ac | ||
|
|
1ae18933d5 | ||
|
|
0364d4a4f9 | ||
|
|
3d8cff14bd | ||
|
|
92fff60cc7 | ||
|
|
0a3dadfdb0 | ||
|
|
0285cf0a21 | ||
|
|
dd879140c4 |
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%
|
||||
84
.travis.yml
84
.travis.yml
@@ -1,4 +1,82 @@
|
||||
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
|
||||
- env: PLATFORM=android-5.1
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- env: PLATFORM=android-6.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- env: PLATFORM=android-7.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
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
|
||||
16
README.md
16
README.md
@@ -21,9 +21,9 @@ description: Control the device status bar.
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI|
|
||||
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
||||
|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-statusbar/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-statusbar/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-statusbar/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-statusbar/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-statusbar/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-statusbar/)|[](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
|
||||
|
||||
@@ -32,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
|
||||
@@ -65,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
|
||||
@@ -163,6 +167,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -179,6 +184,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -195,6 +201,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
@@ -211,6 +218,7 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
@@ -20,6 +20,15 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 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+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-statusbar",
|
||||
"version": "2.2.3",
|
||||
"version": "2.3.0",
|
||||
"description": "Cordova StatusBar Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
@@ -17,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",
|
||||
|
||||
@@ -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.2.3">
|
||||
version="2.3.0">
|
||||
<name>StatusBar</name>
|
||||
<description>Cordova StatusBar Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
@@ -34,6 +34,7 @@ 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";
|
||||
@@ -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"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -159,6 +163,46 @@ public class StatusBar extends CordovaPlugin {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -198,4 +242,35 @@ public class StatusBar extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ function notSupported(win,fail) {
|
||||
//
|
||||
console.log('StatusBar is not supported');
|
||||
setTimeout(function(){
|
||||
win();
|
||||
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
|
||||
|
||||
@@ -100,6 +100,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
//add a small delay for iOS 7 ( 0.1 seconds )
|
||||
__weak CDVStatusBar* weakSelf = self;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||
[self resizeStatusBarBackgroundView];
|
||||
[weakSelf resizeWebView];
|
||||
});
|
||||
}
|
||||
@@ -137,8 +138,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;
|
||||
@@ -216,7 +223,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
rect.size.height = temp;
|
||||
rect.origin = CGPointZero;
|
||||
}
|
||||
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
@@ -226,7 +233,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
if (!IsAtLeastiOSVersion(@"7.0") || statusBarOverlaysWebView == _statusBarOverlaysWebView) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_statusBarOverlaysWebView = statusBarOverlaysWebView;
|
||||
|
||||
[self resizeWebView];
|
||||
@@ -386,7 +393,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
if (!app.isStatusBarHidden)
|
||||
{
|
||||
|
||||
|
||||
[self hideStatusBar];
|
||||
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
@@ -431,11 +438,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
// 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 resizeStatusBarBackgroundView];
|
||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||
|
||||
}
|
||||
@@ -446,9 +449,18 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)resizeStatusBarBackgroundView {
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
statusBarFrame = [self invertFrameIfNeeded: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 = [self.viewController.view.window bounds];
|
||||
@@ -467,13 +479,22 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
CGFloat height = statusBarFrame.size.height;
|
||||
|
||||
if (!self.statusBarOverlaysWebView) {
|
||||
if (_statusBarVisible) {
|
||||
// CB-10158 If a full screen video is playing the status bar height will be 0, set it to 20 if _statusBarVisible
|
||||
frame.origin.y = height > 0 ? height: 20;
|
||||
}
|
||||
frame.origin.y = height;
|
||||
} else {
|
||||
// Even if overlay is used, we want to handle in-call/recording/hotspot larger status bar
|
||||
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;
|
||||
|
||||
@@ -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.2.3">
|
||||
version="2.3.0">
|
||||
<name>Cordova StatusBar Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user