forked from organicmaps/organicmaps
[iOS] Codestyle
This commit is contained in:
parent
59501220e1
commit
179a7e0840
8 changed files with 251 additions and 297 deletions
|
@ -228,11 +228,12 @@ using namespace osm_auth_ios;
|
|||
}];
|
||||
[[InAppPurchase allPassSubscriptionManager] validateWithCompletion:^(MWMValidationResult result, BOOL isTrial) {
|
||||
if (result == MWMValidationResultNotValid) {
|
||||
[[InAppPurchase allPassSubscriptionManager] setSubscriptionActive:NO isTrial: NO];
|
||||
[[InAppPurchase allPassSubscriptionManager] setSubscriptionActive:NO isTrial:NO];
|
||||
}
|
||||
}];
|
||||
[[InAppPurchase adsRemovalSubscriptionManager] validateWithCompletion:^(MWMValidationResult result, BOOL isTrial) {
|
||||
[[InAppPurchase adsRemovalSubscriptionManager] setSubscriptionActive:result != MWMValidationResultNotValid isTrial:NO];
|
||||
[[InAppPurchase adsRemovalSubscriptionManager] setSubscriptionActive:result != MWMValidationResultNotValid
|
||||
isTrial:NO];
|
||||
}];
|
||||
self.pendingTransactionHandler = [InAppPurchase pendingTransactionsHandler];
|
||||
__weak __typeof(self) ws = self;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fileprivate struct StoreProduct: IStoreProduct {
|
||||
private struct StoreProduct: IStoreProduct {
|
||||
var localizedName: String
|
||||
var formattedPrice: String
|
||||
|
||||
|
@ -31,12 +31,12 @@ final class PaidRoutePurchase: NSObject, IPaidRoutePurchase {
|
|||
self.productId = productId
|
||||
self.purchaseValidation = purchaseValidation
|
||||
self.billing = billing
|
||||
self.purchaseManager = MWMPurchaseManager(vendorId: vendorId)
|
||||
purchaseManager = MWMPurchaseManager(vendorId: vendorId)
|
||||
super.init()
|
||||
}
|
||||
|
||||
func requestStoreProduct(_ completion: @escaping StoreProductCompletion) {
|
||||
billing.requestProducts([productId]) { [weak self] (products, error) in
|
||||
billing.requestProducts([productId]) { [weak self] products, error in
|
||||
guard let product = products?.first else {
|
||||
completion(nil, error)
|
||||
return
|
||||
|
@ -53,13 +53,13 @@ final class PaidRoutePurchase: NSObject, IPaidRoutePurchase {
|
|||
}
|
||||
|
||||
storePaymentCompletion = completion
|
||||
purchaseManager.startTransaction(serverId) { [weak self] (success, serverId) in
|
||||
purchaseManager.startTransaction(serverId) { [weak self] success, serverId in
|
||||
if !success {
|
||||
self?.storePaymentCompletion?(.error, RoutePurchaseError.paymentError)
|
||||
self?.storePaymentCompletion = nil
|
||||
return
|
||||
}
|
||||
self?.billing.makePayment(product) { (status, error) in
|
||||
self?.billing.makePayment(product) { status, error in
|
||||
switch status {
|
||||
case .success:
|
||||
self?.purchased()
|
||||
|
@ -75,7 +75,7 @@ final class PaidRoutePurchase: NSObject, IPaidRoutePurchase {
|
|||
}
|
||||
|
||||
private func purchased() {
|
||||
purchaseValidation.validateReceipt(serverId, callback: { [weak self] result, isTrial in
|
||||
purchaseValidation.validateReceipt(serverId, callback: { [weak self] result, isTrial in
|
||||
switch result {
|
||||
case .valid:
|
||||
self?.billing.finishTransaction()
|
||||
|
@ -85,7 +85,7 @@ final class PaidRoutePurchase: NSObject, IPaidRoutePurchase {
|
|||
case .error:
|
||||
self?.storePaymentCompletion?(.error, RoutePurchaseError.validationError)
|
||||
case .authError:
|
||||
break // TODO(@beloal)
|
||||
break // TODO(@beloal)
|
||||
}
|
||||
self?.storePaymentCompletion = nil
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@ final class PendingTransactionsHandler: IPendingTransactionsHandler {
|
|||
private let pendingTransaction: IBillingPendingTransaction
|
||||
|
||||
init(validation: IMWMPurchaseValidation, pendingTransaction: IBillingPendingTransaction) {
|
||||
self.purchaseValidation = validation
|
||||
purchaseValidation = validation
|
||||
self.pendingTransaction = pendingTransaction
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,8 @@ final class PendingTransactionsHandler: IPendingTransactionsHandler {
|
|||
switch pendingTransaction.status {
|
||||
case .none:
|
||||
completion(.none)
|
||||
break
|
||||
case .paid:
|
||||
purchaseValidation.validateReceipt("") {[weak self] result, _ in
|
||||
purchaseValidation.validateReceipt("") { [weak self] result, _ in
|
||||
switch result {
|
||||
case .valid, .notValid, .noReceipt:
|
||||
completion(.success)
|
||||
|
@ -24,13 +23,10 @@ final class PendingTransactionsHandler: IPendingTransactionsHandler {
|
|||
completion(.needAuth)
|
||||
}
|
||||
}
|
||||
break
|
||||
case .failed:
|
||||
pendingTransaction.finishTransaction()
|
||||
break
|
||||
case .error:
|
||||
completion(.error)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,31 +101,32 @@
|
|||
|
||||
- (void)validateReceipt:(NSString *)serverId refreshReceipt:(BOOL)refresh {
|
||||
__weak __typeof(self) ws = self;
|
||||
[self.purchaseValidation validateReceipt:serverId
|
||||
callback:^(MWMPurchaseValidationResult validationResult, BOOL isTrial) {
|
||||
__strong __typeof(self) self = ws;
|
||||
switch (validationResult) {
|
||||
case MWMPurchaseValidationResultValid:
|
||||
[self notifyValidation:serverId result:MWMValidationResultValid isTrial: isTrial];
|
||||
break;
|
||||
case MWMPurchaseValidationResultNotValid:
|
||||
[self notifyValidation:serverId result:MWMValidationResultNotValid isTrial: NO];
|
||||
break;
|
||||
case MWMPurchaseValidationResultError:
|
||||
[self notifyValidation:serverId result:MWMValidationResultServerError isTrial: NO];
|
||||
break;
|
||||
case MWMPurchaseValidationResultAuthError:
|
||||
[self notifyValidation:serverId result:MWMValidationResultAuthError isTrial: NO];
|
||||
break;
|
||||
case MWMPurchaseValidationResultNoReceipt:
|
||||
if (refresh) {
|
||||
[self refreshReceipt];
|
||||
} else {
|
||||
[self notifyValidation:serverId result:MWMValidationResultNotValid isTrial: NO];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}];
|
||||
[self.purchaseValidation
|
||||
validateReceipt:serverId
|
||||
callback:^(MWMPurchaseValidationResult validationResult, BOOL isTrial) {
|
||||
__strong __typeof(self) self = ws;
|
||||
switch (validationResult) {
|
||||
case MWMPurchaseValidationResultValid:
|
||||
[self notifyValidation:serverId result:MWMValidationResultValid isTrial:isTrial];
|
||||
break;
|
||||
case MWMPurchaseValidationResultNotValid:
|
||||
[self notifyValidation:serverId result:MWMValidationResultNotValid isTrial:NO];
|
||||
break;
|
||||
case MWMPurchaseValidationResultError:
|
||||
[self notifyValidation:serverId result:MWMValidationResultServerError isTrial:NO];
|
||||
break;
|
||||
case MWMPurchaseValidationResultAuthError:
|
||||
[self notifyValidation:serverId result:MWMValidationResultAuthError isTrial:NO];
|
||||
break;
|
||||
case MWMPurchaseValidationResultNoReceipt:
|
||||
if (refresh) {
|
||||
[self refreshReceipt];
|
||||
} else {
|
||||
[self notifyValidation:serverId result:MWMValidationResultNotValid isTrial:NO];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkTrialEligibility:(NSString *)serverId
|
||||
|
@ -201,7 +202,7 @@
|
|||
GetFramework().GetPurchase()->SetSubscriptionEnabled(SubscriptionType::BookmarksSights, active, false);
|
||||
}
|
||||
|
||||
+ (void)setAllPassSubscriptionActive:(BOOL)active isTrial:(BOOL)isTrial{
|
||||
+ (void)setAllPassSubscriptionActive:(BOOL)active isTrial:(BOOL)isTrial {
|
||||
GetFramework().GetPurchase()->SetSubscriptionEnabled(SubscriptionType::BookmarksAll, active, isTrial);
|
||||
}
|
||||
|
||||
|
@ -224,7 +225,7 @@
|
|||
[self.trialCallbacks
|
||||
enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, NSMutableArray<TrialEligibilityCallback> *_Nonnull obj,
|
||||
BOOL *_Nonnull stop) {
|
||||
[self notifyValidation:key result:MWMValidationResultServerError isTrial: NO];
|
||||
[self notifyValidation:key result:MWMValidationResultServerError isTrial:NO];
|
||||
}];
|
||||
[self.trialCallbacks
|
||||
enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, NSMutableArray<TrialEligibilityCallback> *_Nonnull obj,
|
||||
|
|
|
@ -105,7 +105,7 @@ class SubscriptionManager: NSObject, ISubscriptionManager {
|
|||
}
|
||||
|
||||
private func validate(_ refreshReceipt: Bool, completion: ValidationCompletion? = nil) {
|
||||
purchaseManager?.validateReceipt(serverId, refreshReceipt: refreshReceipt) { [weak self] _, validationResult, isTrial in
|
||||
purchaseManager?.validateReceipt(serverId, refreshReceipt: refreshReceipt) { [weak self] _, validationResult, isTrial in
|
||||
self?.logEvents(validationResult)
|
||||
if validationResult == .valid || validationResult == .notValid {
|
||||
self?.listeners.allObjects.forEach { $0.didValidate(validationResult == .valid) }
|
||||
|
|
|
@ -15,6 +15,7 @@ import SafariServices
|
|||
loadingIndicator.color = .blackPrimaryText()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet weak var payButton: UIButton!
|
||||
@IBOutlet weak var monthButton: UIButton!
|
||||
@IBOutlet weak var weekButton: UIButton!
|
||||
|
@ -28,17 +29,20 @@ import SafariServices
|
|||
moreOptionsButton.setTitle(L("options_dropdown_title").uppercased(), for: .normal)
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet weak var moreOptionsButtonImage: UIImageView!
|
||||
@IBOutlet weak var titleLabel: UILabel! {
|
||||
didSet {
|
||||
titleLabel.text = L("remove_ads_title").uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet weak var whySupportLabel: UILabel! {
|
||||
didSet {
|
||||
whySupportLabel.text = L("why_support").uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet weak var optionsHeightConstraint: NSLayoutConstraint!
|
||||
@IBOutlet weak var whySupportConstraint: NSLayoutConstraint!
|
||||
|
||||
|
@ -75,7 +79,7 @@ import SafariServices
|
|||
super.viewDidLoad()
|
||||
|
||||
InAppPurchase.adsRemovalSubscriptionManager.addListener(self)
|
||||
InAppPurchase.adsRemovalSubscriptionManager.getAvailableSubscriptions { (subscriptions, error) in
|
||||
InAppPurchase.adsRemovalSubscriptionManager.getAvailableSubscriptions { subscriptions, error in
|
||||
self.subscriptions = subscriptions
|
||||
self.productsLoadingIndicator.stopAnimating()
|
||||
guard let subscriptions = subscriptions else {
|
||||
|
@ -108,9 +112,9 @@ import SafariServices
|
|||
VC.formatPrice(monthlyDiscount, locale: locale)]), for: .normal)
|
||||
self.weekButton.setTitle(String(coreFormat: L("options_dropdown_item2"),
|
||||
arguments: [VC.formatPrice(weeklyPrice, locale: locale)]), for: .normal)
|
||||
Statistics.logEvent(kStatInappShow, withParameters: [kStatVendor : MWMPurchaseManager.adsRemovalVendorId(),
|
||||
kStatProduct : subscriptions[2].productId,
|
||||
kStatPurchase : MWMPurchaseManager.adsRemovalServerId(),
|
||||
Statistics.logEvent(kStatInappShow, withParameters: [kStatVendor: MWMPurchaseManager.adsRemovalVendorId(),
|
||||
kStatProduct: subscriptions[2].productId,
|
||||
kStatPurchase: MWMPurchaseManager.adsRemovalServerId(),
|
||||
kStatInappTrial: false],
|
||||
with: .realtime)
|
||||
}
|
||||
|
@ -125,7 +129,7 @@ import SafariServices
|
|||
}
|
||||
|
||||
@IBAction func onClose(_ sender: Any) {
|
||||
Statistics.logEvent(kStatInappCancel, withParameters: [kStatPurchase : MWMPurchaseManager.adsRemovalServerId()])
|
||||
Statistics.logEvent(kStatInappCancel, withParameters: [kStatPurchase: MWMPurchaseManager.adsRemovalServerId()])
|
||||
delegate?.didCancelSubscribtion(self)
|
||||
}
|
||||
|
||||
|
@ -163,26 +167,26 @@ import SafariServices
|
|||
@IBAction func onTerms(_ sender: UIButton) {
|
||||
guard let url = URL(string: User.termsOfUseLink()) else { return }
|
||||
let safari = SFSafariViewController(url: url)
|
||||
self.present(safari, animated: true, completion: nil)
|
||||
present(safari, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
@IBAction func onPrivacy(_ sender: UIButton) {
|
||||
guard let url = URL(string: User.privacyPolicyLink()) else { return }
|
||||
let safari = SFSafariViewController(url: url)
|
||||
self.present(safari, animated: true, completion: nil)
|
||||
present(safari, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
private func subscribe(_ subscription: ISubscription?) {
|
||||
guard let subscription = subscription else {
|
||||
MWMAlertViewController.activeAlert().presentInfoAlert(L("bookmarks_convert_error_title"),
|
||||
text: L("purchase_error_subtitle"))
|
||||
self.delegate?.didCancelSubscribtion(self)
|
||||
delegate?.didCancelSubscribtion(self)
|
||||
return
|
||||
}
|
||||
Statistics.logEvent(kStatInappSelect, withParameters: [kStatProduct : subscription.productId,
|
||||
kStatPurchase : MWMPurchaseManager.adsRemovalServerId(),
|
||||
Statistics.logEvent(kStatInappSelect, withParameters: [kStatProduct: subscription.productId,
|
||||
kStatPurchase: MWMPurchaseManager.adsRemovalServerId(),
|
||||
kStatInappTrial: false])
|
||||
Statistics.logEvent(kStatInappPay, withParameters: [kStatPurchase : MWMPurchaseManager.adsRemovalServerId(),
|
||||
Statistics.logEvent(kStatInappPay, withParameters: [kStatPurchase: MWMPurchaseManager.adsRemovalServerId(),
|
||||
kStatInappTrial: false],
|
||||
with: .realtime)
|
||||
showPurchaseProgress()
|
||||
|
@ -207,23 +211,19 @@ import SafariServices
|
|||
|
||||
override var transitioningDelegate: UIViewControllerTransitioningDelegate? {
|
||||
get { return transitioning }
|
||||
set { }
|
||||
set {}
|
||||
}
|
||||
|
||||
override var modalPresentationStyle: UIModalPresentationStyle {
|
||||
get { return .custom }
|
||||
set { }
|
||||
set {}
|
||||
}
|
||||
}
|
||||
|
||||
extension RemoveAdsViewController: SubscriptionManagerListener {
|
||||
func didFailToValidate() {
|
||||
func didFailToValidate() {}
|
||||
|
||||
}
|
||||
|
||||
func didValidate(_ isValid: Bool) {
|
||||
|
||||
}
|
||||
func didValidate(_ isValid: Bool) {}
|
||||
|
||||
func didSubscribe(_ subscription: ISubscription) {
|
||||
MWMPurchaseManager.setAdsDisabled(true)
|
||||
|
@ -241,7 +241,7 @@ extension RemoveAdsViewController: SubscriptionManagerListener {
|
|||
MWMAlertViewController.activeAlert().presentInfoAlert(L("bookmarks_convert_error_title"),
|
||||
text: L("purchase_error_subtitle"))
|
||||
}
|
||||
|
||||
|
||||
hidePurchaseProgress()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,35 +9,35 @@
|
|||
|
||||
using namespace power_management;
|
||||
|
||||
@interface MWMSettingsViewController ()<SettingsTableViewSwitchCellDelegate, RemoveAdsViewControllerDelegate>
|
||||
@interface MWMSettingsViewController () <SettingsTableViewSwitchCellDelegate, RemoveAdsViewControllerDelegate>
|
||||
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * profileCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *profileCell;
|
||||
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * unitsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * zoomButtonsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * is3dCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * autoDownloadCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * backupBookmarksCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * mobileInternetCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * powerManagementCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * recentTrackCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * fontScaleCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * transliterationCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * compassCalibrationCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * showOffersCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * statisticsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *unitsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *zoomButtonsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *is3dCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *autoDownloadCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *backupBookmarksCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *mobileInternetCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *powerManagementCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *recentTrackCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *fontScaleCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *transliterationCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *compassCalibrationCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *showOffersCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *statisticsCell;
|
||||
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableProgressCell * restoreSubscriptionCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * manageSubscriptionsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableProgressCell *restoreSubscriptionCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *manageSubscriptionsCell;
|
||||
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * nightModeCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * perspectiveViewCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * autoZoomCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * voiceInstructionsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * drivingOptionsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *nightModeCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *perspectiveViewCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *autoZoomCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *voiceInstructionsCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *drivingOptionsCell;
|
||||
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * helpCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * aboutCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *helpCell;
|
||||
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *aboutCell;
|
||||
|
||||
@property(nonatomic) BOOL restoringSubscription;
|
||||
|
||||
|
@ -45,20 +45,17 @@ using namespace power_management;
|
|||
|
||||
@implementation MWMSettingsViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.title = L(@"settings");
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self configCells];
|
||||
}
|
||||
|
||||
- (void)configCells
|
||||
{
|
||||
- (void)configCells {
|
||||
[self configProfileSection];
|
||||
[self configCommonSection];
|
||||
[self configSubsriptionsSection];
|
||||
|
@ -66,25 +63,24 @@ using namespace power_management;
|
|||
[self configInfoSection];
|
||||
}
|
||||
|
||||
- (void)configProfileSection
|
||||
{
|
||||
NSString * userName = osm_auth_ios::OSMUserName();
|
||||
- (void)configProfileSection {
|
||||
NSString *userName = osm_auth_ios::OSMUserName();
|
||||
[self.profileCell configWithTitle:L(@"profile") info:userName.length != 0 ? userName : @""];
|
||||
}
|
||||
|
||||
- (void)configCommonSection
|
||||
{
|
||||
NSString * units = nil;
|
||||
switch ([MWMSettings measurementUnits])
|
||||
{
|
||||
case MWMUnitsMetric: units = L(@"kilometres"); break;
|
||||
case MWMUnitsImperial: units = L(@"miles"); break;
|
||||
- (void)configCommonSection {
|
||||
NSString *units = nil;
|
||||
switch ([MWMSettings measurementUnits]) {
|
||||
case MWMUnitsMetric:
|
||||
units = L(@"kilometres");
|
||||
break;
|
||||
case MWMUnitsImperial:
|
||||
units = L(@"miles");
|
||||
break;
|
||||
}
|
||||
[self.unitsCell configWithTitle:L(@"measurement_units") info:units];
|
||||
|
||||
[self.zoomButtonsCell configWithDelegate:self
|
||||
title:L(@"pref_zoom_title")
|
||||
isOn:[MWMSettings zoomButtonsEnabled]];
|
||||
[self.zoomButtonsCell configWithDelegate:self title:L(@"pref_zoom_title") isOn:[MWMSettings zoomButtonsEnabled]];
|
||||
|
||||
bool on = true, _ = true;
|
||||
GetFramework().Load3dMode(_, on);
|
||||
|
@ -98,8 +94,8 @@ using namespace power_management;
|
|||
title:L(@"settings_backup_bookmarks")
|
||||
isOn:[[MWMBookmarksManager sharedManager] isCloudEnabled]];
|
||||
|
||||
NSString * mobileInternet = nil;
|
||||
switch([MWMNetworkPolicy sharedPolicy].permission) {
|
||||
NSString *mobileInternet = nil;
|
||||
switch ([MWMNetworkPolicy sharedPolicy].permission) {
|
||||
case MWMNetworkPolicyPermissionAlways:
|
||||
mobileInternet = L(@"mobile_data_option_always");
|
||||
break;
|
||||
|
@ -113,40 +109,53 @@ using namespace power_management;
|
|||
break;
|
||||
}
|
||||
[self.mobileInternetCell configWithTitle:L(@"mobile_data") info:mobileInternet];
|
||||
|
||||
NSString * powerManagement = nil;
|
||||
switch (GetFramework().GetPowerManager().GetScheme())
|
||||
{
|
||||
case Scheme::None: break;
|
||||
case Scheme::Normal: powerManagement = L(@"power_managment_setting_never"); break;
|
||||
case Scheme::EconomyMedium: break;
|
||||
case Scheme::EconomyMaximum: powerManagement = L(@"power_managment_setting_manual_max"); break;
|
||||
case Scheme::Auto: powerManagement = L(@"power_managment_setting_auto"); break;
|
||||
|
||||
NSString *powerManagement = nil;
|
||||
switch (GetFramework().GetPowerManager().GetScheme()) {
|
||||
case Scheme::None:
|
||||
break;
|
||||
case Scheme::Normal:
|
||||
powerManagement = L(@"power_managment_setting_never");
|
||||
break;
|
||||
case Scheme::EconomyMedium:
|
||||
break;
|
||||
case Scheme::EconomyMaximum:
|
||||
powerManagement = L(@"power_managment_setting_manual_max");
|
||||
break;
|
||||
case Scheme::Auto:
|
||||
powerManagement = L(@"power_managment_setting_auto");
|
||||
break;
|
||||
}
|
||||
[self.powerManagementCell configWithTitle:L(@"power_managment_title") info:powerManagement];
|
||||
|
||||
NSString * recentTrack = nil;
|
||||
if (!GpsTracker::Instance().IsEnabled())
|
||||
{
|
||||
NSString *recentTrack = nil;
|
||||
if (!GpsTracker::Instance().IsEnabled()) {
|
||||
recentTrack = L(@"duration_disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (GpsTracker::Instance().GetDuration().count())
|
||||
{
|
||||
case 1: recentTrack = L(@"duration_1_hour"); break;
|
||||
case 2: recentTrack = L(@"duration_2_hours"); break;
|
||||
case 6: recentTrack = L(@"duration_6_hours"); break;
|
||||
case 12: recentTrack = L(@"duration_12_hours"); break;
|
||||
case 24: recentTrack = L(@"duration_1_day"); break;
|
||||
default: NSAssert(false, @"Incorrect hours value"); break;
|
||||
} else {
|
||||
switch (GpsTracker::Instance().GetDuration().count()) {
|
||||
case 1:
|
||||
recentTrack = L(@"duration_1_hour");
|
||||
break;
|
||||
case 2:
|
||||
recentTrack = L(@"duration_2_hours");
|
||||
break;
|
||||
case 6:
|
||||
recentTrack = L(@"duration_6_hours");
|
||||
break;
|
||||
case 12:
|
||||
recentTrack = L(@"duration_12_hours");
|
||||
break;
|
||||
case 24:
|
||||
recentTrack = L(@"duration_1_day");
|
||||
break;
|
||||
default:
|
||||
NSAssert(false, @"Incorrect hours value");
|
||||
break;
|
||||
}
|
||||
}
|
||||
[self.recentTrackCell configWithTitle:L(@"pref_track_record_title") info:recentTrack];
|
||||
|
||||
[self.fontScaleCell configWithDelegate:self
|
||||
title:L(@"big_font")
|
||||
isOn:[MWMSettings largeFontSize]];
|
||||
[self.fontScaleCell configWithDelegate:self title:L(@"big_font") isOn:[MWMSettings largeFontSize]];
|
||||
|
||||
[self.transliterationCell configWithDelegate:self
|
||||
title:L(@"whatsnew_transliteration_title")
|
||||
|
@ -156,16 +165,12 @@ using namespace power_management;
|
|||
title:L(@"pref_calibration_title")
|
||||
isOn:[MWMSettings compassCalibrationEnabled]];
|
||||
|
||||
auto & purchase = GetFramework().GetPurchase();
|
||||
auto &purchase = GetFramework().GetPurchase();
|
||||
bool const hasSubscription = purchase && purchase->IsSubscriptionActive(SubscriptionType::RemoveAds);
|
||||
[self.showOffersCell configWithDelegate:self
|
||||
title:L(@"showcase_settings_title")
|
||||
isOn:!hasSubscription];
|
||||
[self.showOffersCell configWithDelegate:self title:L(@"showcase_settings_title") isOn:!hasSubscription];
|
||||
self.showOffersCell.isEnabled = !hasSubscription;
|
||||
|
||||
[self.statisticsCell configWithDelegate:self
|
||||
title:L(@"allow_statistics")
|
||||
isOn:[MWMSettings statisticsEnabled]];
|
||||
[self.statisticsCell configWithDelegate:self title:L(@"allow_statistics") isOn:[MWMSettings statisticsEnabled]];
|
||||
}
|
||||
|
||||
- (void)configSubsriptionsSection {
|
||||
|
@ -173,41 +178,43 @@ using namespace power_management;
|
|||
[self.manageSubscriptionsCell configWithTitle:L(@"manage_subscription") info:nil];
|
||||
}
|
||||
|
||||
- (void)configNavigationSection
|
||||
{
|
||||
NSString * nightMode = nil;
|
||||
switch ([MWMSettings theme])
|
||||
{
|
||||
case MWMThemeVehicleDay: NSAssert(false, @"Invalid case");
|
||||
case MWMThemeDay: nightMode = L(@"pref_map_style_default"); break;
|
||||
case MWMThemeVehicleNight: NSAssert(false, @"Invalid case");
|
||||
case MWMThemeNight: nightMode = L(@"pref_map_style_night"); break;
|
||||
case MWMThemeAuto: nightMode = L(@"pref_map_style_auto"); break;
|
||||
- (void)configNavigationSection {
|
||||
NSString *nightMode = nil;
|
||||
switch ([MWMSettings theme]) {
|
||||
case MWMThemeVehicleDay:
|
||||
NSAssert(false, @"Invalid case");
|
||||
case MWMThemeDay:
|
||||
nightMode = L(@"pref_map_style_default");
|
||||
break;
|
||||
case MWMThemeVehicleNight:
|
||||
NSAssert(false, @"Invalid case");
|
||||
case MWMThemeNight:
|
||||
nightMode = L(@"pref_map_style_night");
|
||||
break;
|
||||
case MWMThemeAuto:
|
||||
nightMode = L(@"pref_map_style_auto");
|
||||
break;
|
||||
}
|
||||
[self.nightModeCell configWithTitle:L(@"pref_map_style_title") info:nightMode];
|
||||
|
||||
bool _ = true, on = true;
|
||||
auto & f = GetFramework();
|
||||
auto &f = GetFramework();
|
||||
f.Load3dMode(on, _);
|
||||
[self.perspectiveViewCell configWithDelegate:self title:L(@"pref_map_3d_title") isOn:on];
|
||||
|
||||
[self.autoZoomCell configWithDelegate:self
|
||||
title:L(@"pref_map_auto_zoom")
|
||||
isOn:GetFramework().LoadAutoZoom()];
|
||||
[self.autoZoomCell configWithDelegate:self title:L(@"pref_map_auto_zoom") isOn:GetFramework().LoadAutoZoom()];
|
||||
|
||||
NSString * ttsEnabledString = [MWMTextToSpeech isTTSEnabled] ? L(@"on") : L(@"off");
|
||||
NSString *ttsEnabledString = [MWMTextToSpeech isTTSEnabled] ? L(@"on") : L(@"off");
|
||||
[self.voiceInstructionsCell configWithTitle:L(@"pref_tts_enable_title") info:ttsEnabledString];
|
||||
[self.drivingOptionsCell configWithTitle:L(@"driving_options_title") info:@""];
|
||||
}
|
||||
|
||||
- (void)configInfoSection
|
||||
{
|
||||
- (void)configInfoSection {
|
||||
[self.helpCell configWithTitle:L(@"help") info:nil];
|
||||
[self.aboutCell configWithTitle:L(@"about_menu_title") info:nil];
|
||||
}
|
||||
|
||||
- (void)showRemoveAds
|
||||
{
|
||||
- (void)showRemoveAds {
|
||||
auto removeAds = [[RemoveAdsViewController alloc] init];
|
||||
removeAds.delegate = self;
|
||||
[self.navigationController presentViewController:removeAds animated:YES completion:nil];
|
||||
|
@ -215,88 +222,60 @@ using namespace power_management;
|
|||
|
||||
#pragma mark - SettingsTableViewSwitchCellDelegate
|
||||
|
||||
- (void)switchCell:(SettingsTableViewSwitchCell *)cell didChangeValue:(BOOL)value
|
||||
{
|
||||
if (cell == self.zoomButtonsCell)
|
||||
{
|
||||
- (void)switchCell:(SettingsTableViewSwitchCell *)cell didChangeValue:(BOOL)value {
|
||||
if (cell == self.zoomButtonsCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatToggleZoomButtonsVisibility)
|
||||
withParameters:@{kStatValue : (value ? kStatVisible : kStatHidden)}];
|
||||
withParameters:@{kStatValue: (value ? kStatVisible : kStatHidden)}];
|
||||
[MWMSettings setZoomButtonsEnabled:value];
|
||||
}
|
||||
else if (cell == self.is3dCell)
|
||||
{
|
||||
} else if (cell == self.is3dCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStat3DBuildings)
|
||||
withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
auto & f = GetFramework();
|
||||
withParameters:@{kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
auto &f = GetFramework();
|
||||
bool _ = true, is3dBuildings = true;
|
||||
f.Load3dMode(_, is3dBuildings);
|
||||
is3dBuildings = static_cast<bool>(value);
|
||||
f.Save3dMode(_, is3dBuildings);
|
||||
f.Allow3dMode(_, is3dBuildings);
|
||||
}
|
||||
else if (cell == self.autoDownloadCell)
|
||||
{
|
||||
} else if (cell == self.autoDownloadCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatAutoDownload)
|
||||
withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
withParameters:@{kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
[MWMSettings setAutoDownloadEnabled:value];
|
||||
}
|
||||
else if (cell == self.backupBookmarksCell)
|
||||
{
|
||||
[Statistics logEvent:kStatSettingsBookmarksSyncToggle
|
||||
withParameters:@{
|
||||
kStatState: (value ? @1 : @0)
|
||||
}];
|
||||
} else if (cell == self.backupBookmarksCell) {
|
||||
[Statistics logEvent:kStatSettingsBookmarksSyncToggle withParameters:@{kStatState: (value ? @1 : @0)}];
|
||||
[[MWMBookmarksManager sharedManager] setCloudEnabled:value];
|
||||
}
|
||||
else if (cell == self.fontScaleCell)
|
||||
{
|
||||
} else if (cell == self.fontScaleCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatToggleLargeFontSize)
|
||||
withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
withParameters:@{kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
[MWMSettings setLargeFontSize:value];
|
||||
}
|
||||
else if (cell == self.transliterationCell)
|
||||
{
|
||||
} else if (cell == self.transliterationCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatToggleTransliteration)
|
||||
withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
withParameters:@{kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
[MWMSettings setTransliteration:value];
|
||||
}
|
||||
else if (cell == self.compassCalibrationCell)
|
||||
{
|
||||
} else if (cell == self.compassCalibrationCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatToggleCompassCalibration)
|
||||
withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
withParameters:@{kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
[MWMSettings setCompassCalibrationEnabled:value];
|
||||
}
|
||||
else if (cell == self.showOffersCell)
|
||||
{
|
||||
} else if (cell == self.showOffersCell) {
|
||||
[self showRemoveAds];
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatAd)
|
||||
withParameters:@{kStatAction : kStatAd, kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
}
|
||||
else if (cell == self.statisticsCell)
|
||||
{
|
||||
withParameters:@{kStatAction: kStatAd, kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
} else if (cell == self.statisticsCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatToggleStatistics)
|
||||
withParameters:@{
|
||||
kStatAction : kStatToggleStatistics,
|
||||
kStatValue : (value ? kStatOn : kStatOff)
|
||||
}];
|
||||
withParameters:@{kStatAction: kStatToggleStatistics, kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
[MWMSettings setStatisticsEnabled:value];
|
||||
}
|
||||
else if (cell == self.perspectiveViewCell)
|
||||
{
|
||||
} else if (cell == self.perspectiveViewCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStat3D)
|
||||
withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}];
|
||||
auto & f = GetFramework();
|
||||
withParameters:@{kStatValue: (value ? kStatOn : kStatOff)}];
|
||||
auto &f = GetFramework();
|
||||
bool _ = true, is3d = true;
|
||||
f.Load3dMode(is3d, _);
|
||||
is3d = static_cast<bool>(value);
|
||||
f.Save3dMode(is3d, _);
|
||||
f.Allow3dMode(is3d, _);
|
||||
}
|
||||
else if (cell == self.autoZoomCell)
|
||||
{
|
||||
} else if (cell == self.autoZoomCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatAutoZoom)
|
||||
withParameters:@{kStatValue : value ? kStatOn : kStatOff}];
|
||||
auto & f = GetFramework();
|
||||
withParameters:@{kStatValue: value ? kStatOn : kStatOff}];
|
||||
auto &f = GetFramework();
|
||||
f.AllowAutoZoom(value);
|
||||
f.SaveAutoZoom(value);
|
||||
}
|
||||
|
@ -304,85 +283,60 @@ using namespace power_management;
|
|||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
auto cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
if (cell == self.profileCell)
|
||||
{
|
||||
[Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName : kStatAuthorization}];
|
||||
if (cell == self.profileCell) {
|
||||
[Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName: kStatAuthorization}];
|
||||
[self performSegueWithIdentifier:@"SettingsToProfileSegue" sender:nil];
|
||||
}
|
||||
else if (cell == self.unitsCell)
|
||||
{
|
||||
} else if (cell == self.unitsCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatChangeMeasureUnits)
|
||||
withParameters:@{kStatAction : kStatChangeMeasureUnits}];
|
||||
withParameters:@{kStatAction: kStatChangeMeasureUnits}];
|
||||
[self performSegueWithIdentifier:@"SettingsToUnits" sender:nil];
|
||||
}
|
||||
else if (cell == self.mobileInternetCell)
|
||||
{
|
||||
} else if (cell == self.mobileInternetCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatMobileInternet)
|
||||
withParameters:@{kStatAction : kStatChangeMobileInternet}];
|
||||
withParameters:@{kStatAction: kStatChangeMobileInternet}];
|
||||
[self performSegueWithIdentifier:@"SettingsToMobileInternetSegue" sender:nil];
|
||||
}
|
||||
else if (cell == self.powerManagementCell)
|
||||
{
|
||||
} else if (cell == self.powerManagementCell) {
|
||||
[self performSegueWithIdentifier:@"SettingsToPowerManagementSegue" sender:nil];
|
||||
}
|
||||
else if (cell == self.recentTrackCell)
|
||||
{
|
||||
} else if (cell == self.recentTrackCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatRecentTrack)
|
||||
withParameters:@{kStatAction : kStatChangeRecentTrack}];
|
||||
withParameters:@{kStatAction: kStatChangeRecentTrack}];
|
||||
[self performSegueWithIdentifier:@"SettingsToRecentTrackSegue" sender:nil];
|
||||
}
|
||||
else if (cell == self.nightModeCell)
|
||||
{
|
||||
} else if (cell == self.nightModeCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatNightMode)
|
||||
withParameters:@{kStatAction : kStatChangeNightMode}];
|
||||
withParameters:@{kStatAction: kStatChangeNightMode}];
|
||||
[self performSegueWithIdentifier:@"SettingsToNightMode" sender:nil];
|
||||
}
|
||||
else if (cell == self.voiceInstructionsCell)
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatTTS)
|
||||
withParameters:@{kStatAction : kStatChangeLanguage}];
|
||||
} else if (cell == self.voiceInstructionsCell) {
|
||||
[Statistics logEvent:kStatEventName(kStatSettings, kStatTTS) withParameters:@{kStatAction: kStatChangeLanguage}];
|
||||
[self performSegueWithIdentifier:@"SettingsToTTSSegue" sender:nil];
|
||||
}
|
||||
else if (cell == self.drivingOptionsCell)
|
||||
{
|
||||
} else if (cell == self.drivingOptionsCell) {
|
||||
[self performSegueWithIdentifier:@"settingsToDrivingOptionsSegue" sender:nil];
|
||||
}
|
||||
else if (cell == self.helpCell)
|
||||
{
|
||||
[Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName : kStatHelp}];
|
||||
} else if (cell == self.helpCell) {
|
||||
[Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName: kStatHelp}];
|
||||
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"help"];
|
||||
[self performSegueWithIdentifier:@"SettingsToHelp" sender:nil];
|
||||
}
|
||||
else if (cell == self.aboutCell)
|
||||
{
|
||||
[Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName : kStatAbout}];
|
||||
} else if (cell == self.aboutCell) {
|
||||
[Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName: kStatAbout}];
|
||||
[self performSegueWithIdentifier:@"SettingsToAbout" sender:nil];
|
||||
}
|
||||
else if (cell == self.restoreSubscriptionCell)
|
||||
{
|
||||
} else if (cell == self.restoreSubscriptionCell) {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
__weak auto s = self;
|
||||
[self signupWithAnchor:self.restoreSubscriptionCell.progress source:AuthorizationSourceSubscription onComplete:^(BOOL success) {
|
||||
if (success) {
|
||||
[s restoreSubscription];
|
||||
}
|
||||
}];
|
||||
}
|
||||
else if (cell == self.manageSubscriptionsCell)
|
||||
{
|
||||
[self signupWithAnchor:self.restoreSubscriptionCell.progress
|
||||
source:AuthorizationSourceSubscription
|
||||
onComplete:^(BOOL success) {
|
||||
if (success) {
|
||||
[s restoreSubscription];
|
||||
}
|
||||
}];
|
||||
} else if (cell == self.manageSubscriptionsCell) {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
[UIApplication.sharedApplication
|
||||
openURL:[NSURL URLWithString:@"https://apps.apple.com/account/subscriptions"]
|
||||
options:@{}
|
||||
completionHandler:nil];
|
||||
[UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://apps.apple.com/account/subscriptions"]
|
||||
options:@{}
|
||||
completionHandler:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
auto cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
if (cell == self.restoreSubscriptionCell)
|
||||
return self.restoringSubscription ? nil : indexPath;
|
||||
|
@ -392,40 +346,42 @@ using namespace power_management;
|
|||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case 1: return L(@"general_settings");
|
||||
case 2: return L(@"subscriptions_title");
|
||||
case 3: return L(@"prefs_group_route");
|
||||
case 4: return L(@"info");
|
||||
default: return nil;
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
switch (section) {
|
||||
case 1:
|
||||
return L(@"general_settings");
|
||||
case 2:
|
||||
return L(@"subscriptions_title");
|
||||
case 3:
|
||||
return L(@"prefs_group_route");
|
||||
case 4:
|
||||
return L(@"info");
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case 1: return L(@"allow_statistics_hint");
|
||||
default: return nil;
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
|
||||
switch (section) {
|
||||
case 1:
|
||||
return L(@"allow_statistics_hint");
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - RemoveAdsViewControllerDelegate
|
||||
|
||||
- (void)didCompleteSubscribtion:(RemoveAdsViewController *)viewController
|
||||
{
|
||||
- (void)didCompleteSubscribtion:(RemoveAdsViewController *)viewController {
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
self.showOffersCell.isEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)didCancelSubscribtion:(RemoveAdsViewController *)viewController
|
||||
{
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:^{
|
||||
self.showOffersCell.isOn = YES;
|
||||
}];
|
||||
- (void)didCancelSubscribtion:(RemoveAdsViewController *)viewController {
|
||||
[self.navigationController dismissViewControllerAnimated:YES
|
||||
completion:^{
|
||||
self.showOffersCell.isOn = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - RestoreSubscription
|
||||
|
@ -440,7 +396,8 @@ using namespace power_management;
|
|||
self.restoringSubscription = NO;
|
||||
[self.restoreSubscriptionCell.progress stopAnimating];
|
||||
NSString *alertText;
|
||||
[[InAppPurchase adsRemovalSubscriptionManager] setSubscriptionActive: result == MWMValidationResultValid isTrial: isTrial];
|
||||
[[InAppPurchase adsRemovalSubscriptionManager] setSubscriptionActive:result == MWMValidationResultValid
|
||||
isTrial:isTrial];
|
||||
if (result == MWMValidationResultNotValid) {
|
||||
alertText = L(@"restore_no_subscription_alert");
|
||||
} else if (result == MWMValidationResultValid) {
|
||||
|
@ -448,8 +405,7 @@ using namespace power_management;
|
|||
} else {
|
||||
alertText = L(@"restore_error_alert");
|
||||
}
|
||||
[MWMAlertViewController.activeAlertController presentInfoAlert:L(@"restore_subscription")
|
||||
text:alertText];
|
||||
[MWMAlertViewController.activeAlertController presentInfoAlert:L(@"restore_subscription") text:alertText];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ extension SubscriptionInteractor: SubscriptionInteractorProtocol {
|
|||
viewController?.signup(anchor: anchor, source: .subscription) { [weak self] success in
|
||||
guard success else { return }
|
||||
self?.presenter.isLoadingHidden = false
|
||||
self?.subscriptionManager.restore { result, _ in
|
||||
self?.subscriptionManager.restore { result, _ in
|
||||
self?.presenter.isLoadingHidden = true
|
||||
let alertText: String
|
||||
switch result {
|
||||
|
|
Loading…
Add table
Reference in a new issue