diff --git a/Signal/src/Loki/Onboarding/DisplayNameVC.swift b/Signal/src/Loki/Onboarding/DisplayNameVC.swift index 7c96c2581..65eaed844 100644 --- a/Signal/src/Loki/Onboarding/DisplayNameVC.swift +++ b/Signal/src/Loki/Onboarding/DisplayNameVC.swift @@ -6,7 +6,7 @@ final class DisplayNameVC : OnboardingBaseViewController { result.textColor = Theme.primaryColor result.font = UIFont.ows_dynamicTypeBodyClamped result.textAlignment = .center - let placeholder = NSMutableAttributedString(string: NSLocalizedString("Display Name (Optional)", comment: "")) + let placeholder = NSMutableAttributedString(string: NSLocalizedString("Display Name", comment: "")) placeholder.addAttribute(.foregroundColor, value: Theme.placeholderColor, range: NSRange(location: 0, length: placeholder.length)) result.attributedPlaceholder = placeholder result.tintColor = UIColor.lokiGreen() @@ -14,11 +14,6 @@ final class DisplayNameVC : OnboardingBaseViewController { result.keyboardAppearance = .dark return result }() - - private var normalizedUserName: String? { - let result = userNameTextField.text!.ows_stripped() - return !result.isEmpty ? result : nil - } override func viewDidLoad() { super.viewDidLoad() @@ -59,16 +54,16 @@ final class DisplayNameVC : OnboardingBaseViewController { } @objc private func handleNextButtonPressed() { - if let normalizedName = normalizedUserName { - guard !OWSProfileManager.shared().isProfileNameTooLong(normalizedName) else { - return OWSAlerts.showErrorAlert(message: NSLocalizedString("PROFILE_VIEW_ERROR_PROFILE_NAME_TOO_LONG", comment: "Error message shown when user tries to update profile with a profile name that is too long")) - } + let displayName = userNameTextField.text!.ows_stripped() + guard !displayName.isEmpty else { + return OWSAlerts.showErrorAlert(message: NSLocalizedString("Please pick a display name", comment: "")) + } + guard !OWSProfileManager.shared().isProfileNameTooLong(displayName) else { + return OWSAlerts.showErrorAlert(message: NSLocalizedString("Please pick a shorter display name", comment: "")) } TSAccountManager.sharedInstance().didRegister() UserDefaults.standard.set(true, forKey: "didUpdateForMainnet") onboardingController.verificationDidComplete(fromView: self) - if let normalizedName = normalizedUserName { - OWSProfileManager.shared().updateLocalProfileName(normalizedName, avatarImage: nil, success: { }, failure: { }) // Try to save the user name but ignore the result - } + OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { }) // Try to save the user name but ignore the result } } diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index 5284b96f6..3dad86d17 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -393,12 +393,13 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat __weak ProfileViewController *weakSelf = self; NSString *normalizedProfileName = [self normalizedProfileName]; + + if (normalizedProfileName.length == 0) { + return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a display name", @"")]; + } + if ([OWSProfileManager.sharedManager isProfileNameTooLong:normalizedProfileName]) { - [OWSAlerts - showErrorAlertWithMessage:NSLocalizedString(@"PROFILE_VIEW_ERROR_PROFILE_NAME_TOO_LONG", - @"Error message shown when user tries to update profile with a profile name " - @"that is too long.")]; - return; + return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a shorter display name", @"")]; } [LKAnalytics.shared track:@"Display Name Updated"]; diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index addb842c8..c1528299c 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2547,7 +2547,7 @@ "Loki Messenger can let you know when you get a message (and who it is from)" = "Loki Messenger can let you know when you get a message (and who it is from)"; "Create Your Loki Messenger Account" = "Create Your Loki Messenger Account"; "Enter a name to be shown to your contacts" = "Enter a name to be shown to your contacts"; -"Display Name (Optional)" = "Display Name (Optional)"; +"Display Name" = "Display Name"; "Type an optional password for added security" = "Type an optional password for added security"; "Password (Optional)" = "Password (Optional)"; "Next" = "Next"; @@ -2590,7 +2590,6 @@ "Your Seed" = "Your Seed"; "Unlock Loki Messenger's screen using Touch ID, Face ID, or your iOS device passcode. You can still answer incoming calls and receive message notifications while Screen Lock is enabled. Loki Messenger's notification settings allow you to customize the information that is displayed." = "Unlock Loki Messenger's screen using Touch ID, Face ID, or your iOS device passcode. You can still answer incoming calls and receive message notifications while Screen Lock is enabled. Loki Messenger's notification settings allow you to customize the information that is displayed."; "Prevent Loki Messenger previews from appearing in the app switcher." = "Prevent Loki Messenger previews from appearing in the app switcher."; -"Display Name" = "Display Name"; "Loki Messenger" = "Loki Messenger"; "Privacy Policy" = "Privacy Policy"; "New Conversation" = "New Conversation"; @@ -2636,3 +2635,5 @@ "Your device has been linked successfully" = "Your device has been linked successfully"; "Link" = "Link"; "Anonymous" = "Anonymous"; +"Please pick a shorter display name" = "Please pick a shorter display name"; +"Please pick a display name" = "Please pick a display name";