[MAPSME-4906] [ios] Fixed check if phone call available in place page.

This commit is contained in:
Ilya Grechuhin 2017-07-07 14:24:20 +03:00 committed by r.kuznetsov
parent 84941093bb
commit e350821a67
4 changed files with 21 additions and 8 deletions

View file

@ -21,5 +21,6 @@ typedef NS_ENUM(NSInteger, MWMOpenGLDriver) {
@property(nonatomic, readonly) NSDate * buildDate;
@property(nonatomic, readonly) NSString * deviceName;
@property(nonatomic, readonly) MWMOpenGLDriver openGLDriver;
@property(nonatomic, readonly) BOOL canMakeCalls;
@end

View file

@ -259,4 +259,16 @@ NSDictionary * const kDeviceNamesWithMetalDriver = @{
return MWMOpenGLDriverMetal;
}
- (BOOL)canMakeCalls
{
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone)
return NO;
NSURL * telURL = [NSURL URLWithString:@"tel://"];
if (![[UIApplication sharedApplication] canOpenURL:telURL])
return NO;
NSString * networkCode =
[[CTTelephonyNetworkInfo alloc] init].subscriberCellularProvider.mobileNetworkCode;
return networkCode != nil && networkCode.length > 0 && ![networkCode isEqualToString:@"65535"];
}
@end

View file

@ -101,6 +101,7 @@
<string>fbshareextension</string>
<string>uber</string>
<string>yandextaxi</string>
<string>tel</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>

View file

@ -1,4 +1,5 @@
#import "MWMPlacePageActionBar.h"
#import "AppInfo.h"
#import "MWMActionBarButton.h"
#import "MWMCommon.h"
#import "MWMPlacePageProtocol.h"
@ -50,15 +51,13 @@ extern NSString * const kAlohalyticsTapEventKey;
m_visibleButtons.clear();
m_additionalButtons.clear();
auto data = self.data;
NSString * phone = data.phoneNumber;
BOOL const isIphone = [[UIDevice currentDevice].model isEqualToString:@"iPhone"];
BOOL const isPhoneNotEmpty = phone.length > 0;
BOOL const isBooking = data.isBooking;
BOOL const isOpentable = data.isOpentable;
BOOL const isBookingSearch = data.isBookingSearch;
BOOL const isSponsored = isBooking || isOpentable || isBookingSearch;
BOOL const itHasPhoneNumber = isIphone && isPhoneNotEmpty;
BOOL const isPhoneCallAvailable =
[AppInfo sharedInfo].canMakeCalls && data.phoneNumber.length > 0;
BOOL const isApi = data.isApi;
BOOL const isP2P =
[MWMNavigationDashboardManager manager].state != MWMNavigationDashboardStateHidden;
@ -89,7 +88,7 @@ extern NSString * const kAlohalyticsTapEventKey;
m_additionalButtons.push_back(EButton::Bookmark);
if (isSponsored)
m_additionalButtons.push_back(sponsoredButton);
if (itHasPhoneNumber)
if (isPhoneCallAvailable)
m_additionalButtons.push_back(EButton::Call);
if (isApi)
m_additionalButtons.push_back(EButton::Api);
@ -128,7 +127,7 @@ extern NSString * const kAlohalyticsTapEventKey;
m_additionalButtons.push_back(EButton::RouteFrom);
m_additionalButtons.push_back(EButton::Share);
}
else if (isApi && itHasPhoneNumber)
else if (isApi && isPhoneCallAvailable)
{
m_visibleButtons.push_back(EButton::Api);
m_visibleButtons.push_back(EButton::Call);
@ -157,7 +156,7 @@ extern NSString * const kAlohalyticsTapEventKey;
m_additionalButtons.push_back(sponsoredButton);
m_additionalButtons.push_back(EButton::Share);
}
else if (itHasPhoneNumber && isP2P)
else if (isPhoneCallAvailable && isP2P)
{
m_visibleButtons.push_back(EButton::Bookmark);
m_visibleButtons.push_back(EButton::RouteFrom);
@ -171,7 +170,7 @@ extern NSString * const kAlohalyticsTapEventKey;
m_additionalButtons.push_back(EButton::RouteFrom);
m_additionalButtons.push_back(EButton::Share);
}
else if (itHasPhoneNumber)
else if (isPhoneCallAvailable)
{
m_visibleButtons.push_back(EButton::Call);
m_visibleButtons.push_back(EButton::Bookmark);