diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 3f75db9f0b..6cb3eb6666 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -4,6 +4,7 @@ #import "MWMAPIBar.h" #import "MWMAddPlaceNavigationBar.h" #import "MWMAlertViewController.h" +#import "MWMAlertViewController.h" #import "MWMAuthorizationCommon.h" #import "MWMBottomMenuViewController.h" #import "MWMButton.h" @@ -147,7 +148,6 @@ extern NSString * const kAlohalyticsTapEventKey; } } -- (MWMAlertViewController *)alertController { return self.ownerController.alertController; } - (void)searchViewDidEnterState:(MWMSearchManagerState)state { if (state == MWMSearchManagerStateMapSearch) @@ -234,7 +234,7 @@ extern NSString * const kAlohalyticsTapEventKey; { [Statistics logEvent:kStatDownloaderMigrationProhibitedDialogue withParameters:@{kStatFrom : kStatDownloader}]; - [self.alertController presentMigrationProhibitedAlert]; + [[MWMAlertViewController activeAlertController] presentMigrationProhibitedAlert]; } else { diff --git a/iphone/Maps/Classes/LocalNotificationManager.mm b/iphone/Maps/Classes/LocalNotificationManager.mm index 505c4ee0b6..794ed0d54f 100644 --- a/iphone/Maps/Classes/LocalNotificationManager.mm +++ b/iphone/Maps/Classes/LocalNotificationManager.mm @@ -70,7 +70,6 @@ using namespace storage; kStatScenario : kStatDownload }]; [MWMStorage downloadNode:countryId - alertController:mapViewController.alertController onSuccess:^{ GetFramework().ShowNode(countryId); }]; diff --git a/iphone/Maps/Classes/MWMPPView.h b/iphone/Maps/Classes/MWMPPView.h index a2ba1d145a..e807b05c35 100644 --- a/iphone/Maps/Classes/MWMPPView.h +++ b/iphone/Maps/Classes/MWMPPView.h @@ -25,6 +25,4 @@ @property(nonatomic) CGFloat currentContentHeight; @property(nonatomic) id delegate; -- (void)hideTableView:(BOOL)isHidden; - @end diff --git a/iphone/Maps/Classes/MWMPPView.mm b/iphone/Maps/Classes/MWMPPView.mm index 7ff5088869..71a14c71e9 100644 --- a/iphone/Maps/Classes/MWMPPView.mm +++ b/iphone/Maps/Classes/MWMPPView.mm @@ -39,20 +39,6 @@ CGFloat const kTableViewTopInset = -36; @implementation MWMPPView -- (void)hideTableView:(BOOL)isHidden -{ - if (isHidden) - { - self.tableView.alpha = 0.; - self.anchorImage.hidden = YES; - } - else - { - self.tableView.alpha = 1.; - self.anchorImage.hidden = NO; - } -} - - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change diff --git a/iphone/Maps/Classes/MWMPlacePageLayout.mm b/iphone/Maps/Classes/MWMPlacePageLayout.mm index a3c157bb40..e64f098f40 100644 --- a/iphone/Maps/Classes/MWMPlacePageLayout.mm +++ b/iphone/Maps/Classes/MWMPlacePageLayout.mm @@ -77,6 +77,7 @@ array const kButtonsCells = {{@"MWMPlacePageButtonCell"}}; _delegate = delegate; _dataSource = dataSource; [[NSBundle mainBundle] loadNibNamed:[MWMPPView className] owner:self options:nil]; + [_placePageView layoutIfNeeded]; _placePageView.delegate = self; auto const Impl = IPAD ? [MWMiPadPlacePageLayoutImpl class] : [MWMiPhonePlacePageLayoutImpl class]; _layoutImpl = [[Impl alloc] initOwnerView:view placePageView:_placePageView delegate:delegate]; @@ -121,7 +122,6 @@ array const kButtonsCells = {{@"MWMPlacePageButtonCell"}}; self.isPlacePageButtonsEnabled = YES; self.data = data; self.bookmarkCell = nil; - [self.layoutImpl onShow]; [self.actionBar configureWithData:static_cast>(data)]; [self.previewLayoutHelper configWithData:data]; @@ -132,8 +132,7 @@ array const kButtonsCells = {{@"MWMPlacePageButtonCell"}}; [self.placePageView.tableView reloadData]; dispatch_async(dispatch_get_main_queue(), ^{ - if ([self.layoutImpl respondsToSelector:@selector(onExpandWithPlacePagePreviewHeight:)]) - [self.layoutImpl onExpandWithPlacePagePreviewHeight:self.previewLayoutHelper.height]; + [self.layoutImpl onShow]; }); } @@ -152,7 +151,7 @@ array const kButtonsCells = {{@"MWMPlacePageButtonCell"}}; if (!_actionBar) { _actionBar = [MWMPlacePageActionBar actionBarWithDelegate:self.delegate]; - [self.layoutImpl onActionBarInit:_actionBar]; + self.layoutImpl.actionBar = _actionBar; } return _actionBar; } diff --git a/iphone/Maps/Classes/MWMPlacePageLayoutImpl.h b/iphone/Maps/Classes/MWMPlacePageLayoutImpl.h index a54fd041b6..98890efc27 100644 --- a/iphone/Maps/Classes/MWMPlacePageLayoutImpl.h +++ b/iphone/Maps/Classes/MWMPlacePageLayoutImpl.h @@ -32,7 +32,6 @@ inline void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil) - (void)onClose; - (void)onScreenResize:(CGSize const &)size; - (void)onUpdatePlacePageWithHeight:(CGFloat)height; -- (void)onActionBarInit:(MWMPlacePageActionBar *)actionBar; @property(weak, nonatomic) UIView * ownerView; @property(weak, nonatomic) MWMPPView * placePageView; @@ -40,7 +39,6 @@ inline void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil) @property(weak, nonatomic) MWMPlacePageActionBar * actionBar; @optional -- (void)onExpandWithPlacePagePreviewHeight:(CGFloat)height; - (void)updateLayoutWithTopBound:(CGFloat)topBound; - (void)updateLayoutWithLeftBound:(CGFloat)leftBound; - (void)setInitialTopBound:(CGFloat)topBound leftBound:(CGFloat)leftBound; diff --git a/iphone/Maps/Classes/MWMPlacePageManager.mm b/iphone/Maps/Classes/MWMPlacePageManager.mm index e58b56ec15..f4f56eade4 100644 --- a/iphone/Maps/Classes/MWMPlacePageManager.mm +++ b/iphone/Maps/Classes/MWMPlacePageManager.mm @@ -69,14 +69,13 @@ auto const & countryId = self.data.countryId; NodeAttrs nodeAttrs; GetFramework().GetStorage().GetNodeAttrs(countryId, nodeAttrs); - MWMAlertViewController * avc = [MapViewController controller].alertController; switch (nodeAttrs.m_status) { case NodeStatus::NotDownloaded: - case NodeStatus::Partly: [MWMStorage downloadNode:countryId alertController:avc onSuccess:nil]; break; + case NodeStatus::Partly: [MWMStorage downloadNode:countryId onSuccess:nil]; break; case NodeStatus::Undefined: - case NodeStatus::Error: [MWMStorage retryDownloadNode:countryId alertController:avc]; break; - case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId alertController:avc]; break; + case NodeStatus::Error: [MWMStorage retryDownloadNode:countryId]; break; + case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId]; break; case NodeStatus::Downloading: case NodeStatus::InQueue: [MWMStorage cancelDownloadNode:countryId]; break; case NodeStatus::OnDisk: break; diff --git a/iphone/Maps/Classes/MWMiPadPlacePageLayoutImpl.mm b/iphone/Maps/Classes/MWMiPadPlacePageLayoutImpl.mm index f7dda429de..ea311a0778 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePageLayoutImpl.mm +++ b/iphone/Maps/Classes/MWMiPadPlacePageLayoutImpl.mm @@ -54,13 +54,9 @@ CGFloat const kBottomOffset = 60; if (self) { _ownerView = ownerView; - _placePageView = placePageView; + self.placePageView = placePageView; _delegate = delegate; - placePageView.width = kPlacePageWidth; - placePageView.anchorImage.hidden = YES; [self addShadow]; - auto pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)]; - [placePageView addGestureRecognizer:pan]; } return self; } @@ -97,15 +93,16 @@ CGFloat const kBottomOffset = 60; - (void)onClose { auto ppView = self.placePageView; - place_page_layout::animate(^{ - ppView.maxX = 0; - ppView.alpha = 0; - },^{ - [self.placePageView removeFromSuperview]; - [self.actionBar removeFromSuperview]; - self.actionBar = nil; - [self.delegate shouldDestroyLayout]; - }); + place_page_layout::animate( + ^{ + ppView.maxX = 0; + ppView.alpha = 0; + }, + ^{ + self.placePageView = nil; + self.actionBar = nil; + [self.delegate shouldDestroyLayout]; + }); } - (void)onScreenResize:(CGSize const &)size @@ -118,14 +115,6 @@ CGFloat const kBottomOffset = 60; [self layoutPlacePage:height onScreen:self.ownerView.height]; } -- (void)onActionBarInit:(MWMPlacePageActionBar *)actionBar -{ - UIView * superview = self.placePageView; - self.actionBar = actionBar; - [superview addSubview:actionBar]; - actionBar.origin = {0., superview.height - actionBar.height}; -} - - (void)setInitialTopBound:(CGFloat)topBound leftBound:(CGFloat)leftBound { self.topBound = topBound; @@ -216,5 +205,37 @@ CGFloat const kBottomOffset = 60; - (CGFloat)topBound { return _topBound + kTopOffset; } - (CGFloat)leftBound { return _leftBound + kLeftOffset; } +#pragma mark - Properties + +- (void)setPlacePageView:(MWMPPView *)placePageView +{ + if (placePageView) + { + placePageView.width = kPlacePageWidth; + placePageView.anchorImage.hidden = YES; + auto pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)]; + [placePageView addGestureRecognizer:pan]; + } + else + { + [_placePageView removeFromSuperview]; + } + _placePageView = placePageView; +} + +- (void)setActionBar:(MWMPlacePageActionBar *)actionBar +{ + if (actionBar) + { + auto superview = self.placePageView; + actionBar.origin = {0., superview.height - actionBar.height}; + [superview addSubview:actionBar]; + } + else + { + [_actionBar removeFromSuperview]; + } + _actionBar = actionBar; +} @end diff --git a/iphone/Maps/Classes/MWMiPhonePlacePageLayoutImpl.mm b/iphone/Maps/Classes/MWMiPhonePlacePageLayoutImpl.mm index 96467a2b79..034e0c91bf 100644 --- a/iphone/Maps/Classes/MWMiPhonePlacePageLayoutImpl.mm +++ b/iphone/Maps/Classes/MWMiPhonePlacePageLayoutImpl.mm @@ -16,8 +16,6 @@ enum class State Top }; -// Minimal offset for collapse. If place page offset is below this value we should hide place page. -CGFloat const kMinOffset = 1; CGFloat const kOpenPlacePageStopValue = 0.7; CGFloat const kLuftDraggingOffset = 30; } // namespace @@ -55,13 +53,11 @@ CGFloat const kLuftDraggingOffset = 30; _placePageView = placePageView; placePageView.tableView.delegate = self; _delegate = delegate; - _scrollView = [[MWMPPScrollView alloc] initWithFrame:ownerView.frame inactiveView:placePageView]; - _scrollView.delegate = self; + self.scrollView = + [[MWMPPScrollView alloc] initWithFrame:ownerView.frame inactiveView:placePageView]; _portraitOpenContentOffset = MAX(size.width, size.height) * kOpenPlacePageStopValue; _landscapeOpenContentOffset = MIN(size.width, size.height) * kOpenPlacePageStopValue; placePageView.frame = {{0, size.height}, size}; - [ownerView addSubview:self.scrollView]; - [_scrollView addSubview:placePageView]; } return self; } @@ -69,7 +65,24 @@ CGFloat const kLuftDraggingOffset = 30; - (void)onShow { self.state = State::Bottom; - [self collapse]; + + auto scrollView = self.scrollView; + scrollView.scrollEnabled = NO; + + place_page_layout::animate( + ^{ + auto actionBar = self.actionBar; + actionBar.maxY = actionBar.superview.height; + + self.expandedContentOffset = + self.previewLayoutHelper.height + actionBar.height - self.placePageView.top.height; + auto const targetOffset = + self.state == State::Bottom ? self.expandedContentOffset : self.topContentOffset; + [scrollView setContentOffset:{ 0, targetOffset } animated:YES]; + }, + ^{ + scrollView.scrollEnabled = YES; + }); } - (void)onClose @@ -78,8 +91,8 @@ CGFloat const kLuftDraggingOffset = 30; self.actionBar.minY = self.ownerView.height; [self.scrollView setContentOffset:{} animated:YES]; },^{ - [self.actionBar removeFromSuperview]; self.actionBar = nil; + self.scrollView = nil; [self.delegate shouldDestroyLayout]; }); } @@ -100,41 +113,6 @@ CGFloat const kLuftDraggingOffset = 30; self.scrollView.contentSize = {size.width, size.height + self.placePageView.height}; } -- (void)onActionBarInit:(MWMPlacePageActionBar *)actionBar -{ - auto superview = self.ownerView; - self.actionBar = actionBar; - actionBar.minY = superview.height; - [superview addSubview:_actionBar]; -} - -- (void)onExpandWithPlacePagePreviewHeight:(CGFloat)height -{ - self.actionBar.hidden = NO; - self.scrollView.scrollEnabled = YES; - - place_page_layout::animate(^{ - auto ppView = self.placePageView; - [ppView hideTableView:NO]; - auto actionBar = self.actionBar; - actionBar.minY = actionBar.superview.height - actionBar.height; - - self.expandedContentOffset = height + actionBar.height - ppView.top.height; - auto const targetOffset = self.state == State::Bottom ? self.expandedContentOffset : self.topContentOffset; - [self.scrollView setContentOffset:{ 0, targetOffset } animated:YES]; - }); -} - -- (void)collapse -{ - self.scrollView.scrollEnabled = NO; - [self.placePageView hideTableView:YES]; - - place_page_layout::animate(^{ - [self.scrollView setContentOffset:{ 0., kMinOffset } animated:YES]; - }); -} - #pragma mark - UIScrollViewDelegate - (BOOL)isPortrait @@ -165,9 +143,7 @@ CGFloat const kLuftDraggingOffset = 30; id delegate = self.delegate; if (offset.y <= 0) { - [self.scrollView removeFromSuperview]; - [self.actionBar removeFromSuperview]; - [delegate shouldDestroyLayout]; + [self onClose]; return; } @@ -279,5 +255,39 @@ CGFloat const kLuftDraggingOffset = 30; place_page_layout::animate(^{ [self.scrollView setContentOffset:{0, offset} animated:YES]; }); } +#pragma mark - Properties + +- (void)setScrollView:(MWMPPScrollView *)scrollView +{ + if (scrollView) + { + scrollView.delegate = self; + [self.ownerView addSubview:scrollView]; + [scrollView addSubview:self.placePageView]; + } + else + { + _scrollView.delegate = nil; + [_scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; + [_scrollView removeFromSuperview]; + } + _scrollView = scrollView; +} + +- (void)setActionBar:(MWMPlacePageActionBar *)actionBar +{ + if (actionBar) + { + auto superview = self.ownerView; + actionBar.minY = superview.height; + [superview addSubview:actionBar]; + } + else + { + [_actionBar removeFromSuperview]; + } + _actionBar = actionBar; +} + @end diff --git a/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm b/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm index b7e2230534..43330f5211 100644 --- a/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm +++ b/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm @@ -377,7 +377,7 @@ using namespace mwm; kStatFrom : kStatDownloader, kStatScenario : kStatUpdateAll }]; - [MWMStorage updateNode:parentCountryId alertController:self.alertController]; + [MWMStorage updateNode:parentCountryId]; } else { @@ -389,7 +389,6 @@ using namespace mwm; kStatScenario : kStatDownloadGroup }]; [MWMStorage downloadNode:parentCountryId - alertController:self.alertController onSuccess:nil]; } self.skipCountryEventProcessing = NO; @@ -664,7 +663,7 @@ using namespace mwm; kStatScenario : kStatDownload }]; self.skipCountryEventProcessing = YES; - [MWMStorage downloadNode:countryId alertController:self.alertController onSuccess:nil]; + [MWMStorage downloadNode:countryId onSuccess:nil]; self.skipCountryEventProcessing = NO; [self processCountryEvent:countryId]; } @@ -679,7 +678,7 @@ using namespace mwm; kStatScenario : kStatDownload }]; self.skipCountryEventProcessing = YES; - [MWMStorage retryDownloadNode:countryId alertController:self.alertController]; + [MWMStorage retryDownloadNode:countryId]; self.skipCountryEventProcessing = NO; [self processCountryEvent:countryId]; } @@ -694,7 +693,7 @@ using namespace mwm; kStatScenario : kStatUpdate }]; self.skipCountryEventProcessing = YES; - [MWMStorage updateNode:countryId alertController:self.alertController]; + [MWMStorage updateNode:countryId]; self.skipCountryEventProcessing = NO; [self processCountryEvent:countryId]; } @@ -709,7 +708,7 @@ using namespace mwm; kStatScenario : kStatDelete }]; self.skipCountryEventProcessing = YES; - [MWMStorage deleteNode:countryId alertController:self.alertController]; + [MWMStorage deleteNode:countryId]; self.skipCountryEventProcessing = NO; [self processCountryEvent:countryId]; } diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 1fe706b6a1..3de47c902c 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -986,14 +986,10 @@ using namespace osm_auth_ios; if (!Platform::IsConnected()) return; - UIViewController * topViewController = - [(UINavigationController *)self.window.rootViewController visibleViewController]; - MWMAlertViewController * alert = - [[MWMAlertViewController alloc] initWithViewController:topViewController]; if (isRate) - [alert presentRateAlert]; + [[MWMAlertViewController activeAlertController] presentRateAlert]; else - [alert presentFacebookAlert]; + [[MWMAlertViewController activeAlertController] presentFacebookAlert]; [[NSUserDefaults standardUserDefaults] setObject:NSDate.date forKey:isRate ? kUDLastRateRequestDate : kUDLastShareRequstDate]; diff --git a/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm b/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm index 68a214bf02..7f4bdcdc50 100644 --- a/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm +++ b/iphone/Maps/Classes/Migration/MWMMigrationViewController.mm @@ -22,7 +22,7 @@ using namespace storage; @interface MWMStorage () -+ (void)checkConnectionAndPerformAction:(TMWMVoidBlock)action alertController:(MWMAlertViewController *)alertController; ++ (void)checkConnectionAndPerformAction:(TMWMVoidBlock)action; @end @@ -104,21 +104,19 @@ using namespace storage; [view setProgress:static_cast(progress.first) / progress.second]; }; - [MWMStorage checkConnectionAndPerformAction:^ - { + [MWMStorage checkConnectionAndPerformAction:^{ self->m_countryId = f.PreMigrate(position, onStatusChanged, onProgressChanged); if (self->m_countryId != kInvalidCountryId) [self setState:MWMMigrationViewState::Processing]; else migrate(); - } - alertController:self.alertController]; + }]; } - (void)showError:(NodeErrorCode)errorCode countryId:(TCountryId const &)countryId { [self setState:MWMMigrationViewState::Default]; - MWMAlertViewController * avc = self.alertController; + MWMAlertViewController * avc = [MWMAlertViewController activeAlertController]; auto const retryBlock = ^ { GetFramework().GetStorage().GetPrefetchStorage()->RetryDownloadNode(self->m_countryId); @@ -135,7 +133,6 @@ using namespace storage; case NodeErrorCode::UnknownError: [Statistics logEvent:kStatDownloaderMigrationError withParameters:@{kStatType : kStatUnknownError}]; [avc presentDownloaderInternalErrorAlertWithOkBlock:retryBlock cancelBlock:cancelBlock]; - [avc presentInternalErrorAlert]; break; case NodeErrorCode::OutOfMemFailed: [Statistics logEvent:kStatDownloaderMigrationError withParameters:@{kStatType : kStatNoSpace}]; diff --git a/iphone/Maps/Classes/Routing/MWMRouter.mm b/iphone/Maps/Classes/Routing/MWMRouter.mm index 830d13cf07..d4f0aa5dc9 100644 --- a/iphone/Maps/Classes/Routing/MWMRouter.mm +++ b/iphone/Maps/Classes/Routing/MWMRouter.mm @@ -439,7 +439,6 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi } downloadBlock:^(storage::TCountriesVec const & downloadCountries, TMWMVoidBlock onSuccess) { [MWMStorage downloadNodes:downloadCountries - alertController:activeAlertController onSuccess:onSuccess]; } downloadCompleteBlock:^{ diff --git a/iphone/Maps/Classes/Storage/MWMStorage.h b/iphone/Maps/Classes/Storage/MWMStorage.h index 52779669e6..5fd7cfd867 100644 --- a/iphone/Maps/Classes/Storage/MWMStorage.h +++ b/iphone/Maps/Classes/Storage/MWMStorage.h @@ -4,14 +4,13 @@ @interface MWMStorage : NSObject -+ (void)downloadNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess; -+ (void)retryDownloadNode:(storage::TCountryId const &)countryId - alertController:(MWMAlertViewController *)alertController; -+ (void)updateNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController; -+ (void)deleteNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController; ++ (void)downloadNode:(storage::TCountryId const &)countryId onSuccess:(TMWMVoidBlock)onSuccess; ++ (void)retryDownloadNode:(storage::TCountryId const &)countryId; ++ (void)updateNode:(storage::TCountryId const &)countryId; ++ (void)deleteNode:(storage::TCountryId const &)countryId; + (void)cancelDownloadNode:(storage::TCountryId const &)countryId; + (void)showNode:(storage::TCountryId const &)countryId; -+ (void)downloadNodes:(storage::TCountriesVec const &)countryIds alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess; ++ (void)downloadNodes:(storage::TCountriesVec const &)countryIds onSuccess:(TMWMVoidBlock)onSuccess; @end diff --git a/iphone/Maps/Classes/Storage/MWMStorage.mm b/iphone/Maps/Classes/Storage/MWMStorage.mm index b8e505529d..ec5ee00c52 100644 --- a/iphone/Maps/Classes/Storage/MWMStorage.mm +++ b/iphone/Maps/Classes/Storage/MWMStorage.mm @@ -12,64 +12,58 @@ using namespace storage; @implementation MWMStorage + (void)downloadNode:(TCountryId const &)countryId - alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess { if (IsEnoughSpaceForDownload(countryId, GetFramework().GetStorage())) { - [self checkConnectionAndPerformAction:[countryId, onSuccess] - { + [self checkConnectionAndPerformAction:[countryId, onSuccess] { GetFramework().GetStorage().DownloadNode(countryId); if (onSuccess) onSuccess(); - } alertController:alertController]; + }]; } else { - [alertController presentNotEnoughSpaceAlert]; + [[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert]; } } + (void)retryDownloadNode:(TCountryId const &)countryId - alertController:(MWMAlertViewController *)alertController { [self checkConnectionAndPerformAction:[countryId] { GetFramework().GetStorage().RetryDownloadNode(countryId); - } - alertController:alertController]; + }]; } + (void)updateNode:(TCountryId const &)countryId - alertController:(MWMAlertViewController *)alertController { if (IsEnoughSpaceForUpdate(countryId, GetFramework().GetStorage())) { - [self checkConnectionAndPerformAction:[countryId] - { + [self checkConnectionAndPerformAction:[countryId] { GetFramework().GetStorage().UpdateNode(countryId); - } alertController:alertController]; + }]; } else { - [alertController presentNotEnoughSpaceAlert]; + [[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert]; } } -+ (void)deleteNode:(TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController ++ (void)deleteNode:(TCountryId const &)countryId { auto & f = GetFramework(); if (f.IsRoutingActive()) { - [alertController presentDeleteMapProhibitedAlert]; + [[MWMAlertViewController activeAlertController] presentDeleteMapProhibitedAlert]; return; } if (f.HasUnsavedEdits(countryId)) { - [alertController presentUnsavedEditsAlertWithOkBlock:[countryId] - { - GetFramework().GetStorage().DeleteNode(countryId); - }]; + [[MWMAlertViewController activeAlertController] + presentUnsavedEditsAlertWithOkBlock:[countryId] { + GetFramework().GetStorage().DeleteNode(countryId); + }]; } else { @@ -88,7 +82,6 @@ using namespace storage; } + (void)downloadNodes:(TCountriesVec const &)countryIds - alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess { TMwmSize requiredSize = accumulate(countryIds.begin(), countryIds.end(), kMaxMwmSizeBytes, @@ -100,28 +93,26 @@ using namespace storage; }); if (GetPlatform().GetWritableStorageStatus(requiredSize) == Platform::TStorageStatus::STORAGE_OK) { - [self checkConnectionAndPerformAction:[countryIds, onSuccess] - { + [self checkConnectionAndPerformAction:[countryIds, onSuccess] { auto & s = GetFramework().GetStorage(); for (auto const & countryId : countryIds) s.DownloadNode(countryId); if (onSuccess) onSuccess(); - } alertController:alertController]; + }]; } else { - [alertController presentNotEnoughSpaceAlert]; + [[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert]; } } + (void)checkConnectionAndPerformAction:(TMWMVoidBlock)action - alertController:(MWMAlertViewController *)alertController { switch (Platform::ConnectionStatus()) { case Platform::EConnectionType::CONNECTION_NONE: - [alertController presentNoConnectionAlert]; + [[MWMAlertViewController activeAlertController] presentNoConnectionAlert]; break; case Platform::EConnectionType::CONNECTION_WIFI: action(); @@ -130,8 +121,7 @@ using namespace storage; { if (!GetFramework().GetDownloadingPolicy().IsCellularDownloadEnabled()) { - [alertController presentNoWiFiAlertWithOkBlock:[action] - { + [[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:[action] { GetFramework().GetDownloadingPolicy().EnableCellularDownload(true); action(); }]; diff --git a/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm b/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm index 1a6d91fc95..b25c34aa54 100644 --- a/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm +++ b/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm @@ -132,7 +132,6 @@ using namespace storage; }]; m_autoDownloadCountryId = m_countryId; [MWMStorage downloadNode:m_countryId - alertController:controller.alertController onSuccess:^{ [self showInQueue]; }]; @@ -203,8 +202,7 @@ using namespace storage; kStatScenario : kStatDownload }]; [self showInQueue]; - [MWMStorage retryDownloadNode:self->m_countryId - alertController:self.controller.alertController]; + [MWMStorage retryDownloadNode:self->m_countryId]; }; auto const cancelBlock = ^{ [Statistics logEvent:kStatDownloaderDownloadCancel withParameters:@{kStatFrom : kStatMap}]; @@ -293,7 +291,7 @@ using namespace storage; kStatScenario : kStatDownload }]; [self showInQueue]; - [MWMStorage retryDownloadNode:m_countryId alertController:self.controller.alertController]; + [MWMStorage retryDownloadNode:m_countryId]; } else { @@ -324,7 +322,6 @@ using namespace storage; kStatScenario : kStatDownload }]; [MWMStorage downloadNode:m_countryId - alertController:controller.alertController onSuccess:^{ [self showInQueue]; }];