From 7229e542b35e3455a4c839bee975a0fac9c7d142 Mon Sep 17 00:00:00 2001 From: Han Ngo Date: Thu, 28 Feb 2019 16:53:31 +0700 Subject: [PATCH 1/2] Update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19aaef7..31d75f5 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ Hidden Bar lets you hide menu bar items to give your Mac a cleaner look.

## Requirements -macOS version >= 10.13 +macOS version >= 10.13 -## Contribution +## License -If you \ No newline at end of file +MIT © [Dwarves Foundation](https://github.com/dwarvesf) From d6e6bc11e1ad7fd94a18b0a24da24d7dd16d52a3 Mon Sep 17 00:00:00 2001 From: thanhnguyenduc157 Date: Fri, 1 Mar 2019 14:09:21 +0700 Subject: [PATCH 2/2] hot fix for save current state check --- hidden/Base.lproj/Main.storyboard | 26 ++++++++++++++----- hidden/Common/Constant.swift | 1 + hidden/Common/Util.swift | 15 +++++++++++ .../StatusBarController.swift | 2 +- hidden/ViewControlllers/ViewController.swift | 14 ++++++++++ 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/hidden/Base.lproj/Main.storyboard b/hidden/Base.lproj/Main.storyboard index 65376bd..658936b 100644 --- a/hidden/Base.lproj/Main.storyboard +++ b/hidden/Base.lproj/Main.storyboard @@ -706,11 +706,11 @@ - + - + @@ -735,7 +735,7 @@ + + @@ -791,7 +803,7 @@ - + diff --git a/hidden/Common/Constant.swift b/hidden/Common/Constant.swift index a7854bb..c24bc12 100644 --- a/hidden/Common/Constant.swift +++ b/hidden/Common/Constant.swift @@ -12,6 +12,7 @@ let IS_AUTO_START = "isAutoStart" let IS_AUTO_HIDE = "isAutoHide" let IS_KEEP_IN_DOCK = "isKeepInDock" let IS_SHOW_PREFERENCES = "isShowPreferences" +let IS_KEEP_LAST_STATE = "isKeepLastState" let App_Name = "Hidden Bar" let IS_COLLAPSE = "isCollapse" diff --git a/hidden/Common/Util.swift b/hidden/Common/Util.swift index 428f471..d5c1d3e 100644 --- a/hidden/Common/Util.swift +++ b/hidden/Common/Util.swift @@ -107,6 +107,21 @@ class Util { return getShowPreferences() ? .on : .off } + + static func getKeepLastState() -> Bool { + let savedValue = UserDefaults.standard.bool(forKey: IS_KEEP_LAST_STATE) + return savedValue + } + + static func setKeepLastState(_ isKeepLastState: Bool) { + UserDefaults.standard.set(isKeepLastState, forKey: IS_KEEP_LAST_STATE) + } + + static func getStateKeepLastState() -> NSControl.StateValue { + return getKeepLastState() ? .on : .off + } + + static func isMenuOpened() -> Bool { let options = CGWindowListOption(arrayLiteral: .excludeDesktopElements, .optionOnScreenOnly) let windowsListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0)) diff --git a/hidden/ViewControlllers/StatusBarController.swift b/hidden/ViewControlllers/StatusBarController.swift index 88a3d8f..4c106b4 100644 --- a/hidden/ViewControlllers/StatusBarController.swift +++ b/hidden/ViewControlllers/StatusBarController.swift @@ -45,7 +45,7 @@ class StatusBarController{ } private func checkCollapseWhenOpen(){ - if(Util.getIsCollapse()) + if(Util.getIsCollapse() && Util.getKeepLastState()) { if(isToggle && isValidPosition()) { diff --git a/hidden/ViewControlllers/ViewController.swift b/hidden/ViewControlllers/ViewController.swift index f8982c7..dace351 100644 --- a/hidden/ViewControlllers/ViewController.swift +++ b/hidden/ViewControlllers/ViewController.swift @@ -10,6 +10,7 @@ import Cocoa class ViewController: NSViewController { + @IBOutlet weak var checkBoxKeepLastState: NSButton! @IBOutlet weak var textFieldTitle: NSTextField! @IBOutlet weak var imageViewTop: NSImageView! @@ -29,6 +30,7 @@ class ViewController: NSViewController { checkBoxAutoHide.state = Util.getStateAutoHide() checkBoxKeepInDock.state = Util.getStateKeepInDock() checkBoxShowPreferences.state = Util.getStateShowPreferences() + checkBoxKeepLastState.state = Util.getStateKeepLastState() } override var representedObject: Any? { @@ -79,6 +81,7 @@ class ViewController: NSViewController { } } + @IBAction func showPreferencesChanged(_ sender: NSButton) { switch sender.state { case .on: @@ -89,5 +92,16 @@ class ViewController: NSViewController { break } } + + @IBAction func onLastKeepAppStateChange(_ sender: NSButton) { + switch sender.state { + case .on: + Util.setKeepLastState(true) + case .off: + Util.setKeepLastState(false) + default: + break + } + } }