[iOS] [refactoring] remove remaining cpp code from downloader

This commit is contained in:
Aleksey Belouosv 2019-12-24 04:43:05 +03:00 committed by Alexander Boriskov
parent e9d8e41d3a
commit c0ab60ff57
25 changed files with 417 additions and 292 deletions

View file

@ -49,6 +49,8 @@
47D9019523AC22E500D9364C /* MWMMapUpdateInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 47D9019323AC22E500D9364C /* MWMMapUpdateInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
47D9019623AC22E500D9364C /* MWMMapUpdateInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 47D9019423AC22E500D9364C /* MWMMapUpdateInfo.mm */; };
47D9019923AC236100D9364C /* MWMMapUpdateInfo+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 47D9019723AC236100D9364C /* MWMMapUpdateInfo+Core.h */; settings = {ATTRIBUTES = (Public, ); }; };
47E8163623B1889C008FD836 /* MWMStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 47E8163423B1889B008FD836 /* MWMStorage.mm */; };
47E8163723B188D3008FD836 /* MWMStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 47E8163523B1889B008FD836 /* MWMStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
47EEAFF42350CEDB005CF316 /* AppInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 47EEAFF22350CEDA005CF316 /* AppInfo.mm */; };
47EEAFF62350CF48005CF316 /* AppInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 47EEAFF32350CEDB005CF316 /* AppInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
47EEAFF72350D060005CF316 /* MWMCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 47EEAFF52350CEF6005CF316 /* MWMCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -119,6 +121,8 @@
47D9019323AC22E500D9364C /* MWMMapUpdateInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMMapUpdateInfo.h; sourceTree = "<group>"; };
47D9019423AC22E500D9364C /* MWMMapUpdateInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapUpdateInfo.mm; sourceTree = "<group>"; };
47D9019723AC236100D9364C /* MWMMapUpdateInfo+Core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MWMMapUpdateInfo+Core.h"; sourceTree = "<group>"; };
47E8163423B1889B008FD836 /* MWMStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStorage.mm; sourceTree = "<group>"; };
47E8163523B1889B008FD836 /* MWMStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStorage.h; sourceTree = "<group>"; };
47EEAFF22350CEDA005CF316 /* AppInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = AppInfo.mm; sourceTree = "<group>"; };
47EEAFF32350CEDB005CF316 /* AppInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppInfo.h; sourceTree = "<group>"; };
47EEAFF52350CEF6005CF316 /* MWMCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMCommon.h; sourceTree = "<group>"; };
@ -318,6 +322,8 @@
47F4F1F623A333280022FD56 /* Storage */ = {
isa = PBXGroup;
children = (
47E8163523B1889B008FD836 /* MWMStorage.h */,
47E8163423B1889B008FD836 /* MWMStorage.mm */,
47F4F1F723A3336B0022FD56 /* MWMMapNodeAttributes.h */,
47F4F1FB23A3D1AC0022FD56 /* MWMMapNodeAttributes+Core.h */,
47F4F1F823A3336C0022FD56 /* MWMMapNodeAttributes.mm */,
@ -416,6 +422,7 @@
999D3A64237B097C00C5F7A8 /* DeepLinkSubscriptionData.h in Headers */,
470016102342579200EBF03D /* MWMTagGroup.h in Headers */,
479F7063234FBC5900011E2E /* MWMCarPlayBookmarkObject.h in Headers */,
47E8163723B188D3008FD836 /* MWMStorage.h in Headers */,
47EEAFF62350CF48005CF316 /* AppInfo.h in Headers */,
479F7053234FB7BC00011E2E /* MWMCatalogCommon.h in Headers */,
4700160F2342579000EBF03D /* MWMTag.h in Headers */,
@ -524,6 +531,7 @@
4718C4332355FC3C00640DF1 /* MWMNetworkPolicy.mm in Sources */,
993F54F3237C5D1100545511 /* PromoAfterBookingCampaignAdapter.mm in Sources */,
47EEAFF42350CEDB005CF316 /* AppInfo.mm in Sources */,
47E8163623B1889C008FD836 /* MWMStorage.mm in Sources */,
9957FAE9237AE5B000855F48 /* Logger.mm in Sources */,
999D3A65237B097C00C5F7A8 /* DeepLinkSubscriptionData.mm in Sources */,
);

View file

@ -14,6 +14,7 @@ FOUNDATION_EXPORT const unsigned char CoreApiVersionString[];
#import <CoreApi/MWMFrameworkHelper.h>
#import <CoreApi/MWMNetworkPolicy.h>
#import <CoreApi/MWMSearchFrameworkHelper.h>
#import <CoreApi/MWMStorage.h>
#import <CoreApi/MWMTag.h>
#import <CoreApi/MWMTagGroup.h>
#import <CoreApi/MWMTrafficManager.h>

View file

@ -1,27 +1,35 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@class MWMMapNodeAttributes;
@class MWMMapUpdateInfo;
NS_ASSUME_NONNULL_BEGIN
extern NSErrorDomain const kStorageErrorDomain;
extern NSInteger const kStorageNotEnoughSpace;
extern NSInteger const kStorageNoConnection;
extern NSInteger const kStorageCellularForbidden;
extern NSInteger const kStorageRoutingActive;
extern NSInteger const kStorageHaveUnsavedEdits;
NS_SWIFT_NAME(Storage)
@interface MWMStorage : NSObject
+ (void)downloadNode:(NSString *)countryId
onSuccess:(nullable MWMVoidBlock)onSuccess
onCancel:(nullable MWMVoidBlock)onCancel;
+ (BOOL)downloadNode:(NSString *)countryId error:(NSError * __autoreleasing _Nullable *)error;
+ (void)retryDownloadNode:(NSString *)countryId;
+ (void)updateNode:(NSString *)countryId
onCancel:(nullable MWMVoidBlock)onCancel;
+ (void)deleteNode:(NSString *)countryId;
+ (BOOL)updateNode:(NSString *)countryId error:(NSError * __autoreleasing _Nullable *)error;
+ (BOOL)deleteNode:(NSString *)countryId
ignoreUnsavedEdits:(BOOL)force
error:(NSError * __autoreleasing _Nullable *)error;
+ (void)cancelDownloadNode:(NSString *)countryId;
+ (void)showNode:(NSString *)countryId;
+ (void)downloadNodes:(NSArray<NSString *> *)countryIds
onSuccess:(nullable MWMVoidBlock)onSuccess
onCancel:(nullable MWMVoidBlock)onCancel;
+ (BOOL)downloadNodes:(NSArray<NSString *> *)countryIds error:(NSError * __autoreleasing _Nullable *)error;
+ (BOOL)haveDownloadedCountries;
+ (BOOL)downloadInProgress;
+ (void)enableCellularDownload:(BOOL)enable;
#pragma mark - Attributes

View file

@ -1,88 +1,93 @@
#import "MWMStorage.h"
#import "MWMAlertViewController.h"
#import "MWMMapNodeAttributes+Core.h"
#import "MWMMapUpdateInfo+Core.h"
#include <CoreApi/Framework.h>
#import <CoreApi/MWMMapNodeAttributes+Core.h>
#import <CoreApi/MWMMapUpdateInfo+Core.h>
#include "storage/storage_helpers.hpp"
NSErrorDomain const kStorageErrorDomain = @"com.mapswithme.storage";
NSInteger const kStorageNotEnoughSpace = 1;
NSInteger const kStorageNoConnection = 2;
NSInteger const kStorageCellularForbidden = 3;
NSInteger const kStorageRoutingActive = 4;
NSInteger const kStorageHaveUnsavedEdits = 5;
using namespace storage;
@implementation MWMStorage
+ (void)downloadNode:(NSString *)countryId onSuccess:(MWMVoidBlock)onSuccess onCancel:(MWMVoidBlock)onCancel
{
if (IsEnoughSpaceForDownload(countryId.UTF8String, GetFramework().GetStorage()))
{
[self checkConnectionAndPerformAction:[countryId, onSuccess] {
+ (BOOL)downloadNode:(NSString *)countryId error:(NSError *__autoreleasing _Nullable *)error {
if (IsEnoughSpaceForDownload(countryId.UTF8String, GetFramework().GetStorage())) {
NSError *connectionError;
if ([self checkConnection:&connectionError]) {
GetFramework().GetStorage().DownloadNode(countryId.UTF8String);
if (onSuccess)
onSuccess();
} cancelAction:onCancel];
}
else
{
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
if (onCancel)
onCancel();
return YES;
} else if (error) {
*error = connectionError;
}
} else if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageNotEnoughSpace userInfo:nil];
}
return NO;
}
+ (void)retryDownloadNode:(NSString *)countryId
{
[self checkConnectionAndPerformAction:[countryId] {
+ (void)retryDownloadNode:(NSString *)countryId {
if ([self checkConnection:nil]) {
GetFramework().GetStorage().RetryDownloadNode(countryId.UTF8String);
} cancelAction:nil];
}
}
+ (void)updateNode:(NSString *)countryId onCancel:(MWMVoidBlock)onCancel
{
if (IsEnoughSpaceForUpdate(countryId.UTF8String, GetFramework().GetStorage()))
{
[self checkConnectionAndPerformAction:[countryId] {
+ (BOOL)updateNode:(NSString *)countryId error:(NSError *__autoreleasing _Nullable *)error {
if (IsEnoughSpaceForUpdate(countryId.UTF8String, GetFramework().GetStorage())) {
NSError *connectionError;
if ([self checkConnection:&connectionError]) {
GetFramework().GetStorage().UpdateNode(countryId.UTF8String);
} cancelAction:onCancel];
}
else
{
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
if (onCancel)
onCancel();
return YES;
} else if (error) {
*error = connectionError;
}
} else if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageNotEnoughSpace userInfo:nil];
}
return NO;
}
+ (void)deleteNode:(NSString *)countryId
{
auto & f = GetFramework();
if (f.GetRoutingManager().IsRoutingActive())
{
[[MWMAlertViewController activeAlertController] presentDeleteMapProhibitedAlert];
return;
+ (BOOL)deleteNode:(NSString *)countryId
ignoreUnsavedEdits:(BOOL)force
error:(NSError *__autoreleasing _Nullable *)error {
auto &f = GetFramework();
if (f.GetRoutingManager().IsRoutingActive()) {
if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageRoutingActive userInfo:nil];
}
return NO;
}
if (f.HasUnsavedEdits(countryId.UTF8String))
{
[[MWMAlertViewController activeAlertController]
presentUnsavedEditsAlertWithOkBlock:[countryId] {
GetFramework().GetStorage().DeleteNode(countryId.UTF8String);
}];
}
else
{
if (!force && f.HasUnsavedEdits(countryId.UTF8String)) {
if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageHaveUnsavedEdits userInfo:nil];
}
} else {
f.GetStorage().DeleteNode(countryId.UTF8String);
return YES;
}
return NO;
}
+ (void)cancelDownloadNode:(NSString *)countryId
{
+ (void)cancelDownloadNode:(NSString *)countryId {
GetFramework().GetStorage().CancelDownloadNode(countryId.UTF8String);
}
+ (void)showNode:(NSString *)countryId { GetFramework().ShowNode(countryId.UTF8String); }
+ (void)downloadNodes:(NSArray<NSString *> *)countryIds onSuccess:(MWMVoidBlock)onSuccess onCancel:(MWMVoidBlock)onCancel
{
auto & s = GetFramework().GetStorage();
+ (void)showNode:(NSString *)countryId {
GetFramework().ShowNode(countryId.UTF8String);
}
+ (BOOL)downloadNodes:(NSArray<NSString *> *)countryIds error:(NSError *__autoreleasing _Nullable *)error {
auto &s = GetFramework().GetStorage();
MwmSize requiredSize = s.GetMaxMwmSizeBytes();
for (NSString *countryId in countryIds) {
@ -90,47 +95,49 @@ using namespace storage;
GetFramework().GetStorage().GetNodeAttrs(countryId.UTF8String, nodeAttrs);
requiredSize += nodeAttrs.m_mwmSize;
}
if (storage::IsEnoughSpaceForDownload(requiredSize))
{
[self checkConnectionAndPerformAction:[countryIds, onSuccess, &s] {
for (NSString *countryId in countryIds)
if (storage::IsEnoughSpaceForDownload(requiredSize)) {
NSError *connectionError;
if ([self checkConnection:&connectionError]) {
for (NSString *countryId in countryIds) {
s.DownloadNode(countryId.UTF8String);
if (onSuccess)
onSuccess();
} cancelAction: onCancel];
}
else
{
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
if (onCancel)
onCancel();
}
return YES;
} else if (error) {
*error = connectionError;
}
} else if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageNotEnoughSpace userInfo:nil];
}
return NO;
}
+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action cancelAction:(MWMVoidBlock)cancel
{
switch (Platform::ConnectionStatus())
{
+ (BOOL)checkConnection:(NSError *__autoreleasing *)error {
switch (Platform::ConnectionStatus()) {
case Platform::EConnectionType::CONNECTION_NONE:
[[MWMAlertViewController activeAlertController] presentNoConnectionAlert];
if (cancel)
cancel();
if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageNoConnection userInfo:nil];
}
return NO;
break;
case Platform::EConnectionType::CONNECTION_WIFI:
action();
break;
case Platform::EConnectionType::CONNECTION_WWAN:
{
if (!GetFramework().GetDownloadingPolicy().IsCellularDownloadEnabled())
{
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:[action] {
GetFramework().GetDownloadingPolicy().EnableCellularDownload(true);
action();
} andCancelBlock:cancel];
if (error) {
*error = nil;
}
else
{
action();
return YES;
break;
case Platform::EConnectionType::CONNECTION_WWAN: {
if (!GetFramework().GetDownloadingPolicy().IsCellularDownloadEnabled()) {
if (error) {
*error = [NSError errorWithDomain:kStorageErrorDomain code:kStorageCellularForbidden userInfo:nil];
}
return NO;
} else {
if (error) {
*error = nil;
}
return YES;
}
break;
}
@ -145,6 +152,10 @@ using namespace storage;
return GetFramework().GetStorage().IsDownloadInProgress();
}
+ (void)enableCellularDownload:(BOOL)enable {
GetFramework().GetDownloadingPolicy().EnableCellularDownload(enable);
}
#pragma mark - Attributes
+ (NSArray<NSString *> *)allCountries {
@ -155,9 +166,7 @@ using namespace storage;
+ (NSArray<NSString *> *)allCountriesWithParent:(NSString *)countryId {
storage::CountriesVec downloadedChildren;
storage::CountriesVec availableChildren;
GetFramework().GetStorage().GetChildrenInGroups(countryId.UTF8String,
downloadedChildren,
availableChildren,
GetFramework().GetStorage().GetChildrenInGroups(countryId.UTF8String, downloadedChildren, availableChildren,
true /* keepAvailableChildren */);
NSMutableArray *result = [NSMutableArray arrayWithCapacity:availableChildren.size()];
@ -170,9 +179,7 @@ using namespace storage;
+ (NSArray<NSString *> *)availableCountriesWithParent:(NSString *)countryId {
storage::CountriesVec downloadedChildren;
storage::CountriesVec availableChildren;
GetFramework().GetStorage().GetChildrenInGroups(countryId.UTF8String,
downloadedChildren,
availableChildren);
GetFramework().GetStorage().GetChildrenInGroups(countryId.UTF8String, downloadedChildren, availableChildren);
NSMutableArray *result = [NSMutableArray arrayWithCapacity:availableChildren.size()];
for (auto const &cid : availableChildren) {
@ -189,9 +196,7 @@ using namespace storage;
+ (NSArray<NSString *> *)downloadedCountriesWithParent:(NSString *)countryId {
storage::CountriesVec downloadedChildren;
storage::CountriesVec availableChildren;
GetFramework().GetStorage().GetChildrenInGroups(countryId.UTF8String,
downloadedChildren,
availableChildren);
GetFramework().GetStorage().GetChildrenInGroups(countryId.UTF8String, downloadedChildren, availableChildren);
NSMutableArray *result = [NSMutableArray arrayWithCapacity:downloadedChildren.size()];
for (auto const &cid : downloadedChildren) {

View file

@ -33,7 +33,7 @@
#import "MWMAvailableAreaAffectDirection.h"
#import "MWMBanner.h"
#import "MWMBottomMenuViewController.h"
#import "MWMCircularProgress+Swift.h"
#import "MWMCircularProgress.h"
#import "MWMCollectionViewController.h"
#import "MWMConsts.h"
#import "MWMController.h"
@ -69,7 +69,7 @@
#import "MWMSearchNoResults.h"
#import "MWMSettings.h"
#import "MWMSideButtons.h"
#import "MWMStorage.h"
#import "MWMStorage+UI.h"
#import "MWMTableViewCell.h"
#import "MWMTableViewController.h"
#import "MWMTextToSpeech.h"

View file

@ -4,7 +4,7 @@
#import "MWMDownloaderDialogHeader.h"
#import "MWMFrameworkListener.h"
#import "MWMFrameworkStorageObserver.h"
#import "MWMStorage.h"
#import "MWMStorage+UI.h"
#import "Statistics.h"
#import "SwiftBridge.h"
#import "UILabel+RuntimeAttributes.h"

View file

@ -1,29 +0,0 @@
#import "MWMButton.h"
#import "MWMCircularProgressState.h"
#import "UIImageView+Coloring.h"
@class MWMCircularProgress;
@protocol MWMCircularProgressProtocol<NSObject>
- (void)progressButtonPressed:(nonnull MWMCircularProgress *)progress;
@end
@interface MWMCircularProgress : NSObject<CAAnimationDelegate>
+ (nonnull instancetype)downloaderProgressForParentView:(nonnull UIView *)parentView;
@property(nonatomic) CGFloat progress;
@property(nonatomic) MWMCircularProgressState state;
@property(weak, nonatomic) id<MWMCircularProgressProtocol> _Nullable delegate;
- (void)setSpinnerColoring:(MWMImageColoring)coloring;
- (void)setSpinnerBackgroundColor:(nonnull UIColor *)backgroundColor;
- (void)setInvertColor:(BOOL)invertColor;
- (void)setCancelButtonHidden;
- (nonnull instancetype)init __attribute__((unavailable("init is not available")));
- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView;
@end

View file

@ -1,14 +1,40 @@
#import "MWMCircularProgress+Swift.h"
#import "MWMButton.h"
#import "MWMCircularProgressState.h"
#import "UIImageView+Coloring.h"
#include <vector>
NS_ASSUME_NONNULL_BEGIN
using MWMCircularProgressStateVec = std::vector<MWMCircularProgressState>;
@class MWMCircularProgress;
@interface MWMCircularProgress ()
typedef NSArray<NSNumber *> *MWMCircularProgressStateVec;
@protocol MWMCircularProgressProtocol<NSObject>
- (void)progressButtonPressed:(MWMCircularProgress *)progress;
@end
@interface MWMCircularProgress: NSObject<CAAnimationDelegate>
+ (instancetype)downloaderProgressForParentView:(UIView *)parentView;
@property(nonatomic) CGFloat progress;
@property(nonatomic) MWMCircularProgressState state;
@property(weak, nonatomic, nullable) id<MWMCircularProgressProtocol> delegate;
- (void)setSpinnerColoring:(MWMImageColoring)coloring;
- (void)setSpinnerBackgroundColor:(UIColor *)backgroundColor;
- (void)setInvertColor:(BOOL)invertColor;
- (void)setCancelButtonHidden;
- (nonnull instancetype)init __attribute__((unavailable("init is not available")));
- (nonnull instancetype)initWithParentView:(UIView *)parentView;
- (void)setImageName:(nullable NSString *)imageName
forStates:(MWMCircularProgressStateVec const &)states;
- (void)setColor:(nonnull UIColor *)color forStates:(MWMCircularProgressStateVec const &)states;
forStates:(MWMCircularProgressStateVec)states;
- (void)setColor:(UIColor *)color forStates:(MWMCircularProgressStateVec)states;
- (void)setColoring:(MWMButtonColoring)coloring
forStates:(MWMCircularProgressStateVec const &)states;
forStates:(MWMCircularProgressStateVec)states;
@end
NS_ASSUME_NONNULL_END

View file

@ -24,19 +24,17 @@
progress.rootView.suspendRefreshProgress = YES;
[progress setImageName:@"ic_download"
forStates:{MWMCircularProgressStateNormal, MWMCircularProgressStateSelected}];
forStates:@[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected)]];
[progress setImageName:@"ic_close_spinner"
forStates:{MWMCircularProgressStateProgress, MWMCircularProgressStateSpinner}];
[progress setImageName:@"ic_download_error"
forStates:{MWMCircularProgressStateFailed}];
[progress setImageName:@"ic_check"
forStates:{MWMCircularProgressStateCompleted}];
forStates:@[@(MWMCircularProgressStateProgress), @(MWMCircularProgressStateSpinner)]];
[progress setImageName:@"ic_download_error" forStates:@[@(MWMCircularProgressStateFailed)]];
[progress setImageName:@"ic_check" forStates:@[@(MWMCircularProgressStateCompleted)]];
[progress setColoring:MWMButtonColoringBlack
forStates:{MWMCircularProgressStateNormal, MWMCircularProgressStateSelected,
MWMCircularProgressStateProgress, MWMCircularProgressStateSpinner}];
[progress setColoring:MWMButtonColoringOther forStates:{MWMCircularProgressStateFailed}];
[progress setColoring:MWMButtonColoringBlue forStates:{MWMCircularProgressStateCompleted}];
forStates:@[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected),
@(MWMCircularProgressStateProgress), @(MWMCircularProgressStateSpinner)]];
[progress setColoring:MWMButtonColoringOther forStates:@[@(MWMCircularProgressStateFailed)]];
[progress setColoring:MWMButtonColoringBlue forStates:@[@(MWMCircularProgressStateCompleted)]];
progress.rootView.suspendRefreshProgress = NO;
@ -80,23 +78,23 @@
}
- (void)setImageName:(nullable NSString *)imageName
forStates:(MWMCircularProgressStateVec const &)states
forStates:(MWMCircularProgressStateVec)states
{
for (auto const & state : states)
[self.rootView setImageName:imageName forState:state];
for (NSNumber *state in states)
[self.rootView setImageName:imageName forState:(MWMCircularProgressState)state.integerValue];
}
- (void)setColor:(nonnull UIColor *)color forStates:(MWMCircularProgressStateVec const &)states
- (void)setColor:(UIColor *)color forStates:(MWMCircularProgressStateVec)states
{
for (auto const & state : states)
[self.rootView setColor:color forState:state];
for (NSNumber *state in states)
[self.rootView setColor:color forState:(MWMCircularProgressState)state.integerValue];
}
- (void)setColoring:(MWMButtonColoring)coloring
forStates:(MWMCircularProgressStateVec const &)states
forStates:(MWMCircularProgressStateVec)states
{
for (auto const & state : states)
[self.rootView setColoring:coloring forState:state];
for (NSNumber *state in states)
[self.rootView setColoring:coloring forState:(MWMCircularProgressState)state.integerValue];
}
- (void)setInvertColor:(BOOL)invertColor { self.rootView.isInvertColor = invertColor; }

View file

@ -2,15 +2,11 @@
#import "SwiftBridge.h"
#import "UIImageView+Coloring.h"
#include <map>
static CGFloat const kLineWidth = 2.0;
static NSString * const kAnimationKey = @"CircleAnimation";
namespace
{
CGFloat const kLineWidth = 2.0;
NSString * const kAnimationKey = @"CircleAnimation";
static CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_PI_2; }
CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_PI_2; }
} // namespace
@interface MWMCircularProgressView ()
@property(nonatomic) CAShapeLayer * backgroundLayer;
@ -20,6 +16,8 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
@property(nonatomic, readonly) CGColorRef progressLayerColor;
@property(nonatomic) NSMutableDictionary * colors;
@property(nonatomic) NSMutableDictionary<NSNumber *, NSNumber *> * buttonColoring;
@property(nonatomic) NSMutableDictionary<NSNumber *, NSString *> * images;
@property(weak, nonatomic) IBOutlet MWMCircularProgress * owner;
@property(weak, nonatomic) IBOutlet UIImageView * spinner;
@ -30,10 +28,6 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
@end
@implementation MWMCircularProgressView
{
std::map<MWMCircularProgressState, MWMButtonColoring> m_buttonColoring;
std::map<MWMCircularProgressState, NSString *> m_images;
}
- (void)awakeFromNib
{
@ -41,6 +35,7 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
self.suspendRefreshProgress = YES;
[self setupColors];
[self setupButtonColoring];
self.images = [NSMutableDictionary dictionary];
[self setupAnimationLayers];
self.suspendRefreshProgress = NO;
}
@ -65,6 +60,7 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
- (void)setupButtonColoring
{
self.buttonColoring = [NSMutableDictionary dictionary];
[self setColoring:MWMButtonColoringBlack forState:MWMCircularProgressStateNormal];
[self setColoring:MWMButtonColoringBlue forState:MWMCircularProgressStateSelected];
[self setColoring:MWMButtonColoringBlue forState:MWMCircularProgressStateProgress];
@ -93,11 +89,11 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
- (void)setSpinnerColoring:(MWMImageColoring)coloring { self.spinner.mwm_coloring = coloring; }
- (void)setImageName:(nullable NSString *)imageName forState:(MWMCircularProgressState)state
{
m_images[state] = imageName;
self.images[@(state)] = imageName;
[self refreshProgress];
}
- (void)setColor:(nonnull UIColor *)color forState:(MWMCircularProgressState)state
- (void)setColor:(UIColor *)color forState:(MWMCircularProgressState)state
{
self.colors[@(state)] = color;
[self refreshProgress];
@ -105,7 +101,7 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
- (void)setColoring:(MWMButtonColoring)coloring forState:(MWMCircularProgressState)state
{
m_buttonColoring[state] = coloring;
self.buttonColoring[@(state)] = @(coloring);
[self refreshProgress];
}
@ -121,10 +117,12 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
self.progressLayer.strokeColor = self.progressLayerColor;
CGRect rect = CGRectInset(self.bounds, kLineWidth, kLineWidth);
self.backgroundLayer.path = [UIBezierPath bezierPathWithOvalInRect:rect].CGPath;
if (auto imageName = m_images[self.state])
NSString * imageName = self.images[@(self.state)];
if (imageName)
{
[self.button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
if (auto hl = [UIImage imageNamed:[imageName stringByAppendingString:@"_highlighted"]])
UIImage *hl = [UIImage imageNamed:[imageName stringByAppendingString:@"_highlighted"]];
if (hl)
[self.button setImage:hl forState:UIControlStateHighlighted];
}
else
@ -133,7 +131,7 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
[self.button setImage:nil forState:UIControlStateHighlighted];
}
self.button.coloring = m_buttonColoring[self.state];
self.button.coloring = (MWMButtonColoring)self.buttonColoring[@(self.state)].unsignedIntegerValue;
}
- (void)updatePath:(CGFloat)progress
@ -144,9 +142,8 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
progress < 1.0 ? MWMCircularProgressStateProgress : MWMCircularProgressStateCompleted;
[self stopSpinner];
}
CGPoint const center = {static_cast<CGFloat>(self.width / 2.0),
static_cast<CGFloat>(self.height / 2.0)};
CGFloat const radius = MIN(center.x, center.y) - kLineWidth;
CGPoint center = CGPointMake(self.width / 2.0, self.height / 2.0);
CGFloat radius = MIN(center.x, center.y) - kLineWidth;
UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:center
radius:radius
startAngle:angleWithProgress(0.0)
@ -237,7 +234,7 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
- (void)setFrame:(CGRect)frame
{
BOOL const needrefreshProgress = !CGRectEqualToRect(self.frame, frame);
BOOL needrefreshProgress = !CGRectEqualToRect(self.frame, frame);
super.frame = frame;
if (needrefreshProgress)
[self refreshProgress];

View file

@ -86,21 +86,21 @@ static CGFloat const kDrivingOptionsHeight = 48;
routerType:(MWMRouterType)routerType
{
MWMCircularProgress * progress = [[MWMCircularProgress alloc] initWithParentView:parentView];
MWMCircularProgressStateVec const imageStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateProgress, MWMCircularProgressStateSpinner};
MWMCircularProgressStateVec imageStates = @[@(MWMCircularProgressStateNormal),
@(MWMCircularProgressStateProgress), @(MWMCircularProgressStateSpinner)];
[progress setImageName:imageName forStates:imageStates];
[progress setImageName:[imageName stringByAppendingString:@"_selected"] forStates:{MWMCircularProgressStateSelected, MWMCircularProgressStateCompleted}];
[progress setImageName:@"ic_error" forStates:{MWMCircularProgressStateFailed}];
[progress setImageName:[imageName stringByAppendingString:@"_selected"] forStates:@[@(MWMCircularProgressStateSelected), @(MWMCircularProgressStateCompleted)]];
[progress setImageName:@"ic_error" forStates:@[@(MWMCircularProgressStateFailed)]];
[progress setColoring:MWMButtonColoringWhiteText
forStates:{MWMCircularProgressStateFailed, MWMCircularProgressStateSelected,
MWMCircularProgressStateProgress, MWMCircularProgressStateSpinner,
MWMCircularProgressStateCompleted}];
forStates:@[@(MWMCircularProgressStateFailed), @(MWMCircularProgressStateSelected),
@(MWMCircularProgressStateProgress), @(MWMCircularProgressStateSpinner),
@(MWMCircularProgressStateCompleted)]];
[progress setSpinnerBackgroundColor:UIColor.clearColor];
[progress setColor:UIColor.whiteColor
forStates:{MWMCircularProgressStateProgress, MWMCircularProgressStateSpinner}];
forStates:@[@(MWMCircularProgressStateProgress), @(MWMCircularProgressStateSpinner)]];
progress.delegate = self;
m_progresses[routerType] = progress;

View file

@ -6,7 +6,7 @@
#import "MWMFrameworkListener.h"
#import "MWMFrameworkStorageObserver.h"
#import "MWMMegafonBannerViewController.h"
#import "MWMStorage.h"
#import "MWMStorage+UI.h"
#import "MapViewController.h"
#import "Statistics.h"
#import "SwiftBridge.h"
@ -137,8 +137,7 @@ using namespace storage;
[MWMStorage downloadNode:@(m_countryId.c_str())
onSuccess:^{
[self showInQueue];
}
onCancel:nil];
}];
} else {
m_autoDownloadCountryId = kInvalidCountryId;
[self showDownloadRequest];
@ -428,8 +427,7 @@ using namespace storage;
kStatScenario: kStatDownload
}];
[MWMStorage downloadNode:@(m_countryId.c_str())
onSuccess:^{ [self showInQueue]; }
onCancel:nil];
onSuccess:^{ [self showInQueue]; }];
}
#pragma mark - Properties

View file

@ -9,7 +9,7 @@
#import "MWMMapViewControlsManager.h"
#import "MWMNavigationDashboardManager+Entity.h"
#import "MWMRoutePoint+CPP.h"
#import "MWMStorage.h"
#import "MWMStorage+UI.h"
#import "MapsAppDelegate.h"
#import "SwiftBridge.h"
#import "UIImage+RGBAData.h"
@ -727,8 +727,7 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType)
[array addObject:@(cid.c_str())];
}
[MWMStorage downloadNodes:array
onSuccess:onSuccess
onCancel:nil];
onSuccess:onSuccess];
}
downloadCompleteBlock:^{
[MWMRouter rebuildWithBestRouter:NO];

View file

@ -0,0 +1,16 @@
#import <CoreApi/MWMStorage.h>
NS_ASSUME_NONNULL_BEGIN
@interface MWMStorage (UI)
+ (void)downloadNode:(NSString *)countryId;
+ (void)downloadNode:(NSString *)countryId onSuccess:(nullable MWMVoidBlock)success;
+ (void)updateNode:(NSString *)countryId;
+ (void)updateNode:(NSString *)countryId onCancel:(nullable MWMVoidBlock)cancel;
+ (void)deleteNode:(NSString *)countryId;
+ (void)downloadNodes:(NSArray<NSString *> *)countryIds onSuccess:(nullable MWMVoidBlock)success;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,105 @@
#import "MWMStorage+UI.h"
#import "MWMAlertViewController.h"
@implementation MWMStorage (UI)
+ (void)handleError:(NSError *)error {
if (error.code == kStorageNotEnoughSpace) {
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
} else if (error.code == kStorageNoConnection) {
[[MWMAlertViewController activeAlertController] presentNoConnectionAlert];
} else if (error.code == kStorageRoutingActive) {
[[MWMAlertViewController activeAlertController] presentDeleteMapProhibitedAlert];
} else {
NSAssert(NO, @"Unknown error code");
}
}
+ (void)downloadNode:(NSString *)countryId {
[self downloadNode:countryId onSuccess:nil];
}
+ (void)downloadNode:(NSString *)countryId onSuccess:(MWMVoidBlock)success {
NSError *error;
[self downloadNode:countryId error:&error];
if (error) {
if (error.code == kStorageCellularForbidden) {
__weak __typeof(self) ws = self;
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
[ws downloadNode:countryId];
} andCancelBlock:nil];
} else {
[self handleError:error];
}
return;
}
if (success) {
success();
}
}
+ (void)updateNode:(NSString *)countryId {
[self updateNode:countryId onCancel:nil];
}
+ (void)updateNode:(NSString *)countryId onCancel:(MWMVoidBlock)cancel {
NSError *error;
[self updateNode:countryId error:&error];
if (error) {
if (error.code == kStorageCellularForbidden) {
__weak __typeof(self) ws = self;
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
[ws updateNode:countryId onCancel:cancel];
} andCancelBlock:cancel];
} else {
[self handleError:error];
if (cancel) {
cancel();
}
}
}
}
+ (void)deleteNode:(NSString *)countryId {
[self deleteNode:countryId ignoreUnsavedEdits:NO];
}
+ (void)deleteNode:(NSString *)countryId ignoreUnsavedEdits:(BOOL)force {
NSError *error;
[self deleteNode:countryId ignoreUnsavedEdits:force error:&error];
if (error) {
__weak __typeof(self) ws = self;
if (error.code == kStorageCellularForbidden) {
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
[ws deleteNode:countryId];
} andCancelBlock:nil];
} else if (error.code == kStorageHaveUnsavedEdits) {
[[MWMAlertViewController activeAlertController] presentUnsavedEditsAlertWithOkBlock:^ {
[ws deleteNode:countryId ignoreUnsavedEdits:YES];
}];
} else {
[self handleError:error];
}
}
}
+ (void)downloadNodes:(NSArray<NSString *> *)countryIds onSuccess:(nullable MWMVoidBlock)success {
NSError *error;
[self downloadNodes:countryIds error:&error];
if (error) {
if (error.code == kStorageCellularForbidden) {
__weak __typeof(self) ws = self;
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:^{
[ws downloadNodes:countryIds onSuccess:success];
} andCancelBlock:nil];
} else {
[self handleError:error];
}
return;
}
if (success) {
success();
}
}
@end

View file

@ -55,7 +55,6 @@
3404756B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404753B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm */; };
3404756E1E081A4600C92850 /* MWMSearch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404753D1E081A4600C92850 /* MWMSearch.mm */; };
340475711E081A4600C92850 /* MWMSettings.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475411E081A4600C92850 /* MWMSettings.mm */; };
340475741E081A4600C92850 /* MWMStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475441E081A4600C92850 /* MWMStorage.mm */; };
3404757E1E081B3300C92850 /* iosOGLContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404757A1E081B3300C92850 /* iosOGLContext.mm */; };
340475811E081B3300C92850 /* iosOGLContextFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404757C1E081B3300C92850 /* iosOGLContextFactory.mm */; };
3404F48B202894EA0090E401 /* BMCViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3404F489202894EA0090E401 /* BMCViewController.swift */; };
@ -439,6 +438,7 @@
47E6688A23196F0100057733 /* UIViewController+Subscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47E6688923196F0000057733 /* UIViewController+Subscription.swift */; };
47E6CB0B2178BA3600EA102B /* SearchBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47E6CB092178BA3600EA102B /* SearchBannerCell.swift */; };
47E6CB0C2178BA3600EA102B /* SearchBannerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47E6CB0A2178BA3600EA102B /* SearchBannerCell.xib */; };
47E8163323B17734008FD836 /* MWMStorage+UI.m in Sources */ = {isa = PBXBuildFile; fileRef = 47E8163223B17734008FD836 /* MWMStorage+UI.m */; };
47EF05B321504D8F00EAC269 /* RemoveAdsPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EF05B221504D8F00EAC269 /* RemoveAdsPresentationController.swift */; };
47F4F21323A6EC420022FD56 /* DownloadMapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F4F21223A6EC420022FD56 /* DownloadMapsViewController.swift */; };
47F4F21523A6F06F0022FD56 /* AvailableMapsDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F4F21423A6F06F0022FD56 /* AvailableMapsDataSource.swift */; };
@ -503,8 +503,8 @@
6741A9CF1BF340DE002C974C /* MWMLocationAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = F6BBF2C51B4FFB72000CF8E2 /* MWMLocationAlert.m */; };
6741A9D41BF340DE002C974C /* MWMAlertViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19821AB81A00006EAF7E /* MWMAlertViewController.mm */; };
6741A9E01BF340DE002C974C /* MWMDownloaderDialogHeader.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F4B731B4A45FD0081A24A /* MWMDownloaderDialogHeader.mm */; };
6741A9E71BF340DE002C974C /* MWMCircularProgressView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 349A35791B53D4C9009677EE /* MWMCircularProgressView.mm */; };
6741A9EC1BF340DE002C974C /* MWMCircularProgress.mm in Sources */ = {isa = PBXBuildFile; fileRef = 349A35761B53D4C9009677EE /* MWMCircularProgress.mm */; };
6741A9E71BF340DE002C974C /* MWMCircularProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 349A35791B53D4C9009677EE /* MWMCircularProgressView.m */; };
6741A9EC1BF340DE002C974C /* MWMCircularProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 349A35761B53D4C9009677EE /* MWMCircularProgress.m */; };
6741A9F51BF340DE002C974C /* BookmarksVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA36B80615403A4F004560CC /* BookmarksVC.mm */; };
6741A9FE1BF340DE002C974C /* SelectSetVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA054611155C465E001F4E37 /* SelectSetVC.mm */; };
6741AA031BF340DE002C974C /* MWMActivityViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340837121B7243CE00B5C185 /* MWMActivityViewController.mm */; };
@ -720,11 +720,11 @@
F6E2FD5C1E097BA00083EBEC /* MWMMapDownloaderCellHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC051E097B9F0083EBEC /* MWMMapDownloaderCellHeader.m */; };
F6E2FD5F1E097BA00083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC071E097B9F0083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.m */; };
F6E2FD621E097BA00083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FC081E097B9F0083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.xib */; };
F6E2FD651E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC0A1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm */; };
F6E2FD651E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC0A1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.m */; };
F6E2FD681E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FC0B1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.xib */; };
F6E2FD6B1E097BA00083EBEC /* MWMMapDownloaderSubplaceTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC0D1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.m */; };
F6E2FD6E1E097BA00083EBEC /* MWMMapDownloaderSubplaceTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FC0E1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.xib */; };
F6E2FD711E097BA00083EBEC /* MWMMapDownloaderTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC101E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.mm */; };
F6E2FD711E097BA00083EBEC /* MWMMapDownloaderTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC101E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.m */; };
F6E2FD741E097BA00083EBEC /* MWMMapDownloaderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FC111E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.xib */; };
F6E2FD8C1E097BA00083EBEC /* MWMNoMapsView.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC261E097B9F0083EBEC /* MWMNoMapsView.m */; };
F6E2FD8F1E097BA00083EBEC /* MWMNoMapsViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC281E097B9F0083EBEC /* MWMNoMapsViewController.mm */; };
@ -948,8 +948,6 @@
3404753E1E081A4600C92850 /* MWMSearchObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchObserver.h; sourceTree = "<group>"; };
340475401E081A4600C92850 /* MWMSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSettings.h; sourceTree = "<group>"; };
340475411E081A4600C92850 /* MWMSettings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSettings.mm; sourceTree = "<group>"; };
340475431E081A4600C92850 /* MWMStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStorage.h; sourceTree = "<group>"; };
340475441E081A4600C92850 /* MWMStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStorage.mm; sourceTree = "<group>"; };
340475791E081B3300C92850 /* iosOGLContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iosOGLContext.h; sourceTree = "<group>"; };
3404757A1E081B3300C92850 /* iosOGLContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = iosOGLContext.mm; sourceTree = "<group>"; };
3404757B1E081B3300C92850 /* iosOGLContextFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iosOGLContextFactory.h; sourceTree = "<group>"; };
@ -1066,7 +1064,6 @@
3467CEB1202C6EEE00D3C670 /* BMCNotificationsHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMCNotificationsHeader.swift; sourceTree = "<group>"; };
3467CEB4202C6FA900D3C670 /* BMCNotificationsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMCNotificationsCell.swift; sourceTree = "<group>"; };
3467CEB5202C6FA900D3C670 /* BMCNotificationsCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BMCNotificationsCell.xib; sourceTree = "<group>"; };
3467CEB8202C70A300D3C670 /* MWMCircularProgress+Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MWMCircularProgress+Swift.h"; sourceTree = "<group>"; };
346B42A91DD5E3D20094EBEE /* MWMLocationNotFoundAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMLocationNotFoundAlert.h; sourceTree = "<group>"; };
346B42AA1DD5E3D20094EBEE /* MWMLocationNotFoundAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMLocationNotFoundAlert.mm; sourceTree = "<group>"; };
346B42AD1DD5E5450094EBEE /* MWMDefaultAlert_Protected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMDefaultAlert_Protected.h; sourceTree = "<group>"; };
@ -1138,10 +1135,10 @@
349A13801DEC138C00C7DB60 /* MWMMobileInternetAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MWMMobileInternetAlert.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
349A13811DEC138C00C7DB60 /* MWMMobileInternetAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMMobileInternetAlert.xib; sourceTree = "<group>"; };
349A35751B53D4C9009677EE /* MWMCircularProgress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMCircularProgress.h; sourceTree = "<group>"; };
349A35761B53D4C9009677EE /* MWMCircularProgress.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMCircularProgress.mm; sourceTree = "<group>"; };
349A35761B53D4C9009677EE /* MWMCircularProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMCircularProgress.m; sourceTree = "<group>"; };
349A35771B53D4C9009677EE /* MWMCircularProgress.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMCircularProgress.xib; sourceTree = "<group>"; };
349A35781B53D4C9009677EE /* MWMCircularProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMCircularProgressView.h; sourceTree = "<group>"; };
349A35791B53D4C9009677EE /* MWMCircularProgressView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMCircularProgressView.mm; sourceTree = "<group>"; };
349A35791B53D4C9009677EE /* MWMCircularProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMCircularProgressView.m; sourceTree = "<group>"; };
349D1ABA1E2D05EF004A2006 /* SearchBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
349D1AC31E2E325B004A2006 /* MWMBottomMenuCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMBottomMenuCollectionViewCell.h; sourceTree = "<group>"; };
349D1AC41E2E325B004A2006 /* MWMBottomMenuCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMBottomMenuCollectionViewCell.m; sourceTree = "<group>"; };
@ -1545,6 +1542,8 @@
47E6688923196F0000057733 /* UIViewController+Subscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Subscription.swift"; sourceTree = "<group>"; };
47E6CB092178BA3600EA102B /* SearchBannerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBannerCell.swift; sourceTree = "<group>"; };
47E6CB0A2178BA3600EA102B /* SearchBannerCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SearchBannerCell.xib; sourceTree = "<group>"; };
47E8163123B17734008FD836 /* MWMStorage+UI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MWMStorage+UI.h"; sourceTree = "<group>"; };
47E8163223B17734008FD836 /* MWMStorage+UI.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MWMStorage+UI.m"; sourceTree = "<group>"; };
47EF05B221504D8F00EAC269 /* RemoveAdsPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveAdsPresentationController.swift; sourceTree = "<group>"; };
47F4F21223A6EC420022FD56 /* DownloadMapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadMapsViewController.swift; sourceTree = "<group>"; };
47F4F21423A6F06F0022FD56 /* AvailableMapsDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailableMapsDataSource.swift; sourceTree = "<group>"; };
@ -1906,13 +1905,13 @@
F6E2FC071E097B9F0083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMMapDownloaderLargeCountryTableViewCell.m; sourceTree = "<group>"; };
F6E2FC081E097B9F0083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMMapDownloaderLargeCountryTableViewCell.xib; sourceTree = "<group>"; };
F6E2FC091E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapDownloaderPlaceTableViewCell.h; sourceTree = "<group>"; };
F6E2FC0A1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapDownloaderPlaceTableViewCell.mm; sourceTree = "<group>"; };
F6E2FC0A1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMMapDownloaderPlaceTableViewCell.m; sourceTree = "<group>"; };
F6E2FC0B1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMMapDownloaderPlaceTableViewCell.xib; sourceTree = "<group>"; };
F6E2FC0C1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapDownloaderSubplaceTableViewCell.h; sourceTree = "<group>"; };
F6E2FC0D1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMMapDownloaderSubplaceTableViewCell.m; sourceTree = "<group>"; };
F6E2FC0E1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMMapDownloaderSubplaceTableViewCell.xib; sourceTree = "<group>"; };
F6E2FC0F1E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapDownloaderTableViewCell.h; sourceTree = "<group>"; };
F6E2FC101E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapDownloaderTableViewCell.mm; sourceTree = "<group>"; };
F6E2FC101E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMMapDownloaderTableViewCell.m; sourceTree = "<group>"; };
F6E2FC111E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMMapDownloaderTableViewCell.xib; sourceTree = "<group>"; };
F6E2FC211E097B9F0083EBEC /* MWMMapDownloaderMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapDownloaderMode.h; sourceTree = "<group>"; };
F6E2FC251E097B9F0083EBEC /* MWMNoMapsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNoMapsView.h; sourceTree = "<group>"; };
@ -2615,8 +2614,8 @@
340475421E081A4600C92850 /* Storage */ = {
isa = PBXGroup;
children = (
340475431E081A4600C92850 /* MWMStorage.h */,
340475441E081A4600C92850 /* MWMStorage.mm */,
47E8163123B17734008FD836 /* MWMStorage+UI.h */,
47E8163223B17734008FD836 /* MWMStorage+UI.m */,
);
path = Storage;
sourceTree = "<group>";
@ -3083,12 +3082,11 @@
isa = PBXGroup;
children = (
349A35751B53D4C9009677EE /* MWMCircularProgress.h */,
349A35761B53D4C9009677EE /* MWMCircularProgress.mm */,
349A35761B53D4C9009677EE /* MWMCircularProgress.m */,
349A35771B53D4C9009677EE /* MWMCircularProgress.xib */,
3467CEB8202C70A300D3C670 /* MWMCircularProgress+Swift.h */,
340708891F2B8CBF00029ECC /* MWMCircularProgressState.h */,
349A35781B53D4C9009677EE /* MWMCircularProgressView.h */,
349A35791B53D4C9009677EE /* MWMCircularProgressView.mm */,
349A35791B53D4C9009677EE /* MWMCircularProgressView.m */,
);
name = CircularProgress;
path = CustomViews/CircularProgress;
@ -4277,13 +4275,13 @@
F6E2FC071E097B9F0083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.m */,
F6E2FC081E097B9F0083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.xib */,
F6E2FC091E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.h */,
F6E2FC0A1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm */,
F6E2FC0A1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.m */,
F6E2FC0B1E097B9F0083EBEC /* MWMMapDownloaderPlaceTableViewCell.xib */,
F6E2FC0C1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.h */,
F6E2FC0D1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.m */,
F6E2FC0E1E097B9F0083EBEC /* MWMMapDownloaderSubplaceTableViewCell.xib */,
F6E2FC0F1E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.h */,
F6E2FC101E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.mm */,
F6E2FC101E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.m */,
F6E2FC111E097B9F0083EBEC /* MWMMapDownloaderTableViewCell.xib */,
);
path = Cells;
@ -5380,6 +5378,7 @@
340708651F2905A500029ECC /* NavigationInfoArea.swift in Sources */,
34AB666B1FC5AA330078E451 /* TransportTransitCell.swift in Sources */,
3404163C1E7BDFE000E2B6D6 /* PhotosViewController.swift in Sources */,
47E8163323B17734008FD836 /* MWMStorage+UI.m in Sources */,
34AB66471FC5AA330078E451 /* RouteManagerTableView.swift in Sources */,
47DF72B922520CE20004AB10 /* MWMRoutingOptions.mm in Sources */,
F6E2FE611E097BA00083EBEC /* MWMBookmarkCell.mm in Sources */,
@ -5403,7 +5402,7 @@
B32FE74320D2B09600EF7446 /* CatalogWebViewController.swift in Sources */,
F6E2FDB61E097BA00083EBEC /* MWMEditorAdditionalNamesHeader.m in Sources */,
F6E2FDC81E097BA00083EBEC /* MWMEditorNotesFooter.m in Sources */,
F6E2FD651E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm in Sources */,
F6E2FD651E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.m in Sources */,
F6E2FF2D1E097BA00083EBEC /* MWMSearchCell.mm in Sources */,
3454D7C51E07F045004AF2AD /* UIButton+Orientation.m in Sources */,
3454D7E61E07F045004AF2AD /* UIView+RuntimeAttributes.m in Sources */,
@ -5492,7 +5491,7 @@
34C9BD031C6DB693000DC38D /* MWMTableViewController.m in Sources */,
F6E2FD8C1E097BA00083EBEC /* MWMNoMapsView.m in Sources */,
34D3B0361E389D05004100F9 /* MWMEditorSelectTableViewCell.m in Sources */,
F6E2FD711E097BA00083EBEC /* MWMMapDownloaderTableViewCell.mm in Sources */,
F6E2FD711E097BA00083EBEC /* MWMMapDownloaderTableViewCell.m in Sources */,
F6E2FE4F1E097BA00083EBEC /* MWMActionBarButton.mm in Sources */,
47F86CFF20C936FC00FEE291 /* TabView.swift in Sources */,
34AB66741FC5AA330078E451 /* BaseRoutePreviewStatus.swift in Sources */,
@ -5531,7 +5530,7 @@
470F5A7D2189BB2F00754295 /* PaidRoutePurchase.swift in Sources */,
34AB66171FC5AA320078E451 /* MWMiPhoneRoutePreview.m in Sources */,
47E6688A23196F0100057733 /* UIViewController+Subscription.swift in Sources */,
6741A9E71BF340DE002C974C /* MWMCircularProgressView.mm in Sources */,
6741A9E71BF340DE002C974C /* MWMCircularProgressView.m in Sources */,
34AC8FDB1EFC07FE00E7F910 /* UILabel+NumberOfVisibleLines.swift in Sources */,
99B6A77F23684573002C94CB /* PromoDiscoveryBuilder.swift in Sources */,
4767CD9F20AAD48A00BD8166 /* Checkmark.swift in Sources */,
@ -5541,7 +5540,7 @@
349A13831DEC138C00C7DB60 /* MWMMobileInternetAlert.m in Sources */,
349D1ADE1E2E325C004A2006 /* MWMBottomMenuViewController.mm in Sources */,
BB87BF8A22FAF1CA008A8A72 /* TracksSection.mm in Sources */,
6741A9EC1BF340DE002C974C /* MWMCircularProgress.mm in Sources */,
6741A9EC1BF340DE002C974C /* MWMCircularProgress.m in Sources */,
99CB34C3236AEAEA001D28AD /* WhatsNewController.swift in Sources */,
470A89FD21342A9D00D72FBF /* TutorialBlurView.swift in Sources */,
342CC5F21C2D7730005F3FE5 /* MWMAuthorizationLoginViewController.mm in Sources */,
@ -5685,7 +5684,6 @@
4719A64E21A30C3B009F9AA7 /* PaidRouteStatistics.swift in Sources */,
34BBD6601F8270360070CA50 /* AuthorizationiPadPresentationController.swift in Sources */,
F6E2FED31E097BA00083EBEC /* MWMSearchHotelsFilterViewController.mm in Sources */,
340475741E081A4600C92850 /* MWMStorage.mm in Sources */,
347752901F7251C7000D46A3 /* UGCAddReviewTextCell.swift in Sources */,
34E50DF01F6FCC41008EED49 /* UGCYourReviewCell.swift in Sources */,
34AB66381FC5AA330078E451 /* RouteManagerCell.swift in Sources */,

View file

@ -2,7 +2,7 @@
#import "MWMCircularProgress.h"
#import "MWMFrameworkListener.h"
#import "MWMFrameworkStorageObserver.h"
#import "MWMStorage.h"
#import "MWMStorage+UI.h"
#import "Statistics.h"
#import "SwiftBridge.h"

View file

@ -1,4 +1,5 @@
#import "MWMMapDownloaderLargeCountryTableViewCell.h"
#import "MWMCircularProgress.h"
#import <CoreApi/MWMMapNodeAttributes.h>
@ -19,4 +20,12 @@
self.mapsCount.text = [NSString stringWithFormat:@"%@: %@", L(@"downloader_status_maps"), ofMaps];
}
- (void)configProgress:(MWMMapNodeAttributes *)nodeAttrs {
[super configProgress:nodeAttrs];
if (nodeAttrs.nodeStatus == MWMMapNodeStatusPartly || nodeAttrs.nodeStatus == MWMMapNodeStatusNotDownloaded) {
MWMCircularProgressStateVec affectedStates = @[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected)];
[self.progress setImageName:@"ic_folder" forStates:affectedStates];
}
}
@end

View file

@ -1,16 +1,7 @@
#import "MWMMapDownloaderPlaceTableViewCell.h"
#include <CoreApi/Framework.h>
#import <CoreApi/MWMMapNodeAttributes.h>
@interface MWMMapDownloaderTableViewCell ()
- (NSAttributedString *)matchedString:(NSString *)str
selectedAttrs:(NSDictionary *)selectedAttrs
unselectedAttrs:(NSDictionary *)unselectedAttrs;
@end
@interface MWMMapDownloaderPlaceTableViewCell ()
@property(weak, nonatomic) IBOutlet UILabel *descriptionLabel;
@ -29,8 +20,7 @@
NSDictionary *unselectedAreaAttrs = @{NSFontAttributeName : [UIFont regular12]};
self.needDisplayArea = !nodeAttrs.hasParent;
if (self.needDisplayArea && nodeAttrs.topmostParentInfo.count == 1) {
NSString *areaName = nodeAttrs.topmostParentInfo[0].countryId;
isDescriptionVisible = ![areaName isEqualToString:@(GetFramework().GetStorage().GetRootId().c_str())];
isDescriptionVisible = nodeAttrs.hasParent;
if (isDescriptionVisible) {
self.descriptionLabel.attributedText = [self matchedString:nodeAttrs.topmostParentInfo[0].countryName
selectedAttrs:selectedAreaAttrs

View file

@ -1,13 +1,5 @@
#import "MWMMapDownloaderSubplaceTableViewCell.h"
@interface MWMMapDownloaderTableViewCell ()
- (NSAttributedString *)matchedString:(NSString *)str
selectedAttrs:(NSDictionary *)selectedAttrs
unselectedAttrs:(NSDictionary *)unselectedAttrs;
@end
@interface MWMMapDownloaderSubplaceTableViewCell ()
@property(weak, nonatomic) IBOutlet UILabel *subPlace;

View file

@ -1,6 +1,7 @@
#import "MWMMapDownloaderMode.h"
#import "MWMTableViewCell.h"
@class MWMCircularProgress;
@class MWMMapNodeAttributes;
@class MWMMapDownloaderTableViewCell;
@ -15,13 +16,17 @@ NS_ASSUME_NONNULL_BEGIN
@interface MWMMapDownloaderTableViewCell : MWMTableViewCell
@property(nonatomic) MWMCircularProgress *progress;
@property(weak, nonatomic) id<MWMMapDownloaderTableViewCellDelegate> delegate;
@property(nonatomic) MWMMapDownloaderMode mode;
@property(readonly, nonatomic) MWMMapNodeAttributes *nodeAttrs;
- (void)config:(MWMMapNodeAttributes *)nodeAttrs searchQuery:(nullable NSString *)searchQuery;
- (void)configProgress:(MWMMapNodeAttributes *)nodeAttrs;
- (void)setDownloadProgress:(CGFloat)progress;
- (NSAttributedString *)matchedString:(NSString *)str
selectedAttrs:(NSDictionary *)selectedAttrs
unselectedAttrs:(NSDictionary *)unselectedAttrs;
@end
NS_ASSUME_NONNULL_END

View file

@ -1,16 +1,13 @@
#import "MWMMapDownloaderTableViewCell.h"
#import "MWMCircularProgress.h"
#import "MWMMapDownloaderLargeCountryTableViewCell.h"
#import "NSString+Categories.h"
#include <CoreApi/Framework.h>
#import <CoreApi/MWMCommon.h>
#import <CoreApi/MWMFrameworkHelper.h>
#import <CoreApi/MWMMapNodeAttributes.h>
@interface MWMMapDownloaderTableViewCell () <MWMCircularProgressProtocol>
@property(nonatomic) MWMCircularProgress *progress;
@property(copy, nonatomic) NSString *searchQuery;
@property(weak, nonatomic) IBOutlet UIView *stateWrapper;
@ -48,10 +45,10 @@
selectedAttrs:(NSDictionary *)selectedAttrs
unselectedAttrs:(NSDictionary *)unselectedAttrs {
NSMutableAttributedString *attrTitle = [[NSMutableAttributedString alloc] initWithString:str];
[attrTitle addAttributes:unselectedAttrs range:{0, str.length}];
[attrTitle addAttributes:unselectedAttrs range:NSMakeRange(0, str.length)];
if (!self.searchQuery)
return [attrTitle copy];
for (NSValue *range : [str rangesOfString:self.searchQuery])
for (NSValue *range in [str rangesOfString:self.searchQuery])
[attrTitle addAttributes:selectedAttrs range:range.rangeValue];
return [attrTitle copy];
}
@ -99,11 +96,8 @@
switch (nodeAttrs.nodeStatus) {
case MWMMapNodeStatusNotDownloaded:
case MWMMapNodeStatusPartly: {
MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
NSString *imageName =
[self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]] ? @"ic_folder" : @"ic_download";
[progress setImageName:imageName forStates:affectedStates];
MWMCircularProgressStateVec affectedStates = @[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected)];
[progress setImageName:@"ic_download" forStates:affectedStates];
[progress setColoring:coloring forStates:affectedStates];
progress.state = MWMCircularProgressStateNormal;
break;
@ -123,7 +117,7 @@
progress.state = MWMCircularProgressStateCompleted;
break;
case MWMMapNodeStatusOnDiskOutOfDate: {
MWMCircularProgressStateVec affectedStates = {MWMCircularProgressStateNormal, MWMCircularProgressStateSelected};
MWMCircularProgressStateVec affectedStates = @[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected)];
[progress setImageName:@"ic_update" forStates:affectedStates];
[progress setColoring:MWMButtonColoringOther forStates:affectedStates];
progress.state = MWMCircularProgressStateNormal;

View file

@ -11,6 +11,12 @@ class DownloadMapsViewController: MWMViewController {
case delete
}
private enum AllMapsButtonState {
case none
case download(String)
case cancel(String)
}
// MARK: - Outlets
@IBOutlet var tableView: UITableView!
@ -47,7 +53,7 @@ class DownloadMapsViewController: MWMViewController {
case .downloaded:
dataSource = DownloadedMapsDataSource()
case .available:
dataSource = AvailableMapsDataSource()
dataSource = AvailableMapsDataSource(location: MWMLocationManager.lastLocation()?.coordinate)
@unknown default:
fatalError()
}
@ -118,7 +124,7 @@ class DownloadMapsViewController: MWMViewController {
action = UIAlertAction(title: "\(prefix) (\(formattedSize(nodeAttrs.totalSize)))",
style: .default,
handler: { _ in
Storage.downloadNode(nodeAttrs.countryId, onSuccess: nil)
Storage.downloadNode(nodeAttrs.countryId)
})
case .update:
let title = "\(L("downloader_status_outdated")) (TODO: updated size)"
@ -142,45 +148,44 @@ class DownloadMapsViewController: MWMViewController {
}
}
private func setAllMapsButton(_ state: AllMapsButtonState) {
switch state {
case .none:
allMapsView.isHidden = true
case .download(let buttonTitle):
allMapsView.isHidden = false
allMapsButton.isHidden = false
allMapsButton.setTitle(buttonTitle, for: .normal)
allMapsCancelButton.isHidden = true
case .cancel(let buttonTitle):
allMapsView.isHidden = false
allMapsButton.isHidden = true
allMapsCancelButton.isHidden = false
allMapsCancelButton.setTitle(buttonTitle, for: .normal)
}
}
fileprivate func configButtons() {
allMapsView.isHidden = true
if mode == .available {
if dataSource.isRoot {
allMapsView.isHidden = true
setAllMapsButton(.none)
} else {
let parentAttributes = dataSource.parentAttributes()
if parentAttributes.downloadingMwmCount > 0 {
allMapsView.isHidden = false
allMapsButton.isHidden = true
allMapsCancelButton.isHidden = false
allMapsCancelButton.setTitle(
"\(L("downloader_cancel_all")) (\(formattedSize(parentAttributes.downloadingSize)))",
for: .normal)
setAllMapsButton(.cancel("\(L("downloader_cancel_all")) (\(formattedSize(parentAttributes.downloadingSize)))"))
} else if parentAttributes.downloadedMwmCount < parentAttributes.totalMwmCount {
allMapsView.isHidden = false
allMapsButton.isHidden = false
allMapsButton.setTitle(
"\(L("downloader_download_all_button")) (\(formattedSize(parentAttributes.totalSize - parentAttributes.downloadedSize)))",
for: .normal)
allMapsCancelButton.isHidden = true
setAllMapsButton(.download("\(L("downloader_download_all_button")) (\(formattedSize(parentAttributes.totalSize - parentAttributes.downloadedSize)))"))
}
}
} else {
let updateInfo = Storage.updateInfo(withParent: dataSource.parentAttributes().countryId)
if updateInfo.numberOfFiles > 0 {
allMapsView.isHidden = false
allMapsButton.isHidden = false
allMapsButton.setTitle(
"\(L("downloader_update_all_button")) (\(formattedSize(updateInfo.updateSize)))",
for: .normal)
allMapsCancelButton.isHidden = true
setAllMapsButton(.download("\(L("downloader_update_all_button")) (\(formattedSize(updateInfo.updateSize)))"))
} else {
let parentAttributes = dataSource.parentAttributes()
if parentAttributes.downloadingMwmCount > 0 {
allMapsView.isHidden = false
allMapsButton.isHidden = true
allMapsCancelButton.isHidden = false
allMapsCancelButton.setTitle(L("downloader_cancel_all"), for: .normal)
setAllMapsButton(.cancel(L("downloader_cancel_all")))
}
}
}
@ -195,9 +200,9 @@ class DownloadMapsViewController: MWMViewController {
@IBAction func onAllMaps(_ sender: UIButton) {
skipCountryEvent = true
if mode == .downloaded {
Storage.updateNode(dataSource.parentAttributes().countryId, onCancel: nil)
Storage.updateNode(dataSource.parentAttributes().countryId)
} else {
Storage.downloadNode(dataSource.parentAttributes().countryId, onSuccess: nil, onCancel: nil)
Storage.downloadNode(dataSource.parentAttributes().countryId)
}
skipCountryEvent = false
self.processCountryEvent(dataSource.parentAttributes().countryId)
@ -339,7 +344,7 @@ extension DownloadMapsViewController: MWMMapDownloaderTableViewCellDelegate {
if nodeAttrs.hasChildren {
showChildren(nodeAttrs)
} else {
Storage.downloadNode(nodeAttrs.countryId, onSuccess: nil)
Storage.downloadNode(nodeAttrs.countryId)
}
break
@unknown default:

View file

@ -9,7 +9,7 @@
#import "MWMPlacePageLayout.h"
#import "MWMRoutePoint+CPP.h"
#import "MWMSearchManager+Filter.h"
#import "MWMStorage.h"
#import "MWMStorage+UI.h"
#import "SwiftBridge.h"
#import "MWMMapViewControlsManager+AddPlace.h"
@ -168,10 +168,10 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page:
switch (nodeAttrs.m_status)
{
case NodeStatus::NotDownloaded:
case NodeStatus::Partly: [MWMStorage downloadNode:@(countryId.c_str()) onSuccess:nil onCancel:nil]; break;
case NodeStatus::Partly: [MWMStorage downloadNode:@(countryId.c_str())]; break;
case NodeStatus::Undefined:
case NodeStatus::Error: [MWMStorage retryDownloadNode:@(countryId.c_str())]; break;
case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:@(countryId.c_str()) onCancel:nil]; break;
case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:@(countryId.c_str())]; break;
case NodeStatus::Downloading:
case NodeStatus::Applying:
case NodeStatus::InQueue: [MWMStorage cancelDownloadNode:@(countryId.c_str())]; break;

View file

@ -89,8 +89,8 @@ UIColor * backgroundColorForPartner(int partnerIndex)
self.mapDownloadProgress = [MWMCircularProgress downloaderProgressForParentView:self.button];
self.mapDownloadProgress.delegate = self;
MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
MWMCircularProgressStateVec affectedStates = @[@(MWMCircularProgressStateNormal),
@(MWMCircularProgressStateSelected)];
[self.mapDownloadProgress setImageName:@"ic_download" forStates:affectedStates];
[self.mapDownloadProgress setColoring:MWMButtonColoringBlue forStates:affectedStates];