[ios] Added showcase support.

This commit is contained in:
Илья Гречухин 2015-11-17 19:17:04 +03:00
parent 1129afa2dc
commit 1ff18cc516
12 changed files with 248 additions and 73 deletions

View file

@ -1,10 +1,15 @@
@interface MWMBottomMenuCollectionViewCell : UICollectionViewCell
@property(weak, nonatomic) IBOutlet UIImageView * icon;
@property (weak, nonatomic) IBOutlet UIImageView * icon;
- (void)configureWithIconName:(NSString *)iconName
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount;
- (void)configureWithImage:(UIImage *)image
highlightedImage:(UIImage *)highlightedImage
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount;
- (void)configureWithImageName:(NSString *)imageName
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount;
- (void)highlighted:(BOOL)highlighted;

View file

@ -4,25 +4,28 @@
@interface MWMBottomMenuCollectionViewCell ()
@property(weak, nonatomic) IBOutlet UILabel * label;
@property(weak, nonatomic) IBOutlet UIView * badgeBackground;
@property(weak, nonatomic) IBOutlet UILabel * badgeCount;
@property(weak, nonatomic) IBOutlet UIView * separator;
@property (weak, nonatomic) IBOutlet UILabel * label;
@property (weak, nonatomic) IBOutlet UIView * badgeBackground;
@property (weak, nonatomic) IBOutlet UILabel * badgeCount;
@property (weak, nonatomic) IBOutlet UIView * separator;
@property(nonatomic) BOOL isWideMenu;
@property (nonatomic) BOOL isWideMenu;
@property(copy, nonatomic) NSString * iconName;
@property (nonatomic) UIImage * image;
@property (nonatomic) UIImage * highlightedImage;
@end
@implementation MWMBottomMenuCollectionViewCell
- (void)configureWithIconName:(NSString *)iconName
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount
- (void)configureWithImage:(UIImage *)image
highlightedImage:(UIImage *)highlightedImage
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount
{
self.iconName = iconName;
self.icon.image = [UIImage imageNamed:iconName];
self.image = image;
self.highlightedImage = highlightedImage;
self.icon.image = image;
self.label.text = label;
if (badgeCount > 0)
{
@ -38,10 +41,19 @@
[self highlighted:NO];
}
- (void)configureWithImageName:(NSString *)imageName
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount
{
[self configureWithImage:[UIImage imageNamed:imageName]
highlightedImage:[UIImage imageNamed:[imageName stringByAppendingString:@"_press"]]
label:label
badgeCount:badgeCount];
}
- (void)highlighted:(BOOL)highlighted
{
NSString * pressed = highlighted ? @"_press" : @"";
self.icon.image = [UIImage imageNamed:[self.iconName stringByAppendingString:pressed]];
self.icon.image = highlighted ? self.highlightedImage : self.image;
self.label.textColor = highlighted ? [UIColor blackHintText] : [UIColor blackPrimaryText];
}

View file

@ -16,6 +16,7 @@
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * mainButtonWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * separatorWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * additionalButtonsWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * additionalButtonsHeight;
@property(weak, nonatomic) IBOutlet UIView * downloadBadge;
@ -38,7 +39,10 @@
- (void)awakeFromNib
{
[super awakeFromNib];
self.additionalButtons.hidden = self.goButton.hidden = self.streetLabel.hidden = self.downloadBadge.hidden = YES;
self.additionalButtons.hidden = YES;
self.downloadBadge.hidden = YES;
self.goButton.hidden = YES;
self.streetLabel.hidden = YES;
self.restoreState = MWMBottomMenuStateInactive;
}
@ -75,34 +79,46 @@
break;
case MWMBottomMenuStateInactive:
self.backgroundColor = [UIColor menuBackground];
self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 1.0;
self.bookmarksButton.alpha = 1.0;
self.downloadBadge.alpha = 1.0;
self.goButton.alpha = 0.0;
self.p2pButton.alpha = 1.0;
self.searchButton.alpha = 1.0;
self.streetLabel.alpha = 0.0;
break;
case MWMBottomMenuStateActive:
self.backgroundColor = [UIColor whiteColor];
self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 1.0;
self.bookmarksButton.alpha = 1.0;
self.downloadBadge.alpha = 0.0;
self.goButton.alpha = 0.0;
self.p2pButton.alpha = 1.0;
self.searchButton.alpha = 1.0;
self.streetLabel.alpha = 0.0;
break;
case MWMBottomMenuStateCompact:
if (!IPAD)
self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0;
{
self.bookmarksButton.alpha = 0.0;
self.p2pButton.alpha = 0.0;
self.searchButton.alpha = 0.0;
}
self.downloadBadge.alpha = 0.0;
self.goButton.alpha = 0.0;
self.streetLabel.alpha = 0.0;
break;
case MWMBottomMenuStatePlanning:
case MWMBottomMenuStateGo:
self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0;
self.bookmarksButton.alpha = 0.0;
self.goButton.alpha = 1.0;
self.p2pButton.alpha = 0.0;
self.searchButton.alpha = 0.0;
self.streetLabel.alpha = 0.0;
break;
case MWMBottomMenuStateText:
self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0;
self.bookmarksButton.alpha = 0.0;
self.goButton.alpha = 0.0;
self.p2pButton.alpha = 0.0;
self.searchButton.alpha = 0.0;
self.streetLabel.alpha = 1.0;
break;
}
@ -115,8 +131,9 @@
case MWMBottomMenuStateHidden:
break;
case MWMBottomMenuStateInactive:
self.separator.hidden = self.additionalButtons.hidden = YES;
self.additionalButtons.hidden = YES;
self.goButton.hidden = YES;
self.separator.hidden = YES;
self.streetLabel.hidden = YES;
break;
case MWMBottomMenuStateActive:
@ -126,21 +143,29 @@
break;
case MWMBottomMenuStateCompact:
if (!IPAD)
self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES;
{
self.bookmarksButton.hidden = YES;
self.p2pButton.hidden = YES;
self.searchButton.hidden = YES;
}
self.downloadBadge.hidden = YES;
self.goButton.hidden = YES;
self.streetLabel.hidden = YES;
break;
case MWMBottomMenuStatePlanning:
case MWMBottomMenuStateGo:
self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES;
[self.goButton setBackgroundColor:[UIColor linkBlue] forState:UIControlStateNormal];
[self.goButton setBackgroundColor:[UIColor linkBlueDark] forState:UIControlStateHighlighted];
self.bookmarksButton.hidden = YES;
self.p2pButton.hidden = YES;
self.searchButton.hidden = YES;
self.streetLabel.hidden = YES;
break;
case MWMBottomMenuStateText:
self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES;
self.bookmarksButton.hidden = YES;
self.goButton.hidden = YES;
self.p2pButton.hidden = YES;
self.searchButton.hidden = YES;
self.streetLabel.hidden = NO;
break;
}
@ -169,14 +194,27 @@
case MWMBottomMenuStatePlanning:
case MWMBottomMenuStateGo:
case MWMBottomMenuStateText:
self.separator.height = self.additionalButtons.height = 0.0;
self.additionalButtonsHeight.constant = 0.0;
self.separator.height = 0.0;
break;
case MWMBottomMenuStateActive:
self.additionalButtons.height = self.width > self.layoutThreshold ? 64.0 : 148.0;
{
BOOL const isLandscape = self.width > self.layoutThreshold;
if (isLandscape)
{
self.additionalButtonsHeight.constant = 64.0;
}
else
{
NSUInteger const additionalButtonsCount = [self.additionalButtons numberOfItemsInSection:0];
CGFloat const buttonHeight = 52.0;
self.additionalButtonsHeight.constant = additionalButtonsCount * buttonHeight;
}
}
break;
}
CGFloat const width = MIN(self.superview.width - self.leftBound, self.superview.width);
CGFloat const height = self.mainButtons.height + self.separator.height + self.additionalButtons.height;
CGFloat const height = self.mainButtons.height + self.separator.height + self.additionalButtonsHeight.constant;
self.frame = {{self.superview.width - width, self.superview.height - height}, {width, height}};
self.mainButtonWidth.constant = self.separatorWidth.constant = self.additionalButtonsWidth.constant = width;
}
@ -285,8 +323,11 @@
case MWMBottomMenuStateActive:
self.restoreState = _state;
[self updateMenuButtonFromState:_state toState:state];
self.separator.hidden = self.additionalButtons.hidden = NO;
self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = NO;
self.additionalButtons.hidden = NO;
self.bookmarksButton.hidden = NO;
self.p2pButton.hidden = NO;
self.searchButton.hidden = NO;
self.separator.hidden = NO;
break;
case MWMBottomMenuStateCompact:
self.layoutDuration = IPAD ? kDefaultAnimationDuration : 0.0;
@ -304,8 +345,8 @@
break;
case MWMBottomMenuStateText:
self.streetLabel.font = [UIFont medium16];
self.streetLabel.textColor = [UIColor blackSecondaryText];
self.streetLabel.hidden = NO;
self.streetLabel.textColor = [UIColor blackSecondaryText];
[self updateMenuButtonFromState:_state toState:state];
break;
}

View file

@ -26,4 +26,6 @@
- (void)setPlanning;
- (void)setGo;
- (void)refreshLayout;
@end

View file

@ -21,6 +21,8 @@ extern NSString * const kAlohalyticsTapEventKey;
extern NSString * const kSearchStateWillChangeNotification;
extern NSString * const kSearchStateKey;
extern char const * kAdForbiddenSettingsKey;
static NSString * const kCollectionCellPortrait = @"MWMBottomMenuCollectionViewPortraitCell";
static NSString * const kCollectionCelllandscape = @"MWMBottomMenuCollectionViewLandscapeCell";
@ -31,29 +33,32 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
MWMBottomMenuViewCellDownload,
MWMBottomMenuViewCellSettings,
MWMBottomMenuViewCellShare,
MWMBottomMenuViewCellAd,
MWMBottomMenuViewCellCount
};
@interface MWMBottomMenuViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property(weak, nonatomic) MapViewController * controller;
@property(weak, nonatomic) IBOutlet UICollectionView * buttonsCollectionView;
@property (weak, nonatomic) MapViewController * controller;
@property (weak, nonatomic) IBOutlet UICollectionView * buttonsCollectionView;
@property(weak, nonatomic) IBOutlet UIButton * locationButton;
@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
@property(weak, nonatomic) IBOutlet UILabel * streetLabel;
@property (weak, nonatomic) IBOutlet UIButton * locationButton;
@property (weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
@property (weak, nonatomic) IBOutlet UILabel * streetLabel;
@property(weak, nonatomic) id<MWMBottomMenuControllerProtocol> delegate;
@property (weak, nonatomic) id<MWMBottomMenuControllerProtocol> delegate;
@property(nonatomic) BOOL searchIsActive;
@property (nonatomic) BOOL searchIsActive;
@property(nonatomic) SolidTouchView * dimBackground;
@property (nonatomic) SolidTouchView * dimBackground;
@property(nonatomic) MWMBottomMenuState restoreState;
@property (nonatomic) MWMBottomMenuState restoreState;
@property(nonatomic) int locationListenerSlot;
@property (nonatomic) int locationListenerSlot;
@property(nonatomic) location::State::Mode locationState;
@property (nonatomic) location::State::Mode locationState;
@property (nonatomic, readonly) NSUInteger additionalButtonsCount;
@end
@ -87,12 +92,21 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
- (void)viewDidLoad
{
[super viewDidLoad];
[self setupCollectionView];
[self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCellPortrait bundle:nil]
forCellWithReuseIdentifier:kCollectionCellPortrait];
[self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCelllandscape bundle:nil]
forCellWithReuseIdentifier:kCollectionCelllandscape];
MWMBottomMenuLayout * cvLayout =
(MWMBottomMenuLayout *)self.buttonsCollectionView.collectionViewLayout;
cvLayout.layoutThreshold = kLayoutThreshold;
((MWMBottomMenuView *)self.view).layoutThreshold = kLayoutThreshold;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self refreshLayout];
[self configLocationListener];
[self onLocationStateModeChanged:GetFramework().GetLocationState()->GetMode()];
}
@ -108,6 +122,16 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
[self onLocationStateModeChanged:GetFramework().GetLocationState()->GetMode()];
}
#pragma mark - Refresh Collection View layout
- (void)refreshLayout
{
MWMBottomMenuLayout * cvLayout =
(MWMBottomMenuLayout *)self.buttonsCollectionView.collectionViewLayout;
cvLayout.buttonsCount = [self additionalButtonsCount];
[self.additionalButtons reloadData];
}
#pragma mark - Layout
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
@ -246,27 +270,12 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
self.searchIsActive = state != MWMSearchManagerStateHidden;
}
#pragma mark - Setup
- (void)setupCollectionView
{
[self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCellPortrait bundle:nil]
forCellWithReuseIdentifier:kCollectionCellPortrait];
[self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCelllandscape bundle:nil]
forCellWithReuseIdentifier:kCollectionCelllandscape];
MWMBottomMenuLayout * cvLayout =
(MWMBottomMenuLayout *)self.buttonsCollectionView.collectionViewLayout;
cvLayout.buttonsCount = MWMBottomMenuViewCellCount;
cvLayout.layoutThreshold = kLayoutThreshold;
((MWMBottomMenuView *)self.view).layoutThreshold = kLayoutThreshold;
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return MWMBottomMenuViewCellCount;
return [self additionalButtonsCount];
}
- (nonnull UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView
@ -283,16 +292,26 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
{
NSUInteger const badgeCount =
GetFramework().GetCountryTree().GetActiveMapLayout().GetOutOfDateCount();
[cell configureWithIconName:@"ic_menu_download"
label:L(@"download_maps")
badgeCount:badgeCount];
[cell configureWithImageName:@"ic_menu_download"
label:L(@"download_maps")
badgeCount:badgeCount];
}
break;
case MWMBottomMenuViewCellSettings:
[cell configureWithIconName:@"ic_menu_settings" label:L(@"settings") badgeCount:0];
[cell configureWithImageName:@"ic_menu_settings" label:L(@"settings") badgeCount:0];
break;
case MWMBottomMenuViewCellShare:
[cell configureWithIconName:@"ic_menu_share" label:L(@"share_my_location") badgeCount:0];
[cell configureWithImageName:@"ic_menu_share" label:L(@"share_my_location") badgeCount:0];
break;
case MWMBottomMenuViewCellAd:
{
MTRGNativeAppwallBanner * banner = [self.controller.appWallAd.banners firstObject];
[self.controller.appWallAd handleShow:banner];
UIImage * image = banner.icon.image;
UIImage * highlightedImage = banner.itemHighlightIcon.image;
NSString * title = banner.title;
[cell configureWithImage:image highlightedImage:highlightedImage label:title badgeCount:0];
}
break;
case MWMBottomMenuViewCellCount:
break;
@ -316,6 +335,9 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
case MWMBottomMenuViewCellShare:
[self menuActionShareLocation];
break;
case MWMBottomMenuViewCellAd:
[self menuActionOpenAd];
break;
case MWMBottomMenuViewCellCount:
break;
}
@ -378,6 +400,15 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
[shareVC presentInParentViewController:self.controller anchorView:cell.icon];
}
- (void)menuActionOpenAd
{
NSAssert(self.controller.appWallAd.banners.count != 0, @"Banners collection can not be empty!");
[[Statistics instance] logEvent:kStatMenu withParameters:@{kStatButton : kStatMoreApps}];
self.state = self.restoreState;
[self.controller.appWallAd handleClick:[self.controller.appWallAd.banners firstObject]
withController:self.controller];
}
- (IBAction)locationButtonTouchUpInside:(UIButton *)sender
{
[[Statistics instance] logEvent:kStatMenu withParameters:@{kStatButton : kStatLocation}];
@ -541,4 +572,10 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
return ((MWMBottomMenuView *)self.view).searchIsActive;
}
- (NSUInteger)additionalButtonsCount
{
BOOL const adForbidden = (self.controller.appWallAd == nil);
return MWMBottomMenuViewCellCount - (adForbidden ? 1 : 0);
}
@end

View file

@ -22,6 +22,8 @@
#pragma mark - Layout
- (void)refreshLayout;
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration;
- (void)viewWillTransitionToSize:(CGSize)size

View file

@ -74,6 +74,11 @@ extern NSString * const kAlohalyticsTapEventKey;
#pragma mark - Layout
- (void)refreshLayout
{
[self.menuController refreshLayout];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{

View file

@ -1,7 +1,7 @@
#import "LocationManager.h"
#import "LocationPredictor.h"
#import "ViewController.h"
#import <MyTargetSDKCorp/MTRGNativeAppwallAd.h>
#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
@ -46,6 +46,8 @@ namespace search { struct AddressInfo; }
- (void)openBookmarks;
@property (nonatomic) MTRGNativeAppwallAd * appWallAd;
@property (nonatomic) UIPopoverController * popoverVC;
@property (nonatomic) ShareActionSheet * shareActionSheet;
@property (nonatomic, readonly) MWMMapViewControlsManager * controlsManager;

View file

@ -9,8 +9,10 @@
#import "MWMMapViewControlsManager.h"
#import "MWMTextToSpeech.h"
#import "RouteState.h"
#import "Statistics.h"
#import "UIFont+MapsMeFonts.h"
#import "UIViewController+Navigation.h"
#import <MyTargetSDKCorp/MTRGManager_Corp.h>
#import "3party/Alohalytics/src/alohalytics_objc.h"
@ -27,7 +29,11 @@
#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.
#import "../../../private.h"
extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
extern char const * kAdForbiddenSettingsKey;
typedef NS_ENUM(NSUInteger, ForceRoutingStateChange)
{
@ -74,7 +80,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
@end
@interface MapViewController ()
@interface MapViewController () <MTRGNativeAppwallAdDelegate>
@property (nonatomic, readwrite) MWMMapViewControlsManager * controlsManager;
@property (nonatomic) MWMBottomMenuState menuRestoreState;
@ -534,6 +540,21 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
[self invalidate];
self.controlsManager.menuState = self.menuRestoreState;
bool adForbidden = false;
(void)Settings::Get(kAdForbiddenSettingsKey, adForbidden);
if (adForbidden)
{
self.appWallAd = nil;
}
else
{
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)viewDidLoad
@ -542,6 +563,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
EAGLView * v = (EAGLView *)self.view;
[v initRenderPolicy];
self.view.clipsToBounds = YES;
[MTRGManager setMyCom:YES];
}
- (void)viewWillDisappear:(BOOL)animated
@ -753,6 +775,19 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
}
}
#pragma mark - myTarget
- (void)onLoadWithAppwallBanners:(NSArray *)appwallBanners appwallAd:(MTRGNativeAppwallAd *)appwallAd
{
if (appwallBanners.count == 0)
self.appWallAd = nil;
}
- (void)onNoAdWithReason:(NSString *)reason appwallAd:(MTRGNativeAppwallAd *)appwallAd
{
self.appWallAd = nil;
}
#pragma mark - API bar
- (MWMAPIBar *)apiBar
@ -898,4 +933,12 @@ NSInteger compareAddress(id l, id r, void * context)
return _controlsManager;
}
- (void)setAppWallAd:(MTRGNativeAppwallAd *)appWallAd
{
if ([_appWallAd isEqual:appWallAd])
return;
_appWallAd = appWallAd;
[self.controlsManager refreshLayout];
}
@end

View file

@ -252,6 +252,7 @@ void InitLocalizedStrings()
- (void)applicationWillResignActive:(UIApplication *)application
{
[self.mapViewController.appWallAd close];
[RouteState save];
}

View file

@ -16,6 +16,7 @@
#include "platform/preferred_languages.hpp"
extern char const * kStatisticsEnabledSettingsKey;
char const * kAdForbiddenSettingsKey = "AdForbidden";
extern NSString * const kTTSStatusWasChangedNotification = @"TTFStatusWasChangedFromSettingsNotification";
typedef NS_ENUM(NSUInteger, Section)
@ -24,6 +25,7 @@ typedef NS_ENUM(NSUInteger, Section)
SectionZoomButtons,
SectionRouting,
SectionCalibration,
SectionAd,
SectionStatistics,
SectionCount // Must be the latest value!
};
@ -82,6 +84,16 @@ typedef NS_ENUM(NSUInteger, Section)
customCell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
customCell.titleLabel.text = indexPath.row == 0 ? L(@"kilometres") : L(@"miles");
}
else if (indexPath.section == SectionAd)
{
cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]];
SwitchCell * customCell = (SwitchCell *)cell;
bool forbidden = false;
(void)Settings::Get(kAdForbiddenSettingsKey, forbidden);
customCell.switchButton.on = !forbidden;
customCell.titleLabel.text = L(@"showcase_settings_title");
customCell.delegate = self;
}
else if (indexPath.section == SectionStatistics)
{
cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]];
@ -144,7 +156,14 @@ typedef NS_ENUM(NSUInteger, Section)
- (void)switchCell:(SwitchCell *)cell didChangeValue:(BOOL)value
{
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
if (indexPath.section == SectionStatistics)
if (indexPath.section == SectionAd)
{
[[Statistics instance]
logEvent:kStatSettings
withParameters:@{kStatAction : kStatMoreApps, kStatValue : (value ? kStatOn : kStatOff)}];
Settings::Set(kAdForbiddenSettingsKey, (bool)!value);
}
else if (indexPath.section == SectionStatistics)
{
Statistics * stat = [Statistics instance];
[stat logEvent:kStatSettings

View file

@ -1,9 +1,14 @@
static NSString * const kStatAbout = @"About";
static NSString * const kStatAction = @"Action";
static NSString * const kStatActionSheet = @"Action sheet";
static NSString * const kStatAd = @"Ad";
static NSString * const kStatAdTitle = @"Ad title";
static NSString * const kStatAdd = @"Add";
static NSString * const kStatAlert = @"Alert";
static NSString * const kStatApply = @"Apply";
static NSString * const kStatBannerDescription = @"Banner description";
static NSString * const kStatBannerTitle = @"Banner title";
static NSString * const kStatBookmarks = @"Bookmarks";
static NSString * const kStatBuildRoute = @"Build route";
static NSString * const kStatButton = @"Button";
@ -32,14 +37,13 @@ static NSString * const kStatGo = @"Go";
static NSString * const kStatHelp = @"Help";
static NSString * const kStatHidden = @"Hidden";
static NSString * const kStatHistory = @"History";
static NSString * const kStatiPad = @"iPad";
static NSString * const kStatiPhone = @"iPhone";
static NSString * const kStatKilometers = @"Kilometers";
static NSString * const kStatLandscape = @"Landscape";
static NSString * const kStatLocation = @"Location";
static NSString * const kStatMap = @"Map search";
static NSString * const kStatMenu = @"Menu";
static NSString * const kStatMiles = @"Miles";
static NSString * const kStatMoreApps = @"More apps";
static NSString * const kStatMyPosition = @"My position";
static NSString * const kStatName = @"Name";
static NSString * const kStatNo = @"No";
@ -55,8 +59,8 @@ static NSString * const kStatPointToPoint = @"Point to point";
static NSString * const kStatPortrait = @"Portrait";
static NSString * const kStatRate = @"Rate";
static NSString * const kStatRegular = @"Regular";
static NSString * const kStatRename = @"Rename";
static NSString * const kStatRemove = @"Remove";
static NSString * const kStatRename = @"Rename";
static NSString * const kStatReport = @"Report";
static NSString * const kStatSearch = @"Search";
static NSString * const kStatSearchEnteredState = @"Search entered state";
@ -77,12 +81,14 @@ static NSString * const kStatToggleBookmark = @"Toggle bookmark";
static NSString * const kStatToggleCompassCalibration = @"Toggle compass calibration";
static NSString * const kStatToggleCoordinates = @"Toggle coordinates";
static NSString * const kStatToggleDownload = @"Toggle download";
static NSString * const kStatToggleVisibility = @"Toggle visibility";
static NSString * const kStatToggleSection = @"Toggle section";
static NSString * const kStatToggleStatistics = @"Toggle statistics";
static NSString * const kStatToggleVisibility = @"Toggle visibility";
static NSString * const kStatToggleZoomButtonsVisibility = @"Toggle zoom buttons visibility";
static NSString * const kStatUpdateAll = @"Update all";
static NSString * const kStatValue = @"Value";
static NSString * const kStatVehicle = @"Vehicle";
static NSString * const kStatVisible = @"Visible";
static NSString * const kStatYes = @"Yes";
static NSString * const kStatiPad = @"iPad";
static NSString * const kStatiPhone = @"iPhone";