[ios] Added base rate dialog behavior.

This commit is contained in:
VladiMihaylenko 2015-03-25 20:55:47 +03:00 committed by Alex Zolotarev
parent fd3fbfce5a
commit 24e19dd399
44 changed files with 1237 additions and 302 deletions

View file

@ -18,7 +18,9 @@
- (instancetype)initWithViewController:(UIViewController *)viewController;
- (void)presentAlert:(routing::IRouter::ResultCode)type;
- (void)presentDownloaderAlertWithCountrieIndex:(const storage::TIndex&)index;
- (void)presentDownloaderAlertWithCountryIndex:(const storage::TIndex&)index;
- (void)presentRateAlert;
- (void)presentFeedbackAlertWithStarsCount:(NSUInteger)starsCount;
- (void)closeAlert;
@end

View file

@ -28,8 +28,6 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.frame = UIApplication.sharedApplication.keyWindow.bounds;
// Need only for iOS 5.
if ([[[UIDevice currentDevice] systemVersion] integerValue] < 6) {
self.tap.delegate = self;
@ -38,8 +36,18 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
#pragma mark - Actions
- (void)presentDownloaderAlertWithCountrieIndex:(const storage::TIndex&)index {
MWMAlert *alert = [MWMAlert downloaderAlertWithCountrieIndex:index];
- (void)presentRateAlert {
MWMAlert *alert = [MWMAlert rateAlert];
[self displayAlert:alert];
}
- (void)presentFeedbackAlertWithStarsCount:(NSUInteger)starsCount {
MWMAlert *alert = [MWMAlert feedbackAlertWithStarsCount:starsCount];
[self displayAlert:alert];
}
- (void)presentDownloaderAlertWithCountryIndex:(const storage::TIndex&)index {
MWMAlert *alert = [MWMAlert downloaderAlertWithCountryIndex:index];
[self displayAlert:alert];
}
@ -53,6 +61,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
[self.ownerViewController addChildViewController:self];
self.view.center = self.ownerViewController.view.center;
[self.ownerViewController.view addSubview:self.view];
[[[[UIApplication sharedApplication] delegate] window] addSubview:self.view];
self.view.frame = [[[[UIApplication sharedApplication] delegate] window] frame];
[self.view addSubview:alert];
alert.center = self.view.center;
}

View file

@ -17,6 +17,8 @@
@property (nonatomic, weak) MWMAlertViewController *alertController;
+ (MWMAlert *)alert:(routing::IRouter::ResultCode)type;
+ (MWMAlert *)downloaderAlertWithCountrieIndex:(const storage::TIndex&)index;
+ (MWMAlert *)downloaderAlertWithCountryIndex:(const storage::TIndex&)index;
+ (MWMAlert *)rateAlert;
+ (MWMAlert *)feedbackAlertWithStarsCount:(NSUInteger)starsCount;
@end

View file

@ -10,13 +10,23 @@
#import "MWMDownloadTransitMapAlert.h"
#import "MWMDownloadAllMapsAlert.h"
#import "MWMDefaultAlert.h"
#import "MWMFeedbackAlert.h"
#import "MWMRateAlert.h"
extern UIColor * const kActiveDownloaderViewColor = [UIColor colorWithRed:211/255. green:209/255. blue:205/255. alpha:1.];
@implementation MWMAlert
+ (MWMAlert *)downloaderAlertWithCountrieIndex:(const storage::TIndex&)index {
return [MWMDownloadTransitMapAlert alertWithCountrieIndex:index];
+ (MWMAlert *)rateAlert {
return [MWMRateAlert alert];
}
+ (MWMAlert *)feedbackAlertWithStarsCount:(NSUInteger)starsCount {
return [MWMFeedbackAlert alertWithStarsCount:starsCount];
}
+ (MWMAlert *)downloaderAlertWithCountryIndex:(const storage::TIndex&)index {
return [MWMDownloadTransitMapAlert alertWithCountryIndex:index];
}
+ (MWMAlert *)alert:(routing::IRouter::ResultCode)type {

View file

@ -1,15 +0,0 @@
//
// MWMRouteNotFoundDefaultAlert+Configure.h
// Maps
//
// Created by v.mikhaylenko on 12.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMDefaultAlert.h"
@interface MWMDefaultAlert (Configure)
- (void)configure;
@end

View file

@ -1,29 +0,0 @@
//
// MWMRouteNotFoundDefaultAlert+Configure.m
// Maps
//
// Created by v.mikhaylenko on 12.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMDefaultAlert+Configure.h"
#import "UIKitCategories.h"
@implementation MWMDefaultAlert (Configure)
- (void)configure {
[self.messageLabel sizeToFit];
[self configureViewSize];
}
- (void)configureViewSize {
const CGFloat topMainViewOffset = 17.;
const CGFloat minMainViewHeight = 144.;
const CGFloat actualMainViewHeight = 2 * topMainViewOffset + self.messageLabel.height + self.okButton.height;
self.height = actualMainViewHeight >= minMainViewHeight ? actualMainViewHeight : minMainViewHeight;
self.messageLabel.minY = topMainViewOffset;
self.deviderLine.minY = self.height - self.okButton.height;
self.okButton.minY = self.deviderLine.minY + self.deviderLine.height;
}
@end

View file

@ -17,8 +17,4 @@
+ (instancetype)noCurrentPositionAlert;
+ (instancetype)pointsInDifferentMWMAlert;
@property (nonatomic, weak, readonly) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak, readonly) IBOutlet UIButton *okButton;
@property (nonatomic, weak, readonly) IBOutlet UIView *deviderLine;
@end

View file

@ -8,14 +8,14 @@
#import "MWMDefaultAlert.h"
#import "MWMAlertViewController.h"
#import "MWMDefaultAlert+Configure.h"
#import "UILabel+RuntimeAttributes.h"
#import "UIKitCategories.h"
@interface MWMDefaultAlert ()
@property (nonatomic, weak, readwrite) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak, readwrite) IBOutlet UIButton *okButton;
@property (nonatomic, weak, readwrite) IBOutlet UIView *deviderLine;
@property (nonatomic, weak) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak) IBOutlet UIButton *okButton;
@property (nonatomic, weak) IBOutlet UIView *deviderLine;
@end
@ -60,4 +60,21 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
[self.alertController closeAlert];
}
#pragma mark - Configure
- (void)configure {
[self.messageLabel sizeToFit];
[self configureViewSize];
}
- (void)configureViewSize {
const CGFloat topMainViewOffset = 17.;
const CGFloat minMainViewHeight = 144.;
const CGFloat actualMainViewHeight = 2 * topMainViewOffset + self.messageLabel.height + self.okButton.height;
self.height = actualMainViewHeight >= minMainViewHeight ? actualMainViewHeight : minMainViewHeight;
self.messageLabel.minY = topMainViewOffset;
self.deviderLine.minY = self.height - self.okButton.height;
self.okButton.minY = self.deviderLine.minY + self.deviderLine.height;
}
@end

View file

@ -1,15 +0,0 @@
//
// MWMDownloadAllMapsAlert+Configure.h
// Maps
//
// Created by v.mikhaylenko on 12.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMDownloadAllMapsAlert.h"
@interface MWMDownloadAllMapsAlert (Configure)
- (void)configure;
@end

View file

@ -1,33 +0,0 @@
//
// MWMDownloadAllMapsAlert+Configure.m
// Maps
//
// Created by v.mikhaylenko on 12.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMDownloadAllMapsAlert+Configure.h"
#import "UIKitCategories.h"
@implementation MWMDownloadAllMapsAlert (Configure)
- (void)configure {
[self.titleLabel sizeToFit];
[self.messageLabel sizeToFit];
[self configureMainViewSize];
}
- (void)configureMainViewSize {
const CGFloat topMainViewOffset = 17.;
const CGFloat secondMainViewOffset = 14.;
const CGFloat thirdMainViewOffset = 20.;
const CGFloat bottomMainViewOffset = 52.;
const CGFloat mainViewHeight = topMainViewOffset + self.titleLabel.height + secondMainViewOffset + self.messageLabel.height + thirdMainViewOffset + self.specsView.height + bottomMainViewOffset;
self.height = mainViewHeight;
self.titleLabel.minY = topMainViewOffset;
self.messageLabel.minY = self.titleLabel.minY + self.titleLabel.height + secondMainViewOffset;
self.specsView.minY = self.messageLabel.minY + self.messageLabel.height + thirdMainViewOffset;
self.notNowButton.minY = self.specsView.minY + self.specsView.height;
}
@end

View file

@ -12,11 +12,4 @@
+ (instancetype)alert;
@property (nonatomic, weak, readonly) IBOutlet UIView *specsView;
@property (nonatomic, weak, readonly) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak, readonly) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak, readonly) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak, readonly) IBOutlet UIButton *downloadButton;
@property (nonatomic, weak, readonly) IBOutlet UILabel *downloadMapsLabel;
@end

View file

@ -9,15 +9,15 @@
#import "MWMDownloadAllMapsAlert.h"
#import "MWMAlertViewController.h"
#import "CountryTreeVC.h"
#import "MWMDownloadAllMapsAlert+Configure.h"
#import "UIKitCategories.h"
@interface MWMDownloadAllMapsAlert ()
@property (nonatomic, weak, readwrite) IBOutlet UIView *specsView;
@property (nonatomic, weak, readwrite) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak, readwrite) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak, readwrite) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak, readwrite) IBOutlet UIButton *downloadButton;
@property (nonatomic, weak, readwrite) IBOutlet UILabel *downloadMapsLabel;
@property (nonatomic, weak) IBOutlet UIView *specsView;
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak) IBOutlet UIButton *downloadButton;
@property (nonatomic, weak) IBOutlet UILabel *downloadMapsLabel;
@end
static NSString * const kDownloadAllMapsAlertNibName = @"MWMDownloadAllMapsAlert";
@ -48,4 +48,25 @@ static NSInteger const kNodePositionForDownloadMaps = -1;
}];
}
#pragma mark - Configure
- (void)configure {
[self.titleLabel sizeToFit];
[self.messageLabel sizeToFit];
[self configureMainViewSize];
}
- (void)configureMainViewSize {
const CGFloat topMainViewOffset = 17.;
const CGFloat secondMainViewOffset = 14.;
const CGFloat thirdMainViewOffset = 20.;
const CGFloat bottomMainViewOffset = 52.;
const CGFloat mainViewHeight = topMainViewOffset + self.titleLabel.height + secondMainViewOffset + self.messageLabel.height + thirdMainViewOffset + self.specsView.height + bottomMainViewOffset;
self.height = mainViewHeight;
self.titleLabel.minY = topMainViewOffset;
self.messageLabel.minY = self.titleLabel.minY + self.titleLabel.height + secondMainViewOffset;
self.specsView.minY = self.messageLabel.minY + self.messageLabel.height + thirdMainViewOffset;
self.notNowButton.minY = self.specsView.minY + self.specsView.height;
}
@end

View file

@ -1,13 +0,0 @@
//
// MWMDownloadTransitMapAlert+Configure.h
// Maps
//
// Created by v.mikhaylenko on 12.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMDownloadTransitMapAlert.h"
@interface MWMDownloadTransitMapAlert (Configure)
- (void)configure;
@end

View file

@ -1,45 +0,0 @@
//
// MWMDownloadTransitMapAlert+Configure.m
// Maps
//
// Created by v.mikhaylenko on 12.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMDownloadTransitMapAlert+Configure.h"
#import "UIKitCategories.h"
@implementation MWMDownloadTransitMapAlert (Configure)
- (void)configure {
[self.messageLabel sizeToFit];
[self.titleLabel sizeToFit];
[self.countryLabel sizeToFit];
[self configureSpecsViewSize];
[self configureMaintViewSize];
}
- (void)configureSpecsViewSize {
const CGFloat topSpecsViewOffset = 16.;
const CGFloat specsViewHeight = 2 * topSpecsViewOffset + self.countryLabel.frame.size.height;
self.specsView.height = specsViewHeight;
self.countryLabel.minY = topSpecsViewOffset;
self.sizeLabel.center = CGPointMake(self.sizeLabel.center.x, self.countryLabel.center.y);
}
- (void)configureMaintViewSize {
const CGFloat topMainViewOffset = 17.;
const CGFloat secondMainViewOffset = 14.;
const CGFloat thirdMainViewOffset = 20.;
const CGFloat bottomMainViewOffset = 52.;
const CGFloat mainViewHeight = topMainViewOffset + self.titleLabel.frame.size.height + secondMainViewOffset + self.messageLabel.frame.size.height + thirdMainViewOffset + self.specsView.frame.size.height + bottomMainViewOffset;
self.height = mainViewHeight;
self.titleLabel.minY = topMainViewOffset;
self.messageLabel.minY = self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + secondMainViewOffset;
self.specsView.minY = self.messageLabel.frame.origin.y + self.messageLabel.frame.size.height + thirdMainViewOffset;
self.notNowButton.minY = self.specsView.frame.origin.y + self.specsView.frame.size.height;
self.downloadButton.minY = self.notNowButton.frame.origin.y;
}
@end

View file

@ -13,14 +13,6 @@
@interface MWMDownloadTransitMapAlert : MWMAlert
+ (instancetype)alertWithCountrieIndex:(const storage::TIndex)index;
@property (nonatomic, weak, readonly) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak, readonly) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak, readonly) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak, readonly) IBOutlet UIButton *downloadButton;
@property (nonatomic, weak, readonly) IBOutlet UILabel *sizeLabel;
@property (nonatomic, weak, readonly) IBOutlet UILabel *countryLabel;
@property (nonatomic, weak, readonly) IBOutlet UIView *specsView;
+ (instancetype)alertWithCountryIndex:(const storage::TIndex)index;
@end

View file

@ -9,18 +9,18 @@
#import "MWMDownloadTransitMapAlert.h"
#import "MWMAlertViewController.h"
#import "ActiveMapsVC.h"
#import "MWMDownloadTransitMapAlert+Configure.h"
#import "UIKitCategories.h"
typedef void (^MWMDownloaderBlock)();
@interface MWMDownloadTransitMapAlert ()
@property (nonatomic, weak, readwrite) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak, readwrite) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak, readwrite) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak, readwrite) IBOutlet UIButton *downloadButton;
@property (nonatomic, weak, readwrite) IBOutlet UILabel *sizeLabel;
@property (nonatomic, weak, readwrite) IBOutlet UILabel *countryLabel;
@property (nonatomic, weak, readwrite) IBOutlet UIView *specsView;
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak) IBOutlet UIButton *downloadButton;
@property (nonatomic, weak) IBOutlet UILabel *sizeLabel;
@property (nonatomic, weak) IBOutlet UILabel *countryLabel;
@property (nonatomic, weak) IBOutlet UIView *specsView;
@property (nonatomic, copy) MWMDownloaderBlock downloaderBlock;
@end
@ -29,7 +29,7 @@ extern UIColor * const kActiveDownloaderViewColor;
@implementation MWMDownloadTransitMapAlert
+ (instancetype)alertWithCountrieIndex:(const storage::TIndex)index {
+ (instancetype)alertWithCountryIndex:(const storage::TIndex)index {
MWMDownloadTransitMapAlert *alert = [[[NSBundle mainBundle] loadNibNamed:kDownloadTransitMapAlertNibName owner:self options:nil] firstObject];
ActiveMapsLayout& layout = GetFramework().GetCountryTree().GetActiveMapLayout();
alert.countryLabel.text = [NSString stringWithUTF8String:layout.GetFormatedCountryName(index).c_str()];
@ -66,4 +66,36 @@ extern UIColor * const kActiveDownloaderViewColor;
[self.alertController.ownerViewController.navigationController pushViewController:activeMapsViewController animated:YES];
}
#pragma mark - Configure
- (void)configure {
[self.messageLabel sizeToFit];
[self.titleLabel sizeToFit];
[self.countryLabel sizeToFit];
[self configureSpecsViewSize];
[self configureMaintViewSize];
}
- (void)configureSpecsViewSize {
const CGFloat topSpecsViewOffset = 16.;
const CGFloat specsViewHeight = 2 * topSpecsViewOffset + self.countryLabel.frame.size.height;
self.specsView.height = specsViewHeight;
self.countryLabel.minY = topSpecsViewOffset;
self.sizeLabel.center = CGPointMake(self.sizeLabel.center.x, self.countryLabel.center.y);
}
- (void)configureMaintViewSize {
const CGFloat topMainViewOffset = 17.;
const CGFloat secondMainViewOffset = 14.;
const CGFloat thirdMainViewOffset = 20.;
const CGFloat bottomMainViewOffset = 52.;
const CGFloat mainViewHeight = topMainViewOffset + self.titleLabel.frame.size.height + secondMainViewOffset + self.messageLabel.frame.size.height + thirdMainViewOffset + self.specsView.frame.size.height + bottomMainViewOffset;
self.height = mainViewHeight;
self.titleLabel.minY = topMainViewOffset;
self.messageLabel.minY = self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + secondMainViewOffset;
self.specsView.minY = self.messageLabel.frame.origin.y + self.messageLabel.frame.size.height + thirdMainViewOffset;
self.notNowButton.minY = self.specsView.frame.origin.y + self.specsView.frame.size.height;
self.downloadButton.minY = self.notNowButton.frame.origin.y;
}
@end

View file

@ -0,0 +1,15 @@
//
// MWMFeedbackAlert.h
// Maps
//
// Created by v.mikhaylenko on 25.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMAlert.h"
@interface MWMFeedbackAlert : MWMAlert
+ (instancetype)alertWithStarsCount:(NSUInteger)starsCount;
@end

View file

@ -0,0 +1,112 @@
//
// MWMFeedbackAlert.m
// Maps
//
// Created by v.mikhaylenko on 25.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMFeedbackAlert.h"
#import "MWMAlertViewController.h"
#import <MessageUI/MFMailComposeViewController.h>
#import "UIKitCategories.h"
#import <sys/utsname.h>
#include "../../platform/platform.hpp"
@interface MWMFeedbackAlert () <MFMailComposeViewControllerDelegate>
@property (nonatomic, weak) IBOutlet UIView *specsView;
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak) IBOutlet UIButton *notNowButton;
@property (nonatomic, weak) IBOutlet UIButton *writeFeedbackButton;
@property (nonatomic, weak) IBOutlet UILabel *writeFeedbackLabel;
@property (nonatomic, assign) NSUInteger starsCount;
@end
static NSString * const kFeedbackAlertNibName = @"MWMFeedbackAlert";
extern NSString * const kiOSEmail;
extern NSDictionary * const deviceNames;
extern UIColor * const kActiveDownloaderViewColor;
extern NSString * const kLocaleUsedInSupportEmails;
@implementation MWMFeedbackAlert
+ (instancetype)alertWithStarsCount:(NSUInteger)starsCount {
MWMFeedbackAlert *alert = [[[NSBundle mainBundle] loadNibNamed:kFeedbackAlertNibName owner:self options:nil] firstObject];
alert.starsCount = starsCount;
[alert configure];
return alert;
}
#pragma mark - Actions
- (IBAction)notNowButtonTap:(id)sender {
[self.alertController closeAlert];
}
- (IBAction)writeFeedbackButtonTap:(id)sender {
[UIView animateWithDuration:0.2f animations:^{
self.specsView.backgroundColor = kActiveDownloaderViewColor;
} completion:^(BOOL finished) {
self.alpha = 0.;
self.alertController.view.alpha = 0.;
if ([MFMailComposeViewController canSendMail])
{
struct utsname systemInfo;
uname(&systemInfo);
NSString * machine = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSString * device = deviceNames[machine];
if (!device)
device = machine;
NSString * languageCode = [[NSLocale preferredLanguages] firstObject];
NSString * language = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails] displayNameForKey:NSLocaleLanguageCode value:languageCode];
NSString * locale = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
NSString * country = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails] displayNameForKey:NSLocaleCountryCode value:locale];
NSString * bundleVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
NSString * text = [NSString stringWithFormat:@"\n\n\n\n- %@ (%@)\n- MAPS.ME %@\n- %@/%@", device, [UIDevice currentDevice].systemVersion, bundleVersion, language, country];
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:[NSString stringWithFormat:@"%@ : %@", L(@"rating_just_rated"),@(self.starsCount)]];
[mailController setToRecipients:@[kiOSEmail]];
[mailController setMessageBody:text isHTML:NO];
[self.alertController.ownerViewController presentViewController:mailController animated:YES completion:nil];
} else {
NSString * text = [NSString stringWithFormat:L(@"email_error_body"), kiOSEmail];
[[[UIAlertView alloc] initWithTitle:L(@"email_error_title") message:text delegate:nil cancelButtonTitle:L(@"ok") otherButtonTitles:nil] show];
}
}];
}
#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self.alertController.ownerViewController dismissViewControllerAnimated:YES completion:^{
[self.alertController closeAlert];
}];
}
#pragma mark - Configure
- (void)configure {
[self.titleLabel sizeToFit];
[self.messageLabel sizeToFit];
[self configureMainViewSize];
}
- (void)configureMainViewSize {
CGFloat const topMainViewOffset = 17.;
CGFloat const secondMainViewOffset = 14.;
CGFloat const thirdMainViewOffset = 20.;
CGFloat const bottomMainViewOffset = 52.;
CGFloat const mainViewHeight = topMainViewOffset + self.titleLabel.height + secondMainViewOffset + self.messageLabel.height + thirdMainViewOffset + self.specsView.height + bottomMainViewOffset;
self.height = mainViewHeight;
self.titleLabel.minY = topMainViewOffset;
self.messageLabel.minY = self.titleLabel.minY + self.titleLabel.height + secondMainViewOffset;
self.specsView.minY = self.messageLabel.minY + self.messageLabel.height + thirdMainViewOffset;
self.notNowButton.minY = self.specsView.minY + self.specsView.height;
}
@end

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="SqL-OZ-441" customClass="MWMFeedbackAlert">
<rect key="frame" x="0.0" y="0.0" width="280" height="227"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Get transit maps" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="29g-Hq-RFn">
<rect key="frame" x="23" y="20" width="232" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="20"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<size key="shadowOffset" width="0.0" height="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_thanks"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" id="Ptx-1H-RaZ">
<rect key="frame" x="0.0" y="126" width="280" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="7A9-TZ-0Um">
<rect key="frame" x="0.0" y="0.0" width="284" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="writeFeedbackButtonTap:" destination="SqL-OZ-441" eventType="touchUpInside" id="F8I-WZ-Lyb"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="rate-send" id="w6k-xO-9ZG">
<rect key="frame" x="25" y="13" width="48" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Champagne-Ardenne" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2kS-eR-ehT">
<rect key="frame" x="81" y="15" width="188" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_send_feedback"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<color key="backgroundColor" red="0.96862745100000003" green="0.96078431369999995" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="HRW-BJ-Ehj">
<rect key="frame" x="140" y="175" width="140" height="52"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="NOT NOW">
<color key="titleColor" red="0.090196078430000007" green="0.61960784310000006" blue="0.30196078430000001" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="later"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="notNowButtonTap:" destination="SqL-OZ-441" eventType="touchUpInside" id="lhK-29-lWb"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Creating routes between regions is only possible when all the transit maps are downloaded and updated." lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fup-8E-4dg">
<rect key="frame" x="23" y="54" width="234" height="52"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_share_ideas"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="layer.shadowUIColor">
<color key="value" red="0.0" green="0.0" blue="0.0" alpha="0.22" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.shadowRadius">
<integer key="value" value="12"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="size" keyPath="layer.shadowOffset">
<size key="value" width="0.0" height="3"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="4"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="messageLabel" destination="fup-8E-4dg" id="r6f-09-JET"/>
<outlet property="notNowButton" destination="HRW-BJ-Ehj" id="EsR-Yc-RxB"/>
<outlet property="specsView" destination="Ptx-1H-RaZ" id="kPN-Gi-Sct"/>
<outlet property="titleLabel" destination="29g-Hq-RFn" id="PJb-B5-EeM"/>
<outlet property="writeFeedbackButton" destination="7A9-TZ-0Um" id="O7a-R9-Nsm"/>
<outlet property="writeFeedbackLabel" destination="2kS-eR-ehT" id="81B-cW-p4b"/>
</connections>
<point key="canvasLocation" x="342" y="260.5"/>
</view>
</objects>
<resources>
<image name="rate-send" width="48" height="24"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="SqL-OZ-441" customClass="MWMFeedbackAlert">
<rect key="frame" x="0.0" y="0.0" width="280" height="227"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Get transit maps" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="29g-Hq-RFn">
<rect key="frame" x="23" y="20" width="232" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="20"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<size key="shadowOffset" width="0.0" height="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_thanks"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" id="Ptx-1H-RaZ">
<rect key="frame" x="0.0" y="126" width="280" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="7A9-TZ-0Um">
<rect key="frame" x="0.0" y="0.0" width="284" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="writeFeedbackButtonTap:" destination="SqL-OZ-441" eventType="touchUpInside" id="F8I-WZ-Lyb"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="rate-send" id="w6k-xO-9ZG">
<rect key="frame" x="25" y="13" width="48" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Champagne-Ardenne" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2kS-eR-ehT">
<rect key="frame" x="81" y="15" width="188" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_send_feedback"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<color key="backgroundColor" red="0.96862745100000003" green="0.96078431369999995" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="HRW-BJ-Ehj">
<rect key="frame" x="140" y="175" width="140" height="52"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="NOT NOW">
<color key="titleColor" red="0.090196078430000007" green="0.61960784310000006" blue="0.30196078430000001" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="later"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="notNowButtonTap:" destination="SqL-OZ-441" eventType="touchUpInside" id="lhK-29-lWb"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Creating routes between regions is only possible when all the transit maps are downloaded and updated." lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fup-8E-4dg">
<rect key="frame" x="23" y="54" width="234" height="52"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_share_ideas"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="layer.shadowUIColor">
<color key="value" red="0.0" green="0.0" blue="0.0" alpha="0.22" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.shadowRadius">
<integer key="value" value="12"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="size" keyPath="layer.shadowOffset">
<size key="value" width="0.0" height="3"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="4"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="messageLabel" destination="fup-8E-4dg" id="r6f-09-JET"/>
<outlet property="notNowButton" destination="HRW-BJ-Ehj" id="EsR-Yc-RxB"/>
<outlet property="specsView" destination="Ptx-1H-RaZ" id="kPN-Gi-Sct"/>
<outlet property="titleLabel" destination="29g-Hq-RFn" id="PJb-B5-EeM"/>
<outlet property="writeFeedbackButton" destination="7A9-TZ-0Um" id="O7a-R9-Nsm"/>
<outlet property="writeFeedbackLabel" destination="2kS-eR-ehT" id="81B-cW-p4b"/>
</connections>
<point key="canvasLocation" x="342" y="260.5"/>
</view>
</objects>
<resources>
<image name="rate-send" width="48" height="24"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -0,0 +1,15 @@
//
// MWMRateAlert.h
// Maps
//
// Created by v.mikhaylenko on 25.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMAlert.h"
@interface MWMRateAlert : MWMAlert
+ (instancetype)alert;
@end

View file

@ -0,0 +1,195 @@
//
// MWMRateAlert.m
// Maps
//
// Created by v.mikhaylenko on 25.03.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import "MWMRateAlert.h"
#import "MWMAlertViewController.h"
#import "UIKitCategories.h"
#include "../../../../../map/dialog_settings.hpp"
extern NSString * const kUDAlreadyRatedKey;
@interface MWMRateAlert ()
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UILabel *messageLabel;
@property (nonatomic, weak) IBOutlet UIButton *oneStarButton;
@property (nonatomic, weak) IBOutlet UIButton *twoStarButton;
@property (nonatomic, weak) IBOutlet UIButton *threeStarButton;
@property (nonatomic, weak) IBOutlet UIButton *fourStarButton;
@property (nonatomic, weak) IBOutlet UIButton *fiveStarButton;
@property (nonatomic, weak) IBOutlet UIImageView *oneStarPushImageView;
@property (nonatomic, weak) IBOutlet UIImageView *twoStarPushImageView;
@property (nonatomic, weak) IBOutlet UIImageView *threeStarPushImageView;
@property (nonatomic, weak) IBOutlet UIImageView *fourStarPushImageView;
@property (nonatomic, weak) IBOutlet UIImageView *fiveStarPushImageView;
@property (nonatomic, weak) IBOutlet UILabel *oneStarLabel;
@property (nonatomic, weak) IBOutlet UILabel *twoStarLabel;
@property (nonatomic, weak) IBOutlet UILabel *threeStarLabel;
@property (nonatomic, weak) IBOutlet UILabel *fourStarLabel;
@property (nonatomic, weak) IBOutlet UILabel *fiveStarLabel;
@property (nonatomic, weak) IBOutlet UIView *rateView;
@property (nonatomic, weak) IBOutlet UIButton *notNowBotton;
@property (nonatomic, weak) IBOutlet UIView *deviderView;
@end
static NSString * const kRateAlertNibName = @"MWMRateAlert";
@implementation MWMRateAlert
+ (instancetype)alert {
MWMRateAlert *alert = [[[NSBundle mainBundle] loadNibNamed:kRateAlertNibName owner:self options:nil] firstObject];
[alert configure];
return alert;
}
#pragma mark - Actions
- (IBAction)oneStarTap:(UILongPressGestureRecognizer *)sender {
[self starButtonLongTap:sender withBegan:^{
[UIView animateWithDuration:0.35f animations:^{
self.oneStarPushImageView.alpha = 1;
self.oneStarButton.selected = YES;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.35f animations:^{
self.oneStarPushImageView.alpha = 0.;
}];
}];
} completion:^{
[self presentAlertWithStarsCount:1];
}];
}
- (IBAction)twoStarTap:(UILongPressGestureRecognizer *)sender {
[self starButtonLongTap:sender withBegan:^{
[UIView animateWithDuration:0.35f animations:^{
self.twoStarPushImageView.alpha = 1;
self.oneStarButton.selected = YES;
self.twoStarButton.selected = YES;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.35f animations:^{
self.twoStarPushImageView.alpha = 0.;
}];
}];
} completion:^{
[self presentAlertWithStarsCount:2];
}];
}
- (IBAction)threeStarTap:(UILongPressGestureRecognizer *)sender {
[self starButtonLongTap:sender withBegan:^{
[UIView animateWithDuration:0.35f animations:^{
self.threeStarPushImageView.alpha = 1.;
self.oneStarButton.selected = YES;
self.twoStarButton.selected = YES;
self.threeStarButton.selected = YES;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.35f animations:^{
self.threeStarPushImageView.alpha = 0.;
}];
}];
} completion:^{
[self presentAlertWithStarsCount:3];
}];
}
- (IBAction)fourStarTap:(UILongPressGestureRecognizer *)sender {
[self starButtonLongTap:sender withBegan:^{
[UIView animateWithDuration:0.35f animations:^{
self.fourStarPushImageView.alpha = 1.;
self.oneStarButton.selected = YES;
self.twoStarButton.selected = YES;
self.threeStarButton.selected = YES;
self.fourStarButton.selected = YES;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.35f animations:^{
self.fourStarPushImageView.alpha = 0.;
}];
}];
} completion:^{
[self presentAlertWithStarsCount:4];
}];
}
- (IBAction)fiveStarTap:(UILongPressGestureRecognizer *)sender {
[self starButtonLongTap:sender withBegan:^{
[UIView animateWithDuration:0.35f animations:^{
self.fiveStarPushImageView.alpha = 1.;
self.oneStarButton.selected = YES;
self.twoStarButton.selected = YES;
self.threeStarButton.selected = YES;
self.fourStarButton.selected = YES;
self.fiveStarButton.selected = YES;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.35f animations:^{
self.fiveStarPushImageView.alpha = 0.;
}];
}];
} completion:^{
dlg_settings::SaveResult(dlg_settings::AppStore, dlg_settings::OK);
[[UIApplication sharedApplication] rateVersionFrom:@"ios_pro_popup"];
[self.alertController closeAlert];
[self setupAlreadyRatedInUserDefaults];
}];
}
- (IBAction)notNowTap:(UILongPressGestureRecognizer *)sender {
[self.alertController closeAlert];
}
- (void)presentAlertWithStarsCount:(NSUInteger)starsCount {
[self removeFromSuperview];
[self.alertController presentFeedbackAlertWithStarsCount:starsCount];
[self setupAlreadyRatedInUserDefaults];
}
- (void)setupAlreadyRatedInUserDefaults {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kUDAlreadyRatedKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)starButtonLongTap:(UILongPressGestureRecognizer *) tap withBegan:(void (^)())began completion:(void (^)())completion {
switch (tap.state) {
case UIGestureRecognizerStateBegan:
began();
break;
case UIGestureRecognizerStateEnded:
completion();
break;
default:
break;
}
}
#pragma mark - Configure
- (void)configure {
self.oneStarPushImageView.alpha = 0.;
self.twoStarPushImageView.alpha = 0.;
self.threeStarPushImageView.alpha = 0.;
self.fourStarPushImageView.alpha = 0.;
self.fiveStarPushImageView.alpha = 0.;
[self.titleLabel sizeToFit];
[self.messageLabel sizeToFit];
CGFloat const topMainViewOffset = 17.;
CGFloat const secondMainViewOffset = 14.;
CGFloat const thirdMainViewOffset = 20.;
CGFloat const minMainViewHeight = 144. + self.deviderView.height + self.notNowBotton.height;
CGFloat const actualMainViewHeight = topMainViewOffset + secondMainViewOffset + (2 * thirdMainViewOffset) + self.titleLabel.height + self.messageLabel.height + self.rateView.height + self.deviderView.height + self.notNowBotton.height;
self.height = actualMainViewHeight >= minMainViewHeight ? actualMainViewHeight : minMainViewHeight;
self.titleLabel.minY = topMainViewOffset;
self.messageLabel.minY = self.titleLabel.maxY + secondMainViewOffset;
self.notNowBotton.minY = self.height - self.notNowBotton.height;
self.deviderView.minY = self.notNowBotton.minY - 1;
self.rateView.minY = self.messageLabel.maxY + thirdMainViewOffset;
}
@end

View file

@ -0,0 +1,254 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="gvd-7d-ZtN" customClass="MWMRateAlert">
<rect key="frame" x="0.0" y="0.0" width="280" height="271"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="OSX-VH-Atf">
<rect key="frame" x="0.0" y="219" width="280" height="1"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.96862745100000003" green="0.96078431369999995" blue="0.94117647059999998" alpha="1" colorSpace="calibratedRGB"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="aTp-g7-Fnb">
<rect key="frame" x="140" y="219" width="140" height="52"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="NOT NOW">
<color key="titleColor" red="0.090196078430000007" green="0.61960784310000006" blue="0.30196078430000001" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="later"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="notNowTap:" destination="gvd-7d-ZtN" eventType="touchUpInside" id="pDY-f0-XG4"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Do you like maps.me?" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2GE-Kn-ZbS">
<rect key="frame" x="23" y="20" width="232" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="20"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.81999999999999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<size key="shadowOffset" width="0.0" height="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_do_like_maps"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Creating routes between regions is only possible" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="MPG-eg-rnp">
<rect key="frame" x="23" y="48" width="235" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.82000000000000006" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="rating_tap_star"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" id="bwA-2W-QTh">
<rect key="frame" x="0.0" y="118" width="280" height="62"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_rate" id="Rh9-w6-6lT">
<rect key="frame" x="11" y="0.0" width="58" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_rate" id="ci6-Fb-C6O">
<rect key="frame" x="61" y="0.0" width="58" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_rate" id="NSS-cJ-276">
<rect key="frame" x="111" y="0.0" width="58" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_rate" id="mSt-cg-I7c">
<rect key="frame" x="161" y="0.0" width="58" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_rate" id="00F-hH-FpT">
<rect key="frame" x="211" y="0.0" width="58" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Y0l-wf-fRE">
<rect key="frame" x="15" y="4" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<gestureRecognizers/>
<state key="normal" image="rate-empty">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="rate-full"/>
<connections>
<outletCollection property="gestureRecognizers" destination="JxX-DM-Jsf" appends="YES" id="OuW-dq-hsh"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="IwT-0r-9ue">
<rect key="frame" x="65" y="4" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<gestureRecognizers/>
<state key="normal" image="rate-empty">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="rate-full"/>
<connections>
<outletCollection property="gestureRecognizers" destination="PZe-bj-Z29" appends="YES" id="R7u-q2-5PQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="xzy-mk-e60">
<rect key="frame" x="115" y="4" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<gestureRecognizers/>
<state key="normal" image="rate-empty">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="rate-full"/>
<connections>
<outletCollection property="gestureRecognizers" destination="bIK-WQ-cfd" appends="YES" id="UhY-Lr-RcU"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="VpG-bF-F8Q">
<rect key="frame" x="165" y="4" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<gestureRecognizers/>
<state key="normal" image="rate-empty">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="rate-full"/>
<connections>
<outletCollection property="gestureRecognizers" destination="yal-2Y-ZXy" appends="YES" id="61l-vk-WCg"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="b4v-cv-CPh">
<rect key="frame" x="215" y="4" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<gestureRecognizers/>
<state key="normal" image="rate-empty">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="rate-full"/>
<connections>
<outletCollection property="gestureRecognizers" destination="Et3-eU-FTg" appends="YES" id="t59-qQ-4rC"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="DcU-Ep-Vb6">
<rect key="frame" x="33" y="44" width="14" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" red="0.9882352941176471" green="0.59999999999999998" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="nTv-bL-4pY">
<rect key="frame" x="83" y="44" width="14" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" red="0.98823529409999999" green="0.59999999999999998" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="u5G-Be-YJG">
<rect key="frame" x="133" y="44" width="14" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" red="0.98823529409999999" green="0.59999999999999998" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="4" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Qfc-Pc-GfA">
<rect key="frame" x="183" y="44" width="14" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" red="0.98823529409999999" green="0.59999999999999998" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="5" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="hFu-OS-jTe">
<rect key="frame" x="233" y="44" width="14" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" red="0.98823529409999999" green="0.59999999999999998" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="size" keyPath="layer.shadowOffset">
<size key="value" width="0.0" height="3"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="layer.shadowUIColor">
<color key="value" red="0.0" green="0.0" blue="0.0" alpha="0.22" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.shadowRadius">
<integer key="value" value="6"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="4"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="deviderView" destination="OSX-VH-Atf" id="XJK-Wx-llP"/>
<outlet property="fiveStarButton" destination="b4v-cv-CPh" id="dgR-Ga-VLv"/>
<outlet property="fiveStarLabel" destination="hFu-OS-jTe" id="0iO-c7-5oO"/>
<outlet property="fiveStarPushImageView" destination="00F-hH-FpT" id="jYg-Gc-NQg"/>
<outlet property="fourStarButton" destination="VpG-bF-F8Q" id="kld-jx-fbX"/>
<outlet property="fourStarLabel" destination="Qfc-Pc-GfA" id="UR8-Ve-3eB"/>
<outlet property="fourStarPushImageView" destination="mSt-cg-I7c" id="T8z-c7-yxI"/>
<outlet property="messageLabel" destination="MPG-eg-rnp" id="8da-GV-pvF"/>
<outlet property="notNowBotton" destination="aTp-g7-Fnb" id="R5e-Wi-v33"/>
<outlet property="oneStarButton" destination="Y0l-wf-fRE" id="2zr-Po-SYi"/>
<outlet property="oneStarLabel" destination="DcU-Ep-Vb6" id="kwZ-gf-bra"/>
<outlet property="oneStarPushImageView" destination="Rh9-w6-6lT" id="M5z-d4-4GU"/>
<outlet property="rateView" destination="bwA-2W-QTh" id="4EC-t8-saE"/>
<outlet property="threeStarButton" destination="xzy-mk-e60" id="toU-BP-zdp"/>
<outlet property="threeStarLabel" destination="u5G-Be-YJG" id="a97-Wf-Zgo"/>
<outlet property="threeStarPushImageView" destination="NSS-cJ-276" id="ANy-pg-WV9"/>
<outlet property="titleLabel" destination="2GE-Kn-ZbS" id="9DR-1X-mdt"/>
<outlet property="twoStarButton" destination="IwT-0r-9ue" id="a2o-Tf-0iZ"/>
<outlet property="twoStarLabel" destination="nTv-bL-4pY" id="cmA-pt-ZNQ"/>
<outlet property="twoStarPushImageView" destination="ci6-Fb-C6O" id="n7f-Z1-aaK"/>
</connections>
<point key="canvasLocation" x="343" y="342.5"/>
</view>
<pongPressGestureRecognizer delaysTouchesBegan="YES" allowableMovement="10" minimumPressDuration="0.01" id="JxX-DM-Jsf" userLabel="oneStar">
<connections>
<action selector="oneStarTap:" destination="gvd-7d-ZtN" id="hsA-ec-HjB"/>
</connections>
</pongPressGestureRecognizer>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.01" id="PZe-bj-Z29" userLabel="twoStar">
<connections>
<action selector="twoStarTap:" destination="gvd-7d-ZtN" id="xfZ-yx-juv"/>
</connections>
</pongPressGestureRecognizer>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.01" id="bIK-WQ-cfd" userLabel="threeStar">
<connections>
<action selector="threeStarTap:" destination="gvd-7d-ZtN" id="zWY-gE-57l"/>
</connections>
</pongPressGestureRecognizer>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.01" id="yal-2Y-ZXy" userLabel="fourStar">
<connections>
<action selector="fourStarTap:" destination="gvd-7d-ZtN" id="g0X-pE-qXW"/>
</connections>
</pongPressGestureRecognizer>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.01" id="Et3-eU-FTg" userLabel="fiveStart">
<connections>
<action selector="fiveStarTap:" destination="gvd-7d-ZtN" id="vvt-cb-vH6"/>
</connections>
</pongPressGestureRecognizer>
</objects>
<resources>
<image name="bg_rate" width="58" height="58"/>
<image name="rate-empty" width="50" height="50"/>
<image name="rate-full" width="50" height="50"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -577,9 +577,7 @@ extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
Reachability * reachability = [Reachability reachabilityForInternetConnection];
if ([reachability isReachable])
{
if (dlg_settings::ShouldShow(dlg_settings::AppStore))
[self showAppStoreRatingMenu];
else if (dlg_settings::ShouldShow(dlg_settings::FacebookDlg))
if (dlg_settings::ShouldShow(dlg_settings::FacebookDlg))
[self showFacebookRatingMenu];
}
}
@ -821,7 +819,7 @@ extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
- (void)presentDownloaderAlert:(routing::IRouter::ResultCode)type countries:(vector<storage::TIndex> const&)countries {
if (countries.size()) {
MWMAlertViewController *alert = [[MWMAlertViewController alloc] initWithViewController:self];
[alert presentDownloaderAlertWithCountrieIndex:countries[0]];
[alert presentDownloaderAlertWithCountryIndex:countries[0]];
} else {
[self presentDefaultAlert:type];
}
@ -1202,24 +1200,6 @@ extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
{
switch (alertView.tag)
{
case ALERT_VIEW_APPSTORE:
{
if (buttonIndex == 0)
{
dlg_settings::SaveResult(dlg_settings::AppStore, dlg_settings::Never);
}
else if (buttonIndex == 1)
{
dlg_settings::SaveResult(dlg_settings::AppStore, dlg_settings::OK);
[[UIApplication sharedApplication] rateVersionFrom:@"ios_pro_popup"];
}
else if (buttonIndex == 2)
{
dlg_settings::SaveResult(dlg_settings::AppStore, dlg_settings::Later);
}
break;
}
case ALERT_VIEW_FACEBOOK:
{
if (buttonIndex == 0)
@ -1432,17 +1412,6 @@ NSInteger compareAddress(id l, id r, void * context)
f.Invalidate();
}
- (void)showAppStoreRatingMenu
{
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"App Store"
message:L(@"appStore_message")
delegate:self
cancelButtonTitle:L(@"no_thanks")
otherButtonTitles:L(@"ok"), L(@"remind_me_later"), nil];
alertView.tag = ALERT_VIEW_APPSTORE;
[alertView show];
}
- (void)showFacebookRatingMenu
{
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Facebook"

View file

@ -18,7 +18,7 @@ extern NSString * const MapsStatusChangedNotification;
UIAlertView * m_loadingAlertView;
}
@property (nonatomic, strong) IBOutlet MapViewController * m_mapViewController;
@property (nonatomic, weak) IBOutlet MapViewController * m_mapViewController;
@property (nonatomic, readonly) LocationManager * m_locationManager;
+ (MapsAppDelegate *)theApp;

View file

@ -6,6 +6,8 @@
#import "UIKitCategories.h"
#import "AppInfo.h"
#import "LocalNotificationManager.h"
#import "MWMAlertViewController.h"
#import "Reachability.h"
#include <sys/xattr.h>
@ -21,6 +23,11 @@
#import "../../../3party/Alohalytics/src/alohalytics_objc.h"
NSString * const MapsStatusChangedNotification = @"MapsStatusChangedNotification";
static NSString * const kUDLastLaunchDateKey = @"LastLaunchDate";
extern NSString * const kUDAlreadyRatedKey = @"UserAlreadyRatedApp";
static NSString * const kUDSessionsCountKey = @"SessionsCount";
static NSString * const kUDFirstVersionKey = @"FirstVersion";
static NSString * const kUDLastRateRequestDate = @"LastRateRequestDate";
/// Adds needed localized strings to C++ code
/// @TODO Refactor localization mechanism to make it simpler
@ -86,7 +93,7 @@ void InitLocalizedStrings()
mrgsParams.allowPushNotificationHooks = YES;
[MRGServiceInit startWithServiceParams:mrgsParams externalSDKParams:@[] delegate:nil];
[[MRGSApplication currentApplication] markAsUpdatedWithRegistrationDate:[NSDate date]];
[[MRGSApplication currentApplication] markAsUpdatedWithRegistrationDate:NSDate.date];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@ -107,7 +114,8 @@ void InitLocalizedStrings()
[[Statistics instance] logEvent:@"Device Info" withParameters:@{@"IFA" : [AppInfo sharedInfo].advertisingId, @"Country" : [AppInfo sharedInfo].countryCode}];
InitLocalizedStrings();
[self shouldShowRateAlert];
[self.m_mapViewController onEnterForeground];
[Preferences setup:self.m_mapViewController];
@ -392,4 +400,102 @@ void InitLocalizedStrings()
[UIApplication sharedApplication].applicationIconBadgeNumber = [[notification userInfo][@"OutOfDate"] integerValue];
}
- (UIWindow *)window
{
return m_window;
}
#pragma mark - Rate alert logic
- (void)showRateAlert
{
if (!Reachability.reachabilityForInternetConnection.isReachable)
return;
UIViewController *topViewController = [(UINavigationController*)m_window.rootViewController visibleViewController];
MWMAlertViewController *alert = [[MWMAlertViewController alloc] initWithViewController:topViewController];
[alert presentRateAlert];
[[NSUserDefaults standardUserDefaults] setObject:NSDate.date forKey:kUDLastRateRequestDate];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)shouldShowRateAlert
{
NSUInteger const kMaximumSessionCountForShowingAlert = 21;
NSUserDefaults *standartDefaults = [NSUserDefaults standardUserDefaults];
BOOL alreadyRated = [standartDefaults boolForKey:kUDAlreadyRatedKey];
if (alreadyRated)
return;
NSUInteger sessionCount = [standartDefaults integerForKey:kUDSessionsCountKey];
if (sessionCount > kMaximumSessionCountForShowingAlert)
return;
NSDate *lastRateDate = [standartDefaults objectForKey:kUDLastRateRequestDate];
NSUInteger daysFromLastRate = [self.class daysBetweenNowAndDate:lastRateDate];
// Do not show more than one alert per day.
if (lastRateDate != nil && daysFromLastRate == 0)
return;
// Get days spent after last launch. lastLaunchDate may be nil, then dayAgo == 0.
NSDate *lastLaunchDate = [standartDefaults objectForKey:kUDLastLaunchDateKey];
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
if (self.class.isFirstAppLaunch)
{
// It's first launch for new user.
[standartDefaults setObject:currentVersion forKey:kUDFirstVersionKey];
sessionCount = 1;
}
else
{
NSString *firstVersion = [standartDefaults stringForKey:kUDFirstVersionKey];
if (!firstVersion.length || [self version:currentVersion greaterThanVersion:firstVersion])
{
// User just got updated. Show alert, if it first session or if 90 days spent.
if (daysFromLastRate >= 90 || daysFromLastRate == 0)
[NSTimer scheduledTimerWithTimeInterval:30. target:self selector:@selector(showRateAlert) userInfo:nil repeats:NO];
}
else
{
// It's new user.
NSUInteger daysFromLastLaunch = [self.class daysBetweenNowAndDate:lastLaunchDate];
if (daysFromLastLaunch > 0)
sessionCount++;
if (sessionCount == 3 || sessionCount == 10 || sessionCount == kMaximumSessionCountForShowingAlert)
[NSTimer scheduledTimerWithTimeInterval:30. target:self selector:@selector(showRateAlert) userInfo:nil repeats:NO];
}
}
[standartDefaults setInteger:sessionCount forKey:kUDSessionsCountKey];
[standartDefaults setObject:NSDate.date forKey:kUDLastLaunchDateKey];
[standartDefaults synchronize];
}
- (BOOL)version:(NSString *)first greaterThanVersion:(NSString *)second
{
NSArray *f = [first componentsSeparatedByString:@"."];
NSArray *s = [second componentsSeparatedByString:@"."];
NSUInteger iter = 0;
while (f.count > iter && s.count > iter)
{
if ([(NSString*)f[iter] integerValue] == [(NSString*)s[iter] integerValue])
iter++;
else
return [(NSString*)f[iter] integerValue] > [(NSString*)s[iter] integerValue];
}
return f.count > s.count;
}
+ (NSInteger)daysBetweenNowAndDate:(NSDate*)fromDate
{
if (!fromDate)
return 0;
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];
return difference.day;
}
@end

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

View file

@ -115,19 +115,20 @@
EED10A4511F78D120095FAD4 /* MapViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = EED10A4411F78D120095FAD4 /* MapViewController.mm */; };
EEFE7C1412F8C9E1006AF8C3 /* fonts_blacklist.txt in Resources */ = {isa = PBXBuildFile; fileRef = EEFE7C1212F8C9E1006AF8C3 /* fonts_blacklist.txt */; };
EEFE7C1512F8C9E1006AF8C3 /* fonts_whitelist.txt in Resources */ = {isa = PBXBuildFile; fileRef = EEFE7C1312F8C9E1006AF8C3 /* fonts_whitelist.txt */; };
F61579341AC2CE9A0032D8E9 /* MWMRateAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = F61579331AC2CE9A0032D8E9 /* MWMRateAlert.mm */; };
F61579361AC2CEB60032D8E9 /* MWMRateAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = F61579351AC2CEB60032D8E9 /* MWMRateAlert.xib */; };
F62404FB1AAF3DB200B58DB6 /* UILabel+RuntimeAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = F62404FA1AAF3DB200B58DB6 /* UILabel+RuntimeAttributes.m */; };
F64F19991AB81A00006EAF7E /* MWMAlertViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19821AB81A00006EAF7E /* MWMAlertViewController.mm */; };
F64F199A1AB81A00006EAF7E /* MWMAlertViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F64F19831AB81A00006EAF7E /* MWMAlertViewController.xib */; };
F64F199B1AB81A00006EAF7E /* MWMAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19861AB81A00006EAF7E /* MWMAlert.mm */; };
F64F199C1AB81A00006EAF7E /* MWMDefaultAlert+Configure.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19891AB81A00006EAF7E /* MWMDefaultAlert+Configure.mm */; };
F64F199D1AB81A00006EAF7E /* MWMDefaultAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F198B1AB81A00006EAF7E /* MWMDefaultAlert.mm */; };
F64F199E1AB81A00006EAF7E /* MWMDefaultAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = F64F198C1AB81A00006EAF7E /* MWMDefaultAlert.xib */; };
F64F199F1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F198F1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.mm */; };
F64F19A01AB81A00006EAF7E /* MWMDownloadAllMapsAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19911AB81A00006EAF7E /* MWMDownloadAllMapsAlert.mm */; };
F64F19A11AB81A00006EAF7E /* MWMDownloadAllMapsAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = F64F19921AB81A00006EAF7E /* MWMDownloadAllMapsAlert.xib */; };
F64F19A21AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19951AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.mm */; };
F64F19A31AB81A00006EAF7E /* MWMDownloadTransitMapAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = F64F19971AB81A00006EAF7E /* MWMDownloadTransitMapAlert.mm */; };
F64F19A41AB81A00006EAF7E /* MWMDownloadTransitMapAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = F64F19981AB81A00006EAF7E /* MWMDownloadTransitMapAlert.xib */; };
F67BBB571AC54A7800D162C7 /* MWMFeedbackAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = F67BBB551AC54A7800D162C7 /* MWMFeedbackAlert.mm */; };
F67BBB581AC54A7800D162C7 /* MWMFeedbackAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = F67BBB561AC54A7800D162C7 /* MWMFeedbackAlert.xib */; };
F6DBF9B61AA8779300F2EC2C /* CALayer+RuntimeAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = F6DBF9B51AA8779300F2EC2C /* CALayer+RuntimeAttributes.m */; };
F785EB4016386FC4003A38A8 /* BookmarkCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F785EB3F16386FC4003A38A8 /* BookmarkCell.mm */; };
F7B90CD31521E6D200C054EE /* CustomNavigationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F7B90CD21521E6D100C054EE /* CustomNavigationView.mm */; };
@ -377,6 +378,9 @@
EED10A4411F78D120095FAD4 /* MapViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = MapViewController.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
EEFE7C1212F8C9E1006AF8C3 /* fonts_blacklist.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = fonts_blacklist.txt; path = ../../data/fonts_blacklist.txt; sourceTree = "<group>"; };
EEFE7C1312F8C9E1006AF8C3 /* fonts_whitelist.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = fonts_whitelist.txt; path = ../../data/fonts_whitelist.txt; sourceTree = "<group>"; };
F61579321AC2CE9A0032D8E9 /* MWMRateAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRateAlert.h; sourceTree = "<group>"; };
F61579331AC2CE9A0032D8E9 /* MWMRateAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMRateAlert.mm; sourceTree = "<group>"; };
F61579351AC2CEB60032D8E9 /* MWMRateAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMRateAlert.xib; sourceTree = "<group>"; };
F62404F91AAF3DB200B58DB6 /* UILabel+RuntimeAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+RuntimeAttributes.h"; sourceTree = "<group>"; };
F62404FA1AAF3DB200B58DB6 /* UILabel+RuntimeAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+RuntimeAttributes.m"; sourceTree = "<group>"; };
F64F19811AB81A00006EAF7E /* MWMAlertViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMAlertViewController.h; sourceTree = "<group>"; };
@ -384,21 +388,18 @@
F64F19831AB81A00006EAF7E /* MWMAlertViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMAlertViewController.xib; sourceTree = "<group>"; };
F64F19851AB81A00006EAF7E /* MWMAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMAlert.h; sourceTree = "<group>"; };
F64F19861AB81A00006EAF7E /* MWMAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMAlert.mm; sourceTree = "<group>"; };
F64F19881AB81A00006EAF7E /* MWMDefaultAlert+Configure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MWMDefaultAlert+Configure.h"; sourceTree = "<group>"; };
F64F19891AB81A00006EAF7E /* MWMDefaultAlert+Configure.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MWMDefaultAlert+Configure.mm"; sourceTree = "<group>"; };
F64F198A1AB81A00006EAF7E /* MWMDefaultAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMDefaultAlert.h; sourceTree = "<group>"; };
F64F198B1AB81A00006EAF7E /* MWMDefaultAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDefaultAlert.mm; sourceTree = "<group>"; };
F64F198C1AB81A00006EAF7E /* MWMDefaultAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMDefaultAlert.xib; sourceTree = "<group>"; };
F64F198E1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MWMDownloadAllMapsAlert+Configure.h"; sourceTree = "<group>"; };
F64F198F1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MWMDownloadAllMapsAlert+Configure.mm"; sourceTree = "<group>"; };
F64F19901AB81A00006EAF7E /* MWMDownloadAllMapsAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMDownloadAllMapsAlert.h; sourceTree = "<group>"; };
F64F19911AB81A00006EAF7E /* MWMDownloadAllMapsAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDownloadAllMapsAlert.mm; sourceTree = "<group>"; };
F64F19921AB81A00006EAF7E /* MWMDownloadAllMapsAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMDownloadAllMapsAlert.xib; sourceTree = "<group>"; };
F64F19941AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MWMDownloadTransitMapAlert+Configure.h"; sourceTree = "<group>"; };
F64F19951AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MWMDownloadTransitMapAlert+Configure.mm"; sourceTree = "<group>"; };
F64F19961AB81A00006EAF7E /* MWMDownloadTransitMapAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMDownloadTransitMapAlert.h; sourceTree = "<group>"; };
F64F19971AB81A00006EAF7E /* MWMDownloadTransitMapAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDownloadTransitMapAlert.mm; sourceTree = "<group>"; };
F64F19981AB81A00006EAF7E /* MWMDownloadTransitMapAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMDownloadTransitMapAlert.xib; sourceTree = "<group>"; };
F67BBB541AC54A7800D162C7 /* MWMFeedbackAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMFeedbackAlert.h; sourceTree = "<group>"; };
F67BBB551AC54A7800D162C7 /* MWMFeedbackAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMFeedbackAlert.mm; sourceTree = "<group>"; };
F67BBB561AC54A7800D162C7 /* MWMFeedbackAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMFeedbackAlert.xib; sourceTree = "<group>"; };
F6DBF9B41AA8779300F2EC2C /* CALayer+RuntimeAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CALayer+RuntimeAttributes.h"; sourceTree = "<group>"; };
F6DBF9B51AA8779300F2EC2C /* CALayer+RuntimeAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CALayer+RuntimeAttributes.m"; sourceTree = "<group>"; };
F785EB3E16386FC4003A38A8 /* BookmarkCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarkCell.h; path = Bookmarks/BookmarkCell.h; sourceTree = SOURCE_ROOT; };
@ -839,11 +840,23 @@
name = MapViewController;
sourceTree = "<group>";
};
F61579301AC2CE760032D8E9 /* RateAlert */ = {
isa = PBXGroup;
children = (
F61579321AC2CE9A0032D8E9 /* MWMRateAlert.h */,
F61579331AC2CE9A0032D8E9 /* MWMRateAlert.mm */,
F61579351AC2CEB60032D8E9 /* MWMRateAlert.xib */,
);
path = RateAlert;
sourceTree = "<group>";
};
F64F195F1AB8125C006EAF7E /* CustomAlert */ = {
isa = PBXGroup;
children = (
F64F19801AB81A00006EAF7E /* AlertController */,
F67BBB531AC54A7800D162C7 /* FeedbackAlert */,
F64F19841AB81A00006EAF7E /* BaseAlert */,
F61579301AC2CE760032D8E9 /* RateAlert */,
F64F19871AB81A00006EAF7E /* DefaultAlert */,
F64F198D1AB81A00006EAF7E /* DownloadAllMapsAlert */,
F64F19931AB81A00006EAF7E /* DownloadTransitMapsAlert */,
@ -873,8 +886,6 @@
F64F19871AB81A00006EAF7E /* DefaultAlert */ = {
isa = PBXGroup;
children = (
F64F19881AB81A00006EAF7E /* MWMDefaultAlert+Configure.h */,
F64F19891AB81A00006EAF7E /* MWMDefaultAlert+Configure.mm */,
F64F198A1AB81A00006EAF7E /* MWMDefaultAlert.h */,
F64F198B1AB81A00006EAF7E /* MWMDefaultAlert.mm */,
F64F198C1AB81A00006EAF7E /* MWMDefaultAlert.xib */,
@ -885,8 +896,6 @@
F64F198D1AB81A00006EAF7E /* DownloadAllMapsAlert */ = {
isa = PBXGroup;
children = (
F64F198E1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.h */,
F64F198F1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.mm */,
F64F19901AB81A00006EAF7E /* MWMDownloadAllMapsAlert.h */,
F64F19911AB81A00006EAF7E /* MWMDownloadAllMapsAlert.mm */,
F64F19921AB81A00006EAF7E /* MWMDownloadAllMapsAlert.xib */,
@ -897,8 +906,6 @@
F64F19931AB81A00006EAF7E /* DownloadTransitMapsAlert */ = {
isa = PBXGroup;
children = (
F64F19941AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.h */,
F64F19951AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.mm */,
F64F19961AB81A00006EAF7E /* MWMDownloadTransitMapAlert.h */,
F64F19971AB81A00006EAF7E /* MWMDownloadTransitMapAlert.mm */,
F64F19981AB81A00006EAF7E /* MWMDownloadTransitMapAlert.xib */,
@ -906,6 +913,16 @@
path = DownloadTransitMapsAlert;
sourceTree = "<group>";
};
F67BBB531AC54A7800D162C7 /* FeedbackAlert */ = {
isa = PBXGroup;
children = (
F67BBB541AC54A7800D162C7 /* MWMFeedbackAlert.h */,
F67BBB551AC54A7800D162C7 /* MWMFeedbackAlert.mm */,
F67BBB561AC54A7800D162C7 /* MWMFeedbackAlert.xib */,
);
path = FeedbackAlert;
sourceTree = "<group>";
};
FA065FC61286143F00FEA989 /* External Resources */ = {
isa = PBXGroup;
children = (
@ -1179,6 +1196,8 @@
F7FDD823147F30CC005900FA /* drules_proto.bin in Resources */,
FAAEA7D1161BD26600CCD661 /* synonyms.txt in Resources */,
FA140651162A6288002BC1ED /* empty@2x.png in Resources */,
F61579361AC2CEB60032D8E9 /* MWMRateAlert.xib in Resources */,
F67BBB581AC54A7800D162C7 /* MWMFeedbackAlert.xib in Resources */,
FA140653162A6288002BC1ED /* empty.png in Resources */,
FA140655162A6288002BC1ED /* eye.png in Resources */,
FA140657162A6288002BC1ED /* eye@2x.png in Resources */,
@ -1253,11 +1272,13 @@
977E26C219E31BCC00BA2219 /* ActiveMapsVC.mm in Sources */,
B08AA8CE1A24C7BC00810B1C /* LocalNotificationInfoProvider.m in Sources */,
1D3623260D0F684500981E51 /* MapsAppDelegate.mm in Sources */,
F67BBB571AC54A7800D162C7 /* MWMFeedbackAlert.mm in Sources */,
A32B6D4C1A14980500E54A65 /* iosOGLContext.mm in Sources */,
B0E1FCDF1A2343BC00A8E08B /* NextTurnPhoneView.m in Sources */,
9746492718EEE2F8004B4658 /* ToolbarView.mm in Sources */,
46F26CD810F623BA00ECCA39 /* EAGLView.mm in Sources */,
EED10A4511F78D120095FAD4 /* MapViewController.mm in Sources */,
F61579341AC2CE9A0032D8E9 /* MWMRateAlert.mm in Sources */,
A3CC2CD41A1C723900B832E1 /* LocationPredictor.mm in Sources */,
EE7F29811219ECA300EB67A9 /* RenderBuffer.mm in Sources */,
F62404FB1AAF3DB200B58DB6 /* UILabel+RuntimeAttributes.m in Sources */,
@ -1269,7 +1290,6 @@
97C9851E186AE3C500AF7E9E /* Reachability.m in Sources */,
977E26B919E2E64200BA2219 /* MapsObservers.mm in Sources */,
EE7F29821219ECA300EB67A9 /* RenderContext.mm in Sources */,
F64F19A21AB81A00006EAF7E /* MWMDownloadTransitMapAlert+Configure.mm in Sources */,
F64F19991AB81A00006EAF7E /* MWMAlertViewController.mm in Sources */,
FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */,
FA34BECA1338D72F00FFB2A7 /* CustomAlertView.mm in Sources */,
@ -1287,7 +1307,6 @@
976D86F519CB21BD00C920EF /* RouteView.m in Sources */,
FA29FDAA141E77F8004ADF66 /* Preferences.mm in Sources */,
97A8000C18B21363000C07A2 /* SearchView.mm in Sources */,
F64F199F1AB81A00006EAF7E /* MWMDownloadAllMapsAlert+Configure.mm in Sources */,
FAA5C2A2144F135F005337F6 /* LocationManager.mm in Sources */,
97AA2821190AD21100AE1AAB /* PlacePageShareCell.m in Sources */,
97DEA09618D75BB000C5F963 /* ContextViews.mm in Sources */,
@ -1297,7 +1316,6 @@
F6DBF9B61AA8779300F2EC2C /* CALayer+RuntimeAttributes.m in Sources */,
FA36B80D15403A4F004560CC /* BookmarksVC.mm in Sources */,
A32B6D4D1A14980500E54A65 /* iosOGLContextFactory.mm in Sources */,
F64F199C1AB81A00006EAF7E /* MWMDefaultAlert+Configure.mm in Sources */,
9769D6EF1912BF3000CA6158 /* ContainerView.mm in Sources */,
FAF457E715597D4600DCCC49 /* Framework.cpp in Sources */,
97CC93BB19599F4700369B42 /* SearchSuggestCell.m in Sources */,

View file

@ -12,15 +12,58 @@
#import "RichTextVC.h"
#import "../../3party/Alohalytics/src/alohalytics_objc.h"
extern NSString * const kAlohalyticsTapEventKey;
@interface SettingsAndMoreVC () <MFMailComposeViewControllerDelegate>
@property (nonatomic) NSArray * items;
@property (nonatomic) NSDictionary * deviceNames;
@end
extern NSString * const kLocaleUsedInSupportEmails = @"en_gb";
extern NSString * const kAlohalyticsTapEventKey;
extern NSString * const kiOSEmail = @"ios@maps.me";
extern NSDictionary * const deviceNames = @{@"x86_64" : @"Simulator",
@"i386" : @"Simulator",
@"iPod1,1" : @"iPod Touch",
@"iPod2,1" : @"iPod Touch 2nd gen.",
@"iPod3,1" : @"iPod Touch 3rd gen.",
@"iPod4,1" : @"iPod Touch 4th gen.",
@"iPod5,1" : @"iPod Touch 5th gen.",
@"iPhone1,1" : @"iPhone",
@"iPhone1,2" : @"iPhone 3G",
@"iPhone2,1" : @"iPhone 3GS",
@"iPhone3,1" : @"iPhone 4",
@"iPhone4,1" : @"iPhone 4S",
@"iPhone4,2" : @"iPhone 4S",
@"iPhone4,3" : @"iPhone 4S",
@"iPhone5,1" : @"iPhone 5",
@"iPhone5,2" : @"iPhone 5",
@"iPhone5,3" : @"iPhone 5c",
@"iPhone5,4" : @"iPhone 5c",
@"iPhone6,1" : @"iPhone 5s",
@"iPhone6,2" : @"iPhone 5s",
@"iPad1,1" : @"iPad WiFi",
@"iPad1,2" : @"iPad GSM",
@"iPad2,1" : @"iPad 2 WiFi",
@"iPad2,2" : @"iPad 2 GSM",
@"iPad2,2" : @"iPad 2 CDMA",
@"iPad3,1" : @"iPad 3rd gen. WiFi",
@"iPad3,2" : @"iPad 3rd gen. GSM",
@"iPad3,3" : @"iPad 3rd gen. CDMA",
@"iPad3,4" : @"iPad 4th gen. WiFi",
@"iPad3,5" : @"iPad 4th gen. GSM",
@"iPad3,6" : @"iPad 4th gen. CDMA",
@"iPad4,1" : @"iPad Air WiFi",
@"iPad4,2" : @"iPad Air GSM",
@"iPad4,3" : @"iPad Air CDMA",
@"iPad2,5" : @"iPad Mini WiFi",
@"iPad2,6" : @"iPad Mini GSM",
@"iPad2,7" : @"iPad Mini CDMA",
@"iPad4,4" : @"iPad Mini 2nd gen. WiFi",
@"iPad4,5" : @"iPad Mini 2nd gen. GSM",
@"iPad4,6" : @"iPad Mini 2nd gen. CDMA"};
@implementation SettingsAndMoreVC
- (void)viewDidLoad
@ -28,48 +71,6 @@ extern NSString * const kAlohalyticsTapEventKey;
[super viewDidLoad];
self.title = L(@"settings_and_more");
self.deviceNames = @{@"x86_64" : @"Simulator",
@"i386" : @"Simulator",
@"iPod1,1" : @"iPod Touch",
@"iPod2,1" : @"iPod Touch 2nd gen.",
@"iPod3,1" : @"iPod Touch 3rd gen.",
@"iPod4,1" : @"iPod Touch 4th gen.",
@"iPod5,1" : @"iPod Touch 5th gen.",
@"iPhone1,1" : @"iPhone",
@"iPhone1,2" : @"iPhone 3G",
@"iPhone2,1" : @"iPhone 3GS",
@"iPhone3,1" : @"iPhone 4",
@"iPhone4,1" : @"iPhone 4S",
@"iPhone4,2" : @"iPhone 4S",
@"iPhone4,3" : @"iPhone 4S",
@"iPhone5,1" : @"iPhone 5",
@"iPhone5,2" : @"iPhone 5",
@"iPhone5,3" : @"iPhone 5c",
@"iPhone5,4" : @"iPhone 5c",
@"iPhone6,1" : @"iPhone 5s",
@"iPhone6,2" : @"iPhone 5s",
@"iPad1,1" : @"iPad WiFi",
@"iPad1,2" : @"iPad GSM",
@"iPad2,1" : @"iPad 2 WiFi",
@"iPad2,2" : @"iPad 2 GSM",
@"iPad2,2" : @"iPad 2 CDMA",
@"iPad3,1" : @"iPad 3rd gen. WiFi",
@"iPad3,2" : @"iPad 3rd gen. GSM",
@"iPad3,3" : @"iPad 3rd gen. CDMA",
@"iPad3,4" : @"iPad 4th gen. WiFi",
@"iPad3,5" : @"iPad 4th gen. GSM",
@"iPad3,6" : @"iPad 4th gen. CDMA",
@"iPad4,1" : @"iPad Air WiFi",
@"iPad4,2" : @"iPad Air GSM",
@"iPad4,3" : @"iPad Air CDMA",
@"iPad2,5" : @"iPad Mini WiFi",
@"iPad2,6" : @"iPad Mini GSM",
@"iPad2,7" : @"iPad Mini CDMA",
@"iPad4,4" : @"iPad Mini 2nd gen. WiFi",
@"iPad4,5" : @"iPad Mini 2nd gen. GSM",
@"iPad4,6" : @"iPad Mini 2nd gen. CDMA"};
self.items = @[@{@"Title" : @"",
@"Items" : @[@{@"Id" : @"Settings", @"Title" : L(@"settings"), @"Icon" : @"IconAppSettings"},
@{@"Id" : @"Help", @"Title" : L(@"help"), @"Icon" : @"IconHelp"},
@ -204,28 +205,27 @@ extern NSString * const kAlohalyticsTapEventKey;
struct utsname systemInfo;
uname(&systemInfo);
NSString * machine = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSString * device = self.deviceNames[machine];
NSString * device = deviceNames[machine];
if (!device)
device = machine;
NSString * languageCode = [[NSLocale preferredLanguages] firstObject];
NSString * language = [[NSLocale localeWithLocaleIdentifier:@"en_gb"] displayNameForKey:NSLocaleLanguageCode value:languageCode];
NSString * language = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails] displayNameForKey:NSLocaleLanguageCode value:languageCode];
NSString * locale = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
NSString * country = [[NSLocale localeWithLocaleIdentifier:@"en_gb"] displayNameForKey:NSLocaleCountryCode value:locale];
NSString * country = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails] displayNameForKey:NSLocaleCountryCode value:locale];
NSString * bundleVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
NSString * text = [NSString stringWithFormat:@"\n\n\n\n- %@ (%@)\n- MAPS.ME %@\n- %@/%@", device, [UIDevice currentDevice].systemVersion, bundleVersion, language, country];
NSString * email = @"ios@maps.me";
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController * vc = [[MFMailComposeViewController alloc] init];
vc.mailComposeDelegate = self;
[vc setSubject:@"MAPS.ME"];
[vc setToRecipients:@[email]];
[vc setToRecipients:@[kiOSEmail]];
[vc setMessageBody:text isHTML:NO];
[self presentViewController:vc animated:YES completion:nil];
}
else
{
NSString * text = [NSString stringWithFormat:L(@"email_error_body"), email];
NSString * text = [NSString stringWithFormat:L(@"email_error_body"), kiOSEmail];
[[[UIAlertView alloc] initWithTitle:L(@"email_error_title") message:text delegate:nil cancelButtonTitle:L(@"ok") otherButtonTitles:nil] show];
}
}