cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: [CB-2384] Add new iOS Project Setting to suppress the form accessory bar above the keyboard
Date Fri, 08 Mar 2013 06:14:22 GMT
Updated Branches:
  refs/heads/master 942d33c8e -> 97b89edfa


[CB-2384] Add new iOS Project Setting to suppress the form accessory bar above the keyboard


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/97b89edf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/97b89edf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/97b89edf

Branch: refs/heads/master
Commit: 97b89edfae3527828c0ca6bb2f6d58d9ded95188
Parents: 942d33c
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu Mar 7 22:14:15 2013 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu Mar 7 22:14:15 2013 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m       |   44 +++++++++++++++++++--
 CordovaLibTests/CordovaLibApp/config.xml     |    1 +
 bin/templates/project/__TESTING__/config.xml |    1 +
 3 files changed, 42 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/97b89edf/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 01ac317..dfeee6f 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -272,6 +272,10 @@
     if ([self.settings objectForKey:@"MediaPlaybackRequiresUserAction"]) {
         mediaPlaybackRequiresUserAction = [(NSNumber*)[settings objectForKey:@"MediaPlaybackRequiresUserAction"]
boolValue];
     }
+    BOOL hideKeyboardFormAccessoryBar = NO;  // default value
+    if ([self.settings objectForKey:@"HideKeyboardFormAccessoryBar"]) {
+        hideKeyboardFormAccessoryBar = [(NSNumber*)[settings objectForKey:@"HideKeyboardFormAccessoryBar"]
boolValue];
+    }
 
     self.webView.scalesPageToFit = [enableViewportScale boolValue];
 
@@ -284,12 +288,22 @@
         [[self.commandDelegate getCommandInstance:@"Geolocation"] getLocation:[CDVInvokedUrlCommand
new]];
     }
 
+    if (hideKeyboardFormAccessoryBar) {
+        [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification
+                                                          object:nil
+                                                           queue:[NSOperationQueue mainQueue]
+                                                      usingBlock:^(NSNotification * notification)
{
+                // we can't hide it here because the accessory bar hasn't been created yet,
so we delay on the queue
+                [self performSelector:@selector(hideKeyboardFormAccessoryBar) withObject:nil
afterDelay:0];
+            }];
+    }
+
     /*
      * Fire up CDVLocalStorage to work-around WebKit storage limitations: on all iOS 5.1+
versions for local-only backups, but only needed on iOS 5.1 for cloud backup.
      */
-    if (IsAtLeastiOSVersion(@"5.1") && (([backupWebStorageType isEqualToString:@"local"])
||
-            ([backupWebStorageType isEqualToString:@"cloud"] && !IsAtLeastiOSVersion(@"6.0"))))
{
-        [self registerPlugin:[[CDVLocalStorage alloc] initWithWebView:self.webView] withClassName:NSStringFromClass([CDVLocalStorage
class])];
+    if (IsAtLeastiOSVersion (@"5.1") && (([backupWebStorageType isEqualToString:@"local"])
||
+            ([backupWebStorageType isEqualToString:@"cloud"] && !IsAtLeastiOSVersion
(@"6.0")))) {
+        [self registerPlugin:[[CDVLocalStorage alloc] initWithWebView:self.webView] withClassName:NSStringFromClass
([CDVLocalStorage class])];
     }
 
     /*
@@ -323,7 +337,7 @@
     /*
      * iOS 6.0 UIWebView properties
      */
-    if (IsAtLeastiOSVersion(@"6.0")) {
+    if (IsAtLeastiOSVersion (@"6.0")) {
         BOOL keyboardDisplayRequiresUserAction = YES; // KeyboardDisplayRequiresUserAction
- defaults to YES
         if ([self.settings objectForKey:@"KeyboardDisplayRequiresUserAction"] != nil) {
             if ([self.settings objectForKey:@"KeyboardDisplayRequiresUserAction"]) {
@@ -372,6 +386,28 @@
         }];
 }
 
+- (void)hideKeyboardFormAccessoryBar
+{
+    NSArray* windows = [[UIApplication sharedApplication] windows];
+
+    for (UIWindow* window in windows) {
+        for (UIView* view in window.subviews) {
+            if ([[view description] hasPrefix:@"<UIPeripheralHostView"]) {
+                for (UIView* peripheralView in view.subviews) {
+                    // hides the accessory bar
+                    if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"])
{
+                        [peripheralView setHidden:YES];
+                    }
+                    // hides the thin grey line used to adorn the bar (iOS 6)
+                    if ([[peripheralView description] hasPrefix:@"<UIImageView"]) {
+                        [[peripheralView layer] setOpacity:0.0];
+                    }
+                }
+            }
+        }
+    }
+}
+
 - (NSArray*)parseInterfaceOrientations:(NSArray*)orientations
 {
     NSMutableArray* result = [[NSMutableArray alloc] init];

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/97b89edf/CordovaLibTests/CordovaLibApp/config.xml
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CordovaLibApp/config.xml b/CordovaLibTests/CordovaLibApp/config.xml
index af311b6..64c96fe 100644
--- a/CordovaLibTests/CordovaLibApp/config.xml
+++ b/CordovaLibTests/CordovaLibApp/config.xml
@@ -13,6 +13,7 @@
     <preference name="MediaPlaybackRequiresUserAction" value="false" />
     <preference name="AllowInlineMediaPlayback" value="false" />
     <preference name="BackupWebStorage" value="cloud" />
+    <preference name="HideKeyboardFormAccessoryBar" value="false" />
 
     <plugins>
         <plugin name="LocalStorage" value="CDVLocalStorage" />

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/97b89edf/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 04260aa..d307827 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -34,6 +34,7 @@
     <preference name="SuppressesIncrementalRendering" value="false" />
     <preference name="TopActivityIndicator" value="gray" />
     <preference name="UIWebViewBounce" value="true" />
+    <preference name="HideKeyboardFormAccessoryBar" value="false" />
 
     <content src="index.html" />
 


Mime
View raw message