diff --git a/Signal/src/Loki/SeedViewController.swift b/Signal/src/Loki/SeedViewController.swift index 57f51e579..311eaba18 100644 --- a/Signal/src/Loki/SeedViewController.swift +++ b/Signal/src/Loki/SeedViewController.swift @@ -7,15 +7,15 @@ final class SeedViewController : OnboardingBaseViewController { // MARK: Components private lazy var registerStackView: UIStackView = { - let result = UIStackView(arrangedSubviews: [ explanationLabel, UIView.spacer(withHeight: 32), mnemonicLabel, UIView.spacer(withHeight: 24), copyButton, UIView.spacer(withHeight: 8), restoreButton ]) + let result = UIStackView(arrangedSubviews: [ explanationLabel1, UIView.spacer(withHeight: 32), mnemonicLabel, UIView.spacer(withHeight: 24), copyButton, UIView.spacer(withHeight: 8), restoreButton ]) result.accessibilityIdentifier = "onboarding.keyPairStep.registerStackView" result.axis = .vertical return result }() - private lazy var explanationLabel: UILabel = { + private lazy var explanationLabel1: UILabel = { let result = createExplanationLabel(text: NSLocalizedString("Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device.", comment: "")) - result.accessibilityIdentifier = "onboarding.keyPairStep.explanationLabel" + result.accessibilityIdentifier = "onboarding.keyPairStep.explanationLabel1" result.textColor = Theme.primaryColor var fontTraits = result.font.fontDescriptor.symbolicTraits fontTraits.insert(.traitBold) @@ -41,26 +41,42 @@ final class SeedViewController : OnboardingBaseViewController { }() private lazy var restoreButton: OWSFlatButton = { - let result = createLinkButton(title: NSLocalizedString("Restore Using Mnemonic", comment: ""), selector: #selector(switchMode)) + let result = createLinkButton(title: NSLocalizedString("Restore Using Seed", comment: ""), selector: #selector(switchMode)) result.accessibilityIdentifier = "onboarding.keyPairStep.restoreButton" result.setBackgroundColors(upColor: .clear, downColor: .clear) return result }() + private lazy var errorLabelSpacer: UIView = { + let result = UIView.spacer(withHeight: 32) + result.isHidden = true + return result + }() + private lazy var restoreStackView: UIStackView = { - let result = UIStackView(arrangedSubviews: [ errorLabel, UIView.spacer(withHeight: 32), mnemonicTextField, UIView.spacer(withHeight: 24), registerButton ]) + let result = UIStackView(arrangedSubviews: [ explanationLabel2, UIView.spacer(withHeight: 32), errorLabel, errorLabelSpacer, mnemonicTextField, UIView.spacer(withHeight: 24), registerButton ]) result.accessibilityIdentifier = "onboarding.keyPairStep.restoreStackView" result.axis = .vertical return result }() + private lazy var explanationLabel2: UILabel = { + let result = createExplanationLabel(text: NSLocalizedString("Restore your account by entering your seed below.", comment: "")) + result.accessibilityIdentifier = "onboarding.keyPairStep.explanationLabel2" + result.textColor = Theme.primaryColor + var fontTraits = result.font.fontDescriptor.symbolicTraits + fontTraits.insert(.traitBold) + result.font = UIFont(descriptor: result.font.fontDescriptor.withSymbolicTraits(fontTraits)!, size: result.font.pointSize) + return result + }() + private lazy var errorLabel: UILabel = { let result = createExplanationLabel(text: "") result.accessibilityIdentifier = "onboarding.keyPairStep.errorLabel" result.textColor = UIColor.red var fontTraits = result.font.fontDescriptor.symbolicTraits fontTraits.insert(.traitBold) - result.font = UIFont(descriptor: result.font.fontDescriptor.withSymbolicTraits(fontTraits)!, size: result.font.pointSize) + result.font = UIFont(descriptor: result.font.fontDescriptor.withSymbolicTraits(fontTraits)!, size: 12) return result }() @@ -69,7 +85,7 @@ final class SeedViewController : OnboardingBaseViewController { result.textColor = Theme.primaryColor result.font = UIFont.ows_dynamicTypeBodyClamped result.textAlignment = .center - let placeholder = NSMutableAttributedString(string: NSLocalizedString("Enter Your Mnemonic", comment: "")) + let placeholder = NSMutableAttributedString(string: NSLocalizedString("Enter Your Seed", comment: "")) placeholder.addAttribute(.foregroundColor, value: Theme.placeholderColor, range: NSRange(location: 0, length: placeholder.length)) result.attributedPlaceholder = placeholder result.tintColor = UIColor.lokiGreen() @@ -200,6 +216,7 @@ final class SeedViewController : OnboardingBaseViewController { seed = Data(hex: hexEncodedSeed) } catch let error { let error = error as? Mnemonic.DecodingError ?? Mnemonic.DecodingError.generic + errorLabelSpacer.isHidden = false return errorLabel.text = error.errorDescription } } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index f969fdb60..150922ec5 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2552,18 +2552,19 @@ "Password (Optional)" = "Password (Optional)"; "Next" = "Next"; "Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device." = "Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device."; +"Restore your account by entering your seed below." = "Restore your account by entering your seed below."; "Copy" = "Copy"; "Copied ✓" = "Copied ✓"; -"Restore Using Mnemonic" = "Restore Using Mnemonic"; +"Restore Using Seed" = "Restore Using Seed"; "Register" = "Register"; -"Enter Your Mnemonic" = "Enter Your Mnemonic"; +"Enter Your Seed" = "Enter Your Seed"; "Register a New Account" = "Register a New Account"; "Restore" = "Restore"; -"Something went wrong. Please check your mnemonic and try again." = "Something went wrong. Please check your mnemonic and try again."; -"Looks like you didn't enter enough words. Please check your mnemonic and try again." = "Looks like you didn't enter enough words. Please check your mnemonic and try again."; -"You seem to be missing the last word of your mnemonic. Please check what you entered and try again." = "You seem to be missing the last word of your mnemonic. Please check what you entered and try again."; -"There appears to be an invalid word in your mnemonic. Please check what you entered and try again." = "There appears to be an invalid word in your mnemonic. Please check what you entered and try again."; -"Your mnemonic couldn't be verified. Please check what you entered and try again." = "Your mnemonic couldn't be verified. Please check what you entered and try again."; +"Something went wrong. Please check your seed and try again." = "Something went wrong. Please check your seed and try again."; +"Looks like you didn't enter enough words. Please check your seed and try again." = "Looks like you didn't enter enough words. Please check your seed and try again."; +"You seem to be missing the last word of your seed. Please check what you entered and try again." = "You seem to be missing the last word of your seed. Please check what you entered and try again."; +"There appears to be an invalid word in your seed. Please check what you entered and try again." = "There appears to be an invalid word in your seed. Please check what you entered and try again."; +"Your seed couldn't be verified. Please check what you entered and try again." = "Your seed couldn't be verified. Please check what you entered and try again."; "Search by public key" = "Search by public key"; "Start a Conversation" = "Start a Conversation"; "Invalid public key" = "Invalid public key"; diff --git a/SignalServiceKit/src/Loki/Crypto/Mnemonic.swift b/SignalServiceKit/src/Loki/Crypto/Mnemonic.swift index e55b42f3c..b560d0ede 100644 --- a/SignalServiceKit/src/Loki/Crypto/Mnemonic.swift +++ b/SignalServiceKit/src/Loki/Crypto/Mnemonic.swift @@ -49,11 +49,11 @@ public enum Mnemonic { public var errorDescription: String? { switch self { - case .generic: return NSLocalizedString("Something went wrong. Please check your mnemonic and try again.", comment: "") - case .inputTooShort: return NSLocalizedString("Looks like you didn't enter enough words. Please check your mnemonic and try again.", comment: "") - case .missingLastWord: return NSLocalizedString("You seem to be missing the last word of your mnemonic. Please check what you entered and try again.", comment: "") - case .invalidWord: return NSLocalizedString("There appears to be an invalid word in your mnemonic. Please check what you entered and try again.", comment: "") - case .verificationFailed: return NSLocalizedString("Your mnemonic couldn't be verified. Please check what you entered and try again.", comment: "") + case .generic: return NSLocalizedString("Something went wrong. Please check your seed and try again.", comment: "") + case .inputTooShort: return NSLocalizedString("Looks like you didn't enter enough words. Please check your seed and try again.", comment: "") + case .missingLastWord: return NSLocalizedString("You seem to be missing the last word of your seed. Please check what you entered and try again.", comment: "") + case .invalidWord: return NSLocalizedString("There appears to be an invalid word in your seed. Please check what you entered and try again.", comment: "") + case .verificationFailed: return NSLocalizedString("Your seed couldn't be verified. Please check what you entered and try again.", comment: "") } } }