forked from organicmaps/organicmaps
[MAPSME-2994] [ios] Updated UI to support networking policy.
This commit is contained in:
parent
5bcc41bf6f
commit
fa1f7a6bd1
6 changed files with 47 additions and 10 deletions
|
@ -50,7 +50,7 @@
|
|||
- (void)presentPersonalInfoWarningAlertWithBlock:(nonnull TMWMVoidBlock)block;
|
||||
- (void)presentTrackWarningAlertWithCancelBlock:(nonnull TMWMVoidBlock)block;
|
||||
- (void)presentSearchNoResultsAlert;
|
||||
- (void)presentMobileInternetAlert;
|
||||
- (void)presentMobileInternetAlertWithBlock:(nonnull TMWMVoidBlock)block;
|
||||
- (void)closeAlert:(nullable TMWMVoidBlock)completion;
|
||||
|
||||
- (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
|
|
|
@ -206,7 +206,10 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[alert update];
|
||||
}
|
||||
|
||||
- (void)presentMobileInternetAlert { [self displayAlert:[MWMMobileInternetAlert alert]]; }
|
||||
- (void)presentMobileInternetAlertWithBlock:(nonnull TMWMVoidBlock)block
|
||||
{
|
||||
[self displayAlert:[MWMMobileInternetAlert alertWithBlock:block]];
|
||||
}
|
||||
- (void)presentEditorViralAlert { [self displayAlert:[MWMAlert editorViralAlert]]; }
|
||||
- (void)presentOsmAuthAlert { [self displayAlert:[MWMAlert osmAuthAlert]]; }
|
||||
- (void)displayAlert:(MWMAlert *)alert
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
@interface MWMMobileInternetAlert : MWMAlert
|
||||
|
||||
+ (instancetype)alert;
|
||||
+ (instancetype)alertWithBlock:(nonnull TMWMVoidBlock)block;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,38 +1,51 @@
|
|||
#import "MWMMobileInternetAlert.h"
|
||||
#import "MWMNetworkingPolicy.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
using namespace networking_policy;
|
||||
|
||||
namespace
|
||||
{
|
||||
NSString * const kStatisticsEvent = @"Mobile Internet Settings Alert";
|
||||
}
|
||||
|
||||
@interface MWMMobileInternetAlert ()
|
||||
|
||||
@property(copy, nonatomic) TMWMVoidBlock completionBlock;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMMobileInternetAlert
|
||||
|
||||
+ (instancetype)alert
|
||||
+ (instancetype)alertWithBlock:(nonnull TMWMVoidBlock)block
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
|
||||
MWMMobileInternetAlert * alert =
|
||||
[[[NSBundle mainBundle] loadNibNamed:[MWMMobileInternetAlert className] owner:nil options:nil]
|
||||
firstObject];
|
||||
alert.completionBlock = block;
|
||||
return alert;
|
||||
}
|
||||
|
||||
- (IBAction)alwaysTap
|
||||
{
|
||||
[Statistics logEvent:kStatMobileInternet withParameters:@{kStatValue : kStatAlways}];
|
||||
[self close:nil];
|
||||
SetNetworkingPolicyState(NetworkingPolicyState::Always);
|
||||
[self close:self.completionBlock];
|
||||
}
|
||||
|
||||
- (IBAction)askTap
|
||||
{
|
||||
[Statistics logEvent:kStatMobileInternet withParameters:@{kStatValue : kStatAsk}];
|
||||
[self close:nil];
|
||||
SetNetworkingPolicyState(NetworkingPolicyState::Session);
|
||||
[self close:self.completionBlock];
|
||||
}
|
||||
|
||||
- (IBAction)neverTap
|
||||
{
|
||||
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatNever}];
|
||||
[self close:nil];
|
||||
SetNetworkingPolicyState(NetworkingPolicyState::Never);
|
||||
[self close:self.completionBlock];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#import "MWMMobileInternetViewController.h"
|
||||
#import "MWMNetworkingPolicy.h"
|
||||
#import "SelectableCell.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
using namespace networking_policy;
|
||||
|
||||
@interface MWMMobileInternetViewController ()
|
||||
|
||||
@property(weak, nonatomic) IBOutlet SelectableCell * always;
|
||||
|
@ -18,8 +21,15 @@
|
|||
[super viewDidLoad];
|
||||
self.title = L(@"pref_mobile_internet");
|
||||
|
||||
self.never.accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
_selected = self.never;
|
||||
SelectableCell * selected;
|
||||
switch (GetNetworkingPolicyState())
|
||||
{
|
||||
case NetworkingPolicyState::Always: selected = self.always; break;
|
||||
case NetworkingPolicyState::Session: selected = self.ask; break;
|
||||
case NetworkingPolicyState::Never: selected = self.never; break;
|
||||
}
|
||||
selected.accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
self.selected = selected;
|
||||
}
|
||||
|
||||
- (void)setSelected:(SelectableCell *)selected
|
||||
|
@ -32,14 +42,17 @@
|
|||
if ([selected isEqual:self.always])
|
||||
{
|
||||
statValue = kStatAlways;
|
||||
SetNetworkingPolicyState(NetworkingPolicyState::Always);
|
||||
}
|
||||
else if ([selected isEqual:self.ask])
|
||||
{
|
||||
statValue = kStatAsk;
|
||||
SetNetworkingPolicyState(NetworkingPolicyState::Session);
|
||||
}
|
||||
else if ([selected isEqual:self.never])
|
||||
{
|
||||
statValue = kStatNever;
|
||||
SetNetworkingPolicyState(NetworkingPolicyState::Never);
|
||||
}
|
||||
|
||||
[Statistics logEvent:kStatMobileInternet withParameters:@{kStatValue : statValue}];
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#import "LinkCell.h"
|
||||
#import "LocaleTranslator.h"
|
||||
#import "MWMAuthorizationCommon.h"
|
||||
#import "MWMNetworkingPolicy.h"
|
||||
#import "MWMSettings.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "Statistics.h"
|
||||
|
@ -85,7 +86,14 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
self.autoDownloadCell.switchButton.on = [MWMSettings autoDownloadEnabled];
|
||||
self.autoDownloadCell.delegate = self;
|
||||
|
||||
self.mobileInternetCell.infoLabel.text = L(@"pref_ask");
|
||||
NSString * internetLabel = nil;
|
||||
switch (networking_policy::GetNetworkingPolicyState())
|
||||
{
|
||||
case networking_policy::NetworkingPolicyState::Always: internetLabel = L(@"pref_always"); break;
|
||||
case networking_policy::NetworkingPolicyState::Session: internetLabel = L(@"pref_ask"); break;
|
||||
case networking_policy::NetworkingPolicyState::Never: internetLabel = L(@"pref_never"); break;
|
||||
}
|
||||
self.mobileInternetCell.infoLabel.text = internetLabel;
|
||||
|
||||
if (!GpsTracker::Instance().IsEnabled())
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue