Browse Source

Some makeup.

pull/101/head
Abhishek 3 years ago
parent
commit
8cd3c8a55f
  1. 2
      Clocker/AppDelegate.swift
  2. 1
      Clocker/ClockerUITests/PermissionsTests.swift
  3. 4
      Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift
  4. 8
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift
  5. 6
      Clocker/Dependencies/Date Additions/TimePeriodChain.swift
  6. 11
      Clocker/Events and Reminders/CalendarHandler.swift
  7. 3
      Clocker/Events and Reminders/RemindersHandler.swift
  8. 6
      Clocker/Menu Bar/StatusContainerView.swift
  9. 2
      Clocker/Menu Bar/StatusItemHandler.swift
  10. 10
      Clocker/Onboarding/OnboardingSearchController.swift
  11. 11
      Clocker/Overall App/ConfigExport.swift
  12. 2
      Clocker/Overall App/NetworkManager.swift
  13. 4
      Clocker/Overall App/Themer.swift
  14. 2
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  15. 8
      Clocker/Panel/Notes Popover/NotesPopover.swift
  16. 23
      Clocker/Panel/PanelController.swift
  17. 86
      Clocker/Panel/ParentPanelController.swift
  18. 4
      Clocker/Panel/Rate Controller/ReviewController.swift
  19. 6
      Clocker/Panel/UI/TimezoneCellView.swift
  20. 2
      Clocker/Panel/UI/TimezoneDataSource.swift
  21. 20
      Clocker/Panel/Upcoming Events/ParentPanelController+UpcomingEvents.swift
  22. 6
      Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift
  23. 10
      Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift
  24. 6
      Clocker/Preferences/About/AboutViewController.swift
  25. 19
      Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift
  26. 14
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  27. 6
      Clocker/Preferences/Calendar/CalendarViewController.swift
  28. 7
      Clocker/Preferences/General/PreferencesDataSource.swift
  29. 21
      Clocker/Preferences/General/PreferencesViewController.swift
  30. 6
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  31. 2
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  32. 5
      Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

2
Clocker/AppDelegate.swift

@ -16,7 +16,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
panelObserver?.invalidate()
}
override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
if let path = keyPath, path == PreferencesConstants.hotKeyPathIdentifier {
let hotKeyCenter = PTHotKeyCenter.shared()

1
Clocker/ClockerUITests/PermissionsTests.swift

@ -78,5 +78,4 @@ class PermissionsTests: XCTestCase {
return false
}
}
}

4
Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift

@ -1,12 +1,11 @@
// Copyright © 2015 Abhishek Banthia
import XCTest
import CoreModelKit
import XCTest
@testable import Clocker
class StandardMenubarHandlerTests: XCTestCase {
private let mumbai = ["customLabel": "Ghar",
"formattedAddress": "Mumbai",
"place_id": "ChIJwe1EZjDG5zsRaYxkjY_tpF0",
@ -75,5 +74,4 @@ class StandardMenubarHandlerTests: XCTestCase {
// Test menubar string is absent
XCTAssertTrue(menubarString.count == 0)
}
}

8
Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -85,7 +85,7 @@ public class TimezoneData: NSObject, NSCoding {
public var isSystemTimezone = false
public var overrideFormat: TimezoneOverride = .globalFormat
override public init() {
public override init() {
selectionType = .timezone
isFavourite = 0
note = ModelConstants.emptyString
@ -277,7 +277,7 @@ public class TimezoneData: NSObject, NSCoding {
return formatInString.contains("ss")
}
override public var hash: Int {
public override var hash: Int {
guard let placeIdentifier = placeID, let timezone = timezoneID else {
return -1
}
@ -289,14 +289,14 @@ public class TimezoneData: NSObject, NSCoding {
return lhs.placeID == rhs.placeID
}
override public func isEqual(to object: Any?) -> Bool {
public override func isEqual(to object: Any?) -> Bool {
if let other = object as? TimezoneData {
return placeID == other.placeID
}
return false
}
override public func isEqual(_ object: Any?) -> Bool {
public override func isEqual(_ object: Any?) -> Bool {
guard let compared = object as? TimezoneData else {
return false
}

6
Clocker/Dependencies/Date Additions/TimePeriodChain.swift

@ -138,15 +138,15 @@ open class TimePeriodChain: TimePeriodGroup {
_end = _end?.addingTimeInterval(duration)
}
override public func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
public override func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
return try periods.map(transform)
}
override public func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
public override func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
return try periods.filter(isIncluded)
}
override internal func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result {
internal override func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result {
return try periods.reduce(initialResult, nextPartialResult)
}

11
Clocker/Events and Reminders/CalendarHandler.swift

@ -176,7 +176,7 @@ extension EventCenter {
}
// If there are no accepted events, prefer the first optional event
if acceptedEvents.isEmpty && !optionalEvents.isEmpty {
if acceptedEvents.isEmpty, !optionalEvents.isEmpty {
return optionalEvents.first
}
@ -413,8 +413,7 @@ extension EventCenter {
|| actualLink.contains("indigo.collocall.de")
|| actualLink.contains("public.senfcall.de")
|| actualLink.contains("youcanbook.me/zoom/")
|| actualLink.contains("workplace.com/groupcall")
{
|| actualLink.contains("workplace.com/groupcall") {
if let zoomLink = result.url {
return zoomLink
}
@ -426,7 +425,7 @@ extension EventCenter {
private func retrieveMeetingURL(_ event: EKEvent) -> URL? {
if EventCenter.dataDetector == nil {
var dataDetector: NSDataDetector? = nil
var dataDetector: NSDataDetector?
do {
dataDetector = try NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
} catch {
@ -485,8 +484,8 @@ struct EventInfo {
func metadataForMeeting() -> String {
let timeIntervalSinceNowForMeeting = event.startDate.timeIntervalSinceNow
if (timeIntervalSinceNowForMeeting < 0 && timeIntervalSinceNowForMeeting > -300) {
return "started \(event.startDate.shortTimeAgoSinceNow) ago."
if timeIntervalSinceNowForMeeting < 0, timeIntervalSinceNowForMeeting > -300 {
return "started \(event.startDate.shortTimeAgoSinceNow) ago."
} else {
let timeSince = Date().timeAgo(since: event.startDate)
let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString)

3
Clocker/Events and Reminders/RemindersHandler.swift

@ -51,8 +51,7 @@ extension EventCenter {
timezone: String,
alertIndex: Int,
reminderDate: Date,
additionalNotes: String?) -> Bool
{
additionalNotes: String?) -> Bool {
initializeStoreIfNeccesary()
if reminderAccessNotDetermined() || reminderAccessDenied() {

6
Clocker/Menu Bar/StatusContainerView.swift

@ -31,12 +31,10 @@ func compactWidth(for timezone: TimezoneData) -> Int {
if timeFormat == DateFormat.twelveHour
|| timeFormat == DateFormat.twelveHourWithSeconds
|| timeFormat == DateFormat.twelveHourWithZero
|| timeFormat == DateFormat.twelveHourWithSeconds
{
|| timeFormat == DateFormat.twelveHourWithSeconds {
totalWidth += 20
} else if timeFormat == DateFormat.twentyFourHour
|| timeFormat == DateFormat.twentyFourHourWithSeconds
{
|| timeFormat == DateFormat.twentyFourHourWithSeconds {
totalWidth += 0
}

2
Clocker/Menu Bar/StatusItemHandler.swift

@ -185,7 +185,7 @@ class StatusItemHandler: NSObject {
if let strongSelf = self {
strongSelf.performTimerWork()
}
})
})
// Tolerance, even a small amount, has a positive imapct on the power usage. As a rule, we set it to 10% of the interval
menubarTimer?.tolerance = shouldDisplaySeconds ? 0.5 : 20

10
Clocker/Onboarding/OnboardingSearchController.swift

@ -27,8 +27,8 @@ class OnboardingSearchController: NSViewController {
private var geocodingKey: String = {
guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"),
let dictionary = NSDictionary(contentsOfFile: path),
let apiKey = dictionary["GeocodingKey"] as? String
let dictionary = NSDictionary(contentsOfFile: path),
let apiKey = dictionary["GeocodingKey"] as? String
else {
assertionFailure("Unable to find the API key")
return ""
@ -61,7 +61,7 @@ class OnboardingSearchController: NSViewController {
resultsTableView.reloadData()
func setupUndoButton() {
let font = NSFont(name: "Avenir", size: 13) ?? NSFont.systemFont(ofSize: 13)
let font = NSFont(name: "Avenir", size: 13) ?? NSFont.systemFont(ofSize: 13)
let attributes = [NSAttributedString.Key.foregroundColor: NSColor.linkColor,
NSAttributedString.Key.font: font]
undoButton.attributedTitle = NSAttributedString(string: "UNDO", attributes: attributes)
@ -375,7 +375,7 @@ class OnboardingSearchController: NSViewController {
self.findLocalSearchResultsForTimezones()
self.prepareUIForPresentingResults()
}
})
})
}
private func presentErrorMessage(_ errorMessage: String) {
@ -518,6 +518,6 @@ extension OnboardingSearchController: NSSearchFieldDelegate {
}
func searchFieldDidEndSearching(_ sender: NSSearchField) {
self.search(sender)
search(sender)
}
}

11
Clocker/Overall App/ConfigExport.swift

@ -1,10 +1,9 @@
// Copyright © 2015 Abhishek Banthia
import Foundation
import CoreModelKit
import Foundation
struct ConfigExport {
private func generateJSONFromDefaults() {
let selectedKeys: Set<String> = Set([
CLShowOnboardingFlow,
@ -30,10 +29,10 @@ struct ConfigExport {
CLDefaultMenubarMode,
CLInstallHomeIndicatorObject,
CLSwitchToCompactModeAlert,
CLDisplayDSTTransitionInfo
CLDisplayDSTTransitionInfo,
])
let dictionaryRep = UserDefaults.standard.dictionaryRepresentation()
var clockerPrefs: [String:Any] = [:]
var clockerPrefs: [String: Any] = [:]
for (key, value) in dictionaryRep {
if selectedKeys.contains(key) {
print("Key is \(key) and value is \(value)")
@ -60,7 +59,7 @@ struct ConfigExport {
}
let timezoneDict = ["Timezones": decodeJSON]
clockerPrefs.merge(timezoneDict) { (current, _) in current}
clockerPrefs.merge(timezoneDict) { current, _ in current }
guard let documentDirectoryUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
let fileUrl = documentDirectoryUrl.appendingPathComponent("Persons.json")
@ -77,7 +76,5 @@ struct ConfigExport {
} catch {
print("Failure Observed \(error.localizedDescription)")
}
}
}

2
Clocker/Overall App/NetworkManager.swift

@ -41,7 +41,7 @@ extension NetworkManager {
let session = URLSession(configuration: configuration)
guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: encodedPath)
let url = URL(string: encodedPath)
else {
completionHandler(nil, unableToGenerateURL)
return nil

4
Clocker/Overall App/Themer.swift

@ -210,8 +210,8 @@ extension Themer {
return
themeIndex == .light
? NSImage(named: NSImage.Name("Settings"))!
: NSImage(named: NSImage.Name("Settings-White"))!
? NSImage(named: NSImage.Name("Settings"))!
: NSImage(named: NSImage.Name("Settings-White"))!
}
func pinImage() -> NSImage {

2
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -368,7 +368,7 @@ extension TimezoneDataOperations {
to: Date())
guard let lat = dataObject.latitude,
let long = dataObject.longitude
let long = dataObject.longitude
else {
assertionFailure("Data was unexpectedly nil.")
return

8
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -224,7 +224,7 @@ class NotesPopover: NSViewController {
}
completionHandler(completedDate)
})
})
} catch {
assertionFailure("Failed to successfully initialize DataDetector")
completionHandler(nil)
@ -322,8 +322,7 @@ class NotesPopover: NSViewController {
}
private func updateTimezoneInDefaultPreferences(with override: Int,
_: OverrideType)
{
_: OverrideType) {
let timezones = DataStore.shared().timezones()
var timezoneObjects: [TimezoneData] = []
@ -392,8 +391,7 @@ class NotesPopover: NSViewController {
timezone: model.timezone(),
alertIndex: alertIndex,
reminderDate: reminderPicker.dateValue,
additionalNotes: model.note)
{
additionalNotes: model.note) {
showSuccessMessage()
}
}

23
Clocker/Panel/PanelController.swift

@ -153,8 +153,7 @@ class PanelController: ParentPanelController {
}
if let statusWindow = statusBackgroundWindow,
let statusButton = statusView
{
let statusButton = statusView {
var statusItemFrame = statusWindow.convertToScreen(statusButton.frame)
var statusItemScreen = NSScreen.main
var testPoint = statusItemFrame.origin
@ -186,16 +185,16 @@ class PanelController: ParentPanelController {
let preferences = DataStore.shared().timezones()
guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
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 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,
let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber,
let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber,
let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String,
let country = Locale.autoupdatingCurrent.regionCode
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 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,
let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber,
let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber,
let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String,
let country = Locale.autoupdatingCurrent.regionCode
else {
return
}

86
Clocker/Panel/ParentPanelController.swift

@ -433,9 +433,8 @@ class ParentPanelController: NSWindowController {
if let note = object?.note, note.isEmpty == false {
newHeight += 20
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil
{
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil {
newHeight += 20
}
}
@ -496,20 +495,18 @@ class ParentPanelController: NSWindowController {
}
}
if DataStore.shared().shouldDisplay(.futureSlider) {
let isModernSliderDisplayed = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber ?? 0
if isModernSliderDisplayed == 0 {
if scrollViewHeight.constant >= (screenHeight() - 200) {
scrollViewHeight.constant = (screenHeight() - 300)
}
} else {
if scrollViewHeight.constant >= (screenHeight() - 200) {
scrollViewHeight.constant = (screenHeight() - 200)
}
if DataStore.shared().shouldDisplay(.futureSlider) {
let isModernSliderDisplayed = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber ?? 0
if isModernSliderDisplayed == 0 {
if scrollViewHeight.constant >= (screenHeight() - 200) {
scrollViewHeight.constant = (screenHeight() - 300)
}
} else {
if scrollViewHeight.constant >= (screenHeight() - 200) {
scrollViewHeight.constant = (screenHeight() - 200)
}
}
}
}
}
func updateDefaultPreferences() {
@ -624,9 +621,8 @@ class ParentPanelController: NSWindowController {
let current = preferences[$0]
if $0 < mainTableView.numberOfRows,
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current)
{
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current) {
if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true {
return
}
@ -646,8 +642,7 @@ class ParentPanelController: NSWindowController {
if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue)
{
let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
cellView.noteLabel.stringValue = value
} else {
cellView.noteLabel.stringValue = CLEmptyString
@ -723,26 +718,26 @@ class ParentPanelController: NSWindowController {
}
@IBAction func dismissNextEventLabel(_: NSButton) {
let eventCenter = EventCenter.sharedCenter()
let now = Date()
if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false {
if let upcomingEvent = eventCenter.nextOccuring(events), let meetingLink = upcomingEvent.meetingURL {
NSWorkspace.shared.open(meetingLink)
}
} else {
removeUpcomingEventView()
}
let eventCenter = EventCenter.sharedCenter()
let now = Date()
if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false {
if let upcomingEvent = eventCenter.nextOccuring(events), let meetingLink = upcomingEvent.meetingURL {
NSWorkspace.shared.open(meetingLink)
}
} else {
removeUpcomingEventView()
}
}
func removeUpcomingEventView() {
OperationQueue.main.addOperation {
if self.upcomingEventCollectionView != nil {
if self.stackView.arrangedSubviews.contains(self.upcomingEventContainerView!), self.upcomingEventContainerView?.isHidden == false {
self.upcomingEventContainerView?.isHidden = true
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView)
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View")
}
} else if self.stackView.arrangedSubviews.contains(self.upcomingEventView!), self.upcomingEventView?.isHidden == false {
if self.upcomingEventCollectionView != nil {
if self.stackView.arrangedSubviews.contains(self.upcomingEventContainerView!), self.upcomingEventContainerView?.isHidden == false {
self.upcomingEventContainerView?.isHidden = true
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView)
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View")
}
} else if self.stackView.arrangedSubviews.contains(self.upcomingEventView!), self.upcomingEventView?.isHidden == false {
self.upcomingEventView?.isHidden = true
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView)
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View")
@ -752,8 +747,7 @@ class ParentPanelController: NSWindowController {
@IBAction func calendarButtonAction(_: NSButton) {
if calendarButton.title == NSLocalizedString("Click here to start.",
comment: "Button Title for no Calendar access")
{
comment: "Button Title for no Calendar access") {
showPermissionsWindow()
} else {
retrieveCalendarEvents()
@ -844,13 +838,12 @@ class ParentPanelController: NSWindowController {
if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false {
OperationQueue.main.addOperation {
if self.upcomingEventCollectionView != nil,
let upcomingEvents = eventCenter.upcomingEventsForDay(events) {
let upcomingEvents = eventCenter.upcomingEventsForDay(events) {
self.upcomingEventsDataSource.updateEventsDataSource(upcomingEvents)
self.upcomingEventCollectionView.reloadData()
return
}
guard let upcomingEvent = eventCenter.nextOccuring(events) else {
self.setPlaceholdersForUpcomingCalendarView()
if #available(OSX 10.14, *) {
@ -882,9 +875,9 @@ class ParentPanelController: NSWindowController {
}
}
} else {
if self.upcomingEventCollectionView != nil {
self.upcomingEventsDataSource.updateEventsDataSource([])
self.upcomingEventCollectionView.reloadData()
if upcomingEventCollectionView != nil {
upcomingEventsDataSource.updateEventsDataSource([])
upcomingEventCollectionView.reloadData()
return
}
@ -1071,7 +1064,7 @@ class ParentPanelController: NSWindowController {
@objc func openCrowdin() {
guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink),
let languageCode = Locale.preferredLanguages.first else { return }
let languageCode = Locale.preferredLanguages.first else { return }
NSWorkspace.shared.open(localizationURL)
@ -1154,8 +1147,7 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
let timezones = DataStore.shared().timezones()
stride(from: 0, to: timezones.count, by: 1).forEach {
if $0 < mainTableView.numberOfRows,
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView
{
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView {
clipboardCopy.append("\(cellView.customName.stringValue) - \(cellView.time.stringValue)\n")
}
}

4
Clocker/Panel/Rate Controller/ReviewController.swift

@ -42,12 +42,12 @@ final class ReviewController {
// Check if the app has been installed for atleast 7 days
guard let install = storage.object(forKey: Keys.install) as? Date,
install.timeIntervalSinceNow < minInstall
install.timeIntervalSinceNow < minInstall
else { return false }
// If we have never been prompted before, go ahead and prompt
guard let lastPrompt = storage.object(forKey: Keys.lastPrompt) as? Date,
let lastVersion = storage.object(forKey: Keys.lastVersion) as? String
let lastVersion = storage.object(forKey: Keys.lastVersion) as? String
else { return true }
// Minimum interval between two versions should be 45

6
Clocker/Panel/UI/TimezoneCellView.swift

@ -39,7 +39,7 @@ class TimezoneCellView: NSTableCellView {
func setupLayout() {
guard let relativeFont = relativeDate.font,
let sunriseFont = sunriseSetTime.font
let sunriseFont = sunriseSetTime.font
else {
assertionFailure("Unable to convert to NSString")
return
@ -128,7 +128,7 @@ class TimezoneCellView: NSTableCellView {
}
guard let customFont = customName.font,
let timeFont = time.font
let timeFont = time.font
else {
assertionFailure("User Font Size is in unexpectedly nil")
return
@ -165,7 +165,7 @@ class TimezoneCellView: NSTableCellView {
}
guard let panelTableView = searchView as? PanelTableView,
let enclosingScroller = panelTableView.enclosingScrollView
let enclosingScroller = panelTableView.enclosingScrollView
else {
// We might be coming from the preview tableview!
return

2
Clocker/Panel/UI/TimezoneDataSource.swift

@ -144,7 +144,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
panelController.deleteTimezone(at: row)
}
})
})
if #available(OSX 11.0, *) {
swipeToDelete.image = Themer.shared().filledTrashImage()

20
Clocker/Panel/Upcoming Events/ParentPanelController+UpcomingEvents.swift

@ -10,15 +10,15 @@ var avenirLightFont: NSFont {
}
protocol UpcomingEventPanelDelegate: AnyObject {
func didRemoveCalendarView()
func didClickSupplementaryButton(_ sender: NSButton)
func didRemoveCalendarView()
func didClickSupplementaryButton(_ sender: NSButton)
}
extension ParentPanelController {
func setupUpcomingEventViewCollectionViewIfNeccesary() {
if upcomingEventCollectionView != nil {
upcomingEventsDataSource = UpcomingEventsDataSource(self)
upcomingEventCollectionView.enclosingScrollView?.scrollerInsets = NSEdgeInsetsZero
upcomingEventsDataSource = UpcomingEventsDataSource(self)
upcomingEventCollectionView.enclosingScrollView?.scrollerInsets = NSEdgeInsetsZero
upcomingEventCollectionView.enclosingScrollView?.backgroundColor = NSColor.clear
upcomingEventCollectionView.setAccessibility("UpcomingEventCollectionView")
upcomingEventCollectionView.dataSource = upcomingEventsDataSource
@ -28,11 +28,11 @@ extension ParentPanelController {
}
extension ParentPanelController: UpcomingEventPanelDelegate {
func didRemoveCalendarView() {
removeUpcomingEventView()
}
func didRemoveCalendarView() {
removeUpcomingEventView()
}
func didClickSupplementaryButton(_ sender: NSButton) {
calendarButtonAction(sender)
}
func didClickSupplementaryButton(_ sender: NSButton) {
calendarButtonAction(sender)
}
}

6
Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift

@ -39,7 +39,7 @@ class UpcomingEventViewItem: NSCollectionViewItem {
}
}
func setupUndeterminedState(_ delegate: UpcomingEventPanelDelegate?) {
func setupUndeterminedState(_ delegate: UpcomingEventPanelDelegate?) {
if leadingConstraint.constant != 10 {
leadingConstraint.constant = 10
}
@ -70,14 +70,14 @@ class UpcomingEventViewItem: NSCollectionViewItem {
}
@IBAction func calendarButtonAction(_ sender: NSButton) {
panelDelegate?.didClickSupplementaryButton(sender)
panelDelegate?.didClickSupplementaryButton(sender)
}
@objc func zoomButtonAction(_: Any) {
if let meetingURL = meetingLink {
NSWorkspace.shared.open(meetingURL)
} else {
panelDelegate?.didRemoveCalendarView()
panelDelegate?.didRemoveCalendarView()
}
}
}

10
Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift

@ -4,12 +4,12 @@ import Foundation
class UpcomingEventsDataSource: NSObject, NSCollectionViewDataSource, NSCollectionViewDelegateFlowLayout {
private var upcomingEvents: [EventInfo] = []
private weak var delegate: UpcomingEventPanelDelegate?
private weak var delegate: UpcomingEventPanelDelegate?
init(_ panelDelegate: UpcomingEventPanelDelegate?) {
super.init()
delegate = panelDelegate
}
init(_ panelDelegate: UpcomingEventPanelDelegate?) {
super.init()
delegate = panelDelegate
}
func updateEventsDataSource(_ events: [EventInfo]) {
upcomingEvents = events

6
Clocker/Preferences/About/AboutViewController.swift

@ -98,7 +98,7 @@ class AboutViewController: ParentViewController {
@IBAction func openMyTwitter(_: Any) {
guard let twitterURL = URL(string: AboutUsConstants.TwitterLink),
let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
NSWorkspace.shared.open(twitterURL)
@ -109,7 +109,7 @@ class AboutViewController: ParentViewController {
@IBAction func viewSource(_: Any) {
guard let sourceURL = URL(string: AboutUsConstants.AppStoreLink),
let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
NSWorkspace.shared.open(sourceURL)
@ -131,7 +131,7 @@ class AboutViewController: ParentViewController {
@IBAction func openGitHub(_: Any) {
guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink),
let languageCode = Locale.preferredLanguages.first else { return }
let languageCode = Locale.preferredLanguages.first else { return }
NSWorkspace.shared.open(localizationURL)

19
Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift

@ -127,7 +127,7 @@ class AppFeedbackWindowController: NSWindowController {
let cleanedUpString = feedbackTextView.string.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
if cleanedUpString.isEmpty {
self.window?.contentView?.makeToast(AppFeedbackConstants.CLFeedbackNotEnteredErrorMessage)
window?.contentView?.makeToast(AppFeedbackConstants.CLFeedbackNotEnteredErrorMessage)
isActivityInProgress = false
return false
}
@ -139,9 +139,9 @@ class AppFeedbackWindowController: NSWindowController {
let preferences = DataStore.shared().timezones()
guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let country = Locale.autoupdatingCurrent.regionCode
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let country = Locale.autoupdatingCurrent.regionCode
else {
return "Error"
}
@ -150,7 +150,7 @@ class AppFeedbackWindowController: NSWindowController {
guard let timezoneObject = TimezoneData.customObject(from: data) else {
return nil
}
return "Timezone: \(timezoneObject.timezone()) Name: \(timezoneObject.formattedAddress ?? "No") Favourited: \((timezoneObject.isFavourite == 1) ? "Yes": "No") Note: \(timezoneObject.note ?? "No Note") System: \(timezoneObject.isSystemTimezone ? "Yes": "No")"
return "Timezone: \(timezoneObject.timezone()) Name: \(timezoneObject.formattedAddress ?? "No") Favourited: \((timezoneObject.isFavourite == 1) ? "Yes" : "No") Note: \(timezoneObject.note ?? "No Note") System: \(timezoneObject.isSystemTimezone ? "Yes" : "No")"
}
var relativeDate = "Relative"
@ -176,14 +176,13 @@ class AppFeedbackWindowController: NSWindowController {
}
return """
"Theme: \(themeInfo), "Display Future Slider": \(futureSlider), "Relative Date": \(relativeDate), "Country": \(country), "Timezones": \(selectedTimezones)
"""
"Theme: \(themeInfo), "Display Future Slider": \(futureSlider), "Relative Date": \(relativeDate), "Country": \(country), "Timezones": \(selectedTimezones)
"""
}
private func retrieveDataForSending() -> [String: String] {
guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
else {
return [:]
}
@ -286,7 +285,7 @@ class AppFeedbackWindowController: NSWindowController {
@IBAction func navigateToSupportTwitter(_: Any) {
guard let twitterURL = URL(string: AboutUsConstants.TwitterLink),
let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
NSWorkspace.shared.open(twitterURL)

14
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -63,9 +63,7 @@ class AppearanceViewController: ParentViewController {
"7 days",
])
if #available(macOS 11.0, *) {
} else {
if #available(macOS 11.0, *) {} else {
theme.font = NSFont.systemFont(ofSize: 13)
}
@ -126,8 +124,7 @@ class AppearanceViewController: ParentViewController {
sliderDayRangePopup.selectItem(at: selectedIndex.intValue)
}
if #available(macOS 10.14, *) {
} else {
if #available(macOS 10.14, *) {} else {
theme.removeItem(at: 2)
}
@ -153,7 +150,7 @@ class AppearanceViewController: ParentViewController {
@IBOutlet var menubarModeLabel: NSTextField!
@IBOutlet var previewLabel: NSTextField!
@IBOutlet var miscelleaneousLabel: NSTextField!
@IBOutlet weak var dstTransitionField: NSTextField!
@IBOutlet var dstTransitionField: NSTextField!
// Panel Preview
@IBOutlet var previewPanelTableView: NSTableView!
@ -181,7 +178,7 @@ class AppearanceViewController: ParentViewController {
$0?.textColor = Themer.shared().mainTextColor()
}
self.previewPanelTableView.backgroundColor = Themer.shared().mainBackgroundColor()
previewPanelTableView.backgroundColor = Themer.shared().mainBackgroundColor()
}
@IBAction func timeFormatSelectionChanged(_ sender: NSPopUpButton) {
@ -191,8 +188,7 @@ class AppearanceViewController: ParentViewController {
refresh(panel: true, floating: true)
if let selectedFormat = sender.selectedItem?.title,
selectedFormat.contains("ss")
{
selectedFormat.contains("ss") {
print("Seconds are contained")
guard let panelController = PanelController.panel() else { return }
panelController.pauseTimer()

6
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -243,15 +243,13 @@ extension CalendarViewController: NSTableViewDelegate {
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
if let currentSource = calendars[row] as? String,
let message = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "sourceCellView"), owner: self) as? SourceTableViewCell
{
let message = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "sourceCellView"), owner: self) as? SourceTableViewCell {
message.sourceName.stringValue = currentSource
return message
}
if let currentSource = calendars[row] as? CalendarInfo,
let calendarCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "calendarCellView"), owner: self) as? CalendarTableViewCell
{
let calendarCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "calendarCellView"), owner: self) as? CalendarTableViewCell {
calendarCell.calendarName.stringValue = currentSource.calendar.title
calendarCell.calendarSelected.state = currentSource.selected ? NSControl.StateValue.on : NSControl.StateValue.off
calendarCell.calendarSelected.target = self

7
Clocker/Preferences/General/PreferencesDataSource.swift

@ -104,8 +104,7 @@ extension PreferencesDataSource: NSTableViewDataSource {
var selectedDataSource: TimezoneData?
if selectedTimezones.count > row,
let model = TimezoneData.customObject(from: selectedTimezones[row])
{
let model = TimezoneData.customObject(from: selectedTimezones[row]) {
selectedDataSource = model
}
@ -164,7 +163,7 @@ extension PreferencesDataSource: NSTableViewDataSource {
"Old Label": dataObject.customLabel ?? "Error",
"New Label": formattedValue,
],
for: "Custom Label Changed")
for: "Custom Label Changed")
dataObject.setLabel(formattedValue)
@ -177,7 +176,7 @@ extension PreferencesDataSource: NSTableViewDataSource {
"Selected Timezone Count": selectedTimezones.count,
"Current Row": row,
],
for: "Error in selected row count")
for: "Error in selected row count")
}
}

21
Clocker/Preferences/General/PreferencesViewController.swift

@ -42,8 +42,8 @@ class PreferencesViewController: ParentViewController {
private var geocodingKey: String = {
guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"),
let dictionary = NSDictionary(contentsOfFile: path),
let apiKey = dictionary["GeocodingKey"] as? String
let dictionary = NSDictionary(contentsOfFile: path),
let apiKey = dictionary["GeocodingKey"] as? String
else {
// assertionFailure("Unable to find the API key")
return ""
@ -338,10 +338,9 @@ extension PreferencesViewController: NSTableViewDataSource, NSTableViewDelegate
for: "favouriteRemoved")
if let appDelegate = NSApplication.shared.delegate as? AppDelegate,
let menubarFavourites = DataStore.shared().menubarTimezones(),
menubarFavourites.isEmpty,
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false
{
let menubarFavourites = DataStore.shared().menubarTimezones(),
menubarFavourites.isEmpty,
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false {
appDelegate.invalidateMenubarTimer(true)
}
@ -459,7 +458,7 @@ extension PreferencesViewController {
self.prepareUIForPresentingResults()
}
})
})
}
}
@ -884,7 +883,7 @@ extension PreferencesViewController {
let system = NSTimeZone.system
guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2)
let object2 = TimezoneData.customObject(from: obj2)
else {
assertionFailure("Data was unexpectedly nil")
return false
@ -912,7 +911,7 @@ extension PreferencesViewController {
let sortedLabels = selectedTimeZones.sorted { obj1, obj2 -> Bool in
guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2)
let object2 = TimezoneData.customObject(from: obj2)
else {
assertionFailure("Data was unexpectedly nil")
return false
@ -936,7 +935,7 @@ extension PreferencesViewController {
let sortedByAddress = selectedTimeZones.sorted { obj1, obj2 -> Bool in
guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2)
let object2 = TimezoneData.customObject(from: obj2)
else {
assertionFailure("Data was unexpectedly nil")
return false
@ -1003,7 +1002,7 @@ extension PreferencesViewController: PreferenceSelectionUpdates {
let sortedTimezones = selectedTimeZones.sorted { obj1, obj2 -> Bool in
guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2)
let object2 = TimezoneData.customObject(from: obj2)
else {
assertionFailure("Data was unexpectedly nil")
return false

6
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -33,12 +33,10 @@ func compactWidth(for timezone: TimezoneData) -> Int {
if timeFormat == DateFormat.twelveHour
|| timeFormat == DateFormat.twelveHourWithSeconds
|| timeFormat == DateFormat.twelveHourWithZero
|| timeFormat == DateFormat.twelveHourWithSeconds
{
|| timeFormat == DateFormat.twelveHourWithSeconds {
totalWidth += 20
} else if timeFormat == DateFormat.twentyFourHour
|| timeFormat == DateFormat.twentyFourHourWithSeconds
{
|| timeFormat == DateFormat.twentyFourHourWithSeconds {
totalWidth += 0
}

2
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -188,7 +188,7 @@ class StatusItemHandler: NSObject {
if let strongSelf = self {
strongSelf.refresh()
}
})
})
// Tolerance, even a small amount, has a positive imapct on the power usage. As a rule, we set it to 10% of the interval
menubarTimer?.tolerance = shouldDisplaySeconds ? 0.5 : 20

5
Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

@ -1,7 +1,7 @@
// Copyright © 2015 Abhishek Banthia
import Foundation
import AppKit
import Foundation
class UpcomingEventStatusItemView: NSView {
static let containerWidth = 70
@ -13,6 +13,7 @@ class UpcomingEventStatusItemView: NSView {
initialSetup()
}
}
private var timeAttributes: [NSAttributedString.Key: AnyObject] {
let textColor = hasDarkAppearance ? NSColor.white : NSColor.black
@ -64,7 +65,7 @@ class UpcomingEventStatusItemView: NSView {
])
}
required init?(coder: NSCoder) {
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Loading…
Cancel
Save