Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Add dev channel to SpechtLite
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuhaow committed Nov 21, 2016
1 parent eb2b630 commit 1753989
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.1

### Added
- Dev channel

## 0.5.0

### Changed
Expand Down
4 changes: 4 additions & 0 deletions SpechtLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
36B2ACE01DE096AC00BD2C3D /* Opt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36B2ACDF1DE096AC00BD2C3D /* Opt.swift */; };
36B2ACE31DE0979C00BD2C3D /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36B2ACE21DE0979C00BD2C3D /* Utils.swift */; };
36B2ACE51DE2EA4A00BD2C3D /* LoggerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36B2ACE41DE2EA4A00BD2C3D /* LoggerManager.swift */; };
36B2ACE71DE33A5600BD2C3D /* UpdaterManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36B2ACE61DE33A5600BD2C3D /* UpdaterManager.swift */; };
36BA0BF31D599FF40074BEBF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BA0BF21D599FF40074BEBF /* AppDelegate.swift */; };
36BA0BF51D599FF40074BEBF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 36BA0BF41D599FF40074BEBF /* Assets.xcassets */; };
36BA0BF81D599FF40074BEBF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 36BA0BF61D599FF40074BEBF /* MainMenu.xib */; };
Expand Down Expand Up @@ -152,6 +153,7 @@
36B2ACDF1DE096AC00BD2C3D /* Opt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Opt.swift; sourceTree = "<group>"; };
36B2ACE21DE0979C00BD2C3D /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
36B2ACE41DE2EA4A00BD2C3D /* LoggerManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggerManager.swift; sourceTree = "<group>"; };
36B2ACE61DE33A5600BD2C3D /* UpdaterManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdaterManager.swift; sourceTree = "<group>"; };
36BA0BEF1D599FF40074BEBF /* SpechtLite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpechtLite.app; sourceTree = BUILT_PRODUCTS_DIR; };
36BA0BF21D599FF40074BEBF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
36BA0BF41D599FF40074BEBF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -318,6 +320,7 @@
36B2ACDF1DE096AC00BD2C3D /* Opt.swift */,
36B2ACE21DE0979C00BD2C3D /* Utils.swift */,
36B2ACE41DE2EA4A00BD2C3D /* LoggerManager.swift */,
36B2ACE61DE33A5600BD2C3D /* UpdaterManager.swift */,
);
path = SpechtLite;
sourceTree = "<group>";
Expand Down Expand Up @@ -545,6 +548,7 @@
36A719EC1D617A4A00DC35F5 /* Autostart.swift in Sources */,
36B2ACE31DE0979C00BD2C3D /* Utils.swift in Sources */,
36B2ACE51DE2EA4A00BD2C3D /* LoggerManager.swift in Sources */,
36B2ACE71DE33A5600BD2C3D /* UpdaterManager.swift in Sources */,
36B2ACE01DE096AC00BD2C3D /* Opt.swift in Sources */,
36A719BF1D5F0A9400DC35F5 /* Preference.swift in Sources */,
36BA0BF31D599FF40074BEBF /* AppDelegate.swift in Sources */,
Expand Down
12 changes: 1 addition & 11 deletions SpechtLite/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import Cocoa
import NEKit
import Sparkle

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var menuController: MenuBarController!

func applicationDidFinishLaunching(aNotification: NSNotification) {
setUpAutoUpdate()
UpdaterManager.setUpAutoUpdate()

LoggerManager.setUpFileLogger()

Expand All @@ -18,14 +16,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

func setUpAutoUpdate() {
let updater = SUUpdater.sharedUpdater()
// force to update since this app is very likely to be buggy.
updater.automaticallyChecksForUpdates = true
// check for updates every hour
updater.updateCheckInterval = 3600
}

func applicationWillTerminate(aNotification: NSNotification) {
if Preference.setUpSystemProxy {
ProxyHelper.setUpSystemProxy(0, enabled: false)
Expand Down
13 changes: 12 additions & 1 deletion SpechtLite/MenuBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ class MenuBarController: NSObject, NSMenuDelegate {
if Preference.autostart {
autostartItem.state = NSOnState
}

menu.addItem(autostartItem)

let devItem = NSMenuItem(title: "Use dev channel", action: #selector(useDevChannelClicked(_:)), keyEquivalent: "")
devItem.target = self
if Preference.useDevChannel {
devItem.state = NSOnState
}
menu.addItem(devItem)

menu.addItemWithTitle("Check for updates", action: #selector(checkForUpdatesClicked(_:)), keyEquivalent: "u").target = self
menu.addItemWithTitle("Show log", action: #selector(showLogFileClicked(_:)), keyEquivalent: "").target = self
menu.addItemWithTitle("Help", action: #selector(helpClicked(_:)), keyEquivalent: "").target = self
Expand Down Expand Up @@ -149,6 +155,11 @@ class MenuBarController: NSObject, NSMenuDelegate {
task.resume()
}

func useDevChannelClicked(sender: AnyObject) {
Preference.useDevChannel = !Preference.useDevChannel
UpdaterManager.setUpAutoUpdate()
}

func autostartAtLoginClicked(sender: AnyObject) {
Preference.autostart = !Preference.autostart
func setUpAutostart() {
Expand Down
9 changes: 9 additions & 0 deletions SpechtLite/Preference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ class Preference {
UserDefault.setBool(newValue, forKey: "allowFromLan")
}
}

static var useDevChannel: Bool {
get {
return UserDefault.boolForKey("useDevChannel")
}
set {
UserDefault.setBool(newValue, forKey: "useDevChannel")
}
}
}
18 changes: 18 additions & 0 deletions SpechtLite/UpdaterManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation
import Sparkle

class UpdaterManager {
static func setUpAutoUpdate() {
let updater = SUUpdater.sharedUpdater()
// force to update since this app is very likely to be buggy.
updater.automaticallyChecksForUpdates = true
// check for updates every hour
updater.updateCheckInterval = 3600

if Preference.useDevChannel {
updater.feedURL = NSURL(string: "https://zhuhaow.github.io/SpechtLite/devappcast.xml")
} else {
updater.feedURL = NSURL(string: "https://zhuhaow.github.io/SpechtLite/stableappcast.xml")
}
}
}

0 comments on commit 1753989

Please sign in to comment.