diff options
author | v.mikhaylenko <v.mikhaylenko@corp.mail.ru> | 2015-07-13 16:01:25 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:55:42 +0300 |
commit | e38f2e0322836fd32975f487b73c6d9a206380ab (patch) | |
tree | 45195e976501cb7f30b417b00ee86dac85a0ff62 /iphone/Maps/Classes/CustomAlert | |
parent | 0a85a474e215ea6e8191db5bb747b6ba0bb1cf5f (diff) |
[ios] Dialogs review fixes.
Diffstat (limited to 'iphone/Maps/Classes/CustomAlert')
11 files changed, 137 insertions, 172 deletions
diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index f9ce2de4ef..6c8c6a1386 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -27,8 +27,8 @@ - (void)presentDisabledLocationAlert; - (void)presentLocationAlert; - (void)presentLocationServiceNotSupportedAlert; -- (void)presentNotConnectionAlert; -- (void)presentNotWifiAlertWithName:(NSString *)name downloadBlock:(void(^)())block; +- (void)presentNoConnectionAlert; +- (void)presentnoWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block; - (void)closeAlert; diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index 8e810325b8..7f4d62ad74 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -39,74 +39,62 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController - (void)presentRateAlert { - MWMAlert * alert = [MWMAlert rateAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.rateAlert]; } - (void)presentLocationAlert { - MWMAlert * alert = [MWMAlert locationAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.locationAlert]; } - (void)presentFacebookAlert { - MWMAlert * alert = [MWMAlert facebookAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.facebookAlert]; } - (void)presentLocationServiceNotSupportedAlert { - MWMAlert * alert = [MWMAlert locationServiceNotSupportedAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.locationServiceNotSupportedAlert]; } -- (void)presentNotConnectionAlert +- (void)presentNoConnectionAlert { - MWMAlert * alert = [MWMAlert notConnectionAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.noConnectionAlert]; } -- (void)presentNotWifiAlertWithName:(NSString *)name downloadBlock:(void(^)())block +- (void)presentnoWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block { - MWMAlert * alert = [MWMAlert notWiFiAlertWithName:name downloadBlock:block]; - [self displayAlert:alert]; + [self displayAlert:[MWMAlert noWiFiAlertWithName:name downloadBlock:block]]; } - (void)presentFeedbackAlertWithStarsCount:(NSUInteger)starsCount { - MWMAlert * alert = [MWMAlert feedbackAlertWithStarsCount:starsCount]; - [self displayAlert:alert]; + [self displayAlert:[MWMAlert feedbackAlertWithStarsCount:starsCount]]; } - (void)presentCrossCountryAlertWithCountries:(vector<storage::TIndex> const &)countries routes:(vector<storage::TIndex> const &)routes { - MWMAlert * alert = [MWMAlert crossCountryAlertWithCountries:countries routes:routes]; - [self displayAlert:alert]; + [self displayAlert:[MWMAlert crossCountryAlertWithCountries:countries routes:routes]]; } - (void)presentDownloaderAlertWithCountries:(vector<storage::TIndex> const &)countries routes:(vector<storage::TIndex> const &)routes { - MWMAlert * alert = [MWMAlert downloaderAlertWithAbsentCountries:countries routes:routes]; - [self displayAlert:alert]; + [self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries routes:routes]]; } - (void)presentRoutingDisclaimerAlert { - MWMAlert * alert = [MWMAlert routingDisclaimerAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.routingDisclaimerAlert]; } - (void)presentDisabledLocationAlert { - MWMAlert * alert = [MWMAlert disabledLocationAlert]; - [self displayAlert:alert]; + [self displayAlert:MWMAlert.disabledLocationAlert]; } - (void)presentAlert:(routing::IRouter::ResultCode)type { - MWMAlert * alert = [MWMAlert alert:type]; - [self displayAlert:alert]; + [self displayAlert:[MWMAlert alert:type]]; } - (void)displayAlert:(MWMAlert *)alert @@ -115,8 +103,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [self.ownerViewController addChildViewController:self]; self.view.center = self.ownerViewController.view.center; [self.ownerViewController.view addSubview:self.view]; - [[[[UIApplication sharedApplication] delegate] window] addSubview:self.view]; - self.view.frame = [[[[UIApplication sharedApplication] delegate] window] frame]; + UIWindow * window = [[[UIApplication sharedApplication] delegate] window]; + [window addSubview:self.view]; + self.view.frame = window.bounds; [self.view addSubview:alert]; alert.bounds = self.view.bounds; alert.center = self.view.center; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h index c6d504665f..b16ecabc72 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h @@ -11,11 +11,12 @@ #include "routing/router.hpp" #include "storage/storage.hpp" -@class MWMAlertViewController; +typedef void (^RightButtonAction)(); +@class MWMAlertViewController; @interface MWMAlert : UIView -@property (weak, nonatomic) MWMAlertViewController *alertController; +@property (weak, nonatomic) MWMAlertViewController * alertController; + (MWMAlert *)alert:(routing::IRouter::ResultCode)type; + (MWMAlert *)downloaderAlertWithAbsentCountries:(vector<storage::TIndex> const &)countries routes:(vector<storage::TIndex> const &)routes; @@ -26,8 +27,8 @@ + (MWMAlert *)locationAlert; + (MWMAlert *)routingDisclaimerAlert; + (MWMAlert *)disabledLocationAlert; -+ (MWMAlert *)notWiFiAlertWithName:(NSString *)name downloadBlock:(void(^)())block; -+ (MWMAlert *)notConnectionAlert; ++ (MWMAlert *)noWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block; ++ (MWMAlert *)noConnectionAlert; + (MWMAlert *)locationServiceNotSupportedAlert; - (void)close; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm index 4900e5fa49..cca5dcb876 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm @@ -8,14 +8,12 @@ #import "MWMAlert.h" #import "MWMAlertViewController.h" -#import "MWMDownloadTransitMapAlert.h" #import "MWMDefaultAlert.h" -#import "MWMFeedbackAlert.h" -#import "MWMRateAlert.h" +#import "MWMDownloadTransitMapAlert.h" #import "MWMFacebookAlert.h" +#import "MWMFeedbackAlert.h" #import "MWMLocationAlert.h" - -extern UIColor * const kActiveDownloaderViewColor = [UIColor colorWithRed:211/255. green:209/255. blue:205/255. alpha:1.]; +#import "MWMRateAlert.h" @implementation MWMAlert @@ -44,14 +42,14 @@ extern UIColor * const kActiveDownloaderViewColor = [UIColor colorWithRed:211/25 return [MWMDefaultAlert disabledLocationAlert]; } -+ (MWMAlert *)notWiFiAlertWithName:(NSString *)name downloadBlock:(void(^)())block ++ (MWMAlert *)noWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block { - return [MWMDefaultAlert notWiFiAlertWithName:name downloadBlock:block]; + return [MWMDefaultAlert noWiFiAlertWithName:name downloadBlock:block]; } -+ (MWMAlert *)notConnectionAlert ++ (MWMAlert *)noConnectionAlert { - return [MWMDefaultAlert notConnectionAlert]; + return [MWMDefaultAlert noConnectionAlert]; } + (MWMAlert *)locationServiceNotSupportedAlert @@ -69,7 +67,6 @@ extern UIColor * const kActiveDownloaderViewColor = [UIColor colorWithRed:211/25 return [MWMDownloadTransitMapAlert crossCountryAlertWithCountries:countries routes:routes]; } - + (MWMAlert *)downloaderAlertWithAbsentCountries:(vector<storage::TIndex> const &)countries routes:(vector<storage::TIndex> const &)routes { return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries routes:routes]; @@ -102,7 +99,7 @@ extern UIColor * const kActiveDownloaderViewColor = [UIColor colorWithRed:211/25 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { -// Should override this method if you wont custom relayout after rotation. +// Should override this method if you want custom relayout after rotation. } - (void)close @@ -123,7 +120,7 @@ extern UIColor * const kActiveDownloaderViewColor = [UIColor colorWithRed:211/25 - (void)applicationDidEnterBackground { -// We should not be here when entering back to foreground state +// Should close alert when application entered background. [self close]; } diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h index ed72c045ec..911929e801 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h @@ -18,8 +18,8 @@ + (instancetype)pointsInDifferentMWMAlert; + (instancetype)routingDisclaimerAlert; + (instancetype)disabledLocationAlert; -+ (instancetype)notWiFiAlertWithName:(NSString *)name downloadBlock:(void(^)())block; -+ (instancetype)notConnectionAlert; ++ (instancetype)noWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block; ++ (instancetype)noConnectionAlert; + (instancetype)locationServiceNotSupportedAlert; @end diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm index 885b88c4c8..93489dde56 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm @@ -6,19 +6,19 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // -#import "MWMDefaultAlert.h" -#import "MWMAlertViewController.h" -#import "UILabel+RuntimeAttributes.h" -#import "UIKitCategories.h" +#import "LocationManager.h" #import "MapsAppDelegate.h" #import "MapViewController.h" +#import "MWMAlertViewController.h" +#import "MWMDefaultAlert.h" #import "MWMPlacePageViewManager.h" -#import "LocationManager.h" +#import "UIButton+RuntimeAttributes.h" +#import "UIKitCategories.h" +#import "UILabel+RuntimeAttributes.h" #include "Framework.h" -typedef void (^RightButtonAction)(); -static CGFloat const kDividerTopConstant = -8; +static CGFloat const kDividerTopConstant = -8.; @interface MWMDefaultAlert () @@ -44,18 +44,17 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; + (instancetype)locationServiceNotSupportedAlert { - MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"device_doesnot_support_location_services" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; - return alert; + return [self defaultAlertWithTitle:@"device_doesnot_support_location_services" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; } -+ (instancetype)notConnectionAlert ++ (instancetype)noConnectionAlert { MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"no_internet_connection_detected" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } -+ (instancetype)notWiFiAlertWithName:(NSString *)name downloadBlock:(void(^)())block ++ (instancetype)noWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block { MWMDefaultAlert * alert = [self defaultAlertWithTitle:name message:nil rightButtonTitle:@"use_cellular_data" leftButtonTitle:@"cancel" rightButtonAction:block]; [alert setNeedsCloseAlertAfterEnterBackground]; @@ -96,10 +95,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; { RightButtonAction action = ^ { - MWMPlacePageViewManager * manager = [MapsAppDelegate theApp].m_mapViewController.placePageManager; - [[MapsAppDelegate theApp].m_locationManager stop:(id<LocationObserver>)manager]; GetFramework().GetLocationState()->SwitchToNextMode(); - [[MapsAppDelegate theApp].m_locationManager start:(id<LocationObserver>)manager]; }; return [MWMDefaultAlert defaultAlertWithTitle:@"dialog_routing_location_turn_on" message:@"dialog_routing_location_unknown_turn_on" rightButtonTitle:@"turn_on" leftButtonTitle:@"later" rightButtonAction:action]; } diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h index 95f0e6f735..e5c7e7b501 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.h @@ -8,8 +8,8 @@ #import "MWMAlert.h" -#include "std/vector.hpp" #include "storage/storage.hpp" +#include "std/vector.hpp" @interface MWMDownloadTransitMapAlert : MWMAlert + (instancetype)crossCountryAlertWithMaps:(vector<storage::TIndex> const &)maps routes:(vector<storage::TIndex> const &)routes; diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm index 414b484f3a..dc0332479c 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm @@ -6,13 +6,14 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // -#import "MWMDownloadTransitMapAlert.h" -#import "MWMAlertViewController.h" #import "ActiveMapsVC.h" -#import "UIKitCategories.h" +#import "MWMAlertViewController.h" #import "MWMDownloaderDialogCell.h" #import "MWMDownloaderDialogHeader.h" +#import "MWMDownloadTransitMapAlert.h" #import "UIColor+MapsMeColor.h" +#import "UIKitCategories.h" +#import "UILabel+RuntimeAttributes.h" typedef void (^MWMDownloaderBlock)(); @@ -21,7 +22,6 @@ static CGFloat const kCellHeight = 32.; static CGFloat const kHeaderHeight = 43.; static CGFloat const kHeaderAndFooterHeight = 44.; static CGFloat const kMinimumOffset = 20.; -static NSUInteger numberOfSection; typedef NS_ENUM(NSUInteger, SelectionState) { @@ -32,7 +32,6 @@ typedef NS_ENUM(NSUInteger, SelectionState) }; static NSString * const kDownloadTransitMapAlertNibName = @"MWMDownloadTransitMapAlert"; -extern UIColor * const kActiveDownloaderViewColor; @interface MWMDownloadTransitMapAlert () { @@ -48,6 +47,7 @@ extern UIColor * const kActiveDownloaderViewColor; @property (weak, nonatomic) IBOutlet UITableView * dialogsTableView; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewHeight; @property (weak, nonatomic) IBOutlet UIView * divider; +@property (nonatomic) NSUInteger numberOfSections; @property (nonatomic) MWMDownloaderDialogHeader * mapsHeader; @property (nonatomic) MWMDownloaderDialogHeader * routesHeader; @@ -64,16 +64,16 @@ extern UIColor * const kActiveDownloaderViewColor; + (instancetype)crossCountryAlertWithMaps:(vector<storage::TIndex> const &)maps routes:(vector<storage::TIndex> const &)routes { MWMDownloadTransitMapAlert * alert = [self alertWithMaps:maps routes:routes]; - alert.titleLabel.text = L(@"dialog_routing_download_and_build_cross_route"); - alert.messageLabel.text = L(@"dialog_routing_download_cross_route"); + alert.titleLabel.localizedText = @"dialog_routing_download_and_build_cross_route"; + alert.messageLabel.localizedText = @"dialog_routing_download_cross_route"; return alert; } + (instancetype)downloaderAlertWithMaps:(vector<storage::TIndex> const &)maps routes:(vector<storage::TIndex> const &)routes { MWMDownloadTransitMapAlert * alert = [self alertWithMaps:maps routes:routes]; - alert.titleLabel.text = L(@"dialog_routing_download_files"); - alert.messageLabel.text = L(@"dialog_routing_download_and_update_all"); + alert.titleLabel.localizedText = @"dialog_routing_download_files"; + alert.messageLabel.localizedText = @"dialog_routing_download_and_update_all"; return alert; } @@ -82,11 +82,11 @@ extern UIColor * const kActiveDownloaderViewColor; MWMDownloadTransitMapAlert * alert = [[[NSBundle mainBundle] loadNibNamed:kDownloadTransitMapAlertNibName owner:nil options:nil] firstObject]; alert->maps = maps; alert->routes = routes; - numberOfSection = 0; - if (maps.size() > 0) - numberOfSection++; - if (routes.size() > 0) - numberOfSection++; + alert.numberOfSections = 0; + if (!maps.empty()) + alert.numberOfSections++; + if (!routes.empty()) + alert.numberOfSections++; [alert configure]; return alert; } @@ -98,13 +98,14 @@ extern UIColor * const kActiveDownloaderViewColor; if (maps.size() < 2 && routes.size() < 2) self.dialogsTableView.scrollEnabled = NO; __weak MWMDownloadTransitMapAlert * weakSelf = self; - self.downloaderBlock = ^{ + self.downloaderBlock = ^ + { __strong MWMDownloadTransitMapAlert * self = weakSelf; - ActiveMapsLayout & layout = GetFramework().GetCountryTree().GetActiveMapLayout(); + storage::Storage & s = GetFramework().Storage(); for (auto const & index : maps) - layout.DownloadMap(index, TMapOptions::EMapWithCarRouting); + s.DownloadCountry(index, TMapOptions::EMapWithCarRouting); for (auto const & index : routes) - layout.DownloadMap(index, TMapOptions::ECarRouting); + s.DownloadCountry(index, TMapOptions::ECarRouting); }; [self.dialogsTableView reloadData]; } @@ -152,7 +153,7 @@ extern UIColor * const kActiveDownloaderViewColor; { case SelectionStateNone: { - CGFloat const height = kHeaderAndFooterHeight * numberOfSection; + CGFloat const height = kHeaderAndFooterHeight * self.numberOfSections; self.tableViewHeight.constant = height; [self.dialogsTableView.visibleCells enumerateObjectsUsingBlock:^(MWMDownloaderDialogCell * obj, NSUInteger idx, BOOL *stop) { obj.titleLabel.alpha = 0.; @@ -169,30 +170,24 @@ extern UIColor * const kActiveDownloaderViewColor; case SelectionStateRoutes: case SelectionStateBoth: { - NSUInteger cellCount; - if (state == SelectionStateBoth) - cellCount = maps.size() + routes.size(); - else if (state == SelectionStateMaps) - cellCount = maps.size(); - else - cellCount = routes.size(); - - CGFloat const height = [self bounded:kCellHeight * cellCount + kHeaderAndFooterHeight * numberOfSection withHeight:self.superview.height]; + NSUInteger const cellCount = self.cellCountForCurrentState; + CGFloat const height = [self bounded:kCellHeight * cellCount + kHeaderAndFooterHeight * self.numberOfSections withHeight:self.superview.height]; self.tableViewHeight.constant = height; [UIView animateWithDuration:.05 animations:^ - { + { [self layoutSubviews]; - } - completion:^(BOOL finished) - { - [UIView animateWithDuration:.3 animations:^{ + } + completion:^(BOOL finished) + { + [UIView animateWithDuration:.3 animations:^{ [self.dialogsTableView beginUpdates]; - [self.dialogsTableView.visibleCells enumerateObjectsUsingBlock:^(MWMDownloaderDialogCell * obj, NSUInteger idx, BOOL *stop) { - obj.titleLabel.alpha = 1.; + [self.dialogsTableView.visibleCells enumerateObjectsUsingBlock:^(MWMDownloaderDialogCell * obj, NSUInteger idx, BOOL *stop) + { + obj.titleLabel.alpha = 1.; }]; [self.dialogsTableView endUpdates]; - }]; - }]; + }]; + }]; break; } } @@ -211,25 +206,29 @@ extern UIColor * const kActiveDownloaderViewColor; switch (self.state) { case SelectionStateNone: - self.tableViewHeight.constant = kHeaderAndFooterHeight * numberOfSection ; + self.tableViewHeight.constant = kHeaderAndFooterHeight * self.numberOfSections ; break; case SelectionStateMaps: case SelectionStateRoutes: case SelectionStateBoth: { - NSUInteger cellCount; - if (self.state == SelectionStateBoth) - cellCount = maps.size() + routes.size(); - else if (self.state == SelectionStateMaps) - cellCount = maps.size(); - else - cellCount = routes.size(); - self.tableViewHeight.constant = [self bounded:(kCellHeight * cellCount + kHeaderAndFooterHeight * numberOfSection) withHeight:height];; + NSUInteger const cellCount = self.cellCountForCurrentState; + self.tableViewHeight.constant = [self bounded:(kCellHeight * cellCount + kHeaderAndFooterHeight * self.numberOfSections) withHeight:height];; break; } } } +- (NSUInteger)cellCountForCurrentState +{ + if (self.state == SelectionStateBoth) + return maps.size() + routes.size(); + else if (self.state == SelectionStateMaps) + return maps.size(); + else + return routes.size(); +} + - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { CGFloat const height = UIInterfaceOrientationIsLandscape(orientation) ? MIN(self.superview.width, self.superview.height) : MAX(self.superview.width, self.superview.height); @@ -242,15 +241,12 @@ extern UIColor * const kActiveDownloaderViewColor; - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return numberOfSection; + return self.numberOfSections; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (section == 0) - return maps.size(); - else - return routes.size(); + return section == 0 ? maps.size() : routes.size(); } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section @@ -275,7 +271,7 @@ extern UIColor * const kActiveDownloaderViewColor; - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - ActiveMapsLayout & layout = GetFramework().GetCountryTree().GetActiveMapLayout(); + storage::Storage & s = GetFramework().Storage(); if (section == 0) { if (self.mapsHeader) @@ -283,19 +279,20 @@ extern UIColor * const kActiveDownloaderViewColor; if (maps.size() > 1) { - uint64_t s = 0; + uint64_t totalRoutingSize = 0; for (auto const & index : maps) - s += layout.GetCountrySize(index, TMapOptions::EMapWithCarRouting).second; + totalRoutingSize += s.CountrySizeInBytes(index, TMapOptions::EMapWithCarRouting).second; - NSString * size = [NSString stringWithFormat:@"%@ %@", @(s / (1024 * 1024)), L(@"mb")]; + NSString * size = [NSString stringWithFormat:@"%@ %@", @(totalRoutingSize / (1024 * 1024)), L(@"mb")]; NSString * title = [NSString stringWithFormat:@"%@(%@)", L(@"dialog_routing_maps"), @(maps.size())]; self.mapsHeader = [MWMDownloaderDialogHeader headerForOwnerAlert:self title:title size:size]; } else { + NSAssert(!maps.empty(), @"Maps can't be empty!"); storage::TIndex const & index = maps[0]; - NSString * title = [NSString stringWithUTF8String:layout.GetFormatedCountryName(index).c_str()]; - NSString * size = [NSString stringWithFormat:@"%@ %@", @(layout.GetCountrySize(index, TMapOptions::EMapWithCarRouting).second / (1024 * 1024)), L(@"mb")]; + NSString * title = [NSString stringWithUTF8String:s.CountryName(index).c_str()]; + NSString * size = [NSString stringWithFormat:@"%@ %@", @(s.CountrySizeInBytes(index, TMapOptions::EMapWithCarRouting).second / (1024 * 1024)), L(@"mb")]; self.mapsHeader = [MWMDownloaderDialogHeader headerForOwnerAlert:self title:title size:size]; self.mapsHeader.expandImage.hidden = YES; self.mapsHeader.headerButton.enabled = NO; @@ -303,50 +300,38 @@ extern UIColor * const kActiveDownloaderViewColor; } return self.mapsHeader; } - else - { - if (self.routesHeader) - return self.routesHeader; - - if (routes.size() > 1) - { - uint64_t s = 0; - for (auto const & index : routes) - s += layout.GetCountrySize(index, TMapOptions::ECarRouting).second; - NSString * size = [NSString stringWithFormat:@"%@ %@", @(s / (1024 * 1024)), L(@"mb")]; - NSString * title = [NSString stringWithFormat:@"%@(%@)", L(@"dialog_routing_routes_size"), @(routes.size())]; - self.routesHeader = [MWMDownloaderDialogHeader headerForOwnerAlert:self title:title size:size]; - } - else - { - storage::TIndex const & index = routes[0]; - NSString * title = [NSString stringWithUTF8String:layout.GetFormatedCountryName(index).c_str()]; - NSString * size = [NSString stringWithFormat:@"%@ %@", @(layout.GetCountrySize(index, TMapOptions::ECarRouting).second / (1024 * 1024)), L(@"mb")]; - self.routesHeader = [MWMDownloaderDialogHeader headerForOwnerAlert:self title:title size:size]; - self.routesHeader.expandImage.hidden = YES; - self.routesHeader.headerButton.enabled = NO; - [self.routesHeader layoutSizeLabel]; - } + if (self.routesHeader) return self.routesHeader; - } -} -- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section -{ - - UIView * view = [[UIView alloc] init]; - if (numberOfSection == 2) + if (routes.size() > 1) { - if (section == 0) - view.backgroundColor = [UIColor blackDividers]; - else - view.backgroundColor = [UIColor clearColor]; + uint64_t totalRoutingSize = 0; + for (auto const & index : routes) + totalRoutingSize += s.CountrySizeInBytes(index, TMapOptions::ECarRouting).second; + + NSString * size = [NSString stringWithFormat:@"%@ %@", @(totalRoutingSize / (1024 * 1024)), L(@"mb")]; + NSString * title = [NSString stringWithFormat:@"%@(%@)", L(@"dialog_routing_routes_size"), @(routes.size())]; + self.routesHeader = [MWMDownloaderDialogHeader headerForOwnerAlert:self title:title size:size]; } else { - view.backgroundColor = [UIColor clearColor]; + NSAssert(!routes.empty(), @"Routes can't be empty"); + storage::TIndex const & index = routes[0]; + NSString * title = [NSString stringWithUTF8String:s.CountryName(index).c_str()]; + NSString * size = [NSString stringWithFormat:@"%@ %@", @(s.CountrySizeInBytes(index, TMapOptions::ECarRouting).second / (1024 * 1024)), L(@"mb")]; + self.routesHeader = [MWMDownloaderDialogHeader headerForOwnerAlert:self title:title size:size]; + self.routesHeader.expandImage.hidden = YES; + self.routesHeader.headerButton.enabled = NO; + [self.routesHeader layoutSizeLabel]; } + return self.routesHeader; +} + +- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section +{ + UIView * view = [[UIView alloc] init]; + view.backgroundColor = self.numberOfSections == 2 && section == 9 ? UIColor.blackDividers : UIColor.clearColor; return view; } @@ -356,8 +341,8 @@ extern UIColor * const kActiveDownloaderViewColor; if (!cell) cell = [[MWMDownloaderDialogCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier]; storage::TIndex const & index = indexPath.section == 0 ? maps[indexPath.row] : routes[indexPath.row]; - ActiveMapsLayout & layout = GetFramework().GetCountryTree().GetActiveMapLayout(); - cell.titleLabel.text = [NSString stringWithUTF8String:layout.GetFormatedCountryName(index).c_str()]; + storage::Storage & s = GetFramework().Storage(); + cell.titleLabel.text = [NSString stringWithUTF8String:s.CountryName(index).c_str()]; return cell; } diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloaderDialogHeader.mm b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloaderDialogHeader.mm index b265e1104e..a29b4a5d84 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloaderDialogHeader.mm +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloaderDialogHeader.mm @@ -40,10 +40,7 @@ static NSString * const kDownloaderDialogHeaderNibName = @"MWMDownloaderDialogHe self.dividerView.hidden = currentState; [UIView animateWithDuration:.15 animations:^ { - if (sender.selected) - self.expandImage.transform = CGAffineTransformMakeRotation(M_PI); - else - self.expandImage.transform = CGAffineTransformIdentity; + self.expandImage.transform = sender.selected ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformIdentity; }]; [self.ownerAlert showDownloadDetail:sender]; } diff --git a/iphone/Maps/Classes/CustomAlert/FeedbackAlert/MWMFeedbackAlert.mm b/iphone/Maps/Classes/CustomAlert/FeedbackAlert/MWMFeedbackAlert.mm index bac2ec5203..d0b81e0b8e 100644 --- a/iphone/Maps/Classes/CustomAlert/FeedbackAlert/MWMFeedbackAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/FeedbackAlert/MWMFeedbackAlert.mm @@ -10,6 +10,7 @@ #import "MWMAlertViewController.h" #import <MessageUI/MFMailComposeViewController.h> #import "UIKitCategories.h" +#import "AppInfo.h" #import <sys/utsname.h> #import "3party/Alohalytics/src/alohalytics_objc.h" @@ -24,7 +25,6 @@ static NSString * const kFeedbackAlertNibName = @"MWMFeedbackAlert"; static NSString * const kRateEmail = @"rating@maps.me"; extern NSDictionary * const deviceNames; -extern UIColor * const kActiveDownloaderViewColor; extern NSString * const kLocaleUsedInSupportEmails; extern NSString * const kRateAlertEventName; @@ -62,11 +62,11 @@ extern NSString * const kRateAlertEventName; NSString * language = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails] displayNameForKey:NSLocaleLanguageCode value:languageCode]; NSString * locale = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode]; NSString * country = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails] displayNameForKey:NSLocaleCountryCode value:locale]; - NSString * bundleVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; + NSString * bundleVersion = AppInfo.sharedInfo.bundleVersion; NSString * text = [NSString stringWithFormat:@"\n\n\n\n- %@ (%@)\n- MAPS.ME %@\n- %@/%@", device, [UIDevice currentDevice].systemVersion, bundleVersion, language, country]; MFMailComposeViewController * mailController = [[MFMailComposeViewController alloc] init]; mailController.mailComposeDelegate = self; - [mailController setSubject:[NSString stringWithFormat:@"%@ : %@", L(@"rating_just_rated"),@(self.starsCount)]]; + [mailController setSubject:[NSString stringWithFormat:@"%@ : %@", L(@"rating_just_rated"), @(self.starsCount)]]; [mailController setToRecipients:@[kRateEmail]]; [mailController setMessageBody:text isHTML:NO]; mailController.navigationBar.tintColor = [UIColor blackColor]; diff --git a/iphone/Maps/Classes/CustomAlert/RateAlert/MWMRateAlert.mm b/iphone/Maps/Classes/CustomAlert/RateAlert/MWMRateAlert.mm index 6b72d8409c..8e67134d83 100644 --- a/iphone/Maps/Classes/CustomAlert/RateAlert/MWMRateAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/RateAlert/MWMRateAlert.mm @@ -52,7 +52,7 @@ static NSString * const kRateAlertNibName = @"MWMRateAlert"; { [UIView animateWithDuration:0.15 animations:^ { - self.oneStarPushImageView.alpha = 1; + self.oneStarPushImageView.alpha = 1.; self.oneStarButton.selected = YES; } completion:^(BOOL finished) @@ -72,7 +72,7 @@ static NSString * const kRateAlertNibName = @"MWMRateAlert"; { [UIView animateWithDuration:0.15 animations:^ { - self.twoStarPushImageView.alpha = 1; + self.twoStarPushImageView.alpha = 1.; self.oneStarButton.selected = YES; self.twoStarButton.selected = YES; } @@ -115,11 +115,11 @@ static NSString * const kRateAlertNibName = @"MWMRateAlert"; { [UIView animateWithDuration:0.15 animations:^ { - self.fourStarPushImageView.alpha = 1.; - self.oneStarButton.selected = YES; - self.twoStarButton.selected = YES; - self.threeStarButton.selected = YES; - self.fourStarButton.selected = YES; + self.fourStarPushImageView.alpha = 1.; + self.oneStarButton.selected = YES; + self.twoStarButton.selected = YES; + self.threeStarButton.selected = YES; + self.fourStarButton.selected = YES; } completion:^(BOOL finished) { |