mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Working Headphone HUDs and other stuff
This commit is contained in:
parent
9ea2cce485
commit
4bb67c2cd3
7 changed files with 113 additions and 18 deletions
|
|
@ -9,6 +9,38 @@ extension Notification.Name {
|
|||
static let systemAudioRouteDidChange = Notification.Name("DynamicIsland.systemAudioRouteDidChange")
|
||||
}
|
||||
|
||||
final class HUDSuppressionCoordinator {
|
||||
static let shared = HUDSuppressionCoordinator()
|
||||
|
||||
private let queue = DispatchQueue(label: "com.dynamicisland.hud-suppression")
|
||||
private var volumeSuppressedUntil: Date?
|
||||
|
||||
func suppressVolumeHUD(for interval: TimeInterval) {
|
||||
guard interval > 0 else { return }
|
||||
queue.sync {
|
||||
let proposed = Date().addingTimeInterval(interval)
|
||||
if let current = volumeSuppressedUntil {
|
||||
volumeSuppressedUntil = max(current, proposed)
|
||||
} else {
|
||||
volumeSuppressedUntil = proposed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var shouldSuppressVolumeHUD: Bool {
|
||||
queue.sync {
|
||||
guard let expiration = volumeSuppressedUntil else {
|
||||
return false
|
||||
}
|
||||
if Date() < expiration {
|
||||
return true
|
||||
}
|
||||
volumeSuppressedUntil = nil
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class SystemVolumeController {
|
||||
static let shared = SystemVolumeController()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue