diff --git a/README.md b/README.md index 8b91de9..3828ea5 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,5 @@ # org.apache.cordova.statusbar -Plugin documentation: [doc/index.md](doc/index.md) \ No newline at end of file +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 diff --git a/RELEASENOTES.md b/RELEASENOTES.md deleted file mode 100644 index ef3c505..0000000 --- a/RELEASENOTES.md +++ /dev/null @@ -1,28 +0,0 @@ - -# Release Notes - -### 0.1.5 (Apr 17, 2014) (First release as a core Cordova Plugin) -* CB-6316: Added README.md which point to the new location for docs -* CB-6316: Added license header to the documentation. Added README.md which point to the new location for docs -* CB-6316: Moved StatusBar plugin documentation to docs folder -* CB-6314: [android] Add StatusBar.isVisible support to Android -* CB-6460: Update license headers diff --git a/doc/index.md b/doc/index.md deleted file mode 100644 index 403a891..0000000 --- a/doc/index.md +++ /dev/null @@ -1,234 +0,0 @@ - -#org.apache.cordova.statusbar - -StatusBar -====== - -> The `StatusBar` object provides some functions to customize the iOS and Android StatusBar. - - -Preferences ------------ - -#### config.xml - -- __StatusBarOverlaysWebView__ (boolean, defaults to true). On iOS 7, make the statusbar overlay or not overlay the WebView at startup. - - - -- __StatusBarBackgroundColor__ (color hex string, defaults to #000000). On iOS 7, set the background color of the statusbar by a hex string (#RRGGBB) at startup. - - - -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, 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: - - - UIStatusBarHidden - - UIViewControllerBasedStatusBarAppearance - - - -Methods -------- - -- StatusBar.overlaysWebView -- StatusBar.styleDefault -- StatusBar.styleLightContent -- StatusBar.styleBlackTranslucent -- StatusBar.styleBlackOpaque -- StatusBar.backgroundColorByName -- StatusBar.backgroundColorByHexString -- StatusBar.hide -- StatusBar.show - -Properties --------- - -- StatusBar.isVisible - -Permissions ------------ - -#### config.xml - - - - - -StatusBar.overlaysWebView -================= - -On iOS 7, make the statusbar overlay or not overlay the WebView. - - StatusBar.overlaysWebView(true); - -Description ------------ - -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. - - -Supported Platforms -------------------- - -- iOS - -Quick Example -------------- - - StatusBar.overlaysWebView(true); - StatusBar.overlaysWebView(false); - -StatusBar.styleDefault -================= - -Use the default statusbar (dark text, for light backgrounds). - - StatusBar.styleDefault(); - - -Supported Platforms -------------------- - -- iOS - -StatusBar.styleLightContent -================= - -Use the lightContent statusbar (light text, for dark backgrounds). - - StatusBar.styleLightContent(); - - -Supported Platforms -------------------- - -- iOS - -StatusBar.styleBlackTranslucent -================= - -Use the blackTranslucent statusbar (light text, for dark backgrounds). - - StatusBar.styleBlackTranslucent(); - - -Supported Platforms -------------------- - -- iOS - -StatusBar.styleBlackOpaque -================= - -Use the blackOpaque statusbar (light text, for dark backgrounds). - - StatusBar.styleBlackOpaque(); - - -Supported Platforms -------------------- - -- iOS - - -StatusBar.backgroundColorByName -================= - -On iOS 7, when you set StatusBar.statusBarOverlaysWebView 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, clear - - -Supported Platforms -------------------- - -- iOS - -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). - - StatusBar.backgroundColorByHexString("#C0C0C0"); - - -Supported Platforms -------------------- - -- iOS - -StatusBar.hide -================= - -Hide the statusbar. - - StatusBar.hide(); - - -Supported Platforms -------------------- - -- iOS -- Android - -StatusBar.show -================= - -Shows the statusbar. - - StatusBar.show(); - - -Supported Platforms -------------------- - -- iOS -- Android - - -StatusBar.isVisible -================= - -Read this property to see if the statusbar is visible or not. - - if (StatusBar.isVisible) { - // do something - } - - -Supported Platforms -------------------- - -- iOS -- Android - - - \ No newline at end of file diff --git a/plugin.xml b/plugin.xml deleted file mode 100644 index 9adb60e..0000000 --- a/plugin.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - StatusBar - Cordova StatusBar Plugin - Apache 2.0 - cordova,statusbar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/android/StatusBar.java b/src/android/StatusBar.java deleted file mode 100644 index 17152ec..0000000 --- a/src/android/StatusBar.java +++ /dev/null @@ -1,96 +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.util.Log; -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.PluginResult; -import org.json.JSONException; - -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(CordovaInterface cordova, CordovaWebView webView) { - Log.v(TAG, "StatusBar: initialization"); - super.initialize(cordova, webView); - - // Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially - // by the Cordova. - Window window = this.cordova.getActivity().getWindow(); - window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - } - - /** - * 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(String action, 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)); - } - - if ("show".equals(action)) { - this.cordova.getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - }); - return true; - } - - if ("hide".equals(action)) { - this.cordova.getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - }); - return true; - } - - return false; - } -} diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h deleted file mode 100644 index df48d2d..0000000 --- a/src/ios/CDVStatusBar.h +++ /dev/null @@ -1,51 +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 -#import - -@interface CDVStatusBar : CDVPlugin { - @protected - BOOL _statusBarOverlaysWebView; - @protected - UIView* _statusBarBackgroundView; - @protected - BOOL _uiviewControllerBasedStatusBarAppearance; - @protected - UIColor* _statusBarBackgroundColor; -} - -@property (atomic, assign) BOOL statusBarOverlaysWebView; - -- (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 diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m deleted file mode 100644 index af93134..0000000 --- a/src/ios/CDVStatusBar.m +++ /dev/null @@ -1,409 +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 -#import - -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 - - -@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]; - BOOL boolValue = [newValue boolValue]; - - [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", boolValue? @"false" : @"true" ]]; - } -} - -- (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]; - } - - setting = @"StatusBarBackgroundColor"; - if ([self settingForKey:setting]) { - [self _backgroundColorByHexString:[self settingForKey:setting]]; - } -} - -- (void) _ready:(CDVInvokedUrlCommand*)command -{ - // set the initial value - [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", [UIApplication sharedApplication].statusBarHidden? @"false" : @"true" ]]; -} - -- (void) initializeStatusBarBackgroundView -{ - CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; - if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) { - // swap width and height. set origin to zero - statusBarFrame = CGRectMake(0, 0, statusBarFrame.size.height, statusBarFrame.size.width); - } - - _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 (!IsAtLeastiOSVersion(@"7.0") || statusBarOverlaysWebView == _statusBarOverlaysWebView) { - return; - } - - 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); - } else { - self.webView.frame = bounds; - } - - } else { - - CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; - - [self initializeStatusBarBackgroundView]; - - CGRect frame = self.webView.frame; - - if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) { - frame.origin.y = statusBarFrame.size.width; - frame.size.height -= statusBarFrame.size.width; - } else { - frame.origin.y = statusBarFrame.size.height; - frame.size.height -= statusBarFrame.size.height; - } - - self.webView.frame = frame; - [self.webView.superview addSubview:_statusBarBackgroundView]; - } - - _statusBarOverlaysWebView = statusBarOverlaysWebView; -} - -- (BOOL) statusBarOverlaysWebView -{ - return _statusBarOverlaysWebView; -} - -- (void) overlaysWebView:(CDVInvokedUrlCommand*)command -{ - id value = [command.arguments objectAtIndex: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:UIStatusBarStyleBlackTranslucent]; -} - -- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command -{ - [self setStyleForStatusBar:UIStatusBarStyleBlackOpaque]; -} - -- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command -{ - id value = [command.arguments objectAtIndex: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.arguments objectAtIndex: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 -{ - 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) { - 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 -{ - 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; - sbBgFrame.size = CGSizeMake(statusBarFrame.size.height, statusBarFrame.size.width); - } else { - frame.origin.y = statusBarFrame.size.height; - 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; - } -} - -- (void) dealloc -{ - [[UIApplication sharedApplication] removeObserver:self forKeyPath:@"statusBarHidden"]; -} - - -@end diff --git a/src/wp/StatusBar.cs b/src/wp/StatusBar.cs deleted file mode 100644 index ec83ca8..0000000 --- a/src/wp/StatusBar.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* - 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. -*/ - - -using Microsoft.Phone.Shell; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Threading; -using System.Windows; -using System.Windows.Media; -using System.Windows.Threading; - - -/* - * http://www.idev101.com/code/User_Interface/StatusBar.html - * https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Bars.html - * https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/econst/UIStatusBarStyleDefault - * */ - - -namespace WPCordovaClassLib.Cordova.Commands -{ - public class StatusBar : BaseCommand - { - - // returns an argb value, if the hex is only rgb, it will be full opacity - protected Color ColorFromHex(string hexString) - { - string cleanHex = hexString.Replace("#", "").Replace("0x", ""); - // turn #FFF into #FFFFFF - if (cleanHex.Length == 3) - { - cleanHex = "" + cleanHex[0] + cleanHex[0] + cleanHex[1] + cleanHex[1] + cleanHex[2] + cleanHex[2]; - } - // add an alpha 100% if it is missing - if (cleanHex.Length == 6) - { - cleanHex = "FF" + cleanHex; - } - int argb = Int32.Parse(cleanHex, NumberStyles.HexNumber); - Color clr = Color.FromArgb((byte)((argb & 0xff000000) >> 0x18), - (byte)((argb & 0xff0000) >> 0x10), - (byte)((argb & 0xff00) >> 8), - (byte)(argb & 0xff)); - return clr; - } - - public void _ready(string options) - { - Deployment.Current.Dispatcher.BeginInvoke(() => - { - bool isVis = SystemTray.IsVisible; - // TODO: pass this to JS - //Debug.WriteLine("Result::" + res); - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isVis)); - }); - } - - public void overlaysWebView(string options) - { //exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]); - // string arg = JSON.JsonHelper.Deserialize(options)[0]; - } - - public void styleDefault(string options) - { //exec(null, null, "StatusBar", "styleDefault", []); - Deployment.Current.Dispatcher.BeginInvoke(() => - { - SystemTray.ForegroundColor = Colors.Black; - }); - } - - public void styleLightContent(string options) - { //exec(null, null, "StatusBar", "styleLightContent", []); - - Deployment.Current.Dispatcher.BeginInvoke(() => - { - SystemTray.ForegroundColor = Colors.White; - }); - } - - public void styleBlackTranslucent(string options) - { //exec(null, null, "StatusBar", "styleBlackTranslucent", []); - styleLightContent(options); - } - - public void styleBlackOpaque(string options) - { //exec(null, null, "StatusBar", "styleBlackOpaque", []); - styleLightContent(options); - } - - public void backgroundColorByName(string options) - { //exec(null, null, "StatusBar", "backgroundColorByName", [colorname]); - // this should NOT be called, js should now be using/converting color names to hex - } - - public void backgroundColorByHexString(string options) - { //exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]); - string argb = JSON.JsonHelper.Deserialize(options)[0]; - - Color clr = ColorFromHex(argb); - - Deployment.Current.Dispatcher.BeginInvoke(() => - { - SystemTray.Opacity = clr.A / 255.0d; - SystemTray.BackgroundColor = clr; - - }); - } - - public void hide(string options) - { //exec(null, null, "StatusBar", "hide", []); - Deployment.Current.Dispatcher.BeginInvoke(() => - { - SystemTray.IsVisible = false; - }); - - } - - public void show(string options) - { //exec(null, null, "StatusBar", "show", []); - Deployment.Current.Dispatcher.BeginInvoke(() => - { - SystemTray.IsVisible = true; - }); - } - } -} \ No newline at end of file diff --git a/www/statusbar.js b/www/statusbar.js deleted file mode 100644 index 53e89fd..0000000 --- a/www/statusbar.js +++ /dev/null @@ -1,103 +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. - * -*/ - -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.indexOf("#") < 0) { - hexString = "#" + hexString; - } - - if (hexString.length == 4) { - var split = hexString.split(""); - hexString = "#" + hexString[1] + hexString[1] + hexString[2] + hexString[2] + hexString[3] + hexString[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 -exec(function (res) { - StatusBar.isVisible = res; -}, null, "StatusBar", "_ready", []); - -module.exports = StatusBar;