Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11195658af | ||
|
|
55575f5409 | ||
|
|
4cfee575a1 | ||
|
|
29f119154e | ||
|
|
80203f655b | ||
|
|
949b15eb09 |
37
CONTRIBUTING.md
Normal file
37
CONTRIBUTING.md
Normal file
@@ -0,0 +1,37 @@
|
||||
<!--
|
||||
#
|
||||
# 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!
|
||||
@@ -26,3 +26,11 @@
|
||||
* CB-6316: Moved StatusBar plugin documentation to docs folder
|
||||
* CB-6314: [android] Add StatusBar.isVisible support to Android
|
||||
* CB-6460: Update license headers
|
||||
|
||||
### 0.1.6 (Jun 05, 2014)
|
||||
* CB-6783 - added StatusBarStyle config preference, updated docs (closes #9)
|
||||
* CB-6812 Add license
|
||||
* CB-6491 add CONTRIBUTING.md
|
||||
* CB-6264 minor formatting issue
|
||||
* Update docs with recent WP changes, remove 'clear' from the loist of named colors in documentation
|
||||
* CB-6513 - Statusbar plugin for Android is not compiling
|
||||
|
||||
39
doc/index.md
39
doc/index.md
@@ -32,11 +32,15 @@ Preferences
|
||||
- __StatusBarOverlaysWebView__ (boolean, defaults to true). On iOS 7, make the statusbar overlay or not overlay the WebView at startup.
|
||||
|
||||
<preference name="StatusBarOverlaysWebView" value="true" />
|
||||
|
||||
|
||||
- __StatusBarBackgroundColor__ (color hex string, defaults to #000000). On iOS 7, set the background color of the statusbar by a hex string (#RRGGBB) at startup.
|
||||
|
||||
<preference name="StatusBarBackgroundColor" value="#000000" />
|
||||
|
||||
- __StatusBarStyle__ (status bar style, defaults to lightcontent). On iOS 7, set the status bar style. Available options default, lightcontent, blacktranslucent, blackopaque.
|
||||
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
|
||||
Hiding at startup
|
||||
-----------
|
||||
|
||||
@@ -50,7 +54,7 @@ Add/edit these two attributes if not present. Set **"Status bar is initially hid
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
@@ -114,6 +118,8 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
StatusBar.styleLightContent
|
||||
=================
|
||||
@@ -127,6 +133,8 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
StatusBar.styleBlackTranslucent
|
||||
=================
|
||||
@@ -140,6 +148,8 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
StatusBar.styleBlackOpaque
|
||||
=================
|
||||
@@ -153,6 +163,8 @@ Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
|
||||
StatusBar.backgroundColorByName
|
||||
@@ -164,26 +176,38 @@ On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set
|
||||
|
||||
Supported color names are:
|
||||
|
||||
black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown, clear
|
||||
black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
StatusBar.backgroundColorByHexString
|
||||
=================
|
||||
|
||||
On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB).
|
||||
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 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
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
StatusBar.hide
|
||||
=================
|
||||
@@ -198,6 +222,8 @@ Supported Platforms
|
||||
|
||||
- iOS
|
||||
- Android
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
StatusBar.show
|
||||
=================
|
||||
@@ -212,6 +238,8 @@ Supported Platforms
|
||||
|
||||
- iOS
|
||||
- Android
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
|
||||
StatusBar.isVisible
|
||||
@@ -229,6 +257,7 @@ Supported Platforms
|
||||
|
||||
- iOS
|
||||
- Android
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="org.apache.cordova.statusbar"
|
||||
version="0.1.6-dev">
|
||||
version="0.1.6">
|
||||
<name>StatusBar</name>
|
||||
<description>Cordova StatusBar Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
@@ -35,7 +35,7 @@
|
||||
<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" />
|
||||
|
||||
@@ -55,11 +55,12 @@
|
||||
</feature>
|
||||
<preference name="StatusBarOverlaysWebView" value="true" />
|
||||
<preference name="StatusBarBackgroundColor" value="#000000" />
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
</config-file>
|
||||
|
||||
|
||||
<header-file src="src/ios/CDVStatusBar.h" />
|
||||
<source-file src="src/ios/CDVStatusBar.m" />
|
||||
|
||||
|
||||
</platform>
|
||||
|
||||
<!-- wp7 -->
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
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
|
||||
@@ -17,7 +17,7 @@
|
||||
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
|
||||
@@ -34,18 +34,18 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
@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);
|
||||
}
|
||||
@@ -53,20 +53,20 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
- (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
|
||||
|
||||
|
||||
@@ -90,23 +90,22 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
BOOL isiOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
||||
|
||||
|
||||
// init
|
||||
NSNumber* uiviewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
|
||||
_uiviewControllerBasedStatusBarAppearance = (uiviewControllerBasedStatusBarAppearance == nil || [uiviewControllerBasedStatusBarAppearance boolValue]) && isiOS7;
|
||||
|
||||
|
||||
// observe the statusBarHidden property
|
||||
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew context:NULL];
|
||||
|
||||
|
||||
_statusBarOverlaysWebView = YES; // default
|
||||
|
||||
|
||||
[self initializeStatusBarBackgroundView];
|
||||
|
||||
[self styleLightContent:nil]; // match default backgroundColor of #000000
|
||||
self.viewController.view.autoresizesSubviews = YES;
|
||||
|
||||
|
||||
NSString* setting;
|
||||
|
||||
|
||||
setting = @"StatusBarOverlaysWebView";
|
||||
if ([self settingForKey:setting]) {
|
||||
self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue];
|
||||
@@ -116,6 +115,11 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
if ([self settingForKey:setting]) {
|
||||
[self _backgroundColorByHexString:[self settingForKey:setting]];
|
||||
}
|
||||
|
||||
setting = @"StatusBarStyle";
|
||||
if ([self settingForKey:setting]) {
|
||||
[self setStatusBarStyle:[self settingForKey:setting]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _ready:(CDVInvokedUrlCommand*)command
|
||||
@@ -124,7 +128,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", [UIApplication sharedApplication].statusBarHidden? @"false" : @"true" ]];
|
||||
}
|
||||
|
||||
- (void) initializeStatusBarBackgroundView
|
||||
- (void) initializeStatusBarBackgroundView
|
||||
{
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
|
||||
@@ -146,9 +150,9 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
}
|
||||
|
||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
||||
|
||||
|
||||
if (statusBarOverlaysWebView) {
|
||||
|
||||
|
||||
[_statusBarBackgroundView removeFromSuperview];
|
||||
if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
|
||||
self.webView.frame = CGRectMake(0, 0, bounds.size.height, bounds.size.width);
|
||||
@@ -171,11 +175,11 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
frame.origin.y = statusBarFrame.size.height;
|
||||
frame.size.height -= statusBarFrame.size.height;
|
||||
}
|
||||
|
||||
|
||||
self.webView.frame = frame;
|
||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||
}
|
||||
|
||||
|
||||
_statusBarOverlaysWebView = statusBarOverlaysWebView;
|
||||
}
|
||||
|
||||
@@ -190,7 +194,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
if (!([value isKindOfClass:[NSNumber class]])) {
|
||||
value = [NSNumber numberWithBool:YES];
|
||||
}
|
||||
|
||||
|
||||
self.statusBarOverlaysWebView = [value boolValue];
|
||||
}
|
||||
|
||||
@@ -204,24 +208,24 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
#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"]) {
|
||||
@@ -259,7 +263,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
if (!([value isKindOfClass:[NSString class]])) {
|
||||
value = @"black";
|
||||
}
|
||||
|
||||
|
||||
SEL selector = NSSelectorFromString([value stringByAppendingString:@"Color"]);
|
||||
if ([UIColor respondsToSelector:selector]) {
|
||||
_statusBarBackgroundView.backgroundColor = [UIColor performSelector:selector];
|
||||
@@ -272,7 +276,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
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;
|
||||
}
|
||||
@@ -283,11 +287,11 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
if (!([value isKindOfClass:[NSString class]])) {
|
||||
value = @"#000000";
|
||||
}
|
||||
|
||||
|
||||
if (![value hasPrefix:@"#"] || [value length] < 7) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self _backgroundColorByHexString:value];
|
||||
}
|
||||
|
||||
@@ -303,40 +307,40 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
[app setStatusBarHidden:YES];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) hide:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
|
||||
|
||||
if (!app.isStatusBarHidden)
|
||||
{
|
||||
self.viewController.wantsFullScreenLayout = YES;
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
|
||||
[self hideStatusBar];
|
||||
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
[_statusBarBackgroundView removeFromSuperview];
|
||||
}
|
||||
|
||||
|
||||
if (!_statusBarOverlaysWebView) {
|
||||
|
||||
|
||||
CGRect frame = self.webView.frame;
|
||||
frame.origin.y = 0;
|
||||
|
||||
|
||||
if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
|
||||
frame.size.height += statusBarFrame.size.width;
|
||||
} else {
|
||||
frame.size.height += statusBarFrame.size.height;
|
||||
}
|
||||
|
||||
|
||||
self.webView.frame = frame;
|
||||
}
|
||||
|
||||
|
||||
_statusBarBackgroundView.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) showStatusBar
|
||||
{
|
||||
if (_uiviewControllerBasedStatusBarAppearance) {
|
||||
@@ -349,31 +353,31 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
[app setStatusBarHidden:NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) show:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
UIApplication* app = [UIApplication sharedApplication];
|
||||
|
||||
|
||||
if (app.isStatusBarHidden)
|
||||
{
|
||||
BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
||||
self.viewController.wantsFullScreenLayout = isIOS7;
|
||||
|
||||
|
||||
[self showStatusBar];
|
||||
|
||||
|
||||
if (isIOS7) {
|
||||
CGRect frame = self.webView.frame;
|
||||
self.viewController.view.frame = [[UIScreen mainScreen] bounds];
|
||||
|
||||
|
||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
|
||||
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 sbBgFrame = _statusBarBackgroundView.frame;
|
||||
|
||||
|
||||
if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
|
||||
frame.origin.y = statusBarFrame.size.width;
|
||||
frame.size.height -= statusBarFrame.size.width;
|
||||
@@ -383,19 +387,19 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
frame.size.height -= statusBarFrame.size.height;
|
||||
sbBgFrame.size = statusBarFrame.size;
|
||||
}
|
||||
|
||||
|
||||
_statusBarBackgroundView.frame = sbBgFrame;
|
||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||
}
|
||||
|
||||
self.webView.frame = frame;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
CGRect bounds = [[UIScreen mainScreen] applicationFrame];
|
||||
self.viewController.view.frame = bounds;
|
||||
}
|
||||
|
||||
|
||||
_statusBarBackgroundView.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user