diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index c719851181..56f87a17b9 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -30,9 +30,9 @@ - (void)presentInternalErrorAlert; - (void)presentInvalidUserNameOrPasswordAlert; - (void)presentDisableAutoDownloadAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; -- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; +- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock cancelBlock:(nonnull TMWMVoidBlock)cancelBlock; - (void)presentDownloaderNotEnoughSpaceAlert; -- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; +- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock cancelBlock:(nonnull TMWMVoidBlock)cancelBlock; - (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; - (void)presentEditorViralAlertWithShareBlock:(nonnull TMWMVoidBlock)share; - (void)closeAlertWithCompletion:(nullable TMWMVoidBlock)completion; diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index d8db9ca110..61627adf0d 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -170,9 +170,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [self displayAlert:[MWMAlert disableAutoDownloadAlertWithOkBlock:okBlock]]; } -- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock +- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock cancelBlock:(nonnull TMWMVoidBlock)cancelBlock { - [self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock]]; + [self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock]]; } - (void)presentDownloaderNotEnoughSpaceAlert @@ -180,9 +180,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [self displayAlert:[MWMAlert downloaderNotEnoughSpaceAlert]]; } -- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock +- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock cancelBlock:(nonnull TMWMVoidBlock)cancelBlock { - [self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock]]; + [self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]]; } - (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h index a704d2cc83..9cbfce8935 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h @@ -27,9 +27,9 @@ + (MWMAlert *)invalidUserNameOrPasswordAlert; + (MWMAlert *)point2PointAlertWithOkBlock:(TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; + (MWMAlert *)disableAutoDownloadAlertWithOkBlock:(TMWMVoidBlock)okBlock; -+ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock; + (MWMAlert *)downloaderNotEnoughSpaceAlert; -+ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock; + (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock; + (MWMAlert *)editorViralAlertWithShareBlock:(TMWMVoidBlock)share; - (void)close; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm index 7ff1788810..65c6189166 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm @@ -131,9 +131,9 @@ return [MWMDefaultAlert disableAutoDownloadAlertWithOkBlock:okBlock]; } -+ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock ++ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock { - return [MWMDefaultAlert downloaderNoConnectionAlertWithOkBlock:okBlock]; + return [MWMDefaultAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock]; } + (MWMAlert *)downloaderNotEnoughSpaceAlert @@ -141,9 +141,9 @@ return [MWMDefaultAlert downloaderNotEnoughSpaceAlert]; } -+ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock ++ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock { - return [MWMDefaultAlert downloaderInternalErrorAlertWithOkBlock:okBlock]; + return [MWMDefaultAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]; } + (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h index 47ac25504d..b2d5ba9ef0 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h @@ -20,9 +20,9 @@ + (instancetype)locationServiceNotSupportedAlert; + (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; + (instancetype)disableAutoDownloadAlertWithOkBlock:(TMWMVoidBlock)okBlock; -+ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock; + (instancetype)downloaderNotEnoughSpaceAlert; -+ (instancetype)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (instancetype)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock; + (instancetype)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock; + (instancetype)routingMigrationAlertWithOkBlock:(TMWMVoidBlock)okBlock; diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm index 8a0a18108a..59a5f50852 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm @@ -21,6 +21,7 @@ static NSString * kStatisticsEvent = @"Default Alert"; @property (weak, nonatomic) IBOutlet UILabel * titleLabel; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * rightButtonWidth; @property (copy, nonatomic) TMWMVoidBlock rightButtonAction; +@property (copy, nonatomic) TMWMVoidBlock leftButtonAction; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *dividerTop; @end @@ -246,7 +247,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; return alert; } -+ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock ++ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock { kStatisticsEvent = @"Downloader No Connection Alert"; MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"downloader_status_failed" @@ -254,6 +255,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; rightButtonTitle:@"downloader_retry" leftButtonTitle:@"cancel" rightButtonAction:okBlock]; + alert.leftButtonAction = cancelBlock; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } @@ -270,7 +272,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; return alert; } -+ (instancetype)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock ++ (instancetype)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock cancelBlock:(TMWMVoidBlock)cancelBlock { kStatisticsEvent = @"Downloader Internal Error Alert"; MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"migration_download_error_dialog" @@ -278,6 +280,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; rightButtonTitle:@"downloader_retry" leftButtonTitle:@"cancel" rightButtonAction:okBlock]; + alert.leftButtonAction = cancelBlock; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } @@ -348,6 +351,8 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; - (IBAction)leftButtonTap { [[Statistics instance] logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatClose}]; + if (self.leftButtonAction) + self.leftButtonAction(); [self close]; } diff --git a/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm b/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm index ce7fc3e24e..68886e4947 100644 --- a/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm +++ b/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm @@ -112,13 +112,17 @@ using namespace storage; { GetFramework().Storage().GetPrefetchStorage()->RetryDownloadNode(self->m_countryId); }; + auto const cancelBlock = ^ + { + GetFramework().Storage().GetPrefetchStorage()->CancelDownloadNode(self->m_countryId); + }; switch (errorCode) { case NodeErrorCode::NoError: break; case NodeErrorCode::UnknownError: [Statistics logEvent:kStatDownloaderMigrationError withParameters:@{kStatType : kStatUnknownError}]; - [avc presentDownloaderInternalErrorAlertWithOkBlock:retryBlock]; + [avc presentDownloaderInternalErrorAlertWithOkBlock:retryBlock cancelBlock:cancelBlock]; [avc presentInternalErrorAlert]; break; case NodeErrorCode::OutOfMemFailed: @@ -127,7 +131,7 @@ using namespace storage; break; case NodeErrorCode::NoInetConnection: [Statistics logEvent:kStatDownloaderMigrationError withParameters:@{kStatType : kStatNoConnection}]; - [avc presentDownloaderNoConnectionAlertWithOkBlock:retryBlock]; + [avc presentDownloaderNoConnectionAlertWithOkBlock:retryBlock cancelBlock:cancelBlock]; break; } } diff --git a/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm b/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm index 5de71b513c..026228c568 100644 --- a/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm +++ b/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm @@ -195,18 +195,23 @@ using namespace storage; }]; [MWMStorage retryDownloadNode:self->m_countryId]; }; + auto const cancelBlock = ^ + { + [Statistics logEvent:kStatDownloaderDownloadCancel withParameters:@{kStatFrom : kStatMap}]; + [MWMStorage cancelDownloadNode:self->m_countryId]; + }; switch (errorCode) { case NodeErrorCode::NoError: break; case NodeErrorCode::UnknownError: - [avc presentDownloaderInternalErrorAlertWithOkBlock:retryBlock]; + [avc presentDownloaderInternalErrorAlertWithOkBlock:retryBlock cancelBlock:cancelBlock]; break; case NodeErrorCode::OutOfMemFailed: [avc presentDownloaderNotEnoughSpaceAlert]; break; case NodeErrorCode::NoInetConnection: - [avc presentDownloaderNoConnectionAlertWithOkBlock:retryBlock]; + [avc presentDownloaderNoConnectionAlertWithOkBlock:retryBlock cancelBlock:cancelBlock]; break; } }