Browse Source

Remove 10.14 checks.

master
Abhishek Banthia 9 months ago
parent
commit
511dd23c4a
  1. 2
      Clocker/Overall App/AppKit + Additions.swift
  2. 5
      Clocker/Overall App/Foundation + Additions.swift
  3. 31
      Clocker/Overall App/Themer.swift
  4. 20
      Clocker/Panel/PanelController.swift
  5. 20
      Clocker/Panel/ParentPanelController.swift
  6. 8
      Clocker/Panel/Rate Controller/ReviewController.swift
  7. 2
      Clocker/Panel/UI/TimezoneDataSource.swift
  8. 4
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  9. 2
      Clocker/Preferences/Calendar/CalendarViewController.swift
  10. 4
      Clocker/Preferences/General/PreferencesViewController.swift
  11. 4
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  12. 9
      Clocker/Preferences/Menu Bar/StatusItemView.swift

2
Clocker/Overall App/AppKit + Additions.swift

@ -7,11 +7,9 @@ extension NSTextField {
isBordered = false isBordered = false
allowsDefaultTighteningForTruncation = true allowsDefaultTighteningForTruncation = true
if #available(OSX 10.12.2, *) {
isAutomaticTextCompletionEnabled = false isAutomaticTextCompletionEnabled = false
allowsCharacterPickerTouchBarItem = false allowsCharacterPickerTouchBarItem = false
} }
}
func disableWrapping() { func disableWrapping() {
usesSingleLineMode = false usesSingleLineMode = false

5
Clocker/Overall App/Foundation + Additions.swift

@ -59,11 +59,6 @@ public extension Data {
extension NSKeyedArchiver { extension NSKeyedArchiver {
static func clocker_archive(with object: Any) -> Data? { static func clocker_archive(with object: Any) -> Data? {
if #available(macOS 10.14, *) {
return try? NSKeyedArchiver.archivedData(withRootObject: object, requiringSecureCoding: true) return try? NSKeyedArchiver.archivedData(withRootObject: object, requiringSecureCoding: true)
} }
return nil
}
} }

31
Clocker/Overall App/Themer.swift

@ -49,12 +49,10 @@ class Themer: NSObject {
name: .interfaceStyleDidChange, name: .interfaceStyleDidChange,
object: nil) object: nil)
if #available(macOS 10.14, *) {
effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { _, _ in effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { _, _ in
NotificationCenter.default.post(name: .themeDidChangeNotification, object: nil) NotificationCenter.default.post(name: .themeDidChangeNotification, object: nil)
} }
} }
}
} }
extension Themer { extension Themer {
@ -116,7 +114,6 @@ extension Themer {
} }
func mainBackgroundColor() -> NSColor { func mainBackgroundColor() -> NSColor {
if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light:
return NSColor.white return NSColor.white
@ -131,11 +128,7 @@ extension Themer {
} }
} }
return themeIndex == .light ? NSColor.white : NSColor(deviceRed: 55.0 / 255.0, green: 71.0 / 255.0, blue: 79.0 / 255.0, alpha: 1.0)
}
func textBackgroundColor() -> NSColor { func textBackgroundColor() -> NSColor {
if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light:
return NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) return NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0)
@ -150,13 +143,7 @@ extension Themer {
} }
} }
return themeIndex == .light ?
NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) :
NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0)
}
func mainTextColor() -> NSColor { func mainTextColor() -> NSColor {
if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light:
return NSColor.black return NSColor.black
@ -171,9 +158,6 @@ extension Themer {
} }
} }
return themeIndex == .light ? NSColor.black : NSColor.white
}
// MARK: Images // MARK: Images
func shutdownImage() -> NSImage { func shutdownImage() -> NSImage {
@ -256,7 +240,6 @@ extension Themer {
} }
func menubarOnboardingImage() -> NSImage { func menubarOnboardingImage() -> NSImage {
if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .system: case .system:
return NSImage(named: NSImage.Name("Dynamic Menubar"))! return NSImage(named: NSImage.Name("Dynamic Menubar"))!
@ -267,9 +250,6 @@ extension Themer {
} }
} }
return retrieveCurrentSystem() == .dark ? NSImage(named: NSImage.Name("Dark Menubar"))! : NSImage(named: NSImage.Name("Light Menubar"))!
}
func extraOptionsHighlightedImage() -> NSImage { func extraOptionsHighlightedImage() -> NSImage {
return fallbackImageProvider(NSImage(named: NSImage.Name("ExtraHighlighted"))!, return fallbackImageProvider(NSImage(named: NSImage.Name("ExtraHighlighted"))!,
NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!, NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!,
@ -319,7 +299,6 @@ extension Themer {
} }
func popoverAppearance() -> NSAppearance { func popoverAppearance() -> NSAppearance {
if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light, .solarizedLight: case .light, .solarizedLight:
return NSAppearance(named: NSAppearance.Name.vibrantLight)! return NSAppearance(named: NSAppearance.Name.vibrantLight)!
@ -330,9 +309,6 @@ extension Themer {
} }
} }
return themeIndex == .light ? NSAppearance(named: NSAppearance.Name.vibrantLight)! : NSAppearance(named: NSAppearance.Name.vibrantDark)!
}
func addImage() -> NSImage { func addImage() -> NSImage {
if let symbolImageForPreference = symbolImage(for: "plus") { if let symbolImageForPreference = symbolImage(for: "plus") {
return symbolImageForPreference return symbolImageForPreference
@ -457,7 +433,6 @@ extension Themer {
} }
private func setAppAppearance() { private func setAppAppearance() {
if #available(OSX 10.14, *) {
var appAppearance = NSAppearance(named: .aqua) var appAppearance = NSAppearance(named: .aqua)
if themeIndex == .dark || themeIndex == .solarizedDark { if themeIndex == .dark || themeIndex == .solarizedDark {
@ -468,7 +443,7 @@ extension Themer {
if NSApp.appearance != appAppearance { if NSApp.appearance != appAppearance {
NSApp.appearance = appAppearance NSApp.appearance = appAppearance
} }
}
} }
private func fallbackImageProvider(_ lightImage: NSImage, private func fallbackImageProvider(_ lightImage: NSImage,
@ -477,7 +452,6 @@ extension Themer {
_ solarizedLightImage: NSImage, _ solarizedLightImage: NSImage,
_ solarizedDarkImage: NSImage) -> NSImage _ solarizedDarkImage: NSImage) -> NSImage
{ {
if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light:
return lightImage return lightImage
@ -491,7 +465,4 @@ extension Themer {
return solarizedDarkImage return solarizedDarkImage
} }
} }
return themeIndex == .light ? lightImage : darkImage
}
} }

20
Clocker/Panel/PanelController.swift

@ -40,11 +40,9 @@ class PanelController: ParentPanelController {
private func enablePerformanceLoggingIfNeccessary() { private func enablePerformanceLoggingIfNeccessary() {
if !ProcessInfo.processInfo.environment.keys.contains("ENABLE_PERF_LOGGING") { if !ProcessInfo.processInfo.environment.keys.contains("ENABLE_PERF_LOGGING") {
if #available(OSX 10.14, *) {
PerfLogger.disable() PerfLogger.disable()
} }
} }
}
func setFrameTheNewWay(_ rect: NSRect, _ maxX: CGFloat) { func setFrameTheNewWay(_ rect: NSRect, _ maxX: CGFloat) {
// Calculate window's top left point. // Calculate window's top left point.
@ -63,9 +61,7 @@ class PanelController: ParentPanelController {
} }
func open() { func open() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Open") PerfLogger.startMarker("Open")
}
guard isWindowLoaded == true else { guard isWindowLoaded == true else {
return return
@ -127,17 +123,13 @@ class PanelController: ParentPanelController {
log() log()
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Open") PerfLogger.endMarker("Open")
} }
}
// New way to set the panel's frame. // New way to set the panel's frame.
// This takes into account the screen's dimensions. // This takes into account the screen's dimensions.
private func setPanelFrame() { private func setPanelFrame() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Set Panel Frame") PerfLogger.startMarker("Set Panel Frame")
}
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else { guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else {
return return
@ -172,16 +164,12 @@ class PanelController: ParentPanelController {
statusItemFrame.origin.y = minY statusItemFrame.origin.y = minY
setFrameTheNewWay(statusItemFrame, screenMaxX) setFrameTheNewWay(statusItemFrame, screenMaxX)
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Set Panel Frame") PerfLogger.endMarker("Set Panel Frame")
} }
} }
}
private func log() { private func log() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Logging") PerfLogger.startMarker("Logging")
}
let preferences = DataStore.shared().timezones() let preferences = DataStore.shared().timezones()
@ -226,34 +214,26 @@ class PanelController: ParentPanelController {
Logger.log(object: panelEvent, for: "openedPanel") Logger.log(object: panelEvent, for: "openedPanel")
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Logging") PerfLogger.endMarker("Logging")
} }
}
private func startWindowTimer() { private func startWindowTimer() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Start Window Timer") PerfLogger.startMarker("Start Window Timer")
}
stopMenubarTimerIfNeccesary() stopMenubarTimerIfNeccesary()
if let timer = parentTimer, timer.state == .paused { if let timer = parentTimer, timer.state == .paused {
parentTimer?.start() parentTimer?.start()
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Start Window Timer") PerfLogger.endMarker("Start Window Timer")
}
return return
} }
startTimer() startTimer()
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Start Window Timer") PerfLogger.endMarker("Start Window Timer")
} }
}
private func startTimer() { private func startTimer() {
Logger.info("Start timer called") Logger.info("Start timer called")

20
Clocker/Panel/ParentPanelController.swift

@ -169,13 +169,13 @@ class ParentPanelController: NSWindowController {
updateReviewViewFontColor() updateReviewViewFontColor()
// Set the background color of the bottom buttons view to something different to indicate we're not in a release candidate // Set the background color of the bottom buttons view to something different to indicate we're not in a release candidate
#if DEBUG #if DEBUG
stackView.arrangedSubviews.last?.layer?.backgroundColor = NSColor(deviceRed: 255.0 / 255.0, stackView.arrangedSubviews.last?.layer?.backgroundColor = NSColor(deviceRed: 255.0 / 255.0,
green: 150.0 / 255.0, green: 150.0 / 255.0,
blue: 122.0 / 255.0, blue: 122.0 / 255.0,
alpha: 0.5).cgColor alpha: 0.5).cgColor
stackView.arrangedSubviews.last?.toolTip = "Debug Mode" stackView.arrangedSubviews.last?.toolTip = "Debug Mode"
#endif #endif
// Setup layers // Setup layers
futureSliderView.wantsLayer = true futureSliderView.wantsLayer = true
@ -501,9 +501,7 @@ class ParentPanelController: NSWindowController {
} }
func updateDefaultPreferences() { func updateDefaultPreferences() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Update Default Preferences") PerfLogger.startMarker("Update Default Preferences")
}
updatePanelColor() updatePanelColor()
@ -520,10 +518,8 @@ class ParentPanelController: NSWindowController {
updateDatasource(with: convertedTimezones) updateDatasource(with: convertedTimezones)
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Update Default Preferences") PerfLogger.endMarker("Update Default Preferences")
} }
}
func updateDatasource(with timezones: [TimezoneData]) { func updateDatasource(with timezones: [TimezoneData]) {
datasource?.setItems(items: timezones) datasource?.setItems(items: timezones)
@ -639,9 +635,7 @@ class ParentPanelController: NSWindowController {
cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone
cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage()
if #available(macOS 10.14, *) {
cellView.sunriseImage.contentTintColor = model.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange cellView.sunriseImage.contentTintColor = model.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange
}
if let note = model.note, !note.isEmpty { if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note cellView.noteLabel.stringValue = note
} 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) {
@ -758,9 +752,7 @@ class ParentPanelController: NSWindowController {
} }
func retrieveCalendarEvents() { func retrieveCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Retrieve Calendar Events") PerfLogger.startMarker("Retrieve Calendar Events")
}
let eventCenter = EventCenter.sharedCenter() let eventCenter = EventCenter.sharedCenter()
@ -772,10 +764,8 @@ class ParentPanelController: NSWindowController {
removeUpcomingEventView() removeUpcomingEventView()
} }
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Retrieve Calendar Events") PerfLogger.endMarker("Retrieve Calendar Events")
} }
}
@IBAction func shareAction(_ sender: NSButton) { @IBAction func shareAction(_ sender: NSButton) {
let copyAllTimes = retrieveAllTimes() let copyAllTimes = retrieveAllTimes()
@ -826,9 +816,7 @@ class ParentPanelController: NSWindowController {
} }
private func fetchCalendarEvents() { private func fetchCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Fetch Calendar Events") PerfLogger.startMarker("Fetch Calendar Events")
}
let eventCenter = EventCenter.sharedCenter() let eventCenter = EventCenter.sharedCenter()
let now = Date() let now = Date()
@ -843,21 +831,17 @@ class ParentPanelController: NSWindowController {
return return
} }
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events") PerfLogger.endMarker("Fetch Calendar Events")
} }
}
} else { } else {
if upcomingEventCollectionView != nil { if upcomingEventCollectionView != nil {
upcomingEventsDataSource?.updateEventsDataSource([]) upcomingEventsDataSource?.updateEventsDataSource([])
upcomingEventCollectionView.reloadData() upcomingEventCollectionView.reloadData()
return return
} }
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events") PerfLogger.endMarker("Fetch Calendar Events")
} }
} }
}
// If the popover is displayed, close it // If the popover is displayed, close it
// Called when preferences are going to be displayed! // Called when preferences are going to be displayed!

8
Clocker/Panel/Rate Controller/ReviewController.swift

@ -62,15 +62,7 @@ final class ReviewController {
} }
class func prompt() { class func prompt() {
if #available(OSX 10.14, *) {
SKStoreReviewController.requestReview() SKStoreReviewController.requestReview()
} else {
guard let ratingsURL = URL(string: AboutUsConstants.AppStoreLink) else {
return
}
NSWorkspace.shared.open(ratingsURL)
}
prompted() prompted()
} }
} }

2
Clocker/Panel/UI/TimezoneDataSource.swift

@ -58,9 +58,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.sunriseSetTime.stringValue = operation.formattedSunriseTime(with: sliderValue) cellView.sunriseSetTime.stringValue = operation.formattedSunriseTime(with: sliderValue)
cellView.sunriseImage.image = currentModel.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() cellView.sunriseImage.image = currentModel.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage()
if #available(macOS 10.14, *) {
cellView.sunriseImage.contentTintColor = currentModel.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange cellView.sunriseImage.contentTintColor = currentModel.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange
}
cellView.relativeDate.stringValue = operation.date(with: sliderValue, displayType: .panel) cellView.relativeDate.stringValue = operation.date(with: sliderValue, displayType: .panel)
cellView.rowNumber = row cellView.rowNumber = row
cellView.customName.stringValue = currentModel.formattedTimezoneLabel() cellView.customName.stringValue = currentModel.formattedTimezoneLabel()

4
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -126,10 +126,6 @@ class AppearanceViewController: ParentViewController {
sliderDayRangePopup.selectItem(at: selectedIndex.intValue) sliderDayRangePopup.selectItem(at: selectedIndex.intValue)
} }
if #available(macOS 10.14, *) {} else {
theme.removeItem(at: 2)
}
let shouldDisplayCompact = DataStore.shared().shouldDisplay(.menubarCompactMode) let shouldDisplayCompact = DataStore.shared().shouldDisplay(.menubarCompactMode)
menubarMode.setSelected(true, forSegment: shouldDisplayCompact ? 0 : 1) menubarMode.setSelected(true, forSegment: shouldDisplayCompact ? 0 : 1)

2
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -56,9 +56,7 @@ class CalendarViewController: ParentViewController {
self.setup() self.setup()
} }
if #available(macOS 10.14, *) {
noAccessView.material = .contentBackground noAccessView.material = .contentBackground
}
upcomingEventView.setAccessibility("UpcomingEventView") upcomingEventView.setAccessibility("UpcomingEventView")
} }

4
Clocker/Preferences/General/PreferencesViewController.swift

@ -133,11 +133,9 @@ class PreferencesViewController: ParentViewController {
} }
private func darkModeChanges() { private func darkModeChanges() {
if #available(macOS 10.14, *) {
addTimezoneButton.image = Themer.shared().addImage() addTimezoneButton.image = Themer.shared().addImage()
deleteButton.image = Themer.shared().removeImage() deleteButton.image = Themer.shared().removeImage()
} }
}
private func setupLocalizedText() { private func setupLocalizedText() {
startAtLoginLabel.stringValue = NSLocalizedString("Start at Login", startAtLoginLabel.stringValue = NSLocalizedString("Start at Login",
@ -453,7 +451,7 @@ extension PreferencesViewController {
return return
} }
// let searchResults = data.decode() // let searchResults = data.decode()
if searchResults.status == ResultStatus.zeroResults { if searchResults.status == ResultStatus.zeroResults {
Logger.info("Zero Results returned") Logger.info("Zero Results returned")

4
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -91,11 +91,7 @@ class StatusItemHandler: NSObject {
currentState = menubarState currentState = menubarState
func setSelector() { func setSelector() {
if #available(macOS 10.14, *) {
statusItem.button?.action = #selector(menubarIconClicked(_:)) statusItem.button?.action = #selector(menubarIconClicked(_:))
} else {
statusItem.action = #selector(menubarIconClicked(_:))
}
} }
statusItem.button?.target = self statusItem.button?.target = self

9
Clocker/Preferences/Menu Bar/StatusItemView.swift

@ -27,21 +27,12 @@ var compactModeTimeFont: NSFont {
extension NSView { extension NSView {
var hasDarkAppearance: Bool { var hasDarkAppearance: Bool {
if #available(OSX 10.14, *) {
switch effectiveAppearance.name { switch effectiveAppearance.name {
case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark: case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark:
return true return true
default: default:
return false return false
} }
} else {
switch effectiveAppearance.name {
case .vibrantDark:
return true
default:
return false
}
}
} }
} }

Loading…
Cancel
Save