Review fixes.

This commit is contained in:
Ilya Grechuhin 2016-04-20 17:35:01 +03:00
parent c294c3c212
commit 3379af2253
30 changed files with 62 additions and 99 deletions

View file

@ -7,7 +7,7 @@
@protocol MWMBottomMenuControllerProtocol<NSObject>
- (void)actionDownloadMaps:(TMWMMapDownloaderMode)mode;
- (void)actionDownloadMaps:(mwm::DownloaderMode)mode;
- (void)closeInfoScreens;
- (void)addPlace;
- (void)didFinishAddingPlace;

View file

@ -358,7 +358,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
{
[Statistics logEvent:kStatMenu withParameters:@{kStatButton : kStatDownloadMaps}];
self.state = self.restoreState;
[self.delegate actionDownloadMaps:TMWMMapDownloaderMode::Downloaded];
[self.delegate actionDownloadMaps:mwm::DownloaderMode::Downloaded];
}
- (void)menuActionOpenSettings

View file

@ -255,7 +255,7 @@ extern NSString * const kAlohalyticsTapEventKey;
#pragma mark - MWMSearchManagerProtocol & MWMBottomMenuControllerProtocol
- (void)actionDownloadMaps:(TMWMMapDownloaderMode)mode
- (void)actionDownloadMaps:(mwm::DownloaderMode)mode
{
if (platform::migrate::NeedMigrate())
{

View file

@ -16,7 +16,7 @@ typedef NS_ENUM(NSUInteger, MWMSearchManagerState)
@property (nonnull, nonatomic, readonly) MWMAlertViewController * alertController;
- (void)searchViewDidEnterState:(MWMSearchManagerState)state;
- (void)actionDownloadMaps:(TMWMMapDownloaderMode)mode;
- (void)actionDownloadMaps:(mwm::DownloaderMode)mode;
@end

View file

@ -220,7 +220,7 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
- (void)handleDownloadMapsAction
{
[self.delegate actionDownloadMaps:TMWMMapDownloaderMode::Available];
[self.delegate actionDownloadMaps:mwm::DownloaderMode::Available];
}
#pragma mark - State changes

View file

@ -10,7 +10,7 @@
@property (nonatomic) BOOL isHeightCell;
@property (weak, nonatomic) id<MWMMapDownloaderProtocol> delegate;
@property (nonatomic) TMWMMapDownloaderMode mode;
@property (nonatomic) mwm::DownloaderMode mode;
- (void)config:(storage::NodeAttrs const &)nodeAttrs;
- (void)setCountryId:(NSString *)countryId searchQuery:(NSString *)query;

View file

@ -85,7 +85,7 @@ namespace
- (void)configProgress:(storage::NodeAttrs const &)nodeAttrs
{
MWMCircularProgress * progress = self.progress;
MWMButtonColoring const coloring = self.mode == TMWMMapDownloaderMode::Downloaded
MWMButtonColoring const coloring = self.mode == mwm::DownloaderMode::Downloaded
? MWMButtonColoringBlack
: MWMButtonColoringBlue;
switch (nodeAttrs.m_status)
@ -93,8 +93,8 @@ namespace
case NodeStatus::NotDownloaded:
case NodeStatus::Partly:
{
auto const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
UIImage * image = [self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]]
? [UIImage imageNamed:@"ic_folder"]
: [UIImage imageNamed:@"ic_download"];
@ -121,7 +121,8 @@ namespace
break;
case NodeStatus::OnDiskOutOfDate:
{
auto const affectedStates = {MWMCircularProgressStateNormal, MWMCircularProgressStateSelected};
MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
[progress setImage:[UIImage imageNamed:@"ic_update"] forStates:affectedStates];
[progress setColoring:MWMButtonColoringOther forStates:affectedStates];
progress.state = MWMCircularProgressStateNormal;

View file

@ -8,10 +8,10 @@
@interface MWMMapDownloaderDataSource : NSObject <UITableViewDataSource>
@property (nonatomic, readonly) BOOL isParentRoot;
@property (nonatomic, readonly) TMWMMapDownloaderMode mode;
@property (nonatomic, readonly) mwm::DownloaderMode mode;
@property (weak, nonatomic, readonly) id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol> delegate;
- (instancetype)initWithDelegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(TMWMMapDownloaderMode)mode;
- (instancetype)initWithDelegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(mwm::DownloaderMode)mode;
- (NSString *)parentCountryId;
- (NSString *)countryIdForIndexPath:(NSIndexPath *)indexPath;
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath;

View file

@ -11,7 +11,7 @@ using namespace storage;
@implementation MWMMapDownloaderDataSource
- (instancetype)initWithDelegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(TMWMMapDownloaderMode)mode
- (instancetype)initWithDelegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(mwm::DownloaderMode)mode
{
self = [super init];
if (self)

View file

@ -2,7 +2,7 @@
@interface MWMMapDownloaderDefaultDataSource : MWMMapDownloaderDataSource
- (instancetype)initForRootCountryId:(NSString *)countryId delegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(TMWMMapDownloaderMode)mode;
- (instancetype)initForRootCountryId:(NSString *)countryId delegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(mwm::DownloaderMode)mode;
- (void)load;
@end

View file

@ -29,6 +29,7 @@ auto compareLocalNames = ^NSComparisonResult(NSString * s1, NSString * s2)
} // namespace
using namespace storage;
using namespace mwm;
@interface MWMMapDownloaderDefaultDataSource ()
@ -45,7 +46,7 @@ using namespace storage;
@synthesize isParentRoot = _isParentRoot;
- (instancetype)initForRootCountryId:(NSString *)countryId delegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(TMWMMapDownloaderMode)mode
- (instancetype)initForRootCountryId:(NSString *)countryId delegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(DownloaderMode)mode
{
self = [super initWithDelegate:delegate mode:mode];
if (self)
@ -62,8 +63,8 @@ using namespace storage;
auto const & s = GetFramework().Storage();
TCountriesVec downloadedChildren;
TCountriesVec availableChildren;
s.GetChildrenInGroups(m_parentId, downloadedChildren, availableChildren, true);
if (self.mode == TMWMMapDownloaderMode::Available)
s.GetChildrenInGroups(m_parentId, downloadedChildren, availableChildren, true /* keepAvailableChildren */);
if (self.mode == DownloaderMode::Available)
{
self.downloadedCountries = nil;
[self configAvailableSections:availableChildren];

View file

@ -25,7 +25,7 @@ using namespace storage;
- (void)load
{
[super load];
if (self.mode == TMWMMapDownloaderMode::Available)
if (self.mode == mwm::DownloaderMode::Available)
[self configNearMeSection];
}

View file

@ -21,7 +21,7 @@ extern NSString * const kLargeCountryCellIdentifier;
- (instancetype)initWithSearchResults:(DownloaderSearchResults const &)results delegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate
{
self = [super initWithDelegate:delegate mode:TMWMMapDownloaderMode::Available];
self = [super initWithDelegate:delegate mode:mwm::DownloaderMode::Available];
if (self)
{
NSMutableOrderedSet<NSString *> * nsSearchCountryIds =

View file

@ -8,6 +8,6 @@
- (void)configTable;
- (void)configAllMapsView;
- (void)setParentCountryId:(NSString *)parentId mode:(TMWMMapDownloaderMode)mode;
- (void)setParentCountryId:(NSString *)parentId mode:(mwm::DownloaderMode)mode;
@end

View file

@ -57,6 +57,9 @@ NSString * const kBaseControllerIdentifier = @"MWMBaseMapDownloaderViewControlle
NSString * const kControllerIdentifier = @"MWMMapDownloaderViewController";
} // namespace
using namespace storage;
using namespace mwm;
@interface MWMBaseMapDownloaderViewController () <UIActionSheetDelegate, UIScrollViewDelegate, MWMFrameworkStorageObserver>
@property (weak, nonatomic) IBOutlet UITableView * tableView;
@ -81,14 +84,12 @@ NSString * const kControllerIdentifier = @"MWMMapDownloaderViewController";
@property (nonatomic) BOOL forceFullReload;
@property (nonatomic, readonly) NSString * parentCountryId;
@property (nonatomic, readonly) TMWMMapDownloaderMode mode;
@property (nonatomic, readonly) DownloaderMode mode;
@property (nonatomic) BOOL showAllMapsButtons;
@end
using namespace storage;
@implementation MWMBaseMapDownloaderViewController
{
TCountryId m_actionSheetId;
@ -132,7 +133,7 @@ using namespace storage;
- (void)configNavBar
{
BOOL const downloaded = self.mode == TMWMMapDownloaderMode::Downloaded;
BOOL const downloaded = self.mode == DownloaderMode::Downloaded;
if (self.dataSource.isParentRoot)
{
self.title = downloaded ? L(@"downloader_my_maps_title") : L(@"download_maps");
@ -146,10 +147,8 @@ using namespace storage;
if (downloaded)
{
UIBarButtonItem * addButton =
[self navBarButtonWithImage:[UIImage imageNamed:@"ic_nav_bar_add"]
highlightedImage:[UIImage imageNamed:@"ic_nav_bar_add_press"]
action:@selector(openAvailableMaps)];
UIBarButtonItem * addButton = [self buttonWithImage:[UIImage imageNamed:@"ic_nav_bar_add"]
action:@selector(openAvailableMaps)];
self.navigationItem.rightBarButtonItems = [self alignedNavBarButtonItems:@[ addButton ]];
}
}
@ -266,7 +265,7 @@ using namespace storage;
{
auto const & s = GetFramework().Storage();
TCountryId const parentCountryId = self.parentCountryId.UTF8String;
if (self.mode == TMWMMapDownloaderMode::Downloaded)
if (self.mode == DownloaderMode::Downloaded)
{
Storage::UpdateInfo updateInfo{};
s.GetUpdateInfo(parentCountryId, updateInfo);
@ -361,7 +360,7 @@ using namespace storage;
{
self.skipCountryEventProcessing = YES;
TCountryId const parentCountryId = self.parentCountryId.UTF8String;
if (self.mode == TMWMMapDownloaderMode::Downloaded)
if (self.mode == DownloaderMode::Downloaded)
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
@ -412,9 +411,16 @@ using namespace storage;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSString * identifier = [self.dataSource cellIdentifierForIndexPath:indexPath];
if ([identifier isEqualToString:kLargeCountryCellIdentifier])
[self openNodeSubtree:[self.dataSource countryIdForIndexPath:indexPath].UTF8String];
{
NSAssert(self.dataSource != nil, @"Datasource is nil.");
NSString * countyId = [self.dataSource countryIdForIndexPath:indexPath];
NSAssert(countyId != nil, @"CountryId is nil.");
[self openNodeSubtree:countyId.UTF8String];
}
else
{
[self showActionSheetForRowAtIndexPath:indexPath];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
@ -473,7 +479,10 @@ using namespace storage;
{
auto const & s = GetFramework().Storage();
NodeAttrs nodeAttrs;
m_actionSheetId = [self.dataSource countryIdForIndexPath:indexPath].UTF8String;
NSAssert(self.dataSource != nil, @"Datasource is nil.");
NSString * countyId = [self.dataSource countryIdForIndexPath:indexPath];
NSAssert(countyId != nil, @"CountryId is nil.");
m_actionSheetId = countyId.UTF8String;
s.GetNodeAttrs(m_actionSheetId, nodeAttrs);
ActionButtons buttons = NoAction;
@ -592,7 +601,8 @@ using namespace storage;
{
NodeAttrs nodeAttrs;
s.GetNodeAttrs(countryId, nodeAttrs);
updateSize += nodeAttrs.m_mwmSize;
if (nodeAttrs.m_status == NodeStatus::OnDiskOutOfDate)
updateSize += nodeAttrs.m_mwmSize;
}
NSString * title = [NSString stringWithFormat:kAllMapsLabelFormat, kUpdateActionTitle,
formattedSize(updateSize)];
@ -680,7 +690,7 @@ using namespace storage;
BOOL const isParentRoot = [self.parentCountryId isEqualToString:@(GetFramework().Storage().GetRootId().c_str())];
NSString * identifier = isParentRoot ? kControllerIdentifier : kBaseControllerIdentifier;
MWMBaseMapDownloaderViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
[vc setParentCountryId:self.parentCountryId mode:TMWMMapDownloaderMode::Available];
[vc setParentCountryId:self.parentCountryId mode:DownloaderMode::Available];
[MWMSegue segueFrom:self to:vc];
}
@ -782,7 +792,7 @@ using namespace storage;
#pragma mark - Configuration
- (void)setParentCountryId:(NSString *)parentId mode:(TMWMMapDownloaderMode)mode
- (void)setParentCountryId:(NSString *)parentId mode:(DownloaderMode)mode
{
self.defaultDataSource = [[MWMMapDownloaderDefaultDataSource alloc] initForRootCountryId:parentId
delegate:self
@ -809,7 +819,7 @@ using namespace storage;
return self.dataSource.parentCountryId;
}
- (TMWMMapDownloaderMode)mode
- (DownloaderMode)mode
{
return self.dataSource.mode;
}

View file

@ -1,5 +1,8 @@
enum class TMWMMapDownloaderMode
namespace mwm
{
enum class DownloaderMode
{
Downloaded,
Available
};
} // namespace mwm

View file

@ -25,7 +25,7 @@ using namespace storage;
@property (nonatomic) MWMMapDownloaderDataSource * defaultDataSource;
@property (nonatomic, readonly) NSString * parentCountryId;
@property (nonatomic, readonly) TMWMMapDownloaderMode mode;
@property (nonatomic, readonly) mwm::DownloaderMode mode;
@property (nonatomic) BOOL showAllMapsButtons;
@ -91,7 +91,7 @@ using namespace storage;
auto const & s = GetFramework().Storage();
if (![self.parentCountryId isEqualToString:@(s.GetRootId().c_str())])
return;
if (self.mode == TMWMMapDownloaderMode::Available || s.HaveDownloadedCountries())
if (self.mode == mwm::DownloaderMode::Available || s.HaveDownloadedCountries())
{
[self configAllMapsView];
self.tableView.hidden = NO;
@ -203,7 +203,7 @@ using namespace storage;
#pragma mark - Configuration
- (void)setParentCountryId:(NSString *)parentId mode:(TMWMMapDownloaderMode)mode
- (void)setParentCountryId:(NSString *)parentId mode:(mwm::DownloaderMode)mode
{
self.defaultDataSource = [[MWMMapDownloaderExtendedDataSource alloc] initForRootCountryId:parentId
delegate:self

View file

@ -34,7 +34,7 @@ namespace search { struct AddressInfo; }
- (void)openMigration;
- (void)openBookmarks;
- (void)openMapsDownloader:(TMWMMapDownloaderMode)mode;
- (void)openMapsDownloader:(mwm::DownloaderMode)mode;
- (void)openEditor;
- (void)refreshAd;

View file

@ -548,7 +548,7 @@ NSString * const kUDViralAlertWasShown = @"ViralAlertWasShown";
[self.navigationController pushViewController:vc animated:YES];
}
- (void)openMapsDownloader:(TMWMMapDownloaderMode)mode
- (void)openMapsDownloader:(mwm::DownloaderMode)mode
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"downloader"];
[self performSegueWithIdentifier:kDownloaderSegue sender:@(static_cast<NSInteger>(mode))];
@ -845,7 +845,7 @@ NSString * const kUDViralAlertWasShown = @"ViralAlertWasShown";
{
MWMMapDownloaderViewController * dvc = segue.destinationViewController;
NSNumber * mode = sender;
[dvc setParentCountryId:@(GetFramework().Storage().GetRootId().c_str()) mode:static_cast<TMWMMapDownloaderMode>(mode.integerValue)];
[dvc setParentCountryId:@(GetFramework().Storage().GetRootId().c_str()) mode:static_cast<mwm::DownloaderMode>(mode.integerValue)];
}
else if ([segue.identifier isEqualToString:kMap2FBLoginSegue])
{

View file

@ -179,7 +179,7 @@ using namespace storage;
if ([segue.identifier isEqualToString:kDownloaderSegue])
{
MWMMapDownloaderViewController * dvc = segue.destinationViewController;
[dvc setParentCountryId:@(GetFramework().Storage().GetRootId().c_str()) mode:TMWMMapDownloaderMode::Downloaded];
[dvc setParentCountryId:@(GetFramework().Storage().GetRootId().c_str()) mode:mwm::DownloaderMode::Downloaded];
}
}

View file

@ -3,10 +3,9 @@
- (void)showBackButton;
- (void)backTap;
- (UIBarButtonItem *)navBarButtonWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage action:(SEL)action;
- (UIBarButtonItem *)buttonWithImage:(UIImage *)image action:(SEL)action;
- (NSArray<UIBarButtonItem *> *)alignedNavBarButtonItems:(NSArray<UIBarButtonItem *> *)items;
@property (nonatomic, readonly) UIStoryboard * mainStoryboard;
@end

View file

@ -18,14 +18,11 @@ CGFloat constexpr kButtonExtraWidth = 16.0;
return spacer;
}
- (UIBarButtonItem *)navBarButtonWithImage:(UIImage *)image
highlightedImage:(UIImage *)highlightedImage
action:(SEL)action
- (UIBarButtonItem *)buttonWithImage:(UIImage *)image action:(SEL)action
{
CGSize const buttonSize = {image.size.width + kButtonExtraWidth, image.size.height};
UIButton * button = [[UIButton alloc] initWithFrame:{{}, buttonSize}];
[button setImage:image forState:UIControlStateNormal];
[button setImage:highlightedImage forState:UIControlStateHighlighted];
[button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
return [[UIBarButtonItem alloc] initWithCustomView:button];
}
@ -37,9 +34,7 @@ CGFloat constexpr kButtonExtraWidth = 16.0;
- (UIBarButtonItem *)backButton
{
return [self navBarButtonWithImage:[UIImage imageNamed:@"ic_nav_bar_back"]
highlightedImage:[UIImage imageNamed:@"ic_nav_bar_back_press"]
action:@selector(backTap)];
return [self buttonWithImage:[UIImage imageNamed:@"ic_nav_bar_back"] action:@selector(backTap)];
}
- (void)showBackButton

View file

@ -1,23 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_nav_bar_add_press.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_nav_bar_add_press@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_nav_bar_add_press@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 B

View file

@ -1,23 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_nav_bar_back_press.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_nav_bar_back_press@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_nav_bar_back_press@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B