Removed BoringWorkerNotifier Dependency

This commit is contained in:
Hariharan Mudaliar 2025-11-22 13:16:16 +05:30
commit 89538faffa
9 changed files with 35 additions and 123 deletions

View file

@ -354,10 +354,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
func applicationDidFinishLaunching(_ notification: Notification) {
coordinator.setupWorkersNotificationObservers()
LockScreenLiveActivityWindowManager.shared.configure(viewModel: vm)
LockScreenManager.shared.configure(viewModel: vm)
LockScreenLiveActivityWindowManager.shared.configure(viewModel: vm)
LockScreenManager.shared.configure(viewModel: vm)
// Migrate legacy progress bar settings
Defaults.Keys.migrateProgressBarStyle()

View file

@ -8,7 +8,6 @@
import Combine
import Defaults
import SwiftUI
import TheBoringWorkerNotifier
enum SneakContentType {
case brightness
@ -34,13 +33,6 @@ struct sneakPeek {
var icon: String = ""
}
struct SharedSneakPeek: Codable {
var show: Bool
var type: String
var value: String
var icon: String
}
enum BrowserType {
case chromium
case safari
@ -55,7 +47,6 @@ struct ExpandedItem {
class DynamicIslandViewCoordinator: ObservableObject {
static let shared = DynamicIslandViewCoordinator()
var notifier: TheBoringWorkerNotifier
@Published var currentView: NotchViews = .home
@ -64,7 +55,6 @@ class DynamicIslandViewCoordinator: ObservableObject {
@AppStorage("showWhatsNew") var showWhatsNew: Bool = true
@AppStorage("musicLiveActivityEnabled") var musicLiveActivityEnabled: Bool = true
@AppStorage("timerLiveActivityEnabled") var timerLiveActivityEnabled: Bool = true
@AppStorage("currentMicStatus") var currentMicStatus: Bool = true
@AppStorage("alwaysShowTabs") var alwaysShowTabs: Bool = true {
didSet {
@ -85,11 +75,7 @@ class DynamicIslandViewCoordinator: ObservableObject {
}
}
@AppStorage("hudReplacement") var hudReplacement: Bool = true {
didSet {
notifier.postNotification(name: notifier.toggleHudReplacementNotification.name, userInfo: nil)
}
}
@AppStorage("hudReplacement") var hudReplacement: Bool = true
@AppStorage("preferred_screen_name") var preferredScreen = NSScreen.main?.localizedName ?? "Unknown" {
didSet {
@ -103,46 +89,9 @@ class DynamicIslandViewCoordinator: ObservableObject {
@Published var optionKeyPressed: Bool = true
private init() {
notifier = TheBoringWorkerNotifier()
selectedScreen = preferredScreen
}
func setupWorkersNotificationObservers() {
notifier.setupObserver(notification: notifier.micStatusNotification, handler: initialMicStatus)
notifier.setupObserver(notification: notifier.sneakPeakNotification, handler: sneakPeekEvent)
}
@objc func sneakPeekEvent(_ notification: Notification) {
let decoder = JSONDecoder()
if let decodedData = try? decoder.decode(
SharedSneakPeek.self, from: notification.userInfo?.first?.value as! Data)
{
let contentType =
decodedData.type == "brightness"
? SneakContentType.brightness
: decodedData.type == "volume"
? SneakContentType.volume
: decodedData.type == "backlight"
? SneakContentType.backlight
: decodedData.type == "mic"
? SneakContentType.mic
: decodedData.type == "timer"
? SneakContentType.timer : SneakContentType.brightness
let formatter = NumberFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.numberStyle = .decimal
let value = CGFloat((formatter.number(from: decodedData.value) ?? 0.0).floatValue)
let icon = decodedData.icon
print("Decoded: \(decodedData), Parsed value: \(value)")
toggleSneakPeek(status: decodedData.show, type: contentType, value: value, icon: icon)
} else {
print("Failed to decode JSON data")
}
}
func toggleSneakPeek(status: Bool, type: SneakContentType, duration: TimeInterval = 1.5, value: CGFloat = 0, icon: String = "") {
let resolvedDuration: TimeInterval
switch type {
@ -168,10 +117,6 @@ class DynamicIslandViewCoordinator: ObservableObject {
self.sneakPeek.icon = icon
}
}
if type == .mic {
currentMicStatus = value == 1
}
}
private var sneakPeekDuration: TimeInterval = 1.5
@ -239,14 +184,6 @@ class DynamicIslandViewCoordinator: ObservableObject {
}
@objc func initialMicStatus(_ notification: Notification) {
currentMicStatus = notification.userInfo?.first?.value as! Bool
}
func toggleMic() {
notifier.postNotification(name: notifier.toggleMicNotification.name, userInfo: nil)
}
func showEmpty() {
currentView = .home
}

View file

@ -11032,6 +11032,10 @@
}
}
},
"Manage indicator preferences from Settings → Privacy. No manual microphone toggle is required." : {
"comment" : "A description of how to manage the microphone privacy indicator preferences.",
"isCommentAutoGenerated" : true
},
"Manage the Clock timer from the Clock app." : {
},
@ -12284,6 +12288,10 @@
}
}
},
"Microphone privacy indicator runs automatically whenever apps access audio." : {
"comment" : "A description of the microphone privacy indicator feature.",
"isCommentAutoGenerated" : true
},
"Microphone Status" : {
"localizations" : {
"fr" : {

View file

@ -12,7 +12,6 @@ extension KeyboardShortcuts.Name {
static let clipboardHistoryPanel = Self("clipboardHistoryPanel", default: .init(.c, modifiers: [.shift, .command]))
static let colorPickerPanel = Self("colorPickerPanel", default: .init(.p, modifiers: [.shift, .command]))
static let screenAssistantPanel = Self("screenAssistantPanel", default: .init(.a, modifiers: [.shift, .command]))
static let toggleMicrophone = Self("toggleMicrophone", default: .init(.f5, modifiers: [.function]))
static let decreaseBacklight = Self("decreaseBacklight", default: .init(.f1, modifiers: [.command]))
static let increaseBacklight = Self("increaseBacklight", default: .init(.f2, modifiers: [.command]))
static let toggleSneakPeek = Self("toggleSneakPeek", default: .init(.h, modifiers: [.command, .shift]))

View file

@ -72,35 +72,27 @@ func logout() {
}
struct DynamicIslandSystemTiles: View {
@EnvironmentObject var vm: DynamicIslandViewModel
@ObservedObject var coordinator = DynamicIslandViewCoordinator.shared
struct ItemButton {
var icon: String
var onTap: () -> Void
}
var body: some View {
Grid {
GridRow {
// SystemItemButton(icon: "clipboard", onTap: {
// vm.openClipboard()
// }, label: "Clipboard History", showEmojis: Defaults[.showEmojis], emoji: "✨")
// SystemItemButton(icon: "keyboard", onTap: {
// vm?.close()
// vm?.togglesneakPeek(status: true, type: .backlight, value: 1)
// }, label: "💡 Keyboard Backlight")
}
GridRow {
SystemItemButton(icon: coordinator.currentMicStatus ? "mic" : "mic.slash", onTap: {
coordinator.toggleMic()
vm.close()
}, label: "Toggle Microphone", showEmojis: Defaults[.showEmojis], emoji: coordinator.currentMicStatus ? "😀" : "🤫")
// SystemItemButton(icon: "lock", onTap: {
// logout()
// }, label: "🔒 Lock My Device")
VStack(alignment: .leading, spacing: 6) {
Label {
Text("Microphone privacy indicator runs automatically whenever apps access audio.")
.font(.caption)
.foregroundStyle(.gray)
.lineLimit(3)
.multilineTextAlignment(.leading)
} icon: {
Image(systemName: "shield.lefthalf.filled")
.foregroundStyle(.gray)
}
Text("Manage indicator preferences from Settings → Privacy. No manual microphone toggle is required.")
.font(.caption2)
.foregroundStyle(.secondary)
.lineLimit(3)
.multilineTextAlignment(.leading)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 4)
}
}

View file

@ -8,7 +8,6 @@
import Combine
import Defaults
import SwiftUI
import TheBoringWorkerNotifier
class DynamicIslandViewModel: NSObject, ObservableObject {
@ObservedObject var coordinator = DynamicIslandViewCoordinator.shared