Browse Source

Merge branch 'master' of https://github.com/n0shake/Clocker

pull/113/head
Abhishek Banthia 2 years ago
parent
commit
11638856d9
  1. 2
      Clocker/Clocker/ja.lproj/Localizable.strings
  2. 2
      Clocker/Clocker/pt-BR.lproj/Localizable.strings
  3. 14
      Clocker/ClockerUnitTests/ReviewControllerTests.swift
  4. 2
      Clocker/Events and Reminders/CalendarHandler.swift
  5. 2
      Clocker/Overall App/ConfigExport.swift
  6. 3
      Clocker/Overall App/DataStore.swift
  7. 15
      Clocker/Panel/ParentPanelController.swift
  8. 19
      Clocker/Panel/UI/TimezoneDataSource.swift
  9. 2
      Readme.md

2
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."; "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"; "Truncate menubar text longer than" = "Truncate menubar text longer than";

2
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."; "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"; "Main Panel Options" = "Opções do painel principal";
"Time Format" = "Formato da hora"; "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 Future Slider" = "Show Future Slider";
"Show Sunrise/Sunset" = "Mostrar Nascer do Sol / Pôr do Sol"; "Show Sunrise/Sunset" = "Mostrar Nascer do Sol / Pôr do Sol";
"Display the time in seconds" = "Exibir o tempo em segundos"; "Display the time in seconds" = "Exibir o tempo em segundos";

14
Clocker/ClockerUnitTests/ReviewControllerTests.swift

@ -19,20 +19,6 @@ class ReviewControllerTests: XCTestCase {
mockDefaults.removeSuite(named: mockSuite) 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() { func testPrompDisplayedAfterFirstWeekOfInstall() {
let dateChunk = TimeChunk(seconds: 0, let dateChunk = TimeChunk(seconds: 0,
minutes: 0, minutes: 0,

2
Clocker/Events and Reminders/CalendarHandler.swift

@ -124,7 +124,7 @@ extension EventCenter {
let relevantEvents = filteredEvents[autoupdatingCalendar.startOfDay(for: Date())] ?? [] let relevantEvents = filteredEvents[autoupdatingCalendar.startOfDay(for: Date())] ?? []
let filteredEvents = relevantEvents.filter { 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 } if filteredEvents.count == 1 { return filteredEvents.first }

2
Clocker/Overall App/ConfigExport.swift

@ -1,7 +1,7 @@
// Copyright © 2015 Abhishek Banthia // Copyright © 2015 Abhishek Banthia
import CoreModelKit
import CoreLoggerKit import CoreLoggerKit
import CoreModelKit
import Foundation import Foundation
struct ConfigExport { struct ConfigExport {

3
Clocker/Overall App/DataStore.swift

@ -112,11 +112,13 @@ class DataStore: NSObject {
} }
// MARK: Date (May 8th) in Compact Menubar // MARK: Date (May 8th) in Compact Menubar
func shouldShowDateInMenubar() -> Bool { func shouldShowDateInMenubar() -> Bool {
return shouldDisplay(.dateInMenubar) return shouldDisplay(.dateInMenubar)
} }
// MARK: Day (Sun, Mon etc.) in Compact Menubar // MARK: Day (Sun, Mon etc.) in Compact Menubar
func shouldShowDayInMenubar() -> Bool { func shouldShowDayInMenubar() -> Bool {
return shouldDisplay(.dayInMenubar) return shouldDisplay(.dayInMenubar)
} }
@ -209,6 +211,7 @@ class DataStore: NSObject {
} }
// MARK: Some values are stored as plain integers; objectForKey: will return nil, so using integerForKey: // MARK: Some values are stored as plain integers; objectForKey: will return nil, so using integerForKey:
private func shouldDisplayNonObjectHelper(_ key: String) -> Bool { private func shouldDisplayNonObjectHelper(_ key: String) -> Bool {
let value = userDefaults.integer(forKey: key) let value = userDefaults.integer(forKey: key)
return value == 0 return value == 0

15
Clocker/Panel/ParentPanelController.swift

@ -587,7 +587,7 @@ class ParentPanelController: NSWindowController {
private lazy var menubarTitleHandler = MenubarTitleProvider(with: DataStore.shared(), eventStore: EventCenter.sharedCenter()) 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), private static let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular),
NSAttributedString.Key.baselineOffset: 0.1] NSAttributedString.Key.baselineOffset: 0.1]
@objc func updateTime() { @objc func updateTime() {
@ -615,6 +615,7 @@ class ParentPanelController: NSWindowController {
} }
} }
let hoverRow = mainTableView.hoverRow
stride(from: 0, to: preferences.count, by: 1).forEach { stride(from: 0, to: preferences.count, by: 1).forEach {
let current = preferences[$0] let current = preferences[$0]
@ -628,11 +629,16 @@ class ParentPanelController: NSWindowController {
if modernContainerView != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus { if modernContainerView != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus {
return return
} }
let dataOperation = TimezoneDataOperations(with: model, store: DataStore.shared()) let dataOperation = TimezoneDataOperations(with: model, store: DataStore.shared())
cellView.time.stringValue = dataOperation.time(with: futureSliderValue) cellView.time.stringValue = dataOperation.time(with: futureSliderValue)
cellView.sunriseSetTime.stringValue = dataOperation.formattedSunriseTime(with: futureSliderValue) cellView.sunriseSetTime.stringValue = dataOperation.formattedSunriseTime(with: futureSliderValue)
cellView.sunriseSetTime.lineBreakMode = .byClipping cellView.sunriseSetTime.lineBreakMode = .byClipping
if $0 != hoverRow {
cellView.relativeDate.stringValue = dataOperation.date(with: futureSliderValue, displayType: .panel) cellView.relativeDate.stringValue = dataOperation.date(with: futureSliderValue, displayType: .panel)
}
cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone
cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage()
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
@ -1130,7 +1136,8 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
} }
let timezoneOperations = TimezoneDataOperations(with: earliestTimezone, store: DataStore.shared()) 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") clipboardCopy.append("\(sectionTitle)\n")
stride(from: 0, to: sortedByTime.count, by: 1).forEach { stride(from: 0, to: sortedByTime.count, by: 1).forEach {
@ -1138,8 +1145,8 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
let dataModel = TimezoneData.customObject(from: sortedByTime[$0]) let dataModel = TimezoneData.customObject(from: sortedByTime[$0])
{ {
let dataOperations = TimezoneDataOperations(with: dataModel, store: DataStore.shared()) let dataOperations = TimezoneDataOperations(with: dataModel, store: DataStore.shared())
let date = dataOperations.todaysDate(with: 0) let date = dataOperations.todaysDate(with: futureSliderValue)
let time = dataOperations.time(with: 0) let time = dataOperations.time(with: futureSliderValue)
if date != sectionTitle { if date != sectionTitle {
sectionTitle = date sectionTitle = date
clipboardCopy.append("\n\(sectionTitle)\n") clipboardCopy.append("\n\(sectionTitle)\n")

19
Clocker/Panel/UI/TimezoneDataSource.swift

@ -205,11 +205,30 @@ extension TimezoneDataSource: PanelTableViewDelegate {
} }
rowCellView.extraOptions.alphaValue = (rowIndex == row) ? 1 : 0.5 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
}
}
extension TimezoneCellView { extension TimezoneCellView {
func layout(with model: TimezoneData) { func layout(with model: TimezoneData) {
let shouldDisplay = DataStore.shared().shouldDisplay(.sunrise) && !sunriseSetTime.stringValue.isEmpty let shouldDisplay = DataStore.shared().shouldDisplay(.sunrise) && !sunriseSetTime.stringValue.isEmpty

2
Readme.md

@ -1,5 +1,3 @@
# Clocker
<p align="center"> <p align="center">
<a href="https://github.com/n0shake/Clocker/releases/latest"> <a href="https://github.com/n0shake/Clocker/releases/latest">
<img src="https://img.shields.io/badge/download-latest-brightgreen.svg" alt="download"> <img src="https://img.shields.io/badge/download-latest-brightgreen.svg" alt="download">

Loading…
Cancel
Save