-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPhotoInfo.xm
More file actions
44 lines (39 loc) · 1.58 KB
/
PhotoInfo.xm
File metadata and controls
44 lines (39 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@interface PUOneUpViewController : UIViewController
-(id)pu_debugCurrentAsset;
@end
@interface PUNavigationController
-(UIViewController *)_currentToolbarViewController;
@end
@interface PHAsset : NSObject
-(CGSize)imageSize;
-(id)mainFileURL;
@end
@interface PUPhotoBrowserTitleViewController : UIViewController
-(void)_setNeedsUpdate;
@end
%hook PUPhotoBrowserTitleViewController
-(void)_setTimeDescription:(id)arg1 {
PHAsset *asset = [(PUOneUpViewController *)[(PUNavigationController *)[[self view] performSelector:@selector(_viewControllerForAncestor)] _currentToolbarViewController] pu_debugCurrentAsset];
if (asset) {
CGSize imageSize = [asset imageSize];
NSString *correctURL = [[[asset mainFileURL] absoluteString] stringByReplacingOccurrencesOfString:@"file://" withString:@""];
NSDictionary *fileAttributes;
NSNumber *fileSizeNumber;
long long fileSize;
float fileSizeMB;
BOOL isDirectory;
if ([[NSFileManager defaultManager] fileExistsAtPath:correctURL isDirectory:&isDirectory]) {
fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:correctURL error:nil];
fileSizeNumber = [fileAttributes objectForKey:NSFileSize];
fileSize = [fileSizeNumber longLongValue];
fileSizeMB = (float)fileSize / (1024 * 1024);
} else {
fileSizeMB = 0;
}
NSString *newTitle = [NSString stringWithFormat:@"%@ (%ix%i, %.02fMB)", arg1, (int)imageSize.width, (int)imageSize.height, fileSizeMB];
%orig(newTitle);
}
else
%orig;
}
%end