Permalink
Browse files

Rename CBTrueToneClient file and create shared value for BrightnessSy…

…stemClient
  • Loading branch information...
thompsonate committed Sep 7, 2018
1 parent 3f2920e commit 99e8402968ca5f4c5db447a7dd7e39022385b2b9
@@ -37,6 +37,7 @@
4394DDAA1EBE376F00F22908 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4394DDA31EBE376F00F22908 /* Assets.xcassets */; };
4394DDAD1EBE376F00F22908 /* StatusMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4394DDA81EBE376F00F22908 /* StatusMenuController.swift */; };
43965AC31FC68A19001A076D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 43965AC51FC68A19001A076D /* InfoPlist.strings */; };
43A8E69C2141DF7C00BD3870 /* CBTrueToneClient+Shifty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A8E69B2141DF7C00BD3870 /* CBTrueToneClient+Shifty.swift */; };
43AA23C71FFABCD2001DDF5A /* AccessibilityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43AA23C61FFABCD2001DDF5A /* AccessibilityView.swift */; };
43AA23CE1FFAC69A001DDF5A /* AccessibilityWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43AA23CC1FFAC69A001DDF5A /* AccessibilityWindow.swift */; };
43AA23CF1FFAC69A001DDF5A /* AccessibilityWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43AA23CD1FFAC69A001DDF5A /* AccessibilityWindow.xib */; };
@@ -57,7 +58,6 @@
43D5C2211FC2CACF00AF88E0 /* CustomTimeWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43D5C2231FC2CACF00AF88E0 /* CustomTimeWindow.xib */; };
43D5C2301FC2CECC00AF88E0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 43D5C2321FC2CECC00AF88E0 /* Localizable.strings */; };
43D5C2391FC35FB500AF88E0 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43D5C2381FC35FB500AF88E0 /* MainMenu.xib */; };
43F71DB2213F49DD004F7E2B /* TrueToneClient+Shifty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F71DB1213F49DD004F7E2B /* TrueToneClient+Shifty.swift */; };
43FC498C1FF8936F00CD3196 /* credits.rtfd in Resources */ = {isa = PBXBuildFile; fileRef = 43FC498B1FF8936E00CD3196 /* credits.rtfd */; };
4960957E200EB9CD00D966CA /* RuleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4960957D200EB9CD00D966CA /* RuleManager.swift */; };
497B2395200B576700669DDE /* NightShiftManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 497B2392200B576700669DDE /* NightShiftManager.swift */; };
@@ -127,6 +127,7 @@
4394DDAE1EBE379900F22908 /* Shifty-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Shifty-Bridging-Header.h"; path = "Shifty/Shifty-Bridging-Header.h"; sourceTree = "<group>"; };
43965AC41FC68A19001A076D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
43965AC61FC68A1B001A076D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
43A8E69B2141DF7C00BD3870 /* CBTrueToneClient+Shifty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "CBTrueToneClient+Shifty.swift"; path = "Shifty/CBTrueToneClient+Shifty.swift"; sourceTree = "<group>"; };
43AA23C61FFABCD2001DDF5A /* AccessibilityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AccessibilityView.swift; path = Shifty/AccessibilityView.swift; sourceTree = "<group>"; };
43AA23CC1FFAC69A001DDF5A /* AccessibilityWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AccessibilityWindow.swift; path = Shifty/AccessibilityWindow.swift; sourceTree = "<group>"; };
43AA23CD1FFAC69A001DDF5A /* AccessibilityWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = AccessibilityWindow.xib; path = Shifty/AccessibilityWindow.xib; sourceTree = "<group>"; };
@@ -156,7 +157,6 @@
43D5C2381FC35FB500AF88E0 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MainMenu.xib; path = Shifty/MainMenu.xib; sourceTree = "<group>"; };
43D5C2441FC3A9A100AF88E0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Shifty/Info.plist; sourceTree = "<group>"; };
43F71DB0213F48DA004F7E2B /* CBTrueToneClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CBTrueToneClient.h; path = Shifty/CBTrueToneClient.h; sourceTree = "<group>"; };
43F71DB1213F49DD004F7E2B /* TrueToneClient+Shifty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "TrueToneClient+Shifty.swift"; path = "Shifty/TrueToneClient+Shifty.swift"; sourceTree = "<group>"; };
43FC498B1FF8936E00CD3196 /* credits.rtfd */ = {isa = PBXFileReference; lastKnownFileType = wrapper.rtfd; path = credits.rtfd; sourceTree = "<group>"; };
4960957D200EB9CD00D966CA /* RuleManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RuleManager.swift; path = Shifty/RuleManager.swift; sourceTree = "<group>"; };
497B2392200B576700669DDE /* NightShiftManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NightShiftManager.swift; path = Shifty/NightShiftManager.swift; sourceTree = "<group>"; };
@@ -224,9 +224,9 @@
4394DDAE1EBE379900F22908 /* Shifty-Bridging-Header.h */,
4394DDA41EBE376F00F22908 /* CBBlueLightClient.h */,
43F71DB0213F48DA004F7E2B /* CBTrueToneClient.h */,
43A8E69B2141DF7C00BD3870 /* CBTrueToneClient+Shifty.swift */,
433E60EB207D9995007BB55F /* BrightnessSystemClient.h */,
433E60EA207D9994007BB55F /* BrightnessSystemClient+Shifty.swift */,
43F71DB1213F49DD004F7E2B /* TrueToneClient+Shifty.swift */,
497B2393200B576700669DDE /* NotificationName+Shifty.swift */,
43CE525920379A16002EBF61 /* Event.swift */,
437556B51FF746BD001951AB /* SlideSegue.swift */,
@@ -476,8 +476,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
43A8E69C2141DF7C00BD3870 /* CBTrueToneClient+Shifty.swift in Sources */,
433E60EC207D9995007BB55F /* BrightnessSystemClient+Shifty.swift in Sources */,
43F71DB2213F49DD004F7E2B /* TrueToneClient+Shifty.swift in Sources */,
497B2396200B576700669DDE /* NotificationName+Shifty.swift in Sources */,
43AA23C71FFABCD2001DDF5A /* AccessibilityView.swift in Sources */,
437556B61FF746BD001951AB /* SlideSegue.swift in Sources */,
@@ -8,7 +8,9 @@
import Foundation
extension BrightnessSystemClient {
private func sunriseSunsetData() -> [String: Any]? {
static var shared = BrightnessSystemClient()
func sunriseSunsetData() -> [String: Any]? {
if let sunriseSunsetProperty = copyProperty(forKey: "BlueLightSunSchedule" as CFString),
let sunriseSunsetDict = sunriseSunsetProperty as? [String: Any] {
return sunriseSunsetDict
@@ -0,0 +1,45 @@
//
// CBTrueToneClient+Shifty.swift
// Shifty
//
// Created by Nate Thompson on 9/4/18.
//
import Foundation
import SwiftLog
enum State {
case unsupported
case unavailable
case enabled
case disabled
}
extension CBTrueToneClient {
static var shared = CBTrueToneClient()
private var isTrueToneSupported: Bool {
return CBTrueToneClient.shared.supported()
}
private var isTrueToneAvailable: Bool {
return CBTrueToneClient.shared.available()
}
var isTrueToneEnabled: Bool {
get {
return CBTrueToneClient.shared.enabled()
}
set {
CBTrueToneClient.shared.setEnabled(newValue)
logw("True Tone set to \(newValue)")
}
}
var state: State {
if !isTrueToneSupported { return .unsupported }
else if !isTrueToneAvailable { return .unavailable }
else if isTrueToneEnabled { return .enabled }
else { return .disabled }
}
}
@@ -8,7 +8,6 @@
import Cocoa
import SwiftLog
let BSClient = BrightnessSystemClient()
extension Time: Equatable, Comparable {
init(_ date: Date) {
@@ -186,8 +185,8 @@ enum NightShiftManager {
return now >= startTime || now <= endTime
}
case .solar:
guard let isDaylight = BSClient?.isDaylight else {
logw("Found nil for object BSClient. Returning false for scheduledState.")
guard let isDaylight = BrightnessSystemClient.shared?.isDaylight else {
logw("Found nil for object BrightnessSystemClient. Returning false for scheduledState.")
return false
}
//Should be false between sunrise and sunset

0 comments on commit 99e8402

Please sign in to comment.