-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added upload history; ability to copy and delete past uploads
- Loading branch information
Showing
9 changed files
with
195 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2014 display: none;. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface ALUploadHistoryItem : NSObject | ||
|
||
// The originally returned URL, with no scheme or trailing extension. | ||
@property (retain) NSString* URL; | ||
// The local path of the file that was uploaded. | ||
@property (retain) NSURL* filePath; | ||
// The URL that the upload request was originally sent to. | ||
@property (retain) NSURL* originalURL; | ||
|
||
- (void)deleteUpload; | ||
- (void)copyLink; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2014 display: none;. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#import "ALUploadHistoryItem.h" | ||
#import "ALAppDelegate.h" | ||
#import "ALUploadManager.h" | ||
|
||
@implementation ALUploadHistoryItem | ||
|
||
@synthesize URL, filePath, originalURL; | ||
|
||
- (void)deleteUpload { | ||
[ALUploadManager deleteUploadAtURL:URL]; | ||
[[ALAppDelegate sharedAppDelegate] removeUploadFromHistory:self]; | ||
} | ||
|
||
- (void)copyLink { | ||
NSString* url = URL; | ||
|
||
if ([[NSUserDefaults standardUserDefaults] | ||
boolForKey:@"appendExtensions"]) { | ||
NSString* ext = [[filePath path] pathExtension]; | ||
url = [url stringByAppendingPathExtension:ext]; | ||
} | ||
|
||
NSString* linkableURL = | ||
[NSString stringWithFormat:@"%@://%@", [originalURL scheme], url]; | ||
|
||
NSString* errMsg = [self copyString:linkableURL]; | ||
if (errMsg != nil) { | ||
NSString* subtitle = | ||
[NSString stringWithFormat:@"The upload worked, but couldn't copy " | ||
@"the URL to clipboard: %@", | ||
errMsg]; | ||
[[ALAppDelegate sharedAppDelegate] | ||
showNotificationOfType:ALNotificationUploadAborted | ||
title:[NSString | ||
stringWithFormat:@"Error copying %@", linkableURL] | ||
subtitle:subtitle | ||
additionalInfo:nil]; | ||
} else { | ||
NSDictionary* info = | ||
[NSDictionary dictionaryWithObject:linkableURL forKey:@"url"]; | ||
[[ALAppDelegate sharedAppDelegate] | ||
showNotificationOfType:ALNotificationURLCopied | ||
title:linkableURL | ||
subtitle:@"URL copied to clipboard" | ||
additionalInfo:info]; | ||
} | ||
} | ||
|
||
- (NSString*)copyString:(NSString*)str { | ||
NSPasteboard* pboard = [NSPasteboard generalPasteboard]; | ||
|
||
if (pboard == nil) { | ||
return @"Failed to get handle on pasteboard"; | ||
} | ||
|
||
[pboard declareTypes:@[NSPasteboardTypeString] owner:nil]; | ||
[pboard clearContents]; | ||
|
||
NSString* msg; | ||
|
||
@try { | ||
if (![pboard writeObjects:[NSArray arrayWithObject:str]]) { | ||
msg = @"Pasteboard ownership changed"; | ||
} | ||
} | ||
@catch (NSException* e) { | ||
msg = [NSString stringWithFormat:@"%@: %@", e.name, e.reason]; | ||
} | ||
return msg; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.