diff options
author | Ilya Grechuhin <i.grechuhin@gmail.com> | 2016-12-01 11:26:56 +0300 |
---|---|---|
committer | Ilya Grechuhin <i.grechuhin@gmail.com> | 2016-12-01 11:46:28 +0300 |
commit | 57411e0eee752325b8720c1c00cffe15a56d2060 (patch) | |
tree | a8fb1e9c923e564836422e44ac8524b3e268b7c2 /iphone/Maps | |
parent | 6f0e188b14f7a689c50af422ae58aeb62bc9d27c (diff) |
[MAPSME-3126] [ios] Code cleanup.
Diffstat (limited to 'iphone/Maps')
10 files changed, 41 insertions, 66 deletions
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/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/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<CGFloat>(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]; }]; |