Skip to content

Commit

Permalink
Merge pull request #137 from iglance/release/v2.0.5
Browse files Browse the repository at this point in the history
Release/v2.0.5
  • Loading branch information
D0miH authored Apr 16, 2020
2 parents 04f57dc + f6039b4 commit 23490e4
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Thanks for taking the time and wanting to contribute to this project 👍🏼

Before you start coding it is best to directly comment on the issue and tell everyone that you want to work on it. This prevents misunderstandings such that two persons start working on the same issue.

Know that everyone knows that you wanna work on this issue you can start by forking the repository. This will create a copy of the repository on your GitHub account. After cloning your forked repository you have to install all the dependencies of the project using [CocoaPods](https://cocoapods.org) with the following command:
Now that everyone knows that you wanna work on this issue you can start by forking the repository. This will create a copy of the repository on your GitHub account. After cloning your forked repository you have to install all the dependencies of the project using [CocoaPods](https://cocoapods.org) with the following command in the directory `./iGlance` (you should see a file named `Podfile` in this directory):

```
pod install
Expand All @@ -15,8 +15,8 @@ pod install
We have a `master` and a `development` branch in this repository. The `master` branch is responsible for all the releases. We push to this branch only if we release a new version of `iGlance`. The development (as the name suggests) is for developing.
Therefore the next step is to create a new branch which is based on the `development` branch. Name your branch after the following scheme:

`feature/<short-issue-description>-<github-issue-id>`
`bug-fix/<short-issue-description>-<github-issue-id>`
`feature/<github_issue-id>-<issue_name>`
`bug-fix/<github_issue_id>-<short_issue_description>`

This will make it clear which issue is referenced by this branch.

Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ If applicable, add screenshots to help explain your problem.

**Log**
Please activate `Advanced Logging` in the settings, restart the app and perform the steps to reproduce the bug.
After the bug occurred, please close the app completely (i.e. by opening the app window and pressing `CMD+Q`).
Please take the latest log file from `~/Library/Logs/iGlance/` and upload it here.
After the bug occurred, please open the iGlance window and in the app menu at the top left of the menu bar click on `Diagnostics > Save Logfile...`.
Save the logfile somewhere and upload it here by dragging the file into the textfield.
7 changes: 0 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,3 @@
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Screenshots (if appropriate):
16 changes: 16 additions & 0 deletions Sparkle/updates/appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,21 @@
<enclosure url="https://raw.githubusercontent.com/iglance/iGlance/master/Sparkle/updates/iGlance2.0.4-2.0.delta" sparkle:version="2.0.4" sparkle:shortVersionString="2.0.4" sparkle:deltaFrom="2.0" length="275213" type="application/octet-stream" sparkle:edSignature="V7rKHQP5sGN0OgOLv+AGI7PMWbm8nla2dBxnMREk0o4z8Kpw1cB/FZn7XqwWjIi0/vO7Y+cAsws653lJYF6UCg=="/>
</sparkle:deltas>
</item>
<item>
<title>2.0.5</title>
<sparkle:releaseNotesLink>
https://iglance.github.io/release-notes.html
</sparkle:releaseNotesLink>
<pubDate>Thu, 16 Apr 2020 18:27:00 +0200</pubDate>
<sparkle:minimumSystemVersion>10.12</sparkle:minimumSystemVersion>
<enclosure url="https://github.com/iglance/iGlance/releases/download/v2.0.5/iGlance_v2.0.5.zip" sparkle:version="2.0.5" sparkle:shortVersionString="2.0.5" length="10110539" type="application/octet-stream" sparkle:edSignature="7wZ4PUR8YmRtIc01S3CaIScdK4Z2oPmuH6LUOPpbGRrPawy3JNzS4B8tXAMyufd3jnD2X6VI49xuifWLwr1FCw=="/>
<sparkle:deltas>
<enclosure url="https://raw.githubusercontent.com/iglance/iGlance/master/Sparkle/updates/iGlance2.0.5-2.0.4.delta" sparkle:version="2.0.5" sparkle:shortVersionString="2.0.5" sparkle:deltaFrom="2.0.4" length="175988" type="application/octet-stream" sparkle:edSignature="PvPUzAuW7huBB0pA/2PibogXdCq8aWA+LL21brJ9DQBwax9u5LBkZ/vPGCQCknWZyTngneKzs9dEQEqDcIZcCQ=="/>
<enclosure url="https://raw.githubusercontent.com/iglance/iGlance/master/Sparkle/updates/iGlance2.0.5-2.0.3.delta" sparkle:version="2.0.5" sparkle:shortVersionString="2.0.5" sparkle:deltaFrom="2.0.3" length="272370" type="application/octet-stream" sparkle:edSignature="qPfy5bbfUH20yWcqNah9BFil0piOuzJHSysbeiyIRBe8U3L6AJv+QwhUwyDue9XNQ5dT6gbHR6hzKTjD/b2yDQ=="/>
<enclosure url="https://raw.githubusercontent.com/iglance/iGlance/master/Sparkle/updates/iGlance2.0.5-2.0.2.delta" sparkle:version="2.0.5" sparkle:shortVersionString="2.0.5" sparkle:deltaFrom="2.0.2" length="285862" type="application/octet-stream" sparkle:edSignature="H+5lJYMLnv1kZVMkhdXTBRA9/izt0S/7e2oGzp29CkcZBgckv4KOxT/8lpqwPgk8h3JZnUz27KX+ahEbq6m1Ag=="/>
<enclosure url="https://raw.githubusercontent.com/iglance/iGlance/master/Sparkle/updates/iGlance2.0.5-2.0.1.delta" sparkle:version="2.0.5" sparkle:shortVersionString="2.0.5" sparkle:deltaFrom="2.0.1" length="289017" type="application/octet-stream" sparkle:edSignature="mDysyB49BGrfcHZYJnp4tXTN9fJSKc67iUsdyM3oElWe5/Iq49t7/ZxPEPZStqbYCDiqTl9ucWvCyAwlGCTlAw=="/>
<enclosure url="https://raw.githubusercontent.com/iglance/iGlance/master/Sparkle/updates/iGlance2.0.5-2.0.delta" sparkle:version="2.0.5" sparkle:shortVersionString="2.0.5" sparkle:deltaFrom="2.0" length="290608" type="application/octet-stream" sparkle:edSignature="Eb1VYiXtHgA4TYFNA6y6HB2EuEnz+LrL3MgdUS2zU4oFzhM2UqKxDMZq7W+if6BSOIKjLlI7y3MrcAKdLVsQAw=="/>
</sparkle:deltas>
</item>
</channel>
</rss>
Binary file added Sparkle/updates/iGlance2.0.5-2.0.1.delta
Binary file not shown.
Binary file added Sparkle/updates/iGlance2.0.5-2.0.2.delta
Binary file not shown.
Binary file added Sparkle/updates/iGlance2.0.5-2.0.3.delta
Binary file not shown.
Binary file added Sparkle/updates/iGlance2.0.5-2.0.4.delta
Binary file not shown.
Binary file added Sparkle/updates/iGlance2.0.5-2.0.delta
Binary file not shown.
8 changes: 4 additions & 4 deletions iGlance/iGlance/iGlance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.0.4;
CURRENT_PROJECT_VERSION = 2.0.5;
DEVELOPMENT_TEAM = J6GXEPK4NG;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = iGlance/Info.plist;
Expand All @@ -917,7 +917,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 2.0.4;
MARKETING_VERSION = 2.0.5;
PRODUCT_BUNDLE_IDENTIFIER = io.github.iglance.iGlance;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -935,7 +935,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.0.4;
CURRENT_PROJECT_VERSION = 2.0.5;
DEVELOPMENT_TEAM = J6GXEPK4NG;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = iGlance/Info.plist;
Expand All @@ -944,7 +944,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 2.0.4;
MARKETING_VERSION = 2.0.5;
PRODUCT_BUNDLE_IDENTIFIER = io.github.iglance.iGlance;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
92 changes: 88 additions & 4 deletions iGlance/iGlance/iGlance/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {

// create the timer object
currentUpdateLoopTimer = createUpdateLoopTimer(interval: AppDelegate.userSettings.settings.updateInterval)

// add the observer for sleep mode
NSWorkspace.shared.notificationCenter.addObserver(
self,
selector: #selector(self.onWakeUp(notification:)),
name: NSWorkspace.didWakeNotification,
object: nil
)
NSWorkspace.shared.notificationCenter.addObserver(
self,
selector: #selector(self.onSleep(notification:)),
name: NSWorkspace.willSleepNotification,
object: nil
)
}

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
Expand All @@ -73,6 +87,26 @@ class AppDelegate: NSObject, NSApplicationDelegate {
killLauncherApplication()
}

/**
* This function will be called when the machine is waking up from sleep
*/
@objc
private func onWakeUp(notification: NSNotification) {
// invalidate the old timer and start a new timer
changeUpdateLoopTimeInterval(interval: AppDelegate.userSettings.settings.updateInterval)
DDLogInfo("Create a new timer after waking up from sleep")
}

/**
* This function will be called when the machine is going into sleep mode.
*/
@objc
private func onSleep(notification: NSNotification) {
// invalidate currently used timer
currentUpdateLoopTimer.invalidate()
DDLogInfo("Invalidated the current timer")
}

// MARK: -
// MARK: Actions

Expand Down Expand Up @@ -121,7 +155,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}.isEmpty

if launcherIsRunning {
DDLogInfo("iGlance Launcher is already running")
DDLogInfo("iGlance Launcher is running")
guard let mainAppBundleIdentifier = Bundle.main.bundleIdentifier else {
DDLogError("Could not retrieve the main bundle identifier")
return
Expand All @@ -137,22 +171,51 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: Instance Functions

/**
* Shows the main window, order it in front of any other window and activate the window..
* Shows the main window, order it in front of any other window and activate the window.
*/
@objc
func showMainWindow() {
mainWindow.showWindow(nil)
NSApp.activate(ignoringOtherApps: true)
}

/**
* Shows the preference window by first showing the main window and then the preference window of the app.
*/
func showPreferenceWindow() {
// first show the main window. Basically it should never be the case that the main window is nil or not visible
if let window = mainWindow.window, !window.isVisible {
NSApp.activate(ignoringOtherApps: true)
} else if mainWindow.window == nil {
showMainWindow()
}

// then show the preference window
// instantiate the storyboard (bundle = nil indicates the apps main bundle)
let storyboard = NSStoryboard(name: "PreferenceWindow", bundle: nil)

// instantiate the view controller
guard let preferenceModalViewController = storyboard.instantiateController(withIdentifier: "PreferenceModalViewController") as? PreferenceModalViewController else {
DDLogError("Could not instantiate 'PreferenceModalViewController'")
return
}

// get the parent window
guard let parentWindow = mainWindow.window else {
DDLogError("Could not unwrap the parent window")
return
}

preferenceModalViewController.showModal(parentWindow: parentWindow)
}

/**
* Creates a timer and adds it to a the current run loop. The timer calls the update loop every given time interval.
*
* - Returns: The newly created timer.
*/
func createUpdateLoopTimer(interval: Double) -> Timer {
let timer = Timer(timeInterval: interval, target: self, selector: #selector(updateLoop), userInfo: nil, repeats: true)
RunLoop.current.add(timer, forMode: RunLoop.Mode.common)
let timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(updateLoop), userInfo: nil, repeats: true)

return timer
}
Expand All @@ -178,4 +241,25 @@ class AppDelegate: NSObject, NSApplicationDelegate {

currentUpdateLoopTimer = timer
}

// MARK: -
// MARK: Static Functions

/**
* Returns the current instance of the app delegate class.
*/
static func getInstance() -> AppDelegate? {
NSApplication.shared.delegate as? AppDelegate
}

// MARK: -
// MARK: Actions

@IBAction private func saveMostRecentLogFile(sender: AnyObject) {
self.logger.saveMostRecentLogFile()
}

@IBAction private func showPreferenceWindow(sender: AnyObject) {
self.showPreferenceWindow()
}
}
18 changes: 8 additions & 10 deletions iGlance/iGlance/iGlance/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW">
<connections>
<action selector="showPreferenceWindowWithSender:" target="Ady-hI-5gd" id="gyr-dB-Z0v"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Hide iGlance" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
Expand Down Expand Up @@ -63,21 +67,12 @@
<items>
<menuItem title="Import Settings..." id="aTl-1u-JFS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="print:" target="Ady-hI-5gd" id="qaZ-4w-aoO"/>
</connections>
</menuItem>
<menuItem title="Export Settings..." id="pEa-Tm-cAy">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="print:" target="Ady-hI-5gd" id="znB-8W-S7W"/>
</connections>
</menuItem>
<menuItem title="Reset Settings..." id="mjT-CA-nxz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="print:" target="Ady-hI-5gd" id="euZ-1j-48x"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="edB-3D-5wF"/>
<menuItem title="Close" keyEquivalent="w" id="4rx-Ty-iez">
Expand Down Expand Up @@ -119,6 +114,9 @@
<items>
<menuItem title="Save Logfile..." id="41S-gD-t7E">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="saveMostRecentLogFileWithSender:" target="Ady-hI-5gd" id="4xx-cR-Xmu"/>
</connections>
</menuItem>
</items>
</menu>
Expand Down
4 changes: 3 additions & 1 deletion iGlance/iGlance/iGlance/Graphs/BarGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ class BarGraph: Graph {
image.lockFocus()

// get the height of the bar
let barHeight = Double((maxBarHeight / self.maxValue) * currentValue)
// prevent a value of zero since this would cause a bug when drawing the bar
let value = (currentValue == 0 ? 0.1 : currentValue)
let barHeight = Double((maxBarHeight / self.maxValue) * value)

// draw the gradient if necessary
if gradientColor != nil {
Expand Down
65 changes: 65 additions & 0 deletions iGlance/iGlance/iGlance/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,69 @@ class Logger {
dynamicLogLevel = .all
}
}

func saveMostRecentLogFile() {
// get the log file paths
let logfilePaths = self.fileLogger.logFileManager.sortedLogFilePaths

// check if there are any log files
if logfilePaths.isEmpty {
let alert = NSAlert()
alert.messageText = "Error"
alert.informativeText = "No logfiles were found"
alert.addButton(withTitle: "Ok")
alert.runModal()

DDLogError("No log files were found")
return
}
let mostRecentLogFileUrl = URL(fileURLWithPath: logfilePaths.first!)

// create the save panel
let savePanel = NSSavePanel()
savePanel.nameFieldStringValue = mostRecentLogFileUrl.lastPathComponent

savePanel.begin { result in
if result == .OK {
var success = false
if let destUrl = savePanel.url {
success = self.saveLogFile(logFileUrl: mostRecentLogFileUrl, destinationUrl: destUrl)
}

if !success {
let alert = NSAlert()
alert.messageText = "Error"
alert.informativeText = "Something went wrong while saving the log file"
alert.addButton(withTitle: "Ok")
alert.runModal()
DDLogError("Somethings went wrong while saving the log file")
return
}

DDLogInfo("The log file \(mostRecentLogFileUrl.lastPathComponent) was successfully saved")
} else if result == .cancel {
DDLogInfo("The save logfile dialog was cancelled")
}
}
}

/**
* Saves the log file which is located at the given path to the given destination path.
*
* - Parameter logFileUrl: The url of the log file that is going to be saved.
* - Parameter destinationUrl: The url of the destination where the log file is going to be saved.
*/
func saveLogFile(logFileUrl: URL, destinationUrl: URL) -> Bool {
// get the default file manager of the process
let fileManager = FileManager.default

// copy the log file to the destination
do {
try fileManager.copyItem(at: logFileUrl, to: destinationUrl)
return true
} catch {
DDLogError("Failed to copy the log file to the destination")
return false
}
}
}
3 changes: 3 additions & 0 deletions iGlance/iGlance/iGlance/MainWindow/MainWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class MainWindowController: NSWindowController {
self.window?.center()
}

// MARK: -
// MARK: Private Functions

@objc
private func updateMainWindow() {
mainWindow.backgroundColor = ThemeManager.currentTheme().titlebarColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,12 @@ class SidebarViewController: NSViewController {
// MARK: Actions

@IBAction private func preferenceButtonClick(_ sender: NSButton) {
// instantiate the storyboard (bundle = nil indicates the apps main bundle)
let storyboard = NSStoryboard(name: "PreferenceWindow", bundle: nil)

// instantiate the view controller
guard let preferenceModalViewController = storyboard.instantiateController(withIdentifier: "PreferenceModalViewController") as? PreferenceModalViewController else {
DDLogError("Could not instantiate 'PreferenceModalViewController'")
return
}

// get the parent window
guard let parentWindow = self.view.window else {
DDLogError("Could not unwrap the parent window")
guard let appDelegate = AppDelegate.getInstance() else {
DDLogError("Could not retrieve the app delegate instance")
return
}

preferenceModalViewController.showModal(parentWindow: parentWindow)
appDelegate.showPreferenceWindow()
}

// MARK: -
Expand Down
Loading

0 comments on commit 23490e4

Please sign in to comment.