You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/07/15 04:56:56 UTC
[1/3] git commit: ios: Fix hide to adjust webview's frame only when
status bar is not overlaying webview
Repository: cordova-plugin-statusbar
Updated Branches:
refs/heads/master ccb465f80 -> be8a3e594
ios: Fix hide to adjust webview's frame only when status bar is not overlaying webview
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/6552bddf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/6552bddf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/6552bddf
Branch: refs/heads/master
Commit: 6552bddfd1083dff8a13c165ed8c68476b332ee6
Parents: ccb465f
Author: Tiancheng Zhu <ph...@gmail.com>
Authored: Thu Apr 10 16:25:47 2014 -0700
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 22:56:06 2014 -0400
----------------------------------------------------------------------
src/ios/CDVStatusBar.m | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/6552bddf/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index e954a54..e773397 100644
--- a/src/ios/CDVStatusBar.m
+++ b/src/ios/CDVStatusBar.m
@@ -327,11 +327,12 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
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;
+ if (!self.statusBarOverlaysWebView) {
+ if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
+ frame.size.height += statusBarFrame.size.width;
+ } else {
+ frame.size.height += statusBarFrame.size.height;
+ }
}
self.webView.frame = frame;
[2/3] git commit: CB-6626 ios: Add a JS event for tapping on statusbar
Posted by ag...@apache.org.
CB-6626 ios: Add a JS event for tapping on statusbar
close #4
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/f0031ca2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/f0031ca2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/f0031ca2
Branch: refs/heads/master
Commit: f0031ca2b4d778d8feea1959ec1fd8773ad39872
Parents: 6552bdd
Author: Tiancheng Zhu <ph...@gmail.com>
Authored: Thu Apr 10 16:56:24 2014 -0700
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 22:56:21 2014 -0400
----------------------------------------------------------------------
src/ios/CDVStatusBar.m | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/f0031ca2/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index e773397..98f2285 100644
--- a/src/ios/CDVStatusBar.m
+++ b/src/ios/CDVStatusBar.m
@@ -70,6 +70,10 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
@end
+@interface CDVStatusBar () <
+ UIScrollViewDelegate>
+@end
+
@implementation CDVStatusBar
- (id)settingForKey:(NSString*)key
@@ -120,6 +124,16 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
if ([self settingForKey:setting]) {
[self setStatusBarStyle:[self settingForKey:setting]];
}
+
+ // 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;
+ [self.viewController.view addSubview:fakeScrollView]; // Add scrollview to the view heirarchy so that it will begin accepting status bar taps
+ [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
}
- (void) _ready:(CDVInvokedUrlCommand*)command
@@ -411,4 +425,12 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
}
+#pragma mark - UIScrollViewDelegate
+
+- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
+{
+ [self.webView stringByEvaluatingJavaScriptFromString:@"var evt = document.createEvent(\"Event\"); evt.initEvent(\"statusTap\",true,true); window.dispatchEvent(evt);"];
+ return NO;
+}
+
@end
[3/3] git commit: ios: Use a persistent callbackId instead of calling
sendJs
Posted by ag...@apache.org.
ios: Use a persistent callbackId instead of calling sendJs
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/be8a3e59
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/be8a3e59
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/be8a3e59
Branch: refs/heads/master
Commit: be8a3e5947e5ad47e602cd0064e0ce9442177729
Parents: f0031ca
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 22:55:04 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 22:56:42 2014 -0400
----------------------------------------------------------------------
src/ios/CDVStatusBar.h | 4 +---
src/ios/CDVStatusBar.m | 39 +++++++++++++++++++++++++++++++--------
www/statusbar.js | 8 +++++++-
3 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/be8a3e59/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h
index df48d2d..84f37fa 100644
--- a/src/ios/CDVStatusBar.h
+++ b/src/ios/CDVStatusBar.h
@@ -23,12 +23,10 @@
@interface CDVStatusBar : CDVPlugin {
@protected
BOOL _statusBarOverlaysWebView;
- @protected
UIView* _statusBarBackgroundView;
- @protected
BOOL _uiviewControllerBasedStatusBarAppearance;
- @protected
UIColor* _statusBarBackgroundColor;
+ NSString* _eventsCallbackId;
}
@property (atomic, assign) BOOL statusBarOverlaysWebView;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/be8a3e59/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index 98f2285..8b6666e 100644
--- a/src/ios/CDVStatusBar.m
+++ b/src/ios/CDVStatusBar.m
@@ -70,8 +70,9 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
@end
-@interface CDVStatusBar () <
- UIScrollViewDelegate>
+@interface CDVStatusBar () <UIScrollViewDelegate>
+- (void)fireTappedEvent;
+- (void)updateIsVisible:(BOOL)visible;
@end
@implementation CDVStatusBar
@@ -85,9 +86,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
{
if ([keyPath isEqual:@"statusBarHidden"]) {
NSNumber* newValue = [change objectForKey:NSKeyValueChangeNewKey];
- BOOL boolValue = [newValue boolValue];
-
- [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", boolValue? @"false" : @"true" ]];
+ [self updateIsVisible:![newValue boolValue]];
}
}
@@ -136,10 +135,34 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
fakeScrollView.contentOffset = CGPointMake(0.0f, UIScreen.mainScreen.bounds.size.height); // Scroll down so a tap will take scroll view back to the top
}
+- (void)onReset {
+ _eventsCallbackId = nil;
+}
+
+- (void)fireTappedEvent {
+ if (_eventsCallbackId == nil) {
+ return;
+ }
+ NSDictionary* payload = @{@"type": @"tap"};
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:payload];
+ [result setKeepCallbackAsBool:YES];
+ [self.commandDelegate sendPluginResult:result callbackId:_eventsCallbackId];
+}
+
+- (void)updateIsVisible:(BOOL)visible {
+ if (_eventsCallbackId == nil) {
+ return;
+ }
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:visible];
+ [result setKeepCallbackAsBool:YES];
+ [self.commandDelegate sendPluginResult:result callbackId:_eventsCallbackId];
+}
+
+
- (void) _ready:(CDVInvokedUrlCommand*)command
{
- // set the initial value
- [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", [UIApplication sharedApplication].statusBarHidden? @"false" : @"true" ]];
+ _eventsCallbackId = command.callbackId;
+ [self updateIsVisible:![UIApplication sharedApplication].statusBarHidden];
}
- (void) initializeStatusBarBackgroundView
@@ -429,7 +452,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
{
- [self.webView stringByEvaluatingJavaScriptFromString:@"var evt = document.createEvent(\"Event\"); evt.initEvent(\"statusTap\",true,true); window.dispatchEvent(evt);"];
+ [self fireTappedEvent];
return NO;
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/be8a3e59/www/statusbar.js
----------------------------------------------------------------------
diff --git a/www/statusbar.js b/www/statusbar.js
index 53e89fd..63967a9 100644
--- a/www/statusbar.js
+++ b/www/statusbar.js
@@ -97,7 +97,13 @@ var StatusBar = {
// prime it
exec(function (res) {
- StatusBar.isVisible = res;
+ if (typeof res == 'object') {
+ if (res.type == 'tap') {
+ cordova.fireWindowEvent('statusTap');
+ }
+ } else {
+ StatusBar.isVisible = res;
+ }
}, null, "StatusBar", "_ready", []);
module.exports = StatusBar;