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.";
"Time Format" = "Time Format";
"Time Format" = "表示フォーマット";
"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.";
"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";

14
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,

2
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 }

2
Clocker/Overall App/ConfigExport.swift

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

3
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)
}
@ -209,6 +211,7 @@ class DataStore: NSObject {
}
// 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

15
Clocker/Panel/ParentPanelController.swift

@ -587,7 +587,7 @@ 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),
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() {
@ -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
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, *) {
@ -1130,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 {
@ -1138,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")

19
Clocker/Panel/UI/TimezoneDataSource.swift

@ -205,11 +205,30 @@ 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
}
}
extension TimezoneCellView {
func layout(with model: TimezoneData) {
let shouldDisplay = DataStore.shared().shouldDisplay(.sunrise) && !sunriseSetTime.stringValue.isEmpty

2
Readme.md

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

Loading…
Cancel
Save