forked from organicmaps/organicmaps
[ios] Fixed duplicate alerts display issue. (#4578)
This commit is contained in:
parent
9f0137188b
commit
4223ab0124
13 changed files with 58 additions and 63 deletions
|
@ -49,7 +49,7 @@
|
|||
- (void)presentOsmAuthAlert;
|
||||
- (void)presentPersonalInfoWarningAlertWithBlock:(nonnull TMWMVoidBlock)block;
|
||||
- (void)presentTrackWarningAlertWithCancelBlock:(nonnull TMWMVoidBlock)block;
|
||||
- (void)closeAlert;
|
||||
- (void)closeAlert:(nullable TMWMVoidBlock)completion;
|
||||
|
||||
- (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
+ (nonnull instancetype) new __attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
|
|
|
@ -219,7 +219,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[MapsAppDelegate.theApp.window endEditing:YES];
|
||||
}
|
||||
|
||||
- (void)closeAlert
|
||||
- (void)closeAlert:(nullable TMWMVoidBlock)completion
|
||||
{
|
||||
NSArray * subviews = self.view.subviews;
|
||||
MWMAlert * closeAlert = subviews.lastObject;
|
||||
|
@ -241,6 +241,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self.view removeFromSuperview];
|
||||
[self removeFromParentViewController];
|
||||
}
|
||||
if (completion)
|
||||
completion();
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ using TMWMDownloadBlock = void (^)(storage::TCountriesVec const &, TMWMVoidBlock
|
|||
+ (MWMAlert *)osmAuthAlert;
|
||||
+ (MWMAlert *)personalInfoWarningAlertWithBlock:(TMWMVoidBlock)block;
|
||||
+ (MWMAlert *)trackWarningAlertWithCancelBlock:(TMWMVoidBlock)block;
|
||||
- (void)close;
|
||||
- (void)close:(TMWMVoidBlock)completion;
|
||||
|
||||
- (void)setNeedsCloseAlertAfterEnterBackground;
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation;
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
// Should override this method if you want custom relayout after rotation.
|
||||
}
|
||||
|
||||
- (void)close { [self.alertController closeAlert]; }
|
||||
- (void)close:(TMWMVoidBlock)completion { [self.alertController closeAlert:completion]; }
|
||||
- (void)setNeedsCloseAlertAfterEnterBackground
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
|
@ -172,7 +172,7 @@
|
|||
- (void)applicationDidEnterBackground
|
||||
{
|
||||
// Should close alert when application entered background.
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
- (void)rotate:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
||||
|
|
|
@ -424,17 +424,13 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
|
|||
- (IBAction)rightButtonTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatApply}];
|
||||
if (self.rightButtonAction)
|
||||
self.rightButtonAction();
|
||||
[self close];
|
||||
[self close:self.rightButtonAction];
|
||||
}
|
||||
|
||||
- (IBAction)leftButtonTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
if (self.leftButtonAction)
|
||||
self.leftButtonAction();
|
||||
[self close];
|
||||
[self close:self.leftButtonAction];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -139,16 +139,13 @@ CGFloat const kAnimationDuration = .05;
|
|||
if (s.CheckFailedCountries(m_countries))
|
||||
{
|
||||
if (p.IsAutoRetryDownloadFailed())
|
||||
[self close];
|
||||
[self close:nil];
|
||||
return;
|
||||
}
|
||||
auto const overallProgress = s.GetOverallProgress(m_countries);
|
||||
// Test if downloading has finished by comparing downloaded and total sizes.
|
||||
if (overallProgress.first == overallProgress.second)
|
||||
{
|
||||
self.downloadCompleteBlock();
|
||||
[self close];
|
||||
}
|
||||
[self close:self.downloadCompleteBlock];
|
||||
}
|
||||
|
||||
- (void)processCountry:(TCountryId const &)countryId progress:(MapFilesDownloader::TProgress const &)progress
|
||||
|
@ -164,8 +161,7 @@ CGFloat const kAnimationDuration = .05;
|
|||
- (IBAction)cancelButtonTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
self.cancelBlock();
|
||||
[self close];
|
||||
[self close:self.cancelBlock];
|
||||
}
|
||||
|
||||
- (IBAction)downloadButtonTap
|
||||
|
|
|
@ -32,7 +32,7 @@ static NSString * const kStatisticsEvent = @"Facebook Alert";
|
|||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatApply}];
|
||||
[Alohalytics logEvent:kFacebookInviteEventName withValue:@"shareTap"];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kUDAlreadySharedKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
|
@ -46,7 +46,7 @@ static NSString * const kStatisticsEvent = @"Facebook Alert";
|
|||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
[Alohalytics logEvent:kFacebookInviteEventName withValue:@"notNowTap"];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -25,22 +25,18 @@ static NSString * const kStatisticsEvent = @"Location Alert";
|
|||
- (IBAction)settingsTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatApply}];
|
||||
[self openSettings];
|
||||
[self close];
|
||||
[self close:^{
|
||||
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
||||
UIApplication * a = [UIApplication sharedApplication];
|
||||
if ([a canOpenURL:url])
|
||||
[a openURL:url];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)closeTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
[self close];
|
||||
}
|
||||
|
||||
- (void)openSettings
|
||||
{
|
||||
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
||||
UIApplication * a = [UIApplication sharedApplication];
|
||||
if ([a canOpenURL:url])
|
||||
[a openURL:url];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -46,14 +46,16 @@ namespace
|
|||
- (IBAction)shareTap
|
||||
{
|
||||
[Statistics logEvent:kStatEditorSecondTimeShareClick withParameters:@{kStatValue : self.statMessage}];
|
||||
MWMActivityViewController * shareVC = [MWMActivityViewController shareControllerForEditorViral];
|
||||
[self close];
|
||||
[shareVC presentInParentViewController:self.alertController.ownerViewController anchorView:self.shareButton];
|
||||
[self close:^{
|
||||
MWMActivityViewController * shareVC = [MWMActivityViewController shareControllerForEditorViral];
|
||||
[shareVC presentInParentViewController:self.alertController.ownerViewController
|
||||
anchorView:self.shareButton];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)cancelTap
|
||||
{
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
- (NSString *)statMessage
|
||||
|
|
|
@ -19,36 +19,43 @@ extern NSString * const kMap2GoogleLoginSegue;
|
|||
- (IBAction)facebookTap
|
||||
{
|
||||
[Statistics logEvent:kStatEditorAuthRequets withParameters:@{kStatValue : kStatFacebook, kStatFrom : kStatEdit}];
|
||||
[self close];
|
||||
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2FBLoginSegue sender:nil];
|
||||
[self close:^{
|
||||
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2FBLoginSegue
|
||||
sender:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)googleTap
|
||||
{
|
||||
[Statistics logEvent:kStatEditorAuthRequets withParameters:@{kStatValue : kStatGoogle, kStatFrom : kStatEdit}];
|
||||
[self close];
|
||||
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2GoogleLoginSegue sender:nil];
|
||||
[self close:^{
|
||||
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2GoogleLoginSegue
|
||||
sender:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)osmTap
|
||||
{
|
||||
[Statistics logEvent:kStatEditorAuthRequets withParameters:@{kStatValue : kStatOSM, kStatFrom : kStatEdit}];
|
||||
[self close];
|
||||
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2OsmLoginSegue sender:nil];
|
||||
[self close:^{
|
||||
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2OsmLoginSegue
|
||||
sender:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)signUpTap
|
||||
{
|
||||
[self close];
|
||||
[Statistics logEvent:kStatEditorRegRequest withParameters:@{kStatFrom : kStatEdit}];
|
||||
NSURL * url = [NSURL URLWithString:@(osm::OsmOAuth::ServerAuth().GetRegistrationURL().c_str())];
|
||||
[self.alertController.ownerViewController openUrl:url];
|
||||
[self close:^{
|
||||
[Statistics logEvent:kStatEditorRegRequest withParameters:@{kStatFrom : kStatEdit}];
|
||||
NSURL * url = [NSURL URLWithString:@(osm::OsmOAuth::ServerAuth().GetRegistrationURL().c_str())];
|
||||
[self.alertController.ownerViewController openUrl:url];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)closeTap
|
||||
{
|
||||
[Statistics logEvent:kStatEditorAuthDeclinedByUser];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -25,14 +25,15 @@
|
|||
- (IBAction)rightButtonTap
|
||||
{
|
||||
[self.textField resignFirstResponder];
|
||||
[self close];
|
||||
self.block(self.textField.text);
|
||||
[self close:^{
|
||||
self.block(self.textField.text);
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)leftButtonTap
|
||||
{
|
||||
[self.textField resignFirstResponder];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
#pragma mark - MWMKeyboard
|
||||
|
|
|
@ -107,7 +107,7 @@ static NSString * const kStatisticsEvent = @"Rate Alert";
|
|||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
[Alohalytics logEvent:kRateAlertEventName withValue:@"notNowTap"];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
- (IBAction)rateTap
|
||||
|
@ -121,8 +121,11 @@ static NSString * const kStatisticsEvent = @"Rate Alert";
|
|||
{
|
||||
[[UIApplication sharedApplication] rateVersionFrom:@"ios_pro_popup"];
|
||||
[Alohalytics logEvent:kRateAlertEventName withValue:@"fiveStar"];
|
||||
[self close];
|
||||
[self setupAlreadyRatedInUserDefaults];
|
||||
[self close:^{
|
||||
auto ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setBool:YES forKey:kUDAlreadyRatedKey];
|
||||
[ud synchronize];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,13 +133,6 @@ static NSString * const kStatisticsEvent = @"Rate Alert";
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setupAlreadyRatedInUserDefaults
|
||||
{
|
||||
auto ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setBool:YES forKey:kUDAlreadyRatedKey];
|
||||
[ud synchronize];
|
||||
}
|
||||
|
||||
- (void)sendFeedback
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatisticsEvent, kStatSendEmail)];
|
||||
|
@ -196,7 +192,7 @@ static NSString * const kStatisticsEvent = @"Rate Alert";
|
|||
dismissViewControllerAnimated:YES
|
||||
completion:^{
|
||||
[Statistics logEvent:kStatEventName(kStatisticsEvent, kStatClose)];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -49,14 +49,13 @@ static NSString * const kStatisticsEvent = @"Routing Disclaimer Alert";
|
|||
- (IBAction)okTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatApply}];
|
||||
self.okBlock();
|
||||
[self close];
|
||||
[self close:self.okBlock];
|
||||
}
|
||||
|
||||
- (IBAction)cancelTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatCancel}];
|
||||
[self close];
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
|
||||
|
|
Loading…
Add table
Reference in a new issue