diff --git a/Coffeefy.xcodeproj/project.pbxproj b/Coffeefy.xcodeproj/project.pbxproj
index 22a0bea..108c74c 100644
--- a/Coffeefy.xcodeproj/project.pbxproj
+++ b/Coffeefy.xcodeproj/project.pbxproj
@@ -354,11 +354,12 @@
baseConfigurationReference = 3C84D6F33407824D39B927AE /* Pods-Coffeefy.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CODE_SIGN_IDENTITY = "Mac Developer";
+ CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = PJ627876A5;
INFOPLIST_FILE = Coffeefy/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = kim.taegon.Coffeefy;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
@@ -370,11 +371,12 @@
baseConfigurationReference = 0356958897CBA1B6DE6A3E02 /* Pods-Coffeefy.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CODE_SIGN_IDENTITY = "Mac Developer";
+ CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = PJ627876A5;
INFOPLIST_FILE = Coffeefy/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = kim.taegon.Coffeefy;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
diff --git a/Coffeefy/AboutPreferencesView.xib b/Coffeefy/AboutPreferencesView.xib
index dda482c..b0cf985 100644
--- a/Coffeefy/AboutPreferencesView.xib
+++ b/Coffeefy/AboutPreferencesView.xib
@@ -29,7 +29,7 @@
-
+
@@ -52,6 +52,11 @@
+
+
+
+
+
@@ -109,4 +114,7 @@
+
+
+
diff --git a/Coffeefy/AppDelegate.swift b/Coffeefy/AppDelegate.swift
index 1703278..99e3a51 100644
--- a/Coffeefy/AppDelegate.swift
+++ b/Coffeefy/AppDelegate.swift
@@ -11,11 +11,13 @@ import MASPreferences
import ReachabilitySwift
import CoreWLAN
+public let StopAnimationNotification = NSNotification.Name("StopAnimationNotification")
+
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var statusMenu: NSMenu!
- var statusItem: NSStatusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
+ var statusItem: NSStatusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
var _prefWindowController: NSWindowController?
var prefWindowController: NSWindowController! {
@@ -33,12 +35,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}
+ var currentIconIndex = 3
+ var animTimer: Timer?
+
let reachability = Reachability()!
let bot = LoginBot()
func applicationDidFinishLaunching(_ aNotification: Notification) {
- statusItem.image = NSImage(named: NSImageNameMenuOnStateTemplate)
statusItem.menu = statusMenu
+ loadStatusImage(name: "coffeefy3")
+
+ NotificationCenter.default.addObserver(self, selector: #selector(self.stopAnimation), name: StopAnimationNotification, object: nil)
// start watching wifi connection status
NotificationCenter.default.addObserver(self, selector: #selector(self.reachabilityChanged),name: ReachabilityChangedNotification,object: reachability)
@@ -61,11 +68,45 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// 스타벅스 SSID일 때만 반응
let ssid = CWWiFiClient()?.interface(withName: nil)?.ssid() ?? ""
if ssid.lowercased().contains("starbucks") {
+ startAnimatingStatusImage()
bot.login()
} else {
NSLog("This application works only with Starbucks Wifi network")
}
}
+
+ func stopAnimation(note: NSNotification) {
+ stopAnimatingStatusImage()
+ }
+
+ func loadStatusImage(name: String) {
+ if let button = statusItem.button {
+ let size = NSMakeSize(18.0, 18.0)
+ button.image = NSImage(named: name)
+ button.image!.size = size
+ }
+ }
+
+ func startAnimatingStatusImage() {
+ currentIconIndex = 0
+ updateStatusImage(index: 0)
+
+ animTimer = Timer.scheduledTimer(withTimeInterval: 4.0/15.0, repeats: true){ timer in
+ self.currentIconIndex = ( self.currentIconIndex + 1 ) % 4
+ self.updateStatusImage(index: self.currentIconIndex)
+ }
+ }
+
+ func stopAnimatingStatusImage() {
+ animTimer?.invalidate()
+ animTimer = nil
+
+ updateStatusImage(index: 3)
+ }
+
+ func updateStatusImage(index: Int) {
+ loadStatusImage(name: "coffeefy\(currentIconIndex)")
+ }
@IBAction func openPreference(sender: AnyObject?) {
prefWindowController.showWindow(self)
diff --git a/Coffeefy/Assets.xcassets/AppIcon.appiconset/Contents.json b/Coffeefy/Assets.xcassets/AppIcon.appiconset/Contents.json
index 2db2b1c..a9da92f 100644
--- a/Coffeefy/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ b/Coffeefy/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -36,18 +36,21 @@
"scale" : "1x"
},
{
- "idiom" : "mac",
"size" : "256x256",
+ "idiom" : "mac",
+ "filename" : "coffeefy_512.png",
"scale" : "2x"
},
{
- "idiom" : "mac",
"size" : "512x512",
+ "idiom" : "mac",
+ "filename" : "coffeefy.png",
"scale" : "1x"
},
{
- "idiom" : "mac",
"size" : "512x512",
+ "idiom" : "mac",
+ "filename" : "coffeefy@2x.png",
"scale" : "2x"
}
],
diff --git a/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy.png b/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy.png
new file mode 100644
index 0000000..dc12223
Binary files /dev/null and b/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy.png differ
diff --git a/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy@2x.png b/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy@2x.png
new file mode 100644
index 0000000..dcab6f7
Binary files /dev/null and b/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy@2x.png differ
diff --git a/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy_512.png b/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy_512.png
new file mode 100644
index 0000000..dc12223
Binary files /dev/null and b/Coffeefy/Assets.xcassets/AppIcon.appiconset/coffeefy_512.png differ
diff --git a/Coffeefy/Assets.xcassets/Contents.json b/Coffeefy/Assets.xcassets/Contents.json
new file mode 100644
index 0000000..da4a164
--- /dev/null
+++ b/Coffeefy/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/Coffeefy/Assets.xcassets/coffeefy0.imageset/Contents.json b/Coffeefy/Assets.xcassets/coffeefy0.imageset/Contents.json
new file mode 100644
index 0000000..b4f4e2b
--- /dev/null
+++ b/Coffeefy/Assets.xcassets/coffeefy0.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "coffeefy0.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template"
+ }
+}
\ No newline at end of file
diff --git a/Coffeefy/Assets.xcassets/coffeefy0.imageset/coffeefy0.pdf b/Coffeefy/Assets.xcassets/coffeefy0.imageset/coffeefy0.pdf
new file mode 100644
index 0000000..77009a2
Binary files /dev/null and b/Coffeefy/Assets.xcassets/coffeefy0.imageset/coffeefy0.pdf differ
diff --git a/Coffeefy/Assets.xcassets/coffeefy1.imageset/Contents.json b/Coffeefy/Assets.xcassets/coffeefy1.imageset/Contents.json
new file mode 100644
index 0000000..3723d87
--- /dev/null
+++ b/Coffeefy/Assets.xcassets/coffeefy1.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "coffeefy1.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template"
+ }
+}
\ No newline at end of file
diff --git a/Coffeefy/Assets.xcassets/coffeefy1.imageset/coffeefy1.pdf b/Coffeefy/Assets.xcassets/coffeefy1.imageset/coffeefy1.pdf
new file mode 100644
index 0000000..78a774c
Binary files /dev/null and b/Coffeefy/Assets.xcassets/coffeefy1.imageset/coffeefy1.pdf differ
diff --git a/Coffeefy/Assets.xcassets/coffeefy2.imageset/Contents.json b/Coffeefy/Assets.xcassets/coffeefy2.imageset/Contents.json
new file mode 100644
index 0000000..668ecb1
--- /dev/null
+++ b/Coffeefy/Assets.xcassets/coffeefy2.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "coffeefy2.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template"
+ }
+}
\ No newline at end of file
diff --git a/Coffeefy/Assets.xcassets/coffeefy2.imageset/coffeefy2.pdf b/Coffeefy/Assets.xcassets/coffeefy2.imageset/coffeefy2.pdf
new file mode 100644
index 0000000..e620c0b
Binary files /dev/null and b/Coffeefy/Assets.xcassets/coffeefy2.imageset/coffeefy2.pdf differ
diff --git a/Coffeefy/Assets.xcassets/coffeefy3.imageset/Contents.json b/Coffeefy/Assets.xcassets/coffeefy3.imageset/Contents.json
new file mode 100644
index 0000000..aa060cf
--- /dev/null
+++ b/Coffeefy/Assets.xcassets/coffeefy3.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "coffeefy4.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template"
+ }
+}
\ No newline at end of file
diff --git a/Coffeefy/Assets.xcassets/coffeefy3.imageset/coffeefy4.pdf b/Coffeefy/Assets.xcassets/coffeefy3.imageset/coffeefy4.pdf
new file mode 100644
index 0000000..9251494
Binary files /dev/null and b/Coffeefy/Assets.xcassets/coffeefy3.imageset/coffeefy4.pdf differ
diff --git a/Coffeefy/Info.plist b/Coffeefy/Info.plist
index 7735244..5b09d51 100644
--- a/Coffeefy/Info.plist
+++ b/Coffeefy/Info.plist
@@ -17,7 +17,7 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0
+ 1.1
CFBundleVersion
1
LSApplicationCategoryType
diff --git a/Coffeefy/LoginBot.swift b/Coffeefy/LoginBot.swift
index 82ac25c..a24c35b 100644
--- a/Coffeefy/LoginBot.swift
+++ b/Coffeefy/LoginBot.swift
@@ -64,6 +64,7 @@ class LoginBot: NSObject, WKScriptMessageHandler, WKNavigationDelegate {
}
NSLog("This application works only with Startbucks Wifi network.")
+ self.stopAnimation()
}
}
@@ -93,6 +94,10 @@ class LoginBot: NSObject, WKScriptMessageHandler, WKNavigationDelegate {
NSUserNotificationCenter.default.scheduleNotification(noti)
}
+ func stopAnimation() {
+ NotificationCenter.default.post(name: StopAnimationNotification, object: nil)
+ }
+
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
let body = message.body as! String
@@ -104,6 +109,7 @@ class LoginBot: NSObject, WKScriptMessageHandler, WKNavigationDelegate {
} else if body.hasPrefix("alert:") {
let errorMessage = body.substring(from: body.characters.index(body.characters.startIndex, offsetBy: 6))
notify(title: "인증 에러", subtitle: errorMessage, informativeText: nil)
+ stopAnimation()
}
}
@@ -116,6 +122,7 @@ class LoginBot: NSObject, WKScriptMessageHandler, WKNavigationDelegate {
if host == "www.istarbucks.co.kr" || host.hasPrefix("www.google.") {
webView.stopLoading()
notify(title: "접속 성공", subtitle: "이제 스타벅스 와이파이를 사용할 수 있습니다.", informativeText: nil)
+ stopAnimation()
}
}
}