From b9cbed92a8882f68cfa2d705bf6bb7705c714962 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Fri, 12 Feb 2016 15:31:21 +0300 Subject: [PATCH] [new downloader][ios] Added downloader error dialogs. --- .../AlertController/MWMAlertViewController.h | 12 +- .../AlertController/MWMAlertViewController.mm | 38 +++- .../Classes/CustomAlert/BaseAlert/MWMAlert.h | 10 +- .../Classes/CustomAlert/BaseAlert/MWMAlert.mm | 28 ++- .../DefaultAlert/MWMDefaultAlert.h | 8 +- .../DefaultAlert/MWMDefaultAlert.mm | 175 +++++++++++++++--- .../MWMDownloadTransitMapAlert.h | 2 +- .../MWMDownloadTransitMapAlert.mm | 4 +- iphone/Maps/Classes/MapViewController.mm | 6 +- iphone/Maps/Classes/MapsAppDelegate.mm | 2 +- 10 files changed, 229 insertions(+), 56 deletions(-) diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index 8c6298f115..81b1bed984 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -13,20 +13,24 @@ - (void)presentDownloaderAlertWithCountries:(storage::TCountriesVec const &)countries routes:(storage::TCountriesVec const &)routes code:(routing::IRouter::ResultCode)code - block:(nonnull TMWMVoidBlock)block; + okBlock:(nonnull TMWMVoidBlock)okBlock; - (void)presentRateAlert; - (void)presentFacebookAlert; -- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild; -- (void)presentUpdateMapsAlertWithOkBlock:(nonnull TMWMVoidBlock)block; +- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; +- (void)presentUpdateMapsAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; - (void)presentRoutingDisclaimerAlert; - (void)presentDisabledLocationAlert; - (void)presentLocationAlert; - (void)presentLocationServiceNotSupportedAlert; - (void)presentNoConnectionAlert; -- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name downloadBlock:(nullable TMWMVoidBlock)block; +- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name okBlock:(nullable TMWMVoidBlock)okBlock; - (void)presentPedestrianToastAlert:(BOOL)isFirstLaunch; - (void)presentInternalErrorAlert; - (void)presentInvalidUserNameOrPasswordAlert; +- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; +- (void)presentDownloaderNotEnoughSpaceAlert; +- (void)presentDownloaderInternalErrorAlertForMap:(nonnull NSString *)name okBlock:(nonnull TMWMVoidBlock)okBlock; +- (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock; - (void)closeAlertWithCompletion:(nullable TMWMVoidBlock)completion; - (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!"))); diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index c0690f1de5..ddc2d4de0b 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -61,9 +61,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController // }); } -- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild +- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild { - [self displayAlert:[MWMAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild]]; + [self displayAlert:[MWMAlert point2PointAlertWithOkBlock:okBlock needToRebuild:needToRebuild]]; } - (void)presentFacebookAlert @@ -78,12 +78,12 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController - (void)presentNoConnectionAlert { - [self displayAlert:MWMAlert.noConnectionAlert]; + [self displayAlert:[MWMAlert noConnectionAlert]]; } -- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name downloadBlock:(nullable TMWMVoidBlock)block +- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name okBlock:(nullable TMWMVoidBlock)okBlock { - [self displayAlert:[MWMAlert noWiFiAlertWithName:name downloadBlock:block]]; + [self displayAlert:[MWMAlert noWiFiAlertWithName:name okBlock:okBlock]]; } - (void)presentPedestrianToastAlert:(BOOL)isFirstLaunch @@ -101,17 +101,17 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [self displayAlert:[MWMAlert invalidUserNameOrPasswordAlert]]; } -- (void)presentUpdateMapsAlertWithOkBlock:(nonnull TMWMVoidBlock)block +- (void)presentUpdateMapsAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock { - [self displayAlert:[MWMAlert updateMapsAlertWithOkBlock:block]]; + [self displayAlert:[MWMAlert updateMapsAlertWithOkBlock:okBlock]]; } - (void)presentDownloaderAlertWithCountries:(storage::TCountriesVec const &)countries routes:(storage::TCountriesVec const &)routes code:(routing::IRouter::ResultCode)code - block:(TMWMVoidBlock)block + okBlock:(TMWMVoidBlock)okBlock { - [self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries routes:routes code:code block:block]]; + [self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries routes:routes code:code block:okBlock]]; } - (void)presentRoutingDisclaimerAlert @@ -149,6 +149,26 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController }]; } +- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock +{ + [self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock]]; +} + +- (void)presentDownloaderNotEnoughSpaceAlert +{ + [self displayAlert:[MWMAlert downloaderNotEnoughSpaceAlert]]; +} + +- (void)presentDownloaderInternalErrorAlertForMap:(nonnull NSString *)name okBlock:(nonnull TMWMVoidBlock)okBlock +{ + [self displayAlert:[MWMAlert downloaderInternalErrorAlertForMap:name okBlock:okBlock]]; +} + +- (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock +{ + [self displayAlert:[MWMAlert downloaderNeedUpdateAlertWithOkBlock:okBlock]]; +} + - (void)closeAlertWithCompletion:(nullable TMWMVoidBlock)completion { MWMAlert * alert = self.view.subviews.firstObject; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h index b51e61d004..2513ee9ee4 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h @@ -16,14 +16,18 @@ + (MWMAlert *)locationAlert; + (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation; + (MWMAlert *)disabledLocationAlert; -+ (MWMAlert *)noWiFiAlertWithName:(NSString *)name downloadBlock:(TMWMVoidBlock)block; ++ (MWMAlert *)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock; + (MWMAlert *)noConnectionAlert; + (MWMAlert *)locationServiceNotSupportedAlert; + (MWMAlert *)pedestrianToastShareAlert:(BOOL)isFirstLaunch; + (MWMAlert *)internalErrorAlert; + (MWMAlert *)invalidUserNameOrPasswordAlert; -+ (MWMAlert *)point2PointAlertWithOkBlock:(TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild; -+ (MWMAlert *)updateMapsAlertWithOkBlock:(TMWMVoidBlock)block; ++ (MWMAlert *)point2PointAlertWithOkBlock:(TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; ++ (MWMAlert *)updateMapsAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (MWMAlert *)downloaderNotEnoughSpaceAlert; ++ (MWMAlert *)downloaderInternalErrorAlertForMap:(NSString *)name okBlock:(TMWMVoidBlock)okBlock; ++ (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock; - (void)close; - (void)setNeedsCloseAlertAfterEnterBackground; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm index 14f43e7931..b236857588 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm @@ -42,9 +42,9 @@ return [MWMDefaultAlert disabledLocationAlert]; } -+ (MWMAlert *)noWiFiAlertWithName:(NSString *)name downloadBlock:(TMWMVoidBlock)block ++ (MWMAlert *)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock { - return [MWMDefaultAlert noWiFiAlertWithName:name downloadBlock:block]; + return [MWMDefaultAlert noWiFiAlertWithName:name okBlock:okBlock]; } + (MWMAlert *)noConnectionAlert @@ -60,9 +60,9 @@ + (MWMAlert *)downloaderAlertWithAbsentCountries:(storage::TCountriesVec const &)countries routes:(storage::TCountriesVec const &)routes code:(routing::IRouter::ResultCode)code - block:(TMWMVoidBlock)block + okBlock:(TMWMVoidBlock)okBlock { - return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries routes:routes code:code block:block]; + return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries routes:routes code:code okBlock:okBlock]; } + (MWMAlert *)alert:(routing::IRouter::ResultCode)type @@ -112,6 +112,26 @@ return [MWMDefaultAlert internalErrorAlert]; } ++ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock +{ + return [MWMDefaultAlert downloaderNoConnectionAlertWithOkBlock:okBlock]; +} + ++ (MWMAlert *)downloaderNotEnoughSpaceAlert +{ + return [MWMDefaultAlert downloaderNotEnoughSpaceAlert]; +} + ++ (MWMAlert *)downloaderInternalErrorAlertForMap:(NSString *)name okBlock:(TMWMVoidBlock)okBlock +{ + return [MWMDefaultAlert downloaderInternalErrorAlertForMap:name okBlock:okBlock]; +} + ++ (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock +{ + return [MWMDefaultAlert downloaderNeedUpdateAlertWithOkBlock:okBlock]; +} + - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { // Should override this method if you want custom relayout after rotation. diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h index a08025d1d8..1ea4300768 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h @@ -12,9 +12,13 @@ + (instancetype)noCurrentPositionAlert; + (instancetype)pointsInDifferentMWMAlert; + (instancetype)disabledLocationAlert; -+ (instancetype)noWiFiAlertWithName:(NSString *)name downloadBlock:(TMWMVoidBlock)block; ++ (instancetype)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock; + (instancetype)noConnectionAlert; + (instancetype)locationServiceNotSupportedAlert; -+ (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild; ++ (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; ++ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock; ++ (instancetype)downloaderNotEnoughSpaceAlert; ++ (instancetype)downloaderInternalErrorAlertForMap:(NSString *)name okBlock:(TMWMVoidBlock)okBlock; ++ (instancetype)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock; @end diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm index 965c6e825a..aaf20209ba 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm @@ -32,35 +32,57 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; + (instancetype)routeFileNotExistAlert { kStatisticsEvent = @"Route File Not Exist Alert"; - return [self defaultAlertWithTitle:@"dialog_routing_download_files" message:@"dialog_routing_download_and_update_all" rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + return [self defaultAlertWithTitle:@"dialog_routing_download_files" + message:@"dialog_routing_download_and_update_all" + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)routeNotFoundAlert { kStatisticsEvent = @"Route File Not Exist Alert"; - NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_cant_build_route"), L(@"dialog_routing_change_start_or_end")]; - return [self defaultAlertWithTitle:@"dialog_routing_unable_locate_route" message:message rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + NSString * message = + [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_cant_build_route"), + L(@"dialog_routing_change_start_or_end")]; + return [self defaultAlertWithTitle:@"dialog_routing_unable_locate_route" + message:message + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)locationServiceNotSupportedAlert { kStatisticsEvent = @"Location Service Not Supported Alert"; - return [self defaultAlertWithTitle:@"device_doesnot_support_location_services" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + return [self defaultAlertWithTitle:@"device_doesnot_support_location_services" + message:nil + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)noConnectionAlert { kStatisticsEvent = @"No Connection Alert"; - MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"no_internet_connection_detected" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"no_internet_connection_detected" + message:nil + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } -+ (instancetype)noWiFiAlertWithName:(NSString *)name downloadBlock:(TMWMVoidBlock)block ++ (instancetype)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock { kStatisticsEvent = @"No WiFi Alert"; NSString * title = [NSString stringWithFormat:L(@"no_wifi_ask_cellular_download"), name]; - MWMDefaultAlert * alert = [self defaultAlertWithTitle:title message:nil rightButtonTitle:@"use_cellular_data" leftButtonTitle:@"cancel" rightButtonAction:block]; + MWMDefaultAlert * alert = [self defaultAlertWithTitle:title + message:nil + rightButtonTitle:@"use_cellular_data" + leftButtonTitle:@"cancel" + rightButtonAction:okBlock]; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } @@ -68,78 +90,177 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; + (instancetype)endPointNotFoundAlert { kStatisticsEvent = @"End Point Not Found Alert"; - NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_end_not_determined"), L(@"dialog_routing_select_closer_end")]; - return [self defaultAlertWithTitle:@"dialog_routing_change_end" message:message rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + NSString * message = + [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_end_not_determined"), + L(@"dialog_routing_select_closer_end")]; + return [self defaultAlertWithTitle:@"dialog_routing_change_end" + message:message + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)startPointNotFoundAlert { kStatisticsEvent = @"Start Point Not Found Alert"; - NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_start_not_determined"), L(@"dialog_routing_select_closer_start")]; - return [self defaultAlertWithTitle:@"dialog_routing_change_start" message:message rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + NSString * message = + [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_start_not_determined"), + L(@"dialog_routing_select_closer_start")]; + return [self defaultAlertWithTitle:@"dialog_routing_change_start" + message:message + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)internalRoutingErrorAlert { kStatisticsEvent = @"Internal Routing Error Alert"; - NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_application_error"), L(@"dialog_routing_try_again")]; - return [self defaultAlertWithTitle:@"dialog_routing_system_error" message:message rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + NSString * message = + [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_application_error"), + L(@"dialog_routing_try_again")]; + return [self defaultAlertWithTitle:@"dialog_routing_system_error" + message:message + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)internalErrorAlert { kStatisticsEvent = @"Internal Error Alert"; - return [self defaultAlertWithTitle:@"dialog_routing_system_error" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + return [self defaultAlertWithTitle:@"dialog_routing_system_error" + message:nil + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)invalidUserNameOrPasswordAlert { kStatisticsEvent = @"Invalid User Name or Password Alert"; - return [self defaultAlertWithTitle:@"invalid_username_or_password" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + return [self defaultAlertWithTitle:@"invalid_username_or_password" + message:nil + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)noCurrentPositionAlert { kStatisticsEvent = @"No Current Position Alert"; - NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_error_location_not_found"), L(@"dialog_routing_location_turn_wifi")]; - return [self defaultAlertWithTitle:@"dialog_routing_check_gps" message:message rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + NSString * message = + [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_error_location_not_found"), + L(@"dialog_routing_location_turn_wifi")]; + return [self defaultAlertWithTitle:@"dialog_routing_check_gps" + message:message + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } + (instancetype)disabledLocationAlert { kStatisticsEvent = @"Disabled Location Alert"; - TMWMVoidBlock action = ^ - { + TMWMVoidBlock action = ^{ GetFramework().SwitchMyPositionNextMode(); }; - return [MWMDefaultAlert defaultAlertWithTitle:@"dialog_routing_location_turn_on" message:@"dialog_routing_location_unknown_turn_on" rightButtonTitle:@"turn_on" leftButtonTitle:@"later" rightButtonAction:action]; + return [MWMDefaultAlert defaultAlertWithTitle:@"dialog_routing_location_turn_on" + message:@"dialog_routing_location_unknown_turn_on" + rightButtonTitle:@"turn_on" + leftButtonTitle:@"later" + rightButtonAction:action]; } + (instancetype)pointsInDifferentMWMAlert { kStatisticsEvent = @"Points In Different MWM Alert"; - return [self defaultAlertWithTitle:@"routing_failed_cross_mwm_building" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + return [self defaultAlertWithTitle:@"routing_failed_cross_mwm_building" + message:nil + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } -+ (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild ++ (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild { if (needToRebuild) { return [self defaultAlertWithTitle:@"p2p_only_from_current" - message:@"p2p_reroute_from_current" - rightButtonTitle:@"ok" leftButtonTitle:@"cancel" rightButtonAction:block]; + message:@"p2p_reroute_from_current" + rightButtonTitle:@"ok" + leftButtonTitle:@"cancel" + rightButtonAction:okBlock]; } else { return [self defaultAlertWithTitle:@"p2p_only_from_current" - message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + message:nil + rightButtonTitle:@"ok" + leftButtonTitle:nil + rightButtonAction:nil]; } } -+ (instancetype)defaultAlertWithTitle:(nonnull NSString *)title message:(nullable NSString *)message rightButtonTitle:(nonnull NSString *)rightButtonTitle leftButtonTitle:(nullable NSString *)leftButtonTitle rightButtonAction:(nullable TMWMVoidBlock)action ++ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock +{ + kStatisticsEvent = @"Downloader No Connection Alert"; + MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"downloader_error" + message:@"downloader_no_internet_connection" + rightButtonTitle:@"downloader_retry" + leftButtonTitle:@"cancel" + rightButtonAction:okBlock]; + [alert setNeedsCloseAlertAfterEnterBackground]; + return alert; +} + ++ (instancetype)downloaderNotEnoughSpaceAlert +{ + kStatisticsEvent = @"Downloader Not Enough Space Alert"; + MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"downloader_error" + message:@"downloader_not_enough_space" + rightButtonTitle:@"close" + leftButtonTitle:nil + rightButtonAction:nil]; + [alert setNeedsCloseAlertAfterEnterBackground]; + return alert; +} + ++ (instancetype)downloaderInternalErrorAlertForMap:(NSString *)name okBlock:(TMWMVoidBlock)okBlock +{ + kStatisticsEvent = @"Downloader Internal Error Alert"; + NSString * message = + [NSString stringWithFormat:@"%@%@", L(@"downloader_internal_error_for_map"), name]; + MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"downloader_error" + message:message + rightButtonTitle:@"downloader_retry" + leftButtonTitle:@"cancel" + rightButtonAction:okBlock]; + [alert setNeedsCloseAlertAfterEnterBackground]; + return alert; +} + ++ (instancetype)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock +{ + kStatisticsEvent = @"Downloader Need Update Alert"; + MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"downloader_need_update_title" + message:@"downloader_need_update_message" + rightButtonTitle:@"downloader_status_outdated" + leftButtonTitle:@"not_now" + rightButtonAction:okBlock]; + [alert setNeedsCloseAlertAfterEnterBackground]; + return alert; +} + ++ (instancetype)defaultAlertWithTitle:(nonnull NSString *)title + message:(nullable NSString *)message + rightButtonTitle:(nonnull NSString *)rightButtonTitle + leftButtonTitle:(nullable NSString *)leftButtonTitle + rightButtonAction:(nullable TMWMVoidBlock)action { [[Statistics instance] logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}]; - MWMDefaultAlert * alert = [[[NSBundle mainBundle] loadNibNamed:kDefaultAlertNibName owner:self options:nil] firstObject]; + MWMDefaultAlert * alert = [ + [[NSBundle mainBundle] loadNibNamed:kDefaultAlertNibName owner:self options:nil] firstObject]; alert.titleLabel.localizedText = title; alert.messageLabel.localizedText = message; if (!message) diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h index 594c0c3c6a..25e1a97098 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h @@ -8,7 +8,7 @@ + (instancetype)downloaderAlertWithMaps:(storage::TCountriesVec const &)maps routes:(storage::TCountriesVec const &)routes code:(routing::IRouter::ResultCode)code - block:(TMWMVoidBlock)block; + okBlock:(TMWMVoidBlock)okBlock; - (void)showDownloadDetail:(UIButton *)sender; @end diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm index fdb2dfce9a..fddc6dc0ff 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm @@ -89,7 +89,7 @@ static NSString * const kStatisticsEvent = @"Map download Alert"; + (instancetype)downloaderAlertWithMaps:(storage::TCountriesVec const &)maps routes:(storage::TCountriesVec const &)routes code:(routing::IRouter::ResultCode)code - block:(TMWMVoidBlock)block + okBlock:(TMWMVoidBlock)okBlock { [[Statistics instance] logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}]; MWMDownloadTransitMapAlert * alert = [self alertWithMaps:maps routes:routes]; @@ -113,7 +113,7 @@ static NSString * const kStatisticsEvent = @"Map download Alert"; NSAssert(false, @"Incorrect code!"); break; } - alert.downloaderBlock = block; + alert.downloaderBlock = okBlock; return alert; } diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 4e312ac4af..e9817e8253 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -567,7 +567,7 @@ NSString * const kEditorSegue = @"Map2EditorSegue"; case routing::IRouter::FileTooOld: case routing::IRouter::RouteNotFound: { - [self presentDownloaderAlert:code countries:absentCountries routes:absentRoutes block:[=] + [self presentDownloaderAlert:code countries:absentCountries routes:absentRoutes okBlock:[=] { auto & s = GetFramework().Storage(); for (auto const & countryId : absentCountries) @@ -699,10 +699,10 @@ NSString * const kEditorSegue = @"Map2EditorSegue"; - (void)presentDownloaderAlert:(routing::IRouter::ResultCode)code countries:(storage::TCountriesVec const &)countries routes:(storage::TCountriesVec const &)routes - block:(TMWMVoidBlock)block + okBlock:(TMWMVoidBlock)okBlock { if (countries.size() || routes.size()) - [self.alertController presentDownloaderAlertWithCountries:countries routes:routes code:code block:block]; + [self.alertController presentDownloaderAlertWithCountries:countries routes:routes code:code okBlock:okBlock]; else [self presentDefaultAlert:code]; } diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index d4cf152c74..a388b186ee 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -152,7 +152,7 @@ using namespace osm_auth_ios; GetFramework().Storage().GetNodeAttrs(countryId, attrs); size_t const warningSizeForWWAN = 50 * MB; if (attrs.m_mwmSize > warningSizeForWWAN) - [alertController presentNoWiFiAlertWithName:@(attrs.m_nodeLocalName.c_str()) downloadBlock:action]; + [alertController presentNoWiFiAlertWithName:@(attrs.m_nodeLocalName.c_str()) okBlock:action]; else action(); break;