diff --git a/clients/ios/Classes/DashboardViewController.m b/clients/ios/Classes/DashboardViewController.m index 2f6062e6f..5d1014a4c 100644 --- a/clients/ios/Classes/DashboardViewController.m +++ b/clients/ios/Classes/DashboardViewController.m @@ -93,6 +93,11 @@ return YES; } +// allow keyboard comands +- (BOOL)canBecomeFirstResponder { + return YES; +} + - (IBAction)doLogout:(id)sender { [appDelegate confirmLogout]; } diff --git a/clients/ios/Classes/FeedsMenuViewController.m b/clients/ios/Classes/FeedsMenuViewController.m index 2d0a2c281..20d424e96 100644 --- a/clients/ios/Classes/FeedsMenuViewController.m +++ b/clients/ios/Classes/FeedsMenuViewController.m @@ -91,6 +91,11 @@ return YES; } +// allow keyboard comands +- (BOOL)canBecomeFirstResponder { + return YES; +} + #pragma mark - #pragma mark - Table view data source diff --git a/clients/ios/Classes/FontSettingsViewController.m b/clients/ios/Classes/FontSettingsViewController.m index f2f08ec60..aa22df49b 100644 --- a/clients/ios/Classes/FontSettingsViewController.m +++ b/clients/ios/Classes/FontSettingsViewController.m @@ -39,7 +39,6 @@ self.menuTableView.backgroundColor = UIColorFromRGB(0xECEEEA); self.menuTableView.separatorColor = UIColorFromRGB(0x909090); - self.modalPresentationStyle = UIModalPresentationPopover; } - (void)viewWillAppear:(BOOL)animated { @@ -117,6 +116,11 @@ return YES; } +// allow keyboard comands +- (BOOL)canBecomeFirstResponder { + return YES; +} + - (void)debugOutputFontNames { NSLog(@"Debugging font names"); for (NSString *family in [[UIFont familyNames] sortedArrayUsingSelector:@selector(compare:)]) { diff --git a/clients/ios/Classes/MarkReadMenuViewController.m b/clients/ios/Classes/MarkReadMenuViewController.m index a6026138b..edad71209 100644 --- a/clients/ios/Classes/MarkReadMenuViewController.m +++ b/clients/ios/Classes/MarkReadMenuViewController.m @@ -62,6 +62,11 @@ typedef NS_ENUM(NSUInteger, MarkReadMenuOlderNewerMode) } } +// allow keyboard comands +- (BOOL)canBecomeFirstResponder { + return YES; +} + - (CGSize)preferredContentSize { CGSize size = CGSizeMake(300.0, 190.0); diff --git a/clients/ios/Classes/MenuViewController.m b/clients/ios/Classes/MenuViewController.m index 3bc75f6c6..ef3587a59 100644 --- a/clients/ios/Classes/MenuViewController.m +++ b/clients/ios/Classes/MenuViewController.m @@ -55,6 +55,11 @@ NSString * const MenuHandler = @"handler"; self.menuTableView.scrollEnabled = self.preferredContentSize.height > self.view.frame.size.height; } +// allow keyboard comands +- (BOOL)canBecomeFirstResponder { + return YES; +} + - (CGSize)preferredContentSize { CGSize size = CGSizeMake(100.0, 0.0); UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0]; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index e4b5658ee..79786f7c5 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -63,6 +63,7 @@ #import "NBActivityItemProvider.h" #import "NSNull+JSON.h" #import "UISearchBar+Field.h" +#import "UIViewController+HidePopover.h" #import @interface NewsBlurAppDelegate () @@ -2146,20 +2147,8 @@ self.markReadMenuViewController.olderNewerStory = olderNewerStory; self.markReadMenuViewController.extraItems = extraItems; self.markReadMenuViewController.completionHandler = completionHandler; - - UIPopoverPresentationController *popoverPresentationController = self.markReadMenuViewController.popoverPresentationController; - popoverPresentationController.delegate = self; - popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny; - popoverPresentationController.backgroundColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR); - - if (barButtonItem) { - popoverPresentationController.barButtonItem = barButtonItem; - } else { - popoverPresentationController.sourceView = sourceView; - popoverPresentationController.sourceRect = sourceRect; - } - - [self.navigationController presentViewController:self.markReadMenuViewController animated:YES completion:nil]; + + [self showPopoverWithViewController:self.markReadMenuViewController contentSize:CGSizeZero barButtonItem:barButtonItem sourceView:sourceView sourceRect:sourceRect permittedArrowDirections:UIPopoverArrowDirectionAny]; } - (void)showPopoverWithViewController:(UIViewController *)viewController contentSize:(CGSize)contentSize barButtonItem:(UIBarButtonItem *)barButtonItem { @@ -2183,7 +2172,9 @@ viewController.modalPresentationStyle = UIModalPresentationPopover; viewController.preferredContentSize = contentSize; - + [viewController addKeyCommand:[UIKeyCommand keyCommandWithInput:@"." modifierFlags:UIKeyModifierCommand action:@selector(hidePopover)]]; + [viewController addKeyCommand:[UIKeyCommand keyCommandWithInput:UIKeyInputEscape modifierFlags:0 action:@selector(hidePopover)]]; + UIPopoverPresentationController *popoverPresentationController = viewController.popoverPresentationController; popoverPresentationController.delegate = self; popoverPresentationController.backgroundColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR); @@ -2198,6 +2189,8 @@ [self.navigationControllerForPopover presentViewController:viewController animated:YES completion:^{ popoverPresentationController.passthroughViews = nil; + // NSLog(@"%@ canBecomeFirstResponder? %d", viewController, viewController.canBecomeFirstResponder); + [viewController becomeFirstResponder]; }]; } diff --git a/clients/ios/Classes/StoryPageControl.m b/clients/ios/Classes/StoryPageControl.m index e6d4c0a8d..36b5c5680 100644 --- a/clients/ios/Classes/StoryPageControl.m +++ b/clients/ios/Classes/StoryPageControl.m @@ -1147,17 +1147,10 @@ - (IBAction)toggleFontSize:(id)sender { - [self.appDelegate.fontSettingsNavigationController popToRootViewControllerAnimated:NO]; - self.appDelegate.fontSettingsNavigationController.modalPresentationStyle = UIModalPresentationPopover; - UIPopoverPresentationController *popPC = self.appDelegate.fontSettingsNavigationController.popoverPresentationController; - popPC.permittedArrowDirections = UIPopoverArrowDirectionAny; - popPC.backgroundColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR); - popPC.delegate = self; - popPC.barButtonItem = self.fontSettingsButton; -// popPC.sourceView = self.view; -// popPC.sourceRect = [sender frame]; - - [self presentViewController:self.appDelegate.fontSettingsNavigationController animated:YES completion:nil]; + UINavigationController *fontSettingsNavigationController = self.appDelegate.fontSettingsNavigationController; + + [fontSettingsNavigationController popToRootViewControllerAnimated:NO]; + [self.appDelegate showPopoverWithViewController:fontSettingsNavigationController contentSize:CGSizeZero barButtonItem:self.fontSettingsButton]; } - (void)setFontStyle:(NSString *)fontStyle { @@ -1274,10 +1267,4 @@ } } -#pragma mark - UIPopoverPresentationControllerDelegate - -- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller { - return UIModalPresentationNone; -} - @end diff --git a/clients/ios/Classes/UserProfileViewController.m b/clients/ios/Classes/UserProfileViewController.m index 9fe38a3e9..6a0596946 100644 --- a/clients/ios/Classes/UserProfileViewController.m +++ b/clients/ios/Classes/UserProfileViewController.m @@ -89,6 +89,11 @@ [self.profileTable reloadData]; } +// allow keyboard comands +- (BOOL)canBecomeFirstResponder { + return YES; +} + - (void)doCancelButton { [appDelegate.modalNavigationController dismissViewControllerAnimated:NO completion:nil]; } diff --git a/clients/ios/NewsBlur.xcodeproj/project.pbxproj b/clients/ios/NewsBlur.xcodeproj/project.pbxproj index d93b164bf..4f9191415 100755 --- a/clients/ios/NewsBlur.xcodeproj/project.pbxproj +++ b/clients/ios/NewsBlur.xcodeproj/project.pbxproj @@ -213,6 +213,7 @@ 784B50ED127E3F68008F90EA /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 784B50EB127E3F68008F90EA /* LoginViewController.m */; }; 787A0CDB11CE65330056422D /* FeedDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 787A0CD911CE65330056422D /* FeedDetailViewController.m */; }; 788EF356127E5BC80088EDC5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 788EF355127E5BC80088EDC5 /* QuartzCore.framework */; }; + E160F0571C9DAC2C00CB96DF /* UIViewController+HidePopover.m in Sources */ = {isa = PBXBuildFile; fileRef = E160F0561C9DAC2C00CB96DF /* UIViewController+HidePopover.m */; }; E1D123FE1C66753D00434F40 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = E1D123FD1C66753D00434F40 /* Localizable.stringsdict */; }; FF03AFE419F87A770063002A /* g_icn_folder_read.png in Resources */ = {isa = PBXBuildFile; fileRef = FF03AFE219F87A770063002A /* g_icn_folder_read.png */; }; FF03AFE519F87A770063002A /* g_icn_folder_read@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF03AFE319F87A770063002A /* g_icn_folder_read@2x.png */; }; @@ -806,6 +807,8 @@ 787A0CD911CE65330056422D /* FeedDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = FeedDetailViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 788EF355127E5BC80088EDC5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 8D1107310486CEB800E47090 /* NewsBlur-iPhone-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "NewsBlur-iPhone-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; + E160F0551C9DAC2C00CB96DF /* UIViewController+HidePopover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIViewController+HidePopover.h"; path = "Other Sources/UIViewController+HidePopover.h"; sourceTree = ""; }; + E160F0561C9DAC2C00CB96DF /* UIViewController+HidePopover.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+HidePopover.m"; path = "Other Sources/UIViewController+HidePopover.m"; sourceTree = ""; }; E1D123FD1C66753D00434F40 /* Localizable.stringsdict */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.stringsdict; path = Localizable.stringsdict; sourceTree = ""; }; FF03AFE219F87A770063002A /* g_icn_folder_read.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = g_icn_folder_read.png; sourceTree = ""; }; FF03AFE319F87A770063002A /* g_icn_folder_read@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "g_icn_folder_read@2x.png"; sourceTree = ""; }; @@ -1429,6 +1432,8 @@ 43A4C3D615B00966008787B5 /* UIView+TKCategory.m */, FFA0484219CA73B700618DC4 /* UIView+ViewController.h */, FFA0484319CA73B700618DC4 /* UIView+ViewController.m */, + E160F0551C9DAC2C00CB96DF /* UIViewController+HidePopover.h */, + E160F0561C9DAC2C00CB96DF /* UIViewController+HidePopover.m */, FF4151BE16DED9660013E84B /* UIBarButtonItem+Image.h */, FF4151BF16DED9660013E84B /* UIBarButtonItem+Image.m */, 17C495491C129863004805A7 /* UISearchBar+Field.h */, @@ -2929,6 +2934,7 @@ FF2EB7BA1AA65504002549A7 /* IASKPSSliderSpecifierViewCell.m in Sources */, 43CE0F5F15DADB7F00608ED8 /* SiteCell.m in Sources */, FFA045B419CA49D700618DC4 /* SloppySwiper.m in Sources */, + E160F0571C9DAC2C00CB96DF /* UIViewController+HidePopover.m in Sources */, FFDE35CC161B8F870034BFDE /* FolderTitleView.m in Sources */, FFDE35DA161D12250034BFDE /* UnreadCountView.m in Sources */, FFDE35EA162799B90034BFDE /* FeedDetailMenuViewController.m in Sources */, diff --git a/clients/ios/Other Sources/UIViewController+HidePopover.h b/clients/ios/Other Sources/UIViewController+HidePopover.h new file mode 100644 index 000000000..fde52b6dd --- /dev/null +++ b/clients/ios/Other Sources/UIViewController+HidePopover.h @@ -0,0 +1,15 @@ +// +// UIViewController+HidePopover.h +// NewsBlur +// +// Created by Nicholas Riley on 3/19/16. +// Copyright © 2016 NewsBlur. All rights reserved. +// + +#import + +@interface UIViewController (HidePopover) + +- (void)hidePopover; + +@end diff --git a/clients/ios/Other Sources/UIViewController+HidePopover.m b/clients/ios/Other Sources/UIViewController+HidePopover.m new file mode 100644 index 000000000..883563105 --- /dev/null +++ b/clients/ios/Other Sources/UIViewController+HidePopover.m @@ -0,0 +1,18 @@ +// +// UIViewController+Dismiss.m +// NewsBlur +// +// Created by Nicholas Riley on 3/19/16. +// Copyright © 2016 NewsBlur. All rights reserved. +// + +#import "UIViewController+HidePopover.h" +#import "NewsBlurAppDelegate.h" + +@implementation UIViewController (HidePopover) + +- (void)hidePopover { + [(NewsBlurAppDelegate *)[UIApplication sharedApplication].delegate hidePopover]; +} + +@end