Browse Source

Move to Constants enum.

master
Abhishek Banthia 9 months ago
parent
commit
bb0e0120a7
  1. 6
      Clocker/Overall App/UserDefaults + KVOExtensions.swift
  2. 34
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  3. 2
      Clocker/Panel/Notes Popover/NotesPopover.swift
  4. 2
      Clocker/Panel/Notes Popover/TextViewWithPlaceholder.swift
  5. 22
      Clocker/Panel/PanelController.swift
  6. 6
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  7. 22
      Clocker/Panel/ParentPanelController.swift
  8. 2
      Clocker/Panel/Rate Controller/ReviewController.swift
  9. 4
      Clocker/Panel/UI/TimezoneCellView.swift
  10. 10
      Clocker/Panel/UI/TimezoneDataSource.swift
  11. 2
      Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift
  12. 12
      Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift
  13. 12
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  14. 8
      Clocker/Preferences/Calendar/CalendarViewController.swift
  15. 56
      Clocker/Preferences/General/PreferencesViewController.swift
  16. 6
      Clocker/Preferences/Menu Bar/MenubarTitleProvider.swift
  17. 6
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift

6
Clocker/Overall App/UserDefaults + KVOExtensions.swift

@ -4,14 +4,14 @@ import Cocoa
extension UserDefaults { extension UserDefaults {
@objc dynamic var displayFutureSlider: Int { @objc dynamic var displayFutureSlider: Int {
return integer(forKey: CLDisplayFutureSliderKey) return integer(forKey: UserDefaultKeys.displayFutureSliderKey)
} }
@objc dynamic var userFontSize: Int { @objc dynamic var userFontSize: Int {
return integer(forKey: CLUserFontSizePreference) return integer(forKey: UserDefaultKeys.userFontSizePreference)
} }
@objc dynamic var sliderDayRange: Int { @objc dynamic var sliderDayRange: Int {
return integer(forKey: CLFutureSliderRange) return integer(forKey: UserDefaultKeys.futureSliderRange)
} }
} }

34
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -28,7 +28,7 @@ extension TimezoneDataOperations {
options: .matchFirst) options: .matchFirst)
else { else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return CLEmptyString return UserDefaultKeys.emptyString
} }
if dataObject.timezoneFormat(store.timezoneFormat()) == DateFormat.epochTime { if dataObject.timezoneFormat(store.timezoneFormat()) == DateFormat.epochTime {
@ -81,7 +81,7 @@ extension TimezoneDataOperations {
} }
func compactMenuTitle() -> String { func compactMenuTitle() -> String {
var subtitle = CLEmptyString var subtitle = UserDefaultKeys.emptyString
let shouldLabelBeShownAlongWithTime = !store.shouldDisplay(.placeInMenubar) let shouldLabelBeShownAlongWithTime = !store.shouldDisplay(.placeInMenubar)
@ -105,7 +105,7 @@ extension TimezoneDataOperations {
} }
func compactMenuSubtitle() -> String { func compactMenuSubtitle() -> String {
var subtitle = CLEmptyString var subtitle = UserDefaultKeys.emptyString
let shouldDayBeShown = store.shouldShowDayInMenubar() let shouldDayBeShown = store.shouldShowDayInMenubar()
let shouldLabelsNotBeShownAlongWithTime = store.shouldDisplay(.placeInMenubar) let shouldLabelsNotBeShownAlongWithTime = store.shouldDisplay(.placeInMenubar)
@ -127,7 +127,7 @@ extension TimezoneDataOperations {
} }
func menuTitle() -> String { func menuTitle() -> String {
var menuTitle = CLEmptyString var menuTitle = UserDefaultKeys.emptyString
let dataStore = store let dataStore = store
@ -206,13 +206,13 @@ extension TimezoneDataOperations {
} }
func date(with sliderValue: Int, displayType: TimezoneData.DateDisplayType) -> String { func date(with sliderValue: Int, displayType: TimezoneData.DateDisplayType) -> String {
guard let relativeDayPreference = store.retrieve(key: CLRelativeDateKey) as? NSNumber else { guard let relativeDayPreference = store.retrieve(key: UserDefaultKeys.relativeDateKey) as? NSNumber else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return CLEmptyString return UserDefaultKeys.emptyString
} }
if relativeDayPreference.intValue == 3 { if relativeDayPreference.intValue == 3 {
return CLEmptyString return UserDefaultKeys.emptyString
} }
var currentCalendar = Calendar(identifier: .gregorian) var currentCalendar = Calendar(identifier: .gregorian)
@ -293,24 +293,24 @@ extension TimezoneDataOperations {
"Locale": dateFormatter.locale.identifier, "Locale": dateFormatter.locale.identifier,
] as [String: Any] ] as [String: Any]
Logger.log(object: unableToConvertDateParameters, for: "Date conversion failure - New Date is nil") Logger.log(object: unableToConvertDateParameters, for: "Date conversion failure - New Date is nil")
return CLEmptyString return UserDefaultKeys.emptyString
} }
let timeDifference = local.timeAgo(since: timezoneDate) let timeDifference = local.timeAgo(since: timezoneDate)
if timeDifference.isEmpty { if timeDifference.isEmpty {
return CLEmptyString return UserDefaultKeys.emptyString
} }
if (local as NSDate).earlierDate(timezoneDate) == local { if (local as NSDate).earlierDate(timezoneDate) == local {
var replaceAgo = CLEmptyString var replaceAgo = UserDefaultKeys.emptyString
replaceAgo.append(", +") replaceAgo.append(", +")
let agoString = timezoneDate.timeAgo(since: local, numericDates: true) let agoString = timezoneDate.timeAgo(since: local, numericDates: true)
replaceAgo.append(agoString.replacingOccurrences(of: "ago", with: CLEmptyString)) replaceAgo.append(agoString.replacingOccurrences(of: "ago", with: UserDefaultKeys.emptyString))
if !TimezoneDataOperations.currentLocale.contains("en") { if !TimezoneDataOperations.currentLocale.contains("en") {
if TimezoneDataOperations.currentLocale.contains("de") { if TimezoneDataOperations.currentLocale.contains("de") {
replaceAgo = replaceAgo.replacingOccurrences(of: "Vor ", with: CLEmptyString) replaceAgo = replaceAgo.replacingOccurrences(of: "Vor ", with: UserDefaultKeys.emptyString)
replaceAgo.append(" vor") replaceAgo.append(" vor")
} }
@ -322,15 +322,15 @@ extension TimezoneDataOperations {
return replaceAgo.lowercased() return replaceAgo.lowercased()
} }
var replaceAgo = CLEmptyString var replaceAgo = UserDefaultKeys.emptyString
replaceAgo.append(", -") replaceAgo.append(", -")
let replaced = timeDifference.replacingOccurrences(of: "ago", with: CLEmptyString) let replaced = timeDifference.replacingOccurrences(of: "ago", with: UserDefaultKeys.emptyString)
replaceAgo.append(replaced) replaceAgo.append(replaced)
if !TimezoneDataOperations.currentLocale.contains("en") { if !TimezoneDataOperations.currentLocale.contains("en") {
if TimezoneDataOperations.currentLocale.contains("de") { if TimezoneDataOperations.currentLocale.contains("de") {
replaceAgo = replaceAgo.replacingOccurrences(of: "Vor ", with: CLEmptyString) replaceAgo = replaceAgo.replacingOccurrences(of: "Vor ", with: UserDefaultKeys.emptyString)
replaceAgo.append(" zurück") replaceAgo.append(" zurück")
} }
@ -384,7 +384,7 @@ extension TimezoneDataOperations {
/* We have to call this everytime so that we get an updated value everytime! */ /* We have to call this everytime so that we get an updated value everytime! */
if dataObject.selectionType == .timezone || (dataObject.latitude == nil || dataObject.longitude == nil) { if dataObject.selectionType == .timezone || (dataObject.latitude == nil || dataObject.longitude == nil) {
return CLEmptyString return UserDefaultKeys.emptyString
} }
initializeSunriseSunset(with: sliderValue) initializeSunriseSunset(with: sliderValue)
@ -399,7 +399,7 @@ extension TimezoneDataOperations {
return dateFormatter.string(from: correct) return dateFormatter.string(from: correct)
} }
return CLEmptyString return UserDefaultKeys.emptyString
} }
func todaysDate(with sliderValue: Int, locale: Locale = Locale(identifier: "en-US")) -> String { func todaysDate(with sliderValue: Int, locale: Locale = Locale(identifier: "en-US")) -> String {

2
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -476,7 +476,7 @@ extension NotesPopover {
if let note = model.note, !note.isEmpty { if let note = model.note, !note.isEmpty {
notesTextView.string = note notesTextView.string = note
} else { } else {
notesTextView.string = CLEmptyString notesTextView.string = UserDefaultKeys.emptyString
} }
setInitialReminderTime() setInitialReminderTime()

2
Clocker/Panel/Notes Popover/TextViewWithPlaceholder.swift

@ -32,7 +32,7 @@ class TextViewWithPlaceholder: NSTextView {
override func draw(_ dirtyRect: NSRect) { override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect) super.draw(dirtyRect)
if string == CLEmptyString, self != window?.firstResponder { if string == UserDefaultKeys.emptyString, self != window?.firstResponder {
placeholder.draw(at: NSPoint(x: 0, y: 0)) placeholder.draw(at: NSPoint(x: 0, y: 0))
} }
} }

22
Clocker/Panel/PanelController.swift

@ -82,7 +82,7 @@ class PanelController: ParentPanelController {
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
modernContainerView.isHidden = true modernContainerView.isHidden = true
} else if let value = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber, modernContainerView != nil { } else if let value = DataStore.shared().retrieve(key: UserDefaultKeys.displayFutureSliderKey) as? NSNumber, modernContainerView != nil {
if value.intValue == 1 { if value.intValue == 1 {
modernContainerView.isHidden = true modernContainerView.isHidden = true
} else if value.intValue == 0 { } else if value.intValue == 0 {
@ -185,16 +185,16 @@ class PanelController: ParentPanelController {
let preferences = DataStore.shared().timezones() let preferences = DataStore.shared().timezones()
guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, guard let theme = DataStore.shared().retrieve(key: UserDefaultKeys.themeKey) as? NSNumber,
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, let displayFutureSliderKey = DataStore.shared().retrieve(key: UserDefaultKeys.themeKey) as? NSNumber,
let showAppInForeground = DataStore.shared().retrieve(key: CLShowAppInForeground) as? NSNumber, let showAppInForeground = DataStore.shared().retrieve(key: UserDefaultKeys.showAppInForeground) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber, let relativeDateKey = DataStore.shared().retrieve(key: UserDefaultKeys.relativeDateKey) as? NSNumber,
let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, let fontSize = DataStore.shared().retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber,
let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber, let sunriseTime = DataStore.shared().retrieve(key: UserDefaultKeys.sunriseSunsetTime) as? NSNumber,
let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber, let showDayInMenu = DataStore.shared().retrieve(key: UserDefaultKeys.showDayInMenu) as? NSNumber,
let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber, let showDateInMenu = DataStore.shared().retrieve(key: UserDefaultKeys.showDateInMenu) as? NSNumber,
let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber, let showPlaceInMenu = DataStore.shared().retrieve(key: UserDefaultKeys.showPlaceInMenu) as? NSNumber,
let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String, let showUpcomingEventView = DataStore.shared().retrieve(key: UserDefaultKeys.showUpcomingEventView) as? String,
let country = Locale.autoupdatingCurrent.regionCode let country = Locale.autoupdatingCurrent.regionCode
else { else {
return return

6
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -6,7 +6,7 @@ import Foundation
extension ParentPanelController: NSCollectionViewDataSource { extension ParentPanelController: NSCollectionViewDataSource {
func collectionView(_: NSCollectionView, numberOfItemsInSection _: Int) -> Int { func collectionView(_: NSCollectionView, numberOfItemsInSection _: Int) -> Int {
let futureSliderDayPreference = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber ?? 5 let futureSliderDayPreference = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber ?? 5
let futureSliderDayRange = (futureSliderDayPreference.intValue + 1) let futureSliderDayRange = (futureSliderDayPreference.intValue + 1)
return (PanelConstants.modernSliderPointsInADay * futureSliderDayRange * 2) + 1 return (PanelConstants.modernSliderPointsInADay * futureSliderDayRange * 2) + 1
} }
@ -23,6 +23,8 @@ extension ParentPanelController: NSCollectionViewDataSource {
extension ParentPanelController { extension ParentPanelController {
func setupModernSliderIfNeccessary() { func setupModernSliderIfNeccessary() {
if modernSlider != nil { if modernSlider != nil {
modernSliderLabel.alignment = .center
if #available(OSX 11.0, *) { if #available(OSX 11.0, *) {
resetModernSliderButton.image = Themer.shared().resetModernSliderImage() resetModernSliderButton.image = Themer.shared().resetModernSliderImage()
} else { } else {
@ -159,7 +161,7 @@ extension ParentPanelController {
} }
public func setDefaultDateLabel(_ index: Int) -> Int { public func setDefaultDateLabel(_ index: Int) -> Int {
let futureSliderDayPreference = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber ?? 5 let futureSliderDayPreference = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber ?? 5
let futureSliderDayRange = (futureSliderDayPreference.intValue + 1) let futureSliderDayRange = (futureSliderDayPreference.intValue + 1)
let totalCount = (PanelConstants.modernSliderPointsInADay * futureSliderDayRange * 2) + 1 let totalCount = (PanelConstants.modernSliderPointsInADay * futureSliderDayRange * 2) + 1
let centerPoint = Int(ceil(Double(totalCount / 2))) let centerPoint = Int(ceil(Double(totalCount / 2)))

22
Clocker/Panel/ParentPanelController.swift

@ -218,7 +218,7 @@ class ParentPanelController: NSWindowController {
if modernContainerView != nil { if modernContainerView != nil {
modernContainerView.isHidden = true modernContainerView.isHidden = true
} }
} else if let value = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber { } else if let value = DataStore.shared().retrieve(key: UserDefaultKeys.displayFutureSliderKey) as? NSNumber {
if value.intValue == 1 { if value.intValue == 1 {
if modernContainerView != nil { if modernContainerView != nil {
modernContainerView.isHidden = true modernContainerView.isHidden = true
@ -312,7 +312,7 @@ class ParentPanelController: NSWindowController {
// Setting up Slider's Date Picker // Setting up Slider's Date Picker
sliderDatePicker.minDate = Date() sliderDatePicker.minDate = Date()
guard let sliderRange = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber else { guard let sliderRange = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber else {
sliderDatePicker.maxDate = Date(timeInterval: 1 * 24 * 60 * 60, since: Date()) sliderDatePicker.maxDate = Date(timeInterval: 1 * 24 * 60 * 60, since: Date())
return return
} }
@ -410,7 +410,7 @@ class ParentPanelController: NSWindowController {
} }
private func getAdjustedRowHeight(for object: TimezoneData?, _ currentHeight: CGFloat) -> CGFloat { private func getAdjustedRowHeight(for object: TimezoneData?, _ currentHeight: CGFloat) -> CGFloat {
let userFontSize: NSNumber = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber ?? 4 let userFontSize: NSNumber = DataStore.shared().retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber ?? 4
let shouldShowSunrise = DataStore.shared().shouldDisplay(.sunrise) let shouldShowSunrise = DataStore.shared().shouldDisplay(.sunrise)
var newHeight = currentHeight var newHeight = currentHeight
@ -468,7 +468,7 @@ class ParentPanelController: NSWindowController {
return return
} }
if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber { if let userFontSize = DataStore.shared().retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber {
if userFontSize == 4 { if userFontSize == 4 {
scrollViewHeight.constant = totalHeight + CGFloat(userFontSize.intValue * 2) scrollViewHeight.constant = totalHeight + CGFloat(userFontSize.intValue * 2)
} else { } else {
@ -487,7 +487,7 @@ class ParentPanelController: NSWindowController {
} }
if DataStore.shared().shouldDisplay(.futureSlider) { if DataStore.shared().shouldDisplay(.futureSlider) {
let isModernSliderDisplayed = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber ?? 0 let isModernSliderDisplayed = DataStore.shared().retrieve(key: UserDefaultKeys.displayFutureSliderKey) as? NSNumber ?? 0
if isModernSliderDisplayed == 0 { if isModernSliderDisplayed == 0 {
if scrollViewHeight.constant >= (screenHeight() - 200) { if scrollViewHeight.constant >= (screenHeight() - 200) {
scrollViewHeight.constant = (screenHeight() - 300) scrollViewHeight.constant = (screenHeight() - 300)
@ -529,7 +529,7 @@ class ParentPanelController: NSWindowController {
datasource?.setItems(items: timezones) datasource?.setItems(items: timezones)
datasource?.setSlider(value: futureSliderValue) datasource?.setSlider(value: futureSliderValue)
if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber { if let userFontSize = DataStore.shared().retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber {
scrollViewHeight.constant = CGFloat(timezones.count) * (mainTableView.rowHeight + CGFloat(userFontSize.floatValue * 1.5)) scrollViewHeight.constant = CGFloat(timezones.count) * (mainTableView.rowHeight + CGFloat(userFontSize.floatValue * 1.5))
setScrollViewConstraint() setScrollViewConstraint()
@ -647,7 +647,7 @@ class ParentPanelController: NSWindowController {
} else if let value = TimezoneDataOperations(with: model, store: DataStore.shared()).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) { } else if let value = TimezoneDataOperations(with: model, store: DataStore.shared()).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
cellView.noteLabel.stringValue = value cellView.noteLabel.stringValue = value
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = UserDefaultKeys.emptyString
} }
cellView.layout(with: model) cellView.layout(with: model)
updateDatePicker() updateDatePicker()
@ -657,7 +657,7 @@ class ParentPanelController: NSWindowController {
private func updateDatePicker() { private func updateDatePicker() {
sliderDatePicker.minDate = Date() sliderDatePicker.minDate = Date()
guard let sliderRange = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber else { guard let sliderRange = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber else {
sliderDatePicker.maxDate = Date(timeInterval: 1 * 24 * 60 * 60, since: Date()) sliderDatePicker.maxDate = Date(timeInterval: 1 * 24 * 60 * 60, since: Date())
return return
} }
@ -735,7 +735,7 @@ class ParentPanelController: NSWindowController {
if self.upcomingEventCollectionView != nil { if self.upcomingEventCollectionView != nil {
if self.stackView.arrangedSubviews.contains(self.upcomingEventContainerView!), self.upcomingEventContainerView?.isHidden == false { if self.stackView.arrangedSubviews.contains(self.upcomingEventContainerView!), self.upcomingEventContainerView?.isHidden == false {
self.upcomingEventContainerView?.isHidden = true self.upcomingEventContainerView?.isHidden = true
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView) UserDefaults.standard.set("NO", forKey: UserDefaultKeys.showUpcomingEventView)
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View") Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View")
} }
} }
@ -798,7 +798,7 @@ class ParentPanelController: NSWindowController {
let inverseSelection = showAppInForeground ? NSNumber(value: 0) : NSNumber(value: 1) let inverseSelection = showAppInForeground ? NSNumber(value: 0) : NSNumber(value: 1)
UserDefaults.standard.set(inverseSelection, forKey: CLShowAppInForeground) UserDefaults.standard.set(inverseSelection, forKey: UserDefaultKeys.showAppInForeground)
close() close()
@ -818,7 +818,7 @@ class ParentPanelController: NSWindowController {
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
if let upcomingView = self.upcomingEventContainerView, upcomingView.isHidden { if let upcomingView = self.upcomingEventContainerView, upcomingView.isHidden {
self.upcomingEventContainerView?.isHidden = false self.upcomingEventContainerView?.isHidden = false
UserDefaults.standard.set("YES", forKey: CLShowUpcomingEventView) UserDefaults.standard.set("YES", forKey: UserDefaultKeys.showUpcomingEventView)
Logger.log(object: ["Shown": "YES"], for: "Added Upcoming Event View") Logger.log(object: ["Shown": "YES"], for: "Added Upcoming Event View")
self.themeChanged() self.themeChanged()
} }

2
Clocker/Panel/Rate Controller/ReviewController.swift

@ -14,7 +14,7 @@ final class ReviewController {
} }
class func applicationDidLaunch(_ defaults: UserDefaults) { class func applicationDidLaunch(_ defaults: UserDefaults) {
if ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) { if ProcessInfo.processInfo.arguments.contains(UserDefaultKeys.testingLaunchArgument) {
debugging = true debugging = true
} }

4
Clocker/Panel/UI/TimezoneCellView.swift

@ -20,7 +20,7 @@ class TimezoneCellView: NSTableCellView {
var isPopoverDisplayed: Bool = false var isPopoverDisplayed: Bool = false
override func awakeFromNib() { override func awakeFromNib() {
if ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) { if ProcessInfo.processInfo.arguments.contains(UserDefaultKeys.testingLaunchArgument) {
extraOptions.isHidden = false extraOptions.isHidden = false
return return
} }
@ -125,7 +125,7 @@ class TimezoneCellView: NSTableCellView {
} }
private func setupTextSize() { private func setupTextSize() {
guard let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber else { guard let userFontSize = DataStore.shared().retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber else {
assertionFailure("User Font Size is in unexpected format") assertionFailure("User Font Size is in unexpected format")
return return
} }

10
Clocker/Panel/UI/TimezoneDataSource.swift

@ -65,7 +65,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.rowNumber = row cellView.rowNumber = row
cellView.customName.stringValue = currentModel.formattedTimezoneLabel() cellView.customName.stringValue = currentModel.formattedTimezoneLabel()
cellView.time.stringValue = operation.time(with: sliderValue) cellView.time.stringValue = operation.time(with: sliderValue)
cellView.noteLabel.toolTip = currentModel.note ?? CLEmptyString cellView.noteLabel.toolTip = currentModel.note ?? UserDefaultKeys.emptyString
cellView.currentLocationIndicator.isHidden = !currentModel.isSystemTimezone cellView.currentLocationIndicator.isHidden = !currentModel.isSystemTimezone
cellView.time.setAccessibilityIdentifier("ActualTime") cellView.time.setAccessibilityIdentifier("ActualTime")
cellView.relativeDate.setAccessibilityIdentifier("RelativeDate") cellView.relativeDate.setAccessibilityIdentifier("RelativeDate")
@ -76,7 +76,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.noteLabel.stringValue = value cellView.noteLabel.stringValue = value
cellView.noteLabel.isHidden = false cellView.noteLabel.isHidden = false
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = UserDefaultKeys.emptyString
cellView.noteLabel.isHidden = true cellView.noteLabel.isHidden = true
} }
cellView.layout(with: currentModel) cellView.layout(with: currentModel)
@ -91,9 +91,9 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
return 100 return 100
} }
if let userFontSize = dataStore.retrieve(key: CLUserFontSizePreference) as? NSNumber, if let userFontSize = dataStore.retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber,
timezones.count > row, timezones.count > row,
let relativeDisplay = dataStore.retrieve(key: CLRelativeDateKey) as? NSNumber let relativeDisplay = dataStore.retrieve(key: UserDefaultKeys.relativeDateKey) as? NSNumber
{ {
let model = timezones[row] let model = timezones[row]
let shouldShowSunrise = dataStore.shouldDisplay(.sunrise) let shouldShowSunrise = dataStore.shouldDisplay(.sunrise)
@ -223,7 +223,7 @@ extension TimezoneDataSource: PanelTableViewDelegate {
if offSet == 0.0 { if offSet == 0.0 {
return "\(localizedName)" return "\(localizedName)"
} else { } else {
let offSetSign = offSet > 0 ? "+" : CLEmptyString let offSetSign = offSet > 0 ? "+" : UserDefaultKeys.emptyString
let offsetString = "UTC\(offSetSign)\(offSet)" let offsetString = "UTC\(offSetSign)\(offSet)"
return "\(localizedName) (\(offsetString))" return "\(localizedName) (\(offsetString))"
} }

2
Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift

@ -61,7 +61,7 @@ class UpcomingEventsDataSource: NSObject, NSCollectionViewDataSource, NSCollecti
let currentEventInfo = upcomingEvents[indexPath.item] let currentEventInfo = upcomingEvents[indexPath.item]
let bufferWidth: CGFloat = currentEventInfo.meetingURL != nil ? 60.0 : 20.0 let bufferWidth: CGFloat = currentEventInfo.meetingURL != nil ? 60.0 : 20.0
let longerString = currentEventInfo.event.title.count >= currentEventInfo.metadataForMeeting().count ? currentEventInfo.event.title : currentEventInfo.metadataForMeeting() let longerString = currentEventInfo.event.title.count >= currentEventInfo.metadataForMeeting().count ? currentEventInfo.event.title : currentEventInfo.metadataForMeeting()
let attributedString = NSAttributedString(string: longerString ?? CLEmptyString, attributes: [NSAttributedString.Key.font: avenirBookFont]) let attributedString = NSAttributedString(string: longerString ?? UserDefaultKeys.emptyString, attributes: [NSAttributedString.Key.font: avenirBookFont])
let maxWidth = min((attributedString.size().width + 15) + bufferWidth, UpcomingEventsDataSource.panelWidth / 2) let maxWidth = min((attributedString.size().width + 15) + bufferWidth, UpcomingEventsDataSource.panelWidth / 2)
return NSSize(width: maxWidth, height: collectionView.frame.height - 20) return NSSize(width: maxWidth, height: collectionView.frame.height - 20)
} }

12
Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift

@ -144,9 +144,9 @@ class AppFeedbackWindowController: NSWindowController {
private func generateUserPreferences() -> String { private func generateUserPreferences() -> String {
let preferences = DataStore.shared().timezones() let preferences = DataStore.shared().timezones()
guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, guard let theme = DataStore.shared().retrieve(key: UserDefaultKeys.themeKey) as? NSNumber,
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, let displayFutureSliderKey = DataStore.shared().retrieve(key: UserDefaultKeys.themeKey) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber, let relativeDateKey = DataStore.shared().retrieve(key: UserDefaultKeys.relativeDateKey) as? NSNumber,
let country = Locale.autoupdatingCurrent.regionCode let country = Locale.autoupdatingCurrent.regionCode
else { else {
return "Error" return "Error"
@ -322,9 +322,9 @@ extension AppFeedbackWindowController: NSWindowDelegate {
} }
func performClosingCleanUp() { func performClosingCleanUp() {
nameField.stringValue = CLEmptyString nameField.stringValue = UserDefaultKeys.emptyString
emailField.stringValue = CLEmptyString emailField.stringValue = UserDefaultKeys.emptyString
feedbackTextView.string = CLEmptyString feedbackTextView.string = UserDefaultKeys.emptyString
isActivityInProgress = false isActivityInProgress = false
appFeedbackWindowDelegate?.appFeedbackWindowWillClose() appFeedbackWindowDelegate?.appFeedbackWindowWillClose()
} }

12
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -122,7 +122,7 @@ class AppearanceViewController: ParentViewController {
informationLabel.isHidden = menubarFavourites.isEmpty ? false : true informationLabel.isHidden = menubarFavourites.isEmpty ? false : true
} }
if let selectedIndex = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber { if let selectedIndex = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber {
sliderDayRangePopup.selectItem(at: selectedIndex.intValue) sliderDayRangePopup.selectItem(at: selectedIndex.intValue)
} }
@ -138,7 +138,7 @@ class AppearanceViewController: ParentViewController {
appDisplayControl.setSelected(true, forSegment: appDisplayOptions ? 0 : 1) appDisplayControl.setSelected(true, forSegment: appDisplayOptions ? 0 : 1)
// Set the Sync value from NSUbiqutousKeyValueStore // Set the Sync value from NSUbiqutousKeyValueStore
let syncEnabled = NSUbiquitousKeyValueStore.default.bool(forKey: CLEnableSyncKey) let syncEnabled = NSUbiquitousKeyValueStore.default.bool(forKey: UserDefaultKeys.enableSyncKey)
syncSegementedControl.setSelected(true, forSegment: syncEnabled ? 0 : 1) syncSegementedControl.setSelected(true, forSegment: syncEnabled ? 0 : 1)
} }
@ -190,7 +190,7 @@ class AppearanceViewController: ParentViewController {
@IBAction func timeFormatSelectionChanged(_ sender: NSPopUpButton) { @IBAction func timeFormatSelectionChanged(_ sender: NSPopUpButton) {
let selection = NSNumber(value: sender.indexOfSelectedItem) let selection = NSNumber(value: sender.indexOfSelectedItem)
UserDefaults.standard.set(selection, forKey: CLSelectedTimeZoneFormatKey) UserDefaults.standard.set(selection, forKey: UserDefaultKeys.selectedTimeZoneFormatKey)
refresh(panel: true, floating: true) refresh(panel: true, floating: true)
if let selectedFormat = sender.selectedItem?.title, if let selectedFormat = sender.selectedItem?.title,
@ -357,7 +357,7 @@ class AppearanceViewController: ParentViewController {
} }
@IBAction func toggleSync(_ sender: NSSegmentedControl) { @IBAction func toggleSync(_ sender: NSSegmentedControl) {
NSUbiquitousKeyValueStore.default.set(sender.selectedSegment == 0, forKey: CLEnableSyncKey) NSUbiquitousKeyValueStore.default.set(sender.selectedSegment == 0, forKey: UserDefaultKeys.enableSyncKey)
DataStore.shared().setupSyncNotification() DataStore.shared().setupSyncNotification()
} }
} }
@ -389,7 +389,7 @@ extension AppearanceViewController: NSTableViewDataSource, NSTableViewDelegate {
if let note = currentModel.note, !note.isEmpty { if let note = currentModel.note, !note.isEmpty {
cellView.noteLabel.stringValue = note cellView.noteLabel.stringValue = note
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = UserDefaultKeys.emptyString
} }
cellView.currentLocationIndicator.isHidden = !currentModel.isSystemTimezone cellView.currentLocationIndicator.isHidden = !currentModel.isSystemTimezone
cellView.time.setAccessibilityIdentifier("ActualTime") cellView.time.setAccessibilityIdentifier("ActualTime")
@ -402,7 +402,7 @@ extension AppearanceViewController: NSTableViewDataSource, NSTableViewDelegate {
} }
func tableView(_: NSTableView, heightOfRow row: Int) -> CGFloat { func tableView(_: NSTableView, heightOfRow row: Int) -> CGFloat {
if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, previewTimezones.count > row { if let userFontSize = DataStore.shared().retrieve(key: UserDefaultKeys.userFontSizePreference) as? NSNumber, previewTimezones.count > row {
let model = previewTimezones[row] let model = previewTimezones[row]
let rowHeight: Int = userFontSize == 4 ? 60 : 65 let rowHeight: Int = userFontSize == 4 ? 60 : 65

8
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -94,7 +94,7 @@ class CalendarViewController: ParentViewController {
setGrantAccess(title: "Grant Access".localized()) setGrantAccess(title: "Grant Access".localized())
} else if hasDeniedCalendarAccess { } else if hasDeniedCalendarAccess {
// The informationField text is taken care off in the XIB. Just set the grant button to empty because we can't do anything. // The informationField text is taken care off in the XIB. Just set the grant button to empty because we can't do anything.
setGrantAccess(title: CLEmptyString) setGrantAccess(title: UserDefaultKeys.emptyString)
} else { } else {
calendarsTableView.reloadData() calendarsTableView.reloadData()
} }
@ -124,7 +124,7 @@ class CalendarViewController: ParentViewController {
setGrantAccess(title: "Launch Preferences".localized()) setGrantAccess(title: "Launch Preferences".localized())
// Remove upcoming event view if possible // Remove upcoming event view if possible
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView) UserDefaults.standard.set("NO", forKey: UserDefaultKeys.showUpcomingEventView)
} }
@IBAction func grantAccess(_: Any) { @IBAction func grantAccess(_: Any) {
@ -163,7 +163,7 @@ class CalendarViewController: ParentViewController {
showUpcomingEventView = "NO" showUpcomingEventView = "NO"
} }
UserDefaults.standard.set(showUpcomingEventView, forKey: CLShowUpcomingEventView) UserDefaults.standard.set(showUpcomingEventView, forKey: UserDefaultKeys.showUpcomingEventView)
if DataStore.shared().shouldDisplay(ViewType.showAppInForeground) { if DataStore.shared().shouldDisplay(ViewType.showAppInForeground) {
let floatingWindow = FloatingWindowController.shared() let floatingWindow = FloatingWindowController.shared()
@ -284,7 +284,7 @@ extension CalendarViewController: NSTableViewDelegate {
} }
} }
UserDefaults.standard.set(selectedCalendars, forKey: CLSelectedCalendars) UserDefaults.standard.set(selectedCalendars, forKey: UserDefaultKeys.selectedCalendars)
calendars = EventCenter.sharedCenter().fetchSourcesAndCalendars() calendars = EventCenter.sharedCenter().fetchSourcesAndCalendars()

56
Clocker/Preferences/General/PreferencesViewController.swift

@ -228,7 +228,7 @@ class PreferencesViewController: ParentViewController {
[placeholderLabel].forEach { $0.isHidden = true } [placeholderLabel].forEach { $0.isHidden = true }
messageLabel.stringValue = CLEmptyString messageLabel.stringValue = UserDefaultKeys.emptyString
timezoneTableView.registerForDraggedTypes([.dragSession]) timezoneTableView.registerForDraggedTypes([.dragSession])
@ -238,7 +238,7 @@ class PreferencesViewController: ParentViewController {
setupColor() setupColor()
startupCheckbox.integerValue = DataStore.shared().retrieve(key: CLStartAtLogin) as? Int ?? 0 startupCheckbox.integerValue = DataStore.shared().retrieve(key: UserDefaultKeys.startAtLogin) as? Int ?? 0
searchField.bezelStyle = .roundedBezel searchField.bezelStyle = .roundedBezel
} }
@ -249,7 +249,7 @@ class PreferencesViewController: ParentViewController {
startAtLoginLabel.textColor = Themer.shared().mainTextColor() startAtLoginLabel.textColor = Themer.shared().mainTextColor()
[timezoneNameSortButton, labelSortButton, timezoneSortButton].forEach { [timezoneNameSortButton, labelSortButton, timezoneSortButton].forEach {
$0?.attributedTitle = NSAttributedString(string: $0?.title ?? CLEmptyString, attributes: [ $0?.attributedTitle = NSAttributedString(string: $0?.title ?? UserDefaultKeys.emptyString, attributes: [
NSAttributedString.Key.foregroundColor: Themer.shared().mainTextColor(), NSAttributedString.Key.foregroundColor: Themer.shared().mainTextColor(),
NSAttributedString.Key.font: NSFont(name: "Avenir-Light", size: 13)!, NSAttributedString.Key.font: NSFont(name: "Avenir-Light", size: 13)!,
]) ])
@ -360,10 +360,10 @@ extension PreferencesViewController: NSTableViewDataSource, NSTableViewDelegate
} }
private func showAlertIfMoreThanOneTimezoneHasBeenAddedToTheMenubar() { private func showAlertIfMoreThanOneTimezoneHasBeenAddedToTheMenubar() {
let isUITestRunning = ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) let isUITestRunning = ProcessInfo.processInfo.arguments.contains(UserDefaultKeys.testingLaunchArgument)
// If we have seen displayed the message before, abort! // If we have seen displayed the message before, abort!
let haveWeSeenThisMessageBefore = UserDefaults.standard.bool(forKey: CLLongStatusBarWarningMessage) let haveWeSeenThisMessageBefore = UserDefaults.standard.bool(forKey: UserDefaultKeys.longStatusBarWarningMessage)
if haveWeSeenThisMessageBefore, !isUITestRunning { if haveWeSeenThisMessageBefore, !isUITestRunning {
return return
@ -393,10 +393,10 @@ extension PreferencesViewController: NSTableViewDataSource, NSTableViewDelegate
if response.rawValue == 1000 { if response.rawValue == 1000 {
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
UserDefaults.standard.set(0, forKey: CLMenubarCompactMode) UserDefaults.standard.set(0, forKey: UserDefaultKeys.menubarCompactMode)
if alert.suppressionButton?.state == NSControl.StateValue.on { if alert.suppressionButton?.state == NSControl.StateValue.on {
UserDefaults.standard.set(true, forKey: CLLongStatusBarWarningMessage) UserDefaults.standard.set(true, forKey: UserDefaultKeys.longStatusBarWarningMessage)
} }
self.updateStatusBarAppearance() self.updateStatusBarAppearance()
@ -458,14 +458,14 @@ extension PreferencesViewController {
if searchResults.status == ResultStatus.zeroResults { if searchResults.status == ResultStatus.zeroResults {
Logger.info("Zero Results returned") Logger.info("Zero Results returned")
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "No results! 😔 Try entering the exact name." : CLEmptyString self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "No results! 😔 Try entering the exact name." : UserDefaultKeys.emptyString
self.reloadSearchResults() self.reloadSearchResults()
self.isActivityInProgress = false self.isActivityInProgress = false
return return
} else if searchResults.status == ResultStatus.requestDenied && searchResults.results.isEmpty { } else if searchResults.status == ResultStatus.requestDenied && searchResults.results.isEmpty {
Logger.info("Request denied!") Logger.info("Request denied!")
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "Update Clocker to get a faster experience 😃" : CLEmptyString self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "Update Clocker to get a faster experience 😃" : UserDefaultKeys.emptyString
self.reloadSearchResults() self.reloadSearchResults()
self.isActivityInProgress = false self.isActivityInProgress = false
return return
@ -490,7 +490,7 @@ extension PreferencesViewController {
var searchString = searchField.stringValue var searchString = searchField.stringValue
let words = searchString.components(separatedBy: CharacterSet.whitespacesAndNewlines) let words = searchString.components(separatedBy: CharacterSet.whitespacesAndNewlines)
searchString = words.joined(separator: CLEmptyString) searchString = words.joined(separator: UserDefaultKeys.emptyString)
return "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchString)&key=\(geocodingKey)&language=\(userPreferredLanguage)" return "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchString)&key=\(geocodingKey)&language=\(userPreferredLanguage)"
} }
@ -511,10 +511,10 @@ extension PreferencesViewController {
let totalPackage = [ let totalPackage = [
"latitude": latitude, "latitude": latitude,
"longitude": longitude, "longitude": longitude,
CLTimezoneName: formattedAddress, UserDefaultKeys.timezoneName: formattedAddress,
CLCustomLabel: formattedAddress, UserDefaultKeys.customLabel: formattedAddress,
CLTimezoneID: CLEmptyString, UserDefaultKeys.timezoneID: UserDefaultKeys.emptyString,
CLPlaceIdentifier: $0.placeId, UserDefaultKeys.placeIdentifier: $0.placeId,
] as [String: Any] ] as [String: Any]
finalResults.append(TimezoneData(with: totalPackage)) finalResults.append(TimezoneData(with: totalPackage))
@ -523,7 +523,7 @@ extension PreferencesViewController {
} }
private func prepareUIForPresentingResults() { private func prepareUIForPresentingResults() {
placeholderLabel.placeholderString = CLEmptyString placeholderLabel.placeholderString = UserDefaultKeys.emptyString
isActivityInProgress = false isActivityInProgress = false
reloadSearchResults() reloadSearchResults()
} }
@ -541,7 +541,7 @@ extension PreferencesViewController {
} }
isActivityInProgress = false isActivityInProgress = false
placeholderLabel.placeholderString = CLEmptyString placeholderLabel.placeholderString = UserDefaultKeys.emptyString
} }
private func getTimezone(for latitude: Double, and longitude: Double) { private func getTimezone(for latitude: Double, and longitude: Double) {
@ -600,13 +600,13 @@ extension PreferencesViewController {
} }
let newTimeZone = [ let newTimeZone = [
CLTimezoneID: timezone.timeZoneId, UserDefaultKeys.timezoneID: timezone.timeZoneId,
CLTimezoneName: filteredAddress, UserDefaultKeys.timezoneName: filteredAddress,
CLPlaceIdentifier: dataObject.placeID!, UserDefaultKeys.placeIdentifier: dataObject.placeID!,
"latitude": dataObject.latitude!, "latitude": dataObject.latitude!,
"longitude": dataObject.longitude!, "longitude": dataObject.longitude!,
"nextUpdate": CLEmptyString, "nextUpdate": UserDefaultKeys.emptyString,
CLCustomLabel: filteredAddress, UserDefaultKeys.customLabel: filteredAddress,
] as [String: Any] ] as [String: Any]
// Mark if the timezone is same as local timezone // Mark if the timezone is same as local timezone
@ -658,7 +658,7 @@ extension PreferencesViewController {
refreshTimezoneTableView(true) refreshTimezoneTableView(true)
refreshMainTable() refreshMainTable()
timezonePanel.close() timezonePanel.close()
placeholderLabel.placeholderString = CLEmptyString placeholderLabel.placeholderString = UserDefaultKeys.emptyString
searchField.placeholderString = NSLocalizedString("Search Field Placeholder", searchField.placeholderString = NSLocalizedString("Search Field Placeholder",
comment: "Search Field Placeholder") comment: "Search Field Placeholder")
availableTimezoneTableView.isHidden = false availableTimezoneTableView.isHidden = false
@ -723,7 +723,7 @@ extension PreferencesViewController {
} }
if messageLabel.stringValue.isEmpty { if messageLabel.stringValue.isEmpty {
searchField.stringValue = CLEmptyString searchField.stringValue = UserDefaultKeys.emptyString
guard let latitude = dataObject.latitude, let longitude = dataObject.longitude else { guard let latitude = dataObject.latitude, let longitude = dataObject.longitude else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
@ -736,7 +736,7 @@ extension PreferencesViewController {
private func cleanupAfterInstallingTimezone() { private func cleanupAfterInstallingTimezone() {
let data = TimezoneData() let data = TimezoneData()
data.setLabel(CLEmptyString) data.setLabel(UserDefaultKeys.emptyString)
let currentSelection = searchResultsDataSource.retrieveSelectedTimezone(availableTimezoneTableView.selectedRow) let currentSelection = searchResultsDataSource.retrieveSelectedTimezone(availableTimezoneTableView.selectedRow)
@ -751,8 +751,8 @@ extension PreferencesViewController {
searchResultsDataSource.cleanupFilterArray() searchResultsDataSource.cleanupFilterArray()
searchResultsDataSource.timezoneFilteredArray = [] searchResultsDataSource.timezoneFilteredArray = []
placeholderLabel.placeholderString = CLEmptyString placeholderLabel.placeholderString = UserDefaultKeys.emptyString
searchField.stringValue = CLEmptyString searchField.stringValue = UserDefaultKeys.emptyString
reloadSearchResults() reloadSearchResults()
refreshTimezoneTableView(true) refreshTimezoneTableView(true)
@ -788,8 +788,8 @@ extension PreferencesViewController {
@IBAction func closePanel(_: NSButton) { @IBAction func closePanel(_: NSButton) {
searchResultsDataSource.cleanupFilterArray() searchResultsDataSource.cleanupFilterArray()
searchResultsDataSource.timezoneFilteredArray = [] searchResultsDataSource.timezoneFilteredArray = []
searchField.stringValue = CLEmptyString searchField.stringValue = UserDefaultKeys.emptyString
placeholderLabel.placeholderString = CLEmptyString placeholderLabel.placeholderString = UserDefaultKeys.emptyString
searchField.placeholderString = NSLocalizedString("Search Field Placeholder", searchField.placeholderString = NSLocalizedString("Search Field Placeholder",
comment: "Search Field Placeholder") comment: "Search Field Placeholder")

6
Clocker/Preferences/Menu Bar/MenubarTitleProvider.swift

@ -73,13 +73,13 @@ class MenubarTitleProvider: NSObject {
} }
internal func format(event: EKEvent) -> String { internal func format(event: EKEvent) -> String {
guard let truncateLength = store.retrieve(key: CLTruncateTextLength) as? NSNumber, let eventTitle = event.title, event.title.isEmpty == false else { guard let truncateLength = store.retrieve(key: UserDefaultKeys.truncateTextLength) as? NSNumber, let eventTitle = event.title, event.title.isEmpty == false else {
return CLEmptyString return UserDefaultKeys.emptyString
} }
let seconds = event.startDate.timeIntervalSinceNow let seconds = event.startDate.timeIntervalSinceNow
var menubarText: String = CLEmptyString var menubarText: String = UserDefaultKeys.emptyString
if eventTitle.count > truncateLength.intValue { if eventTitle.count > truncateLength.intValue {
let truncateIndex = eventTitle.index(eventTitle.startIndex, offsetBy: truncateLength.intValue) let truncateIndex = eventTitle.index(eventTitle.startIndex, offsetBy: truncateLength.intValue)

6
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -46,7 +46,7 @@ class StatusItemHandler: NSObject {
statusItem.button?.subviews = [] statusItem.button?.subviews = []
statusContainerView = nil statusContainerView = nil
case .standardText: case .standardText:
statusItem.button?.title = CLEmptyString statusItem.button?.title = UserDefaultKeys.emptyString
case .icon: case .icon:
statusItem.button?.image = nil statusItem.button?.image = nil
} }
@ -362,14 +362,14 @@ class StatusItemHandler: NSObject {
return return
} }
statusItem.button?.title = CLEmptyString statusItem.button?.title = UserDefaultKeys.emptyString
statusItem.button?.image = NSImage(named: .menubarIcon) statusItem.button?.image = NSImage(named: .menubarIcon)
statusItem.button?.imagePosition = .imageOnly statusItem.button?.imagePosition = .imageOnly
statusItem.button?.toolTip = "Clocker" statusItem.button?.toolTip = "Clocker"
} }
private func setupForStandardText() { private func setupForStandardText() {
var menubarText = CLEmptyString var menubarText = UserDefaultKeys.emptyString
if let menubarTitle = menubarTitleHandler.titleForMenubar() { if let menubarTitle = menubarTitleHandler.titleForMenubar() {
menubarText = menubarTitle menubarText = menubarTitle

Loading…
Cancel
Save