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

Commit

Permalink
Beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
edualm committed Feb 12, 2016
1 parent d8b7257 commit 357ca35
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 32 deletions.
10 changes: 7 additions & 3 deletions FinderShareExtension/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ShareViewController: NSViewController, NSTableViewDataSource {
override func loadView() {
super.loadView()

if LatteShare.sharedInstance.getConnection().hasStoredDetails() {

}

let item = self.extensionContext!.inputItems[0] as! NSExtensionItem

if let a = item.attachments {
Expand Down Expand Up @@ -100,7 +104,7 @@ class ShareViewController: NSViewController, NSTableViewDataSource {

let outputItems = [outputItem]

LatteShare.sharedInstance.getConnection()?.uploadFile(filePaths[0], success: { url in
LatteShare.sharedInstance.getConnection().uploadFile(filePaths[0], success: { url in
NSPasteboard.generalPasteboard().clearContents()
NSPasteboard.generalPasteboard().writeObjects([url])

Expand Down Expand Up @@ -131,7 +135,7 @@ class ShareViewController: NSViewController, NSTableViewDataSource {
})
} else {
for path in filePaths {
LatteShare.sharedInstance.getConnection()?.uploadFile(path, success: { url in
LatteShare.sharedInstance.getConnection().uploadFile(path, success: { url in
print(url)

let arr = url.characters.split{ $0 == "/" }.map(String.init)
Expand Down Expand Up @@ -161,7 +165,7 @@ class ShareViewController: NSViewController, NSTableViewDataSource {

let outputItems = [outputItem]

try! LatteShare.sharedInstance.getConnection()?.createGroup(ids, success: { url in
try! LatteShare.sharedInstance.getConnection().createGroup(ids, success: { url in
NSPasteboard.generalPasteboard().clearContents()
NSPasteboard.generalPasteboard().writeObjects([url])

Expand Down
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2016 Eduardo Almeida

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---

The app icon has a flaticon license (http://cdn.flaticon.com/license/license.pdf)
30 changes: 20 additions & 10 deletions LatteGrab/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,63 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16@2x.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32@2x.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128@2x.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_256x256.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_256x256@2x.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"idiom" : "mac",
"filename" : "icon_512x512.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"idiom" : "mac",
"filename" : "icon_512x512@2x.png",
"scale" : "2x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions LatteGrab/Assets.xcassets/Latte.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"idiom" : "mac",
"filename" : "Latte.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"idiom" : "mac",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
18 changes: 18 additions & 0 deletions LatteGrab/Assets.xcassets/MenuBarIcon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "mac",
"filename" : "icon_16x16.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"filename" : "icon_16x16@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions LatteGrab/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<outlet property="quotaField" destination="CP7-yc-unr" id="Q9T-hi-oCf"/>
<outlet property="serverField" destination="4v9-77-kXp" id="eaA-Bi-uWB"/>
<outlet property="usernameField" destination="KtJ-9G-wQA" id="Qe5-Ax-FDh"/>
<outlet property="window" destination="0Ka-B5-rcE" id="tnW-7Q-GIW"/>
</connections>
</customObject>
<menu id="0SE-yF-BE1">
Expand Down Expand Up @@ -177,12 +178,12 @@
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="General" identifier="1" id="eeQ-fy-uv1">
<view key="view" id="A4l-IN-eZh">
<rect key="frame" x="10" y="33" width="434" height="208"/>
<view key="view" ambiguous="YES" id="A4l-IN-eZh">
<rect key="frame" x="10" y="33" width="192" height="0.0"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Q6f-aq-vqt">
<rect key="frame" x="15" y="178" width="404" height="18"/>
<rect key="frame" x="15" y="-30" width="404" height="18"/>
<buttonCell key="cell" type="check" title="Open at Login" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="GVT-AF-liq">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -195,7 +196,7 @@
</view>
</tabViewItem>
<tabViewItem label="latteshare server" identifier="2" id="LXb-j8-flf">
<view key="view" ambiguous="YES" id="ndb-uE-eko">
<view key="view" id="ndb-uE-eko">
<rect key="frame" x="10" y="33" width="434" height="208"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -334,6 +335,9 @@
</tabView>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="c3a-LZ-xCv" id="dIc-Ax-saD"/>
</connections>
<point key="canvasLocation" x="963" y="839"/>
</window>
</objects>
Expand Down
6 changes: 3 additions & 3 deletions LatteGrab/LatteShare.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class LatteShare {
}

public func setServer(connectionString cs: String) {

connectionString = cs
}

public func hasAuthenticationDetails() -> Bool {
Expand All @@ -69,12 +69,12 @@ public class LatteShare {
}
}

public func getConnection() -> LatteShareConnection? {
public func getConnection() -> LatteShareConnection {
if connection == nil {
newConnection()
}

return connection
return connection!
}

public func save() {
Expand Down
4 changes: 4 additions & 0 deletions LatteGrab/LatteShareConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class LatteShareConnection {
token = apiToken
}

public func hasStoredDetails() -> Bool {
return username != nil && token != nil
}

public func getUserInfo(success: LatteShareUserInformation -> (), failure: String -> ()) throws {
if username == nil || token == nil {
throw APIError.NotLoggedIn
Expand Down
2 changes: 1 addition & 1 deletion LatteGrab/ScreenshotWatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ScreenshotWatcher : DirectoryMonitorDelegate {

if attrNames.names != nil {
if attrNames.names!.contains("com.apple.metadata:kMDItemIsScreenCapture") || attrNames.names!.contains("com.apple.metadata:kMDItemScreenCaptureGlobalRect") || attrNames.names!.contains("com.apple.metadata:kMDItemScreenCaptureType") {
LatteShare.sharedInstance.getConnection()?.uploadFile(fullElemPath, success: { url in
LatteShare.sharedInstance.getConnection().uploadFile(fullElemPath, success: { url in

NSPasteboard.generalPasteboard().clearContents()
NSPasteboard.generalPasteboard().writeObjects([url])
Expand Down
4 changes: 1 addition & 3 deletions LatteGrab/SettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class SettingsController: NSObject, NSWindowDelegate {
}

func windowDidChangeOcclusionState(notification: NSNotification) {
// FIXME: Fix this, not working!

updateRemoteInfo(self)
}

Expand All @@ -56,7 +54,7 @@ class SettingsController: NSObject, NSWindowDelegate {
}

func updateRemoteInfo(sender: AnyObject!) {
try! LatteShare.sharedInstance.getConnection()?.getUserInfo({ userInfo in
try! LatteShare.sharedInstance.getConnection().getUserInfo({ userInfo in
let usedReadable = NSByteCountFormatter.stringFromByteCount(userInfo.usedDiskSpace, countStyle: .File)
let quotaReadable = NSByteCountFormatter.stringFromByteCount(userInfo.quota, countStyle: .File)

Expand Down
4 changes: 2 additions & 2 deletions LatteGrab/StatusBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StatusBarController: NSObject, ScreenshotWatcherDelegate, AuthenticationCh
override func awakeFromNib() {
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength)

statusItem.title = "LG"
statusItem.image = NSImage(named: "MenuBarIcon")
statusItem.menu = menu

refresh()
Expand Down Expand Up @@ -88,7 +88,7 @@ class StatusBarController: NSObject, ScreenshotWatcherDelegate, AuthenticationCh

let arr = ri.id.characters.split{ $0 == "/" }.map(String.init)

try! LatteShare.sharedInstance.getConnection()?.deleteFile(arr.last!, success: {
try! LatteShare.sharedInstance.getConnection().deleteFile(arr.last!, success: {

let ris = RecentItems()

Expand Down

0 comments on commit 357ca35

Please sign in to comment.