Skip to content

Commit

Permalink
Merge pull request #134 from Automattic/develop
Browse files Browse the repository at this point in the history
Simplenote Mark 4.4.3
  • Loading branch information
jleandroperez authored Feb 19, 2017
2 parents 43a2fee + f1bd2bf commit 57e7d3f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 24 deletions.
8 changes: 0 additions & 8 deletions Simplenote/Classes/SPNoteEditorViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ - (instancetype)init {
selector:@selector(didReceiveVoiceOverNotification:)
name:UIAccessibilityVoiceOverStatusChanged
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
}

return self;
Expand Down Expand Up @@ -286,10 +282,6 @@ - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withT
[self refreshNavBarSizeWithCoordinator:coordinator];
}

- (void)applicationWillResignActive:(NSNotification *)notification {
[self dismissActivityView];
}

- (void)refreshNavBarSizeWithCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[self resetNavigationBarToIdentityWithAnimation:YES completion:nil];
Expand Down
1 change: 1 addition & 0 deletions Simplenote/Classes/SPTagsListViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@

@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;

- (void)removeKeyboardObservers;

@end
26 changes: 19 additions & 7 deletions Simplenote/Classes/SPTagsListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ - (void)viewDidLoad
forCellReuseIdentifier:cellWithIconIdentifier];
[self.tableView setTableHeaderView:[self buildTableHeaderView]];

// Register for keyboard notifications
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

_tagImage = [[UIImage imageNamed:@"icon_tag"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_settingsImage = [[UIImage imageNamed:@"icon_settings"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_allNotesImage = [[UIImage imageNamed:@"icon_allnotes"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
Expand All @@ -124,6 +119,7 @@ - (void)viewDidLoad
[[UIMenuController sharedMenuController] setMenuItems:@[renameItem]];
[[UIMenuController sharedMenuController] update];

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(menuDidChangeVisibility:) name:UIMenuControllerDidHideMenuNotification object:nil];
[nc addObserver:self selector:@selector(menuDidChangeVisibility:) name:UIMenuControllerDidShowMenuNotification object:nil];

Expand All @@ -133,6 +129,11 @@ - (void)viewDidLoad
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

// Register for keyboard notifications
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

CGRect tableViewFrame = self.tableView.frame;
tableViewFrame.size.height = self.view.frame.size.height - SPSettingsButtonHeight;
Expand All @@ -146,6 +147,19 @@ - (void)viewWillAppear:(BOOL)animated
[self updateHeaderButtonHighlight];
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];

[self removeKeyboardObservers];
}

- (void)removeKeyboardObservers
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver: self name:UIKeyboardWillHideNotification object:nil];
[nc removeObserver: self name:UIKeyboardWillShowNotification object:nil];
}

- (VSTheme *)theme {

return [[VSThemeManager sharedManager] theme];
Expand Down Expand Up @@ -733,7 +747,6 @@ - (void)delayedReloadData {
#pragma mark KeyboardNotifications

- (void)keyboardWillShow:(NSNotification *)notification {

CGRect keyboardFrame = [(NSValue *)[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

CGFloat keyboardHeight = MIN(keyboardFrame.size.height, keyboardFrame.size.width);
Expand All @@ -750,7 +763,6 @@ - (void)keyboardWillShow:(NSNotification *)notification {
}

- (void)keyboardWillHide:(NSNotification *)notification {

CGRect newFrame = self.tableView.frame;
newFrame.size.height = self.view.superview.frame.size.height - self.view.frame.origin.y - SPSettingsButtonHeight;

Expand Down
1 change: 1 addition & 0 deletions Simplenote/SPAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@interface SPAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow *pinLockWindow;

@property (strong, nonatomic, readonly) Simperium *simperium;
@property (strong, nonatomic, readonly) NSManagedObjectContext *managedObjectContext;
Expand Down
31 changes: 28 additions & 3 deletions Simplenote/SPAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#import "GAI.h"
#import "SPTracker.h"

@import Contacts;
@import SSKeychain;
@import Simperium;
@import WordPress_AppbotX;
Expand Down Expand Up @@ -325,6 +326,7 @@ - (void)onboardingDidFinish:(NSNotification *)notification

- (void)applicationWillResignActive:(UIApplication *)application
{
[self.tagListViewController removeKeyboardObservers];
[self showPasscodeLockIfNecessary];
UIViewController *viewController = self.window.rootViewController;
[viewController.view setNeedsLayout];
Expand Down Expand Up @@ -850,7 +852,7 @@ -(void)showPasscodeLockIfNecessary

NSString *pin = [self getPin:YES];

if (!pin || pin.length == 0 || [[self topMostController] class] == [DTPinLockController class]) {
if (!pin || pin.length == 0 || [self isPresentingPinLock] || [self isRequestingContactsPermission]) {
return;
}

Expand All @@ -861,13 +863,21 @@ -(void)showPasscodeLockIfNecessary
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

// no animation to cover up app right away
[[self topMostController] presentViewController:controller animated:NO completion:nil];
self.pinLockWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.pinLockWindow.rootViewController = controller;
[self.pinLockWindow makeKeyAndVisible];
[controller fixLayout];
}

- (void)pinLockControllerDidFinishUnlocking
{
[[self topMostController] dismissViewControllerAnimated:YES completion:nil];
[UIView animateWithDuration:0.3
animations:^{ self.pinLockWindow.alpha = 0.0; }
completion:^(BOOL finished) {
[self.window makeKeyAndVisible];
[self.pinLockWindow removeFromSuperview];
self.pinLockWindow = nil;
}];
}

- (NSString *)getPin:(BOOL)checkLegacy
Expand Down Expand Up @@ -896,6 +906,7 @@ - (void)setPin:(NSString *)newPin
- (void)removePin
{
[SSKeychain deletePasswordForService:kSimplenotePinKey account:kSimplenotePinKey];
[self setAllowTouchIDInsteadOfPin:NO];
}

- (BOOL)allowTouchIDInsteadOfPin
Expand All @@ -913,6 +924,20 @@ - (void)setAllowTouchIDInsteadOfPin:(BOOL)allowTouchIDInsteadOfPin
[userDefaults synchronize];
}

- (BOOL)isPresentingPinLock
{
return self.pinLockWindow && [self.pinLockWindow isKeyWindow];
}

-(BOOL)isRequestingContactsPermission
{
NSArray *topChildren = self.topMostController.childViewControllers;
BOOL isShowingCollaborators = [topChildren count] > 0 && [topChildren[0] isKindOfClass:[SPAddCollaboratorsViewController class]];
BOOL isNotDeterminedAuth = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts] == CNAuthorizationStatusNotDetermined;

return isShowingCollaborators && isNotDeterminedAuth;
}


#pragma mark ================================================================================
#pragma mark App Tracking
Expand Down
8 changes: 4 additions & 4 deletions Simplenote/Simplenote-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.4.2</string>
<string>4.4.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>4423</string>
<string>4430</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down Expand Up @@ -60,10 +60,10 @@
</dict>
<key>NSContactsUsageDescription</key>
<string>This app requires contacts access to properly share data with other users.</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app does not require Photo Library access.</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
4 changes: 2 additions & 2 deletions SimplenoteShare/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>4.4.2</string>
<string>4.4.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>4423</string>
<string>4430</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down

0 comments on commit 57e7d3f

Please sign in to comment.