From 5411f68eaa11c5b56fec0daf56ad830b96557d67 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Tue, 16 Aug 2016 17:16:43 +0300 Subject: [PATCH 1/2] [ios] App startup optimization. --- .../MWMMapViewControlsManager.mm | 14 +++-- .../MWMOpeningHoursClosedSpanTableViewCell.mm | 5 +- .../MWMMapDownloaderPlaceTableViewCell.mm | 16 +++--- .../MWMMapDownloaderSubplaceTableViewCell.mm | 12 ++--- .../Cells/MWMMapDownloaderTableViewCell.mm | 13 ++--- iphone/Maps/Classes/MapViewController.mm | 2 +- iphone/Maps/Classes/MapsAppDelegate.mm | 6 +-- iphone/Maps/Classes/RouteState/RouteState.h | 15 ------ iphone/Maps/Classes/Routing/MWMRouter.h | 1 - iphone/Maps/Classes/Routing/MWMRouter.mm | 44 ++++------------ .../Classes/Routing/MWMRouterSavedState.h | 23 ++++++++ .../MWMRouterSavedState.mm} | 52 +++++++++++-------- iphone/Maps/Maps.xcodeproj/project.pbxproj | 24 +++------ 13 files changed, 102 insertions(+), 125 deletions(-) delete mode 100644 iphone/Maps/Classes/RouteState/RouteState.h create mode 100644 iphone/Maps/Classes/Routing/MWMRouterSavedState.h rename iphone/Maps/Classes/{RouteState/RouteState.mm => Routing/MWMRouterSavedState.mm} (55%) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 70e9fb3a11..88ad502707 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -73,11 +73,13 @@ extern NSString * const kAlohalyticsTapEventKey; - (UIStatusBarStyle)preferredStatusBarStyle { + MWMSearchManagerState const searchManagerState = + _searchManager ? _searchManager.state : MWMSearchManagerStateHidden; BOOL const isNightMode = [UIColor isNightMode]; - BOOL const isLight = (self.searchManager.state == MWMSearchManagerStateMapSearch && + BOOL const isLight = (searchManagerState == MWMSearchManagerStateMapSearch && self.navigationState != MWMNavigationDashboardStateNavigation) || - (self.searchManager.state != MWMSearchManagerStateMapSearch && - self.searchManager.state != MWMSearchManagerStateHidden) || + (searchManagerState != MWMSearchManagerStateMapSearch && + searchManagerState != MWMSearchManagerStateHidden) || self.navigationState == MWMNavigationDashboardStatePlanning || self.menuState == MWMBottomMenuStateActive || self.isDirectionViewShown || (isNightMode && self.navigationState != MWMNavigationDashboardStateHidden) || @@ -512,7 +514,11 @@ extern NSString * const kAlohalyticsTapEventKey; - (MWMNavigationDashboardState)navigationState { return self.navigationManager.state; } - (MWMPlacePageEntity *)placePageEntity { return self.placePageManager.entity; } -- (BOOL)isDirectionViewShown { return self.placePageManager.isDirectionViewShown; } +- (BOOL)isDirectionViewShown +{ + return _placePageManager ? _placePageManager.isDirectionViewShown : NO; +} + - (void)setTopBound:(CGFloat)topBound { if (IPAD) diff --git a/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm b/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm index 84631647cb..52c967f980 100644 --- a/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm +++ b/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm @@ -13,11 +13,10 @@ CGFloat labelWidth() return label.width; } -static CGFloat const kLabelWidth = labelWidth(); - BOOL isCompactForCellWidth(CGFloat width) { - CGFloat const widthOfAllElementsWithoutLabel = 234.0; + static CGFloat const kLabelWidth = labelWidth(); + CGFloat constexpr widthOfAllElementsWithoutLabel = 234.0; CGFloat const maxLabelWidthForCompactCell = width - widthOfAllElementsWithoutLabel; return kLabelWidth < maxLabelWidthForCompactCell; } diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm index b9a640783f..69a584e07d 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm @@ -4,12 +4,6 @@ #include "Framework.h" -namespace -{ - NSDictionary * const kSelectedAreaAttrs = @{ NSFontAttributeName : [UIFont bold12] }; - NSDictionary * const kUnselectedAreaAttrs = @{ NSFontAttributeName : [UIFont regular12] }; -} // namespace - @interface MWMMapDownloaderTableViewCell () - (NSAttributedString *)matchedString:(NSString *)str selectedAttrs:(NSDictionary *)selectedAttrs unselectedAttrs:(NSDictionary *)unselectedAttrs; @@ -46,21 +40,23 @@ namespace { [super config:nodeAttrs]; BOOL isDescriptionVisible = NO; + NSDictionary * const selectedAreaAttrs = @{ NSFontAttributeName : [UIFont bold12] }; + NSDictionary * const unselectedAreaAttrs = @{ NSFontAttributeName : [UIFont regular12] }; if (self.needDisplayArea && nodeAttrs.m_topmostParentInfo.size() == 1) { string const & areaName = nodeAttrs.m_topmostParentInfo[0].m_localName; isDescriptionVisible = (areaName != GetFramework().Storage().GetRootId()); if (isDescriptionVisible) self.descriptionLabel.attributedText = [self matchedString:@(areaName.c_str()) - selectedAttrs:kSelectedAreaAttrs - unselectedAttrs:kUnselectedAreaAttrs]; + selectedAttrs:selectedAreaAttrs + unselectedAttrs:unselectedAreaAttrs]; } else if (!nodeAttrs.m_nodeLocalDescription.empty()) { isDescriptionVisible = YES; self.descriptionLabel.attributedText = [self matchedString:@(nodeAttrs.m_nodeLocalDescription.c_str()) - selectedAttrs:kSelectedAreaAttrs - unselectedAttrs:kUnselectedAreaAttrs]; + selectedAttrs:selectedAreaAttrs + unselectedAttrs:unselectedAreaAttrs]; } self.descriptionLabel.hidden = !isDescriptionVisible; self.titleBottomOffset.priority = isDescriptionVisible ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh; diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm index adc95d9537..41ad2a8f64 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm @@ -2,12 +2,6 @@ #import "MWMMapDownloaderSubplaceTableViewCell.h" #import "UIFont+MapsMeFonts.h" -namespace -{ - NSDictionary * const kSelectedSubPlaceAttrs = @{ NSFontAttributeName : [UIFont bold14] }; - NSDictionary * const kUnselectedSubPlaceAttrs = @{ NSFontAttributeName : [UIFont regular14] }; -} // namespace - @interface MWMMapDownloaderTableViewCell () - (NSAttributedString *)matchedString:(NSString *)str selectedAttrs:(NSDictionary *)selectedAttrs unselectedAttrs:(NSDictionary *)unselectedAttrs; @@ -39,9 +33,11 @@ namespace - (void)setSubplaceText:(NSString *)text { + NSDictionary * const selectedSubPlaceAttrs = @{ NSFontAttributeName : [UIFont bold14] }; + NSDictionary * const unselectedSubPlaceAttrs = @{ NSFontAttributeName : [UIFont regular14] }; self.subPlace.attributedText = [self matchedString:text - selectedAttrs:kSelectedSubPlaceAttrs - unselectedAttrs:kUnselectedSubPlaceAttrs]; + selectedAttrs:selectedSubPlaceAttrs + unselectedAttrs:unselectedSubPlaceAttrs]; } @end diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm index ba96079ed0..7dac7f1de8 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm @@ -7,12 +7,6 @@ #include "Framework.h" -namespace -{ - NSDictionary * const kSelectedTitleAttrs = @{ NSFontAttributeName : [UIFont bold17] }; - NSDictionary * const kUnselectedTitleAttrs = @{ NSFontAttributeName : [UIFont regular17] }; -} // namespace - @interface MWMMapDownloaderTableViewCell () @property (nonatomic) MWMCircularProgress * progress; @@ -75,9 +69,12 @@ namespace - (void)config:(storage::NodeAttrs const &)nodeAttrs { [self configProgress:nodeAttrs]; + + NSDictionary * const selectedTitleAttrs = @{ NSFontAttributeName : [UIFont bold17] }; + NSDictionary * const unselectedTitleAttrs = @{ NSFontAttributeName : [UIFont regular17] }; self.title.attributedText = [self matchedString:@(nodeAttrs.m_nodeLocalName.c_str()) - selectedAttrs:kSelectedTitleAttrs - unselectedAttrs:kUnselectedTitleAttrs]; + selectedAttrs:selectedTitleAttrs + unselectedAttrs:unselectedTitleAttrs]; TMwmSize const size = self.mode == mwm::DownloaderMode::Downloaded ? nodeAttrs.m_downloadingMwmSize : nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize; diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 502b729a42..b969472835 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -26,7 +26,7 @@ #import "MWMTableViewController.h" #import "MWMWhatsNewNavigationController.h" #import "MapsAppDelegate.h" -#import "RouteState.h" +#import "MWMRouterSavedState.h" #import "Statistics.h" #import "UIColor+MapsMeColor.h" #import "UIFont+MapsMeFonts.h" diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index dcadc688d5..ddc9f60582 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -17,7 +17,7 @@ #import "MWMTextToSpeech.h" #import "MapViewController.h" #import "Preferences.h" -#import "RouteState.h" +#import "MWMRouterSavedState.h" #import "Statistics.h" #import "UIColor+MapsMeColor.h" #import "UIFont+MapsMeFonts.h" @@ -627,7 +627,7 @@ using namespace osm_auth_ios; LOG(LINFO, ("applicationWillResignActive")); [self.mapViewController onGetFocus:NO]; [self.mapViewController.appWallAd close]; - [RouteState save]; + [MWMRouterSavedState store]; GetFramework().SetRenderingEnabled(false); [MWMLocationManager applicationWillResignActive]; } @@ -664,7 +664,7 @@ using namespace osm_auth_ios; [[Statistics instance] applicationDidBecomeActive]; GetFramework().SetRenderingEnabled(true); [MWMLocationManager applicationDidBecomeActive]; - [[MWMRouter router] restore]; + [MWMRouterSavedState restore]; } - (void)dealloc diff --git a/iphone/Maps/Classes/RouteState/RouteState.h b/iphone/Maps/Classes/RouteState/RouteState.h deleted file mode 100644 index a7e83c20f0..0000000000 --- a/iphone/Maps/Classes/RouteState/RouteState.h +++ /dev/null @@ -1,15 +0,0 @@ -#import - -#include - -@interface RouteState : NSObject - -@property (nonatomic, readonly) BOOL hasActualRoute; -@property (nonatomic) m2::PointD endPoint; - -+ (instancetype)savedState; - -+ (void)save; -+ (void)remove; - -@end diff --git a/iphone/Maps/Classes/Routing/MWMRouter.h b/iphone/Maps/Classes/Routing/MWMRouter.h index ca4fb95387..67a1c037f6 100644 --- a/iphone/Maps/Classes/Routing/MWMRouter.h +++ b/iphone/Maps/Classes/Routing/MWMRouter.h @@ -19,7 +19,6 @@ - (void)rebuildWithBestRouter:(BOOL)bestRouter; - (void)start; - (void)stop; -- (void)restore; - (instancetype)init __attribute__((unavailable("call +router instead"))); - (instancetype)copy __attribute__((unavailable("call +router instead"))); diff --git a/iphone/Maps/Classes/Routing/MWMRouter.mm b/iphone/Maps/Classes/Routing/MWMRouter.mm index d3a0051f85..7baa26fc04 100644 --- a/iphone/Maps/Classes/Routing/MWMRouter.mm +++ b/iphone/Maps/Classes/Routing/MWMRouter.mm @@ -11,7 +11,7 @@ #import "MWMTextToSpeech.h" #import "MapViewController.h" #import "MapsAppDelegate.h" -#import "RouteState.h" +#import "MWMRouterSavedState.h" #import "Statistics.h" #include "Framework.h" @@ -22,13 +22,6 @@ using namespace routing; namespace { -enum class ForceStateChange -{ - None, - Rebuild, - Start -}; - MWMRoutePoint lastLocationPoint() { CLLocation * lastLocation = [MWMLocationManager lastLocation]; @@ -42,8 +35,6 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi @property(nonatomic, readwrite) MWMRoutePoint startPoint; @property(nonatomic, readwrite) MWMRoutePoint finishPoint; -@property(nonatomic, readwrite) MWMRoutePoint restorePoint; -@property(nonatomic) ForceStateChange forceStateChange; @end @@ -65,7 +56,6 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi if (self) { [self resetPoints]; - self.forceStateChange = ForceStateChange::None; [MWMLocationManager addObserver:self]; [MWMFrameworkListener addObserver:self]; } @@ -203,7 +193,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi [[MWMMapViewControlsManager manager] onRouteStart]; MapsAppDelegate * app = [MapsAppDelegate theApp]; app.routingPlaneMode = MWMRoutingPlaneModeNone; - [RouteState save]; + [MWMRouterSavedState store]; [MapsAppDelegate changeMapStyleIfNedeed]; [app startMapStyleChecker]; } @@ -235,7 +225,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi GetFramework().CloseRouting(); MapsAppDelegate * app = [MapsAppDelegate theApp]; app.routingPlaneMode = MWMRoutingPlaneModeNone; - [RouteState remove]; + [MWMRouterSavedState remove]; if ([MapsAppDelegate isAutoNightMode]) [MapsAppDelegate resetToDefaultMapStyle]; [app showAlertIfRequired]; @@ -252,22 +242,6 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi [[MWMNavigationDashboardManager manager] updateFollowingInfo:info]; } -- (void)restore -{ - if (GetFramework().IsRoutingActive()) - return; - RouteState * state = [RouteState savedState]; - if (state.hasActualRoute) - { - self.restorePoint = MWMRoutePoint(state.endPoint, @"Destination"); - self.forceStateChange = ForceStateChange::Rebuild; - } - else - { - [RouteState remove]; - } -} - #pragma mark - MWMLocationObserver - (void)onLocationUpdate:(location::GpsInfo const &)info @@ -283,11 +257,12 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi } else { - if (self.forceStateChange == ForceStateChange::Rebuild) + MWMRouterSavedState * state = [MWMRouterSavedState state]; + if (state.forceStateChange == MWMRouterForceStateChange::Rebuild) { - self.forceStateChange = ForceStateChange::Start; + state.forceStateChange = MWMRouterForceStateChange::Start; self.type = GetFramework().GetLastUsedRouter(); - [self buildToPoint:self.restorePoint bestRouter:NO]; + [self buildToPoint:state.restorePoint bestRouter:NO]; } } } @@ -297,13 +272,14 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi - (void)processRouteBuilderEvent:(routing::IRouter::ResultCode)code countries:(storage::TCountriesVec const &)absentCountries { + MWMRouterSavedState * state = [MWMRouterSavedState state]; switch (code) { case routing::IRouter::ResultCode::NoError: { auto & f = GetFramework(); f.DeactivateMapSelection(true); - if (self.forceStateChange == ForceStateChange::Start) + if (state.forceStateChange == MWMRouterForceStateChange::Start) [self start]; else [[MWMMapViewControlsManager manager] onRouteReady]; @@ -357,7 +333,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi [[MWMMapViewControlsManager manager] onRouteError]; break; } - self.forceStateChange = ForceStateChange::None; + state.forceStateChange = MWMRouterForceStateChange::None; } - (void)processRouteBuilderProgress:(CGFloat)progress diff --git a/iphone/Maps/Classes/Routing/MWMRouterSavedState.h b/iphone/Maps/Classes/Routing/MWMRouterSavedState.h new file mode 100644 index 0000000000..5d6111d893 --- /dev/null +++ b/iphone/Maps/Classes/Routing/MWMRouterSavedState.h @@ -0,0 +1,23 @@ +#include "MWMRoutePoint.h" + +#include "geometry/point2d.hpp" + +enum class MWMRouterForceStateChange +{ + None, + Rebuild, + Start +}; + +@interface MWMRouterSavedState : NSObject + +@property(nonatomic, readonly) MWMRoutePoint restorePoint; +@property(nonatomic) MWMRouterForceStateChange forceStateChange; + ++ (instancetype)state; + ++ (void)store; ++ (void)remove; ++ (void)restore; + +@end diff --git a/iphone/Maps/Classes/RouteState/RouteState.mm b/iphone/Maps/Classes/Routing/MWMRouterSavedState.mm similarity index 55% rename from iphone/Maps/Classes/RouteState/RouteState.mm rename to iphone/Maps/Classes/Routing/MWMRouterSavedState.mm index 13eee66d9e..61d2488126 100644 --- a/iphone/Maps/Classes/RouteState/RouteState.mm +++ b/iphone/Maps/Classes/Routing/MWMRouterSavedState.mm @@ -1,24 +1,30 @@ -#import "RouteState.h" +#import "MWMRouterSavedState.h" +#import "MWMRouter.h" #include "Framework.h" static NSString * const kEndPointKey = @"endPoint"; static NSString * const kETAKey = @"eta"; -@interface RouteState() +@implementation MWMRouterSavedState -@property (nonatomic) NSDate * eta; - -@end - -@implementation RouteState - -+ (instancetype)savedState ++ (instancetype)state { - RouteState * const state = [[super alloc] init]; - if (state) + static MWMRouterSavedState * state; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + state = [[super alloc] initState]; + }); + return state; +} + +- (instancetype)initState +{ + self = [super init]; + if (self) { - NSDictionary * const stateDict = [NSDictionary dictionaryWithContentsOfURL:[RouteState stateFileURL]]; + _forceStateChange = MWMRouterForceStateChange::None; + NSDictionary * const stateDict = [NSDictionary dictionaryWithContentsOfURL:[MWMRouterSavedState stateFileURL]]; if (stateDict) { m2::PointD point; @@ -29,15 +35,16 @@ static NSString * const kETAKey = @"eta"; if (endPointData && eta) { [endPointData getBytes:&point length:size]; - state.endPoint = point; - state.eta = eta; + _restorePoint = MWMRoutePoint(point, @"Destination"); + if ([eta compare:[NSDate date]] == NSOrderedDescending) + _forceStateChange = MWMRouterForceStateChange::Rebuild; } } } - return state; + return self; } -+ (void)save ++ (void)store { Framework & f = GetFramework(); if (!f.IsOnRoute()) @@ -50,12 +57,12 @@ static NSString * const kETAKey = @"eta"; NSGetSizeAndAlignment(@encode(m2::PointD), &size, nullptr); stateDict[kEndPointKey] = [NSData dataWithBytes:&endPoint length:size]; stateDict[kETAKey] = [NSDate dateWithTimeIntervalSinceNow:routeInfo.m_time]; - [stateDict writeToURL:[RouteState stateFileURL] atomically:YES]; + [stateDict writeToURL:[MWMRouterSavedState stateFileURL] atomically:YES]; } + (void)remove { - [[NSFileManager defaultManager] removeItemAtURL:[RouteState stateFileURL] error:nil]; + [[NSFileManager defaultManager] removeItemAtURL:[MWMRouterSavedState stateFileURL] error:nil]; } + (NSURL *)stateFileURL @@ -63,11 +70,12 @@ static NSString * const kETAKey = @"eta"; return [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"route_info.ini"]]; } -#pragma mark - Properties - -- (BOOL)hasActualRoute ++ (void)restore { - return [self.eta compare:[NSDate date]] == NSOrderedDescending; + if (GetFramework().IsRoutingActive()) + return; + if ([MWMRouterSavedState state].forceStateChange == MWMRouterForceStateChange::None) + [MWMRouterSavedState remove]; } @end diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index af876f241f..02e7c5b178 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -38,7 +38,6 @@ 340C20E41C3E565600111D22 /* MWMCuisineEditorViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340C20E21C3E565600111D22 /* MWMCuisineEditorViewController.mm */; }; 340E10601B944DAB00D975D5 /* MWMSearchHistoryManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340E105F1B944DAB00D975D5 /* MWMSearchHistoryManager.mm */; }; 340E10631B949D1900D975D5 /* MWMSearchBookmarksManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340E10621B949D1900D975D5 /* MWMSearchBookmarksManager.mm */; }; - 340F24631B14910500F874CD /* RouteState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340F24621B14910500F874CD /* RouteState.mm */; }; 3411387D1C15AE73002E3B3E /* libeditor.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3411387C1C15AE73002E3B3E /* libeditor.a */; }; 341138801C15B50B002E3B3E /* MWMOpeningHoursModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3411387F1C15B50B002E3B3E /* MWMOpeningHoursModel.mm */; }; 341138811C15B50B002E3B3E /* MWMOpeningHoursModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3411387F1C15B50B002E3B3E /* MWMOpeningHoursModel.mm */; }; @@ -204,6 +203,8 @@ 34A62D4F1C903533007FDCB7 /* Fabric.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34A62D4C1C903533007FDCB7 /* Fabric.framework */; }; 34A62D501C903533007FDCB7 /* Crashlytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34A62D4D1C903533007FDCB7 /* Crashlytics.framework */; }; 34A62D511C903533007FDCB7 /* Crashlytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34A62D4D1C903533007FDCB7 /* Crashlytics.framework */; }; + 34AA7D9F1D63543E00254037 /* MWMRouterSavedState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AA7D9E1D63543E00254037 /* MWMRouterSavedState.mm */; }; + 34AA7DA01D63543E00254037 /* MWMRouterSavedState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AA7D9E1D63543E00254037 /* MWMRouterSavedState.mm */; }; 34AB04B71CEC95B500CE8B36 /* MWMEditorAdditionalNamePlaceholderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34AB04B61CEC95B500CE8B36 /* MWMEditorAdditionalNamePlaceholderTableViewCell.xib */; }; 34AB04B81CEC95B500CE8B36 /* MWMEditorAdditionalNamePlaceholderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34AB04B61CEC95B500CE8B36 /* MWMEditorAdditionalNamePlaceholderTableViewCell.xib */; }; 34AB39C11D2BD8310021857D /* MWMStopButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AB39C01D2BD8310021857D /* MWMStopButton.mm */; }; @@ -470,7 +471,6 @@ 6741A9D41BF340DE002C974C /* MWMAlertViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19821AB81A00006EAF7E /* MWMAlertViewController.mm */; }; 6741A9D51BF340DE002C974C /* WebViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAFCB63513366E78001A5C59 /* WebViewController.mm */; }; 6741A9D61BF340DE002C974C /* MWMPlacePageNavigationBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6FE2C0E1B03A006009814AA /* MWMPlacePageNavigationBar.mm */; }; - 6741A9D81BF340DE002C974C /* RouteState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340F24621B14910500F874CD /* RouteState.mm */; }; 6741A9DA1BF340DE002C974C /* UIKitCategories.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9747264118323080006B7CB7 /* UIKitCategories.mm */; }; 6741A9DB1BF340DE002C974C /* MWMRoutePreview.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6BD337E1B62403B00F2CE18 /* MWMRoutePreview.mm */; }; 6741A9DC1BF340DE002C974C /* MWMRoutePointLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6BB6CC21BB1860D00DF1DF2 /* MWMRoutePointLayout.mm */; }; @@ -892,8 +892,6 @@ 340E105F1B944DAB00D975D5 /* MWMSearchHistoryManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSearchHistoryManager.mm; sourceTree = ""; }; 340E10611B949D1900D975D5 /* MWMSearchBookmarksManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchBookmarksManager.h; sourceTree = ""; }; 340E10621B949D1900D975D5 /* MWMSearchBookmarksManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSearchBookmarksManager.mm; sourceTree = ""; }; - 340F24611B14910500F874CD /* RouteState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RouteState.h; sourceTree = ""; }; - 340F24621B14910500F874CD /* RouteState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RouteState.mm; sourceTree = ""; }; 3411387C1C15AE73002E3B3E /* libeditor.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libeditor.a; path = "../../../omim-xcode-build/Debug/libeditor.a"; sourceTree = ""; }; 3411387E1C15B50B002E3B3E /* MWMOpeningHoursModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMOpeningHoursModel.h; sourceTree = ""; }; 3411387F1C15B50B002E3B3E /* MWMOpeningHoursModel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMOpeningHoursModel.mm; sourceTree = ""; }; @@ -1078,6 +1076,8 @@ 349C3AF11D33C6EE002AC7A9 /* MWMNavigationDashboardInfoProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardInfoProtocol.h; sourceTree = ""; }; 34A62D4C1C903533007FDCB7 /* Fabric.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Fabric.framework; sourceTree = ""; }; 34A62D4D1C903533007FDCB7 /* Crashlytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Crashlytics.framework; sourceTree = ""; }; + 34AA7D9D1D63543E00254037 /* MWMRouterSavedState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRouterSavedState.h; sourceTree = ""; }; + 34AA7D9E1D63543E00254037 /* MWMRouterSavedState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMRouterSavedState.mm; sourceTree = ""; }; 34AB04B61CEC95B500CE8B36 /* MWMEditorAdditionalNamePlaceholderTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMEditorAdditionalNamePlaceholderTableViewCell.xib; sourceTree = ""; }; 34AB39BF1D2BD8310021857D /* MWMStopButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStopButton.h; sourceTree = ""; }; 34AB39C01D2BD8310021857D /* MWMStopButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStopButton.mm; sourceTree = ""; }; @@ -1724,7 +1724,6 @@ 34E2731E1C7379EA00463965 /* Migration */, 346EDAD81B9F0E15004F8DB5 /* Components */, 340837101B7243B500B5C185 /* Share */, - 340F24601B1490ED00F874CD /* RouteState */, F6588E291B15C25C00EE1E58 /* TextView */, F64F195F1AB8125C006EAF7E /* CustomAlert */, 97B4E9271851DAB300BEC5D7 /* Custom Views */, @@ -1892,6 +1891,8 @@ 34002A661D2F9C8100AC201E /* MWMRoutePoint.h */, 34002A6B1D2F9D0700AC201E /* MWMRouter.h */, 34002A6C1D2F9D0700AC201E /* MWMRouter.mm */, + 34AA7D9D1D63543E00254037 /* MWMRouterSavedState.h */, + 34AA7D9E1D63543E00254037 /* MWMRouterSavedState.mm */, ); path = Routing; sourceTree = ""; @@ -1918,15 +1919,6 @@ path = Cuisine; sourceTree = ""; }; - 340F24601B1490ED00F874CD /* RouteState */ = { - isa = PBXGroup; - children = ( - 340F24611B14910500F874CD /* RouteState.h */, - 340F24621B14910500F874CD /* RouteState.mm */, - ); - path = RouteState; - sourceTree = ""; - }; 3418CEAB1CBF9D7700641B25 /* NoMaps */ = { isa = PBXGroup; children = ( @@ -3662,6 +3654,7 @@ FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */, 34C9BD091C6DBCDA000DC38D /* MWMNavigationController.mm in Sources */, 3406FA151C6E0C3300E9FAD2 /* MWMMapDownloadDialog.mm in Sources */, + 34AA7D9F1D63543E00254037 /* MWMRouterSavedState.mm in Sources */, 34C9BD021C6DB693000DC38D /* MWMTableViewController.mm in Sources */, 34CD81D71C92D96F007D2A60 /* MWMFirstLaunchController.mm in Sources */, F63BA3711BCD5B520044C504 /* MWMTTSLanguageViewController.mm in Sources */, @@ -3670,7 +3663,6 @@ 34DCDE3A1C75CD8100652CAC /* Framework.cpp in Sources */, F6FE2C0F1B03A006009814AA /* MWMPlacePageNavigationBar.mm in Sources */, 341138801C15B50B002E3B3E /* MWMOpeningHoursModel.mm in Sources */, - 340F24631B14910500F874CD /* RouteState.mm in Sources */, 9747264318323080006B7CB7 /* UIKitCategories.mm in Sources */, F6BD33811B62403B00F2CE18 /* MWMRoutePreview.mm in Sources */, F6BB6CC31BB1860D00DF1DF2 /* MWMRoutePointLayout.mm in Sources */, @@ -3887,10 +3879,10 @@ 3406FA161C6E0C3300E9FAD2 /* MWMMapDownloadDialog.mm in Sources */, 6741A9D51BF340DE002C974C /* WebViewController.mm in Sources */, 34C9BD031C6DB693000DC38D /* MWMTableViewController.mm in Sources */, + 34AA7DA01D63543E00254037 /* MWMRouterSavedState.mm in Sources */, 6741A9D61BF340DE002C974C /* MWMPlacePageNavigationBar.mm in Sources */, 34CD81D81C92D96F007D2A60 /* MWMFirstLaunchController.mm in Sources */, F64DA8031C52520000330E9E /* UISwitch+RuntimeAttributes.m in Sources */, - 6741A9D81BF340DE002C974C /* RouteState.mm in Sources */, 676507631C1055BB00830BB3 /* MWMTTSLanguageViewController.mm in Sources */, 341138811C15B50B002E3B3E /* MWMOpeningHoursModel.mm in Sources */, 6741A9DA1BF340DE002C974C /* UIKitCategories.mm in Sources */, From 68f5e9b963de7a8b079ffb72528d69119010792f Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Tue, 16 Aug 2016 17:17:16 +0300 Subject: [PATCH 2/2] Clang-format. --- .../MWMOpeningHoursClosedSpanTableViewCell.mm | 26 ++-- .../MWMMapDownloaderPlaceTableViewCell.mm | 30 ++-- .../MWMMapDownloaderSubplaceTableViewCell.mm | 18 +-- .../Cells/MWMMapDownloaderTableViewCell.mm | 139 ++++++++---------- iphone/Maps/Classes/MapViewController.mm | 2 +- iphone/Maps/Classes/MapsAppDelegate.mm | 2 +- iphone/Maps/Classes/Routing/MWMRouter.mm | 2 +- .../Classes/Routing/MWMRouterSavedState.mm | 6 +- 8 files changed, 101 insertions(+), 124 deletions(-) diff --git a/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm b/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm index 52c967f980..8e04f5f8c4 100644 --- a/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm +++ b/iphone/Maps/Classes/Editor/OpeningHours/Cells/MWMOpeningHoursClosedSpanTableViewCell.mm @@ -1,6 +1,6 @@ #import "MWMOpeningHoursClosedSpanTableViewCell.h" -#import "UIFont+MapsMeFonts.h" #import "UIColor+MapsMeColor.h" +#import "UIFont+MapsMeFonts.h" static NSString * const kLabelText = L(@"editor_hours_closed"); @@ -23,24 +23,20 @@ BOOL isCompactForCellWidth(CGFloat width) @interface MWMOpeningHoursClosedSpanTableViewCell () -@property (weak, nonatomic) IBOutlet UILabel * hoursClosedLabel; -@property (weak, nonatomic) IBOutlet UILabel * timeSpanLabel; +@property(weak, nonatomic) IBOutlet UILabel * hoursClosedLabel; +@property(weak, nonatomic) IBOutlet UILabel * timeSpanLabel; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint * timeSpanHorizontalAlignment; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint * timeSpanVerticalAlignment; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint * hoursClosedTrailing; +@property(weak, nonatomic) IBOutlet NSLayoutConstraint * timeSpanHorizontalAlignment; +@property(weak, nonatomic) IBOutlet NSLayoutConstraint * timeSpanVerticalAlignment; +@property(weak, nonatomic) IBOutlet NSLayoutConstraint * hoursClosedTrailing; -@property (nonatomic) BOOL isCompact; +@property(nonatomic) BOOL isCompact; @end @implementation MWMOpeningHoursClosedSpanTableViewCell -+ (CGFloat)heightForWidth:(CGFloat)width -{ - return isCompactForCellWidth(width) ? 44.0 : 64.0; -} - ++ (CGFloat)heightForWidth:(CGFloat)width { return isCompactForCellWidth(width) ? 44.0 : 64.0; } - (void)awakeFromNib { [super awakeFromNib]; @@ -101,11 +97,7 @@ BOOL isCompactForCellWidth(CGFloat width) #pragma mark - Actions -- (IBAction)cancelTap -{ - [self.section removeClosedTime:self.row]; -} - +- (IBAction)cancelTap { [self.section removeClosedTime:self.row]; } - (IBAction)expandTap { if (!self.isVisible) diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm index 69a584e07d..3b389aa2e3 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderPlaceTableViewCell.mm @@ -1,29 +1,27 @@ -#import "Common.h" #import "MWMMapDownloaderPlaceTableViewCell.h" +#import "Common.h" #import "UIFont+MapsMeFonts.h" #include "Framework.h" @interface MWMMapDownloaderTableViewCell () -- (NSAttributedString *)matchedString:(NSString *)str selectedAttrs:(NSDictionary *)selectedAttrs unselectedAttrs:(NSDictionary *)unselectedAttrs; +- (NSAttributedString *)matchedString:(NSString *)str + selectedAttrs:(NSDictionary *)selectedAttrs + unselectedAttrs:(NSDictionary *)unselectedAttrs; @end @interface MWMMapDownloaderPlaceTableViewCell () -@property (weak, nonatomic) IBOutlet UILabel * descriptionLabel; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint * titleBottomOffset; +@property(weak, nonatomic) IBOutlet UILabel * descriptionLabel; +@property(weak, nonatomic) IBOutlet NSLayoutConstraint * titleBottomOffset; @end @implementation MWMMapDownloaderPlaceTableViewCell -+ (CGFloat)estimatedHeight -{ - return 62.0; -} - ++ (CGFloat)estimatedHeight { return 62.0; } - (void)layoutSubviews { [super layoutSubviews]; @@ -40,8 +38,8 @@ { [super config:nodeAttrs]; BOOL isDescriptionVisible = NO; - NSDictionary * const selectedAreaAttrs = @{ NSFontAttributeName : [UIFont bold12] }; - NSDictionary * const unselectedAreaAttrs = @{ NSFontAttributeName : [UIFont regular12] }; + NSDictionary * const selectedAreaAttrs = @{NSFontAttributeName : [UIFont bold12]}; + NSDictionary * const unselectedAreaAttrs = @{NSFontAttributeName : [UIFont regular12]}; if (self.needDisplayArea && nodeAttrs.m_topmostParentInfo.size() == 1) { string const & areaName = nodeAttrs.m_topmostParentInfo[0].m_localName; @@ -54,12 +52,14 @@ else if (!nodeAttrs.m_nodeLocalDescription.empty()) { isDescriptionVisible = YES; - self.descriptionLabel.attributedText = [self matchedString:@(nodeAttrs.m_nodeLocalDescription.c_str()) - selectedAttrs:selectedAreaAttrs - unselectedAttrs:unselectedAreaAttrs]; + self.descriptionLabel.attributedText = + [self matchedString:@(nodeAttrs.m_nodeLocalDescription.c_str()) + selectedAttrs:selectedAreaAttrs + unselectedAttrs:unselectedAreaAttrs]; } self.descriptionLabel.hidden = !isDescriptionVisible; - self.titleBottomOffset.priority = isDescriptionVisible ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh; + self.titleBottomOffset.priority = + isDescriptionVisible ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh; } @end diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm index 41ad2a8f64..063c743c7e 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderSubplaceTableViewCell.mm @@ -1,26 +1,24 @@ -#import "Common.h" #import "MWMMapDownloaderSubplaceTableViewCell.h" +#import "Common.h" #import "UIFont+MapsMeFonts.h" @interface MWMMapDownloaderTableViewCell () -- (NSAttributedString *)matchedString:(NSString *)str selectedAttrs:(NSDictionary *)selectedAttrs unselectedAttrs:(NSDictionary *)unselectedAttrs; +- (NSAttributedString *)matchedString:(NSString *)str + selectedAttrs:(NSDictionary *)selectedAttrs + unselectedAttrs:(NSDictionary *)unselectedAttrs; @end @interface MWMMapDownloaderSubplaceTableViewCell () -@property (weak, nonatomic) IBOutlet UILabel * subPlace; +@property(weak, nonatomic) IBOutlet UILabel * subPlace; @end @implementation MWMMapDownloaderSubplaceTableViewCell -+ (CGFloat)estimatedHeight -{ - return 82.0; -} - ++ (CGFloat)estimatedHeight { return 82.0; } - (void)layoutSubviews { [super layoutSubviews]; @@ -33,8 +31,8 @@ - (void)setSubplaceText:(NSString *)text { - NSDictionary * const selectedSubPlaceAttrs = @{ NSFontAttributeName : [UIFont bold14] }; - NSDictionary * const unselectedSubPlaceAttrs = @{ NSFontAttributeName : [UIFont regular14] }; + NSDictionary * const selectedSubPlaceAttrs = @{NSFontAttributeName : [UIFont bold14]}; + NSDictionary * const unselectedSubPlaceAttrs = @{NSFontAttributeName : [UIFont regular14]}; self.subPlace.attributedText = [self matchedString:text selectedAttrs:selectedSubPlaceAttrs unselectedAttrs:unselectedSubPlaceAttrs]; diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm index 7dac7f1de8..12ea4e5ed2 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm @@ -1,20 +1,20 @@ +#import "MWMMapDownloaderTableViewCell.h" #import "Common.h" #import "MWMCircularProgress.h" #import "MWMMapDownloaderLargeCountryTableViewCell.h" -#import "MWMMapDownloaderTableViewCell.h" #import "NSString+Categories.h" #import "UIFont+MapsMeFonts.h" #include "Framework.h" -@interface MWMMapDownloaderTableViewCell () +@interface MWMMapDownloaderTableViewCell () -@property (nonatomic) MWMCircularProgress * progress; -@property (copy, nonatomic) NSString * searchQuery; +@property(nonatomic) MWMCircularProgress * progress; +@property(copy, nonatomic) NSString * searchQuery; -@property (weak, nonatomic) IBOutlet UIView * stateWrapper; -@property (weak, nonatomic) IBOutlet UILabel * title; -@property (weak, nonatomic) IBOutlet UILabel * downloadSize; +@property(weak, nonatomic) IBOutlet UIView * stateWrapper; +@property(weak, nonatomic) IBOutlet UILabel * title; +@property(weak, nonatomic) IBOutlet UILabel * downloadSize; @end @@ -23,11 +23,7 @@ storage::TCountryId m_countryId; } -+ (CGFloat)estimatedHeight -{ - return 52.0; -} - ++ (CGFloat)estimatedHeight { return 52.0; } - (void)awakeFromNib { [super awakeFromNib]; @@ -53,7 +49,9 @@ #pragma mark - Search matching -- (NSAttributedString *)matchedString:(NSString *)str selectedAttrs:(NSDictionary *)selectedAttrs unselectedAttrs:(NSDictionary *)unselectedAttrs +- (NSAttributedString *)matchedString:(NSString *)str + selectedAttrs:(NSDictionary *)selectedAttrs + unselectedAttrs:(NSDictionary *)unselectedAttrs { NSMutableAttributedString * attrTitle = [[NSMutableAttributedString alloc] initWithString:str]; [attrTitle addAttributes:unselectedAttrs range:{0, str.length}]; @@ -70,8 +68,8 @@ { [self configProgress:nodeAttrs]; - NSDictionary * const selectedTitleAttrs = @{ NSFontAttributeName : [UIFont bold17] }; - NSDictionary * const unselectedTitleAttrs = @{ NSFontAttributeName : [UIFont regular17] }; + NSDictionary * const selectedTitleAttrs = @{NSFontAttributeName : [UIFont bold17]}; + NSDictionary * const unselectedTitleAttrs = @{NSFontAttributeName : [UIFont regular17]}; self.title.attributedText = [self matchedString:@(nodeAttrs.m_nodeLocalName.c_str()) selectedAttrs:selectedTitleAttrs unselectedAttrs:unselectedTitleAttrs]; @@ -85,49 +83,42 @@ - (void)configProgress:(storage::NodeAttrs const &)nodeAttrs { MWMCircularProgress * progress = self.progress; - MWMButtonColoring const coloring = self.mode == mwm::DownloaderMode::Downloaded - ? MWMButtonColoringBlack - : MWMButtonColoringBlue; + MWMButtonColoring const coloring = + self.mode == mwm::DownloaderMode::Downloaded ? MWMButtonColoringBlack : MWMButtonColoringBlue; switch (nodeAttrs.m_status) { - case NodeStatus::NotDownloaded: - case NodeStatus::Partly: - { - MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal, - MWMCircularProgressStateSelected}; - UIImage * image = [self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]] - ? [UIImage imageNamed:@"ic_folder"] - : [UIImage imageNamed:@"ic_download"]; - [progress setImage:image forStates:affectedStates]; - [progress setColoring:coloring forStates:affectedStates]; - progress.state = MWMCircularProgressStateNormal; - break; - } - case NodeStatus::Downloading: - { - auto const & prg = nodeAttrs.m_downloadingProgress; - progress.progress = static_cast(prg.first) / prg.second; - break; - } - case NodeStatus::InQueue: - progress.state = MWMCircularProgressStateSpinner; - break; - case NodeStatus::Undefined: - case NodeStatus::Error: - progress.state = MWMCircularProgressStateFailed; - break; - case NodeStatus::OnDisk: - progress.state = MWMCircularProgressStateCompleted; - break; - case NodeStatus::OnDiskOutOfDate: - { - MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal, - MWMCircularProgressStateSelected}; - [progress setImage:[UIImage imageNamed:@"ic_update"] forStates:affectedStates]; - [progress setColoring:MWMButtonColoringOther forStates:affectedStates]; - progress.state = MWMCircularProgressStateNormal; - break; - } + case NodeStatus::NotDownloaded: + case NodeStatus::Partly: + { + MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal, + MWMCircularProgressStateSelected}; + UIImage * image = [self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]] + ? [UIImage imageNamed:@"ic_folder"] + : [UIImage imageNamed:@"ic_download"]; + [progress setImage:image forStates:affectedStates]; + [progress setColoring:coloring forStates:affectedStates]; + progress.state = MWMCircularProgressStateNormal; + break; + } + case NodeStatus::Downloading: + { + auto const & prg = nodeAttrs.m_downloadingProgress; + progress.progress = static_cast(prg.first) / prg.second; + break; + } + case NodeStatus::InQueue: progress.state = MWMCircularProgressStateSpinner; break; + case NodeStatus::Undefined: + case NodeStatus::Error: progress.state = MWMCircularProgressStateFailed; break; + case NodeStatus::OnDisk: progress.state = MWMCircularProgressStateCompleted; break; + case NodeStatus::OnDiskOutOfDate: + { + MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal, + MWMCircularProgressStateSelected}; + [progress setImage:[UIImage imageNamed:@"ic_update"] forStates:affectedStates]; + [progress setColoring:MWMButtonColoringOther forStates:affectedStates]; + progress.state = MWMCircularProgressStateNormal; + break; + } } } @@ -142,7 +133,8 @@ [self config:nodeAttrs]; } -- (void)processCountry:(TCountryId const &)countryId progress:(MapFilesDownloader::TProgress const &)progress +- (void)processCountry:(TCountryId const &)countryId + progress:(MapFilesDownloader::TProgress const &)progress { if (countryId != m_countryId) return; @@ -157,26 +149,19 @@ GetFramework().Storage().GetNodeAttrs(m_countryId, nodeAttrs); switch (nodeAttrs.m_status) { - case NodeStatus::NotDownloaded: - case NodeStatus::Partly: - if ([self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]]) - [self.delegate openNodeSubtree:m_countryId]; - else - [self.delegate downloadNode:m_countryId]; - break; - case NodeStatus::Undefined: - case NodeStatus::Error: - [self.delegate retryDownloadNode:m_countryId]; - break; - case NodeStatus::OnDiskOutOfDate: - [self.delegate updateNode:m_countryId]; - break; - case NodeStatus::Downloading: - case NodeStatus::InQueue: - [self.delegate cancelNode:m_countryId]; - break; - case NodeStatus::OnDisk: - break; + case NodeStatus::NotDownloaded: + case NodeStatus::Partly: + if ([self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]]) + [self.delegate openNodeSubtree:m_countryId]; + else + [self.delegate downloadNode:m_countryId]; + break; + case NodeStatus::Undefined: + case NodeStatus::Error: [self.delegate retryDownloadNode:m_countryId]; break; + case NodeStatus::OnDiskOutOfDate: [self.delegate updateNode:m_countryId]; break; + case NodeStatus::Downloading: + case NodeStatus::InQueue: [self.delegate cancelNode:m_countryId]; break; + case NodeStatus::OnDisk: break; } } diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index b969472835..b92235ffbf 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -22,11 +22,11 @@ #import "MWMPageController.h" #import "MWMPlacePageEntity.h" #import "MWMRouter.h" +#import "MWMRouterSavedState.h" #import "MWMStorage.h" #import "MWMTableViewController.h" #import "MWMWhatsNewNavigationController.h" #import "MapsAppDelegate.h" -#import "MWMRouterSavedState.h" #import "Statistics.h" #import "UIColor+MapsMeColor.h" #import "UIFont+MapsMeFonts.h" diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index ddc9f60582..bdf7ad34bb 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -13,11 +13,11 @@ #import "MWMFrameworkObservers.h" #import "MWMLocationManager.h" #import "MWMRouter.h" +#import "MWMRouterSavedState.h" #import "MWMStorage.h" #import "MWMTextToSpeech.h" #import "MapViewController.h" #import "Preferences.h" -#import "MWMRouterSavedState.h" #import "Statistics.h" #import "UIColor+MapsMeColor.h" #import "UIFont+MapsMeFonts.h" diff --git a/iphone/Maps/Classes/Routing/MWMRouter.mm b/iphone/Maps/Classes/Routing/MWMRouter.mm index 7baa26fc04..501014ccff 100644 --- a/iphone/Maps/Classes/Routing/MWMRouter.mm +++ b/iphone/Maps/Classes/Routing/MWMRouter.mm @@ -6,12 +6,12 @@ #import "MWMLocationManager.h" #import "MWMMapViewControlsManager.h" #import "MWMNavigationDashboardManager.h" +#import "MWMRouterSavedState.h" #import "MWMSearch.h" #import "MWMStorage.h" #import "MWMTextToSpeech.h" #import "MapViewController.h" #import "MapsAppDelegate.h" -#import "MWMRouterSavedState.h" #import "Statistics.h" #include "Framework.h" diff --git a/iphone/Maps/Classes/Routing/MWMRouterSavedState.mm b/iphone/Maps/Classes/Routing/MWMRouterSavedState.mm index 61d2488126..15d0138ced 100644 --- a/iphone/Maps/Classes/Routing/MWMRouterSavedState.mm +++ b/iphone/Maps/Classes/Routing/MWMRouterSavedState.mm @@ -24,7 +24,8 @@ static NSString * const kETAKey = @"eta"; if (self) { _forceStateChange = MWMRouterForceStateChange::None; - NSDictionary * const stateDict = [NSDictionary dictionaryWithContentsOfURL:[MWMRouterSavedState stateFileURL]]; + NSDictionary * const stateDict = + [NSDictionary dictionaryWithContentsOfURL:[MWMRouterSavedState stateFileURL]]; if (stateDict) { m2::PointD point; @@ -67,7 +68,8 @@ static NSString * const kETAKey = @"eta"; + (NSURL *)stateFileURL { - return [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"route_info.ini"]]; + return [NSURL + fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"route_info.ini"]]; } + (void)restore