From 93fb32122f2706988475e95a447588d08dea9a2e Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Wed, 20 Jan 2016 12:42:39 +0300 Subject: [PATCH] [ios] Bugs fixes. --- .../Login/MWMAuthorizationCommon.h | 2 + .../Login/MWMAuthorizationCommon.mm | 13 +++ .../Editor/MWMEditorTextTableViewCell.mm | 6 ++ .../Classes/Editor/MWMEditorViewController.mm | 26 ++---- ...MOpeningHoursDaysSelectorTableViewCell.xib | 86 ++++++++----------- iphone/Maps/Classes/MapViewController.mm | 34 ++++++++ iphone/Maps/Mapsme.storyboard | 48 +++++------ iphone/Maps/UIButton+RuntimeAttributes.mm | 5 ++ 8 files changed, 127 insertions(+), 93 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h index c4db7b324c..93f59e98dd 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h @@ -16,3 +16,5 @@ BOOL MWMAuthorizationHaveCredentials(); void MWMAuthorizationSetUserSkip(); BOOL MWMAuthorizationIsUserSkip(); +void MWMAuthorizationSetNeedCheck(BOOL needCheck); +BOOL MWMAuthorizationIsNeedCheck(); diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm index 49e80d45fc..72540b7191 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm @@ -6,6 +6,7 @@ namespace NSString * const kOSMRequestToken = @"OSMRequestToken"; NSString * const kOSMRequestSecret = @"OSMRequestSecret"; NSString * const kAuthUserSkip = @"AuthUserSkip"; +NSString * const kAuthNeedCheck = @"AuthNeedCheck"; } // namespace UIColor * MWMAuthorizationButtonTextColor(MWMAuthorizationButtonType type) @@ -76,3 +77,15 @@ BOOL MWMAuthorizationIsUserSkip() { return [[NSUserDefaults standardUserDefaults] objectForKey:kAuthUserSkip] != nil; } + +void MWMAuthorizationSetNeedCheck(BOOL needCheck) +{ + NSUserDefaults * ud = [NSUserDefaults standardUserDefaults]; + [ud setBool:needCheck forKey:kAuthNeedCheck]; + [ud synchronize]; +} + +BOOL MWMAuthorizationIsNeedCheck() +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:kAuthNeedCheck]; +} diff --git a/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm b/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm index 660a303983..cee438ebfb 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm +++ b/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm @@ -40,6 +40,12 @@ return YES; } +- (BOOL)textFieldShouldReturn:(UITextField *)textField +{ + [textField resignFirstResponder]; + return YES; +} + #pragma mark - Properties - (NSString *)text diff --git a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm index 9de22fa77b..3736cdcf78 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm @@ -1,5 +1,4 @@ #import "MWMAuthorizationCommon.h" -#import "MWMAuthorizationLoginViewController.h" #import "MWMCuisineEditorViewController.h" #import "MWMEditorCommon.h" #import "MWMEditorSelectTableViewCell.h" @@ -16,11 +15,9 @@ namespace { - NSString * const kOpeningHoursEditorSegue = @"Editor2OpeningHoursEditorSegue"; NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue"; NSString * const kStreetEditorSegue = @"Editor2StreetEditorSegue"; -NSString * const kAuthorizationSegue = @"Editor2AuthorizationSegue"; typedef NS_ENUM(NSUInteger, MWMEditorSection) { @@ -97,20 +94,9 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self checkAuthorization]; [self reloadData]; } -- (void)checkAuthorization -{ - if (!MWMAuthorizationHaveCredentials() && !MWMAuthorizationIsUserSkip()) - { - [[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime) - withParameters:@{kStatValue : kStatAuthorization}]; - [self performSegueWithIdentifier:kAuthorizationSegue sender:nil]; - } -} - #pragma mark - Configuration - (void)configNavBar @@ -140,7 +126,11 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) - (void)onSave { - [self.entity saveEditedCells:m_edited_cells]; + if (!m_edited_cells.empty()) + { + MWMAuthorizationSetNeedCheck(YES); + [self.entity saveEditedCells:m_edited_cells]; + } [self onCancel]; } @@ -573,12 +563,6 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) MWMStreetEditorViewController * dvc = segue.destinationViewController; dvc.delegate = self; } - else if ([segue.identifier isEqualToString:kAuthorizationSegue]) - { - UINavigationController * dvc = segue.destinationViewController; - MWMAuthorizationLoginViewController * authVC = (MWMAuthorizationLoginViewController *)[dvc topViewController]; - authVC.isCalledFromSettings = NO; - } } @end diff --git a/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursDaysSelectorTableViewCell.xib b/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursDaysSelectorTableViewCell.xib index dd8ca38479..8f4c5b63db 100644 --- a/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursDaysSelectorTableViewCell.xib +++ b/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursDaysSelectorTableViewCell.xib @@ -1,8 +1,8 @@ - + - + @@ -19,31 +19,30 @@ - + - + + + - @@ -62,31 +61,30 @@ - + - + + + - @@ -105,31 +103,30 @@ - + - + + + - @@ -148,31 +145,30 @@ - + - + + + - @@ -191,31 +187,30 @@ - + - + + + - @@ -234,31 +229,30 @@ - + - + + + - @@ -277,31 +271,30 @@ - + - + + + - @@ -317,7 +310,6 @@ - @@ -327,7 +319,6 @@ - @@ -362,7 +353,6 @@ - @@ -390,6 +380,6 @@ - + diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 5ad97f79b9..6cb17b5365 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -6,6 +6,8 @@ #import "MapViewController.h" #import "MWMAlertViewController.h" #import "MWMAPIBar.h" +#import "MWMAuthorizationCommon.h" +#import "MWMAuthorizationLoginViewController.h" #import "MWMEditorViewController.h" #import "MWMMapViewControlsManager.h" #import "MWMPageController.h" @@ -55,6 +57,11 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) UserTouchesActionScale }; +namespace +{ +NSString * const kAuthorizationSegue = @"Map2AuthorizationSegue"; +} // namespace + @interface NSValueWrapper : NSObject -(NSValue *)getInnerValue; @@ -410,6 +417,12 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) [self showWhatsNewIfNeeded]; } +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + [self checkAuthorization]; +} + - (void)viewDidLoad { [super viewDidLoad]; @@ -643,6 +656,19 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) [self.navigationController pushViewController:vc animated:YES]; } +#pragma mark - Authorization + +- (void)checkAuthorization +{ + if (MWMAuthorizationIsNeedCheck() && !MWMAuthorizationHaveCredentials() && !MWMAuthorizationIsUserSkip()) + { + [[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime) + withParameters:@{kStatValue : kStatAuthorization}]; + [self performSegueWithIdentifier:kAuthorizationSegue sender:nil]; + } + MWMAuthorizationSetNeedCheck(NO); +} + #pragma mark - 3d touch - (void)performAction:(NSString *)action @@ -796,6 +822,8 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) [[MapsAppDelegate theApp] enableStandby]; } +#pragma mark - Segue + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"Map2EditorSegue"]) @@ -805,6 +833,12 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) MWMEditorViewController * editorVC = (MWMEditorViewController *)[dvc topViewController]; editorVC.entity = sender; } + else if ([segue.identifier isEqualToString:kAuthorizationSegue]) + { + UINavigationController * dvc = segue.destinationViewController; + MWMAuthorizationLoginViewController * authVC = (MWMAuthorizationLoginViewController *)[dvc topViewController]; + authVC.isCalledFromSettings = NO; + } } #pragma mark - Properties diff --git a/iphone/Maps/Mapsme.storyboard b/iphone/Maps/Mapsme.storyboard index 5681a4fe01..0cc884b806 100644 --- a/iphone/Maps/Mapsme.storyboard +++ b/iphone/Maps/Mapsme.storyboard @@ -1,5 +1,5 @@ - + @@ -32,6 +32,7 @@ + @@ -68,10 +69,10 @@ - + - + - + - + - + - +