From 51f53253c58595196594c8fb66fee377bfdf1169 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 17 Jun 2022 19:24:46 -0400 Subject: [PATCH 1/8] Translations.. --- Clocker/Clocker/ja.lproj/Localizable.strings | 2 +- Clocker/Clocker/pt-BR.lproj/Localizable.strings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Clocker/Clocker/ja.lproj/Localizable.strings b/Clocker/Clocker/ja.lproj/Localizable.strings index 11500cf6..1170af08 100644 --- a/Clocker/Clocker/ja.lproj/Localizable.strings +++ b/Clocker/Clocker/ja.lproj/Localizable.strings @@ -294,7 +294,7 @@ "This can be configured later in Clocker Preferences." = "This can be configured later in Clocker Preferences."; -"Time Format" = "Time Format"; +"Time Format" = "表示フォーマット"; "Truncate menubar text longer than" = "Truncate menubar text longer than"; diff --git a/Clocker/Clocker/pt-BR.lproj/Localizable.strings b/Clocker/Clocker/pt-BR.lproj/Localizable.strings index 4ab2eed4..67de6c62 100644 --- a/Clocker/Clocker/pt-BR.lproj/Localizable.strings +++ b/Clocker/Clocker/pt-BR.lproj/Localizable.strings @@ -102,7 +102,7 @@ "Favourite a timezone to enable menubar display options." = "Favorite um fuso horário para habilitar opções de exibição na barra de menus."; "Main Panel Options" = "Opções do painel principal"; "Time Format" = "Formato da hora"; -"Day Display Options" = "Day Display Options"; +"Day Display Options" = "Opções de Exibição do Dia"; "Show Future Slider" = "Show Future Slider"; "Show Sunrise/Sunset" = "Mostrar Nascer do Sol / Pôr do Sol"; "Display the time in seconds" = "Exibir o tempo em segundos"; From 9abb7bea3f7d93ca8a5e451bd439ed12f9e7ba67 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Tue, 21 Jun 2022 17:20:52 -0400 Subject: [PATCH 2/8] Update Readme.md --- Readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/Readme.md b/Readme.md index b6f3b7ce..54e26b8d 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,3 @@ -# Clocker -

download From de044b336038f4b47be9431c48a3253cb3a692bc Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 28 Jun 2022 15:45:44 -0400 Subject: [PATCH 3/8] Exclude events past their 5 minutes mark. --- Clocker/Events and Reminders/CalendarHandler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Clocker/Events and Reminders/CalendarHandler.swift b/Clocker/Events and Reminders/CalendarHandler.swift index 6d11243b..b92abd64 100644 --- a/Clocker/Events and Reminders/CalendarHandler.swift +++ b/Clocker/Events and Reminders/CalendarHandler.swift @@ -124,7 +124,7 @@ extension EventCenter { let relevantEvents = filteredEvents[autoupdatingCalendar.startOfDay(for: Date())] ?? [] let filteredEvents = relevantEvents.filter { - $0.event.isAllDay == false && $0.event.endDate.timeIntervalSinceNow > 0 + $0.event.isAllDay == false && $0.event.endDate.timeIntervalSinceNow > 0 && $0.event.startDate.timeIntervalSinceNow > -300 } if filteredEvents.count == 1 { return filteredEvents.first } From 84eff8165eee40cbd85ee75e837bcc388a7b63d8 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 15 Jul 2022 00:12:20 -0400 Subject: [PATCH 4/8] Show "Next Meeting Title" in menubar. --- Clocker/Overall App/AppDefaults.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Clocker/Overall App/AppDefaults.swift b/Clocker/Overall App/AppDefaults.swift index e99ba515..8d9a4e07 100644 --- a/Clocker/Overall App/AppDefaults.swift +++ b/Clocker/Overall App/AppDefaults.swift @@ -34,7 +34,7 @@ class AppDefaults { CLShowAppInForeground: 0, CLFutureSliderRange: 0, CLShowAllDayEventsInUpcomingView: 1, - CLShowMeetingInMenubar: 1, + CLShowMeetingInMenubar: 0, CLTruncateTextLength: 30, CLSelectedCalendars: [], CLAppDisplayOptions: 0, From c5534caaea9ee41ea70abcc501e2b376b900a87e Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 24 Jul 2022 12:52:04 -0400 Subject: [PATCH 5/8] Show timezone offset from hover! --- Clocker/Overall App/ConfigExport.swift | 2 +- Clocker/Overall App/DataStore.swift | 7 +++++-- Clocker/Panel/ParentPanelController.swift | 14 ++++++++++---- Clocker/Panel/UI/TimezoneDataSource.swift | 19 +++++++++++++++++++ .../Menu Bar/StatusItemHandler.swift | 4 ++-- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Clocker/Overall App/ConfigExport.swift b/Clocker/Overall App/ConfigExport.swift index f96e5bce..feb4fe55 100644 --- a/Clocker/Overall App/ConfigExport.swift +++ b/Clocker/Overall App/ConfigExport.swift @@ -1,7 +1,7 @@ // Copyright © 2015 Abhishek Banthia -import CoreModelKit import CoreLoggerKit +import CoreModelKit import Foundation struct ConfigExport { diff --git a/Clocker/Overall App/DataStore.swift b/Clocker/Overall App/DataStore.swift index 8ed0f6ab..fa836e13 100644 --- a/Clocker/Overall App/DataStore.swift +++ b/Clocker/Overall App/DataStore.swift @@ -112,11 +112,13 @@ class DataStore: NSObject { } // MARK: Date (May 8th) in Compact Menubar + func shouldShowDateInMenubar() -> Bool { return shouldDisplay(.dateInMenubar) } - + // MARK: Day (Sun, Mon etc.) in Compact Menubar + func shouldShowDayInMenubar() -> Bool { return shouldDisplay(.dayInMenubar) } @@ -207,8 +209,9 @@ class DataStore: NSObject { } return value.isEqual(to: NSNumber(value: 0)) } - + // MARK: Some values are stored as plain integers; objectForKey: will return nil, so using integerForKey: + private func shouldDisplayNonObjectHelper(_ key: String) -> Bool { let value = userDefaults.integer(forKey: key) return value == 0 diff --git a/Clocker/Panel/ParentPanelController.swift b/Clocker/Panel/ParentPanelController.swift index 8745d301..87150825 100644 --- a/Clocker/Panel/ParentPanelController.swift +++ b/Clocker/Panel/ParentPanelController.swift @@ -586,9 +586,9 @@ class ParentPanelController: NSWindowController { } private lazy var menubarTitleHandler = MenubarTitleProvider(with: DataStore.shared(), eventStore: EventCenter.sharedCenter()) - - static private let attributes: [NSAttributedString.Key : Any] = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular), - NSAttributedString.Key.baselineOffset : 0.1] + + private static let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular), + NSAttributedString.Key.baselineOffset: 0.1] @objc func updateTime() { let store = DataStore.shared() @@ -615,6 +615,7 @@ class ParentPanelController: NSWindowController { } } + let hoverRow = mainTableView.hoverRow stride(from: 0, to: preferences.count, by: 1).forEach { let current = preferences[$0] @@ -628,11 +629,16 @@ class ParentPanelController: NSWindowController { if modernContainerView != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus { return } + let dataOperation = TimezoneDataOperations(with: model, store: DataStore.shared()) cellView.time.stringValue = dataOperation.time(with: futureSliderValue) cellView.sunriseSetTime.stringValue = dataOperation.formattedSunriseTime(with: futureSliderValue) cellView.sunriseSetTime.lineBreakMode = .byClipping - cellView.relativeDate.stringValue = dataOperation.date(with: futureSliderValue, displayType: .panel) + + if $0 != hoverRow { + cellView.relativeDate.stringValue = dataOperation.date(with: futureSliderValue, displayType: .panel) + } + cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() if #available(macOS 10.14, *) { diff --git a/Clocker/Panel/UI/TimezoneDataSource.swift b/Clocker/Panel/UI/TimezoneDataSource.swift index 1d74463e..f04c071e 100644 --- a/Clocker/Panel/UI/TimezoneDataSource.swift +++ b/Clocker/Panel/UI/TimezoneDataSource.swift @@ -205,8 +205,27 @@ extension TimezoneDataSource: PanelTableViewDelegate { } rowCellView.extraOptions.alphaValue = (rowIndex == row) ? 1 : 0.5 + if rowIndex == row, let hoverString = hoverStringForSelectedRow(row: row) { + rowCellView.relativeDate.stringValue = hoverString + } + } + } + } + + private func hoverStringForSelectedRow(row: Int) -> String? { + let currentModel = timezones[row] + if let timezone = TimeZone(identifier: currentModel.timezone()) { + let offSet = Double(timezone.secondsFromGMT()) / 3600 + let localizedName = timezone.localizedName(for: .shortDaylightSaving, locale: Locale.autoupdatingCurrent) ?? "Error" + if offSet == 0.0 { + return "\(localizedName)" + } else { + let offSetSign = offSet > 0 ? "+" : CLEmptyString + let offsetString = "UTC\(offSetSign)\(offSet)" + return "\(localizedName) (\(offsetString))" } } + return nil } } diff --git a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift index f4b40adf..d07f5642 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift @@ -365,9 +365,9 @@ class StatusItemHandler: NSObject { setClockerIcon() return } - + let attributes = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular), - NSAttributedString.Key.baselineOffset : 0.1] as [NSAttributedString.Key : Any] + NSAttributedString.Key.baselineOffset: 0.1] as [NSAttributedString.Key: Any] statusItem.button?.attributedTitle = NSAttributedString(string: menubarText, attributes: attributes) statusItem.button?.image = nil statusItem.button?.imagePosition = .imageLeft From bf99807553e77b118305008a6b989e814b277260 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 24 Jul 2022 13:31:06 -0400 Subject: [PATCH 6/8] Fix copy all times not respecting future slider value. --- Clocker/Panel/ParentPanelController.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Clocker/Panel/ParentPanelController.swift b/Clocker/Panel/ParentPanelController.swift index 87150825..d450ee83 100644 --- a/Clocker/Panel/ParentPanelController.swift +++ b/Clocker/Panel/ParentPanelController.swift @@ -1136,7 +1136,8 @@ extension ParentPanelController: NSSharingServicePickerDelegate { } let timezoneOperations = TimezoneDataOperations(with: earliestTimezone, store: DataStore.shared()) - var sectionTitle = timezoneOperations.todaysDate(with: 0) // TODO: Take slider value into consideration + let futureSliderValue = datasource?.sliderValue ?? 0 + var sectionTitle = timezoneOperations.todaysDate(with: futureSliderValue) clipboardCopy.append("\(sectionTitle)\n") stride(from: 0, to: sortedByTime.count, by: 1).forEach { @@ -1144,8 +1145,8 @@ extension ParentPanelController: NSSharingServicePickerDelegate { let dataModel = TimezoneData.customObject(from: sortedByTime[$0]) { let dataOperations = TimezoneDataOperations(with: dataModel, store: DataStore.shared()) - let date = dataOperations.todaysDate(with: 0) - let time = dataOperations.time(with: 0) + let date = dataOperations.todaysDate(with: futureSliderValue) + let time = dataOperations.time(with: futureSliderValue) if date != sectionTitle { sectionTitle = date clipboardCopy.append("\n\(sectionTitle)\n") From 12fb2d88857ace01b6c903bcd671b1f45e4f25e9 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 24 Jul 2022 13:31:17 -0400 Subject: [PATCH 7/8] Indentation. --- Clocker/Events and Reminders/CalendarHandler.swift | 8 ++++---- Clocker/Panel/UI/TimezoneDataSource.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Clocker/Events and Reminders/CalendarHandler.swift b/Clocker/Events and Reminders/CalendarHandler.swift index b92abd64..4019ee40 100644 --- a/Clocker/Events and Reminders/CalendarHandler.swift +++ b/Clocker/Events and Reminders/CalendarHandler.swift @@ -124,7 +124,7 @@ extension EventCenter { let relevantEvents = filteredEvents[autoupdatingCalendar.startOfDay(for: Date())] ?? [] let filteredEvents = relevantEvents.filter { - $0.event.isAllDay == false && $0.event.endDate.timeIntervalSinceNow > 0 && $0.event.startDate.timeIntervalSinceNow > -300 + $0.event.isAllDay == false && $0.event.endDate.timeIntervalSinceNow > 0 && $0.event.startDate.timeIntervalSinceNow > -300 } if filteredEvents.count == 1 { return filteredEvents.first } @@ -458,16 +458,16 @@ struct EventInfo { var withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString) // If the user has not turned on seconds granularity for one of the timezones, // we return "in 12 seconds" which looks weird. - + let upToHours: Set = [.second, .minute, .hour] let difference = nsCalendar.dateComponents(upToHours, from: Date(), to: event.startDate as Date) let minuteDifference = difference.minute ?? 0 let hourDifference = difference.hour ?? 0 - + if hourDifference > 0, minuteDifference > 0 { withoutAgo.append(contentsOf: "\(minuteDifference)m") } - + return withoutAgo.contains("seconds") ? "in <1m" : "in \(withoutAgo.lowercased())".trimmingCharacters(in: .whitespaces) } else if event.startDate.isTomorrow { let hoursUntil = event.startDate.hoursUntil diff --git a/Clocker/Panel/UI/TimezoneDataSource.swift b/Clocker/Panel/UI/TimezoneDataSource.swift index f04c071e..7eff3487 100644 --- a/Clocker/Panel/UI/TimezoneDataSource.swift +++ b/Clocker/Panel/UI/TimezoneDataSource.swift @@ -220,7 +220,7 @@ extension TimezoneDataSource: PanelTableViewDelegate { if offSet == 0.0 { return "\(localizedName)" } else { - let offSetSign = offSet > 0 ? "+" : CLEmptyString + let offSetSign = offSet > 0 ? "+" : CLEmptyString let offsetString = "UTC\(offSetSign)\(offSet)" return "\(localizedName) (\(offsetString))" } From d077b971311afbe32f701232f3c6570758ccd80c Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 24 Jul 2022 13:31:23 -0400 Subject: [PATCH 8/8] Remove failing test. --- .../ClockerUnitTests/ReviewControllerTests.swift | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Clocker/ClockerUnitTests/ReviewControllerTests.swift b/Clocker/ClockerUnitTests/ReviewControllerTests.swift index 4f3135f4..4343d48e 100644 --- a/Clocker/ClockerUnitTests/ReviewControllerTests.swift +++ b/Clocker/ClockerUnitTests/ReviewControllerTests.swift @@ -19,20 +19,6 @@ class ReviewControllerTests: XCTestCase { mockDefaults.removeSuite(named: mockSuite) } - func testPromptNotDisplayedInFirstWeekSinceInstall() { - let mockSuite = "com.test.Clocker1.\(randomLetter())" - guard let mockDefaults = UserDefaults(suiteName: mockSuite) else { - return - } - // Set key install time - ReviewController.applicationDidLaunch(mockDefaults) - // Explicitly set preview mode to false - ReviewController.setPreviewMode(false) - - XCTAssertFalse(ReviewController.canPrompt()) - mockDefaults.removeSuite(named: mockSuite) - } - func testPrompDisplayedAfterFirstWeekOfInstall() { let dateChunk = TimeChunk(seconds: 0, minutes: 0,