diff --git a/MoppApp/MoppApp/LocalizationKeys.swift b/MoppApp/MoppApp/LocalizationKeys.swift
index e049054d7..d890cfc6e 100644
--- a/MoppApp/MoppApp/LocalizationKeys.swift
+++ b/MoppApp/MoppApp/LocalizationKeys.swift
@@ -169,6 +169,8 @@ enum LocKey : String
case nfcTitle = "nfc-title"
case nfcCANTitle = "nfc-can-title"
case nfcDeviceNoSupport = "nfc-device-no-support"
+ case nfcCanLocation = "nfc-can-location"
+ case nfcIncorrectLength = "nfc-incorrect-length"
case nfcHoldNear = "nfc-hold-near"
case nfcMultipleCards = "nfc-multiple-cards"
case nfcInvalidTag = "nfc-invalid-tag"
diff --git a/MoppApp/MoppApp/NFCEditViewController.swift b/MoppApp/MoppApp/NFCEditViewController.swift
index 1c0973b8a..8902dda47 100644
--- a/MoppApp/MoppApp/NFCEditViewController.swift
+++ b/MoppApp/MoppApp/NFCEditViewController.swift
@@ -35,7 +35,7 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var canTextLabel: UILabel!
@IBOutlet weak var pinTextLabel: UILabel!
- @IBOutlet weak var canTextErrorLabel: UILabel!
+ @IBOutlet weak var canTextInfoLabel: ScaledLabel!
@IBOutlet weak var pinTextErrorLabel: UILabel!
@IBOutlet weak var cancelButton: MoppButton!
@IBOutlet weak var signButton: MoppButton!
@@ -56,8 +56,8 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
pinTextLabel.text = L(.pin2TextfieldLabel)
pinTextLabel.isHidden = notAvailable
- canTextErrorLabel.text = ""
- canTextErrorLabel.isHidden = true
+ setCANDefaultText()
+
pinTextErrorLabel.text = ""
pinTextErrorLabel.isHidden = true
@@ -84,6 +84,20 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
tapGR.addTarget(self, action: #selector(cancelAction))
view.addGestureRecognizer(tapGR)
}
+
+ override func viewDidAppear(_ animated: Bool) {
+ super.viewDidAppear(animated)
+
+ if let canNumber = canTextField.text {
+ if !canNumber.isEmpty && canNumber.count != 6 {
+ setCANErrorText()
+ } else {
+ setCANDefaultText()
+ }
+ } else {
+ setCANDefaultText()
+ }
+ }
@objc func dismissKeyboard(_ notification: NSNotification) {
pinTextField.resignFirstResponder()
@@ -196,6 +210,18 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
override func keyboardWillHide(notification: NSNotification) {
hideKeyboard(scrollView: scrollView)
}
+
+ func setCANDefaultText() {
+ canTextInfoLabel.text = L(.nfcCanLocation)
+ canTextInfoLabel.isHidden = false
+ canTextInfoLabel.textColor = UIColor.moppText
+ }
+
+ func setCANErrorText() {
+ canTextInfoLabel.text = L(.nfcIncorrectLength)
+ canTextInfoLabel.isHidden = false
+ canTextInfoLabel.textColor = UIColor.moppError
+ }
}
extension NFCEditViewController : UITextFieldDelegate {
@@ -226,12 +252,17 @@ extension NFCEditViewController : UITextFieldDelegate {
func textFieldDidEndEditing(_ textField: UITextField) {
if textField.accessibilityIdentifier == "nfcCanField" {
if let can = textField.text {
+ if !can.isEmpty && can.count != 6 {
+ setCANErrorText()
+ } else {
+ setCANDefaultText()
+ }
do {
let symKey = try EncryptedDataUtil.getSymmetricKey(fileName: NFCEditViewController.nfcCANKeyFilename)
if let encryptedKey = EncryptedDataUtil.encryptSecret(can, with: symKey) {
_ = KeychainUtil.save(key: NFCEditViewController.nfcCANKey, info: encryptedKey, withPasscodeSetOnly: true)
} else {
- printLog("Encryption failed for 'can' string")
+ printLog("Encryption failed for 'CAN' string")
}
} catch {
do {
@@ -249,8 +280,7 @@ extension NFCEditViewController : UITextFieldDelegate {
}
} else {
KeychainUtil.remove(key: NFCEditViewController.nfcCANKey)
- canTextErrorLabel.text = ""
- canTextErrorLabel.isHidden = true
+ setCANDefaultText()
removeViewBorder(view: textField)
UIAccessibility.post(notification: .layoutChanged, argument: canTextField)
}
diff --git a/MoppApp/MoppApp/TokenFlow.storyboard b/MoppApp/MoppApp/TokenFlow.storyboard
index ca025fa8c..7b45bda3f 100644
--- a/MoppApp/MoppApp/TokenFlow.storyboard
+++ b/MoppApp/MoppApp/TokenFlow.storyboard
@@ -3,7 +3,7 @@
-
+
@@ -1418,7 +1418,7 @@
-
+
-
+
diff --git a/MoppApp/MoppApp/en.lproj/Localizable.strings b/MoppApp/MoppApp/en.lproj/Localizable.strings
index 59ce739dc..049b0fb18 100755
--- a/MoppApp/MoppApp/en.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/en.lproj/Localizable.strings
@@ -233,6 +233,8 @@
"nfc-title" = "Enter your ID-card access number and PIN2 code to sign with ID-card";
"nfc-can-title" = "ID-card access number";
"nfc-device-no-support" = "This device does not support NFC.";
+"nfc-can-location" = "The 6-digit access number of the ID card is located under the document photo";
+"nfc-incorrect-length" = "CAN-code must be 6 digits long";
"nfc-hold-near" = "Hold your phone near the ID-card";
"nfc-multiple-cards" = "More than 1 NFC tag is detected, please remove all NFC tags and try again";
"nfc-invalid-tag" = "Invalid NFC tag";
diff --git a/MoppApp/MoppApp/et.lproj/Localizable.strings b/MoppApp/MoppApp/et.lproj/Localizable.strings
index e0b428b5b..9809f74d3 100755
--- a/MoppApp/MoppApp/et.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/et.lproj/Localizable.strings
@@ -234,6 +234,8 @@
"nfc-title" = "ID-kaardiga allkirjastamiseks sisesta oma ID-kaardi ligipääsu number ja PIN2-kood";
"nfc-can-title" = "ID-kaardi ligipääsu number";
"nfc-device-no-support" = "See seade ei toeta NFC-d";
+"nfc-can-location" = "ID-kaardi 6-kohaline ligipääsu number asub dokumendi foto all";
+"nfc-incorrect-length" = "Ligipääsu number (CAN) peab olema 6-kohaline";
"nfc-hold-near" = "Hoidke ID-kaarti telefoni lähedal";
"nfc-multiple-cards" = "Rohkem kui 1 NFC märgis on tuvastatud, eemaldage kõik NFC-märgisega esemed ja proovige uuesti";
"nfc-invalid-tag" = "Kehtetu NFC-märgis";
diff --git a/MoppApp/MoppApp/ru.lproj/Localizable.strings b/MoppApp/MoppApp/ru.lproj/Localizable.strings
index 27848c134..5c738062c 100644
--- a/MoppApp/MoppApp/ru.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/ru.lproj/Localizable.strings
@@ -234,6 +234,8 @@
"nfc-title" = "Введите номер доступа к карте и PIN2-код для подписи с помощью ID-карты";
"nfc-can-title" = "Номер доступа к карте";
"nfc-device-no-support" = "Это устройство не поддерживает NFC";
+"nfc-can-location" = "6-значный номер находится под фотографией на документе";
+"nfc-incorrect-length" = "Номер доступа (CAN) должен состоять из %1$s-цифр";
"nfc-hold-near" = "Держите телефон рядом с ID-картой";
"nfc-multiple-cards" = "Обнаружено более одной NFC-метки, пожалуйста, удалите все NFC-метки и повторите попытку";
"nfc-invalid-tag" = "Недействительная NFC-метка";