[ios] Updated routing disclaimer alert.

This commit is contained in:
Ilya Grechuhin 2016-09-05 12:54:59 +03:00
parent 0fac8c1eb7
commit d8fabaa348
10 changed files with 115 additions and 51 deletions

View file

@ -20,7 +20,7 @@
- (void)presentRateAlert;
- (void)presentFacebookAlert;
- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild;
- (void)presentRoutingDisclaimerAlert;
- (void)presentRoutingDisclaimerAlertWithOkBlock:(nonnull nonnull TMWMVoidBlock)block;
- (void)presentDisabledLocationAlert;
- (void)presentLocationAlert;
- (void)presentLocationServiceNotSupportedAlert;

View file

@ -108,11 +108,12 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
downloadCompleteBlock:downloadCompleteBlock]];
}
- (void)presentRoutingDisclaimerAlert
- (void)presentRoutingDisclaimerAlertWithOkBlock:(TMWMVoidBlock)block
{
[self displayAlert:[MWMAlert
routingDisclaimerAlertWithInitialOrientation:self.ownerViewController
.interfaceOrientation]];
[self
displayAlert:[MWMAlert routingDisclaimerAlertWithInitialOrientation:self.ownerViewController
.interfaceOrientation
okBlock:block]];
}
- (void)presentDisabledLocationAlert { [self displayAlert:MWMAlert.disabledLocationAlert]; }

View file

@ -18,7 +18,7 @@ using TMWMDownloadBlock = void (^)(storage::TCountriesVec const &, TMWMVoidBlock
+ (MWMAlert *)rateAlert;
+ (MWMAlert *)facebookAlert;
+ (MWMAlert *)locationAlert;
+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation;
+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation okBlock:(TMWMVoidBlock)block;
+ (MWMAlert *)disabledLocationAlert;
+ (MWMAlert *)noWiFiAlertWithOkBlock:(TMWMVoidBlock)okBlock;
+ (MWMAlert *)noConnectionAlert;

View file

@ -33,9 +33,9 @@
return [MWMDefaultAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild];
}
+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation
+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation okBlock:(TMWMVoidBlock)block
{
return [MWMRoutingDisclaimerAlert alertWithInitialOrientation:orientation];
return [MWMRoutingDisclaimerAlert alertWithInitialOrientation:orientation okBlock:block];
}
+ (MWMAlert *)disabledLocationAlert

View file

@ -2,6 +2,6 @@
@interface MWMRoutingDisclaimerAlert : MWMAlert
+ (instancetype)alertWithInitialOrientation:(UIInterfaceOrientation)orientation;
+ (instancetype)alertWithInitialOrientation:(UIInterfaceOrientation)orientation okBlock:(TMWMVoidBlock)block;
@end

View file

@ -12,12 +12,13 @@ static NSString * const kStatisticsEvent = @"Routing Disclaimer Alert";
@property(weak, nonatomic) IBOutlet UITextView * textView;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
@property(copy, nonatomic) TMWMVoidBlock okBlock;
@end
@implementation MWMRoutingDisclaimerAlert
+ (instancetype)alertWithInitialOrientation:(UIInterfaceOrientation)orientation
+ (instancetype)alertWithInitialOrientation:(UIInterfaceOrientation)orientation okBlock:(TMWMVoidBlock)block
{
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
MWMRoutingDisclaimerAlert * alert =
@ -45,12 +46,20 @@ static NSString * const kStatisticsEvent = @"Routing Disclaimer Alert";
else
height = window.height;
[alert invalidateTextViewHeight:alert.textView.height withHeight:height];
alert.okBlock = block;
return alert;
}
- (IBAction)okTap
{
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatApply}];
self.okBlock();
[self close];
}
- (IBAction)cancelTap
{
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatCancel}];
[self close];
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
@ -8,6 +8,7 @@
<mutableArray key="HelveticaNeue.ttc">
<string>HelveticaNeue-Medium</string>
<string>HelveticaNeue-Medium</string>
<string>HelveticaNeue-Medium</string>
</mutableArray>
</customFonts>
<objects>
@ -68,10 +69,9 @@
</userDefinedRuntimeAttributes>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aCY-1G-NL5" userLabel="right">
<rect key="frame" x="0.0" y="93" width="280" height="44"/>
<rect key="frame" x="141" y="93" width="139" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="AAv-pX-uuc"/>
<constraint firstAttribute="width" constant="280" id="lvU-ua-qht"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="17"/>
<state key="normal" title="right">
@ -80,7 +80,7 @@
</state>
<state key="highlighted" backgroundImage="dialog_btn_press"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="ok"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="accept"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="medium17"/>
</userDefinedRuntimeAttributes>
@ -88,6 +88,33 @@
<action selector="okTap" destination="Ie9-JJ-hnZ" eventType="touchUpInside" id="vfz-Rd-Kh6"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JfV-qu-qmI" userLabel="left">
<rect key="frame" x="0.0" y="93" width="140" height="44"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="17"/>
<state key="normal" title="left">
<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>
<state key="highlighted" backgroundImage="dialog_btn_press"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="decline"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="medium17"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="cancelTap" destination="Ie9-JJ-hnZ" eventType="touchUpInside" id="KWl-Dn-BpU"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="930-J1-9o0" userLabel="vDivider">
<rect key="frame" x="140" y="93" width="1" height="44"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="mf2-e7-Qg6"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="blackDividers"/>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="0.88" colorSpace="calibratedWhite"/>
<constraints>
@ -95,12 +122,20 @@
<constraint firstAttribute="width" secondItem="XIL-q9-MMp" secondAttribute="width" id="3m7-Ha-HlN"/>
<constraint firstItem="XIL-q9-MMp" firstAttribute="top" secondItem="lbr-Xd-hLF" secondAttribute="bottom" constant="20" id="4k1-g8-WZV"/>
<constraint firstAttribute="trailing" secondItem="aCY-1G-NL5" secondAttribute="trailing" id="BcN-zR-SdX"/>
<constraint firstItem="930-J1-9o0" firstAttribute="bottom" secondItem="aCY-1G-NL5" secondAttribute="bottom" id="F4d-Td-XJg"/>
<constraint firstItem="JfV-qu-qmI" firstAttribute="width" secondItem="aCY-1G-NL5" secondAttribute="width" id="KAH-qc-1f1"/>
<constraint firstAttribute="width" constant="280" id="KpN-ir-OWh"/>
<constraint firstAttribute="centerX" secondItem="lbr-Xd-hLF" secondAttribute="centerX" id="KuP-DA-FWV"/>
<constraint firstItem="JfV-qu-qmI" firstAttribute="bottom" secondItem="aCY-1G-NL5" secondAttribute="bottom" id="MPL-wr-BbK"/>
<constraint firstItem="aCY-1G-NL5" firstAttribute="leading" secondItem="930-J1-9o0" secondAttribute="trailing" id="N4p-JX-gzl"/>
<constraint firstAttribute="centerX" secondItem="S3s-j7-v6E" secondAttribute="centerX" id="Oag-6s-ais"/>
<constraint firstItem="S3s-j7-v6E" firstAttribute="top" secondItem="Ogu-AE-Ohh" secondAttribute="top" constant="20" id="OoP-Qp-YIb"/>
<constraint firstItem="JfV-qu-qmI" firstAttribute="leading" secondItem="Ogu-AE-Ohh" secondAttribute="leading" id="VYG-iz-HL8"/>
<constraint firstAttribute="bottom" secondItem="aCY-1G-NL5" secondAttribute="bottom" id="WB8-od-eAG"/>
<constraint firstItem="930-J1-9o0" firstAttribute="top" secondItem="aCY-1G-NL5" secondAttribute="top" id="aP7-3d-zW1"/>
<constraint firstItem="JfV-qu-qmI" firstAttribute="top" secondItem="aCY-1G-NL5" secondAttribute="top" id="b8D-tm-ZFK"/>
<constraint firstAttribute="centerX" secondItem="XIL-q9-MMp" secondAttribute="centerX" id="bas-rx-OTg"/>
<constraint firstItem="930-J1-9o0" firstAttribute="leading" secondItem="JfV-qu-qmI" secondAttribute="trailing" id="gTM-qA-I1T"/>
<constraint firstItem="aCY-1G-NL5" firstAttribute="top" secondItem="XIL-q9-MMp" secondAttribute="bottom" id="swb-Yx-lVo"/>
</constraints>
<userDefinedRuntimeAttributes>

View file

@ -178,37 +178,51 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
- (void)start
{
if (self.startPoint.IsMyPosition())
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatGo)
withParameters:@{kStatValue : kStatFromMyPosition}];
else if (self.finishPoint.IsMyPosition())
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatGo)
withParameters:@{kStatValue : kStatToMyPosition}];
else
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatGo)
withParameters:@{kStatValue : kStatPointToPoint}];
auto const doStart = ^{
if (self.startPoint.IsMyPosition())
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatGo)
withParameters:@{kStatValue : kStatFromMyPosition}];
else if (self.finishPoint.IsMyPosition())
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatGo)
withParameters:@{kStatValue : kStatToMyPosition}];
else
[Statistics logEvent:kStatEventName(kStatPointToPoint, kStatGo)
withParameters:@{kStatValue : kStatPointToPoint}];
if (self.startPoint.IsMyPosition())
if (self.startPoint.IsMyPosition())
{
GetFramework().FollowRoute();
[[MWMMapViewControlsManager manager] onRouteStart];
MapsAppDelegate * app = [MapsAppDelegate theApp];
app.routingPlaneMode = MWMRoutingPlaneModeNone;
[MWMRouterSavedState store];
[MapsAppDelegate changeMapStyleIfNedeed];
[app startMapStyleChecker];
}
else
{
MWMAlertViewController * alertController = [MWMAlertViewController activeAlertController];
CLLocation * lastLocation = [MWMLocationManager lastLocation];
BOOL const needToRebuild = lastLocation &&
!location_helpers::isMyPositionPendingOrNoPosition() &&
!self.finishPoint.IsMyPosition();
[alertController presentPoint2PointAlertWithOkBlock:^{
[self buildFromPoint:lastLocationPoint() bestRouter:NO];
}
needToRebuild:needToRebuild];
}
};
if ([MWMSettings routingDisclaimerApproved])
{
GetFramework().FollowRoute();
[[MWMMapViewControlsManager manager] onRouteStart];
MapsAppDelegate * app = [MapsAppDelegate theApp];
app.routingPlaneMode = MWMRoutingPlaneModeNone;
[MWMRouterSavedState store];
[MapsAppDelegate changeMapStyleIfNedeed];
[app startMapStyleChecker];
doStart();
}
else
{
MWMAlertViewController * alertController = [MWMAlertViewController activeAlertController];
CLLocation * lastLocation = [MWMLocationManager lastLocation];
BOOL const needToRebuild = lastLocation &&
!location_helpers::isMyPositionPendingOrNoPosition() &&
!self.finishPoint.IsMyPosition();
[alertController presentPoint2PointAlertWithOkBlock:^{
[self buildFromPoint:lastLocationPoint() bestRouter:NO];
}
needToRebuild:needToRebuild];
[[MWMAlertViewController activeAlertController] presentRoutingDisclaimerAlertWithOkBlock:^{
doStart();
[MWMSettings setRoutingDisclaimerApproved];
}];
}
}
@ -243,16 +257,6 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
[[MWMNavigationDashboardManager manager] updateFollowingInfo:info];
}
- (void)showDisclaimer
{
bool isDisclaimerApproved = false;
UNUSED_VALUE(settings::Get("IsDisclaimerApproved", isDisclaimerApproved));
if (isDisclaimerApproved)
return;
[[MWMAlertViewController activeAlertController] presentRoutingDisclaimerAlert];
settings::Set("IsDisclaimerApproved", true);
}
#pragma mark - MWMLocationObserver
- (void)onLocationUpdate:(location::GpsInfo const &)info
@ -295,7 +299,6 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
else
[[MWMMapViewControlsManager manager] onRouteReady];
[self updateFollowingInfo];
[self showDisclaimer];
[[MWMNavigationDashboardManager manager] setRouteBuilderProgress:100];
[MWMMapViewControlsManager manager].searchHidden = YES;
break;

View file

@ -24,4 +24,7 @@
+ (BOOL)autoNightModeEnabled;
+ (void)setAutoNightModeEnabled:(BOOL)autoNightModeEnabled;
+ (BOOL)routingDisclaimerApproved;
+ (void)setRoutingDisclaimerApproved;
@end

View file

@ -14,6 +14,7 @@ char const * kAdServerForbiddenKey = "AdServerForbidden";
char const * kAutoDownloadEnabledKey = "AutoDownloadEnabled";
char const * kZoomButtonsEnabledKey = "ZoomButtonsEnabled";
char const * kCompassCalibrationEnabledKey = "CompassCalibrationEnabled";
char const * kRoutingDisclaimerApprovedKey = "IsDisclaimerApproved";
NSString * const kUDAutoNightModeOff = @"AutoNightModeOff";
} // namespace
@ -108,4 +109,16 @@ NSString * const kUDAutoNightModeOff = @"AutoNightModeOff";
[ud synchronize];
}
+ (BOOL)routingDisclaimerApproved
{
bool enabled = false;
UNUSED_VALUE(settings::Get(kRoutingDisclaimerApprovedKey, enabled));
return enabled;
}
+ (void)setRoutingDisclaimerApproved
{
settings::Set(kRoutingDisclaimerApprovedKey, true);
}
@end