diff --git a/PasscodeLock.xcodeproj/project.pbxproj b/PasscodeLock.xcodeproj/project.pbxproj index 64d9b76c..eec2906d 100644 --- a/PasscodeLock.xcodeproj/project.pbxproj +++ b/PasscodeLock.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 281AA9201DB626E000908E23 /* Localize.strings in Resources */ = {isa = PBXBuildFile; fileRef = 281AA9221DB626E000908E23 /* Localize.strings */; }; + 4A57CCF92010A437006A7B80 /* Localize.strings in Resources */ = {isa = PBXBuildFile; fileRef = 281AA9221DB626E000908E23 /* Localize.strings */; }; 8F3B9D031E028815008CF18F /* PasscodeLockImages.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F3B9D021E028815008CF18F /* PasscodeLockImages.xcassets */; }; C99EAF431B90B05700D61E1B /* PasscodeLock.h in Headers */ = {isa = PBXBuildFile; fileRef = C99EAF421B90B05700D61E1B /* PasscodeLock.h */; settings = {ATTRIBUTES = (Public, ); }; }; C99EAF4A1B90B05800D61E1B /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; }; @@ -516,6 +517,7 @@ C9D3DF1D1B91AD11008561EB /* LaunchScreen.storyboard in Resources */, C9D3DF1A1B91AD11008561EB /* Assets.xcassets in Resources */, C9D3DF181B91AD11008561EB /* Main.storyboard in Resources */, + 4A57CCF92010A437006A7B80 /* Localize.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PasscodeLock/Base.lproj/Localize.strings b/PasscodeLock/Base.lproj/Localize.strings index 25926802..1c83f62c 100644 --- a/PasscodeLock/Base.lproj/Localize.strings +++ b/PasscodeLock/Base.lproj/Localize.strings @@ -35,3 +35,4 @@ "Cancel" = "Cancel"; "Delete" = "Delete"; "UseTouchId" = "Use TouchID"; +"UseFaceId" = "Use FaceID"; diff --git a/PasscodeLock/Functions.swift b/PasscodeLock/Functions.swift index 48fec1bd..c7ba7509 100644 --- a/PasscodeLock/Functions.swift +++ b/PasscodeLock/Functions.swift @@ -13,8 +13,8 @@ func localizedStringFor(_ key: String, comment: String) -> String { let name = "Localize" let bundle = bundleForResource(name, ofType: "strings") - - return NSLocalizedString(key, tableName: name, bundle: bundle, comment: comment) + + return NSLocalizedString(key, tableName: name, bundle: bundle, value: "", comment: comment) } func bundleForResource(_ name: String, ofType type: String) -> Bundle { diff --git a/PasscodeLock/PasscodeLockPresenter.swift b/PasscodeLock/PasscodeLockPresenter.swift index 5ecbd8e3..cb7018a2 100644 --- a/PasscodeLock/PasscodeLockPresenter.swift +++ b/PasscodeLock/PasscodeLockPresenter.swift @@ -27,8 +27,9 @@ public struct StringsToBeDisplayed { public var cancel: String? public var delete: String? public var useTouchID: String? + public var useFaceID: String? - public init(passcodeLockEnterTitle: String?, passcodeLockEnterDescription: String?, passcodeLockSetTitle: String?, passcodeLockSetDescription: String?, passcodeLockConfirmTitle: String?, passcodeLockConfirmDescription: String?, passcodeLockChangeTitle: String?, passcodeLockChangeDescription: String?, passcodeLockMismatchTitle: String?, passcodeLockMismatchDescription: String?, passcodeLockTouchIDReason: String?, passcodeLockTouchIDButton: String?, cancel: String?, delete: String?, useTouchID: String?) { + public init(passcodeLockEnterTitle: String?, passcodeLockEnterDescription: String?, passcodeLockSetTitle: String?, passcodeLockSetDescription: String?, passcodeLockConfirmTitle: String?, passcodeLockConfirmDescription: String?, passcodeLockChangeTitle: String?, passcodeLockChangeDescription: String?, passcodeLockMismatchTitle: String?, passcodeLockMismatchDescription: String?, passcodeLockTouchIDReason: String?, passcodeLockTouchIDButton: String?, cancel: String?, delete: String?, useTouchID: String?, useFaceID: String?) { self.passcodeLockEnterTitle = passcodeLockEnterTitle self.passcodeLockEnterDescription = passcodeLockEnterDescription @@ -45,6 +46,7 @@ public struct StringsToBeDisplayed { self.cancel = cancel self.delete = delete self.useTouchID = useTouchID + self.useFaceID = useFaceID } } diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index 63117e3a..7fdf570b 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import LocalAuthentication open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegate { @@ -111,22 +112,34 @@ open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegat } } - internal func updatePasscodeView() { + internal func updatePasscodeView() { self.customImageView?.image = self.customImage - self.titleLabel?.text = passcodeLock.state.title + self.titleLabel?.text = passcodeLock.state.title self.titleLabel?.font = self.font self.titleLabel?.textColor = self.customTintColor - self.descriptionLabel?.text = passcodeLock.state.description - self.touchIDButton?.isHidden = !passcodeLock.isTouchIDAllowed - self.touchIDButton?.setTitle((self.stringsToShow?.useTouchID ?? localizedStringFor("UseTouchId", comment: "")), for: UIControlState()) - self.touchIDButton?.setTitleColor(self.customTintColor, for: UIControlState()) + self.descriptionLabel?.text = passcodeLock.state.description + self.touchIDButton?.isHidden = !passcodeLock.isTouchIDAllowed + + var useBiometrics: String = localizedStringFor("UseTouchId", comment: "") + var useBiomatricsToShow: String? = self.stringsToShow?.useTouchID + if #available(iOS 11.0, *) { + let context = LAContext() + context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) + let bioType = context.biometryType + if (bioType == .faceID) { + useBiometrics = localizedStringFor("UseFaceId", comment: "") + useBiomatricsToShow = self.stringsToShow?.useFaceID + } + } + + self.touchIDButton?.setTitle((useBiomatricsToShow ?? useBiometrics), for: UIControlState()) self.passcodeButtons?.forEach({ (passcodeButton: PasscodeSignButton) in passcodeButton.tintColor = self.customTintColor }) self.cancelDeleteButtonSetup() - } + } // MARK: - Events diff --git a/PasscodeLock/Views/PasscodeLockView.xib b/PasscodeLock/Views/PasscodeLockView.xib index 694aaf33..339d3782 100644 --- a/PasscodeLock/Views/PasscodeLockView.xib +++ b/PasscodeLock/Views/PasscodeLockView.xib @@ -1,5 +1,5 @@ - + @@ -328,23 +328,33 @@ - + + + + + + + + + + + @@ -355,7 +365,7 @@ - + @@ -387,10 +397,10 @@ + - @@ -402,6 +412,7 @@ + diff --git a/PasscodeLock/de.lproj/Localize.strings b/PasscodeLock/de.lproj/Localize.strings index d0d12f90..a5f13fae 100644 --- a/PasscodeLock/de.lproj/Localize.strings +++ b/PasscodeLock/de.lproj/Localize.strings @@ -35,3 +35,4 @@ "Cancel" = "Abbrechen"; "Delete" = "Löschen"; "UseTouchId" = "TouchID verwenden"; +"UseFaceId" = "FaceID verwenden"; diff --git a/PasscodeLock/en.lproj/Localize.strings b/PasscodeLock/en.lproj/Localize.strings new file mode 100644 index 00000000..1c83f62c --- /dev/null +++ b/PasscodeLock/en.lproj/Localize.strings @@ -0,0 +1,38 @@ +/* + Localize.strings + PasscodeLock + + Created by Ramiro Ramirez on 18/10/16. + Copyright © 2016 Yanko Dimitrov. All rights reserved. +*/ + +/* Enter Passcode State */ +"PasscodeLockEnterTitle" = "Enter Passcode"; +"PasscodeLockEnterDescription" = "Enter your passcode to proceed."; + +/* Set Passcode State */ +"PasscodeLockSetTitle" = "Enter a Passcode"; +"PasscodeLockSetDescription" = "Choose your passcode."; + +/* Confirm Passcode State */ +"PasscodeLockConfirmTitle" = "Confirm Passcode"; +"PasscodeLockConfirmDescription" = "Enter the passcode again."; + +/* Change Passcode State */ +"PasscodeLockChangeTitle" = "Enter Old Passcode"; +"PasscodeLockChangeDescription" = "Enter your old passcode."; + +/* Passcode Mismatch State */ +"PasscodeLockMismatchTitle" = "Try again"; +"PasscodeLockMismatchDescription" = "Passcodes didn\'t match."; + +/* Touch ID Reason */ +"PasscodeLockTouchIDReason" = "Authentication required to proceed"; + +/* Touch ID Fallback Button */ +"PasscodeLockTouchIDButton" = "Enter Passcode"; + +"Cancel" = "Cancel"; +"Delete" = "Delete"; +"UseTouchId" = "Use TouchID"; +"UseFaceId" = "Use FaceID";