From 18352309bf71185d8deb798657458590d0bf2b32 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 22 Sep 2019 14:22:46 -0700 Subject: [PATCH] Hiding email link. --- Clocker/AppDelegate.swift | 4 +- .../FinalOnboardingViewController.swift | 38 ++++++++++++++++++- Clocker/Onboarding/Onboarding.storyboard | 33 ++++++++-------- .../About/AboutViewController.swift | 1 + 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Clocker/AppDelegate.swift b/Clocker/AppDelegate.swift index b627833..dc2c249 100644 --- a/Clocker/AppDelegate.swift +++ b/Clocker/AppDelegate.swift @@ -41,6 +41,8 @@ open class AppDelegate: NSObject, NSApplicationDelegate { } public func applicationDidFinishLaunching(_: Notification) { + UserDefaults.standard.wipe() + // Initializing the event store takes really long EventCenter.sharedCenter() @@ -106,7 +108,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate { let shouldLaunchOnboarding = (DataStore.shared().retrieve(key: CLShowOnboardingFlow) == nil && DataStore.shared().timezones().isEmpty) || ProcessInfo.processInfo.arguments.contains(CLOnboaringTestsLaunchArgument) - shouldLaunchOnboarding ? controller?.launch() : continueUsually() + shouldLaunchOnboarding ? controller?.launch() : controller?.launch() } func continueUsually() { diff --git a/Clocker/Onboarding/FinalOnboardingViewController.swift b/Clocker/Onboarding/FinalOnboardingViewController.swift index 5746887..d77b05f 100644 --- a/Clocker/Onboarding/FinalOnboardingViewController.swift +++ b/Clocker/Onboarding/FinalOnboardingViewController.swift @@ -17,7 +17,7 @@ class FinalOnboardingViewController: NSViewController { @IBOutlet var accesoryLabel: NSTextField! @IBOutlet var accessoryImageView: NSImageView! @IBOutlet var emailTextField: NSTextField! - @IBOutlet var emailExplanationLabel: NSTextField! + @IBOutlet var localizationButton: UnderlinedButton! private let emailValidator = EmailTextFieldValidator() @@ -43,7 +43,41 @@ class FinalOnboardingViewController: NSViewController { subtitleLabel.stringValue = "Thank you for the details.".localized() accesoryLabel.stringValue = "You'll see a clock icon in your Menu Bar when you launch the app. If you'd like to see a dock icon, go to Preferences.".localized() accessoryImageView.image = Themer.shared().menubarOnboardingImage() - emailExplanationLabel.stringValue = "If you'd like to help us localize the app in your language or receive infrequent app-related updates, please enter your email!".localized() + emailTextField.isHidden = true + setupLocalizationButton() + } + + private func setupLocalizationButton() { + let mutableParaghStyle = NSMutableParagraphStyle() + mutableParaghStyle.alignment = .center + + let underlineRange = NSRange(location: 42, length: 14) + let originalText = NSMutableAttributedString(string: "Help localize Clocker in your language by clicking here!") + originalText.addAttribute(NSAttributedString.Key.underlineStyle, + value: NSNumber(value: Int8(NSUnderlineStyle.single.rawValue)), + range: underlineRange) + originalText.addAttribute(NSAttributedString.Key.foregroundColor, + value: Themer.shared().mainTextColor(), + range: NSRange(location: 0, length: localizationButton.attributedTitle.string.count)) + originalText.addAttribute(NSAttributedString.Key.font, + value: (localizationButton?.font)!, + range: NSRange(location: 0, length: localizationButton.attributedTitle.string.count)) + originalText.addAttribute(NSAttributedString.Key.paragraphStyle, + value: mutableParaghStyle, + range: NSRange(location: 0, length: localizationButton.attributedTitle.string.count)) + + localizationButton.attributedTitle = originalText + } + + @IBAction func localizationAction(_: Any) { + guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink), + let languageCode = Locale.preferredLanguages.first else { return } + + NSWorkspace.shared.open(localizationURL) + + // Log this + let custom: [String: Any] = ["Language": languageCode] + Logger.log(object: custom, for: "Opened Localization Link") } override func viewWillAppear() { diff --git a/Clocker/Onboarding/Onboarding.storyboard b/Clocker/Onboarding/Onboarding.storyboard index 2b96e41..1a24731 100644 --- a/Clocker/Onboarding/Onboarding.storyboard +++ b/Clocker/Onboarding/Onboarding.storyboard @@ -1,6 +1,7 @@ + @@ -464,7 +465,7 @@ DQ - + @@ -651,28 +652,31 @@ DQ - + - - - - - - - - + + - + @@ -680,18 +684,17 @@ DQ + - - - + @@ -702,7 +705,7 @@ DQ - + diff --git a/Clocker/Preferences/About/AboutViewController.swift b/Clocker/Preferences/About/AboutViewController.swift index 24cda8b..e398a59 100644 --- a/Clocker/Preferences/About/AboutViewController.swift +++ b/Clocker/Preferences/About/AboutViewController.swift @@ -9,6 +9,7 @@ struct AboutUsConstants { static let TwitterLink = "https://twitter.com/n0shake/?ref=ClockerApp" static let PersonalWebsite = "http://abhishekbanthia.com/?ref=ClockerApp" static let AppStoreLink = "macappstore://itunes.apple.com/us/app/clocker/id1056643111?action=write-review" + static let CrowdInLocalizationLink = "https://crwd.in/clocker" } class AboutViewController: ParentViewController {