From 13da4bc7d08079d44f4e788cda795a2a61817fc8 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 30 Nov 2018 08:59:10 -0700 Subject: [PATCH 1/2] rename to "primary button" --- ...ExperienceUpgradesPageViewController.swift | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index 29974ea9d..54291296f 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -7,7 +7,7 @@ import SignalMessaging private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: ExperienceUpgradeViewController { - var buttonAction: ((UIButton) -> Void)? + var primaryButtonAction: ((UIButton) -> Void)? override func loadView() { self.view = UIView.container() @@ -41,7 +41,7 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: imageView.contentMode = .scaleAspectFit let buttonTitle = NSLocalizedString("UPGRADE_EXPERIENCE_INTRODUCING_NOTIFICATION_AUDIO_SETTINGS_BUTTON", comment: "button label shown one time, after upgrade") - let button = addButton(title: buttonTitle) { _ in + let button = addPrimaryButton(title: buttonTitle) { _ in // dismiss the modally presented view controller, then proceed. self.experienceUpgradesPageViewController.dismiss(animated: true) { guard let fromViewController = UIApplication.shared.frontmostViewController else { @@ -89,8 +89,8 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: // MARK: - Actions - func addButton(title: String, action: @escaping (UIButton) -> Void) -> UIButton { - self.buttonAction = action + func addPrimaryButton(title: String, action: @escaping (UIButton) -> Void) -> UIButton { + self.primaryButtonAction = action let button = MultiLineButton() view.addSubview(button) button.setTitle(title, for: .normal) @@ -106,18 +106,18 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: @objc func didTapButton(sender: UIButton) { Logger.debug("") - guard let buttonAction = self.buttonAction else { + guard let primaryButtonAction = self.primaryButtonAction else { owsFailDebug("button action was nil") return } - buttonAction(sender) + primaryButtonAction(sender) } } private class IntroductingReadReceiptsExperienceUpgradeViewController: ExperienceUpgradeViewController { - var buttonAction: ((UIButton) -> Void)? + var primaryButtonAction: ((UIButton) -> Void)? override func loadView() { self.view = UIView.container() @@ -151,7 +151,7 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc imageView.contentMode = .scaleAspectFit let buttonTitle = NSLocalizedString("UPGRADE_EXPERIENCE_INTRODUCING_READ_RECEIPTS_PRIVACY_SETTINGS", comment: "button label shown one time, after upgrade") - let button = addButton(title: buttonTitle) { _ in + let button = addPrimaryButton(title: buttonTitle) { _ in // dismiss the modally presented view controller, then proceed. self.experienceUpgradesPageViewController.dismiss(animated: true) { guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else { @@ -199,8 +199,8 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc // MARK: - Actions - func addButton(title: String, action: @escaping (UIButton) -> Void) -> UIButton { - self.buttonAction = action + func addPrimaryButton(title: String, action: @escaping (UIButton) -> Void) -> UIButton { + self.primaryButtonAction = action let button = MultiLineButton() view.addSubview(button) button.setTitle(title, for: .normal) @@ -216,18 +216,18 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc @objc func didTapButton(sender: UIButton) { Logger.debug("") - guard let buttonAction = self.buttonAction else { + guard let primaryButtonAction = self.primaryButtonAction else { owsFailDebug("button action was nil") return } - buttonAction(sender) + primaryButtonAction(sender) } } private class IntroductingTypingIndicatorsExperienceUpgradeViewController: ExperienceUpgradeViewController { - var buttonAction: ((UIButton) -> Void)? + var primaryButtonAction: ((UIButton) -> Void)? override func loadView() { self.view = UIView.container() @@ -271,7 +271,7 @@ private class IntroductingTypingIndicatorsExperienceUpgradeViewController: Exper imageView.contentMode = .scaleAspectFit let buttonTitle = NSLocalizedString("UPGRADE_EXPERIENCE_INTRODUCING_TYPING_INDICATOR_PRIVACY_SETTINGS", comment: "button label shown one time, after upgrade") - let button = addButton(title: buttonTitle) { _ in + let button = addPrimaryButton(title: buttonTitle) { _ in // dismiss the modally presented view controller, then proceed. self.experienceUpgradesPageViewController.dismiss(animated: true) { guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else { @@ -319,8 +319,8 @@ private class IntroductingTypingIndicatorsExperienceUpgradeViewController: Exper // MARK: - Actions - func addButton(title: String, action: @escaping (UIButton) -> Void) -> UIButton { - self.buttonAction = action + func addPrimaryButton(title: String, action: @escaping (UIButton) -> Void) -> UIButton { + self.primaryButtonAction = action let button = MultiLineButton() view.addSubview(button) button.setTitle(title, for: .normal) @@ -336,12 +336,12 @@ private class IntroductingTypingIndicatorsExperienceUpgradeViewController: Exper @objc func didTapButton(sender: UIButton) { Logger.debug("") - guard let buttonAction = self.buttonAction else { + guard let primaryButtonAction = self.primaryButtonAction else { owsFailDebug("button action was nil") return } - buttonAction(sender) + primaryButtonAction(sender) } } From 1ab4ed9aec340bc30de101684f2998ae7afa5874 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 30 Nov 2018 09:17:16 -0700 Subject: [PATCH 2/2] enable typing indicators directly from splash --- ...ExperienceUpgradesPageViewController.swift | 23 +++++++------------ .../translations/en.lproj/Localizable.strings | 9 +++++--- .../src/Util/TypingIndicators.swift | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index 54291296f..71bd77d56 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -229,6 +229,10 @@ private class IntroductingTypingIndicatorsExperienceUpgradeViewController: Exper var primaryButtonAction: ((UIButton) -> Void)? + var typingIndicators: TypingIndicators { + return SSKEnvironment.shared.typingIndicators + } + override func loadView() { self.view = UIView.container() @@ -270,21 +274,10 @@ private class IntroductingTypingIndicatorsExperienceUpgradeViewController: Exper view.addSubview(imageView) imageView.contentMode = .scaleAspectFit - let buttonTitle = NSLocalizedString("UPGRADE_EXPERIENCE_INTRODUCING_TYPING_INDICATOR_PRIVACY_SETTINGS", comment: "button label shown one time, after upgrade") + let buttonTitle = NSLocalizedString("UPGRADE_EXPERIENCE_ENABLE_TYPING_INDICATOR_BUTTON", comment: "button label shown one time, after upgrade") let button = addPrimaryButton(title: buttonTitle) { _ in - // dismiss the modally presented view controller, then proceed. - self.experienceUpgradesPageViewController.dismiss(animated: true) { - guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else { - owsFailDebug("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))") - return - } - - // Construct the "settings" view & push the "privacy settings" view. - let navigationController = AppSettingsViewController.inModalNavigationController() - navigationController.pushViewController(PrivacySettingsTableViewController(), animated: false) - - fromViewController.present(navigationController, animated: true) - } + self.typingIndicators.setTypingIndicatorsEnabled(value: true) + self.experienceUpgradesPageViewController.dismiss(animated: true) } let bottomSpacer = UIView() @@ -665,7 +658,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView // Dismiss button let dismissButton = UIButton() view.addSubview(dismissButton) - dismissButton.setTitle(CommonStrings.dismissButton, for: .normal) + dismissButton.setTitle(NSLocalizedString("EXPERIENCE_UPGRADE_DISMISS_BUTTON", comment: "Button to dismiss/ignore the one time splash screen that appears after upgrading"), for: .normal) dismissButton.setTitleColor(UIColor.ows_signalBrandBlue, for: .normal) dismissButton.isUserInteractionEnabled = true dismissButton.addTarget(self, action: #selector(didTapDismissButton), for: .touchUpInside) diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index ad3d5bd83..a641ce074 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -912,6 +912,9 @@ /* Format string for 'unregistered user' error. Embeds {{the unregistered user's name or signal id}}. */ "ERROR_UNREGISTERED_USER_FORMAT" = "Unregistered User: %@"; +/* Button to dismiss/ignore the one time splash screen that appears after upgrading */ +"EXPERIENCE_UPGRADE_DISMISS_BUTTON" = "Not Now"; + /* action sheet header when re-sending message which failed because of too many attempts */ "FAILED_SENDING_BECAUSE_RATE_LIMIT" = "Too many failures with this contact. Please try again later."; @@ -2285,6 +2288,9 @@ /* Header for upgrade experience */ "UPGRADE_EXPERIENCE_CALLKIT_TITLE" = "Just Swipe to Answer"; +/* button label shown one time, after upgrade */ +"UPGRADE_EXPERIENCE_ENABLE_TYPING_INDICATOR_BUTTON" = "Turn On Typing Indicators"; + /* Description for notification audio customization */ "UPGRADE_EXPERIENCE_INTRODUCING_NOTIFICATION_AUDIO_DESCRIPTION" = "You can now choose default and per-conversation notification sounds, and calls will respect the ringtone you've chosen for each system contact."; @@ -2312,9 +2318,6 @@ /* Header for upgrade experience */ "UPGRADE_EXPERIENCE_INTRODUCING_READ_RECEIPTS_TITLE" = "Introducing Read Receipts"; -/* button label shown one time, after upgrade */ -"UPGRADE_EXPERIENCE_INTRODUCING_TYPING_INDICATOR_PRIVACY_SETTINGS" = "Enable typing indicators in your privacy settings."; - /* Body text for upgrading users */ "UPGRADE_EXPERIENCE_INTRODUCING_TYPING_INDICATORS_DESCRIPTION" = "Now you can optionally see and share when messages are being typed."; diff --git a/SignalServiceKit/src/Util/TypingIndicators.swift b/SignalServiceKit/src/Util/TypingIndicators.swift index 4e34f935b..be57a61e3 100644 --- a/SignalServiceKit/src/Util/TypingIndicators.swift +++ b/SignalServiceKit/src/Util/TypingIndicators.swift @@ -82,7 +82,7 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators { @objc public func setTypingIndicatorsEnabled(value: Bool) { AssertIsOnMainThread() - + Logger.info("\(_areTypingIndicatorsEnabled) -> \(value)") _areTypingIndicatorsEnabled = value primaryStorage.dbReadWriteConnection.setBool(value, forKey: kDatabaseKey_TypingIndicatorsEnabled, inCollection: kDatabaseCollection)