Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AA55710338 for ; Mon, 7 Oct 2013 22:13:46 +0000 (UTC) Received: (qmail 90382 invoked by uid 500); 7 Oct 2013 22:13:42 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 89298 invoked by uid 500); 7 Oct 2013 22:13:41 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 89098 invoked by uid 99); 7 Oct 2013 22:13:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Oct 2013 22:13:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 16F0F911DE8; Mon, 7 Oct 2013 22:13:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shazron@apache.org To: commits@cordova.apache.org Message-Id: <1f3fac7f94aa4a9bba46277c2912f04f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Added statusbar preferences to plugin.xml Date: Mon, 7 Oct 2013 22:13:41 +0000 (UTC) Updated Branches: refs/heads/plugins 733a52911 -> ecfd5659e Added statusbar preferences to plugin.xml Removed Info.plist section in plugin xml due to crash: https://issues.apache.org/jira/browse/CB-5012 Project: http://git-wip-us.apache.org/repos/asf/cordova-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-labs/commit/ecfd5659 Tree: http://git-wip-us.apache.org/repos/asf/cordova-labs/tree/ecfd5659 Diff: http://git-wip-us.apache.org/repos/asf/cordova-labs/diff/ecfd5659 Branch: refs/heads/plugins Commit: ecfd5659e9e0b97d566ea5bb22a72707a5ca0d19 Parents: 733a529 Author: Shazron Abdullah Authored: Mon Oct 7 15:13:32 2013 -0700 Committer: Shazron Abdullah Committed: Mon Oct 7 15:13:32 2013 -0700 ---------------------------------------------------------------------- statusbar/plugin.xml | 5 +++ statusbar/src/ios/CDVStatusBar.m | 59 ++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/ecfd5659/statusbar/plugin.xml ---------------------------------------------------------------------- diff --git a/statusbar/plugin.xml b/statusbar/plugin.xml index ad69b14..d4c937a 100644 --- a/statusbar/plugin.xml +++ b/statusbar/plugin.xml @@ -24,12 +24,17 @@ + + + + http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/ecfd5659/statusbar/src/ios/CDVStatusBar.m ---------------------------------------------------------------------- diff --git a/statusbar/src/ios/CDVStatusBar.m b/statusbar/src/ios/CDVStatusBar.m index 7a301b8..0809d24 100644 --- a/statusbar/src/ios/CDVStatusBar.m +++ b/statusbar/src/ios/CDVStatusBar.m @@ -32,6 +32,14 @@ return [self.commandDelegate.settings objectForKey:[key lowercaseString]]; } +- (void) checkInfoPlistKey +{ + NSNumber* uiviewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"]; + if (uiviewControllerBasedStatusBarAppearance == nil || [uiviewControllerBasedStatusBarAppearance boolValue]) { + NSLog(@"ERROR: To use the statusbar plugin, in your app's Info.plist, you need to add a 'UIViewControllerBasedStatusBarAppearance' key with a value of "); + } +} + - (void)pluginInitialize { _statusBarOverlaysWebView = YES; // default @@ -41,10 +49,22 @@ _statusBarBackgroundView = [[UIView alloc] initWithFrame:frame]; _statusBarBackgroundView.backgroundColor = [UIColor blackColor]; - NSString* setting = @"StatusBarOverlaysWebView"; + NSString* setting; + + setting = @"StatusBarOverlaysWebView"; if ([self settingForKey:setting]) { self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue]; } + + setting = @"StatusBarBackgroundColor"; + if ([self settingForKey:setting]) { + [self _statusBarBackgroundColorByHexString:[self settingForKey:setting]]; + } + + setting = @"StatusBarStyle"; + if ([self settingForKey:setting]) { + [self setStatusBarStyle:[self settingForKey:setting]]; + } } - (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView @@ -94,23 +114,43 @@ self.statusBarOverlaysWebView = [value boolValue]; } +- (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 checkInfoPlistKey]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } - (void) styleLightContent:(CDVInvokedUrlCommand*)command { + [self checkInfoPlistKey]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } - (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command { + [self checkInfoPlistKey]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent]; } - (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command { + [self checkInfoPlistKey]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; } @@ -127,6 +167,16 @@ } } +- (void) _statusBarBackgroundColorByHexString:(NSString*)hexString +{ + unsigned int rgbValue = 0; + NSScanner* scanner = [NSScanner scannerWithString:hexString]; + [scanner setScanLocation:1]; + [scanner scanHexInt:&rgbValue]; + + _statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; +} + - (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command { NSString* value = [command.arguments objectAtIndex:0]; @@ -138,12 +188,7 @@ return; } - unsigned int rgbValue = 0; - NSScanner* scanner = [NSScanner scannerWithString:value]; - [scanner setScanLocation:1]; - [scanner scanHexInt:&rgbValue]; - - _statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; + [self _statusBarBackgroundColorByHexString:value]; }