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
allowsDefaultTighteningForTruncation = true
if #available(OSX 10.12.2, *) {
isAutomaticTextCompletionEnabled = false
allowsCharacterPickerTouchBarItem = false
}
}
func disableWrapping() {
usesSingleLineMode = false

5
Clocker/Overall App/Foundation + Additions.swift

@ -59,11 +59,6 @@ public extension Data {
extension NSKeyedArchiver {
static func clocker_archive(with object: Any) -> Data? {
if #available(macOS 10.14, *) {
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,
object: nil)
if #available(macOS 10.14, *) {
effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { _, _ in
NotificationCenter.default.post(name: .themeDidChangeNotification, object: nil)
}
}
}
}
extension Themer {
@ -116,7 +114,6 @@ extension Themer {
}
func mainBackgroundColor() -> NSColor {
if #available(macOS 10.14, *) {
switch themeIndex {
case .light:
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 {
if #available(macOS 10.14, *) {
switch themeIndex {
case .light:
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 {
if #available(macOS 10.14, *) {
switch themeIndex {
case .light:
return NSColor.black
@ -171,9 +158,6 @@ extension Themer {
}
}
return themeIndex == .light ? NSColor.black : NSColor.white
}
// MARK: Images
func shutdownImage() -> NSImage {
@ -256,7 +240,6 @@ extension Themer {
}
func menubarOnboardingImage() -> NSImage {
if #available(macOS 10.14, *) {
switch themeIndex {
case .system:
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 {
return fallbackImageProvider(NSImage(named: NSImage.Name("ExtraHighlighted"))!,
NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!,
@ -319,7 +299,6 @@ extension Themer {
}
func popoverAppearance() -> NSAppearance {
if #available(macOS 10.14, *) {
switch themeIndex {
case .light, .solarizedLight:
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 {
if let symbolImageForPreference = symbolImage(for: "plus") {
return symbolImageForPreference
@ -457,7 +433,6 @@ extension Themer {
}
private func setAppAppearance() {
if #available(OSX 10.14, *) {
var appAppearance = NSAppearance(named: .aqua)
if themeIndex == .dark || themeIndex == .solarizedDark {
@ -468,7 +443,7 @@ extension Themer {
if NSApp.appearance != appAppearance {
NSApp.appearance = appAppearance
}
}
}
private func fallbackImageProvider(_ lightImage: NSImage,
@ -477,7 +452,6 @@ extension Themer {
_ solarizedLightImage: NSImage,
_ solarizedDarkImage: NSImage) -> NSImage
{
if #available(macOS 10.14, *) {
switch themeIndex {
case .light:
return lightImage
@ -491,7 +465,4 @@ extension Themer {
return solarizedDarkImage
}
}
return themeIndex == .light ? lightImage : darkImage
}
}

20
Clocker/Panel/PanelController.swift

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

20
Clocker/Panel/ParentPanelController.swift

@ -169,13 +169,13 @@ class ParentPanelController: NSWindowController {
updateReviewViewFontColor()
// 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,
green: 150.0 / 255.0,
blue: 122.0 / 255.0,
alpha: 0.5).cgColor
stackView.arrangedSubviews.last?.toolTip = "Debug Mode"
#endif
#endif
// Setup layers
futureSliderView.wantsLayer = true
@ -501,9 +501,7 @@ class ParentPanelController: NSWindowController {
}
func updateDefaultPreferences() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Update Default Preferences")
}
updatePanelColor()
@ -520,10 +518,8 @@ class ParentPanelController: NSWindowController {
updateDatasource(with: convertedTimezones)
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Update Default Preferences")
}
}
func updateDatasource(with timezones: [TimezoneData]) {
datasource?.setItems(items: timezones)
@ -639,9 +635,7 @@ class ParentPanelController: NSWindowController {
cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone
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
}
if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note
} else if let value = TimezoneDataOperations(with: model, store: DataStore.shared()).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
@ -758,9 +752,7 @@ class ParentPanelController: NSWindowController {
}
func retrieveCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Retrieve Calendar Events")
}
let eventCenter = EventCenter.sharedCenter()
@ -772,10 +764,8 @@ class ParentPanelController: NSWindowController {
removeUpcomingEventView()
}
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Retrieve Calendar Events")
}
}
@IBAction func shareAction(_ sender: NSButton) {
let copyAllTimes = retrieveAllTimes()
@ -826,9 +816,7 @@ class ParentPanelController: NSWindowController {
}
private func fetchCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Fetch Calendar Events")
}
let eventCenter = EventCenter.sharedCenter()
let now = Date()
@ -843,21 +831,17 @@ class ParentPanelController: NSWindowController {
return
}
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events")
}
}
} else {
if upcomingEventCollectionView != nil {
upcomingEventsDataSource?.updateEventsDataSource([])
upcomingEventCollectionView.reloadData()
return
}
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events")
}
}
}
// If the popover is displayed, close it
// 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() {
if #available(OSX 10.14, *) {
SKStoreReviewController.requestReview()
} else {
guard let ratingsURL = URL(string: AboutUsConstants.AppStoreLink) else {
return
}
NSWorkspace.shared.open(ratingsURL)
}
prompted()
}
}

2
Clocker/Panel/UI/TimezoneDataSource.swift

@ -58,9 +58,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.sunriseSetTime.stringValue = operation.formattedSunriseTime(with: sliderValue)
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.relativeDate.stringValue = operation.date(with: sliderValue, displayType: .panel)
cellView.rowNumber = row
cellView.customName.stringValue = currentModel.formattedTimezoneLabel()

4
Clocker/Preferences/Appearance/AppearanceViewController.swift

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

2
Clocker/Preferences/Calendar/CalendarViewController.swift

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

4
Clocker/Preferences/General/PreferencesViewController.swift

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

4
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

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

9
Clocker/Preferences/Menu Bar/StatusItemView.swift

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

Loading…
Cancel
Save