[ios] Removed myTarget ad from bottom menu.

This commit is contained in:
Ilya Grechuhin 2016-09-21 11:41:35 +03:00
parent 87312eac64
commit c70ccabf6a
4 changed files with 3 additions and 119 deletions

View file

@ -49,7 +49,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
MWMBottomMenuViewCellDownload,
MWMBottomMenuViewCellSettings,
MWMBottomMenuViewCellShare,
MWMBottomMenuViewCellAd,
MWMBottomMenuViewCellCount
};
@ -219,7 +218,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
{
MWMBottomMenuLayout * cvLayout =
(MWMBottomMenuLayout *)self.buttonsCollectionView.collectionViewLayout;
cvLayout.buttonsCount = [self additionalButtonsCount];
cvLayout.buttonsCount = MWMBottomMenuViewCellCount;
[self.additionalButtons reloadData];
[(MWMBottomMenuView *)self.view refreshLayout];
}
@ -264,7 +263,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return [self additionalButtonsCount];
return MWMBottomMenuViewCellCount;
}
- (nonnull UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView
@ -311,16 +310,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
badgeCount:0
isEnabled:YES];
break;
case MWMBottomMenuViewCellAd:
{
MTRGNativeAppwallBanner * banner = [self.controller.appWallAd.banners firstObject];
[self.controller.appWallAd handleShow:banner];
[cell configureWithImageName:@"ic_menu_showcase"
label:L(@"showcase_more_apps")
badgeCount:0
isEnabled:YES];
}
break;
case MWMBottomMenuViewCellCount: break;
}
return cell;
@ -341,7 +330,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
case MWMBottomMenuViewCellDownload: [self menuActionDownloadMaps]; break;
case MWMBottomMenuViewCellSettings: [self menuActionOpenSettings]; break;
case MWMBottomMenuViewCellShare: [self menuActionShareLocation]; break;
case MWMBottomMenuViewCellAd: [self menuActionOpenAd]; break;
case MWMBottomMenuViewCellCount: break;
}
}
@ -394,46 +382,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
[shareVC presentInParentViewController:self.controller anchorView:cell.icon];
}
- (void)menuActionOpenAd
{
NSArray<MTRGNativeAppwallBanner *> * banners = self.controller.appWallAd.banners;
NSAssert(banners.count != 0, @"Banners collection can not be empty!");
[Statistics logEvent:kStatMenu withParameters:@{kStatButton : kStatMoreApps}];
self.state = self.restoreState;
[self.controller.appWallAd showWithController:self.controller
onComplete:^{
[Statistics logEvent:kStatMyTargetAppsDisplayed
withParameters:@{
kStatCount : @(banners.count)
}];
NSMutableArray<NSString *> * appNames = [@[] mutableCopy];
for (MTRGNativeAppwallBanner * banner in banners)
{
[Statistics logEvent:kStatMyTargetAppsDisplayed
withParameters:@{kStatName : banner.title}];
[appNames addObject:banner.title];
}
NSString * appNamesString = [appNames componentsJoinedByString:@";"];
[Alohalytics logEvent:kStatMyTargetAppsDisplayed
withDictionary:@{
kStatCount : @(banners.count),
kStatName : appNamesString
}];
}
onError:^(NSError * error) {
NSMutableArray<NSString *> * appNames = [@[] mutableCopy];
for (MTRGNativeAppwallBanner * banner in banners)
[appNames addObject:banner.title];
NSString * appNamesString = [appNames componentsJoinedByString:@";"];
[Statistics logEvent:kStatMyTargetAppsDisplayed
withParameters:@{
kStatError : error,
kStatCount : @(banners.count),
kStatName : appNamesString
}];
}];
}
- (IBAction)point2PointButtonTouchUpInside:(UIButton *)sender
{
[Statistics logEvent:kStatMenu withParameters:@{kStatButton : kStatPointToPoint}];
@ -600,10 +548,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
}
- (BOOL)searchIsActive { return ((MWMBottomMenuView *)self.view).searchIsActive; }
- (NSUInteger)additionalButtonsCount
{
return MWMBottomMenuViewCellCount - (self.controller.isAppWallAdActive ? 0 : 1);
}
- (void)setTtsSoundButton:(MWMButton *)ttsSoundButton
{

View file

@ -1,4 +1,3 @@
#import <MyTargetSDKCorp/MTRGNativeAppwallAd.h>
#import "MWMMapDownloaderTypes.h"
#import "MWMViewController.h"
@ -33,13 +32,8 @@ struct AddressInfo;
- (void)openMapsDownloader:(mwm::DownloaderMode)mode;
- (void)openEditor;
- (void)refreshAd;
- (void)initialize;
@property(nonatomic) MTRGNativeAppwallAd * appWallAd;
@property(nonatomic, readonly) BOOL isAppWallAdActive;
@property(nonatomic, readonly) MWMMapViewControlsManager * controlsManager;
@property(nonatomic) MWMAPIBar * apiBar;

View file

@ -100,7 +100,7 @@ BOOL gIsFirstMyPositionMode = YES;
- (BOOL)isEqual:(id)anObject { return [anObject isMemberOfClass:[NSValueWrapper class]]; }
@end
@interface MapViewController ()<MTRGNativeAppwallAdDelegate, MWMFrameworkDrapeObserver,
@interface MapViewController ()<MWMFrameworkDrapeObserver,
MWMFrameworkStorageObserver, MWMPageControllerProtocol>
@property(nonatomic, readwrite) MWMMapViewControlsManager * controlsManager;
@ -275,8 +275,6 @@ BOOL gIsFirstMyPositionMode = YES;
self.controlsManager.menuState = self.controlsManager.menuRestoreState;
[self refreshAd];
[self updateStatusBarStyle];
GetFramework().InvalidateRendering();
[self showWelcomeScreenIfNeeded];
@ -537,41 +535,6 @@ BOOL gIsFirstMyPositionMode = YES;
[self.controlsManager onRoutePrepare];
}
#pragma mark - myTarget
- (void)refreshAd
{
if (isIOS7 || [MWMSettings adServerForbidden] || [MWMSettings adForbidden])
{
self.appWallAd = nil;
return;
}
if (self.isAppWallAdActive)
return;
self.appWallAd = [[MTRGNativeAppwallAd alloc] initWithSlotId:@(MY_TARGET_KEY)];
self.appWallAd.handleLinksInApp = YES;
self.appWallAd.closeButtonTitle = L(@"close");
self.appWallAd.delegate = self;
[self.appWallAd load];
}
- (void)onLoadWithAppwallBanners:(NSArray *)appwallBanners
appwallAd:(MTRGNativeAppwallAd *)appwallAd
{
if (![appwallAd isEqual:self.appWallAd])
return;
if (appwallBanners.count == 0)
self.appWallAd = nil;
[self.controlsManager refreshLayout];
}
- (void)onNoAdWithReason:(NSString *)reason appwallAd:(MTRGNativeAppwallAd *)appwallAd
{
if (![appwallAd isEqual:self.appWallAd])
return;
self.appWallAd = nil;
}
#pragma mark - API bar
- (MWMAPIBar *)apiBar
@ -637,12 +600,6 @@ BOOL gIsFirstMyPositionMode = YES;
#pragma mark - Properties
- (void)setAppWallAd:(MTRGNativeAppwallAd *)appWallAd
{
_appWallAd = appWallAd;
[self.controlsManager refreshLayout];
}
- (MWMMapViewControlsManager *)controlsManager
{
if (!self.isViewLoaded)
@ -652,13 +609,6 @@ BOOL gIsFirstMyPositionMode = YES;
return _controlsManager;
}
- (BOOL)isAppWallAdActive
{
BOOL const haveAppWall = (self.appWallAd != nil);
BOOL const haveBanners = (self.appWallAd.banners && self.appWallAd.banners != 0);
return haveAppWall && haveBanners;
}
- (BOOL)hasNavigationBar { return NO; }
- (MWMMapDownloadDialog *)downloadDialog
{

View file

@ -622,7 +622,6 @@ using namespace osm_auth_ios;
{
LOG(LINFO, ("applicationWillResignActive"));
[self.mapViewController onGetFocus:NO];
[self.mapViewController.appWallAd close];
[MWMRouterSavedState store];
GetFramework().SetRenderingDisabled(false);
[MWMLocationManager applicationWillResignActive];
@ -1105,9 +1104,6 @@ using namespace osm_auth_ios;
completionHandler:^(NSData * data, NSURLResponse * response, NSError * error) {
bool const adServerForbidden = (error || [(NSHTTPURLResponse *)response statusCode] != 200);
[MWMSettings setAdServerForbidden:adServerForbidden];
dispatch_async(dispatch_get_main_queue(), ^{
[self.mapViewController refreshAd];
});
}];
[task resume];
}