From 3309fd747fd49c1ce9374b601a9ffd422f93fa25 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 9 Apr 2019 11:16:15 +0200 Subject: [PATCH] Lock donation controller if no payment method --- .../Scenes/Organizer/OrganizerViewController.swift | 10 ++++++++++ Passepartout/Resources/en.lproj/Localizable.strings | 1 + Passepartout/Resources/it.lproj/Localizable.strings | 1 + Passepartout/Sources/SwiftGen+Strings.swift | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 27da909b..88852c25 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import StoreKit import MessageUI import Passepartout_Core @@ -193,6 +194,15 @@ class OrganizerViewController: UITableViewController, TableModelHost { } private func donateToDeveloper() { + guard SKPaymentQueue.canMakePayments() else { + let alert = Macros.alert( + L10n.Organizer.Cells.Donate.caption, + L10n.Organizer.Alerts.CannotDonate.message + ) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + return + } perform(segue: StoryboardSegue.Organizer.donateSegueIdentifier, sender: nil) } diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 9469add6..1b952a3f 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -55,6 +55,7 @@ "organizer.cells.uninstall.caption" = "Remove VPN configuration"; "organizer.alerts.exhausted_providers.message" = "You have created profiles for any available provider."; "organizer.alerts.add_host.message" = "Open an URL to an .ovpn configuration file from Safari, Mail or another app to set up a host profile.\n\nYou can also import an .ovpn with iTunes File Sharing."; +"organizer.alerts.cannot_donate.message" = "There is no payment method configured on this device."; "organizer.alerts.delete_vpn_profile.message" = "Do you really want to erase the VPN configuration from your device settings? This may fix some broken VPN states and will not affect your provider and host profiles."; "wizards.host.cells.title_input.caption" = "Title"; diff --git a/Passepartout/Resources/it.lproj/Localizable.strings b/Passepartout/Resources/it.lproj/Localizable.strings index 0d7b3513..ed5be6be 100644 --- a/Passepartout/Resources/it.lproj/Localizable.strings +++ b/Passepartout/Resources/it.lproj/Localizable.strings @@ -55,6 +55,7 @@ "organizer.cells.uninstall.caption" = "Rimuovi configurazione VPN"; "organizer.alerts.exhausted_providers.message" = "Hai creato profili per tutti i provider disponibili."; "organizer.alerts.add_host.message" = "Apri l'URL di un file di configurazione .ovpn da Safari, Mail o da un'altra app per configurare un host.\n\nPuoi anche importare un file .ovpn con iTunes File Sharing."; +"organizer.alerts.cannot_donate.message" = "Nessun metodo di pagamento configurato su questo dispositivo."; "organizer.alerts.delete_vpn_profile.message" = "Vuoi veramente cancellare la configurazione VPN dalle impostazioni del tuo dispositivo? Quest'azione potrebbe risolvere alcuni stati erronei della VPN e non altererà i tuoi provider e i tuoi host."; "wizards.host.cells.title_input.caption" = "Titolo"; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 2012db18..b2bd6a0a 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -407,6 +407,10 @@ public enum L10n { /// Open an URL to an .ovpn configuration file from Safari, Mail or another app to set up a host profile.\n\nYou can also import an .ovpn with iTunes File Sharing. public static let message = L10n.tr("Localizable", "organizer.alerts.add_host.message") } + public enum CannotDonate { + /// There is no payment method configured on this device. + public static let message = L10n.tr("Localizable", "organizer.alerts.cannot_donate.message") + } public enum DeleteVpnProfile { /// Do you really want to erase the VPN configuration from your device settings? This may fix some broken VPN states and will not affect your provider and host profiles. public static let message = L10n.tr("Localizable", "organizer.alerts.delete_vpn_profile.message")