Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show CAN info message #510

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions MoppApp/MoppApp/AlertUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ class AlertUtil {
return alert
}

static func messageAlertWithLinkAndActionButton(message: String?, okButtonTitle: String? = "OK", additionalInfoButtonTitle: String? = nil, actionButtonTitle: String? = nil, okButtonAction: ((UIAlertAction) -> Void)?, actionButtonAction: ((UIAlertAction) -> Void)? = nil) -> UIAlertController {
var messageNoLink: String? = message
if let messageText = message {
messageNoLink = messageText.removeFirstLinkFromMessage()
}
let okButton = okButtonTitle ?? L(.actionOk)
let alert = UIAlertController(title: messageNoLink, message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: actionButtonTitle, style: .destructive, handler: actionButtonAction))
if let linkInUrl: String = message?.getFirstLinkInMessage() {
if let alertActionUrl: UIAlertAction = UIAlertAction().getLinkAlert(title: additionalInfoButtonTitle, message: linkInUrl), !alertActionUrl.title.isNilOrEmpty {
alert.addAction(alertActionUrl)
}
}
alert.addAction(UIAlertAction(title: okButton, style: .default, handler: okButtonAction))

return alert
}

static func errorMessageDialog(_ notification: Notification, topViewController: UIViewController) {
guard let userInfo = notification.userInfo else { return }
let error = userInfo[kErrorKey] as? NSError
Expand Down
10 changes: 10 additions & 0 deletions MoppApp/MoppApp/DefaultsHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fileprivate let kProxySetting = "kProxySetting"
fileprivate let kProxyHost = "kProxyHost"
fileprivate let kProxyPort = "kProxyPort"
fileprivate let kProxyUsername = "kProxyUsername"
fileprivate let kNfcShowCanMessage = "kNfcShowCanMessage"

class DefaultsHelper
{
Expand Down Expand Up @@ -380,4 +381,13 @@ class DefaultsHelper
return UserDefaults.standard.value(forKey: kProxyUsername) as? String
}
}

class var nfcShowCanMessage: Bool {
set {
UserDefaults.standard.set(newValue, forKey: kNfcShowCanMessage)
}
get {
return UserDefaults.standard.bool(forKey: kNfcShowCanMessage)
}
}
}
2 changes: 1 addition & 1 deletion MoppApp/MoppApp/DiagnosticsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class DiagnosticsViewController: MoppViewController, UIDocumentPickerDelegate {
private func handleFileLoggingSwitchChanged() {
if oneTimeLoggingSwitch.isOn {
oneTimeLoggingSwitch.accessibilityUserInputLabels = [L(.voiceControlDisableLogGeneration)]
let messageAlert = AlertUtil.messageAlertWithLink(message: L(.diagnosticsRestartToActivateLogging), additionalInfoButtonTitle: L(.diagnosticsOneTimeLoggingReadMore)) { _ in
let messageAlert = AlertUtil.messageAlertWithLink(message: L(.diagnosticsRestartToActivateLogging), additionalInfoButtonTitle: L(.actionReadMore)) { _ in
FileLogUtil.enableLogging()
}
present(messageAlert, animated: true)
Expand Down
4 changes: 3 additions & 1 deletion MoppApp/MoppApp/LocalizationKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum LocKey : String
case actionDelete = "action-delete"
case actionSign = "action-sign"
case actionDecrypt = "action-decrypt"
case actionDialogDontShowAgain = "action-dialog-dont-show-again"
case fileImportTitle = "file-import-title"
case fileImportTitleAccessibility = "file-import-title-accessibility"
case addresseeImportTitle = "addressee-import-title"
Expand Down Expand Up @@ -187,6 +188,7 @@ enum LocKey : String
case nfcCertExpired = "nfc-cert-expired"
case nfcWrongPin1 = "nfc-wrong-pin1"
case nfcWrongPin2 = "nfc-wrong-pin2"
case nfcCanInfo = "nfc-can-info"
case containerSignTitle = "container-sign-title"
case containerEncryptionTitle = "container-encryption-title"
case containerDecryptionTitle = "container-decryption-title"
Expand Down Expand Up @@ -361,7 +363,7 @@ enum LocKey : String
case diagnosticsActivateOneTimeLogging = "diagnostics-activate-one-time-logging"
case diagnosticsSaveLog = "diagnostics-save-log"
case diagnosticsRestartToActivateLogging = "diagnostics-restart-to-active-logging"
case diagnosticsOneTimeLoggingReadMore = "diagnostics-one-time-logging-read-more"
case actionReadMore = "action-read-more"
case diagnosticsAppVersion = "diagnostics-app-version"
case diagnosticsIosVersion = "diagnostics-ios-version"
case diagnosticsLibrariesLabel = "diagnostics-libraries-label"
Expand Down
17 changes: 17 additions & 0 deletions MoppApp/MoppApp/NFCEditViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

let nfcSupported = NFCTagReaderSession.readingAvailable

if let canNumber = canTextField.text {
if !canNumber.isEmpty && canNumber.count != 6 {
setCANErrorText()
Expand All @@ -100,6 +102,21 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
} else {
setCANDefaultText()
}

if !DefaultsHelper.nfcShowCanMessage && nfcSupported {
let nfcCanInfoMessageAlert = AlertUtil.messageAlertWithLinkAndActionButton(
message: L(.nfcCanInfo),
additionalInfoButtonTitle: L(.actionReadMore),
actionButtonTitle: L(.actionDialogDontShowAgain),
okButtonAction: {_ in },
actionButtonAction: { _ in
DefaultsHelper.nfcShowCanMessage = true
})
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
guard let sself = self else { return }
sself.present(nfcCanInfoMessageAlert, animated: true)
}
}
}

@objc func dismissKeyboard(_ notification: NSNotification) {
Expand Down
6 changes: 5 additions & 1 deletion MoppApp/MoppApp/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
"action-delete" = "Remove";
"action-sign" = "Sign";
"action-decrypt" = "Decrypt";
"action-dialog-dont-show-again" = "Don't show again";
"action-read-more" = "Read more here";

// *** Signed containers ***

Expand Down Expand Up @@ -250,6 +252,7 @@
"nfc-cert-expired" = "An expired certificate cannot be used for signing";
"nfc-wrong-pin2" = "Wrong PIN2. Remaining attempts: %d";
"nfc-wrong-pin1" = "Wrong PIN1. Remaining attempts: %d";
"nfc-can-info" = "NFC signing uses the CAN number. NFC may lock up if CAN is entered incorrectly multiple times. https://www.id.ee/en/article/digital-signing-in-ria-digidoc-mobile-application/";
"role-and-address" = "Role and address";
"role-and-address-title" = "Enter your role and address info";
"role-and-address-role-title" = "Role / resolution";
Expand Down Expand Up @@ -351,6 +354,7 @@
"my-eid-wrong-code-message" = "Wrong %@ code. You can try 2 more times.";
"my-eid-wrong-code-message-singular" = "Wrong %@ code. You can try 1 more time.";
"my-eid-code-blocked-message" = "%1$@ has been blocked because %1$@ code has been entered incorrectly 3 times. Unblock to reuse %1$@.";

// *** My eID info bullets ***
"my-eid-info-bullet-same-codes-warning" = "New %1$@ must be different from current %1$@.";
"my-eid-info-bullet-auth-cert-info" = "PIN1 code is used for authentication.";
Expand All @@ -361,6 +365,7 @@
"my-eid-info-bullet-pin2-blocked-warning" = "If PIN2 is inserted incorrectly 3 times, the signing certificate will be blocked and it will be impossible to use ID-card for digital signatures, until it is unblocked via the PUK code.";
"my-eid-info-bullet-puk-unblock-info" = "PUK code is used for unblocking the certificates when PIN1 or PIN2 has been entered 3 times incorrectly.";
"my-eid-info-bullet-puk-blocked-warning" = "If you forget the PUK code or the certificates remain blocked, you have to visit the service center to obtain new codes.";

"my-eid-change-code-title" = "Change %@";
"my-eid-unblock-code-title" = "Unblock %@";
"my-eid-current-code-label" = "CURRENT %@ CODE";
Expand Down Expand Up @@ -424,7 +429,6 @@
"diagnostics-activate-one-time-logging" = "Enable one-time log generation";
"diagnostics-save-log" = "SAVE LOG";
"diagnostics-restart-to-active-logging" = "Restart RIA DigiDoc to activate logging. https://www.id.ee/en/article/log-file-generation-in-digidoc4-client/";
"diagnostics-one-time-logging-read-more" = "Read more here";
"diagnostics-app-version" = "Application version";
"diagnostics-ios-version" = "OS";
"diagnostics-libraries-label" = "Libraries:";
Expand Down
6 changes: 5 additions & 1 deletion MoppApp/MoppApp/et.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"action-delete" = "Eemalda";
"action-sign" = "Allkirjasta";
"action-decrypt" = "Dekrüpteeri";
"action-dialog-dont-show-again" = "Ära rohkem näita";
"action-read-more" = "Loe täpsemalt siit";

// *** Signed containers ***

Expand Down Expand Up @@ -251,6 +253,7 @@
"nfc-cert-expired" = "Aegunud sertifikaati ei saa kasutada allkirjastamiseks";
"nfc-wrong-pin2" = "Vale PIN2. Katseid jäänud: %d";
"nfc-wrong-pin1" = "Vale PIN1. Katseid jäänud: %d";
"nfc-can-info" = "NFC allkirjastamisel kasutatakse CAN numbrit. Mitmekordsel CANi valesti sisestamisel võib NFC lukustuda. https://www.id.ee/artikkel/digiallkirjastamine-ria-digidoc-mobiilirakenduses/";
"role-and-address" = "Roll ja aadress";
"role-and-address-title" = "Sisesta oma roll ja aadress";
"role-and-address-role-title" = "Roll / resolutsioon";
Expand Down Expand Up @@ -352,6 +355,7 @@
"my-eid-wrong-code-message" = "Vale %@-kood. Saad veel proovida 2 korda.";
"my-eid-wrong-code-message-singular" = "Vale %@-kood. Saad veel proovida 1 kord.";
"my-eid-code-blocked-message" = "%1$@ on blokeeritud, kuna %1$@-koodi on sisestatud 3 korda valesti. Tühista blokeering, et %1$@ taas kasutada.";

// *** My eID info bullets ***
"my-eid-info-bullet-same-codes-warning" = "Uus %@ peab olema erinev eelmisest.";
"my-eid-info-bullet-auth-cert-info" = "PIN1-koodi kasutatakse isikutuvastamiseks.";
Expand All @@ -362,6 +366,7 @@
"my-eid-info-bullet-pin2-blocked-warning" = "Kui sisestad PIN2-koodi kolm korda valesti, siis allkirjastamise sertifikaat blokeeritakse ning ID-kaarti pole võimalik allkirjastamiseks kasutada enne blokeeringu tühistamist PUK-koodi abil.";
"my-eid-info-bullet-puk-unblock-info" = "PUK-koodi abil saab tühistada sertifikaadi blokeeringu, kui PIN1- või PIN2-koodi on 3 korda järjest valesti sisestatud.";
"my-eid-info-bullet-puk-blocked-warning" = "Kui peale vahetamist PUK-kood ununeb ja sertifikaat jääb blokeerituks kolme vale PIN1 või PIN2 sisestamise järel, siis ainus võimalus ID-kaart jälle tööle saada on pöörduda klienditeeninduspunkti poole.";

"my-eid-change-code-title" = "%@-koodi vahetus";
"my-eid-unblock-code-title" = "%@ lahti blokeerimine";
"my-eid-current-code-label" = "KEHTIV %@-KOOD";
Expand Down Expand Up @@ -425,7 +430,6 @@
"diagnostics-activate-one-time-logging" = "Aktiveeri ühekordne logifaili genereerimine";
"diagnostics-save-log" = "SALVESTA LOGIFAIL";
"diagnostics-restart-to-active-logging" = "Logimise aktiveerimiseks taaskäivita RIA DigiDoc. https://www.id.ee/artikkel/logifaili-genereerimine-digidoc4-kliendis/";
"diagnostics-one-time-logging-read-more" = "Loe täpsemalt siit";
"diagnostics-app-version" = "Rakenduse versioon";
"diagnostics-ios-version" = "Operatsioonisüsteem";
"diagnostics-libraries-label" = "Teegid:";
Expand Down
6 changes: 5 additions & 1 deletion MoppApp/MoppApp/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
"action-delete" = "Удалить";
"action-sign" = "Подписать";
"action-decrypt" = "Дешифровать";
"action-dialog-dont-show-again" = "Больше не показывать";
"action-read-more" = "Подробнее читайте здесь";

// *** Signed containers ***

Expand Down Expand Up @@ -251,6 +253,7 @@
"nfc-cert-expired" = "Сертификат с истекшим сроком действия не может быть использован для подписи";
"nfc-wrong-pin2" = "Неверный PIN2-код. Оставшиеся попытки: %d";
"nfc-wrong-pin1" = "Неверный PIN1-код. Оставшиеся попытки: %d";
"nfc-can-info" = "При подписании через NFC используется номер CAN. NFC может заблокироваться, если CAN введен неправильно несколько раз. https://www.id.ee/ru/artikkel/czifrovoe-podpisanie-v-mobilnom-prilozhenii-ria-digidoc/";
"role-and-address" = "Роль и адрес";
"role-and-address-title" = "Введите свою роль и адрес";
"role-and-address-role-title" = "Роль / pезолюция";
Expand Down Expand Up @@ -352,6 +355,7 @@
"my-eid-wrong-code-message" = "Неверный %@-код. Вы можете попробовать ещё 2 раз.";
"my-eid-wrong-code-message-singular" = "Неверный %@-код. Вы можете попробовать ещё 1 раз.";
"my-eid-code-blocked-message" = "%1$@ заблокирован, потому что %1$@-код был введён неверно 3 раза. Разблокируйте, чтобы использовать %1$@.";

// *** My eID info bullets ***
"my-eid-info-bullet-same-codes-warning" = "Новый %1$@ должен отличаться от предыдущего %1$@.";
"my-eid-info-bullet-auth-cert-info" = "PIN1-код используется для идентификации.";
Expand All @@ -362,6 +366,7 @@
"my-eid-info-bullet-pin2-blocked-warning" = "Если PIN2 введён 3 раза неверно, тогда блокируется сертификат цифровой подписи и использовать ID-карту для цифровой подписи невозможно, пока блокировка не снята PUK-кодом.";
"my-eid-info-bullet-puk-unblock-info" = "PUK-код используется для разблокирования сертификатов, когда PIN1 или PIN2 были неверно введены 3 раза.";
"my-eid-info-bullet-puk-blocked-warning" = "Если Вы забудете PUK-код или сертификаты остануться заблокированными, необходимо посетить центр обслуживания для получения новых кодов.";

"my-eid-change-code-title" = "Изменить %@";
"my-eid-unblock-code-title" = "Разблокировать %@";
"my-eid-current-code-label" = "ДЕЙСТВУЮЩИЙ %@-КОД";
Expand Down Expand Up @@ -425,7 +430,6 @@
"diagnostics-activate-one-time-logging" = "Активировать одноразовое создание лог-файла";
"diagnostics-save-log" = "СОХРАНИТЬ ЛОГ-ФАЙЛ";
"diagnostics-restart-to-active-logging" = "Перезапустите RIA DigiDoc, чтобы активировать ведение журнала. https://www.id.ee/ru/artikkel/generirovanie-log-fajla-v-kliente-digidoc4/";
"diagnostics-one-time-logging-read-more" = "Подробнее читайте здесь";
"diagnostics-app-version" = "Версия приложения";
"diagnostics-ios-version" = "Операционная система";
"diagnostics-libraries-label" = "Библиотеки:";
Expand Down