Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Hidden Bar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
4D8C4B09D62D4884B34E1A14 /* NotchOverflowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE73DB4E0664488997EEB6DE /* NotchOverflowController.swift */; };
00117C4426600671005E517C /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00117C4326600671005E517C /* Assets.swift */; };
00137CDF24A63DB1004AC855 /* Notification.Name+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00137CDE24A63DB1004AC855 /* Notification.Name+Extension.swift */; };
0842CDFB23A9FDD000D14BD4 /* GlobalKeybindingPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0842CDFA23A9FDD000D14BD4 /* GlobalKeybindingPreferences.swift */; };
Expand Down Expand Up @@ -57,6 +58,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
BE73DB4E0664488997EEB6DE /* NotchOverflowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotchOverflowController.swift; sourceTree = "<group>"; };
00117C4326600671005E517C /* Assets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = "<group>"; };
00137CDE24A63DB1004AC855 /* Notification.Name+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Notification.Name+Extension.swift"; sourceTree = "<group>"; };
0842CDFA23A9FDD000D14BD4 /* GlobalKeybindingPreferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalKeybindingPreferences.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -152,12 +154,21 @@
isa = PBXGroup;
children = (
08C20FDC23AABC440035D978 /* About */,
905962CD99D24D0C893AFFA7 /* NotchOverflow */,
0842CDFE23A9FF7C00D14BD4 /* Preferences */,
0842CDFD23A9FF7500D14BD4 /* StatusBar */,
);
path = Features;
sourceTree = "<group>";
};
905962CD99D24D0C893AFFA7 /* NotchOverflow */ = {
isa = PBXGroup;
children = (
BE73DB4E0664488997EEB6DE /* NotchOverflowController.swift */,
);
path = NotchOverflow;
sourceTree = "<group>";
};
0842CDFD23A9FF7500D14BD4 /* StatusBar */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -422,6 +433,7 @@
08C20FE223AB452C0035D978 /* AboutViewController.swift in Sources */,
00137CDF24A63DB1004AC855 /* Notification.Name+Extension.swift in Sources */,
08A5F86423AA09F300981CA5 /* UserDefault+Extension.swift in Sources */,
4D8C4B09D62D4884B34E1A14 /* NotchOverflowController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
23 changes: 20 additions & 3 deletions hidden/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,46 @@
//

import AppKit
import Carbon
import HotKey

@NSApplicationMain

class AppDelegate: NSObject, NSApplicationDelegate{

var statusBarController = StatusBarController()

var hotKey: HotKey? {
didSet {
guard let hotKey = hotKey else { return }

hotKey.keyDownHandler = { [weak self] in
self?.statusBarController.expandCollapseIfNeeded()
}
}
}

// Notch overflow hotkey: Cmd+Shift+B
var notchOverflowHotKey: HotKey?

func applicationDidFinishLaunching(_ aNotification: Notification) {
setupAutoStartApp()
registerDefaultValues()
setupHotKey()
openPreferencesIfNeeded()
detectLTRLang()
statusBarController.setupNotchOverflow()
setupNotchOverflowHotKey()
}

func setupNotchOverflowHotKey() {
guard NotchOverflowController.hasNotch else { return }
// Cmd+Shift+B (keyCode 11 = B)
let carbonMods = UInt32(cmdKey | shiftKey)
notchOverflowHotKey = HotKey(keyCombo: KeyCombo(carbonKeyCode: 11, carbonModifiers: carbonMods))
notchOverflowHotKey?.keyDownHandler = { [weak self] in
self?.statusBarController.notchOverflowController.triggerOverflow()
}
}

func openPreferencesIfNeeded() {
Expand All @@ -50,7 +66,8 @@ class AppDelegate: NSObject, NSApplicationDelegate{
UserDefaults.Key.isAutoHide: true,
UserDefaults.Key.numberOfSecondForAutoHide: 10.0,
UserDefaults.Key.areSeparatorsHidden: false,
UserDefaults.Key.alwaysHiddenSectionEnabled: false
UserDefaults.Key.alwaysHiddenSectionEnabled: false,
UserDefaults.Key.notchOverflowEnabled: true
])
}

Expand Down
15 changes: 12 additions & 3 deletions hidden/Common/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,20 @@ enum Preferences {
get {
UserDefaults.standard.bool(forKey: UserDefaults.Key.useFullStatusBarOnExpandEnabled)
}

set {
UserDefaults.standard.set(newValue, forKey: UserDefaults.Key.useFullStatusBarOnExpandEnabled)
}
}



static var notchOverflowEnabled: Bool {
get {
UserDefaults.standard.bool(forKey: UserDefaults.Key.notchOverflowEnabled)
}

set {
UserDefaults.standard.set(newValue, forKey: UserDefaults.Key.notchOverflowEnabled)
NotificationCenter.default.post(Notification(name: .notchOverflowToggle))
}
}
}
1 change: 1 addition & 0 deletions hidden/Extensions/Notification.Name+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ extension Notification.Name {

static let prefsChanged = Notification.Name("prefsChanged")
static let alwayHideToggle = Notification.Name("alwayHideToggle")
static let notchOverflowToggle = Notification.Name("notchOverflowToggle")
}
1 change: 1 addition & 0 deletions hidden/Extensions/UserDefault+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extension UserDefaults {
static let areSeparatorsHidden = "areSeparatorsHidden"
static let alwaysHiddenSectionEnabled = "alwaysHiddenSectionEnabled"
static let useFullStatusBarOnExpandEnabled = "useFullStatusBarOnExpandEnabled"
static let notchOverflowEnabled = "notchOverflowEnabled"
}

open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
Expand Down
Loading