27 |
27 |
#import "JSON.h"
|
28 |
28 |
#import "APICallback.h"
|
29 |
29 |
#import "OpenStackAppDelegate.h"
|
|
30 |
#import <MobileCoreServices/MobileCoreServices.h>
|
30 |
31 |
|
31 |
32 |
|
32 |
33 |
@implementation FolderViewController
|
... | ... | |
211 |
212 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
|
212 |
213 |
}
|
213 |
214 |
|
214 |
|
id item = [[self.folder sortedContents] objectAtIndex:indexPath.row];
|
|
215 |
id item = [[self.folder sortedContents] objectAtIndex:indexPath.row];
|
|
216 |
[cell.textLabel setLineBreakMode:UILineBreakModeTailTruncation];
|
215 |
217 |
cell.textLabel.text = [item name];
|
216 |
218 |
|
217 |
219 |
if ([[item class] isEqual:[Folder class]]) {
|
... | ... | |
236 |
238 |
}
|
237 |
239 |
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@%@", folderString, objectString];
|
238 |
240 |
} else if ([[item class] isEqual:[StorageObject class]]) {
|
|
241 |
[cell.textLabel setLineBreakMode:UILineBreakModeMiddleTruncation];
|
239 |
242 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
240 |
243 |
|
241 |
244 |
StorageObject *object = item;
|
242 |
|
OpenStackAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
|
243 |
|
NSString *filePath = [appDelegate.cachedObjectsDictionary objectForKey:object.hash];
|
244 |
|
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
|
245 |
|
UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
|
246 |
|
if ([udic.icons count] > 0) {
|
247 |
|
cell.imageView.image = [udic.icons objectAtIndex:0];
|
248 |
|
}
|
249 |
|
} else {
|
250 |
|
NSString *emptyPath = [[NSBundle mainBundle] pathForResource:@"empty-file" ofType:@""];
|
251 |
|
UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:emptyPath]];
|
252 |
|
if ([udic.icons count] > 0) {
|
253 |
|
cell.imageView.image = [udic.icons objectAtIndex:0]; //[UIImage imageNamed:@"file-icon.png"];
|
254 |
|
}
|
255 |
|
}
|
|
245 |
CFStringRef mimeType = (CFStringRef)object.contentType;
|
|
246 |
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL);
|
|
247 |
NSString *emptyPath = [[NSBundle mainBundle] pathForResource:@"empty-file" ofType:@""];
|
|
248 |
UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:emptyPath]];
|
|
249 |
if (((NSString *)uti).length > 0)
|
|
250 |
udic.UTI = (NSString *)uti;
|
|
251 |
if ([udic.icons count] > 0)
|
|
252 |
cell.imageView.image = [udic.icons objectAtIndex:0];
|
256 |
253 |
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@, %@", [item humanizedBytes], [item contentType]];
|
257 |
254 |
}
|
258 |
255 |
|