forked from organicmaps/organicmaps
[ios] clang-format.
This commit is contained in:
parent
f5a722ae6a
commit
c507ac03dc
33 changed files with 1695 additions and 1962 deletions
|
@ -1,15 +1,15 @@
|
|||
#import "Common.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "Common.h"
|
||||
#import "MWMController.h"
|
||||
#import "MWMDownloadTransitMapAlert.h"
|
||||
#import "MWMLocationAlert.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
|
||||
static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController";
|
||||
|
||||
@interface MWMAlertViewController () <UIGestureRecognizerDelegate>
|
||||
@interface MWMAlertViewController ()<UIGestureRecognizerDelegate>
|
||||
|
||||
@property (weak, nonatomic, readwrite) UIViewController * ownerViewController;
|
||||
@property(weak, nonatomic, readwrite) UIViewController * ownerViewController;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -20,10 +20,12 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
UIWindow * window = UIApplication.sharedApplication.delegate.window;
|
||||
UIViewController * rootViewController = window.rootViewController;
|
||||
ASSERT([rootViewController isKindOfClass:[UINavigationController class]], ());
|
||||
UINavigationController * navigationController = static_cast<UINavigationController *>(rootViewController);
|
||||
UINavigationController * navigationController =
|
||||
static_cast<UINavigationController *>(rootViewController);
|
||||
UIViewController * topViewController = navigationController.topViewController;
|
||||
ASSERT([topViewController conformsToProtocol:@protocol(MWMController)], ());
|
||||
UIViewController<MWMController> * mwmController = static_cast<UIViewController<MWMController> *>(topViewController);
|
||||
UIViewController<MWMController> * mwmController =
|
||||
static_cast<UIViewController<MWMController> *>(topViewController);
|
||||
return mwmController.alertController;
|
||||
}
|
||||
|
||||
|
@ -35,7 +37,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
|
||||
duration:(NSTimeInterval)duration
|
||||
{
|
||||
for (MWMAlert * alert in self.view.subviews)
|
||||
[alert rotate:toInterfaceOrientation duration:duration];
|
||||
|
@ -43,26 +46,15 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)presentRateAlert
|
||||
{
|
||||
[self displayAlert:MWMAlert.rateAlert];
|
||||
}
|
||||
|
||||
- (void)presentLocationAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert locationAlert]];
|
||||
}
|
||||
|
||||
- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild
|
||||
- (void)presentRateAlert { [self displayAlert:MWMAlert.rateAlert]; }
|
||||
- (void)presentLocationAlert { [self displayAlert:[MWMAlert locationAlert]]; }
|
||||
- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
|
||||
needToRebuild:(BOOL)needToRebuild
|
||||
{
|
||||
[self displayAlert:[MWMAlert point2PointAlertWithOkBlock:okBlock needToRebuild:needToRebuild]];
|
||||
}
|
||||
|
||||
- (void)presentFacebookAlert
|
||||
{
|
||||
[self displayAlert:MWMAlert.facebookAlert];
|
||||
}
|
||||
|
||||
- (void)presentFacebookAlert { [self displayAlert:MWMAlert.facebookAlert]; }
|
||||
- (void)presentLocationServiceNotSupportedAlert
|
||||
{
|
||||
[self displayAlert:MWMAlert.locationServiceNotSupportedAlert];
|
||||
|
@ -73,21 +65,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert locationNotFoundAlertWithOkBlock:okBlock]];
|
||||
}
|
||||
|
||||
- (void)presentNoConnectionAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert noConnectionAlert]];
|
||||
}
|
||||
|
||||
- (void)presentMigrationProhibitedAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert migrationProhibitedAlert]];
|
||||
}
|
||||
|
||||
- (void)presentDeleteMapProhibitedAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert deleteMapProhibitedAlert]];
|
||||
}
|
||||
|
||||
- (void)presentNoConnectionAlert { [self displayAlert:[MWMAlert noConnectionAlert]]; }
|
||||
- (void)presentMigrationProhibitedAlert { [self displayAlert:[MWMAlert migrationProhibitedAlert]]; }
|
||||
- (void)presentDeleteMapProhibitedAlert { [self displayAlert:[MWMAlert deleteMapProhibitedAlert]]; }
|
||||
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
|
||||
{
|
||||
[self displayAlert:[MWMAlert unsavedEditsAlertWithOkBlock:okBlock]];
|
||||
|
@ -108,16 +88,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert incorrectFeauturePositionAlert]];
|
||||
}
|
||||
|
||||
- (void)presentInternalErrorAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert internalErrorAlert]];
|
||||
}
|
||||
|
||||
- (void)presentNotEnoughSpaceAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert notEnoughSpaceAlert]];
|
||||
}
|
||||
|
||||
- (void)presentInternalErrorAlert { [self displayAlert:[MWMAlert internalErrorAlert]]; }
|
||||
- (void)presentNotEnoughSpaceAlert { [self displayAlert:[MWMAlert notEnoughSpaceAlert]]; }
|
||||
- (void)presentInvalidUserNameOrPasswordAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert invalidUserNameOrPasswordAlert]];
|
||||
|
@ -143,7 +115,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
|
||||
- (void)presentRoutingDisclaimerAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert routingDisclaimerAlertWithInitialOrientation:self.ownerViewController.interfaceOrientation]];
|
||||
[self displayAlert:[MWMAlert
|
||||
routingDisclaimerAlertWithInitialOrientation:self.ownerViewController
|
||||
.interfaceOrientation]];
|
||||
}
|
||||
|
||||
- (void)presentBicycleRoutingDisclaimerAlert
|
||||
|
@ -151,11 +125,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert routingBicycleDisclaimerAlert]];
|
||||
}
|
||||
|
||||
- (void)presentDisabledLocationAlert
|
||||
{
|
||||
[self displayAlert:MWMAlert.disabledLocationAlert];
|
||||
}
|
||||
|
||||
- (void)presentDisabledLocationAlert { [self displayAlert:MWMAlert.disabledLocationAlert]; }
|
||||
- (void)presentAlert:(routing::IRouter::ResultCode)type
|
||||
{
|
||||
[self displayAlert:[MWMAlert alert:type]];
|
||||
|
@ -166,9 +136,11 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert disableAutoDownloadAlertWithOkBlock:okBlock]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock cancelBlock:(nonnull TMWMVoidBlock)cancelBlock
|
||||
- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull TMWMVoidBlock)cancelBlock
|
||||
{
|
||||
[self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
|
||||
[self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock
|
||||
cancelBlock:cancelBlock]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderNotEnoughSpaceAlert
|
||||
|
@ -176,9 +148,11 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert downloaderNotEnoughSpaceAlert]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock cancelBlock:(nonnull TMWMVoidBlock)cancelBlock
|
||||
- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull TMWMVoidBlock)cancelBlock
|
||||
{
|
||||
[self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
|
||||
[self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock
|
||||
cancelBlock:cancelBlock]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
|
||||
|
@ -201,20 +175,12 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert deleteFeatureAlertWithBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentEditorViralAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert editorViralAlert]];
|
||||
}
|
||||
|
||||
- (void)presentOsmAuthAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert osmAuthAlert]];
|
||||
}
|
||||
|
||||
- (void)presentEditorViralAlert { [self displayAlert:[MWMAlert editorViralAlert]]; }
|
||||
- (void)presentOsmAuthAlert { [self displayAlert:[MWMAlert osmAuthAlert]]; }
|
||||
- (void)displayAlert:(MWMAlert *)alert
|
||||
{
|
||||
//TODO(igrechuhin): Remove this check on location manager refactoring.
|
||||
//Workaround for current location manager duplicate error alerts.
|
||||
// TODO(igrechuhin): Remove this check on location manager refactoring.
|
||||
// Workaround for current location manager duplicate error alerts.
|
||||
if ([alert isKindOfClass:[MWMLocationAlert class]])
|
||||
{
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
|
@ -223,19 +189,18 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
return;
|
||||
}
|
||||
}
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
view.alpha = 0.0;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
{
|
||||
if (view != alert)
|
||||
view.hidden = YES;
|
||||
}
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
view.alpha = 0.0;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
{
|
||||
if (view != alert)
|
||||
view.hidden = YES;
|
||||
}
|
||||
}];
|
||||
|
||||
[self removeFromParentViewController];
|
||||
alert.alertController = self;
|
||||
|
@ -247,13 +212,13 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
CGFloat const scale = 1.1;
|
||||
alert.transform = CGAffineTransformMakeScale(scale, scale);
|
||||
}
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.view.alpha = 1.;
|
||||
alert.alpha = 1.;
|
||||
if (!isIOS7)
|
||||
alert.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.view.alpha = 1.;
|
||||
alert.alpha = 1.;
|
||||
if (!isIOS7)
|
||||
alert.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
[MapsAppDelegate.theApp.window endEditing:YES];
|
||||
}
|
||||
|
||||
|
@ -264,23 +229,22 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
MWMAlert * showAlert = (subviews.count >= 2 ? subviews[subviews.count - 2] : nil);
|
||||
if (showAlert)
|
||||
showAlert.hidden = NO;
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
closeAlert.alpha = 0.;
|
||||
if (showAlert)
|
||||
showAlert.alpha = 1.;
|
||||
else
|
||||
self.view.alpha = 0.;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
[closeAlert removeFromSuperview];
|
||||
if (!showAlert)
|
||||
{
|
||||
[self.view removeFromSuperview];
|
||||
[self removeFromParentViewController];
|
||||
}
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
closeAlert.alpha = 0.;
|
||||
if (showAlert)
|
||||
showAlert.alpha = 1.;
|
||||
else
|
||||
self.view.alpha = 0.;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[closeAlert removeFromSuperview];
|
||||
if (!showAlert)
|
||||
{
|
||||
[self.view removeFromSuperview];
|
||||
[self removeFromParentViewController];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
typedef NS_ENUM(NSUInteger, MWMBottomMenuState)
|
||||
{
|
||||
typedef NS_ENUM(NSUInteger, MWMBottomMenuState) {
|
||||
MWMBottomMenuStateHidden,
|
||||
MWMBottomMenuStateInactive,
|
||||
MWMBottomMenuStateActive,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import "MWMBottomMenuView.h"
|
||||
#import "Common.h"
|
||||
#import "EAGLView.h"
|
||||
#import "MWMBottomMenuView.h"
|
||||
#import "MWMBottomMenuViewController.h"
|
||||
#import "MWMButton.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
|
@ -37,54 +37,55 @@ CGFloat constexpr kThresholdCompact = 321;
|
|||
CGFloat constexpr kThresholdRegular = 415;
|
||||
CGFloat constexpr kTimeWidthCompact = 112;
|
||||
CGFloat constexpr kTimeWidthRegular = 128;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@interface MWMBottomMenuView ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * mainButtons;
|
||||
@property (weak, nonatomic) IBOutlet UIView * separator;
|
||||
@property (weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
|
||||
@property(weak, nonatomic) IBOutlet UIView * mainButtons;
|
||||
@property(weak, nonatomic) IBOutlet UIView * separator;
|
||||
@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * mainButtonsHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * additionalButtonsHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * separatorHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * mainButtonsHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * additionalButtonsHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * separatorHeight;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * downloadBadge;
|
||||
@property(weak, nonatomic) IBOutlet UIView * downloadBadge;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet MWMButton * p2pButton;
|
||||
@property (weak, nonatomic) IBOutlet MWMButton * searchButton;
|
||||
@property (weak, nonatomic) IBOutlet MWMButton * bookmarksButton;
|
||||
@property (weak, nonatomic) IBOutlet MWMButton * menuButton;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * menuButtonWidth;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton * p2pButton;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton * searchButton;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton * bookmarksButton;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton * menuButton;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * menuButtonWidth;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * routingView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * goButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * toggleInfoButton;
|
||||
@property (weak, nonatomic) IBOutlet UIView * speedView;
|
||||
@property (weak, nonatomic) IBOutlet UIView * timeView;
|
||||
@property (weak, nonatomic) IBOutlet UIView * distanceView;
|
||||
@property (weak, nonatomic) IBOutlet UIView * progressView;
|
||||
@property (weak, nonatomic) IBOutlet UIView * routingAdditionalView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * routingAdditionalViewHeight;
|
||||
@property (nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray * routingAdditionalButtonsOffset;
|
||||
@property (nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray * speedDistanceOffset;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * speedLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * timeLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * speedLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * speedWithLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceWithLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UIView * routingView;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * goButton;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * toggleInfoButton;
|
||||
@property(weak, nonatomic) IBOutlet UIView * speedView;
|
||||
@property(weak, nonatomic) IBOutlet UIView * timeView;
|
||||
@property(weak, nonatomic) IBOutlet UIView * distanceView;
|
||||
@property(weak, nonatomic) IBOutlet UIView * progressView;
|
||||
@property(weak, nonatomic) IBOutlet UIView * routingAdditionalView;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * routingAdditionalViewHeight;
|
||||
@property(nonatomic) IBOutletCollection(NSLayoutConstraint)
|
||||
NSArray * routingAdditionalButtonsOffset;
|
||||
@property(nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray * speedDistanceOffset;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * speedLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * timeLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * distanceLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * speedLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * distanceLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * speedWithLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * distanceWithLegendLabel;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIPageControl * pageControl;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * pageControlTopOffset;
|
||||
@property(weak, nonatomic) IBOutlet UIPageControl * pageControl;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * pageControlTopOffset;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * speedDistanceWidth;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * timeWidth;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * speedDistanceWidth;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * timeWidth;
|
||||
|
||||
@property (nonatomic) CGFloat layoutDuration;
|
||||
@property(nonatomic) CGFloat layoutDuration;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet MWMBottomMenuViewController * owner;
|
||||
@property(weak, nonatomic) IBOutlet MWMBottomMenuViewController * owner;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -105,7 +106,8 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
self.routingAdditionalView.hidden = YES;
|
||||
self.restoreState = MWMBottomMenuStateInactive;
|
||||
[self.goButton setBackgroundColor:[UIColor linkBlue] forState:UIControlStateNormal];
|
||||
[self.goButton setBackgroundColor:[UIColor linkBlueHighlighted] forState:UIControlStateHighlighted];
|
||||
[self.goButton setBackgroundColor:[UIColor linkBlueHighlighted]
|
||||
forState:UIControlStateHighlighted];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
|
@ -116,18 +118,23 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
CGFloat const duration = self.layoutDuration;
|
||||
self.layoutDuration = 0.0;
|
||||
[self layoutIfNeeded];
|
||||
[UIView animateWithDuration:duration animations:^
|
||||
{
|
||||
[self layoutGeometry];
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
[UIView animateWithDuration:duration
|
||||
animations:^{
|
||||
[self layoutGeometry];
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self layoutGeometry];
|
||||
}
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^{ [self updateAlphaAndColor]; }
|
||||
completion:^(BOOL finished) { [self updateVisibility]; }];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
[self updateAlphaAndColor];
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[self updateVisibility];
|
||||
}];
|
||||
((EAGLView *)self.superview).widgetsManager.bottomBound = self.mainButtonsHeight.constant;
|
||||
[self updateFonts];
|
||||
[super layoutSubviews];
|
||||
|
@ -137,8 +144,7 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
{
|
||||
switch (self.state)
|
||||
{
|
||||
case MWMBottomMenuStateHidden:
|
||||
break;
|
||||
case MWMBottomMenuStateHidden: break;
|
||||
case MWMBottomMenuStateInactive:
|
||||
self.backgroundColor = [UIColor menuBackground];
|
||||
self.bookmarksButton.alpha = 1.0;
|
||||
|
@ -206,7 +212,8 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
{
|
||||
if (self.state != MWMBottomMenuStateRouting && self.state != MWMBottomMenuStateRoutingExpanded)
|
||||
return;
|
||||
UIFont * numberFont = (IPAD || self.width > kThresholdRegular) ? [UIFont bold24] : [UIFont bold22];
|
||||
UIFont * numberFont =
|
||||
(IPAD || self.width > kThresholdRegular) ? [UIFont bold24] : [UIFont bold22];
|
||||
UIFont * legendFont = [UIFont bold12];
|
||||
self.speedLabel.font = numberFont;
|
||||
self.timeLabel.font = numberFont;
|
||||
|
@ -219,8 +226,7 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
{
|
||||
switch (self.state)
|
||||
{
|
||||
case MWMBottomMenuStateHidden:
|
||||
break;
|
||||
case MWMBottomMenuStateHidden: break;
|
||||
case MWMBottomMenuStateInactive:
|
||||
self.additionalButtons.hidden = YES;
|
||||
self.routingView.hidden = YES;
|
||||
|
@ -273,8 +279,7 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
case MWMBottomMenuStateInactive:
|
||||
case MWMBottomMenuStateCompact:
|
||||
case MWMBottomMenuStatePlanning:
|
||||
case MWMBottomMenuStateGo:
|
||||
break;
|
||||
case MWMBottomMenuStateGo: break;
|
||||
case MWMBottomMenuStateActive:
|
||||
{
|
||||
self.separatorHeight.constant = 1.0;
|
||||
|
@ -291,29 +296,27 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
}
|
||||
}
|
||||
break;
|
||||
case MWMBottomMenuStateRouting:
|
||||
[self layoutRoutingGeometry];
|
||||
break;
|
||||
case MWMBottomMenuStateRouting: [self layoutRoutingGeometry]; break;
|
||||
case MWMBottomMenuStateRoutingExpanded:
|
||||
self.routingAdditionalViewHeight.constant = kAdditionalHeight;
|
||||
[self layoutRoutingGeometry];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
CGFloat const width = MIN(self.superview.width - self.leftBound, self.superview.width);
|
||||
CGFloat const additionalHeight = MAX(self.additionalButtonsHeight.constant, self.routingAdditionalViewHeight.constant);
|
||||
CGFloat const height = self.mainButtonsHeight.constant + self.separatorHeight.constant + additionalHeight;
|
||||
CGFloat const additionalHeight =
|
||||
MAX(self.additionalButtonsHeight.constant, self.routingAdditionalViewHeight.constant);
|
||||
CGFloat const height =
|
||||
self.mainButtonsHeight.constant + self.separatorHeight.constant + additionalHeight;
|
||||
self.frame = {{self.superview.width - width, self.superview.height - height}, {width, height}};
|
||||
}
|
||||
|
||||
- (void)layoutRoutingGeometry
|
||||
{
|
||||
auto layoutAdditionalButtonsOffset = ^(CGFloat offset)
|
||||
{
|
||||
auto layoutAdditionalButtonsOffset = ^(CGFloat offset) {
|
||||
for (NSLayoutConstraint * constraint in self.routingAdditionalButtonsOffset)
|
||||
constraint.constant = offset;
|
||||
};
|
||||
auto layoutSpeedDistanceOffset = ^(CGFloat offset)
|
||||
{
|
||||
auto layoutSpeedDistanceOffset = ^(CGFloat offset) {
|
||||
for (NSLayoutConstraint * constraint in self.speedDistanceOffset)
|
||||
constraint.constant = offset;
|
||||
};
|
||||
|
@ -353,7 +356,8 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
else
|
||||
{
|
||||
self.pageControlTopOffset.constant = kPageControlTopOffsetLandscape;
|
||||
self.pageControl.transform = CGAffineTransformMakeScale(kPageControlScaleLandscape, kPageControlScaleLandscape);
|
||||
self.pageControl.transform =
|
||||
CGAffineTransformMakeScale(kPageControlScaleLandscape, kPageControlScaleLandscape);
|
||||
self.speedDistanceWidth.constant = kSpeedDistanceWidthLandscape;
|
||||
self.mainButtonsHeight.constant = kRoutingMainButtonsHeightLandscape;
|
||||
self.menuButtonWidth.constant = kRoutingMenuButtonWidthRegular;
|
||||
|
@ -387,8 +391,9 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
NSInteger const stepValue = direct ? 1 : -1;
|
||||
NSMutableArray * morphImages = [NSMutableArray arrayWithCapacity:morphImagesCount];
|
||||
for (NSUInteger i = startValue, j = 0; i != endValue; i += stepValue, j++)
|
||||
morphImages[j] = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@_%@", morphTemplate, @(i).stringValue,
|
||||
[UIColor isNightMode] ? @"dark" : @"light"]];
|
||||
morphImages[j] =
|
||||
[UIImage imageNamed:[NSString stringWithFormat:@"%@%@_%@", morphTemplate, @(i).stringValue,
|
||||
[UIColor isNightMode] ? @"dark" : @"light"]];
|
||||
btn.imageView.animationImages = morphImages;
|
||||
btn.imageView.animationRepeatCount = 1;
|
||||
btn.imageView.image = morphImages.lastObject;
|
||||
|
@ -397,8 +402,7 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
|
||||
- (void)refreshMenuButtonState
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.menuButton.imageView.isAnimating)
|
||||
{
|
||||
[self refreshMenuButtonState];
|
||||
|
@ -412,17 +416,11 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
case MWMBottomMenuStateHidden:
|
||||
case MWMBottomMenuStateInactive:
|
||||
case MWMBottomMenuStatePlanning:
|
||||
case MWMBottomMenuStateGo:
|
||||
name = @"ic_menu";
|
||||
break;
|
||||
case MWMBottomMenuStateGo: name = @"ic_menu"; break;
|
||||
case MWMBottomMenuStateActive:
|
||||
case MWMBottomMenuStateRouting:
|
||||
case MWMBottomMenuStateRoutingExpanded:
|
||||
name = @"ic_menu_down";
|
||||
break;
|
||||
case MWMBottomMenuStateCompact:
|
||||
name = @"ic_menu_left";
|
||||
break;
|
||||
case MWMBottomMenuStateRoutingExpanded: name = @"ic_menu_down"; break;
|
||||
case MWMBottomMenuStateCompact: name = @"ic_menu_left"; break;
|
||||
}
|
||||
UIImage * image = [UIImage imageNamed:name];
|
||||
if (isIOS7)
|
||||
|
@ -435,10 +433,11 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
else
|
||||
{
|
||||
BOOL const rotate = (self.state == MWMBottomMenuStateRouting);
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
btn.transform = rotate ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformIdentity;
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
btn.transform = rotate ? CGAffineTransformMakeRotation(M_PI)
|
||||
: CGAffineTransformIdentity;
|
||||
}];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -483,7 +482,8 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
auto & s = GetFramework().Storage();
|
||||
storage::Storage::UpdateInfo updateInfo{};
|
||||
s.GetUpdateInfo(s.GetRootId(), updateInfo);
|
||||
self.downloadBadge.hidden = (updateInfo.m_numberOfMwmFilesToUpdate == 0) && !platform::migrate::NeedMigrate();
|
||||
self.downloadBadge.hidden =
|
||||
(updateInfo.m_numberOfMwmFilesToUpdate == 0) && !platform::migrate::NeedMigrate();
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
@ -502,71 +502,70 @@ CGFloat constexpr kTimeWidthRegular = 128;
|
|||
BOOL updateMenuButton = YES;
|
||||
switch (state)
|
||||
{
|
||||
case MWMBottomMenuStateHidden:
|
||||
updateMenuButton = NO;
|
||||
break;
|
||||
case MWMBottomMenuStateInactive:
|
||||
{
|
||||
if (MapsAppDelegate.theApp.routingPlaneMode == MWMRoutingPlaneModeNone)
|
||||
_leftBound = 0.0;
|
||||
[self updateBadge];
|
||||
self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = NO;
|
||||
self.layoutDuration = (_state == MWMBottomMenuStateCompact && !IPAD) ? 0.0 : kDefaultAnimationDuration;
|
||||
break;
|
||||
}
|
||||
case MWMBottomMenuStateActive:
|
||||
self.restoreState = _state;
|
||||
[self updateMenuButtonFromState:_state toState:state];
|
||||
self.additionalButtons.hidden = NO;
|
||||
self.bookmarksButton.hidden = NO;
|
||||
self.p2pButton.hidden = NO;
|
||||
self.searchButton.hidden = NO;
|
||||
break;
|
||||
case MWMBottomMenuStateCompact:
|
||||
self.layoutDuration = IPAD ? kDefaultAnimationDuration : 0.0;
|
||||
break;
|
||||
case MWMBottomMenuStatePlanning:
|
||||
self.goButton.enabled = NO;
|
||||
self.goButton.hidden = NO;
|
||||
self.toggleInfoButton.hidden = YES;
|
||||
self.speedView.hidden = YES;
|
||||
self.timeView.hidden = YES;
|
||||
self.distanceView.hidden = YES;
|
||||
self.progressView.hidden = YES;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = YES;
|
||||
break;
|
||||
case MWMBottomMenuStateGo:
|
||||
self.goButton.enabled = YES;
|
||||
self.goButton.hidden = NO;
|
||||
self.toggleInfoButton.hidden = YES;
|
||||
self.speedView.hidden = YES;
|
||||
self.timeView.hidden = YES;
|
||||
self.distanceView.hidden = YES;
|
||||
self.progressView.hidden = YES;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = YES;
|
||||
break;
|
||||
case MWMBottomMenuStateRouting:
|
||||
self.goButton.hidden = YES;
|
||||
self.toggleInfoButton.hidden = NO;
|
||||
self.speedView.hidden = NO;
|
||||
self.timeView.hidden = NO;
|
||||
self.distanceView.hidden = NO;
|
||||
self.progressView.hidden = NO;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = YES;
|
||||
break;
|
||||
case MWMBottomMenuStateRoutingExpanded:
|
||||
self.goButton.hidden = YES;
|
||||
self.toggleInfoButton.hidden = NO;
|
||||
self.speedView.hidden = NO;
|
||||
self.timeView.hidden = NO;
|
||||
self.distanceView.hidden = NO;
|
||||
self.progressView.hidden = NO;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = NO;
|
||||
break;
|
||||
case MWMBottomMenuStateHidden: updateMenuButton = NO; break;
|
||||
case MWMBottomMenuStateInactive:
|
||||
{
|
||||
if (MapsAppDelegate.theApp.routingPlaneMode == MWMRoutingPlaneModeNone)
|
||||
_leftBound = 0.0;
|
||||
[self updateBadge];
|
||||
self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = NO;
|
||||
self.layoutDuration =
|
||||
(_state == MWMBottomMenuStateCompact && !IPAD) ? 0.0 : kDefaultAnimationDuration;
|
||||
break;
|
||||
}
|
||||
case MWMBottomMenuStateActive:
|
||||
self.restoreState = _state;
|
||||
[self updateMenuButtonFromState:_state toState:state];
|
||||
self.additionalButtons.hidden = NO;
|
||||
self.bookmarksButton.hidden = NO;
|
||||
self.p2pButton.hidden = NO;
|
||||
self.searchButton.hidden = NO;
|
||||
break;
|
||||
case MWMBottomMenuStateCompact:
|
||||
self.layoutDuration = IPAD ? kDefaultAnimationDuration : 0.0;
|
||||
break;
|
||||
case MWMBottomMenuStatePlanning:
|
||||
self.goButton.enabled = NO;
|
||||
self.goButton.hidden = NO;
|
||||
self.toggleInfoButton.hidden = YES;
|
||||
self.speedView.hidden = YES;
|
||||
self.timeView.hidden = YES;
|
||||
self.distanceView.hidden = YES;
|
||||
self.progressView.hidden = YES;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = YES;
|
||||
break;
|
||||
case MWMBottomMenuStateGo:
|
||||
self.goButton.enabled = YES;
|
||||
self.goButton.hidden = NO;
|
||||
self.toggleInfoButton.hidden = YES;
|
||||
self.speedView.hidden = YES;
|
||||
self.timeView.hidden = YES;
|
||||
self.distanceView.hidden = YES;
|
||||
self.progressView.hidden = YES;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = YES;
|
||||
break;
|
||||
case MWMBottomMenuStateRouting:
|
||||
self.goButton.hidden = YES;
|
||||
self.toggleInfoButton.hidden = NO;
|
||||
self.speedView.hidden = NO;
|
||||
self.timeView.hidden = NO;
|
||||
self.distanceView.hidden = NO;
|
||||
self.progressView.hidden = NO;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = YES;
|
||||
break;
|
||||
case MWMBottomMenuStateRoutingExpanded:
|
||||
self.goButton.hidden = YES;
|
||||
self.toggleInfoButton.hidden = NO;
|
||||
self.speedView.hidden = NO;
|
||||
self.timeView.hidden = NO;
|
||||
self.distanceView.hidden = NO;
|
||||
self.progressView.hidden = NO;
|
||||
self.routingView.hidden = NO;
|
||||
self.routingAdditionalView.hidden = NO;
|
||||
break;
|
||||
}
|
||||
if (updateMenuButton)
|
||||
[self updateMenuButtonFromState:_state toState:state];
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface MWMBottomMenuViewController : UIViewController <MWMNavigationDashboardInfoProtocol>
|
||||
@interface MWMBottomMenuViewController : UIViewController<MWMNavigationDashboardInfoProtocol>
|
||||
|
||||
@property(nonatomic) MWMBottomMenuState state;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton * p2pButton;
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#import "MWMBottomMenuViewController.h"
|
||||
#import "Common.h"
|
||||
#import "EAGLView.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMActivityViewController.h"
|
||||
#import "MWMBottomMenuCollectionViewCell.h"
|
||||
#import "MWMBottomMenuLayout.h"
|
||||
#import "MWMBottomMenuView.h"
|
||||
#import "MWMBottomMenuViewController.h"
|
||||
#import "MWMButton.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMFrameworkObservers.h"
|
||||
|
@ -15,6 +13,8 @@
|
|||
#import "MWMRouter.h"
|
||||
#import "MWMSearchManager.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "SettingsAndMoreVC.h"
|
||||
#import "Statistics.h"
|
||||
#import "TimeUtils.h"
|
||||
|
@ -68,20 +68,20 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
|
|||
|
||||
@property (nonatomic, readonly) NSUInteger additionalButtonsCount;
|
||||
|
||||
@property (weak, nonatomic) MWMNavigationDashboardEntity * routingInfo;
|
||||
@property(weak, nonatomic) MWMNavigationDashboardEntity * routingInfo;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * speedLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * timeLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * speedLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * speedWithLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceWithLegendLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIPageControl * routingInfoPageControl;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * speedLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * timeLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * distanceLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * speedLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * distanceLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * speedWithLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * distanceWithLegendLabel;
|
||||
@property(weak, nonatomic) IBOutlet UIPageControl * routingInfoPageControl;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * progressView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * routingProgress;
|
||||
@property (weak, nonatomic) IBOutlet MWMButton * ttsSoundButton;
|
||||
@property(weak, nonatomic) IBOutlet UIView * progressView;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * routingProgress;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton * ttsSoundButton;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -141,7 +141,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
|
|||
{
|
||||
[self.view mwm_refreshUI];
|
||||
}
|
||||
|
||||
#pragma mark - MWMNavigationDashboardInfoProtocol
|
||||
|
||||
- (void)updateRoutingInfo:(MWMNavigationDashboardEntity *)info
|
||||
|
@ -188,11 +187,11 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
|
|||
self.speedWithLegendLabel.attributedText = speed;
|
||||
|
||||
[self.progressView layoutIfNeeded];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.routingProgress.constant = self.progressView.width * info.progress / 100.;
|
||||
[self.progressView layoutIfNeeded];
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.routingProgress.constant = self.progressView.width * info.progress / 100.;
|
||||
[self.progressView layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Routing
|
||||
|
@ -204,16 +203,8 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
|
|||
[self updateRoutingInfo:self.routingInfo];
|
||||
}
|
||||
|
||||
- (IBAction)routingStartTouchUpInside
|
||||
{
|
||||
[[MWMRouter router] start];
|
||||
}
|
||||
|
||||
- (IBAction)routingStopTouchUpInside
|
||||
{
|
||||
[[MWMRouter router] stop];
|
||||
}
|
||||
|
||||
- (IBAction)routingStartTouchUpInside { [[MWMRouter router] start]; }
|
||||
- (IBAction)routingStopTouchUpInside { [[MWMRouter router] stop]; }
|
||||
- (IBAction)soundTouchUpInside:(UIButton *)sender
|
||||
{
|
||||
BOOL const isEnable = !sender.selected;
|
||||
|
@ -498,9 +489,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
|
|||
[Statistics logEvent:kStatMenu withParameters:@{kStatButton : kStatRegular}];
|
||||
[self.delegate closeInfoScreens];
|
||||
break;
|
||||
case MWMBottomMenuStateRouting:
|
||||
self.state = MWMBottomMenuStateRoutingExpanded;
|
||||
break;
|
||||
case MWMBottomMenuStateRouting: self.state = MWMBottomMenuStateRoutingExpanded; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -552,7 +541,8 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
|
|||
- (void)setState:(MWMBottomMenuState)state
|
||||
{
|
||||
MWMBottomMenuView * view = (MWMBottomMenuView *)self.view;
|
||||
BOOL const menuActive = (state == MWMBottomMenuStateActive || state == MWMBottomMenuStateRoutingExpanded);
|
||||
BOOL const menuActive =
|
||||
(state == MWMBottomMenuStateActive || state == MWMBottomMenuStateRoutingExpanded);
|
||||
if (menuActive)
|
||||
[self.controller.view bringSubviewToFront:view];
|
||||
[self toggleDimBackgroundVisible:menuActive];
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
#import "MWMMapViewControlsManager.h"
|
||||
#import "Common.h"
|
||||
#import "EAGLView.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMAPIBar.h"
|
||||
#import "MWMAddPlaceNavigationBar.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMAPIBar.h"
|
||||
#import "MWMAuthorizationCommon.h"
|
||||
#import "MWMBottomMenuViewController.h"
|
||||
#import "MWMButton.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMObjectsCategorySelectorController.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
|
@ -18,6 +16,8 @@
|
|||
#import "MWMSearchManager.h"
|
||||
#import "MWMSearchView.h"
|
||||
#import "MWMSideButtons.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
@ -30,36 +30,32 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
NSString * const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue";
|
||||
} // namespace
|
||||
NSString * const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue";
|
||||
} // namespace
|
||||
|
||||
extern NSString * const kAlohalyticsTapEventKey;
|
||||
|
||||
@interface MWMMapViewControlsManager ()<MWMNavigationDashboardManagerProtocol,
|
||||
MWMBottomMenuControllerProtocol>
|
||||
MWMBottomMenuControllerProtocol>
|
||||
|
||||
@property (nonatomic) MWMSideButtons * sideButtons;
|
||||
@property (nonatomic) MWMBottomMenuViewController * menuController;
|
||||
@property (nonatomic) MWMPlacePageViewManager * placePageManager;
|
||||
@property (nonatomic) MWMNavigationDashboardManager * navigationManager;
|
||||
@property (nonatomic) MWMSearchManager * searchManager;
|
||||
@property(nonatomic) MWMSideButtons * sideButtons;
|
||||
@property(nonatomic) MWMBottomMenuViewController * menuController;
|
||||
@property(nonatomic) MWMPlacePageViewManager * placePageManager;
|
||||
@property(nonatomic) MWMNavigationDashboardManager * navigationManager;
|
||||
@property(nonatomic) MWMSearchManager * searchManager;
|
||||
|
||||
@property (weak, nonatomic) MapViewController * ownerController;
|
||||
@property(weak, nonatomic) MapViewController * ownerController;
|
||||
|
||||
@property (nonatomic) BOOL disableStandbyOnRouteFollowing;
|
||||
@property(nonatomic) BOOL disableStandbyOnRouteFollowing;
|
||||
|
||||
@property (nonatomic) CGFloat topBound;
|
||||
@property (nonatomic) CGFloat leftBound;
|
||||
@property(nonatomic) CGFloat topBound;
|
||||
@property(nonatomic) CGFloat leftBound;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMMapViewControlsManager
|
||||
|
||||
+ (MWMMapViewControlsManager *)manager
|
||||
{
|
||||
return [MapViewController controller].controlsManager;
|
||||
}
|
||||
|
||||
+ (MWMMapViewControlsManager *)manager { return [MapViewController controller].controlsManager; }
|
||||
- (instancetype)initWithParentController:(MapViewController *)controller
|
||||
{
|
||||
if (!controller)
|
||||
|
@ -83,11 +79,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (void)refreshLayout
|
||||
{
|
||||
[self.menuController refreshLayout];
|
||||
}
|
||||
|
||||
- (void)refreshLayout { [self.menuController refreshLayout]; }
|
||||
- (void)mwm_refreshUI
|
||||
{
|
||||
[self.sideButtons mwm_refreshUI];
|
||||
|
@ -115,21 +107,9 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
|
||||
#pragma mark - MWMPlacePageViewManager
|
||||
|
||||
- (void)dismissPlacePage
|
||||
{
|
||||
[self.placePageManager hidePlacePage];
|
||||
}
|
||||
|
||||
- (void)showPlacePage:(place_page::Info const &)info
|
||||
{
|
||||
[self.placePageManager showPlacePage:info];
|
||||
}
|
||||
|
||||
- (MWMAlertViewController *)alertController
|
||||
{
|
||||
return self.ownerController.alertController;
|
||||
}
|
||||
|
||||
- (void)dismissPlacePage { [self.placePageManager hidePlacePage]; }
|
||||
- (void)showPlacePage:(place_page::Info const &)info { [self.placePageManager showPlacePage:info]; }
|
||||
- (MWMAlertViewController *)alertController { return self.ownerController.alertController; }
|
||||
- (void)searchViewDidEnterState:(MWMSearchManagerState)state
|
||||
{
|
||||
if (state == MWMSearchManagerStateHidden)
|
||||
|
@ -146,36 +126,35 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
MWMRoutingPlaneMode const m = MapsAppDelegate.theApp.routingPlaneMode;
|
||||
if (m == MWMRoutingPlaneModeSearchSource || m == MWMRoutingPlaneModeSearchDestination)
|
||||
{
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
if (state == MWMSearchManagerStateHidden)
|
||||
{
|
||||
self.navigationManager.routePreview.alpha = 1.;
|
||||
MapsAppDelegate.theApp.routingPlaneMode = MWMRoutingPlaneModePlacePage;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.navigationManager.routePreview.alpha = 0.;
|
||||
}
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
if (state == MWMSearchManagerStateHidden)
|
||||
{
|
||||
self.navigationManager.routePreview.alpha = 1.;
|
||||
MapsAppDelegate.theApp.routingPlaneMode = MWMRoutingPlaneModePlacePage;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.navigationManager.routePreview.alpha = 0.;
|
||||
}
|
||||
}];
|
||||
}
|
||||
else if (m == MWMRoutingPlaneModePlacePage)
|
||||
{
|
||||
if (state == MWMSearchManagerStateHidden)
|
||||
return;
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.navigationManager.routePreview.alpha = 0.;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
MapsAppDelegate.theApp.routingPlaneMode = MWMRoutingPlaneModeNone;
|
||||
self.navigationManager.routePreview.alpha = 1.;
|
||||
[self.navigationManager.routePreview removeFromSuperview];
|
||||
[[MWMRouter router] stop];
|
||||
self.navigationManager.state = MWMNavigationDashboardStateHidden;
|
||||
self.menuController.p2pButton.selected = NO;
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.navigationManager.routePreview.alpha = 0.;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
MapsAppDelegate.theApp.routingPlaneMode = MWMRoutingPlaneModeNone;
|
||||
self.navigationManager.routePreview.alpha = 1.;
|
||||
[self.navigationManager.routePreview removeFromSuperview];
|
||||
[[MWMRouter router] stop];
|
||||
self.navigationManager.state = MWMNavigationDashboardStateHidden;
|
||||
self.menuController.p2pButton.selected = NO;
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,12 +173,14 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
{
|
||||
if (GetFramework().IsRoutingActive())
|
||||
{
|
||||
[Statistics logEvent:kStatDownloaderMigrationProhibitedDialogue withParameters:@{kStatFrom : kStatDownloader}];
|
||||
[Statistics logEvent:kStatDownloaderMigrationProhibitedDialogue
|
||||
withParameters:@{kStatFrom : kStatDownloader}];
|
||||
[self.alertController presentMigrationProhibitedAlert];
|
||||
}
|
||||
else
|
||||
{
|
||||
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatDownloader}];
|
||||
[Statistics logEvent:kStatDownloaderMigrationDialogue
|
||||
withParameters:@{kStatFrom : kStatDownloader}];
|
||||
[self.ownerController openMigration];
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +199,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
if (!self.searchHidden)
|
||||
self.searchManager.state = MWMSearchManagerStateHidden;
|
||||
else if (MapsAppDelegate.theApp.routingPlaneMode != MWMRoutingPlaneModeNone)
|
||||
[[MWMRouter router] stop];
|
||||
[[MWMRouter router] stop];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -246,21 +227,23 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
self.searchManager.state = MWMSearchManagerStateHidden;
|
||||
|
||||
[MWMAddPlaceNavigationBar showInSuperview:self.ownerController.view
|
||||
isBusiness:isBusiness applyPosition:hasPoint position:point doneBlock:^
|
||||
{
|
||||
auto & f = GetFramework();
|
||||
isBusiness:isBusiness
|
||||
applyPosition:hasPoint
|
||||
position:point
|
||||
doneBlock:^{
|
||||
auto & f = GetFramework();
|
||||
|
||||
if (IsPointCoveredByDownloadedMaps(f.GetViewportCenter(), f.Storage(), f.CountryInfoGetter()))
|
||||
[self.ownerController performSegueWithIdentifier:kMapToCategorySelectorSegue sender:nil];
|
||||
else
|
||||
[self.ownerController.alertController presentIncorrectFeauturePositionAlert];
|
||||
if (IsPointCoveredByDownloadedMaps(f.GetViewportCenter(), f.Storage(),
|
||||
f.CountryInfoGetter()))
|
||||
[self.ownerController performSegueWithIdentifier:kMapToCategorySelectorSegue sender:nil];
|
||||
else
|
||||
[self.ownerController.alertController presentIncorrectFeauturePositionAlert];
|
||||
|
||||
[self didFinishAddingPlace];
|
||||
}
|
||||
cancelBlock:^
|
||||
{
|
||||
[self didFinishAddingPlace];
|
||||
}];
|
||||
[self didFinishAddingPlace];
|
||||
}
|
||||
cancelBlock:^{
|
||||
[self didFinishAddingPlace];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)dragPlacePage:(CGRect)frame
|
||||
|
@ -301,18 +284,18 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
CGFloat const bound = newFrame.origin.x + newFrame.size.width;
|
||||
if (self.searchManager.state == MWMSearchManagerStateHidden)
|
||||
{
|
||||
self.placePageManager.leftBound = self.menuController.leftBound = newFrame.origin.x + newFrame.size.width;
|
||||
self.placePageManager.leftBound = self.menuController.leftBound =
|
||||
newFrame.origin.x + newFrame.size.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.searchManager.view.alpha = bound > 0 ? 0. : 1.;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
self.searchManager.state = MWMSearchManagerStateHidden;
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.searchManager.view.alpha = bound > 0 ? 0. : 1.;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
self.searchManager.state = MWMSearchManagerStateHidden;
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,8 +310,9 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
- (void)didStartEditingRoutePoint:(BOOL)isSource
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatSearch)
|
||||
withParameters:@{kStatValue : (isSource ? kStatSource : kStatDestination)}];
|
||||
MapsAppDelegate.theApp.routingPlaneMode = isSource ? MWMRoutingPlaneModeSearchSource : MWMRoutingPlaneModeSearchDestination;
|
||||
withParameters:@{kStatValue : (isSource ? kStatSource : kStatDestination)}];
|
||||
MapsAppDelegate.theApp.routingPlaneMode =
|
||||
isSource ? MWMRoutingPlaneModeSearchSource : MWMRoutingPlaneModeSearchDestination;
|
||||
self.searchManager.state = MWMSearchManagerStateDefault;
|
||||
}
|
||||
|
||||
|
@ -371,8 +355,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
{
|
||||
if (![MWMRouter router].startPoint.IsMyPosition())
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
GetFramework().DisableFollowMode();
|
||||
[self.navigationManager updateDashboard];
|
||||
});
|
||||
|
@ -439,8 +422,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
- (MWMSearchManager *)searchManager
|
||||
{
|
||||
if (!_searchManager)
|
||||
_searchManager =
|
||||
[[MWMSearchManager alloc] initWithParentView:self.ownerController.view];
|
||||
_searchManager = [[MWMSearchManager alloc] initWithParentView:self.ownerController.view];
|
||||
return _searchManager;
|
||||
}
|
||||
|
||||
|
@ -483,26 +465,15 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
return _menuState;
|
||||
}
|
||||
|
||||
- (MWMNavigationDashboardState)navigationState
|
||||
{
|
||||
return self.navigationManager.state;
|
||||
}
|
||||
|
||||
- (MWMPlacePageEntity *)placePageEntity
|
||||
{
|
||||
return self.placePageManager.entity;
|
||||
}
|
||||
|
||||
- (BOOL)isDirectionViewShown
|
||||
{
|
||||
return self.placePageManager.isDirectionViewShown;
|
||||
}
|
||||
|
||||
- (MWMNavigationDashboardState)navigationState { return self.navigationManager.state; }
|
||||
- (MWMPlacePageEntity *)placePageEntity { return self.placePageManager.entity; }
|
||||
- (BOOL)isDirectionViewShown { return self.placePageManager.isDirectionViewShown; }
|
||||
- (void)setTopBound:(CGFloat)topBound
|
||||
{
|
||||
if (IPAD)
|
||||
return;
|
||||
_topBound = self.placePageManager.topBound = self.sideButtons.topBound = self.navigationManager.topBound = topBound;
|
||||
_topBound = self.placePageManager.topBound = self.sideButtons.topBound =
|
||||
self.navigationManager.topBound = topBound;
|
||||
}
|
||||
|
||||
- (void)setLeftBound:(CGFloat)leftBound
|
||||
|
@ -512,17 +483,15 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
MWMRoutingPlaneMode const m = MapsAppDelegate.theApp.routingPlaneMode;
|
||||
if (m != MWMRoutingPlaneModeNone)
|
||||
return;
|
||||
_leftBound = self.placePageManager.leftBound = self.navigationManager.leftBound = self.menuController.leftBound = leftBound;
|
||||
}
|
||||
|
||||
- (BOOL)searchHidden
|
||||
{
|
||||
return self.searchManager.state == MWMSearchManagerStateHidden;
|
||||
_leftBound = self.placePageManager.leftBound = self.navigationManager.leftBound =
|
||||
self.menuController.leftBound = leftBound;
|
||||
}
|
||||
|
||||
- (BOOL)searchHidden { return self.searchManager.state == MWMSearchManagerStateHidden; }
|
||||
- (void)setSearchHidden:(BOOL)searchHidden
|
||||
{
|
||||
self.searchManager.state = searchHidden ? MWMSearchManagerStateHidden : MWMSearchManagerStateDefault;
|
||||
self.searchManager.state =
|
||||
searchHidden ? MWMSearchManagerStateHidden : MWMSearchManagerStateDefault;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#import "MapsAppDelegate.h"
|
||||
#import "MWMSearchManager.h"
|
||||
#import "MWMConsole.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMLocationManager.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMNoMapsViewController.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMSearchManager.h"
|
||||
#import "MWMSearchTabbedViewController.h"
|
||||
#import "MWMSearchTabButtonsView.h"
|
||||
#import "MWMSearchTabbedViewController.h"
|
||||
#import "MWMSearchTableViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import "MWMSearchView.h"
|
||||
#import "Common.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMSearchTabButtonsView.h"
|
||||
#import "MWMSearchView.h"
|
||||
|
||||
static CGFloat constexpr kWidthForiPad = 320.0;
|
||||
|
||||
|
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
@interface MWMNavigationDashboardEntity : NSObject
|
||||
|
||||
@property (nonatomic, readonly) BOOL isValid;
|
||||
@property (nonatomic, readonly) NSString * speed;
|
||||
@property (nonatomic, readonly) NSString * speedUnits;
|
||||
@property (nonatomic, readonly) NSString * targetDistance;
|
||||
@property (nonatomic, readonly) NSString * targetUnits;
|
||||
@property (nonatomic, readonly) NSString * distanceToTurn;
|
||||
@property (nonatomic, readonly) NSString * turnUnits;
|
||||
@property (nonatomic, readonly) NSString * streetName;
|
||||
@property (nonatomic, readonly) UIImage * turnImage;
|
||||
@property (nonatomic, readonly) UIImage * nextTurnImage;
|
||||
@property (nonatomic, readonly) NSUInteger roundExitNumber;
|
||||
@property (nonatomic, readonly) NSUInteger timeToTarget;
|
||||
@property (nonatomic, readonly) CGFloat progress;
|
||||
@property(nonatomic, readonly) BOOL isValid;
|
||||
@property(nonatomic, readonly) NSString * speed;
|
||||
@property(nonatomic, readonly) NSString * speedUnits;
|
||||
@property(nonatomic, readonly) NSString * targetDistance;
|
||||
@property(nonatomic, readonly) NSString * targetUnits;
|
||||
@property(nonatomic, readonly) NSString * distanceToTurn;
|
||||
@property(nonatomic, readonly) NSString * turnUnits;
|
||||
@property(nonatomic, readonly) NSString * streetName;
|
||||
@property(nonatomic, readonly) UIImage * turnImage;
|
||||
@property(nonatomic, readonly) UIImage * nextTurnImage;
|
||||
@property(nonatomic, readonly) NSUInteger roundExitNumber;
|
||||
@property(nonatomic, readonly) NSUInteger timeToTarget;
|
||||
@property(nonatomic, readonly) CGFloat progress;
|
||||
//@property (nonatomic, readonly) vector<location::FollowingInfo::SingleLaneInfoClient> lanes;
|
||||
@property (nonatomic, readonly) BOOL isPedestrian;
|
||||
@property(nonatomic, readonly) BOOL isPedestrian;
|
||||
|
||||
- (void)updateFollowingInfo:(location::FollowingInfo const &)info;
|
||||
|
||||
+ (instancetype)new __attribute__((unavailable("init is not available")));
|
||||
+ (instancetype) new __attribute__((unavailable("init is not available")));
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include "Framework.h"
|
||||
#include "platform/location.hpp"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState)
|
||||
{
|
||||
typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) {
|
||||
MWMNavigationDashboardStateHidden,
|
||||
MWMNavigationDashboardStatePrepare,
|
||||
MWMNavigationDashboardStatePlanning,
|
||||
|
@ -24,27 +23,29 @@ typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState)
|
|||
|
||||
@end
|
||||
|
||||
@protocol MWMNavigationDashboardManagerProtocol <MWMNavigationViewProtocol>
|
||||
@protocol MWMNavigationDashboardManagerProtocol<MWMNavigationViewProtocol>
|
||||
|
||||
- (void)didStartEditingRoutePoint:(BOOL)isSource;
|
||||
- (void)setMenuState:(MWMBottomMenuState)menuState;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMNavigationDashboardManager : NSObject <MWMLocationObserver>
|
||||
@interface MWMNavigationDashboardManager : NSObject<MWMLocationObserver>
|
||||
|
||||
+ (MWMNavigationDashboardManager *)manager;
|
||||
|
||||
@property (nonatomic, readonly) MWMNavigationDashboardEntity * entity;
|
||||
@property (nonatomic, readonly) MWMRoutePreview * routePreview;
|
||||
@property (nonatomic) MWMNavigationDashboardState state;
|
||||
@property (weak, nonatomic, readonly) id<MWMNavigationDashboardManagerProtocol> delegate;
|
||||
@property (nonatomic) CGFloat topBound;
|
||||
@property (nonatomic) CGFloat leftBound;
|
||||
@property (nonatomic, readonly) CGFloat height;
|
||||
@property(nonatomic, readonly) MWMNavigationDashboardEntity * entity;
|
||||
@property(nonatomic, readonly) MWMRoutePreview * routePreview;
|
||||
@property(nonatomic) MWMNavigationDashboardState state;
|
||||
@property(weak, nonatomic, readonly) id<MWMNavigationDashboardManagerProtocol> delegate;
|
||||
@property(nonatomic) CGFloat topBound;
|
||||
@property(nonatomic) CGFloat leftBound;
|
||||
@property(nonatomic, readonly) CGFloat height;
|
||||
|
||||
- (instancetype)init __attribute__((unavailable("init is not available")));
|
||||
- (instancetype)initWithParentView:(UIView *)view infoDisplay:(id<MWMNavigationDashboardInfoProtocol>)infoDisplay delegate:(id<MWMNavigationDashboardManagerProtocol>)delegate;
|
||||
- (instancetype)initWithParentView:(UIView *)view
|
||||
infoDisplay:(id<MWMNavigationDashboardInfoProtocol>)infoDisplay
|
||||
delegate:(id<MWMNavigationDashboardManagerProtocol>)delegate;
|
||||
- (void)updateFollowingInfo:(location::FollowingInfo const &)info;
|
||||
- (void)updateDashboard;
|
||||
- (void)setRouteBuilderProgress:(CGFloat)progress;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#import "MWMNavigationDashboardManager.h"
|
||||
#import "Common.h"
|
||||
#import "Macros.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMLocationHelpers.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMNavigationDashboardManager.h"
|
||||
#import "MWMRoutePreview.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "Macros.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
namespace
|
||||
|
@ -18,18 +18,18 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
|
||||
@interface MWMMapViewControlsManager ()
|
||||
|
||||
@property (nonatomic) MWMNavigationDashboardManager * navigationManager;
|
||||
@property(nonatomic) MWMNavigationDashboardManager * navigationManager;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMNavigationDashboardManager ()
|
||||
|
||||
@property (nonatomic, readwrite) IBOutlet MWMRoutePreview * routePreview;
|
||||
@property(nonatomic, readwrite) IBOutlet MWMRoutePreview * routePreview;
|
||||
|
||||
@property (weak, nonatomic) UIView * ownerView;
|
||||
@property (weak, nonatomic) id<MWMNavigationDashboardInfoProtocol> infoDisplay;
|
||||
@property(weak, nonatomic) UIView * ownerView;
|
||||
@property(weak, nonatomic) id<MWMNavigationDashboardInfoProtocol> infoDisplay;
|
||||
|
||||
@property (nonatomic) MWMNavigationDashboardEntity * entity;
|
||||
@property(nonatomic) MWMNavigationDashboardEntity * entity;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -40,7 +40,9 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
return [MWMMapViewControlsManager manager].navigationManager;
|
||||
}
|
||||
|
||||
- (instancetype)initWithParentView:(UIView *)view infoDisplay:(id<MWMNavigationDashboardInfoProtocol>)infoDisplay delegate:(id<MWMNavigationDashboardManagerProtocol>)delegate
|
||||
- (instancetype)initWithParentView:(UIView *)view
|
||||
infoDisplay:(id<MWMNavigationDashboardInfoProtocol>)infoDisplay
|
||||
delegate:(id<MWMNavigationDashboardManagerProtocol>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
|
@ -90,18 +92,10 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
|
||||
#pragma mark - MWMNavigationGo
|
||||
|
||||
- (IBAction)routingStartTouchUpInside
|
||||
{
|
||||
[[MWMRouter router] start];
|
||||
}
|
||||
|
||||
- (IBAction)routingStartTouchUpInside { [[MWMRouter router] start]; }
|
||||
#pragma mark - State changes
|
||||
|
||||
- (void)hideState
|
||||
{
|
||||
[self.routePreview remove];
|
||||
}
|
||||
|
||||
- (void)hideState { [self.routePreview remove]; }
|
||||
- (void)showStatePrepare
|
||||
{
|
||||
[self.routePreview addToView:self.ownerView];
|
||||
|
@ -129,11 +123,7 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
[self.routePreview remove];
|
||||
}
|
||||
|
||||
- (void)mwm_refreshUI
|
||||
{
|
||||
[self.routePreview mwm_refreshUI];
|
||||
}
|
||||
|
||||
- (void)mwm_refreshUI { [self.routePreview mwm_refreshUI]; }
|
||||
#pragma mark - Properties
|
||||
|
||||
- (void)setState:(MWMNavigationDashboardState)state
|
||||
|
@ -142,47 +132,32 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
return;
|
||||
switch (state)
|
||||
{
|
||||
case MWMNavigationDashboardStateHidden:
|
||||
[self hideState];
|
||||
break;
|
||||
case MWMNavigationDashboardStatePrepare:
|
||||
[self showStatePrepare];
|
||||
break;
|
||||
case MWMNavigationDashboardStatePlanning:
|
||||
[self showStatePlanning];
|
||||
break;
|
||||
case MWMNavigationDashboardStateHidden: [self hideState]; break;
|
||||
case MWMNavigationDashboardStatePrepare: [self showStatePrepare]; break;
|
||||
case MWMNavigationDashboardStatePlanning: [self showStatePlanning]; break;
|
||||
case MWMNavigationDashboardStateError:
|
||||
NSAssert(_state == MWMNavigationDashboardStatePlanning || _state == MWMNavigationDashboardStateReady, @"Invalid state change (error)");
|
||||
NSAssert(
|
||||
_state == MWMNavigationDashboardStatePlanning || _state == MWMNavigationDashboardStateReady,
|
||||
@"Invalid state change (error)");
|
||||
[self handleError];
|
||||
break;
|
||||
case MWMNavigationDashboardStateReady:
|
||||
NSAssert(_state == MWMNavigationDashboardStatePlanning, @"Invalid state change (ready)");
|
||||
[self showStateReady];
|
||||
break;
|
||||
case MWMNavigationDashboardStateNavigation:
|
||||
[self showStateNavigation];
|
||||
break;
|
||||
case MWMNavigationDashboardStateNavigation: [self showStateNavigation]; break;
|
||||
}
|
||||
_state = state;
|
||||
[[MapViewController controller] updateStatusBarStyle];
|
||||
}
|
||||
|
||||
- (void)setTopBound:(CGFloat)topBound
|
||||
{
|
||||
_topBound = self.routePreview.topBound = topBound;
|
||||
}
|
||||
|
||||
- (void)setLeftBound:(CGFloat)leftBound
|
||||
{
|
||||
_leftBound = self.routePreview.leftBound = leftBound;
|
||||
}
|
||||
|
||||
- (void)setTopBound:(CGFloat)topBound { _topBound = self.routePreview.topBound = topBound; }
|
||||
- (void)setLeftBound:(CGFloat)leftBound { _leftBound = self.routePreview.leftBound = leftBound; }
|
||||
- (CGFloat)height
|
||||
{
|
||||
switch (self.state)
|
||||
{
|
||||
case MWMNavigationDashboardStateHidden:
|
||||
return 0.0;
|
||||
case MWMNavigationDashboardStateHidden: return 0.0;
|
||||
case MWMNavigationDashboardStatePlanning:
|
||||
case MWMNavigationDashboardStateReady:
|
||||
case MWMNavigationDashboardStateError:
|
||||
|
@ -191,7 +166,7 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
return self.topBound;
|
||||
return self.routePreview.visibleHeight;
|
||||
case MWMNavigationDashboardStateNavigation:
|
||||
return 0.0; // TODO: Replace with real value
|
||||
return 0.0; // TODO: Replace with real value
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +199,9 @@ NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
|
|||
{
|
||||
if (!_routePreview)
|
||||
{
|
||||
[NSBundle.mainBundle loadNibNamed:IPAD ? kRoutePreviewIPADXibName : kRoutePreviewXibName owner:self options:nil];
|
||||
[NSBundle.mainBundle loadNibNamed:IPAD ? kRoutePreviewIPADXibName : kRoutePreviewXibName
|
||||
owner:self
|
||||
options:nil];
|
||||
_routePreview.dashboardManager = self;
|
||||
_routePreview.delegate = self.delegate;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
+ (NSString *)ttsStatusNotificationKey;
|
||||
|
||||
@property (nonatomic) BOOL active;
|
||||
@property(nonatomic) BOOL active;
|
||||
// Returns a list of available languages in the following format:
|
||||
// * name in bcp47;
|
||||
// * localized name;
|
||||
|
@ -22,14 +22,14 @@
|
|||
- (instancetype)copy __attribute__((unavailable("call tts instead")));
|
||||
- (instancetype)copyWithZone:(NSZone *)zone __attribute__((unavailable("call tts instead")));
|
||||
+ (instancetype)alloc __attribute__((unavailable("call tts instead")));
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable("call tts instead")));
|
||||
+ (instancetype)new __attribute__((unavailable("call tts instead")));
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone
|
||||
__attribute__((unavailable("call tts instead")));
|
||||
+ (instancetype) new __attribute__((unavailable("call tts instead")));
|
||||
|
||||
@end
|
||||
|
||||
namespace tts
|
||||
{
|
||||
|
||||
string translatedTwine(string const & twine);
|
||||
|
||||
} // namespace tts
|
||||
} // namespace tts
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import "Common.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "Statistics.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import "Common.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
#include "LocaleTranslator.h"
|
||||
|
||||
|
@ -41,16 +41,16 @@ vector<pair<string, string>> availableLanguages()
|
|||
}
|
||||
} // namespace
|
||||
|
||||
@interface MWMTextToSpeech() <AVSpeechSynthesizerDelegate>
|
||||
@interface MWMTextToSpeech ()<AVSpeechSynthesizerDelegate>
|
||||
{
|
||||
vector<pair<string, string>> _availableLanguages;
|
||||
}
|
||||
|
||||
@property (nonatomic) AVSpeechSynthesizer * speechSynthesizer;
|
||||
@property (nonatomic) AVSpeechSynthesisVoice * speechVoice;
|
||||
@property (nonatomic) float speechRate;
|
||||
@property (nonatomic) AVAudioSession * audioSession;
|
||||
@property (nonatomic) NSInteger notificationsToSpeak;
|
||||
@property(nonatomic) AVSpeechSynthesizer * speechSynthesizer;
|
||||
@property(nonatomic) AVSpeechSynthesisVoice * speechVoice;
|
||||
@property(nonatomic) float speechRate;
|
||||
@property(nonatomic) AVAudioSession * audioSession;
|
||||
@property(nonatomic) NSInteger notificationsToSpeak;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -60,8 +60,7 @@ vector<pair<string, string>> availableLanguages()
|
|||
{
|
||||
static dispatch_once_t onceToken;
|
||||
static MWMTextToSpeech * tts = nil;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
dispatch_once(&onceToken, ^{
|
||||
tts = [[super alloc] initTTS];
|
||||
});
|
||||
return tts;
|
||||
|
@ -85,14 +84,19 @@ vector<pair<string, string>> availableLanguages()
|
|||
make_pair([preferedLanguageBcp47 UTF8String],
|
||||
tts::translatedTwine(bcp47ToTwineLanguage(preferedLanguageBcp47)));
|
||||
|
||||
if (find(_availableLanguages.begin(), _availableLanguages.end(), lan) != _availableLanguages.end())
|
||||
if (find(_availableLanguages.begin(), _availableLanguages.end(), lan) !=
|
||||
_availableLanguages.end())
|
||||
[self setNotificationsLocale:preferedLanguageBcp47];
|
||||
else
|
||||
[self setNotificationsLocale:kDefaultLanguage];
|
||||
|
||||
// Before 9.0 version iOS has an issue with speechRate. AVSpeechUtteranceDefaultSpeechRate does not work correctly.
|
||||
// Before 9.0 version iOS has an issue with speechRate. AVSpeechUtteranceDefaultSpeechRate does
|
||||
// not work correctly.
|
||||
// It's a work around for iOS 7.x and 8.x.
|
||||
_speechRate = isIOSVersionLessThan(@"7.1.1") ? 0.3 : (isIOSVersionLessThan(@"9.0.0") ? 0.15 : AVSpeechUtteranceDefaultSpeechRate);
|
||||
_speechRate =
|
||||
isIOSVersionLessThan(@"7.1.1")
|
||||
? 0.3
|
||||
: (isIOSVersionLessThan(@"9.0.0") ? 0.15 : AVSpeechUtteranceDefaultSpeechRate);
|
||||
|
||||
NSError * err = nil;
|
||||
_audioSession = [AVAudioSession sharedInstance];
|
||||
|
@ -106,36 +110,20 @@ vector<pair<string, string>> availableLanguages()
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (NSString *)ttsStatusNotificationKey
|
||||
{
|
||||
return @"TTFStatusWasChangedFromSettingsNotification";
|
||||
}
|
||||
|
||||
- (vector<pair<string, string>>)availableLanguages
|
||||
{
|
||||
return _availableLanguages;
|
||||
}
|
||||
|
||||
+ (NSString *)ttsStatusNotificationKey { return @"TTFStatusWasChangedFromSettingsNotification"; }
|
||||
- (vector<pair<string, string>>)availableLanguages { return _availableLanguages; }
|
||||
- (void)setNotificationsLocale:(NSString *)locale
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatTTSSettings, kStatChangeLanguage)
|
||||
withParameters:@{kStatValue : locale}];
|
||||
withParameters:@{kStatValue : locale}];
|
||||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setObject:locale forKey:kUserDefaultsTTSLanguageBcp47];
|
||||
[ud synchronize];
|
||||
[self createVoice:locale];
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return _speechSynthesizer != nil && _speechVoice != nil;
|
||||
}
|
||||
|
||||
+ (BOOL)isTTSEnabled
|
||||
{
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:kIsTTSEnabled];
|
||||
}
|
||||
|
||||
- (BOOL)isValid { return _speechSynthesizer != nil && _speechVoice != nil; }
|
||||
+ (BOOL)isTTSEnabled { return [[NSUserDefaults standardUserDefaults] boolForKey:kIsTTSEnabled]; }
|
||||
+ (void)setTTSEnabled:(BOOL)enabled
|
||||
{
|
||||
if ([MWMTextToSpeech isTTSEnabled] == enabled)
|
||||
|
@ -145,7 +133,9 @@ vector<pair<string, string>> availableLanguages()
|
|||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setBool:enabled forKey:kIsTTSEnabled];
|
||||
[ud synchronize];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:[self ttsStatusNotificationKey] object:nil userInfo:nil];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:[self ttsStatusNotificationKey]
|
||||
object:nil
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (void)setActive:(BOOL)active
|
||||
|
@ -155,7 +145,10 @@ vector<pair<string, string>> availableLanguages()
|
|||
if (active && ![self isValid])
|
||||
[self createSynthesizer];
|
||||
GetFramework().EnableTurnNotifications(active ? true : false);
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:[MWMTextToSpeech ttsStatusNotificationKey] object:nil userInfo:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:[MWMTextToSpeech ttsStatusNotificationKey]
|
||||
object:nil
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (BOOL)active
|
||||
|
@ -170,19 +163,20 @@ vector<pair<string, string>> availableLanguages()
|
|||
|
||||
- (void)createSynthesizer
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
|
||||
self.speechSynthesizer.delegate = self;
|
||||
[self createVoice:[MWMTextToSpeech savedLanguage]];
|
||||
});
|
||||
// TODO(vbykoianko) Use [NSLocale preferredLanguages] instead of [AVSpeechSynthesisVoice currentLanguageCode].
|
||||
// [AVSpeechSynthesisVoice currentLanguageCode] is used now because of we need a language code in BCP-47.
|
||||
// TODO(vbykoianko) Use [NSLocale preferredLanguages] instead of [AVSpeechSynthesisVoice
|
||||
// currentLanguageCode].
|
||||
// [AVSpeechSynthesisVoice currentLanguageCode] is used now because of we need a language code in
|
||||
// BCP-47.
|
||||
}
|
||||
|
||||
- (void)createVoice:(NSString *)locale
|
||||
{
|
||||
NSMutableArray<NSString *> * candidateLocales = [@[kDefaultLanguage, @"en-GB"] mutableCopy];
|
||||
NSMutableArray<NSString *> * candidateLocales = [@[ kDefaultLanguage, @"en-GB" ] mutableCopy];
|
||||
|
||||
if (locale)
|
||||
[candidateLocales insertObject:locale atIndex:0];
|
||||
|
@ -214,13 +208,15 @@ vector<pair<string, string>> availableLanguages()
|
|||
{
|
||||
string const twineLang = bcp47ToTwineLanguage(voice.language);
|
||||
if (twineLang.empty())
|
||||
LOG(LERROR, ("Cannot convert UI locale or default locale to twine language. MWMTextToSpeech is invalid."));
|
||||
LOG(LERROR, ("Cannot convert UI locale or default locale to twine language. MWMTextToSpeech "
|
||||
"is invalid."));
|
||||
else
|
||||
GetFramework().SetTurnNotificationsLocale(twineLang);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LERROR, ("The UI language and English are not available for TTS. MWMTextToSpeech is invalid."));
|
||||
LOG(LERROR,
|
||||
("The UI language and English are not available for TTS. MWMTextToSpeech is invalid."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +227,7 @@ vector<pair<string, string>> availableLanguages()
|
|||
[self reduceNotificationsToSpeak];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSLog(@"Speak text: %@", textToSpeak);
|
||||
AVSpeechUtterance * utterance = [AVSpeechUtterance speechUtteranceWithString:textToSpeak];
|
||||
utterance.voice = self.speechVoice;
|
||||
|
@ -244,7 +240,7 @@ vector<pair<string, string>> availableLanguages()
|
|||
Framework & frm = GetFramework();
|
||||
if (!frm.IsRoutingActive())
|
||||
return;
|
||||
|
||||
|
||||
vector<string> notifications;
|
||||
frm.GenerateTurnNotifications(notifications);
|
||||
|
||||
|
@ -266,9 +262,12 @@ vector<pair<string, string>> availableLanguages()
|
|||
- (BOOL)setAudioSessionActive:(BOOL)audioSessionActive
|
||||
{
|
||||
NSError * err;
|
||||
if (![self.audioSession setActive:audioSessionActive withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&err])
|
||||
if (![self.audioSession setActive:audioSessionActive
|
||||
withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
|
||||
error:&err])
|
||||
{
|
||||
LOG(LWARNING, ("[[AVAudioSession sharedInstance] setActive]] error.", [err localizedDescription]));
|
||||
LOG(LWARNING,
|
||||
("[[AVAudioSession sharedInstance] setActive]] error.", [err localizedDescription]));
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
|
@ -283,33 +282,32 @@ vector<pair<string, string>> availableLanguages()
|
|||
|
||||
#pragma mark - AVSpeechSynthesizerDelegate
|
||||
|
||||
- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didCancelSpeechUtterance:(AVSpeechUtterance *)utterance
|
||||
- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer
|
||||
didCancelSpeechUtterance:(AVSpeechUtterance *)utterance
|
||||
{
|
||||
[self reduceNotificationsToSpeak];
|
||||
}
|
||||
|
||||
- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance
|
||||
- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer
|
||||
didFinishSpeechUtterance:(AVSpeechUtterance *)utterance
|
||||
{
|
||||
[self reduceNotificationsToSpeak];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
namespace tts
|
||||
{
|
||||
|
||||
string translatedTwine(string const & twine)
|
||||
{
|
||||
auto const & list = routing::turns::sound::kLanguageList;
|
||||
auto const it = find_if(list.begin(), list.end(), [&twine](pair<string, string> const & pair)
|
||||
{
|
||||
return pair.first == twine;
|
||||
});
|
||||
|
||||
auto const it = find_if(list.begin(), list.end(), [&twine](pair<string, string> const & pair) {
|
||||
return pair.first == twine;
|
||||
});
|
||||
|
||||
if (it != list.end())
|
||||
return it->second;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
} // namespace tts
|
||||
} // namespace tts
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#import "MWMCircularProgress.h"
|
||||
#import "MWMNavigationView.h"
|
||||
|
||||
#include "routing/router.hpp"
|
||||
|
||||
@class MWMNavigationDashboardEntity;
|
||||
@class MWMNavigationDashboardManager;
|
||||
@class MWMCircularProgress;
|
||||
|
||||
@interface MWMRoutePreview : MWMNavigationView
|
||||
|
||||
@property (weak, nonatomic, readonly) IBOutlet UIButton * extendButton;
|
||||
@property (weak, nonatomic) MWMNavigationDashboardManager * dashboardManager;
|
||||
@property(weak, nonatomic, readonly) IBOutlet UIButton * extendButton;
|
||||
@property(weak, nonatomic) MWMNavigationDashboardManager * dashboardManager;
|
||||
|
||||
- (void)configureWithEntity:(MWMNavigationDashboardEntity *)entity;
|
||||
- (void)statePrepare;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#import "MWMRoutePreview.h"
|
||||
#import "Common.h"
|
||||
#import "MWMCircularProgress.h"
|
||||
#import "MWMNavigationDashboardManager.h"
|
||||
#import "MWMRoutePointCell.h"
|
||||
#import "MWMRoutePointLayout.h"
|
||||
#import "MWMRoutePreview.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "Statistics.h"
|
||||
#import "TimeUtils.h"
|
||||
|
@ -12,30 +12,30 @@
|
|||
|
||||
static CGFloat constexpr kAdditionalHeight = 20.;
|
||||
|
||||
@interface MWMRoutePreview () <MWMRoutePointCellDelegate, MWMCircularProgressProtocol>
|
||||
@interface MWMRoutePreview ()<MWMRoutePointCellDelegate, MWMCircularProgressProtocol>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * pedestrian;
|
||||
@property (weak, nonatomic) IBOutlet UIView * vehicle;
|
||||
@property (weak, nonatomic) IBOutlet UIView * bicycle;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * planningRouteViewHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * planningContainerHeight;
|
||||
@property (weak, nonatomic, readwrite) IBOutlet UIButton * extendButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * goButton;
|
||||
@property (weak, nonatomic) IBOutlet UICollectionView * collectionView;
|
||||
@property (weak, nonatomic) IBOutlet MWMRoutePointLayout * layout;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * arrowImageView;
|
||||
@property (weak, nonatomic) IBOutlet UIView * statusBox;
|
||||
@property (weak, nonatomic) IBOutlet UIView * planningBox;
|
||||
@property (weak, nonatomic) IBOutlet UIView * resultsBox;
|
||||
@property (weak, nonatomic) IBOutlet UIView * errorBox;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * resultLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * arriveLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * completeImageView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * statusBoxHeight;
|
||||
@property (nonatomic) UIImageView * movingCellImage;
|
||||
@property(weak, nonatomic) IBOutlet UIView * pedestrian;
|
||||
@property(weak, nonatomic) IBOutlet UIView * vehicle;
|
||||
@property(weak, nonatomic) IBOutlet UIView * bicycle;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * planningRouteViewHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * planningContainerHeight;
|
||||
@property(weak, nonatomic, readwrite) IBOutlet UIButton * extendButton;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * goButton;
|
||||
@property(weak, nonatomic) IBOutlet UICollectionView * collectionView;
|
||||
@property(weak, nonatomic) IBOutlet MWMRoutePointLayout * layout;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * arrowImageView;
|
||||
@property(weak, nonatomic) IBOutlet UIView * statusBox;
|
||||
@property(weak, nonatomic) IBOutlet UIView * planningBox;
|
||||
@property(weak, nonatomic) IBOutlet UIView * resultsBox;
|
||||
@property(weak, nonatomic) IBOutlet UIView * errorBox;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * resultLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * arriveLabel;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * completeImageView;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * statusBoxHeight;
|
||||
@property(nonatomic) UIImageView * movingCellImage;
|
||||
|
||||
@property (nonatomic) BOOL isNeedToMove;
|
||||
@property (nonatomic) NSIndexPath * indexPathOfMovingCell;
|
||||
@property(nonatomic) BOOL isNeedToMove;
|
||||
@property(nonatomic) NSIndexPath * indexPathOfMovingCell;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -58,27 +58,28 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
- (void)setupProgresses
|
||||
{
|
||||
[self addProgress:self.vehicle imageName:@"ic_drive" routerType:routing::RouterType::Vehicle];
|
||||
[self addProgress:self.pedestrian imageName:@"ic_walk" routerType:routing::RouterType::Pedestrian];
|
||||
[self addProgress:self.bicycle imageName:@"ic_bike_route" routerType:routing::RouterType::Bicycle];
|
||||
[self addProgress:self.pedestrian
|
||||
imageName:@"ic_walk"
|
||||
routerType:routing::RouterType::Pedestrian];
|
||||
[self addProgress:self.bicycle
|
||||
imageName:@"ic_bike_route"
|
||||
routerType:routing::RouterType::Bicycle];
|
||||
}
|
||||
|
||||
- (void)addProgress:(UIView *)parentView imageName:(NSString *)imageName routerType:(routing::RouterType)routerType
|
||||
- (void)addProgress:(UIView *)parentView
|
||||
imageName:(NSString *)imageName
|
||||
routerType:(routing::RouterType)routerType
|
||||
{
|
||||
MWMCircularProgress * progress = [[MWMCircularProgress alloc] initWithParentView:parentView];
|
||||
[progress
|
||||
setImage:[UIImage imageNamed:imageName]
|
||||
forStates:{MWMCircularProgressStateNormal, MWMCircularProgressStateFailed,
|
||||
MWMCircularProgressStateSelected, MWMCircularProgressStateProgress,
|
||||
MWMCircularProgressStateSpinner, MWMCircularProgressStateCompleted}];
|
||||
[progress setImage:[UIImage imageNamed:imageName]
|
||||
forStates:{MWMCircularProgressStateNormal, MWMCircularProgressStateFailed,
|
||||
MWMCircularProgressStateSelected, MWMCircularProgressStateProgress,
|
||||
MWMCircularProgressStateSpinner, MWMCircularProgressStateCompleted}];
|
||||
progress.delegate = self;
|
||||
m_progresses[routerType] = progress;
|
||||
}
|
||||
|
||||
- (void)didMoveToSuperview
|
||||
{
|
||||
[self setupActualHeight];
|
||||
}
|
||||
|
||||
- (void)didMoveToSuperview { [self setupActualHeight]; }
|
||||
- (void)addToView:(UIView *)superview
|
||||
{
|
||||
[super addToView:superview];
|
||||
|
@ -88,20 +89,19 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
- (void)configureWithEntity:(MWMNavigationDashboardEntity *)entity
|
||||
{
|
||||
NSString * eta = [NSDateFormatter estimatedArrivalTimeWithSeconds:@(entity.timeToTarget)];
|
||||
NSString * resultString = [NSString stringWithFormat:@"%@ • %@ %@",
|
||||
eta,
|
||||
entity.targetDistance,
|
||||
entity.targetUnits];
|
||||
NSMutableAttributedString * result = [[NSMutableAttributedString alloc] initWithString:resultString];
|
||||
NSString * resultString =
|
||||
[NSString stringWithFormat:@"%@ • %@ %@", eta, entity.targetDistance, entity.targetUnits];
|
||||
NSMutableAttributedString * result =
|
||||
[[NSMutableAttributedString alloc] initWithString:resultString];
|
||||
[result addAttributes:self.etaAttributes range:NSMakeRange(0, eta.length)];
|
||||
self.resultLabel.attributedText = result;
|
||||
if (!IPAD)
|
||||
return;
|
||||
|
||||
NSString * arriveStr = [NSDateFormatter localizedStringFromDate:[[NSDate date]
|
||||
dateByAddingTimeInterval:entity.timeToTarget]
|
||||
dateStyle:NSDateFormatterNoStyle
|
||||
timeStyle:NSDateFormatterShortStyle];
|
||||
NSString * arriveStr = [NSDateFormatter
|
||||
localizedStringFromDate:[[NSDate date] dateByAddingTimeInterval:entity.timeToTarget]
|
||||
dateStyle:NSDateFormatterNoStyle
|
||||
timeStyle:NSDateFormatterShortStyle];
|
||||
self.arriveLabel.text = [NSString stringWithFormat:L(@"routing_arrive"), arriveStr.UTF8String];
|
||||
}
|
||||
|
||||
|
@ -164,21 +164,19 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
{
|
||||
[self layoutIfNeeded];
|
||||
self.statusBoxHeight.constant = 76.;
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.arriveLabel.alpha = 1.;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
self.completeImageView.hidden = NO;
|
||||
}];
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.arriveLabel.alpha = 1.;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
self.completeImageView.hidden = NO;
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)iPadNotReady
|
||||
|
@ -187,17 +185,13 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
self.arriveLabel.alpha = 0.;
|
||||
[self layoutIfNeeded];
|
||||
self.statusBoxHeight.constant = 56.;
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)reloadData
|
||||
{
|
||||
[self.collectionView reloadData];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)reloadData { [self.collectionView reloadData]; }
|
||||
- (void)selectRouter:(routing::RouterType)routerType
|
||||
{
|
||||
for (auto const & progress : m_progresses)
|
||||
|
@ -245,21 +239,18 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
[router rebuildWithBestRouter:NO];
|
||||
switch (routerType)
|
||||
{
|
||||
case routing::RouterType::Vehicle:
|
||||
[Statistics
|
||||
logEvent:kStatPointToPoint
|
||||
withParameters:@{kStatAction : kStatChangeRoutingMode, kStatValue : kStatVehicle}];
|
||||
break;
|
||||
case routing::RouterType::Pedestrian:
|
||||
[Statistics
|
||||
logEvent:kStatPointToPoint
|
||||
withParameters:@{kStatAction : kStatChangeRoutingMode, kStatValue : kStatPedestrian}];
|
||||
break;
|
||||
case routing::RouterType::Bicycle:
|
||||
[Statistics
|
||||
logEvent:kStatPointToPoint
|
||||
withParameters:@{kStatAction : kStatChangeRoutingMode, kStatValue : kStatBicycle}];
|
||||
break;
|
||||
case routing::RouterType::Vehicle:
|
||||
[Statistics logEvent:kStatPointToPoint
|
||||
withParameters:@{kStatAction : kStatChangeRoutingMode, kStatValue : kStatVehicle}];
|
||||
break;
|
||||
case routing::RouterType::Pedestrian:
|
||||
[Statistics logEvent:kStatPointToPoint
|
||||
withParameters:@{kStatAction : kStatChangeRoutingMode, kStatValue : kStatPedestrian}];
|
||||
break;
|
||||
case routing::RouterType::Bicycle:
|
||||
[Statistics logEvent:kStatPointToPoint
|
||||
withParameters:@{kStatAction : kStatChangeRoutingMode, kStatValue : kStatBicycle}];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,22 +268,25 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
|
||||
- (CGFloat)visibleHeight
|
||||
{
|
||||
return self.planningRouteViewHeight.constant + self.planningContainerHeight.constant + kAdditionalHeight;
|
||||
return self.planningRouteViewHeight.constant + self.planningContainerHeight.constant +
|
||||
kAdditionalHeight;
|
||||
}
|
||||
|
||||
- (IBAction)extendTap
|
||||
{
|
||||
BOOL const isExtended = !self.extendButton.selected;
|
||||
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatExpand)
|
||||
withParameters:@{kStatValue : (isExtended ? kStatYes : kStatNo)}];
|
||||
withParameters:@{kStatValue : (isExtended ? kStatYes : kStatNo)}];
|
||||
self.extendButton.selected = isExtended;
|
||||
[self layoutIfNeeded];
|
||||
[self setupActualHeight];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.arrowImageView.transform = isExtended ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformIdentity;
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.arrowImageView.transform = isExtended
|
||||
? CGAffineTransformMakeRotation(M_PI)
|
||||
: CGAffineTransformIdentity;
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setupActualHeight
|
||||
|
@ -313,7 +307,8 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
CGFloat const selfHeight = planningRouteViewHeight + self.planningContainerHeight.constant;
|
||||
self.defaultHeight = selfHeight;
|
||||
self.height = selfHeight;
|
||||
[self.dashboardManager.delegate routePreviewDidChangeFrame:{self.origin, {self.width, selfHeight + kAdditionalHeight}}];
|
||||
[self.dashboardManager.delegate
|
||||
routePreviewDidChangeFrame:{self.origin, {self.width, selfHeight + kAdditionalHeight}}];
|
||||
}
|
||||
|
||||
- (void)snapshotCell:(MWMRoutePointCell *)cell
|
||||
|
@ -337,8 +332,10 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
|
||||
- (NSDictionary *)etaAttributes
|
||||
{
|
||||
return @{NSForegroundColorAttributeName : UIColor.blackPrimaryText,
|
||||
NSFontAttributeName : UIFont.medium17};
|
||||
return @{
|
||||
NSForegroundColorAttributeName : UIColor.blackPrimaryText,
|
||||
NSFontAttributeName : UIFont.medium17
|
||||
};
|
||||
}
|
||||
|
||||
#pragma mark - MWMRoutePointCellDelegate
|
||||
|
@ -360,12 +357,12 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
self.isNeedToMove = NO;
|
||||
self.indexPathOfMovingCell = [self.collectionView indexPathForCell:cell];
|
||||
[self snapshotCell:cell];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
cell.contentView.alpha = 0.;
|
||||
CGFloat const scaleY = 1.05;
|
||||
self.movingCellImage.transform = CGAffineTransformMakeScale(1., scaleY);
|
||||
}];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
cell.contentView.alpha = 0.;
|
||||
CGFloat const scaleY = 1.05;
|
||||
self.movingCellImage.transform = CGAffineTransformMakeScale(1., scaleY);
|
||||
}];
|
||||
}
|
||||
|
||||
if (pan.state == UIGestureRecognizerStateChanged)
|
||||
|
@ -377,11 +374,12 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
if (self.isNeedToMove)
|
||||
return;
|
||||
self.isNeedToMove = YES;
|
||||
[self.collectionView performBatchUpdates:^
|
||||
{
|
||||
[self.collectionView moveItemAtIndexPath:finalIndexPath toIndexPath:self.indexPathOfMovingCell];
|
||||
[self.collectionView performBatchUpdates:^{
|
||||
[self.collectionView moveItemAtIndexPath:finalIndexPath
|
||||
toIndexPath:self.indexPathOfMovingCell];
|
||||
self.indexPathOfMovingCell = finalIndexPath;
|
||||
} completion:nil];
|
||||
}
|
||||
completion:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -397,15 +395,14 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
if (self.isNeedToMove)
|
||||
{
|
||||
cell.contentView.alpha = 1.;
|
||||
[self.collectionView performBatchUpdates:^
|
||||
{
|
||||
[self.collectionView moveItemAtIndexPath:self.indexPathOfMovingCell toIndexPath:finalIndexPath];
|
||||
[self.collectionView performBatchUpdates:^{
|
||||
[self.collectionView moveItemAtIndexPath:self.indexPathOfMovingCell
|
||||
toIndexPath:finalIndexPath];
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
[self.movingCellImage removeFromSuperview];
|
||||
self.movingCellImage.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
completion:^(BOOL finished) {
|
||||
[self.movingCellImage removeFromSuperview];
|
||||
self.movingCellImage.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -421,20 +418,24 @@ static CGFloat constexpr kAdditionalHeight = 20.;
|
|||
|
||||
#pragma mark - UICollectionView
|
||||
|
||||
@interface MWMRoutePreview (UICollectionView) <UICollectionViewDataSource, UICollectionViewDelegate>
|
||||
@interface MWMRoutePreview (UICollectionView)<UICollectionViewDataSource, UICollectionViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMRoutePreview (UICollectionView)
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView
|
||||
numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
|
||||
cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMRoutePointCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[MWMRoutePointCell className] forIndexPath:indexPath];
|
||||
MWMRoutePointCell * cell =
|
||||
[collectionView dequeueReusableCellWithReuseIdentifier:[MWMRoutePointCell className]
|
||||
forIndexPath:indexPath];
|
||||
cell.number.text = @(indexPath.row + 1).stringValue;
|
||||
if (indexPath.row == 0)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,9 @@
|
|||
#import "LocalNotificationManager.h"
|
||||
#import "CLLocation+Mercator.h"
|
||||
#import "Common.h"
|
||||
#import "LocalNotificationManager.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
#import "TimeUtils.h"
|
||||
|
||||
|
@ -24,16 +24,17 @@ NSString * const kDownloadMapCountryId = @"DownloadMapCountryId";
|
|||
|
||||
NSString * const kFlagsKey = @"DownloadMapNotificationFlags";
|
||||
|
||||
NSTimeInterval constexpr kRepeatedNotificationIntervalInSeconds = 3 * 30 * 24 * 60 * 60; // three months
|
||||
} // namespace
|
||||
NSTimeInterval constexpr kRepeatedNotificationIntervalInSeconds =
|
||||
3 * 30 * 24 * 60 * 60; // three months
|
||||
} // namespace
|
||||
|
||||
using namespace storage;
|
||||
|
||||
@interface LocalNotificationManager () <CLLocationManagerDelegate, UIAlertViewDelegate>
|
||||
@interface LocalNotificationManager ()<CLLocationManagerDelegate, UIAlertViewDelegate>
|
||||
|
||||
@property (nonatomic) CLLocationManager * locationManager;
|
||||
@property (copy, nonatomic) CompletionHandler downloadMapCompletionHandler;
|
||||
@property (weak, nonatomic) NSTimer * timer;
|
||||
@property(nonatomic) CLLocationManager * locationManager;
|
||||
@property(copy, nonatomic) CompletionHandler downloadMapCompletionHandler;
|
||||
@property(weak, nonatomic) NSTimer * timer;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -43,18 +44,13 @@ using namespace storage;
|
|||
{
|
||||
static LocalNotificationManager * manager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
dispatch_once(&onceToken, ^{
|
||||
manager = [[self alloc] init];
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
_locationManager.delegate = nil;
|
||||
}
|
||||
|
||||
- (void)dealloc { _locationManager.delegate = nil; }
|
||||
- (void)processNotification:(UILocalNotification *)notification onLaunch:(BOOL)onLaunch
|
||||
{
|
||||
NSDictionary * userInfo = [notification userInfo];
|
||||
|
@ -73,10 +69,11 @@ using namespace storage;
|
|||
kStatFrom : kStatMap,
|
||||
kStatScenario : kStatDownload
|
||||
}];
|
||||
[MWMStorage downloadNode:countryId alertController:mapViewController.alertController onSuccess:^
|
||||
{
|
||||
GetFramework().ShowNode(countryId);
|
||||
}];
|
||||
[MWMStorage downloadNode:countryId
|
||||
alertController:mapViewController.alertController
|
||||
onSuccess:^{
|
||||
GetFramework().ShowNode(countryId);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +111,8 @@ using namespace storage;
|
|||
NSDictionary<NSString *, NSDate *> * flags = [ud objectForKey:kFlagsKey];
|
||||
NSDate * lastShowDate = flags[countryId];
|
||||
return !lastShowDate ||
|
||||
[[NSDate date] timeIntervalSinceDate:lastShowDate] > kRepeatedNotificationIntervalInSeconds;
|
||||
[[NSDate date] timeIntervalSinceDate:lastShowDate] >
|
||||
kRepeatedNotificationIntervalInSeconds;
|
||||
}
|
||||
|
||||
- (void)markNotificationShownForCountryId:(NSString *)countryId
|
||||
|
@ -166,7 +164,8 @@ using namespace storage;
|
|||
NSString * flurryEventName = @"'Download Map' Notification Didn't Schedule";
|
||||
UIBackgroundFetchResult result = UIBackgroundFetchResultNoData;
|
||||
|
||||
BOOL const inBackground = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
|
||||
BOOL const inBackground =
|
||||
[UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
|
||||
BOOL const onWiFi = (Platform::ConnectionStatus() == Platform::EConnectionType::CONNECTION_WIFI);
|
||||
if (inBackground && onWiFi)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#import "MWMLocationManager.h"
|
||||
#import "Common.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMController.h"
|
||||
#import "MWMLocationManager.h"
|
||||
#import "MWMLocationPredictor.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
@ -132,31 +132,31 @@ BOOL keepRunningInBackground()
|
|||
|
||||
void sendInfoToFramework(dispatch_block_t block)
|
||||
{
|
||||
MapsAppDelegate * delegate = static_cast<MapsAppDelegate *>(UIApplication.sharedApplication.delegate);
|
||||
MapsAppDelegate * delegate =
|
||||
static_cast<MapsAppDelegate *>(UIApplication.sharedApplication.delegate);
|
||||
if (delegate.isDrapeEngineCreated)
|
||||
{
|
||||
block();
|
||||
}
|
||||
else
|
||||
{
|
||||
runAsyncOnMainQueue(^
|
||||
{
|
||||
runAsyncOnMainQueue(^{
|
||||
sendInfoToFramework(block);
|
||||
});
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@interface MWMLocationManager () <CLLocationManagerDelegate>
|
||||
@interface MWMLocationManager ()<CLLocationManagerDelegate>
|
||||
|
||||
@property (nonatomic) BOOL started;
|
||||
@property (nonatomic) CLLocationManager * locationManager;
|
||||
@property (nonatomic) GeoMode geoMode;
|
||||
@property (nonatomic) CLHeading * lastHeadingInfo;
|
||||
@property (nonatomic) CLLocation * lastLocationInfo;
|
||||
@property (nonatomic) location::TLocationError lastLocationStatus;
|
||||
@property (nonatomic) MWMLocationPredictor * predictor;
|
||||
@property (nonatomic) TObservers * observers;
|
||||
@property(nonatomic) BOOL started;
|
||||
@property(nonatomic) CLLocationManager * locationManager;
|
||||
@property(nonatomic) GeoMode geoMode;
|
||||
@property(nonatomic) CLHeading * lastHeadingInfo;
|
||||
@property(nonatomic) CLLocation * lastLocationInfo;
|
||||
@property(nonatomic) location::TLocationError lastLocationStatus;
|
||||
@property(nonatomic) MWMLocationPredictor * predictor;
|
||||
@property(nonatomic) TObservers * observers;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -168,7 +168,9 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
{
|
||||
static MWMLocationManager * manager;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{ manager = [[super alloc] initManager]; });
|
||||
dispatch_once(&onceToken, ^{
|
||||
manager = [[super alloc] initManager];
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
@ -184,8 +186,7 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
|
||||
+ (void)addObserver:(TObserver)observer
|
||||
{
|
||||
runAsyncOnMainQueue(^
|
||||
{
|
||||
runAsyncOnMainQueue(^{
|
||||
MWMLocationManager * manager = [MWMLocationManager manager];
|
||||
[manager.observers addObject:observer];
|
||||
[manager processLocationUpdate:manager.lastLocationInfo];
|
||||
|
@ -194,8 +195,7 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
|
||||
+ (void)removeObserver:(TObserver)observer
|
||||
{
|
||||
runAsyncOnMainQueue(^
|
||||
{
|
||||
runAsyncOnMainQueue(^{
|
||||
[[MWMLocationManager manager].observers removeObject:observer];
|
||||
});
|
||||
}
|
||||
|
@ -247,11 +247,10 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
|
||||
- (void)processLocationStatus:(location::TLocationError)locationError
|
||||
{
|
||||
// if (self.lastLocationStatus == locationError)
|
||||
// return;
|
||||
// if (self.lastLocationStatus == locationError)
|
||||
// return;
|
||||
self.lastLocationStatus = locationError;
|
||||
sendInfoToFramework(^
|
||||
{
|
||||
sendInfoToFramework(^{
|
||||
if (self.lastLocationStatus != location::TLocationError::ENoError)
|
||||
GetFramework().OnLocationError(self.lastLocationStatus);
|
||||
});
|
||||
|
@ -265,8 +264,7 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
- (void)processHeadingUpdate:(CLHeading *)headingInfo
|
||||
{
|
||||
self.lastHeadingInfo = headingInfo;
|
||||
sendInfoToFramework(^
|
||||
{
|
||||
sendInfoToFramework(^{
|
||||
GetFramework().OnCompassUpdate(compassInfoFromHeading(self.lastHeadingInfo));
|
||||
});
|
||||
location::CompassInfo const compassInfo = compassInfoFromHeading(headingInfo);
|
||||
|
@ -293,10 +291,7 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
- (void)onLocationUpdate:(location::GpsInfo const &)gpsInfo
|
||||
{
|
||||
GpsTracker::Instance().OnLocationUpdated(gpsInfo);
|
||||
sendInfoToFramework([gpsInfo]
|
||||
{
|
||||
GetFramework().OnLocationUpdate(gpsInfo);
|
||||
});
|
||||
sendInfoToFramework([gpsInfo] { GetFramework().OnLocationUpdate(gpsInfo); });
|
||||
for (TObserver observer in self.observers)
|
||||
{
|
||||
if ([observer respondsToSelector:@selector(onLocationUpdate:)])
|
||||
|
@ -311,17 +306,16 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
_lastLocationStatus = lastLocationStatus;
|
||||
switch (lastLocationStatus)
|
||||
{
|
||||
case location::ENoError:
|
||||
break;
|
||||
case location::ENotSupported:
|
||||
[[MWMAlertViewController activeAlertController] presentLocationServiceNotSupportedAlert];
|
||||
break;
|
||||
case location::EDenied:
|
||||
[[MWMAlertViewController activeAlertController] presentLocationAlert];
|
||||
break;
|
||||
case location::EGPSIsOff:
|
||||
// iOS shows its own alert.
|
||||
break;
|
||||
case location::ENoError: break;
|
||||
case location::ENotSupported:
|
||||
[[MWMAlertViewController activeAlertController] presentLocationServiceNotSupportedAlert];
|
||||
break;
|
||||
case location::EDenied:
|
||||
[[MWMAlertViewController activeAlertController] presentLocationAlert];
|
||||
break;
|
||||
case location::EGPSIsOff:
|
||||
// iOS shows its own alert.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,34 +331,22 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
{
|
||||
switch (f.GetRouter())
|
||||
{
|
||||
case routing::RouterType::Vehicle:
|
||||
manager.geoMode = GeoMode::VehicleRouting;
|
||||
break;
|
||||
case routing::RouterType::Pedestrian:
|
||||
manager.geoMode = GeoMode::PedestrianRouting;
|
||||
break;
|
||||
case routing::RouterType::Bicycle:
|
||||
manager.geoMode = GeoMode::BicycleRouting;
|
||||
break;
|
||||
case routing::RouterType::Vehicle: manager.geoMode = GeoMode::VehicleRouting; break;
|
||||
case routing::RouterType::Pedestrian: manager.geoMode = GeoMode::PedestrianRouting; break;
|
||||
case routing::RouterType::Bicycle: manager.geoMode = GeoMode::BicycleRouting; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case location::EMyPositionMode::PendingPosition:
|
||||
manager.geoMode = GeoMode::Pending;
|
||||
break;
|
||||
case location::EMyPositionMode::NotFollowNoPosition:
|
||||
case location::EMyPositionMode::NotFollow:
|
||||
manager.geoMode = GeoMode::NotInPosition;
|
||||
break;
|
||||
case location::EMyPositionMode::Follow:
|
||||
manager.geoMode = GeoMode::InPosition;
|
||||
break;
|
||||
case location::EMyPositionMode::FollowAndRotate:
|
||||
manager.geoMode = GeoMode::FollowAndRotate;
|
||||
break;
|
||||
case location::EMyPositionMode::PendingPosition: manager.geoMode = GeoMode::Pending; break;
|
||||
case location::EMyPositionMode::NotFollowNoPosition:
|
||||
case location::EMyPositionMode::NotFollow: manager.geoMode = GeoMode::NotInPosition; break;
|
||||
case location::EMyPositionMode::Follow: manager.geoMode = GeoMode::InPosition; break;
|
||||
case location::EMyPositionMode::FollowAndRotate:
|
||||
manager.geoMode = GeoMode::FollowAndRotate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,10 +358,10 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
if (!_predictor)
|
||||
{
|
||||
__weak MWMLocationManager * weakSelf = self;
|
||||
_predictor = [[MWMLocationPredictor alloc] initWithOnPredictionBlock:^(location::GpsInfo const & gpsInfo)
|
||||
{
|
||||
[weakSelf onLocationUpdate:gpsInfo];
|
||||
}];
|
||||
_predictor = [[MWMLocationPredictor alloc]
|
||||
initWithOnPredictionBlock:^(location::GpsInfo const & gpsInfo) {
|
||||
[weakSelf onLocationUpdate:gpsInfo];
|
||||
}];
|
||||
}
|
||||
return _predictor;
|
||||
}
|
||||
|
@ -388,7 +370,8 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
|
||||
- (void)orientationChanged
|
||||
{
|
||||
self.locationManager.headingOrientation = (CLDeviceOrientation)[UIDevice currentDevice].orientation;
|
||||
self.locationManager.headingOrientation =
|
||||
(CLDeviceOrientation)[UIDevice currentDevice].orientation;
|
||||
}
|
||||
|
||||
- (void)batteryStateChangedNotification:(NSNotification *)notification
|
||||
|
@ -406,19 +389,15 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
CLLocationManager * locationManager = self.locationManager;
|
||||
switch (geoMode)
|
||||
{
|
||||
case GeoMode::Pending:
|
||||
case GeoMode::InPosition:
|
||||
case GeoMode::NotInPosition:
|
||||
case GeoMode::FollowAndRotate:
|
||||
locationManager.activityType = CLActivityTypeOther;
|
||||
break;
|
||||
case GeoMode::VehicleRouting:
|
||||
locationManager.activityType = CLActivityTypeAutomotiveNavigation;
|
||||
break;
|
||||
case GeoMode::PedestrianRouting:
|
||||
case GeoMode::BicycleRouting:
|
||||
locationManager.activityType = CLActivityTypeFitness;
|
||||
break;
|
||||
case GeoMode::Pending:
|
||||
case GeoMode::InPosition:
|
||||
case GeoMode::NotInPosition:
|
||||
case GeoMode::FollowAndRotate: locationManager.activityType = CLActivityTypeOther; break;
|
||||
case GeoMode::VehicleRouting:
|
||||
locationManager.activityType = CLActivityTypeAutomotiveNavigation;
|
||||
break;
|
||||
case GeoMode::PedestrianRouting:
|
||||
case GeoMode::BicycleRouting: locationManager.activityType = CLActivityTypeFitness; break;
|
||||
}
|
||||
[self refreshGeoModeSettings];
|
||||
}
|
||||
|
@ -426,10 +405,12 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
- (void)refreshGeoModeSettings
|
||||
{
|
||||
UIDeviceBatteryState const state = [UIDevice currentDevice].batteryState;
|
||||
BOOL const isCharging = (state == UIDeviceBatteryStateCharging || state == UIDeviceBatteryStateFull);
|
||||
BOOL const isCharging =
|
||||
(state == UIDeviceBatteryStateCharging || state == UIDeviceBatteryStateFull);
|
||||
GeoModeSettings const settings = kGeoSettings.at(self.geoMode);
|
||||
CLLocationManager * locationManager = self.locationManager;
|
||||
locationManager.desiredAccuracy = isCharging ? settings.accuracy.charging : settings.accuracy.battery;
|
||||
locationManager.desiredAccuracy =
|
||||
isCharging ? settings.accuracy.charging : settings.accuracy.battery;
|
||||
locationManager.distanceFilter = settings.distanceFilter;
|
||||
}
|
||||
|
||||
|
@ -453,7 +434,8 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
[self processHeadingUpdate:heading];
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations
|
||||
- (void)locationManager:(CLLocationManager *)manager
|
||||
didUpdateLocations:(NSArray<CLLocation *> *)locations
|
||||
{
|
||||
CLLocation * location = locations.lastObject;
|
||||
// According to documentation, lat and lon are valid only if horizontalAccuracy is non-negative.
|
||||
|
@ -482,23 +464,32 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
{
|
||||
_started = [self start];
|
||||
device.batteryMonitoringEnabled = YES;
|
||||
[notificationCenter addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(batteryStateChangedNotification:) name:UIDeviceBatteryStateDidChangeNotification object:nil];
|
||||
[notificationCenter addObserver:self
|
||||
selector:@selector(orientationChanged)
|
||||
name:UIDeviceOrientationDidChangeNotification
|
||||
object:nil];
|
||||
[notificationCenter addObserver:self
|
||||
selector:@selector(batteryStateChangedNotification:)
|
||||
name:UIDeviceBatteryStateDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
_started = NO;
|
||||
[self stop];
|
||||
device.batteryMonitoringEnabled = NO;
|
||||
[notificationCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
|
||||
[notificationCenter removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
|
||||
[notificationCenter removeObserver:self
|
||||
name:UIDeviceOrientationDidChangeNotification
|
||||
object:nil];
|
||||
[notificationCenter removeObserver:self
|
||||
name:UIDeviceBatteryStateDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)start
|
||||
{
|
||||
auto const doStart = ^
|
||||
{
|
||||
auto const doStart = ^{
|
||||
LOG(LINFO, ("startUpdatingLocation"));
|
||||
CLLocationManager * locationManager = self.locationManager;
|
||||
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
|
||||
|
@ -511,15 +502,11 @@ void sendInfoToFramework(dispatch_block_t block)
|
|||
{
|
||||
switch ([CLLocationManager authorizationStatus])
|
||||
{
|
||||
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
||||
case kCLAuthorizationStatusAuthorizedAlways:
|
||||
case kCLAuthorizationStatusNotDetermined:
|
||||
doStart();
|
||||
return YES;
|
||||
case kCLAuthorizationStatusRestricted:
|
||||
case kCLAuthorizationStatusDenied:
|
||||
[self processLocationStatus:location::EDenied];
|
||||
break;
|
||||
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
||||
case kCLAuthorizationStatusAuthorizedAlways:
|
||||
case kCLAuthorizationStatusNotDetermined: doStart(); return YES;
|
||||
case kCLAuthorizationStatusRestricted:
|
||||
case kCLAuthorizationStatusDenied: [self processLocationStatus:location::EDenied]; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#import "MWMPlacePageActionBar.h"
|
||||
#import "Common.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMActionBarButton.h"
|
||||
#import "MWMBasePlacePageView.h"
|
||||
#import "MWMPlacePageActionBar.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
|
@ -19,16 +19,16 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
|
||||
} // namespace
|
||||
|
||||
@interface MWMPlacePageActionBar () <MWMActionBarButtonDelegate, UIActionSheetDelegate>
|
||||
@interface MWMPlacePageActionBar ()<MWMActionBarButtonDelegate, UIActionSheetDelegate>
|
||||
{
|
||||
vector<EButton> m_visibleButtons;
|
||||
vector<EButton> m_additionalButtons;
|
||||
}
|
||||
|
||||
@property (weak, nonatomic) MWMPlacePageViewManager * placePageManager;
|
||||
@property (copy, nonatomic) IBOutletCollection(UIView) NSArray<UIView *> * buttons;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * separator;
|
||||
@property (nonatomic) BOOL isPrepareRouteMode;
|
||||
@property(weak, nonatomic) MWMPlacePageViewManager * placePageManager;
|
||||
@property(copy, nonatomic) IBOutletCollection(UIView) NSArray<UIView *> * buttons;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * separator;
|
||||
@property(nonatomic) BOOL isPrepareRouteMode;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -36,8 +36,9 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
|
||||
+ (MWMPlacePageActionBar *)actionBarForPlacePageManager:(MWMPlacePageViewManager *)placePageManager
|
||||
{
|
||||
MWMPlacePageActionBar * bar = [[NSBundle.mainBundle
|
||||
loadNibNamed:kPlacePageActionBarNibName owner:nil options:nil] firstObject];
|
||||
MWMPlacePageActionBar * bar =
|
||||
[[NSBundle.mainBundle loadNibNamed:kPlacePageActionBarNibName owner:nil options:nil]
|
||||
firstObject];
|
||||
[bar configureWithPlacePageManager:placePageManager];
|
||||
return bar;
|
||||
}
|
||||
|
@ -172,35 +173,20 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case EButton::Api:
|
||||
[self.placePageManager apiBack];
|
||||
break;
|
||||
case EButton::Booking:
|
||||
[self.placePageManager book:NO];
|
||||
break;
|
||||
case EButton::Call:
|
||||
[self.placePageManager call];
|
||||
break;
|
||||
case EButton::Api: [self.placePageManager apiBack]; break;
|
||||
case EButton::Booking: [self.placePageManager book:NO]; break;
|
||||
case EButton::Call: [self.placePageManager call]; break;
|
||||
case EButton::Bookmark:
|
||||
if (self.isBookmark)
|
||||
[self.placePageManager removeBookmark];
|
||||
else
|
||||
[self.placePageManager addBookmark];
|
||||
break;
|
||||
case EButton::RouteFrom:
|
||||
[self.placePageManager routeFrom];
|
||||
break;
|
||||
case EButton::RouteTo:
|
||||
[self.placePageManager routeTo];
|
||||
break;
|
||||
case EButton::Share:
|
||||
[self.placePageManager share];
|
||||
break;
|
||||
case EButton::More:
|
||||
[self showActionSheet];
|
||||
break;
|
||||
case EButton::Spacer:
|
||||
break;
|
||||
case EButton::RouteFrom: [self.placePageManager routeFrom]; break;
|
||||
case EButton::RouteTo: [self.placePageManager routeTo]; break;
|
||||
case EButton::Share: [self.placePageManager share]; break;
|
||||
case EButton::More: [self showActionSheet]; break;
|
||||
case EButton::Spacer: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +199,7 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
BOOL const isTitleNotEmpty = entity.title.length > 0;
|
||||
NSString * title = isTitleNotEmpty ? entity.title : entity.subtitle;
|
||||
NSString * subtitle = isTitleNotEmpty ? entity.subtitle : nil;
|
||||
|
||||
|
||||
UIViewController * vc = static_cast<UIViewController *>([MapViewController controller]);
|
||||
NSMutableArray<NSString *> * titles = [@[] mutableCopy];
|
||||
for (auto const buttonType : m_additionalButtons)
|
||||
|
@ -227,7 +213,11 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
|
||||
if (isIOS7)
|
||||
{
|
||||
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:cancel destructiveButtonTitle:nil otherButtonTitles:nil];
|
||||
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:title
|
||||
delegate:self
|
||||
cancelButtonTitle:cancel
|
||||
destructiveButtonTitle:nil
|
||||
otherButtonTitles:nil];
|
||||
|
||||
for (NSString * title in titles)
|
||||
[actionSheet addButtonWithTitle:title];
|
||||
|
@ -236,22 +226,29 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
}
|
||||
else
|
||||
{
|
||||
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:title message:subtitle preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:cancel style:UIAlertActionStyleCancel handler:nil];
|
||||
UIAlertController * alertController =
|
||||
[UIAlertController alertControllerWithTitle:title
|
||||
message:subtitle
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction * cancelAction =
|
||||
[UIAlertAction actionWithTitle:cancel style:UIAlertActionStyleCancel handler:nil];
|
||||
|
||||
for (auto i = 0; i < titles.count; i++)
|
||||
{
|
||||
UIAlertAction * commonAction = [UIAlertAction actionWithTitle:titles[i] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action)
|
||||
{
|
||||
[self tapOnButtonWithType:self->m_additionalButtons[i]];
|
||||
}];
|
||||
UIAlertAction * commonAction =
|
||||
[UIAlertAction actionWithTitle:titles[i]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
[self tapOnButtonWithType:self->m_additionalButtons[i]];
|
||||
}];
|
||||
[alertController addAction:commonAction];
|
||||
}
|
||||
[alertController addAction:cancelAction];
|
||||
|
||||
if (IPAD)
|
||||
{
|
||||
UIPopoverPresentationController * popPresenter = [alertController popoverPresentationController];
|
||||
UIPopoverPresentationController * popPresenter =
|
||||
[alertController popoverPresentationController];
|
||||
popPresenter.sourceView = self.shareAnchor;
|
||||
popPresenter.sourceRect = self.shareAnchor.bounds;
|
||||
}
|
||||
|
@ -271,7 +268,6 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar";
|
|||
[self tapOnButtonWithType:m_additionalButtons[buttonIndex - 1]];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (void)layoutSubviews
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import "MWMPlacePageBookmarkCell.h"
|
||||
#import "Common.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMPlacePageBookmarkCell.h"
|
||||
#import "Statistics.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIFont+MapsMeFonts.h"
|
||||
|
@ -14,33 +14,36 @@ CGFloat const kTextViewLeft = 16.;
|
|||
|
||||
void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
||||
{
|
||||
if (!block) return;
|
||||
if (!block)
|
||||
return;
|
||||
|
||||
// We can't render html in the background queue in iOS7.
|
||||
if (isIOS7) block();
|
||||
else dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
|
||||
if (isIOS7)
|
||||
block();
|
||||
else
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface MWMPlacePageBookmarkCell () <UITextFieldDelegate, UITextViewDelegate>
|
||||
@interface MWMPlacePageBookmarkCell ()<UITextFieldDelegate, UITextViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextView * textView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * moreButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * editButton;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * separator;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * gradient;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * spinner;
|
||||
@property(weak, nonatomic) IBOutlet UITextView * textView;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * moreButton;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * editButton;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * separator;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * gradient;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * spinner;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewTopOffset;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewBottomOffset;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * moreButtonHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * textViewTopOffset;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * textViewBottomOffset;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * moreButtonHeight;
|
||||
|
||||
@property (weak, nonatomic) id<MWMPlacePageBookmarkDelegate> delegate;
|
||||
@property(weak, nonatomic) id<MWMPlacePageBookmarkDelegate> delegate;
|
||||
|
||||
@property (copy, nonatomic) NSAttributedString * attributedHtml;
|
||||
@property (copy, nonatomic) NSString * cachedHtml;
|
||||
@property(copy, nonatomic) NSAttributedString * attributedHtml;
|
||||
@property(copy, nonatomic) NSString * cachedHtml;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -65,9 +68,10 @@ void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
|||
|
||||
- (void)configEmptyDescription
|
||||
{
|
||||
self.textView.hidden = self.separator.hidden = self.gradient.hidden = self.moreButton.hidden = self.spinner.hidden = YES;
|
||||
self.textViewTopOffset.constant = self.textViewBottomOffset.constant = self.textViewHeight.constant =
|
||||
self.moreButtonHeight.constant = 0;
|
||||
self.textView.hidden = self.separator.hidden = self.gradient.hidden = self.moreButton.hidden =
|
||||
self.spinner.hidden = YES;
|
||||
self.textViewTopOffset.constant = self.textViewBottomOffset.constant =
|
||||
self.textViewHeight.constant = self.moreButtonHeight.constant = 0;
|
||||
}
|
||||
|
||||
- (void)startSpinner
|
||||
|
@ -77,7 +81,8 @@ void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
|||
NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
|
||||
NSString * postfix = [UIColor isNightMode] ? @"dark" : @"light";
|
||||
for (NSUInteger i = 0; i < animationImagesCount; ++i)
|
||||
animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i+1), postfix]];
|
||||
animationImages[i] =
|
||||
[UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i + 1), postfix]];
|
||||
|
||||
self.spinner.animationDuration = 0.8;
|
||||
self.spinner.animationImages = animationImages;
|
||||
|
@ -147,17 +152,20 @@ void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
|||
{
|
||||
[self configEmptyDescription];
|
||||
[self startSpinner];
|
||||
performRenderingInConcurrentQueue(^
|
||||
{
|
||||
performRenderingInConcurrentQueue(^{
|
||||
self.cachedHtml = text;
|
||||
NSDictionary<NSString *, id> * attr = @{NSForegroundColorAttributeName : [UIColor blackPrimaryText],
|
||||
NSFontAttributeName : [UIFont regular12]};
|
||||
NSDictionary<NSString *, id> * attr = @{
|
||||
NSForegroundColorAttributeName : [UIColor blackPrimaryText],
|
||||
NSFontAttributeName : [UIFont regular12]
|
||||
};
|
||||
NSError * error = nil;
|
||||
NSMutableAttributedString * str = [[NSMutableAttributedString alloc]
|
||||
initWithData:[text dataUsingEncoding:NSUnicodeStringEncoding]
|
||||
options:@{NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType}
|
||||
documentAttributes:nil
|
||||
error:&error];
|
||||
initWithData:[text dataUsingEncoding:NSUnicodeStringEncoding]
|
||||
options:@{
|
||||
NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType
|
||||
}
|
||||
documentAttributes:nil
|
||||
error:&error];
|
||||
if (error)
|
||||
{
|
||||
// If we failed while attempting to render html than just show plain text in bookmark.
|
||||
|
@ -169,8 +177,7 @@ void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
|||
[str addAttributes:attr range:{0, str.length}];
|
||||
self.attributedHtml = str;
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self stopSpinner];
|
||||
[self.delegate reloadBookmark];
|
||||
});
|
||||
|
@ -185,16 +192,8 @@ void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
|||
self.textView.scrollEnabled = isEnabled;
|
||||
}
|
||||
|
||||
- (IBAction)moreTap
|
||||
{
|
||||
[self.delegate moreTap];
|
||||
}
|
||||
|
||||
- (IBAction)editTap
|
||||
{
|
||||
[self.delegate editBookmarkTap];
|
||||
}
|
||||
|
||||
- (IBAction)moreTap { [self.delegate moreTap]; }
|
||||
- (IBAction)editTap { [self.delegate editBookmarkTap]; }
|
||||
- (CGFloat)cellHeight
|
||||
{
|
||||
return self.textViewTopOffset.constant + self.textViewHeight.constant +
|
||||
|
@ -204,7 +203,9 @@ void performRenderingInConcurrentQueue(TMWMVoidBlock block)
|
|||
|
||||
#pragma mark - UITextViewDelegate
|
||||
|
||||
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
|
||||
- (BOOL)textView:(UITextView *)textView
|
||||
shouldInteractWithURL:(NSURL *)URL
|
||||
inRange:(NSRange)characterRange
|
||||
{
|
||||
UIViewController * vc = static_cast<UIViewController *>([MapViewController controller]);
|
||||
[vc openUrl:URL];
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
|
@ -18,7 +18,6 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"
|
|||
|
||||
namespace
|
||||
{
|
||||
|
||||
NSUInteger gMetaFieldsMap[MWMPlacePageCellTypeCount] = {};
|
||||
|
||||
void putFields(NSUInteger eTypeValue, NSUInteger ppValue)
|
||||
|
@ -46,7 +45,7 @@ void initFieldsMap()
|
|||
ASSERT_EQUAL(gMetaFieldsMap[MWMPlacePageCellTypePostcode], Metadata::FMD_POSTCODE, ());
|
||||
ASSERT_EQUAL(gMetaFieldsMap[Metadata::FMD_MAXSPEED], 0, ());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@implementation MWMPlacePageEntity
|
||||
{
|
||||
|
@ -105,19 +104,16 @@ void initFieldsMap()
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case Metadata::FMD_URL:
|
||||
case Metadata::FMD_WEBSITE:
|
||||
case Metadata::FMD_PHONE_NUMBER:
|
||||
case Metadata::FMD_OPEN_HOURS:
|
||||
case Metadata::FMD_EMAIL:
|
||||
case Metadata::FMD_POSTCODE:
|
||||
[self setMetaField:gMetaFieldsMap[type] value:md.Get(type)];
|
||||
break;
|
||||
case Metadata::FMD_INTERNET:
|
||||
[self setMetaField:gMetaFieldsMap[type] value:L(@"WiFi_available").UTF8String];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case Metadata::FMD_URL:
|
||||
case Metadata::FMD_WEBSITE:
|
||||
case Metadata::FMD_PHONE_NUMBER:
|
||||
case Metadata::FMD_OPEN_HOURS:
|
||||
case Metadata::FMD_EMAIL:
|
||||
case Metadata::FMD_POSTCODE: [self setMetaField:gMetaFieldsMap[type] value:md.Get(type)]; break;
|
||||
case Metadata::FMD_INTERNET:
|
||||
[self setMetaField:gMetaFieldsMap[type] value:L(@"WiFi_available").UTF8String];
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,33 +130,39 @@ void initFieldsMap()
|
|||
currencyFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
|
||||
currencyFormatter.maximumFractionDigits = 0;
|
||||
string const currency = currencyFormatter.currencyCode.UTF8String;
|
||||
GetFramework().GetBookingApi().GetMinPrice(m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID),
|
||||
currency,
|
||||
[self, completion, failure, currency, currencyFormatter](string const & minPrice, string const & priceCurrency)
|
||||
{
|
||||
if (currency != priceCurrency)
|
||||
{
|
||||
failure();
|
||||
return;
|
||||
}
|
||||
NSNumberFormatter * decimalFormatter = [[NSNumberFormatter alloc] init];
|
||||
decimalFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
NSString * currencyString = [currencyFormatter stringFromNumber:
|
||||
[decimalFormatter numberFromString:
|
||||
[@(minPrice.c_str()) stringByReplacingOccurrencesOfString:@"."
|
||||
withString:decimalFormatter.decimalSeparator]]];
|
||||
NSString * currencyPattern = [L(@"place_page_starting_from") stringByReplacingOccurrencesOfString:@"%s"
|
||||
withString:@"%@"];
|
||||
self.bookingOnlinePrice = [NSString stringWithFormat:currencyPattern, currencyString];
|
||||
completion();
|
||||
});
|
||||
GetFramework().GetBookingApi().GetMinPrice(
|
||||
m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID), currency,
|
||||
[self, completion, failure, currency, currencyFormatter](string const & minPrice,
|
||||
string const & priceCurrency) {
|
||||
if (currency != priceCurrency)
|
||||
{
|
||||
failure();
|
||||
return;
|
||||
}
|
||||
NSNumberFormatter * decimalFormatter = [[NSNumberFormatter alloc] init];
|
||||
decimalFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
NSString * currencyString = [currencyFormatter
|
||||
stringFromNumber:
|
||||
[decimalFormatter
|
||||
numberFromString:
|
||||
[@(minPrice.c_str())
|
||||
stringByReplacingOccurrencesOfString:@"."
|
||||
withString:decimalFormatter
|
||||
.decimalSeparator]]];
|
||||
NSString * currencyPattern =
|
||||
[L(@"place_page_starting_from") stringByReplacingOccurrencesOfString:@"%s"
|
||||
withString:@"%@"];
|
||||
self.bookingOnlinePrice = [NSString stringWithFormat:currencyPattern, currencyString];
|
||||
completion();
|
||||
});
|
||||
}
|
||||
|
||||
- (void)configureBookmark
|
||||
{
|
||||
auto const bac = m_info.GetBookmarkAndCategory();
|
||||
BookmarkCategory * cat = GetFramework().GetBmCategory(bac.first);
|
||||
BookmarkData const & data = static_cast<Bookmark const *>(cat->GetUserMark(bac.second))->GetData();
|
||||
BookmarkData const & data =
|
||||
static_cast<Bookmark const *>(cat->GetUserMark(bac.second))->GetData();
|
||||
|
||||
self.bookmarkTitle = @(data.GetName().c_str());
|
||||
self.bookmarkCategory = @(m_info.GetBookmarkCategoryName().c_str());
|
||||
|
@ -185,25 +187,21 @@ void initFieldsMap()
|
|||
BOOL const navigationIsHidden = s == MWMNavigationDashboardStateHidden;
|
||||
switch (cellType)
|
||||
{
|
||||
case MWMPlacePageCellTypeName:
|
||||
return self.title;
|
||||
case MWMPlacePageCellTypeCoordinate:
|
||||
return [self coordinate];
|
||||
case MWMPlacePageCellTypeAddPlaceButton:
|
||||
return navigationIsHidden && m_info.ShouldShowAddPlace() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeBookmark:
|
||||
return m_info.IsBookmark() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeEditButton:
|
||||
// TODO(Vlad): It's a really strange way to "display" cell if returned text is not nil.
|
||||
return navigationIsHidden && m_info.ShouldShowEditPlace() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeAddBusinessButton:
|
||||
return navigationIsHidden && m_info.ShouldShowAddBusiness() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeWebsite:
|
||||
return m_info.IsSponsoredHotel() ? nil : [self getDefaultField:cellType];
|
||||
case MWMPlacePageCellTypeBookingMore:
|
||||
return m_info.IsSponsoredHotel() ? @(m_info.GetSponsoredDescriptionUrl().c_str()) : nil;
|
||||
default:
|
||||
return [self getDefaultField:cellType];
|
||||
case MWMPlacePageCellTypeName: return self.title;
|
||||
case MWMPlacePageCellTypeCoordinate: return [self coordinate];
|
||||
case MWMPlacePageCellTypeAddPlaceButton:
|
||||
return navigationIsHidden && m_info.ShouldShowAddPlace() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeBookmark: return m_info.IsBookmark() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeEditButton:
|
||||
// TODO(Vlad): It's a really strange way to "display" cell if returned text is not nil.
|
||||
return navigationIsHidden && m_info.ShouldShowEditPlace() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeAddBusinessButton:
|
||||
return navigationIsHidden && m_info.ShouldShowAddBusiness() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeWebsite:
|
||||
return m_info.IsSponsoredHotel() ? nil : [self getDefaultField:cellType];
|
||||
case MWMPlacePageCellTypeBookingMore:
|
||||
return m_info.IsSponsoredHotel() ? @(m_info.GetSponsoredDescriptionUrl().c_str()) : nil;
|
||||
default: return [self getDefaultField:cellType];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,66 +218,22 @@ void initFieldsMap()
|
|||
return url.empty() ? nil : [NSURL URLWithString:@(url.c_str())];
|
||||
}
|
||||
|
||||
- (place_page::Info const &)info
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
||||
- (FeatureID const &)featureID
|
||||
{
|
||||
return m_info.GetID();
|
||||
}
|
||||
|
||||
- (storage::TCountryId const &)countryId
|
||||
{
|
||||
return m_info.m_countryId;
|
||||
}
|
||||
|
||||
- (BOOL)isMyPosition
|
||||
{
|
||||
return m_info.IsMyPosition();
|
||||
}
|
||||
|
||||
- (BOOL)isBookmark
|
||||
{
|
||||
return m_info.IsBookmark();
|
||||
}
|
||||
|
||||
- (BOOL)isApi
|
||||
{
|
||||
return m_info.HasApiUrl();
|
||||
}
|
||||
|
||||
- (BOOL)isBooking
|
||||
{
|
||||
return m_info.IsSponsoredHotel();
|
||||
}
|
||||
|
||||
- (NSString * )hotelId
|
||||
- (place_page::Info const &)info { return m_info; }
|
||||
- (FeatureID const &)featureID { return m_info.GetID(); }
|
||||
- (storage::TCountryId const &)countryId { return m_info.m_countryId; }
|
||||
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
|
||||
- (BOOL)isBookmark { return m_info.IsBookmark(); }
|
||||
- (BOOL)isApi { return m_info.HasApiUrl(); }
|
||||
- (BOOL)isBooking { return m_info.IsSponsoredHotel(); }
|
||||
- (NSString *)hotelId
|
||||
{
|
||||
return self.isBooking ? @(m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID).c_str()) : nil;
|
||||
}
|
||||
|
||||
- (ms::LatLon)latlon
|
||||
{
|
||||
return m_info.GetLatLon();
|
||||
}
|
||||
|
||||
- (m2::PointD const &)mercator
|
||||
{
|
||||
return m_info.GetMercator();
|
||||
}
|
||||
|
||||
- (NSString *)apiURL
|
||||
{
|
||||
return @(m_info.GetApiUrl().c_str());
|
||||
}
|
||||
|
||||
- (string)titleForNewBookmark
|
||||
{
|
||||
return m_info.FormatNewBookmarkName();
|
||||
}
|
||||
|
||||
- (ms::LatLon)latlon { return m_info.GetLatLon(); }
|
||||
- (m2::PointD const &)mercator { return m_info.GetMercator(); }
|
||||
- (NSString *)apiURL { return @(m_info.GetApiUrl().c_str()); }
|
||||
- (string)titleForNewBookmark { return m_info.FormatNewBookmarkName(); }
|
||||
- (NSString *)coordinate
|
||||
{
|
||||
BOOL const useDMSFormat =
|
||||
|
@ -292,16 +246,8 @@ void initFieldsMap()
|
|||
|
||||
#pragma mark - Bookmark editing
|
||||
|
||||
- (void)setBac:(BookmarkAndCategory)bac
|
||||
{
|
||||
m_info.m_bac = bac;
|
||||
}
|
||||
|
||||
- (BookmarkAndCategory)bac
|
||||
{
|
||||
return m_info.GetBookmarkAndCategory();
|
||||
}
|
||||
|
||||
- (void)setBac:(BookmarkAndCategory)bac { m_info.m_bac = bac; }
|
||||
- (BookmarkAndCategory)bac { return m_info.GetBookmarkAndCategory(); }
|
||||
- (NSString *)bookmarkCategory
|
||||
{
|
||||
if (!_bookmarkCategory)
|
||||
|
@ -347,7 +293,8 @@ void initFieldsMap()
|
|||
|
||||
{
|
||||
BookmarkCategory::Guard guard(*category);
|
||||
Bookmark * bookmark = static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(self.bac.second));
|
||||
Bookmark * bookmark =
|
||||
static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(self.bac.second));
|
||||
if (!bookmark)
|
||||
return;
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
@interface MWMPlacePageViewManager : NSObject
|
||||
|
||||
@property (weak, nonatomic, readonly) MWMViewController * ownerViewController;
|
||||
@property (nonatomic, readonly) MWMPlacePageEntity * entity;
|
||||
@property (nonatomic) MWMPlacePageNavigationBar * iPhoneNavigationBar;
|
||||
@property (nonatomic) CGFloat topBound;
|
||||
@property (nonatomic) CGFloat leftBound;
|
||||
@property (nonatomic, readonly) BOOL isDirectionViewShown;
|
||||
@property(weak, nonatomic, readonly) MWMViewController * ownerViewController;
|
||||
@property(nonatomic, readonly) MWMPlacePageEntity * entity;
|
||||
@property(nonatomic) MWMPlacePageNavigationBar * iPhoneNavigationBar;
|
||||
@property(nonatomic) CGFloat topBound;
|
||||
@property(nonatomic) CGFloat leftBound;
|
||||
@property(nonatomic, readonly) BOOL isDirectionViewShown;
|
||||
|
||||
- (instancetype)initWithViewController:(MWMViewController *)viewController;
|
||||
- (void)showPlacePage:(place_page::Info const &)info;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#import "MWMPlacePageViewManager.h"
|
||||
#import "Common.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMActivityViewController.h"
|
||||
#import "MWMAPIBar.h"
|
||||
#import "MWMActivityViewController.h"
|
||||
#import "MWMBasePlacePageView.h"
|
||||
#import "MWMDirectionView.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMiPadPlacePage.h"
|
||||
#import "MWMiPhoneLandscapePlacePage.h"
|
||||
#import "MWMiPhonePortraitPlacePage.h"
|
||||
#import "MWMLocationHelpers.h"
|
||||
#import "MWMLocationManager.h"
|
||||
#import "MWMPlacePage.h"
|
||||
#import "MWMPlacePageActionBar.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageNavigationBar.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMiPadPlacePage.h"
|
||||
#import "MWMiPhoneLandscapePlacePage.h"
|
||||
#import "MWMiPhonePortraitPlacePage.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
@ -230,8 +230,7 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
withParameters:stat
|
||||
atLocation:[MWMLocationManager lastLocation]];
|
||||
|
||||
UIViewController * vc =
|
||||
static_cast<UIViewController *>([MapViewController controller]);
|
||||
UIViewController * vc = static_cast<UIViewController *>([MapViewController controller]);
|
||||
NSURL * url =
|
||||
isDescription
|
||||
? [NSURL URLWithString:[self.entity getCellValue:MWMPlacePageCellTypeBookingMore]]
|
||||
|
@ -325,11 +324,7 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
[self updateDistance];
|
||||
}
|
||||
|
||||
- (void)dragPlacePage:(CGRect)frame
|
||||
{
|
||||
[[MWMMapViewControlsManager manager] dragPlacePage:frame];
|
||||
}
|
||||
|
||||
- (void)dragPlacePage:(CGRect)frame { [[MWMMapViewControlsManager manager] dragPlacePage:frame]; }
|
||||
- (void)updateDistance
|
||||
{
|
||||
NSString * distance = [self distance];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import "MWMMapDownloaderViewController.h"
|
||||
#import "Common.h"
|
||||
#import "MWMMapDownloaderExtendedDataSource.h"
|
||||
#import "MWMMapDownloaderSearchDataSource.h"
|
||||
#import "MWMMapDownloaderViewController.h"
|
||||
#import "MWMNoMapsViewController.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIKitCategories.h"
|
||||
|
@ -13,21 +13,21 @@
|
|||
namespace
|
||||
{
|
||||
NSString * const kNoMapsSegue = @"MapDownloaderEmbedNoMapsSegue";
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
using namespace storage;
|
||||
|
||||
@interface MWMBaseMapDownloaderViewController ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITableView * tableView;
|
||||
@property(weak, nonatomic) IBOutlet UITableView * tableView;
|
||||
|
||||
@property (nonatomic) MWMMapDownloaderDataSource * dataSource;
|
||||
@property (nonatomic) MWMMapDownloaderDataSource * defaultDataSource;
|
||||
@property(nonatomic) MWMMapDownloaderDataSource * dataSource;
|
||||
@property(nonatomic) MWMMapDownloaderDataSource * defaultDataSource;
|
||||
|
||||
@property (nonatomic, readonly) NSString * parentCountryId;
|
||||
@property (nonatomic, readonly) mwm::DownloaderMode mode;
|
||||
@property(nonatomic, readonly) NSString * parentCountryId;
|
||||
@property(nonatomic, readonly) mwm::DownloaderMode mode;
|
||||
|
||||
@property (nonatomic) BOOL showAllMapsButtons;
|
||||
@property(nonatomic) BOOL showAllMapsButtons;
|
||||
|
||||
- (void)configViews;
|
||||
|
||||
|
@ -37,14 +37,14 @@ using namespace storage;
|
|||
|
||||
@end
|
||||
|
||||
@interface MWMMapDownloaderViewController () <UISearchBarDelegate, UIScrollViewDelegate>
|
||||
@interface MWMMapDownloaderViewController ()<UISearchBarDelegate, UIScrollViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * statusBarBackground;
|
||||
@property (weak, nonatomic) IBOutlet UISearchBar * searchBar;
|
||||
@property (weak, nonatomic) IBOutlet UIView * noMapsContainer;
|
||||
@property (nonatomic) MWMNoMapsViewController * noMapsController;
|
||||
@property(weak, nonatomic) IBOutlet UIView * statusBarBackground;
|
||||
@property(weak, nonatomic) IBOutlet UISearchBar * searchBar;
|
||||
@property(weak, nonatomic) IBOutlet UIView * noMapsContainer;
|
||||
@property(nonatomic) MWMNoMapsViewController * noMapsController;
|
||||
|
||||
@property (nonatomic) MWMMapDownloaderDataSource * searchDataSource;
|
||||
@property(nonatomic) MWMMapDownloaderDataSource * searchDataSource;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -142,24 +142,19 @@ using namespace storage;
|
|||
|
||||
#pragma mark - UIBarPositioningDelegate
|
||||
|
||||
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
|
||||
{
|
||||
return UIBarPositionTopAttached;
|
||||
}
|
||||
|
||||
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { return UIBarPositionTopAttached; }
|
||||
#pragma mark - Search
|
||||
|
||||
- (void)setupSearchParams
|
||||
{
|
||||
__weak auto weakSelf = self;
|
||||
m_searchParams.m_onResults = ^(DownloaderSearchResults const & results)
|
||||
{
|
||||
m_searchParams.m_onResults = ^(DownloaderSearchResults const & results) {
|
||||
__strong auto self = weakSelf;
|
||||
if (!self || results.m_endMarker)
|
||||
return;
|
||||
self.searchDataSource = [[MWMMapDownloaderSearchDataSource alloc] initWithSearchResults:results delegate:self];
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
self.searchDataSource =
|
||||
[[MWMMapDownloaderSearchDataSource alloc] initWithSearchResults:results delegate:self];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.dataSource = self.searchDataSource;
|
||||
[self reloadTable];
|
||||
});
|
||||
|
@ -175,11 +170,7 @@ using namespace storage;
|
|||
|
||||
#pragma mark - MWMNoMapsViewControllerProtocol
|
||||
|
||||
- (void)handleDownloadMapsAction
|
||||
{
|
||||
[self openAvailableMaps];
|
||||
}
|
||||
|
||||
- (void)handleDownloadMapsAction { [self openAvailableMaps]; }
|
||||
#pragma mark - Segue
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMNoMapsViewController.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
|
||||
@implementation MWMNoMapsViewController
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#import <MyTargetSDKCorp/MTRGNativeAppwallAd.h>
|
||||
#import "MWMMapDownloaderTypes.h"
|
||||
#import "MWMViewController.h"
|
||||
#import <MyTargetSDKCorp/MTRGNativeAppwallAd.h>
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
#include "indexer/map_style.hpp"
|
||||
|
||||
namespace search { struct AddressInfo; }
|
||||
namespace search
|
||||
{
|
||||
struct AddressInfo;
|
||||
}
|
||||
|
||||
@class MWMMapViewControlsManager;
|
||||
@class MWMAPIBar;
|
||||
|
@ -34,10 +37,10 @@ namespace search { struct AddressInfo; }
|
|||
|
||||
- (void)initialize;
|
||||
|
||||
@property (nonatomic) MTRGNativeAppwallAd * appWallAd;
|
||||
@property (nonatomic, readonly) BOOL isAppWallAdActive;
|
||||
@property(nonatomic) MTRGNativeAppwallAd * appWallAd;
|
||||
@property(nonatomic, readonly) BOOL isAppWallAdActive;
|
||||
|
||||
@property (nonatomic, readonly) MWMMapViewControlsManager * controlsManager;
|
||||
@property (nonatomic) MWMAPIBar * apiBar;
|
||||
@property(nonatomic, readonly) MWMMapViewControlsManager * controlsManager;
|
||||
@property(nonatomic) MWMAPIBar * apiBar;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#import "MapViewController.h"
|
||||
#import <MyTargetSDKCorp/MTRGManager_Corp.h>
|
||||
#import "BookmarksRootVC.h"
|
||||
#import "BookmarksVC.h"
|
||||
#import "Common.h"
|
||||
#import "EAGLView.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMAPIBar.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMAuthorizationCommon.h"
|
||||
#import "MWMAuthorizationLoginViewController.h"
|
||||
#import "MWMAuthorizationWebViewLoginViewController.h"
|
||||
|
@ -25,12 +25,12 @@
|
|||
#import "MWMStorage.h"
|
||||
#import "MWMTableViewController.h"
|
||||
#import "MWMWhatsNewBookingBicycleRoutingController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "RouteState.h"
|
||||
#import "Statistics.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIFont+MapsMeFonts.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
#import <MyTargetSDKCorp/MTRGManager_Corp.h>
|
||||
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
||||
|
@ -49,7 +49,8 @@
|
|||
#include "platform/platform.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
// If you have a "missing header error" here, then please run configure.sh script in the root repo folder.
|
||||
// If you have a "missing header error" here, then please run configure.sh script in the root repo
|
||||
// folder.
|
||||
#import "../../../private.h"
|
||||
|
||||
extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
|
||||
|
@ -59,8 +60,7 @@ extern NSString * const kMap2GoogleLoginSegue = @"Map2GoogleLogin";
|
|||
extern char const * kAdForbiddenSettingsKey;
|
||||
extern char const * kAdServerForbiddenKey;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, UserTouchesAction)
|
||||
{
|
||||
typedef NS_ENUM(NSUInteger, UserTouchesAction) {
|
||||
UserTouchesActionNone,
|
||||
UserTouchesActionDrag,
|
||||
UserTouchesActionScale
|
||||
|
@ -73,13 +73,14 @@ NSString * const kMigrationSegue = @"Map2MigrationSegue";
|
|||
NSString * const kEditorSegue = @"Map2EditorSegue";
|
||||
NSString * const kUDViralAlertWasShown = @"ViralAlertWasShown";
|
||||
|
||||
// The first launch after process started. Used to skip "Not follow, no position" state and to run locator.
|
||||
// The first launch after process started. Used to skip "Not follow, no position" state and to run
|
||||
// locator.
|
||||
BOOL gIsFirstMyPositionMode = YES;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@interface NSValueWrapper : NSObject
|
||||
|
||||
-(NSValue *)getInnerValue;
|
||||
- (NSValue *)getInnerValue;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -88,12 +89,8 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
NSValue * m_innerValue;
|
||||
}
|
||||
|
||||
-(NSValue *)getInnerValue
|
||||
{
|
||||
return m_innerValue;
|
||||
}
|
||||
|
||||
-(id)initWithValue:(NSValue *)value
|
||||
- (NSValue *)getInnerValue { return m_innerValue; }
|
||||
- (id)initWithValue:(NSValue *)value
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
|
@ -101,44 +98,31 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
return self;
|
||||
}
|
||||
|
||||
-(BOOL)isEqual:(id)anObject
|
||||
{
|
||||
return [anObject isMemberOfClass:[NSValueWrapper class]];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject { return [anObject isMemberOfClass:[NSValueWrapper class]]; }
|
||||
@end
|
||||
|
||||
@interface MapViewController ()<MTRGNativeAppwallAdDelegate,
|
||||
MWMFrameworkDrapeObserver, MWMFrameworkStorageObserver,
|
||||
MWMPageControllerProtocol>
|
||||
@interface MapViewController ()<MTRGNativeAppwallAdDelegate, MWMFrameworkDrapeObserver,
|
||||
MWMFrameworkStorageObserver, MWMPageControllerProtocol>
|
||||
|
||||
@property (nonatomic, readwrite) MWMMapViewControlsManager * controlsManager;
|
||||
@property (nonatomic) MWMBottomMenuState menuRestoreState;
|
||||
@property(nonatomic, readwrite) MWMMapViewControlsManager * controlsManager;
|
||||
@property(nonatomic) MWMBottomMenuState menuRestoreState;
|
||||
|
||||
@property (nonatomic) BOOL disableStandbyOnLocationStateMode;
|
||||
@property(nonatomic) BOOL disableStandbyOnLocationStateMode;
|
||||
|
||||
@property (nonatomic) UserTouchesAction userTouchesAction;
|
||||
@property (nonatomic) MWMPageController * pageViewController;
|
||||
@property (nonatomic) MWMMapDownloadDialog * downloadDialog;
|
||||
@property(nonatomic) UserTouchesAction userTouchesAction;
|
||||
@property(nonatomic) MWMPageController * pageViewController;
|
||||
@property(nonatomic) MWMMapDownloadDialog * downloadDialog;
|
||||
|
||||
@property (nonatomic) BOOL skipForceTouch;
|
||||
@property(nonatomic) BOOL skipForceTouch;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MapViewController
|
||||
|
||||
+ (MapViewController *)controller
|
||||
{
|
||||
return [MapsAppDelegate theApp].mapViewController;
|
||||
}
|
||||
|
||||
+ (MapViewController *)controller { return [MapsAppDelegate theApp].mapViewController; }
|
||||
#pragma mark - Map Navigation
|
||||
|
||||
- (void)dismissPlacePage
|
||||
{
|
||||
[self.controlsManager dismissPlacePage];
|
||||
}
|
||||
|
||||
- (void)dismissPlacePage { [self.controlsManager dismissPlacePage]; }
|
||||
- (void)onMapObjectDeselected:(bool)switchFullScreenMode
|
||||
{
|
||||
[self dismissPlacePage];
|
||||
|
@ -169,7 +153,9 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
e.SetSecondMaskedPointer(pointerIndex);
|
||||
}
|
||||
|
||||
- (void)sendTouchType:(df::TouchEvent::ETouchType)type withTouches:(NSSet *)touches andEvent:(UIEvent *)event
|
||||
- (void)sendTouchType:(df::TouchEvent::ETouchType)type
|
||||
withTouches:(NSSet *)touches
|
||||
andEvent:(UIEvent *)event
|
||||
{
|
||||
NSArray * allTouches = [[event allTouches] allObjects];
|
||||
if ([allTouches count] < 1)
|
||||
|
@ -236,14 +222,10 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
|
||||
#pragma mark - ViewController lifecycle
|
||||
|
||||
- (void)dealloc
|
||||
- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; }
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
return YES; // We support all orientations
|
||||
return YES; // We support all orientations
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
|
||||
|
@ -256,9 +238,10 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
- (void)viewWillTransitionToSize:(CGSize)size
|
||||
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
||||
{
|
||||
[self.alertController willRotateToInterfaceOrientation:(size.width > size.height) ?
|
||||
UIInterfaceOrientationLandscapeLeft : UIInterfaceOrientationPortrait
|
||||
duration:kDefaultAnimationDuration];
|
||||
[self.alertController willRotateToInterfaceOrientation:(size.width > size.height)
|
||||
? UIInterfaceOrientationLandscapeLeft
|
||||
: UIInterfaceOrientationPortrait
|
||||
duration:kDefaultAnimationDuration];
|
||||
[self.controlsManager viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
[self.pageViewController viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
}
|
||||
|
@ -269,20 +252,14 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
- (void)onTerminate
|
||||
{
|
||||
[(EAGLView *)self.view deallocateNative];
|
||||
}
|
||||
|
||||
- (void)onGetFocus:(BOOL)isOnFocus
|
||||
{
|
||||
[(EAGLView *)self.view setPresentAvailable:isOnFocus];
|
||||
}
|
||||
|
||||
- (void)onTerminate { [(EAGLView *)self.view deallocateNative]; }
|
||||
- (void)onGetFocus:(BOOL)isOnFocus { [(EAGLView *)self.view setPresentAvailable:isOnFocus]; }
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIDeviceOrientationDidChangeNotification
|
||||
object:nil];
|
||||
|
||||
self.controlsManager.menuState = self.menuRestoreState;
|
||||
|
||||
|
@ -321,15 +298,18 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
if (isIOS7)
|
||||
return;
|
||||
|
||||
Class<MWMWelcomeControllerProtocol> whatsNewClass = [MWMWhatsNewBookingBicycleRoutingController class];
|
||||
Class<MWMWelcomeControllerProtocol> whatsNewClass =
|
||||
[MWMWhatsNewBookingBicycleRoutingController class];
|
||||
BOOL const isFirstSession = [Alohalytics isFirstSession];
|
||||
Class<MWMWelcomeControllerProtocol> welcomeClass = isFirstSession ? [MWMFirstLaunchController class] : whatsNewClass;
|
||||
Class<MWMWelcomeControllerProtocol> welcomeClass =
|
||||
isFirstSession ? [MWMFirstLaunchController class] : whatsNewClass;
|
||||
|
||||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
if ([ud boolForKey:[welcomeClass udWelcomeWasShownKey]])
|
||||
return;
|
||||
|
||||
self.pageViewController = [MWMPageController pageControllerWithParent:self welcomeClass:welcomeClass];
|
||||
self.pageViewController =
|
||||
[MWMPageController pageControllerWithParent:self welcomeClass:welcomeClass];
|
||||
[self.pageViewController show];
|
||||
|
||||
[ud setBool:YES forKey:[whatsNewClass udWelcomeWasShownKey]];
|
||||
|
@ -348,7 +328,8 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
using namespace osm_auth_ios;
|
||||
if (!AuthorizationIsNeedCheck() || [ud objectForKey:kUDViralAlertWasShown] || !AuthorizationHaveCredentials())
|
||||
if (!AuthorizationIsNeedCheck() || [ud objectForKey:kUDViralAlertWasShown] ||
|
||||
!AuthorizationHaveCredentials())
|
||||
return;
|
||||
|
||||
if (osm::Editor::Instance().GetStats().m_edits.size() != 2)
|
||||
|
@ -367,7 +348,10 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
{
|
||||
[super viewWillDisappear:animated];
|
||||
self.menuRestoreState = self.controlsManager.menuState;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(orientationChanged:)
|
||||
name:UIDeviceOrientationDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)presentViewController:(UIViewController *)viewControllerToPresent
|
||||
|
@ -384,28 +368,21 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
[self willRotateToInterfaceOrientation:self.interfaceOrientation duration:0.];
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden
|
||||
{
|
||||
return self.apiBar.isVisible;
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden { return self.apiBar.isVisible; }
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
BOOL const isNightMode = [UIColor isNightMode];
|
||||
BOOL const isLight = !self.controlsManager.searchHidden ||
|
||||
self.controlsManager.menuState == MWMBottomMenuStateActive ||
|
||||
self.controlsManager.isDirectionViewShown ||
|
||||
(isNightMode &&
|
||||
self.controlsManager.navigationState != MWMNavigationDashboardStateHidden) ||
|
||||
MapsAppDelegate.theApp.routingPlaneMode != MWMRoutingPlaneModeNone;
|
||||
return (isLight || (!isLight && isNightMode)) ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (void)updateStatusBarStyle
|
||||
{
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
BOOL const isLight =
|
||||
!self.controlsManager.searchHidden ||
|
||||
self.controlsManager.menuState == MWMBottomMenuStateActive ||
|
||||
self.controlsManager.isDirectionViewShown ||
|
||||
(isNightMode && self.controlsManager.navigationState != MWMNavigationDashboardStateHidden) ||
|
||||
MapsAppDelegate.theApp.routingPlaneMode != MWMRoutingPlaneModeNone;
|
||||
return (isLight || (!isLight && isNightMode)) ? UIStatusBarStyleLightContent
|
||||
: UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (void)updateStatusBarStyle { [self setNeedsStatusBarAppearanceUpdate]; }
|
||||
- (id)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
NSLog(@"MapViewController initWithCoder Started");
|
||||
|
@ -421,11 +398,11 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
{
|
||||
Framework & f = GetFramework();
|
||||
// TODO: Review and improve this code.
|
||||
f.SetMapSelectionListeners([self](place_page::Info const & info) { [self onMapObjectSelected:info]; },
|
||||
[self](bool switchFullScreen) { [self onMapObjectDeselected:switchFullScreen]; });
|
||||
f.SetMapSelectionListeners(
|
||||
[self](place_page::Info const & info) { [self onMapObjectSelected:info]; },
|
||||
[self](bool switchFullScreen) { [self onMapObjectDeselected:switchFullScreen]; });
|
||||
// TODO: Review and improve this code.
|
||||
f.SetMyPositionModeListener([self](location::EMyPositionMode mode, bool routingActive)
|
||||
{
|
||||
f.SetMyPositionModeListener([self](location::EMyPositionMode mode, bool routingActive) {
|
||||
// TODO: Two global listeners are subscribed to the same event from the core.
|
||||
// Probably it's better to subscribe only wnen needed and usubscribe in other cases.
|
||||
// May be better solution would be multiobservers support in the C++ core.
|
||||
|
@ -440,15 +417,12 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
|
||||
#pragma mark - Open controllers
|
||||
|
||||
- (void)openMigration
|
||||
{
|
||||
[self performSegueWithIdentifier:kMigrationSegue sender:self];
|
||||
}
|
||||
|
||||
- (void)openMigration { [self performSegueWithIdentifier:kMigrationSegue sender:self]; }
|
||||
- (void)openBookmarks
|
||||
{
|
||||
BOOL const oneCategory = (GetFramework().GetBmCategoriesCount() == 1);
|
||||
MWMTableViewController * vc = oneCategory ? [[BookmarksVC alloc] initWithCategory:0] : [[BookmarksRootVC alloc] init];
|
||||
MWMTableViewController * vc =
|
||||
oneCategory ? [[BookmarksVC alloc] initWithCategory:0] : [[BookmarksRootVC alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
|
@ -463,10 +437,13 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
using namespace osm_auth_ios;
|
||||
auto const & featureID = self.controlsManager.placePageEntity.info.GetID();
|
||||
|
||||
[Statistics logEvent:kStatEditorEditStart withParameters:@{kStatEditorIsAuthenticated : @(AuthorizationHaveCredentials()),
|
||||
kStatIsOnline : Platform::IsConnected() ? kStatYes : kStatNo,
|
||||
kStatEditorMWMName : @(featureID.GetMwmName().c_str()),
|
||||
kStatEditorMWMVersion : @(featureID.GetMwmVersion())}];
|
||||
[Statistics logEvent:kStatEditorEditStart
|
||||
withParameters:@{
|
||||
kStatEditorIsAuthenticated : @(AuthorizationHaveCredentials()),
|
||||
kStatIsOnline : Platform::IsConnected() ? kStatYes : kStatNo,
|
||||
kStatEditorMWMName : @(featureID.GetMwmName().c_str()),
|
||||
kStatEditorMWMVersion : @(featureID.GetMwmVersion())
|
||||
}];
|
||||
[self performSegueWithIdentifier:kEditorSegue sender:self.controlsManager.placePageEntity];
|
||||
}
|
||||
|
||||
|
@ -487,20 +464,16 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
BOOL const isMapVisible = (self.navigationController.visibleViewController == self);
|
||||
if (isMapVisible && !location_helpers::isLocationProhibited())
|
||||
{
|
||||
[self.alertController presentLocationNotFoundAlertWithOkBlock:^
|
||||
{
|
||||
[self.alertController presentLocationNotFoundAlertWithOkBlock:^{
|
||||
GetFramework().SwitchMyPositionNextMode();
|
||||
}];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case location::PendingPosition:
|
||||
case location::NotFollow:
|
||||
break;
|
||||
case location::NotFollow: break;
|
||||
case location::Follow:
|
||||
case location::FollowAndRotate:
|
||||
self.disableStandbyOnLocationStateMode = YES;
|
||||
break;
|
||||
case location::FollowAndRotate: self.disableStandbyOnLocationStateMode = YES; break;
|
||||
}
|
||||
gIsFirstMyPositionMode = NO;
|
||||
}
|
||||
|
@ -522,17 +495,16 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
return;
|
||||
switch (nodeStatuses.m_error)
|
||||
{
|
||||
case NodeErrorCode::NoError:
|
||||
break;
|
||||
case NodeErrorCode::UnknownError:
|
||||
[Statistics logEvent:kStatDownloaderMapError withParameters:@{kStatType : kStatUnknownError}];
|
||||
break;
|
||||
case NodeErrorCode::OutOfMemFailed:
|
||||
[Statistics logEvent:kStatDownloaderMapError withParameters:@{kStatType : kStatNoSpace}];
|
||||
break;
|
||||
case NodeErrorCode::NoInetConnection:
|
||||
[Statistics logEvent:kStatDownloaderMapError withParameters:@{kStatType : kStatNoConnection}];
|
||||
break;
|
||||
case NodeErrorCode::NoError: break;
|
||||
case NodeErrorCode::UnknownError:
|
||||
[Statistics logEvent:kStatDownloaderMapError withParameters:@{kStatType : kStatUnknownError}];
|
||||
break;
|
||||
case NodeErrorCode::OutOfMemFailed:
|
||||
[Statistics logEvent:kStatDownloaderMapError withParameters:@{kStatType : kStatNoSpace}];
|
||||
break;
|
||||
case NodeErrorCode::NoInetConnection:
|
||||
[Statistics logEvent:kStatDownloaderMapError withParameters:@{kStatType : kStatNoConnection}];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,7 +520,7 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
if (!Platform::IsConnected())
|
||||
return;
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatEditTime)
|
||||
withParameters:@{kStatValue : kStatAuthorization}];
|
||||
withParameters:@{kStatValue : kStatAuthorization}];
|
||||
[self.alertController presentOsmAuthAlert];
|
||||
}
|
||||
}
|
||||
|
@ -583,14 +555,15 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
}
|
||||
if (self.isAppWallAdActive)
|
||||
return;
|
||||
self.appWallAd = [[MTRGNativeAppwallAd alloc]initWithSlotId:@(MY_TARGET_KEY)];
|
||||
self.appWallAd = [[MTRGNativeAppwallAd alloc] initWithSlotId:@(MY_TARGET_KEY)];
|
||||
self.appWallAd.handleLinksInApp = YES;
|
||||
self.appWallAd.closeButtonTitle = L(@"close");
|
||||
self.appWallAd.delegate = self;
|
||||
[self.appWallAd load];
|
||||
}
|
||||
|
||||
- (void)onLoadWithAppwallBanners:(NSArray *)appwallBanners appwallAd:(MTRGNativeAppwallAd *)appwallAd
|
||||
- (void)onLoadWithAppwallBanners:(NSArray *)appwallBanners
|
||||
appwallAd:(MTRGNativeAppwallAd *)appwallAd
|
||||
{
|
||||
if (![appwallAd isEqual:self.appWallAd])
|
||||
return;
|
||||
|
@ -615,18 +588,10 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
return _apiBar;
|
||||
}
|
||||
|
||||
- (void)showAPIBar
|
||||
{
|
||||
self.apiBar.isVisible = YES;
|
||||
}
|
||||
|
||||
- (void)showAPIBar { self.apiBar.isVisible = YES; }
|
||||
#pragma mark - ShowDialog callback
|
||||
|
||||
- (void)presentDisabledLocationAlert
|
||||
{
|
||||
[self.alertController presentDisabledLocationAlert];
|
||||
}
|
||||
|
||||
- (void)presentDisabledLocationAlert { [self.alertController presentDisabledLocationAlert]; }
|
||||
- (void)setDisableStandbyOnLocationStateMode:(BOOL)disableStandbyOnLocationStateMode
|
||||
{
|
||||
if (_disableStandbyOnLocationStateMode == disableStandbyOnLocationStateMode)
|
||||
|
@ -651,7 +616,8 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
{
|
||||
MWMMapDownloaderViewController * dvc = segue.destinationViewController;
|
||||
NSNumber * mode = sender;
|
||||
[dvc setParentCountryId:@(GetFramework().Storage().GetRootId().c_str()) mode:static_cast<mwm::DownloaderMode>(mode.integerValue)];
|
||||
[dvc setParentCountryId:@(GetFramework().Storage().GetRootId().c_str())
|
||||
mode:static_cast<mwm::DownloaderMode>(mode.integerValue)];
|
||||
}
|
||||
else if ([segue.identifier isEqualToString:kMap2FBLoginSegue])
|
||||
{
|
||||
|
@ -700,11 +666,7 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
return haveAppWall && haveBanners;
|
||||
}
|
||||
|
||||
- (BOOL)hasNavigationBar
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)hasNavigationBar { return NO; }
|
||||
- (MWMMapDownloadDialog *)downloadDialog
|
||||
{
|
||||
if (!_downloadDialog)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#import "MapsAppDelegate.h"
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
||||
#import <Pushwoosh/PushNotificationManager.h>
|
||||
#import "AppInfo.h"
|
||||
#import "Common.h"
|
||||
#import "EAGLView.h"
|
||||
#import "LocalNotificationManager.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMAuthorizationCommon.h"
|
||||
#import "MWMController.h"
|
||||
|
@ -13,14 +15,12 @@
|
|||
#import "MWMRouter.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "MapViewController.h"
|
||||
#import "Preferences.h"
|
||||
#import "RouteState.h"
|
||||
#import "Statistics.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIFont+MapsMeFonts.h"
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
||||
#import <Pushwoosh/PushNotificationManager.h>
|
||||
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
||||
|
@ -30,13 +30,14 @@
|
|||
#include "indexer/osm_editor.hpp"
|
||||
#include "map/gps_tracker.hpp"
|
||||
#include "platform/http_thread_apple.h"
|
||||
#include "platform/settings.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "platform/preferred_languages.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
#include "std/target_os.hpp"
|
||||
#include "storage/storage_defines.hpp"
|
||||
|
||||
// If you have a "missing header error" here, then please run configure.sh script in the root repo folder.
|
||||
// If you have a "missing header error" here, then please run configure.sh script in the root repo
|
||||
// folder.
|
||||
#import "../../../private.h"
|
||||
|
||||
#ifdef OMIM_PRODUCTION
|
||||
|
@ -76,7 +77,8 @@ void InitLocalizedStrings()
|
|||
f.AddString("country_status_added_to_queue", [L(@"country_status_added_to_queue") UTF8String]);
|
||||
f.AddString("country_status_downloading", [L(@"country_status_downloading") UTF8String]);
|
||||
f.AddString("country_status_download", [L(@"country_status_download") UTF8String]);
|
||||
f.AddString("country_status_download_without_routing", [L(@"country_status_download_without_routing") UTF8String]);
|
||||
f.AddString("country_status_download_without_routing",
|
||||
[L(@"country_status_download_without_routing") UTF8String]);
|
||||
f.AddString("country_status_download_failed", [L(@"country_status_download_failed") UTF8String]);
|
||||
f.AddString("cancel", [L(@"cancel") UTF8String]);
|
||||
f.AddString("try_again", [L(@"try_again") UTF8String]);
|
||||
|
@ -87,11 +89,16 @@ void InitLocalizedStrings()
|
|||
f.AddString("routes", [L(@"routes") UTF8String]);
|
||||
f.AddString("wifi", L(@"wifi").UTF8String);
|
||||
|
||||
f.AddString("routing_failed_unknown_my_position", [L(@"routing_failed_unknown_my_position") UTF8String]);
|
||||
f.AddString("routing_failed_has_no_routing_file", [L(@"routing_failed_has_no_routing_file") UTF8String]);
|
||||
f.AddString("routing_failed_start_point_not_found", [L(@"routing_failed_start_point_not_found") UTF8String]);
|
||||
f.AddString("routing_failed_dst_point_not_found", [L(@"routing_failed_dst_point_not_found") UTF8String]);
|
||||
f.AddString("routing_failed_cross_mwm_building", [L(@"routing_failed_cross_mwm_building") UTF8String]);
|
||||
f.AddString("routing_failed_unknown_my_position",
|
||||
[L(@"routing_failed_unknown_my_position") UTF8String]);
|
||||
f.AddString("routing_failed_has_no_routing_file",
|
||||
[L(@"routing_failed_has_no_routing_file") UTF8String]);
|
||||
f.AddString("routing_failed_start_point_not_found",
|
||||
[L(@"routing_failed_start_point_not_found") UTF8String]);
|
||||
f.AddString("routing_failed_dst_point_not_found",
|
||||
[L(@"routing_failed_dst_point_not_found") UTF8String]);
|
||||
f.AddString("routing_failed_cross_mwm_building",
|
||||
[L(@"routing_failed_cross_mwm_building") UTF8String]);
|
||||
f.AddString("routing_failed_route_not_found", [L(@"routing_failed_route_not_found") UTF8String]);
|
||||
f.AddString("routing_failed_internal_error", [L(@"routing_failed_internal_error") UTF8String]);
|
||||
f.AddString("place_page_booking_rating", [L(@"place_page_booking_rating") UTF8String]);
|
||||
|
@ -109,7 +116,7 @@ void InitCrashTrackers()
|
|||
// Initialize Hockey App SDK.
|
||||
BITHockeyManager * hockeyManager = [BITHockeyManager sharedHockeyManager];
|
||||
[hockeyManager configureWithIdentifier:hockeyKey];
|
||||
[hockeyManager.crashManager setCrashManagerStatus: BITCrashManagerStatusAutoSend];
|
||||
[hockeyManager.crashManager setCrashManagerStatus:BITCrashManagerStatusAutoSend];
|
||||
[hockeyManager startManager];
|
||||
}
|
||||
|
||||
|
@ -117,7 +124,7 @@ void InitCrashTrackers()
|
|||
if (fabricKey.length != 0)
|
||||
{
|
||||
// Initialize Fabric/Crashlytics SDK.
|
||||
[Fabric with:@[[Crashlytics class]]];
|
||||
[Fabric with:@[ [Crashlytics class] ]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -125,20 +132,21 @@ void InitCrashTrackers()
|
|||
void ConfigCrashTrackers()
|
||||
{
|
||||
#ifdef OMIM_PRODUCTION
|
||||
[[Crashlytics sharedInstance] setObjectValue:[Alohalytics installationId] forKey:@"AlohalyticsInstallationId"];
|
||||
[[Crashlytics sharedInstance] setObjectValue:[Alohalytics installationId]
|
||||
forKey:@"AlohalyticsInstallationId"];
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace osm_auth_ios;
|
||||
|
||||
@interface MapsAppDelegate () <MWMFrameworkStorageObserver>
|
||||
@interface MapsAppDelegate ()<MWMFrameworkStorageObserver>
|
||||
|
||||
@property (nonatomic) NSInteger standbyCounter;
|
||||
@property(nonatomic) NSInteger standbyCounter;
|
||||
|
||||
@property (weak, nonatomic) NSTimer * checkAdServerForbiddenTimer;
|
||||
@property (weak, nonatomic) NSTimer * mapStyleSwitchTimer;
|
||||
@property(weak, nonatomic) NSTimer * checkAdServerForbiddenTimer;
|
||||
@property(weak, nonatomic) NSTimer * mapStyleSwitchTimer;
|
||||
|
||||
@property (nonatomic, readwrite) LocationManager * locationManager;
|
||||
@property(nonatomic, readwrite) LocationManager * locationManager;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -164,7 +172,10 @@ using namespace osm_auth_ios;
|
|||
// Do not initialize Pushwoosh for open-source version.
|
||||
if (string(PUSHWOOSH_APPLICATION_ID).empty())
|
||||
return;
|
||||
[PushNotificationManager initializeWithAppCode:@(PUSHWOOSH_APPLICATION_ID) appName:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
|
||||
[PushNotificationManager
|
||||
initializeWithAppCode:@(PUSHWOOSH_APPLICATION_ID)
|
||||
appName:[[NSBundle mainBundle]
|
||||
objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
|
||||
PushNotificationManager * pushManager = [PushNotificationManager pushManager];
|
||||
|
||||
// handling push on app start
|
||||
|
@ -178,7 +189,8 @@ using namespace osm_auth_ios;
|
|||
}
|
||||
|
||||
// system push notification registration success callback, delegate to pushManager
|
||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
- (void)application:(UIApplication *)application
|
||||
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
{
|
||||
PushNotificationManager * pushManager = [PushNotificationManager pushManager];
|
||||
[pushManager handlePushRegistration:deviceToken];
|
||||
|
@ -186,13 +198,16 @@ using namespace osm_auth_ios;
|
|||
}
|
||||
|
||||
// system push notification registration error callback, delegate to pushManager
|
||||
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
||||
- (void)application:(UIApplication *)application
|
||||
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
||||
{
|
||||
[[PushNotificationManager pushManager] handlePushRegistrationFailure:error];
|
||||
}
|
||||
|
||||
// system push notifications callback, delegate to pushManager
|
||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
|
||||
- (void)application:(UIApplication *)application
|
||||
didReceiveRemoteNotification:(NSDictionary *)userInfo
|
||||
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatApplication, kStatPushReceived) withParameters:userInfo];
|
||||
if (![self handleURLPush:userInfo])
|
||||
|
@ -221,7 +236,9 @@ using namespace osm_auth_ios;
|
|||
{
|
||||
if (!self.isDrapeEngineCreated)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [self handleURLs]; });
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self handleURLs];
|
||||
});
|
||||
return;
|
||||
}
|
||||
Framework & f = GetFramework();
|
||||
|
@ -230,7 +247,7 @@ using namespace osm_auth_ios;
|
|||
if (f.ShowMapForURL([m_geoURL UTF8String]))
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatApplication, kStatImport)
|
||||
withParameters:@{kStatValue : m_scheme}];
|
||||
withParameters:@{kStatValue : m_scheme}];
|
||||
[self showMap];
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +268,7 @@ using namespace osm_auth_ios;
|
|||
[[NSNotificationCenter defaultCenter] postNotificationName:@"KML file added" object:nil];
|
||||
[self showLoadFileAlertIsSuccessful:YES];
|
||||
[Statistics logEvent:kStatEventName(kStatApplication, kStatImport)
|
||||
withParameters:@{kStatValue : kStatKML}];
|
||||
withParameters:@{kStatValue : kStatKML}];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -287,7 +304,8 @@ using namespace osm_auth_ios;
|
|||
|
||||
self.standbyCounter = 0;
|
||||
NSTimeInterval const minimumBackgroundFetchIntervalInSeconds = 6 * 60 * 60;
|
||||
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:minimumBackgroundFetchIntervalInSeconds];
|
||||
[[UIApplication sharedApplication]
|
||||
setMinimumBackgroundFetchInterval:minimumBackgroundFetchIntervalInSeconds];
|
||||
[self startAdServerForbiddenCheckTimer];
|
||||
[self updateApplicationIconBadgeNumber];
|
||||
}
|
||||
|
@ -324,16 +342,15 @@ using namespace osm_auth_ios;
|
|||
{
|
||||
if (![MapsAppDelegate isAutoNightMode])
|
||||
return;
|
||||
self.mapStyleSwitchTimer = [NSTimer scheduledTimerWithTimeInterval:(30 * 60) target:[MapsAppDelegate class]
|
||||
selector:@selector(changeMapStyleIfNedeed) userInfo:nil
|
||||
repeats:YES];
|
||||
}
|
||||
|
||||
- (void)stopMapStyleChecker
|
||||
{
|
||||
[self.mapStyleSwitchTimer invalidate];
|
||||
self.mapStyleSwitchTimer =
|
||||
[NSTimer scheduledTimerWithTimeInterval:(30 * 60)
|
||||
target:[MapsAppDelegate class]
|
||||
selector:@selector(changeMapStyleIfNedeed)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
}
|
||||
|
||||
- (void)stopMapStyleChecker { [self.mapStyleSwitchTimer invalidate]; }
|
||||
+ (void)resetToDefaultMapStyle
|
||||
{
|
||||
MapsAppDelegate * app = MapsAppDelegate.theApp;
|
||||
|
@ -343,7 +360,8 @@ using namespace osm_auth_ios;
|
|||
return;
|
||||
f.SetMapStyle(MapStyleClear);
|
||||
[UIColor setNightMode:NO];
|
||||
[static_cast<id<MWMController>>(app.mapViewController.navigationController.topViewController) mwm_refreshUI];
|
||||
[static_cast<id<MWMController>>(app.mapViewController.navigationController.topViewController)
|
||||
mwm_refreshUI];
|
||||
[app stopMapStyleChecker];
|
||||
}
|
||||
|
||||
|
@ -356,40 +374,40 @@ using namespace osm_auth_ios;
|
|||
if (!lastLocation || !f.IsRoutingActive())
|
||||
return;
|
||||
CLLocationCoordinate2D const coord = lastLocation.coordinate;
|
||||
dispatch_async(dispatch_get_main_queue(), [coord]
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), [coord] {
|
||||
auto & f = GetFramework();
|
||||
MapsAppDelegate * app = MapsAppDelegate.theApp;
|
||||
auto const dayTime =
|
||||
GetDayTime(static_cast<time_t>(NSDate.date.timeIntervalSince1970),
|
||||
coord.latitude, coord.longitude);
|
||||
id<MWMController> vc = static_cast<id<MWMController>>(app.mapViewController.navigationController.topViewController);
|
||||
auto const dayTime = GetDayTime(static_cast<time_t>(NSDate.date.timeIntervalSince1970),
|
||||
coord.latitude, coord.longitude);
|
||||
id<MWMController> vc = static_cast<id<MWMController>>(
|
||||
app.mapViewController.navigationController.topViewController);
|
||||
auto style = f.GetMapStyle();
|
||||
switch (dayTime)
|
||||
{
|
||||
case DayTimeType::Day:
|
||||
case DayTimeType::PolarDay:
|
||||
if (style != MapStyleClear && style != MapStyleLight)
|
||||
{
|
||||
f.SetMapStyle(MapStyleClear);
|
||||
[UIColor setNightMode:NO];
|
||||
[vc mwm_refreshUI];
|
||||
}
|
||||
break;
|
||||
case DayTimeType::Night:
|
||||
case DayTimeType::PolarNight:
|
||||
if (style != MapStyleDark)
|
||||
{
|
||||
f.SetMapStyle(MapStyleDark);
|
||||
[UIColor setNightMode:YES];
|
||||
[vc mwm_refreshUI];
|
||||
}
|
||||
break;
|
||||
case DayTimeType::Day:
|
||||
case DayTimeType::PolarDay:
|
||||
if (style != MapStyleClear && style != MapStyleLight)
|
||||
{
|
||||
f.SetMapStyle(MapStyleClear);
|
||||
[UIColor setNightMode:NO];
|
||||
[vc mwm_refreshUI];
|
||||
}
|
||||
break;
|
||||
case DayTimeType::Night:
|
||||
case DayTimeType::PolarNight:
|
||||
if (style != MapStyleDark)
|
||||
{
|
||||
f.SetMapStyle(MapStyleDark);
|
||||
[UIColor setNightMode:YES];
|
||||
[vc mwm_refreshUI];
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
InitCrashTrackers();
|
||||
|
||||
|
@ -418,7 +436,9 @@ using namespace osm_auth_ios;
|
|||
|
||||
LocalNotificationManager * notificationManager = [LocalNotificationManager sharedManager];
|
||||
if (launchOptions[UIApplicationLaunchOptionsLocalNotificationKey])
|
||||
[notificationManager processNotification:launchOptions[UIApplicationLaunchOptionsLocalNotificationKey] onLaunch:YES];
|
||||
[notificationManager
|
||||
processNotification:launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]
|
||||
onLaunch:YES];
|
||||
|
||||
if ([Alohalytics isFirstSession])
|
||||
[self firstLaunchSetup];
|
||||
|
@ -439,19 +459,27 @@ using namespace osm_auth_ios;
|
|||
}
|
||||
|
||||
// Starts async edits uploading process.
|
||||
+ (void)uploadLocalMapEdits:(void (^)(osm::Editor::UploadResult))finishCallback with:(osm::TKeySecret const &)keySecret
|
||||
+ (void)uploadLocalMapEdits:(void (^)(osm::Editor::UploadResult))finishCallback
|
||||
with:(osm::TKeySecret const &)keySecret
|
||||
{
|
||||
auto const lambda = [finishCallback](osm::Editor::UploadResult result) { finishCallback(result); };
|
||||
osm::Editor::Instance().UploadChanges(keySecret.first, keySecret.second,
|
||||
{{"created_by", string("MAPS.ME " OMIM_OS_NAME " ") + AppInfo.sharedInfo.bundleVersion.UTF8String},
|
||||
{"bundle_id", NSBundle.mainBundle.bundleIdentifier.UTF8String}}, lambda);
|
||||
auto const lambda = [finishCallback](osm::Editor::UploadResult result) {
|
||||
finishCallback(result);
|
||||
};
|
||||
osm::Editor::Instance().UploadChanges(
|
||||
keySecret.first, keySecret.second,
|
||||
{{"created_by",
|
||||
string("MAPS.ME " OMIM_OS_NAME " ") + AppInfo.sharedInfo.bundleVersion.UTF8String},
|
||||
{"bundle_id", NSBundle.mainBundle.bundleIdentifier.UTF8String}},
|
||||
lambda);
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
|
||||
- (void)application:(UIApplication *)application
|
||||
performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
|
||||
{
|
||||
// At the moment, we need to perform 3 asynchronous background tasks simultaneously.
|
||||
// We will force complete fetch before backgroundTimeRemaining.
|
||||
// However if all scheduled tasks complete before backgroundTimeRemaining, fetch completes as soon as last task finishes.
|
||||
// However if all scheduled tasks complete before backgroundTimeRemaining, fetch completes as soon
|
||||
// as last task finishes.
|
||||
// fetchResultPriority is used to determine result we must send to fetch completion block.
|
||||
// Threads synchronization is made through dispatch_async on the main queue.
|
||||
static NSUInteger fetchRunningTasks;
|
||||
|
@ -462,8 +490,7 @@ using namespace osm_auth_ios;
|
|||
fetchRunningTasks = 0;
|
||||
fetchResult = UIBackgroundFetchResultNewData;
|
||||
|
||||
auto const fetchResultPriority = ^NSUInteger(UIBackgroundFetchResult result)
|
||||
{
|
||||
auto const fetchResultPriority = ^NSUInteger(UIBackgroundFetchResult result) {
|
||||
switch (result)
|
||||
{
|
||||
case UIBackgroundFetchResultNewData: return 2;
|
||||
|
@ -471,10 +498,8 @@ using namespace osm_auth_ios;
|
|||
case UIBackgroundFetchResultFailed: return 3;
|
||||
}
|
||||
};
|
||||
auto const callback = ^(UIBackgroundFetchResult result)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
auto const callback = ^(UIBackgroundFetchResult result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (taskFetchStamp != fetchStamp)
|
||||
return;
|
||||
if (fetchResultPriority(fetchResult) < fetchResultPriority(result))
|
||||
|
@ -486,16 +511,14 @@ using namespace osm_auth_ios;
|
|||
}
|
||||
});
|
||||
};
|
||||
auto const runFetchTask = ^(TMWMVoidBlock task)
|
||||
{
|
||||
auto const runFetchTask = ^(TMWMVoidBlock task) {
|
||||
++fetchRunningTasks;
|
||||
task();
|
||||
};
|
||||
|
||||
dispatch_time_t const forceCompleteTime = dispatch_time(
|
||||
DISPATCH_TIME_NOW, static_cast<int64_t>(application.backgroundTimeRemaining) * NSEC_PER_SEC);
|
||||
dispatch_after(forceCompleteTime, dispatch_get_main_queue(), ^
|
||||
{
|
||||
dispatch_after(forceCompleteTime, dispatch_get_main_queue(), ^{
|
||||
if (taskFetchStamp != fetchStamp)
|
||||
return;
|
||||
fetchRunningTasks = 1;
|
||||
|
@ -503,30 +526,28 @@ using namespace osm_auth_ios;
|
|||
});
|
||||
|
||||
// 1. Try to send collected statistics (if any) to our server.
|
||||
runFetchTask(^
|
||||
{
|
||||
runFetchTask(^{
|
||||
[Alohalytics forceUpload:callback];
|
||||
});
|
||||
// 2. Upload map edits (if any).
|
||||
if (osm::Editor::Instance().HaveMapEditsOrNotesToUpload() && AuthorizationHaveCredentials())
|
||||
{
|
||||
runFetchTask(^
|
||||
{
|
||||
[MapsAppDelegate uploadLocalMapEdits:^(osm::Editor::UploadResult result)
|
||||
{
|
||||
runFetchTask(^{
|
||||
[MapsAppDelegate uploadLocalMapEdits:^(osm::Editor::UploadResult result) {
|
||||
using UploadResult = osm::Editor::UploadResult;
|
||||
switch (result)
|
||||
{
|
||||
case UploadResult::Success: callback(UIBackgroundFetchResultNewData); break;
|
||||
case UploadResult::Error: callback(UIBackgroundFetchResultFailed); break;
|
||||
case UploadResult::NothingToUpload: callback(UIBackgroundFetchResultNoData); break;
|
||||
case UploadResult::Success: callback(UIBackgroundFetchResultNewData); break;
|
||||
case UploadResult::Error: callback(UIBackgroundFetchResultFailed); break;
|
||||
case UploadResult::NothingToUpload: callback(UIBackgroundFetchResultNoData); break;
|
||||
}
|
||||
} with:AuthorizationGetCredentials()];
|
||||
}
|
||||
with:AuthorizationGetCredentials()];
|
||||
});
|
||||
}
|
||||
// 3. Check if map for current location is already downloaded, and if not - notify user to download it.
|
||||
runFetchTask(^
|
||||
{
|
||||
// 3. Check if map for current location is already downloaded, and if not - notify user to
|
||||
// download it.
|
||||
runFetchTask(^{
|
||||
[[LocalNotificationManager sharedManager] showDownloadMapNotificationIfNeeded:callback];
|
||||
});
|
||||
}
|
||||
|
@ -547,34 +568,34 @@ using namespace osm_auth_ios;
|
|||
self->m_backgroundTask = UIBackgroundTaskInvalid;
|
||||
}];
|
||||
}
|
||||
// Upload map edits if any, but only if we have Internet connection and user has already been authorized.
|
||||
if (osm::Editor::Instance().HaveMapEditsOrNotesToUpload() &&
|
||||
AuthorizationHaveCredentials() &&
|
||||
// Upload map edits if any, but only if we have Internet connection and user has already been
|
||||
// authorized.
|
||||
if (osm::Editor::Instance().HaveMapEditsOrNotesToUpload() && AuthorizationHaveCredentials() &&
|
||||
Platform::EConnectionType::CONNECTION_NONE != Platform::ConnectionStatus())
|
||||
{
|
||||
void (^finishEditorUploadTaskBlock)() = ^
|
||||
{
|
||||
void (^finishEditorUploadTaskBlock)() = ^{
|
||||
if (self->m_editorUploadBackgroundTask != UIBackgroundTaskInvalid)
|
||||
{
|
||||
[application endBackgroundTask:self->m_editorUploadBackgroundTask];
|
||||
self->m_editorUploadBackgroundTask = UIBackgroundTaskInvalid;
|
||||
}
|
||||
};
|
||||
::dispatch_after(::dispatch_time(DISPATCH_TIME_NOW, static_cast<int64_t>(application.backgroundTimeRemaining)),
|
||||
::dispatch_get_main_queue(),
|
||||
finishEditorUploadTaskBlock);
|
||||
m_editorUploadBackgroundTask = [application beginBackgroundTaskWithExpirationHandler:finishEditorUploadTaskBlock];
|
||||
[MapsAppDelegate uploadLocalMapEdits:^(osm::Editor::UploadResult /*ignore it here*/)
|
||||
{
|
||||
::dispatch_after(::dispatch_time(DISPATCH_TIME_NOW,
|
||||
static_cast<int64_t>(application.backgroundTimeRemaining)),
|
||||
::dispatch_get_main_queue(), finishEditorUploadTaskBlock);
|
||||
m_editorUploadBackgroundTask =
|
||||
[application beginBackgroundTaskWithExpirationHandler:finishEditorUploadTaskBlock];
|
||||
[MapsAppDelegate uploadLocalMapEdits:^(osm::Editor::UploadResult /*ignore it here*/) {
|
||||
finishEditorUploadTaskBlock();
|
||||
} with:AuthorizationGetCredentials()];
|
||||
}
|
||||
with:AuthorizationGetCredentials()];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
LOG(LINFO, ("applicationWillResignActive"));
|
||||
[self.mapViewController onGetFocus: NO];
|
||||
[self.mapViewController onGetFocus:NO];
|
||||
[self.mapViewController.appWallAd close];
|
||||
[RouteState save];
|
||||
GetFramework().SetRenderingEnabled(false);
|
||||
|
@ -590,7 +611,7 @@ using namespace osm_auth_ios;
|
|||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
LOG(LINFO, ("applicationDidBecomeActive"));
|
||||
[self.mapViewController onGetFocus: YES];
|
||||
[self.mapViewController onGetFocus:YES];
|
||||
[self handleURLs];
|
||||
[[Statistics instance] applicationDidBecomeActive];
|
||||
GetFramework().SetRenderingEnabled(true);
|
||||
|
@ -605,28 +626,29 @@ using namespace osm_auth_ios;
|
|||
DeleteFramework();
|
||||
}
|
||||
|
||||
- (BOOL)initStatistics:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
- (BOOL)initStatistics:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
Statistics * statistics = [Statistics instance];
|
||||
BOOL returnValue = [statistics application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
BOOL returnValue =
|
||||
[statistics application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
|
||||
NSString * connectionType;
|
||||
switch (Platform::ConnectionStatus())
|
||||
{
|
||||
case Platform::EConnectionType::CONNECTION_NONE:
|
||||
break;
|
||||
case Platform::EConnectionType::CONNECTION_WIFI:
|
||||
connectionType = @"Wi-Fi";
|
||||
break;
|
||||
case Platform::EConnectionType::CONNECTION_WWAN:
|
||||
connectionType = [[CTTelephonyNetworkInfo alloc] init].currentRadioAccessTechnology;
|
||||
break;
|
||||
case Platform::EConnectionType::CONNECTION_NONE: break;
|
||||
case Platform::EConnectionType::CONNECTION_WIFI: connectionType = @"Wi-Fi"; break;
|
||||
case Platform::EConnectionType::CONNECTION_WWAN:
|
||||
connectionType = [[CTTelephonyNetworkInfo alloc] init].currentRadioAccessTechnology;
|
||||
break;
|
||||
}
|
||||
if (!connectionType)
|
||||
connectionType = @"Offline";
|
||||
[Statistics logEvent:kStatDeviceInfo
|
||||
withParameters:
|
||||
@{kStatCountry : [AppInfo sharedInfo].countryCode, kStatConnection : connectionType}];
|
||||
withParameters:@{
|
||||
kStatCountry : [AppInfo sharedInfo].countryCode,
|
||||
kStatConnection : connectionType
|
||||
}];
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
@ -652,12 +674,7 @@ using namespace osm_auth_ios;
|
|||
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)setMapStyle:(MapStyle)mapStyle
|
||||
{
|
||||
GetFramework().SetMapStyle(mapStyle);
|
||||
}
|
||||
|
||||
- (void)setMapStyle:(MapStyle)mapStyle { GetFramework().SetMapStyle(mapStyle); }
|
||||
+ (NSDictionary *)navigationBarTextAttributes
|
||||
{
|
||||
return @{
|
||||
|
@ -686,7 +703,8 @@ using namespace osm_auth_ios;
|
|||
[barBtn setTitleTextAttributes:[self navigationBarTextAttributes] forState:UIControlStateNormal];
|
||||
[barBtn setTitleTextAttributes:@{
|
||||
NSForegroundColorAttributeName : [UIColor lightGrayColor],
|
||||
} forState:UIControlStateDisabled];
|
||||
}
|
||||
forState:UIControlStateDisabled];
|
||||
|
||||
UIPageControl * pageControl = [UIPageControl appearance];
|
||||
pageControl.pageIndicatorTintColor = [UIColor blackHintText];
|
||||
|
@ -694,7 +712,8 @@ using namespace osm_auth_ios;
|
|||
pageControl.backgroundColor = [UIColor white];
|
||||
|
||||
UITextField * textField = [UITextField appearance];
|
||||
textField.keyboardAppearance = [UIColor isNightMode] ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;
|
||||
textField.keyboardAppearance =
|
||||
[UIColor isNightMode] ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;
|
||||
|
||||
UISearchBar * searchBar = [UISearchBar appearance];
|
||||
searchBar.barTintColor = [UIColor primary];
|
||||
|
@ -702,7 +721,8 @@ using namespace osm_auth_ios;
|
|||
if (isIOS7 || isIOS8)
|
||||
textFieldInSearchBar = [UITextField appearanceWhenContainedIn:[UISearchBar class], nil];
|
||||
else
|
||||
textFieldInSearchBar = [UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]];
|
||||
textFieldInSearchBar =
|
||||
[UITextField appearanceWhenContainedInInstancesOfClasses:@[ [UISearchBar class] ]];
|
||||
|
||||
textField.backgroundColor = [UIColor white];
|
||||
textFieldInSearchBar.defaultTextAttributes = @{
|
||||
|
@ -711,36 +731,48 @@ using namespace osm_auth_ios;
|
|||
};
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
|
||||
- (void)application:(UIApplication *)application
|
||||
didReceiveLocalNotification:(UILocalNotification *)notification
|
||||
{
|
||||
[[LocalNotificationManager sharedManager] processNotification:notification onLaunch:NO];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation
|
||||
{
|
||||
m_sourceApplication = sourceApplication;
|
||||
|
||||
if ([self checkLaunchURL:url])
|
||||
return YES;
|
||||
|
||||
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
|
||||
return [[FBSDKApplicationDelegate sharedInstance] application:application
|
||||
openURL:url
|
||||
sourceApplication:sourceApplication
|
||||
annotation:annotation];
|
||||
}
|
||||
|
||||
- (void)showLoadFileAlertIsSuccessful:(BOOL)successful
|
||||
{
|
||||
m_loadingAlertView = [[UIAlertView alloc] initWithTitle:L(@"load_kmz_title")
|
||||
message:
|
||||
(successful ? L(@"load_kmz_successful") : L(@"load_kmz_failed"))
|
||||
delegate:nil
|
||||
cancelButtonTitle:L(@"ok") otherButtonTitles:nil];
|
||||
m_loadingAlertView = [[UIAlertView alloc]
|
||||
initWithTitle:L(@"load_kmz_title")
|
||||
message:(successful ? L(@"load_kmz_successful") : L(@"load_kmz_failed"))
|
||||
delegate:nil
|
||||
cancelButtonTitle:L(@"ok")
|
||||
otherButtonTitles:nil];
|
||||
m_loadingAlertView.delegate = self;
|
||||
[m_loadingAlertView show];
|
||||
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(dismissAlert) userInfo:nil repeats:NO];
|
||||
[NSTimer scheduledTimerWithTimeInterval:5.0
|
||||
target:self
|
||||
selector:@selector(dismissAlert)
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
}
|
||||
|
||||
- (BOOL)checkLaunchURL:(NSURL *)url
|
||||
{
|
||||
NSString *scheme = url.scheme;
|
||||
NSString * scheme = url.scheme;
|
||||
m_scheme = scheme;
|
||||
if ([scheme isEqualToString:@"geo"] || [scheme isEqualToString:@"ge0"])
|
||||
{
|
||||
|
@ -782,7 +814,8 @@ using namespace osm_auth_ios;
|
|||
auto & s = GetFramework().Storage();
|
||||
storage::Storage::UpdateInfo updateInfo{};
|
||||
s.GetUpdateInfo(s.GetRootId(), updateInfo);
|
||||
[UIApplication sharedApplication].applicationIconBadgeNumber = updateInfo.m_numberOfMwmFilesToUpdate;
|
||||
[UIApplication sharedApplication].applicationIconBadgeNumber =
|
||||
updateInfo.m_numberOfMwmFilesToUpdate;
|
||||
}
|
||||
|
||||
- (void)setRoutingPlaneMode:(MWMRoutingPlaneMode)routingPlaneMode
|
||||
|
@ -795,9 +828,9 @@ using namespace osm_auth_ios;
|
|||
|
||||
- (void)processCountryEvent:(storage::TCountryId const &)countryId
|
||||
{
|
||||
//Dispatch this method after delay since there are too many events for group mwms download.
|
||||
//We do not need to update badge frequently.
|
||||
//Update after 1 second delay (after last country event) is sure enough for app badge.
|
||||
// Dispatch this method after delay since there are too many events for group mwms download.
|
||||
// We do not need to update badge frequently.
|
||||
// Update after 1 second delay (after last country event) is sure enough for app badge.
|
||||
SEL const updateBadge = @selector(updateApplicationIconBadgeNumber);
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:updateBadge object:nil];
|
||||
[self performSelector:updateBadge withObject:nil afterDelay:1.0];
|
||||
|
@ -820,16 +853,8 @@ using namespace osm_auth_ios;
|
|||
|
||||
#pragma mark - Standby
|
||||
|
||||
- (void)enableStandby
|
||||
{
|
||||
self.standbyCounter--;
|
||||
}
|
||||
|
||||
- (void)disableStandby
|
||||
{
|
||||
self.standbyCounter++;
|
||||
}
|
||||
|
||||
- (void)enableStandby { self.standbyCounter--; }
|
||||
- (void)disableStandby { self.standbyCounter++; }
|
||||
- (void)setStandbyCounter:(NSInteger)standbyCounter
|
||||
{
|
||||
_standbyCounter = MAX(0, standbyCounter);
|
||||
|
@ -840,8 +865,9 @@ using namespace osm_auth_ios;
|
|||
|
||||
- (void)firstLaunchSetup
|
||||
{
|
||||
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
|
||||
NSUserDefaults *standartDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString * currentVersion =
|
||||
[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
|
||||
NSUserDefaults * standartDefaults = [NSUserDefaults standardUserDefaults];
|
||||
[standartDefaults setObject:currentVersion forKey:kUDFirstVersionKey];
|
||||
[standartDefaults setInteger:1 forKey:kUDSessionsCountKey];
|
||||
[standartDefaults setObject:NSDate.date forKey:kUDLastLaunchDateKey];
|
||||
|
@ -850,13 +876,13 @@ using namespace osm_auth_ios;
|
|||
|
||||
- (void)incrementSessionCount
|
||||
{
|
||||
NSUserDefaults *standartDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults * standartDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUInteger sessionCount = [standartDefaults integerForKey:kUDSessionsCountKey];
|
||||
NSUInteger const kMaximumSessionCountForShowingShareAlert = 50;
|
||||
if (sessionCount > kMaximumSessionCountForShowingShareAlert)
|
||||
return;
|
||||
|
||||
NSDate *lastLaunchDate = [standartDefaults objectForKey:kUDLastLaunchDateKey];
|
||||
NSDate * lastLaunchDate = [standartDefaults objectForKey:kUDLastLaunchDateKey];
|
||||
NSUInteger daysFromLastLaunch = [self.class daysBetweenNowAndDate:lastLaunchDate];
|
||||
if (daysFromLastLaunch > 0)
|
||||
{
|
||||
|
@ -882,22 +908,22 @@ using namespace osm_auth_ios;
|
|||
if (!Platform::IsConnected())
|
||||
return;
|
||||
|
||||
UIViewController * topViewController = [(UINavigationController*)self.window.rootViewController visibleViewController];
|
||||
MWMAlertViewController * alert = [[MWMAlertViewController alloc] initWithViewController:topViewController];
|
||||
UIViewController * topViewController =
|
||||
[(UINavigationController *)self.window.rootViewController visibleViewController];
|
||||
MWMAlertViewController * alert =
|
||||
[[MWMAlertViewController alloc] initWithViewController:topViewController];
|
||||
if (isRate)
|
||||
[alert presentRateAlert];
|
||||
else
|
||||
[alert presentFacebookAlert];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:NSDate.date forKey:isRate ? kUDLastRateRequestDate : kUDLastShareRequstDate];
|
||||
[alert presentFacebookAlert];
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setObject:NSDate.date
|
||||
forKey:isRate ? kUDLastRateRequestDate : kUDLastShareRequstDate];
|
||||
}
|
||||
|
||||
#pragma mark - Facebook
|
||||
|
||||
- (void)showFacebookAlert
|
||||
{
|
||||
[self showAlert:NO];
|
||||
}
|
||||
|
||||
- (void)showFacebookAlert { [self showAlert:NO]; }
|
||||
- (BOOL)shouldShowFacebookAlert
|
||||
{
|
||||
NSUInteger const kMaximumSessionCountForShowingShareAlert = 50;
|
||||
|
@ -910,7 +936,8 @@ using namespace osm_auth_ios;
|
|||
return NO;
|
||||
|
||||
NSDate * const lastShareRequestDate = [standartDefaults objectForKey:kUDLastShareRequstDate];
|
||||
NSUInteger const daysFromLastShareRequest = [MapsAppDelegate daysBetweenNowAndDate:lastShareRequestDate];
|
||||
NSUInteger const daysFromLastShareRequest =
|
||||
[MapsAppDelegate daysBetweenNowAndDate:lastShareRequestDate];
|
||||
if (lastShareRequestDate != nil && daysFromLastShareRequest == 0)
|
||||
return NO;
|
||||
|
||||
|
@ -932,11 +959,7 @@ using namespace osm_auth_ios;
|
|||
|
||||
#pragma mark - Rate
|
||||
|
||||
- (void)showRateAlert
|
||||
{
|
||||
[self showAlert:YES];
|
||||
}
|
||||
|
||||
- (void)showRateAlert { [self showAlert:YES]; }
|
||||
- (BOOL)shouldShowRateAlert
|
||||
{
|
||||
NSUInteger const kMaximumSessionCountForShowingAlert = 21;
|
||||
|
@ -949,7 +972,8 @@ using namespace osm_auth_ios;
|
|||
return NO;
|
||||
|
||||
NSDate * const lastRateRequestDate = [standartDefaults objectForKey:kUDLastRateRequestDate];
|
||||
NSUInteger const daysFromLastRateRequest = [MapsAppDelegate daysBetweenNowAndDate:lastRateRequestDate];
|
||||
NSUInteger const daysFromLastRateRequest =
|
||||
[MapsAppDelegate daysBetweenNowAndDate:lastRateRequestDate];
|
||||
// Do not show more than one alert per day.
|
||||
if (lastRateRequestDate != nil && daysFromLastRateRequest == 0)
|
||||
return NO;
|
||||
|
@ -957,7 +981,8 @@ using namespace osm_auth_ios;
|
|||
if (self.userIsNew)
|
||||
{
|
||||
// It's new user.
|
||||
if (sessionCount == 3 || sessionCount == 10 || sessionCount == kMaximumSessionCountForShowingAlert)
|
||||
if (sessionCount == 3 || sessionCount == 10 ||
|
||||
sessionCount == kMaximumSessionCountForShowingAlert)
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
|
@ -971,24 +996,26 @@ using namespace osm_auth_ios;
|
|||
|
||||
- (BOOL)userIsNew
|
||||
{
|
||||
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
|
||||
NSString *firstVersion = [[NSUserDefaults standardUserDefaults] stringForKey:kUDFirstVersionKey];
|
||||
NSString * currentVersion =
|
||||
[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
|
||||
NSString * firstVersion = [[NSUserDefaults standardUserDefaults] stringForKey:kUDFirstVersionKey];
|
||||
if (!firstVersion.length || firstVersionIsLessThanSecond(firstVersion, currentVersion))
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (NSInteger)daysBetweenNowAndDate:(NSDate*)fromDate
|
||||
+ (NSInteger)daysBetweenNowAndDate:(NSDate *)fromDate
|
||||
{
|
||||
if (!fromDate)
|
||||
return 0;
|
||||
|
||||
NSDate *now = NSDate.date;
|
||||
NSCalendar *calendar = [NSCalendar currentCalendar];
|
||||
NSDate * now = NSDate.date;
|
||||
NSCalendar * calendar = [NSCalendar currentCalendar];
|
||||
[calendar rangeOfUnit:NSCalendarUnitDay startDate:&fromDate interval:NULL forDate:fromDate];
|
||||
[calendar rangeOfUnit:NSCalendarUnitDay startDate:&now interval:NULL forDate:now];
|
||||
NSDateComponents *difference = [calendar components:NSCalendarUnitDay fromDate:fromDate toDate:now options:0];
|
||||
NSDateComponents * difference =
|
||||
[calendar components:NSCalendarUnitDay fromDate:fromDate toDate:now options:0];
|
||||
return difference.day;
|
||||
}
|
||||
|
||||
|
@ -998,14 +1025,15 @@ using namespace osm_auth_ios;
|
|||
{
|
||||
NSURLSession * session = [NSURLSession sharedSession];
|
||||
NSURL * url = [NSURL URLWithString:@(AD_PERMISION_SERVER_URL)];
|
||||
NSURLSessionDataTask * task = [session dataTaskWithURL:url
|
||||
completionHandler:^(NSData * data, NSURLResponse * response,
|
||||
NSError * error)
|
||||
{
|
||||
bool adServerForbidden = (error || [(NSHTTPURLResponse *)response statusCode] != 200);
|
||||
settings::Set(kAdServerForbiddenKey, adServerForbidden);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [self.mapViewController refreshAd]; });
|
||||
}];
|
||||
NSURLSessionDataTask * task = [session
|
||||
dataTaskWithURL:url
|
||||
completionHandler:^(NSData * data, NSURLResponse * response, NSError * error) {
|
||||
bool adServerForbidden = (error || [(NSHTTPURLResponse *)response statusCode] != 200);
|
||||
settings::Set(kAdServerForbiddenKey, adServerForbidden);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.mapViewController refreshAd];
|
||||
});
|
||||
}];
|
||||
[task resume];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,45 +7,27 @@ class MWMRoutePoint
|
|||
public:
|
||||
MWMRoutePoint() = default;
|
||||
|
||||
MWMRoutePoint(m2::PointD const & p, NSString * n) : m_point(p), m_name(n), m_isMyPosition(false) {}
|
||||
|
||||
explicit MWMRoutePoint(m2::PointD const & p) : m_point(p), m_name(L(@"p2p_your_location")), m_isMyPosition(true) {}
|
||||
|
||||
bool operator ==(MWMRoutePoint const & p) const
|
||||
MWMRoutePoint(m2::PointD const & p, NSString * n) : m_point(p), m_name(n), m_isMyPosition(false)
|
||||
{
|
||||
return m_point.EqualDxDy(p.m_point, 0.00000001) && [m_name isEqualToString:p.m_name] && m_isMyPosition == p.m_isMyPosition;
|
||||
}
|
||||
|
||||
bool operator !=(MWMRoutePoint const & p) const
|
||||
explicit MWMRoutePoint(m2::PointD const & p)
|
||||
: m_point(p), m_name(L(@"p2p_your_location")), m_isMyPosition(true)
|
||||
{
|
||||
return !(*this == p);
|
||||
}
|
||||
|
||||
static MWMRoutePoint MWMRoutePointZero()
|
||||
bool operator==(MWMRoutePoint const & p) const
|
||||
{
|
||||
return MWMRoutePoint(m2::PointD::Zero(), @"");
|
||||
}
|
||||
|
||||
m2::PointD const & Point() const
|
||||
{
|
||||
return m_point;
|
||||
}
|
||||
|
||||
NSString * Name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool IsMyPosition() const
|
||||
{
|
||||
return m_isMyPosition;
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return *this != MWMRoutePoint::MWMRoutePointZero();
|
||||
return m_point.EqualDxDy(p.m_point, 0.00000001) && [m_name isEqualToString:p.m_name] &&
|
||||
m_isMyPosition == p.m_isMyPosition;
|
||||
}
|
||||
|
||||
bool operator!=(MWMRoutePoint const & p) const { return !(*this == p); }
|
||||
static MWMRoutePoint MWMRoutePointZero() { return MWMRoutePoint(m2::PointD::Zero(), @""); }
|
||||
m2::PointD const & Point() const { return m_point; }
|
||||
NSString * Name() const { return m_name; }
|
||||
bool IsMyPosition() const { return m_isMyPosition; }
|
||||
bool IsValid() const { return *this != MWMRoutePoint::MWMRoutePointZero(); }
|
||||
private:
|
||||
m2::PointD m_point;
|
||||
NSString * m_name;
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
- (void)swapPointsAndRebuild;
|
||||
- (void)buildFromPoint:(MWMRoutePoint const &)start bestRouter:(BOOL)bestRouter;
|
||||
- (void)buildToPoint:(MWMRoutePoint const &)finish bestRouter:(BOOL)bestRouter;
|
||||
- (void)buildFromPoint:(MWMRoutePoint const &)start toPoint:(MWMRoutePoint const &)finish bestRouter:(BOOL)bestRouter;
|
||||
- (void)buildFromPoint:(MWMRoutePoint const &)start
|
||||
toPoint:(MWMRoutePoint const &)finish
|
||||
bestRouter:(BOOL)bestRouter;
|
||||
- (void)rebuildWithBestRouter:(BOOL)bestRouter;
|
||||
- (void)start;
|
||||
- (void)stop;
|
||||
|
@ -23,7 +25,8 @@
|
|||
- (instancetype)copy __attribute__((unavailable("call +router instead")));
|
||||
- (instancetype)copyWithZone:(NSZone *)zone __attribute__((unavailable("call +router instead")));
|
||||
+ (instancetype)alloc __attribute__((unavailable("call +router instead")));
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable("call +router instead")));
|
||||
+ (instancetype)new __attribute__((unavailable("call +router instead")));
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone
|
||||
__attribute__((unavailable("call +router instead")));
|
||||
+ (instancetype) new __attribute__((unavailable("call +router instead")));
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMLocationHelpers.h"
|
||||
#import "MWMLocationManager.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMNavigationDashboardManager.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "RouteState.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
|
@ -33,10 +33,7 @@ MWMRoutePoint lastLocationPoint()
|
|||
return lastLocation ? MWMRoutePoint(lastLocation.mercator) : MWMRoutePoint::MWMRoutePointZero();
|
||||
}
|
||||
|
||||
bool isMarkerPoint(MWMRoutePoint const & point)
|
||||
{
|
||||
return point.IsValid() && !point.IsMyPosition();
|
||||
}
|
||||
bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !point.IsMyPosition(); }
|
||||
} // namespace
|
||||
|
||||
@interface MWMRouter ()<MWMLocationObserver, MWMFrameworkRouteBuilderObserver>
|
||||
|
@ -88,7 +85,6 @@ bool isMarkerPoint(MWMRoutePoint const & point)
|
|||
}
|
||||
|
||||
- (RouterType)type { return GetFramework().GetRouter(); }
|
||||
|
||||
- (BOOL)arePointsValidForRouting
|
||||
{
|
||||
MWMRoutePoint const zeroPoint = MWMRoutePoint::MWMRoutePointZero();
|
||||
|
@ -119,7 +115,9 @@ bool isMarkerPoint(MWMRoutePoint const & point)
|
|||
[self rebuildWithBestRouter:bestRouter];
|
||||
}
|
||||
|
||||
- (void)buildFromPoint:(MWMRoutePoint const &)startPoint toPoint:(MWMRoutePoint const &)finishPoint bestRouter:(BOOL)bestRouter
|
||||
- (void)buildFromPoint:(MWMRoutePoint const &)startPoint
|
||||
toPoint:(MWMRoutePoint const &)finishPoint
|
||||
bestRouter:(BOOL)bestRouter
|
||||
{
|
||||
self.startPoint = startPoint.IsValid() ? startPoint : lastLocationPoint();
|
||||
self.finishPoint = finishPoint.IsValid() ? finishPoint : lastLocationPoint();
|
||||
|
|
|
@ -21,28 +21,37 @@ CGFloat scaled(CGFloat f)
|
|||
{
|
||||
return f / 255.;
|
||||
}
|
||||
|
||||
NSDictionary<NSString *, UIColor *> * night =
|
||||
@{
|
||||
@"primaryDark" : [UIColor colorWithRed:scaled(25.) green:scaled(30) blue:scaled(35.) alpha:alpha100],
|
||||
NSDictionary<NSString *, UIColor *> * night = @{
|
||||
@"primaryDark" :
|
||||
[UIColor colorWithRed:scaled(25.) green:scaled(30) blue:scaled(35.) alpha:alpha100],
|
||||
@"primary" : [UIColor colorWithRed:scaled(45.) green:scaled(50.) blue:scaled(55.) alpha:alpha100],
|
||||
// Light green color
|
||||
@"primaryLight" : [UIColor colorWithRed:scaled(65.) green:scaled(70.) blue:scaled(75.) alpha:alpha100],
|
||||
@"menuBackground" : [UIColor colorWithRed:scaled(45.) green:scaled(50.) blue:scaled(55.) alpha:alpha80],
|
||||
@"downloadBadgeBackground" : [UIColor colorWithRed:scaled(230.) green:scaled(70.) blue:scaled(60.) alpha:alpha100],
|
||||
@"primaryLight" :
|
||||
[UIColor colorWithRed:scaled(65.) green:scaled(70.) blue:scaled(75.) alpha:alpha100],
|
||||
@"menuBackground" :
|
||||
[UIColor colorWithRed:scaled(45.) green:scaled(50.) blue:scaled(55.) alpha:alpha80],
|
||||
@"downloadBadgeBackground" :
|
||||
[UIColor colorWithRed:scaled(230.) green:scaled(70.) blue:scaled(60.) alpha:alpha100],
|
||||
// Background color && press color
|
||||
@"pressBackground" : [UIColor colorWithRed:scaled(50.) green:scaled(54.) blue:scaled(58.) alpha:alpha100],
|
||||
@"pressBackground" :
|
||||
[UIColor colorWithRed:scaled(50.) green:scaled(54.) blue:scaled(58.) alpha:alpha100],
|
||||
// Red color (use for status closed in place page)
|
||||
@"red" : [UIColor colorWithRed:scaled(230.) green:scaled(70.) blue:scaled(60.) alpha:alpha100],
|
||||
@"errorPink" : [UIColor colorWithRed:scaled(246.) green:scaled(60.) blue:scaled(51.) alpha:alpha26],
|
||||
@"errorPink" :
|
||||
[UIColor colorWithRed:scaled(246.) green:scaled(60.) blue:scaled(51.) alpha:alpha26],
|
||||
// Orange color (use for status 15 min in place page)
|
||||
@"orange" : [UIColor colorWithRed:250. green:scaled(190.) blue:scaled(10.) alpha:alpha100],
|
||||
// Blue color (use for links and phone numbers)
|
||||
@"linkBlue" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha100],
|
||||
@"linkBlueHighlighted" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30],
|
||||
@"linkBlueDark" : [UIColor colorWithRed:scaled(200.) green:scaled(180.) blue:scaled(110.) alpha:alpha100],
|
||||
@"buttonRed" : [UIColor colorWithRed:scaled(244.) green:scaled(67.) blue:scaled(67.) alpha:alpha100],
|
||||
@"buttonRedHighlighted" : [UIColor colorWithRed:scaled(183.) green:scaled(28.) blue:scaled(28.) alpha:alpha100],
|
||||
@"linkBlue" :
|
||||
[UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha100],
|
||||
@"linkBlueHighlighted" :
|
||||
[UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30],
|
||||
@"linkBlueDark" :
|
||||
[UIColor colorWithRed:scaled(200.) green:scaled(180.) blue:scaled(110.) alpha:alpha100],
|
||||
@"buttonRed" :
|
||||
[UIColor colorWithRed:scaled(244.) green:scaled(67.) blue:scaled(67.) alpha:alpha100],
|
||||
@"buttonRedHighlighted" :
|
||||
[UIColor colorWithRed:scaled(183.) green:scaled(28.) blue:scaled(28.) alpha:alpha100],
|
||||
@"blackPrimaryText" : [UIColor colorWithWhite:1. alpha:alpha90],
|
||||
@"blackSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha70],
|
||||
@"blackHintText" : [UIColor colorWithWhite:1. alpha:alpha30],
|
||||
|
@ -50,32 +59,44 @@ NSDictionary<NSString *, UIColor *> * night =
|
|||
@"white" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha100],
|
||||
@"whiteSecondaryText" : [UIColor colorWithWhite:0. alpha:alpha70],
|
||||
@"whiteHintText" : [UIColor colorWithWhite:0. alpha:alpha26],
|
||||
@"buttonDisabledBlueText" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30],
|
||||
@"alertBackground" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha90],
|
||||
@"buttonDisabledBlueText" :
|
||||
[UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30],
|
||||
@"alertBackground" :
|
||||
[UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha90],
|
||||
@"blackOpaque" : [UIColor colorWithWhite:1. alpha:alpha04]
|
||||
};
|
||||
|
||||
NSDictionary<NSString *, UIColor *> * day =
|
||||
@{
|
||||
@"primaryDark" : [UIColor colorWithRed:scaled(24.) green:scaled(128) blue:scaled(68.) alpha:alpha100],
|
||||
@"primary" : [UIColor colorWithRed:scaled(32.) green:scaled(152.) blue:scaled(82.) alpha:alpha100],
|
||||
NSDictionary<NSString *, UIColor *> * day = @{
|
||||
@"primaryDark" :
|
||||
[UIColor colorWithRed:scaled(24.) green:scaled(128) blue:scaled(68.) alpha:alpha100],
|
||||
@"primary" :
|
||||
[UIColor colorWithRed:scaled(32.) green:scaled(152.) blue:scaled(82.) alpha:alpha100],
|
||||
// Light green color
|
||||
@"primaryLight" : [UIColor colorWithRed:scaled(36.) green:scaled(180.) blue:scaled(98.) alpha:alpha100],
|
||||
@"primaryLight" :
|
||||
[UIColor colorWithRed:scaled(36.) green:scaled(180.) blue:scaled(98.) alpha:alpha100],
|
||||
@"menuBackground" : [UIColor colorWithWhite:1. alpha:alpha80],
|
||||
@"downloadBadgeBackground" : [UIColor colorWithRed:scaled(255.) green:scaled(55.) blue:scaled(35.) alpha:alpha100],
|
||||
@"downloadBadgeBackground" :
|
||||
[UIColor colorWithRed:scaled(255.) green:scaled(55.) blue:scaled(35.) alpha:alpha100],
|
||||
// Background color && press color
|
||||
@"pressBackground" : [UIColor colorWithRed:scaled(245.) green:scaled(245.) blue:scaled(245.) alpha:alpha100],
|
||||
@"pressBackground" :
|
||||
[UIColor colorWithRed:scaled(245.) green:scaled(245.) blue:scaled(245.) alpha:alpha100],
|
||||
// Red color (use for status closed in place page)
|
||||
@"red" : [UIColor colorWithRed:scaled(230.) green:scaled(15.) blue:scaled(35.) alpha:alpha100],
|
||||
@"errorPink" : [UIColor colorWithRed:scaled(246.) green:scaled(60.) blue:scaled(51.) alpha:alpha12],
|
||||
@"errorPink" :
|
||||
[UIColor colorWithRed:scaled(246.) green:scaled(60.) blue:scaled(51.) alpha:alpha12],
|
||||
// Orange color (use for status 15 min in place page)
|
||||
@"orange" : [UIColor colorWithRed:1. green:scaled(120.) blue:scaled(5.) alpha:alpha100],
|
||||
// Blue color (use for links and phone numbers)
|
||||
@"linkBlue" : [UIColor colorWithRed:scaled(30.) green:scaled(150.) blue:scaled(240.) alpha:alpha100],
|
||||
@"linkBlueHighlighted" : [UIColor colorWithRed:scaled(30.) green:scaled(150.) blue:scaled(240.) alpha:alpha30],
|
||||
@"linkBlueDark" : [UIColor colorWithRed:scaled(25.) green:scaled(135.) blue:scaled(215.) alpha:alpha100],
|
||||
@"buttonRed" : [UIColor colorWithRed:scaled(244.) green:scaled(67.) blue:scaled(67.) alpha:alpha100],
|
||||
@"buttonRedHighlighted" : [UIColor colorWithRed:scaled(183.) green:scaled(28.) blue:scaled(28.) alpha:alpha100],
|
||||
@"linkBlue" :
|
||||
[UIColor colorWithRed:scaled(30.) green:scaled(150.) blue:scaled(240.) alpha:alpha100],
|
||||
@"linkBlueHighlighted" :
|
||||
[UIColor colorWithRed:scaled(30.) green:scaled(150.) blue:scaled(240.) alpha:alpha30],
|
||||
@"linkBlueDark" :
|
||||
[UIColor colorWithRed:scaled(25.) green:scaled(135.) blue:scaled(215.) alpha:alpha100],
|
||||
@"buttonRed" :
|
||||
[UIColor colorWithRed:scaled(244.) green:scaled(67.) blue:scaled(67.) alpha:alpha100],
|
||||
@"buttonRedHighlighted" :
|
||||
[UIColor colorWithRed:scaled(183.) green:scaled(28.) blue:scaled(28.) alpha:alpha100],
|
||||
@"blackPrimaryText" : [UIColor colorWithWhite:0. alpha:alpha87],
|
||||
@"blackSecondaryText" : [UIColor colorWithWhite:0. alpha:alpha54],
|
||||
@"blackHintText" : [UIColor colorWithWhite:0. alpha:alpha26],
|
||||
|
@ -83,7 +104,8 @@ NSDictionary<NSString *, UIColor *> * day =
|
|||
@"white" : [UIColor colorWithWhite:1. alpha:alpha100],
|
||||
@"whiteSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha54],
|
||||
@"whiteHintText" : [UIColor colorWithWhite:1. alpha:alpha30],
|
||||
@"buttonDisabledBlueText" :[UIColor colorWithRed:scaled(3.) green:scaled(122.) blue:scaled(255.) alpha:alpha26],
|
||||
@"buttonDisabledBlueText" :
|
||||
[UIColor colorWithRed:scaled(3.) green:scaled(122.) blue:scaled(255.) alpha:alpha26],
|
||||
@"alertBackground" : [UIColor colorWithWhite:1. alpha:alpha90],
|
||||
@"blackOpaque" : [UIColor colorWithWhite:0. alpha:alpha04]
|
||||
};
|
||||
|
@ -192,17 +214,8 @@ UIColor * color(SEL cmd)
|
|||
{
|
||||
return color(_cmd);
|
||||
}
|
||||
|
||||
+ (UIColor *)buttonRed
|
||||
{
|
||||
return color(_cmd);
|
||||
}
|
||||
|
||||
+ (UIColor *)buttonRedHighlighted
|
||||
{
|
||||
return color(_cmd);
|
||||
}
|
||||
|
||||
+ (UIColor *)buttonRed { return color(_cmd); }
|
||||
+ (UIColor *)buttonRedHighlighted { return color(_cmd); }
|
||||
+ (UIColor *)blackPrimaryText
|
||||
{
|
||||
return color(_cmd);
|
||||
|
|
|
@ -197,17 +197,8 @@ NSString * const kLightFontName = @"HelveticaNeue-Light";
|
|||
{
|
||||
return [UIFont boldSystemFontOfSize:17];
|
||||
}
|
||||
|
||||
+ (UIFont *)bold22
|
||||
{
|
||||
return [UIFont boldSystemFontOfSize:22];
|
||||
}
|
||||
|
||||
+ (UIFont *)bold24
|
||||
{
|
||||
return [UIFont boldSystemFontOfSize:24];
|
||||
}
|
||||
|
||||
+ (UIFont *)bold22 { return [UIFont boldSystemFontOfSize:22]; }
|
||||
+ (UIFont *)bold24 { return [UIFont boldSystemFontOfSize:24]; }
|
||||
+ (UIFont *)bold48
|
||||
{
|
||||
return [UIFont boldSystemFontOfSize:48];
|
||||
|
|
Loading…
Add table
Reference in a new issue