From b564fe15c2b9d66c6e33a512388148c1aedb4d6d Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 8 Oct 2020 17:45:18 +0200 Subject: [PATCH] Implemented setting device specific biometric authentication type --- .../BankingiOSApp/Base.lproj/Localizable.strings | 2 +- .../Security/AuthenticationService.swift | 9 +++++++++ .../BankingiOSApp/de.lproj/Localizable.strings | 4 ++-- .../BankingiOSApp/ui/dialogs/AddAccountDialog.swift | 2 +- .../ui/dialogs/ProtectAppSettingsDialog.swift | 13 ++++--------- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index 7f1282cf..724d4751 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -82,7 +82,7 @@ "Error message from your bank %@" = "Error message from your bank:\n\n%@"; "Secure data?" = "Secure data?"; -"Secure data with?" = "Adding account was successful.\n\nDo you want to secure your data and login passwords by password, TouchID or FaceID (if available)?\n\nYou can also do this later in the settings."; +"Secure data with password or %@?" = "Successfully added account.\n\nYour data gets stored encrypted. Do you additionally want to secure your data by password or %@?\n\nYou can also do this later in the settings."; /* AccountTransactionsDialog */ diff --git a/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift b/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift index 78aa4b02..b17a1f3a 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift +++ b/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift @@ -58,6 +58,15 @@ class AuthenticationService { return biometricAuthenticationService.isTouchIDSupported } + var supportedBiometricAuthenticationLocalizedName: String { + if deviceSupportsTouchID { + return "TouchID".localize() + } + else { + return "FaceID".localize() + } + } + func setAuthenticationMethodToPassword(_ newPassword: String) { setAuthenticationType(.password) diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index 3a17d758..58e01fe9 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -81,8 +81,8 @@ "Could not add account" = "Konto konnte nicht hinzugefügt werden."; "Error message from your bank %@" = "Fehlermeldung Ihrer Bank:\n\n%@"; -"Secure data?" = "Daten schützen?"; -"Secure data with?" = "Hinuzufügen war erfolgreich.\n\nMöchten Sie Ihre Daten und Anmeldekennwörter durch Passwort, TouchID oder FaceID (falls vorhanden) schützen?\n\nSie können dies auch später in den Einstellungen vornehmen."; +"Secure data?" = "Appzugang schützen?"; +"Secure data with password or %@?" = "Konto erfolgreich hinzugefügt.\n\nIhre Daten werden verschlüsselt gespeichert. Möchten Sie zusätzlich den Appzugang durch Passwort oder %@ schützen?\n\nSie können dies auch später in den Einstellungen vornehmen."; /* AccountTransactionsDialog */ diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift index fd3e61a6..1f797ba2 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift @@ -110,7 +110,7 @@ struct AddAccountDialog: View { let authenticationService = AuthenticationService() if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none { - UIAlert("Secure data?", "Secure data with?", + UIAlert("Secure data?", "Secure data with password or %@?".localize(authenticationService.supportedBiometricAuthenticationLocalizedName), UIAlertAction.default("Yes") { SceneDelegate.navigateToView(ProtectAppSettingsDialog()) }, UIAlertAction.cancel("Later", self.closeDialog)) .show() diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/ProtectAppSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/ProtectAppSettingsDialog.swift index 85c71e6a..edae3a12 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/ProtectAppSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/ProtectAppSettingsDialog.swift @@ -144,7 +144,7 @@ struct ProtectAppSettingsDialog: View { private func getAuthenticationTypeLabel(_ type: AuthenticationType) -> LocalizedStringKey { switch type { case .biometric: - return LocalizedStringKey(supportedBiometricAuthenticationTitle) + return LocalizedStringKey(supportedBiometricAuthenticationLocalizedName) case .password: return "Password" default: @@ -152,13 +152,8 @@ struct ProtectAppSettingsDialog: View { } } - private var supportedBiometricAuthenticationTitle: String { - if authenticationService.deviceSupportsTouchID { - return "TouchID" - } - else { - return "FaceID" - } + private var supportedBiometricAuthenticationLocalizedName: String { + return authenticationService.supportedBiometricAuthenticationLocalizedName } private func selectedAuthenticationTypeChanged(_ type: AuthenticationType) { @@ -188,7 +183,7 @@ struct ProtectAppSettingsDialog: View { } private func doBiometricAuthentication() { - authenticationService.authenticateUserWithBiometric("Authenticate to encrypt data with %@".localize(supportedBiometricAuthenticationTitle.localize())) { success, errorMessage in + authenticationService.authenticateUserWithBiometric("Authenticate to encrypt data with %@".localize(supportedBiometricAuthenticationLocalizedName)) { success, errorMessage in self.successfullyAuthenticatedWithBiometricAuthentication = success } }