From e94194a672782377ceac67e0728a5a602d11dfba Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 5 Dec 2020 17:40:58 -0600 Subject: [PATCH] More changes for customized time formats.. --- Clocker/Menu Bar/StatusContainerView.swift | 8 +++----- .../OnboardingSearchController.swift | 2 +- Clocker/Overall App/AppDefaults.swift | 3 +-- Clocker/Overall App/DataStore.swift | 3 --- Clocker/Overall App/Strings.swift | 1 - Clocker/Panel/Data Layer/TimezoneData.swift | 10 ++++++++-- Clocker/Panel/Notes Popover/NotesPopover.xib | 2 +- Clocker/Panel/PanelController.swift | 2 -- .../Appearance/AppearanceViewController.swift | 20 +++++++------------ 9 files changed, 21 insertions(+), 30 deletions(-) diff --git a/Clocker/Menu Bar/StatusContainerView.swift b/Clocker/Menu Bar/StatusContainerView.swift index aab8f0d..9a1c46f 100644 --- a/Clocker/Menu Bar/StatusContainerView.swift +++ b/Clocker/Menu Bar/StatusContainerView.swift @@ -13,10 +13,6 @@ func bufferCalculatedWidth() -> Int { totalWidth += 20 } - if DataStore.shared().shouldDisplay(.seconds) { - totalWidth += 15 - } - if DataStore.shared().shouldShowDateInMenubar() { totalWidth += 20 } @@ -85,7 +81,9 @@ class StatusContainerView: NSView { let operationObject = TimezoneDataOperations(with: timezoneObject) let calculatedSubtitleSize = compactModeTimeFont.size(operationObject.compactMenuSubtitle(), precalculatedWidth, attributes: timeBasedAttributes) let calculatedTitleSize = compactModeTimeFont.size(operationObject.compactMenuTitle(), precalculatedWidth, attributes: timeBasedAttributes) - return result + max(calculatedTitleSize.width, calculatedSubtitleSize.width) + bufferWidth + let showSeconds = timezoneObject.shouldShowSeconds() + let secondsBuffer: CGFloat = showSeconds ? 7 : 0 + return result + max(calculatedTitleSize.width, calculatedSubtitleSize.width) + bufferWidth + secondsBuffer } return result + CGFloat(bufferCalculatedWidth()) diff --git a/Clocker/Onboarding/OnboardingSearchController.swift b/Clocker/Onboarding/OnboardingSearchController.swift index 6d80584..fbfcc88 100644 --- a/Clocker/Onboarding/OnboardingSearchController.swift +++ b/Clocker/Onboarding/OnboardingSearchController.swift @@ -18,7 +18,7 @@ class OnboardingSearchController: NSViewController { guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"), let dictionary = NSDictionary(contentsOfFile: path), let apiKey = dictionary["GeocodingKey"] as? String else { - assertionFailure("Unable to find the API key") +// assertionFailure("Unable to find the API key") return "" } return apiKey diff --git a/Clocker/Overall App/AppDefaults.swift b/Clocker/Overall App/AppDefaults.swift index ff33e94..3ccdf65 100644 --- a/Clocker/Overall App/AppDefaults.swift +++ b/Clocker/Overall App/AppDefaults.swift @@ -99,14 +99,13 @@ class AppDefaults { private class func defaultsDictionary() -> [String: Any] { return [CLThemeKey: 0, CLDisplayFutureSliderKey: 0, - CL24hourFormatSelectedKey: 1, + CL24hourFormatSelectedKey: 0, // 12-hour format CLRelativeDateKey: 0, CLShowDayInMenu: 0, CLShowDateInMenu: 1, CLShowPlaceInMenu: 0, CLStartAtLogin: 0, CLSunriseSunsetTime: 1, - CLShowSecondsInMenubar: 1, CLUserFontSizePreference: 4, CLShowUpcomingEventView: "YES", CLShowAppInForeground: 0, diff --git a/Clocker/Overall App/DataStore.swift b/Clocker/Overall App/DataStore.swift index d8824a1..27ffa91 100644 --- a/Clocker/Overall App/DataStore.swift +++ b/Clocker/Overall App/DataStore.swift @@ -7,7 +7,6 @@ enum ViewType { case upcomingEventView case twelveHour case sunrise - case seconds case showMeetingInMenubar case showAllDayEventsInMenubar case showAppInForeground @@ -126,8 +125,6 @@ class DataStore: NSObject { return shouldDisplayHelper(CLShowAllDayEventsInUpcomingView) case .sunrise: return shouldDisplayHelper(CLSunriseSunsetTime) - case .seconds: - return shouldDisplayHelper(CLShowSecondsInMenubar) case .showMeetingInMenubar: return shouldDisplayHelper(CLShowMeetingInMenubar) case .showAppInForeground: diff --git a/Clocker/Overall App/Strings.swift b/Clocker/Overall App/Strings.swift index c4db561..bcb9353 100644 --- a/Clocker/Overall App/Strings.swift +++ b/Clocker/Overall App/Strings.swift @@ -19,7 +19,6 @@ let CLDisplayFutureSliderKey = "displayFutureSlider" let CLStartAtLogin = "startAtLogin" let CLShowAppInForeground = "displayAppAsForegroundApp" let CLSunriseSunsetTime = "showSunriseSetTime" -let CLShowSecondsInMenubar = "showSeconds" let CLUserFontSizePreference = "userFontSize" let CLShowUpcomingEventView = "ShowUpcomingEventView" let CLShowAllDayEventsInUpcomingView = "showAllDayEventsInUpcomingView" diff --git a/Clocker/Panel/Data Layer/TimezoneData.swift b/Clocker/Panel/Data Layer/TimezoneData.swift index 0dce65a..a472494 100644 --- a/Clocker/Panel/Data Layer/TimezoneData.swift +++ b/Clocker/Panel/Data Layer/TimezoneData.swift @@ -40,11 +40,17 @@ class TimezoneData: NSObject, NSCoding { static let values = [ NSNumber(integerLiteral: 0): DateFormat.twelveHour, - NSNumber(integerLiteral: 1): DateFormat.twelveHourWithSeconds, - NSNumber(integerLiteral: 2): DateFormat.twentyFourHour, + NSNumber(integerLiteral: 1): DateFormat.twentyFourHour, + + // Seconds + NSNumber(integerLiteral: 2): DateFormat.twelveHourWithSeconds, NSNumber(integerLiteral: 3): DateFormat.twentyFourHourWithSeconds, + + // Preceding Zero NSNumber(integerLiteral: 4): DateFormat.twelveHourWithZero, NSNumber(integerLiteral: 5): DateFormat.twelveHourWithZeroSeconds, + + // Suffix NSNumber(integerLiteral: 6): DateFormat.twelveHourWithoutSuffix, NSNumber(integerLiteral: 7): DateFormat.twelveHourWithoutSuffixAndSeconds, ] diff --git a/Clocker/Panel/Notes Popover/NotesPopover.xib b/Clocker/Panel/Notes Popover/NotesPopover.xib index 85d59ab..4341694 100644 --- a/Clocker/Panel/Notes Popover/NotesPopover.xib +++ b/Clocker/Panel/Notes Popover/NotesPopover.xib @@ -304,7 +304,7 @@ - + diff --git a/Clocker/Panel/PanelController.swift b/Clocker/Panel/PanelController.swift index 728f390..b145cee 100644 --- a/Clocker/Panel/PanelController.swift +++ b/Clocker/Panel/PanelController.swift @@ -171,7 +171,6 @@ class PanelController: ParentPanelController { let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, let showAppInForeground = DataStore.shared().retrieve(key: CLShowAppInForeground) as? NSNumber, let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber, - let showSecondsInMenubar = DataStore.shared().retrieve(key: CLShowSecondsInMenubar) as? NSNumber, let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber, let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber, @@ -195,7 +194,6 @@ class PanelController: ParentPanelController { "Display Future Slider": displayFutureSliderKey.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No", "Clocker mode": showAppInForeground.isEqual(to: NSNumber(value: 0)) ? "Menubar" : "Floating", "Relative Date": relativeDate, - "Show Seconds in Menubar": showSecondsInMenubar.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No", "Font Size": fontSize, "Sunrise Sunset": sunriseTime.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No", "Show Day in Menu": showDayInMenu.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No", diff --git a/Clocker/Preferences/Appearance/AppearanceViewController.swift b/Clocker/Preferences/Appearance/AppearanceViewController.swift index b467a11..5797dea 100644 --- a/Clocker/Preferences/Appearance/AppearanceViewController.swift +++ b/Clocker/Preferences/Appearance/AppearanceViewController.swift @@ -181,8 +181,14 @@ class AppearanceViewController: ParentViewController { refresh(panel: true, floating: true) - updateStatusItem() + if let selectedFormat = sender.selectedItem?.title, + selectedFormat.contains("ss") { + print("Seconds are contained") + guard let panelController = PanelController.panel() else { return } + panelController.pauseTimer() + } + updateStatusItem() previewPanelTableView.reloadData() } @@ -257,18 +263,6 @@ class AppearanceViewController: ParentViewController { previewPanelTableView.reloadData() } - @IBAction func displayTimeWithSeconds(_ sender: NSSegmentedControl) { - Logger.log(object: ["Displayed": sender.selectedSegment == 0 ? "YES" : "NO"], for: "Display Time With Seconds") - - if DataStore.shared().shouldDisplay(.seconds) { - guard let panelController = PanelController.panel() else { return } - panelController.pauseTimer() - } - - updateStatusItem() - previewPanelTableView.reloadData() - } - @IBAction func changeAppDisplayOptions(_ sender: NSSegmentedControl) { if sender.selectedSegment == 0 { Logger.log(object: ["Selection": "Menubar"], for: "Dock Mode")