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. 9
      Clocker/Events and Reminders/CalendarHandler.swift
  7. 3
      Clocker/Events and Reminders/RemindersHandler.swift
  8. 6
      Clocker/Menu Bar/StatusContainerView.swift
  9. 2
      Clocker/Onboarding/OnboardingSearchController.swift
  10. 11
      Clocker/Overall App/ConfigExport.swift
  11. 6
      Clocker/Panel/Notes Popover/NotesPopover.swift
  12. 3
      Clocker/Panel/PanelController.swift
  13. 24
      Clocker/Panel/ParentPanelController.swift
  14. 5
      Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift
  15. 14
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  16. 6
      Clocker/Preferences/Calendar/CalendarViewController.swift
  17. 3
      Clocker/Preferences/General/PreferencesDataSource.swift
  18. 3
      Clocker/Preferences/General/PreferencesViewController.swift
  19. 6
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  20. 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)
}

9
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,7 +484,7 @@ struct EventInfo {
func metadataForMeeting() -> String {
let timeIntervalSinceNowForMeeting = event.startDate.timeIntervalSinceNow
if (timeIntervalSinceNowForMeeting < 0 && timeIntervalSinceNowForMeeting > -300) {
if timeIntervalSinceNowForMeeting < 0, timeIntervalSinceNowForMeeting > -300 {
return "started \(event.startDate.shortTimeAgoSinceNow) ago."
} else {
let timeSince = Date().timeAgo(since: event.startDate)

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/Onboarding/OnboardingSearchController.swift

@ -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)")
}
}
}

6
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -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()
}
}

3
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

24
Clocker/Panel/ParentPanelController.swift

@ -434,8 +434,7 @@ class ParentPanelController: NSWindowController {
newHeight += 20
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil
{
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil {
newHeight += 20
}
}
@ -507,8 +506,6 @@ class ParentPanelController: NSWindowController {
scrollViewHeight.constant = (screenHeight() - 200)
}
}
}
}
@ -625,8 +622,7 @@ class ParentPanelController: NSWindowController {
if $0 < mainTableView.numberOfRows,
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current)
{
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
@ -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()
@ -850,7 +844,6 @@ class ParentPanelController: NSWindowController {
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
}
@ -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")
}
}

5
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
}
@ -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"
@ -178,7 +178,6 @@ class AppFeedbackWindowController: NSWindowController {
return """
"Theme: \(themeInfo), "Display Future Slider": \(futureSlider), "Relative Date": \(relativeDate), "Country": \(country), "Timezones": \(selectedTimezones)
"""
}
private func retrieveDataForSending() -> [String: String] {

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

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

3
Clocker/Preferences/General/PreferencesViewController.swift

@ -340,8 +340,7 @@ extension PreferencesViewController: NSTableViewDataSource, NSTableViewDelegate
if let appDelegate = NSApplication.shared.delegate as? AppDelegate,
let menubarFavourites = DataStore.shared().menubarTimezones(),
menubarFavourites.isEmpty,
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false
{
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false {
appDelegate.invalidateMenubarTimer(true)
}

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
}

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