Skip to content

Commit

Permalink
Merge pull request #67 from Clipy/release/1.0.10
Browse files Browse the repository at this point in the history
Released v1.0.10
  • Loading branch information
Econa77 committed May 17, 2016
2 parents 89f7657 + 7786dee commit 4b8731f
Show file tree
Hide file tree
Showing 34 changed files with 341 additions and 2,697 deletions.
54 changes: 4 additions & 50 deletions Clipy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

46 changes: 17 additions & 29 deletions Clipy/AppDelegate.swift
Expand Up @@ -14,6 +14,7 @@ import RxCocoa
import RxSwift
import RxOptional
import NSObject_Rx
import LoginServiceKit

@NSApplicationMain
class AppDelegate: NSObject {
Expand All @@ -32,9 +33,7 @@ class AppDelegate: NSObject {
// MARK: - Override Methods
override func validateMenuItem(menuItem: NSMenuItem) -> Bool {
if menuItem.action == #selector(AppDelegate.clearAllHistory) {
if CPYClip.allObjects().count == 0 {
return false
}
return (CPYClip.allObjects().count != 0)
}
return true
}
Expand All @@ -49,7 +48,7 @@ class AppDelegate: NSObject {
// MARK: - Menu Actions
func showPreferenceWindow() {
NSApp.activateIgnoringOtherApps(true)
CPYPreferenceWindowController.sharedPrefsWindowController().showWindow(self)
CPYPreferencesWindowController.sharedController.showWindow(self)
}

func showSnippetEditorWindow() {
Expand All @@ -58,7 +57,7 @@ class AppDelegate: NSObject {
}

func clearAllHistory() {
let isShowAlert = defaults.boolForKey(kCPYPrefShowAlertBeforeClearHistoryKey)
let isShowAlert = defaults.boolForKey(Constants.UserDefaults.showAlertBeforeClearHistory)
if isShowAlert {
let alert = NSAlert()
alert.messageText = LocalizedString.ClearHistory.value
Expand All @@ -73,7 +72,7 @@ class AppDelegate: NSObject {
if result != NSAlertFirstButtonReturn { return }

if alert.suppressionButton?.state == NSOnState {
defaults.setBool(false, forKey: kCPYPrefShowAlertBeforeClearHistoryKey)
defaults.setBool(false, forKey: Constants.UserDefaults.showAlertBeforeClearHistory)
}
defaults.synchronize()
}
Expand All @@ -85,7 +84,7 @@ class AppDelegate: NSObject {
Answers.logCustomEventWithName("selectClipMenuItem", customAttributes: nil)
if let primaryKey = sender.representedObject as? String, let clip = CPYClip(forPrimaryKey: primaryKey) {
PasteboardManager.sharedManager.copyClipToPasteboard(clip)
CPYUtilities.paste()
PasteboardManager.paste()
} else {
Answers.logCustomEventWithName("Cann't fetch clip data", customAttributes: nil)
NSBeep()
Expand All @@ -96,7 +95,7 @@ class AppDelegate: NSObject {
Answers.logCustomEventWithName("selectSnippetMenuItem", customAttributes: nil)
if let primaryKey = sender.representedObject as? String, let snippet = CPYSnippet(forPrimaryKey: primaryKey) {
PasteboardManager.sharedManager.copyStringToPasteboard(snippet.content)
CPYUtilities.paste()
PasteboardManager.paste()
} else {
Answers.logCustomEventWithName("Cann't fetch snippet data", customAttributes: nil)
NSBeep()
Expand All @@ -115,39 +114,28 @@ class AppDelegate: NSObject {

// Launch on system startup
if alert.runModal() == NSAlertFirstButtonReturn {
defaults.setBool(true, forKey: kCPYPrefLoginItemKey)
defaults.setBool(true, forKey: Constants.UserDefaults.loginItem)
toggleLoginItemState()
}
// Do not show this message again
if alert.suppressionButton?.state == NSOnState {
defaults.setBool(true, forKey: kCPYPrefSuppressAlertForLoginItemKey)
defaults.setBool(true, forKey: Constants.UserDefaults.suppressAlertForLoginItem)
}
defaults.synchronize()
}

private func toggleAddingToLoginItems(enable: Bool) {
let appPath = NSBundle.mainBundle().bundlePath
LoginServiceKit.removePathFromLoginItems(appPath)
if enable {
NMLoginItems.removePathFromLoginItems(appPath)
NMLoginItems.addPathToLoginItems(appPath, hide: false)
} else {
NMLoginItems.removePathFromLoginItems(appPath)
LoginServiceKit.addPathToLoginItems(appPath)
}
}

private func toggleLoginItemState() {
let isInLoginItems = NSUserDefaults.standardUserDefaults().boolForKey(kCPYPrefLoginItemKey)
let isInLoginItems = NSUserDefaults.standardUserDefaults().boolForKey(Constants.UserDefaults.loginItem)
toggleAddingToLoginItems(isInLoginItems)
}

// MARK: - Version Up Methods
private func checkUpdates() {
let feed = "https://clipy-app.com/appcast.xml"
if let feedURL = NSURL(string: feed) {
SUUpdater.sharedUpdater().feedURL = feedURL
}
}

}

// MARK: - NSApplication Delegate
Expand All @@ -164,15 +152,15 @@ extension AppDelegate: NSApplicationDelegate {
CPYHotKeyManager.sharedManager.registerHotKeys()

// Show Login Item
if !defaults.boolForKey(kCPYPrefLoginItemKey) && !defaults.boolForKey(kCPYPrefSuppressAlertForLoginItemKey) {
if !defaults.boolForKey(Constants.UserDefaults.loginItem) && !defaults.boolForKey(Constants.UserDefaults.suppressAlertForLoginItem) {
promptToAddLoginItems()
}

// Sparkle
let updater = SUUpdater.sharedUpdater()
checkUpdates()
updater.automaticallyChecksForUpdates = defaults.boolForKey(kCPYEnableAutomaticCheckKey)
updater.updateCheckInterval = NSTimeInterval(defaults.integerForKey(kCPYUpdateCheckIntervalKey))
updater.feedURL = Constants.Application.appcastURL
updater.automaticallyChecksForUpdates = defaults.boolForKey(Constants.Update.enableAutomaticCheck)
updater.updateCheckInterval = NSTimeInterval(defaults.integerForKey(Constants.Update.checkInterval))

// Binding Events
bind()
Expand All @@ -192,7 +180,7 @@ extension AppDelegate: NSApplicationDelegate {
private extension AppDelegate {
private func bind() {
// Login Item
defaults.rx_observe(Bool.self, kCPYPrefLoginItemKey, options: [.New])
defaults.rx_observe(Bool.self, Constants.UserDefaults.loginItem, options: [.New])
.filterNil()
.subscribeNext { [weak self] enabled in
self?.toggleLoginItemState()
Expand Down
91 changes: 0 additions & 91 deletions Clipy/CPYConstants.swift

This file was deleted.

2 changes: 0 additions & 2 deletions Clipy/Clipy-Bridging-Header.h
Expand Up @@ -7,7 +7,5 @@
#import <PTHotKey/PTHotKeyCenter.h>

// Library
#import "NMLoginItems.h"
#import "DBPrefsWindowController.h"
#import "ShortcutRecorder.h"

82 changes: 82 additions & 0 deletions Clipy/Constants.swift
@@ -0,0 +1,82 @@
//
// Constants.swift
// Clipy
//
// Created by 古林俊佑 on 2016/04/17.
// Copyright © 2016年 Shunsuke Furubayashi. All rights reserved.
//

import Foundation

struct Constants {

struct Application {
static let name = "Clipy"
static let appcastURL = NSURL(string: "https://clipy-app.com/appcast.xml")!
}

struct Menu {
static let clip = "ClipMenu"
static let history = "HistoryMenu"
static let snippet = "SnippetsMenu"
}

struct Common {
static let index = "index"
static let title = "title"
static let snippets = "snippets"
static let content = "content"
static let selector = "selector"
static let draggedDataType = "DraggedDataType"
}

struct UserDefaults {
static let hotKeys = "kCPYPrefHotKeysKey"
static let menuIconSize = "kCPYPrefMenuIconSizeKey"
static let maxHistorySize = "kCPYPrefMaxHistorySizeKey"
static let timeInterval = "kCPYPrefTimeIntervalKey"
static let storeTypes = "kCPYPrefStoreTypesKey"
static let inputPasteCommand = "kCPYPrefInputPasteCommandKey"
static let showIconInTheMenu = "kCPYPrefShowIconInTheMenuKey"
static let numberOfItemsPlaceInline = "kCPYPrefNumberOfItemsPlaceInlineKey"
static let numberOfItemsPlaceInsideFolder = "kCPYPrefNumberOfItemsPlaceInsideFolderKey"
static let maxMenuItemTitleLength = "kCPYPrefMaxMenuItemTitleLengthKey"
static let menuItemsTitleStartWithZero = "kCPYPrefMenuItemsTitleStartWithZeroKey"
static let reorderClipsAfterPasting = "kCPYPrefReorderClipsAfterPasting"
static let addClearHistoryMenuItem = "kCPYPrefAddClearHistoryMenuItemKey"
static let showAlertBeforeClearHistory = "kCPYPrefShowAlertBeforeClearHistoryKey"
static let menuItemsAreMarkedWithNumbers = "menuItemsAreMarkedWithNumbers"
static let showToolTipOnMenuItem = "showToolTipOnMenuItem"
static let showImageInTheMenu = "showImageInTheMenu"
static let addNumericKeyEquivalents = "addNumericKeyEquivalents"
static let maxLengthOfToolTip = "maxLengthOfToolTipKey"
static let loginItem = "loginItem"
static let suppressAlertForLoginItem = "suppressAlertForLoginItem"
static let showStatusItem = "kCPYPrefShowStatusItemKey"
static let thumbnailWidth = "thumbnailWidth"
static let thumbnailHeight = "thumbnailHeight"
static let overwriteSameHistory = "kCPYPrefOverwriteSameHistroy"
static let copySameHistory = "kCPYPrefCopySameHistroy"
}

struct Update {
static let enableAutomaticCheck = "kCPYEnableAutomaticCheckKey"
static let checkInterval = "kCPYUpdateCheckIntervalKey"
}

struct Notification {
static let closeSnippetEditor = "kCPYSnippetEditorWillCloseNotification"
}

struct Xml {
static let fileType = "xml"
static let type = "type"
static let rootElement = "folders"
static let folderElement = "folder"
static let snippetElement = "snippet"
static let titleElement = "title"
static let snippetsElement = "snippets"
static let contentElement = "content"
}

}
2 changes: 1 addition & 1 deletion Clipy/Extensions/NSMenuItem+Initialize.swift
Expand Up @@ -10,6 +10,6 @@ import Foundation

extension NSMenuItem {
convenience init(title: String, action: Selector) {
self.init(title: title, action: action, keyEquivalent: kEmptyString)
self.init(title: title, action: action, keyEquivalent: "")
}
}
4 changes: 2 additions & 2 deletions Clipy/Info.plist
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.9</string>
<string>1.0.10</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.9</string>
<string>1.0.10</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
37 changes: 0 additions & 37 deletions Clipy/Libraries/DBPrefsWindowController/DBPrefsWindowController.h

This file was deleted.

0 comments on commit 4b8731f

Please sign in to comment.