Save your Bkstg media (Reddit TweakBounty)
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 7 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. #import <Photos/Photos.h>
  2. #import <AssetsLibrary/AssetsLibrary.h>
  3. #import "MBProgressHUD.h"
  4. @interface FLImageView : UIView
  5. @property (assign, nonatomic) UIImage *originalImage;
  6. -(UIImage *)image;
  7. @end
  8. @interface FLHubPhotoViewController : UIViewController
  9. @property (assign, nonatomic) FLImageView *imageView;
  10. @end
  11. @interface FLVideoContentView : UIView
  12. @property (assign, nonatomic) NSURL *videoURL;
  13. @end
  14. @interface FLBaseContentHolderView : UIView
  15. @property (assign, nonatomic) FLVideoContentView *videoView;
  16. @end
  17. @interface FLPostCollectionViewCell : UIView
  18. @property (assign, nonatomic) FLBaseContentHolderView *postView;
  19. @end
  20. @interface FLCollageSinglePhotoView : UIView
  21. @property (assign, nonatomic) FLImageView* photoView;
  22. @end
  23. @interface FLCollageSinglePhotoViewController : UIViewController
  24. @property (assign, nonatomic) FLCollageSinglePhotoView* photoView;
  25. @end
  26. %hook FLHubPhotoViewController
  27. -(void)viewDidLoad
  28. {
  29. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
  30. initWithTarget:self
  31. action:@selector(handleLongPress:)];
  32. longPress.minimumPressDuration = 1.5;
  33. [self.view addGestureRecognizer:longPress];
  34. %orig;
  35. }
  36. %new
  37. -(void)handleLongPress:(UILongPressGestureRecognizer *)sender
  38. {
  39. UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  40. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  41. // Cancel button tappped.
  42. [self dismissViewControllerAnimated:YES completion:^{
  43. }];
  44. }]];
  45. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Save Image" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  46. UIImage *snapshot = self.imageView.originalImage;
  47. [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^
  48. {
  49. PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:snapshot];
  50. changeRequest.creationDate = [NSDate date];
  51. }
  52. completionHandler:^(BOOL success, NSError *error)
  53. {
  54. if (success)
  55. {
  56. NSLog(@"successfully saved");
  57. }
  58. else
  59. {
  60. NSLog(@"error saving to photos: %@", error);
  61. }
  62. }];
  63. [self dismissViewControllerAnimated:YES completion:^{
  64. }];
  65. }]];
  66. // Present action sheet.
  67. [self presentViewController:actionSheet animated:YES completion:nil];
  68. }
  69. %end
  70. @interface FLPhotoDetailViewController : UIViewController
  71. @property (assign, nonatomic) FLImageView *photoView;
  72. @end
  73. %hook FLPhotoDetailViewController
  74. -(void)viewDidLoad
  75. {
  76. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
  77. initWithTarget:self
  78. action:@selector(handleLongPress:)];
  79. longPress.minimumPressDuration = 1.5;
  80. [self.view addGestureRecognizer:longPress];
  81. %orig;
  82. }
  83. %new
  84. -(void)handleLongPress:(UILongPressGestureRecognizer *)sender
  85. {
  86. UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  87. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  88. // Cancel button tappped.
  89. [self dismissViewControllerAnimated:YES completion:^{
  90. }];
  91. }]];
  92. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Save Image" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  93. UIImage *snapshot = [self.photoView image];
  94. [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^
  95. {
  96. PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:snapshot];
  97. changeRequest.creationDate = [NSDate date];
  98. }
  99. completionHandler:^(BOOL success, NSError *error)
  100. {
  101. if (success)
  102. {
  103. NSLog(@"successfully saved");
  104. }
  105. else
  106. {
  107. NSLog(@"error saving to photos: %@", error);
  108. }
  109. }];
  110. [self dismissViewControllerAnimated:YES completion:^{
  111. }];
  112. }]];
  113. // Present action sheet.
  114. [self presentViewController:actionSheet animated:YES completion:nil];
  115. }
  116. %end
  117. %hook FLCollageSinglePhotoViewController
  118. -(void)viewDidLoad
  119. {
  120. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
  121. initWithTarget:self
  122. action:@selector(handleLongPress:)];
  123. longPress.minimumPressDuration = 1.5;
  124. [self.view addGestureRecognizer:longPress];
  125. %orig;
  126. }
  127. %new
  128. -(void)handleLongPress:(UILongPressGestureRecognizer *)sender
  129. {
  130. UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  131. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  132. // Cancel button tappped.
  133. [self dismissViewControllerAnimated:YES completion:^{
  134. }];
  135. }]];
  136. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Save Image" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  137. UIImage *snapshot = self.photoView.photoView.originalImage;
  138. [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^
  139. {
  140. PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:snapshot];
  141. changeRequest.creationDate = [NSDate date];
  142. }
  143. completionHandler:^(BOOL success, NSError *error)
  144. {
  145. if (success)
  146. {
  147. NSLog(@"successfully saved");
  148. }
  149. else
  150. {
  151. NSLog(@"error saving to photos: %@", error);
  152. }
  153. }];
  154. [self dismissViewControllerAnimated:YES completion:^{
  155. }];
  156. }]];
  157. // Present action sheet.
  158. [self presentViewController:actionSheet animated:YES completion:nil];
  159. }
  160. %end
  161. // IGNORE ABOVE. SAVES IMAGES
  162. //FLAVPlayerLayerView
  163. //FLHubVideoCollection
  164. //FLVideoContentHolderVIew
  165. %hook FLPostCollectionViewCell
  166. -(void)setPostView:(FLBaseContentHolderView *)holderView
  167. {
  168. if([holderView respondsToSelector:@selector(videoView)])
  169. {
  170. if(holderView.videoView.videoURL)
  171. {
  172. UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(downloadVideo:)];
  173. doubleTap.numberOfTapsRequired = 3;
  174. [self addGestureRecognizer:doubleTap];
  175. }
  176. }
  177. %orig;
  178. }
  179. %new
  180. -(void)downloadVideo:(UITapGestureRecognizer *)sender
  181. {
  182. [sender setEnabled:NO];
  183. NSLog(@"DOWNLOAD FROM URL: %@", self.postView.videoView.videoURL);
  184. UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  185. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  186. [sender setEnabled:YES];
  187. // Cancel button tappped.
  188. [[[UIApplication sharedApplication] keyWindow].rootViewController dismissViewControllerAnimated:YES completion:^{
  189. }];
  190. }]];
  191. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Save Video" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  192. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
  193. hud.label.text = @"Downloading";
  194. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  195. NSLog(@"Downloading Started");
  196. NSURL *url = self.postView.videoView.videoURL;
  197. NSData *urlData = [NSData dataWithContentsOfURL:url];
  198. if ( urlData )
  199. {
  200. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  201. NSString *documentsDirectory = [paths objectAtIndex:0];
  202. NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"tempVideo.mp4"];
  203. dispatch_async(dispatch_get_main_queue(), ^{
  204. hud.label.text = @"Saving";
  205. [urlData writeToFile:filePath atomically:YES];
  206. NSLog(@"File Saved !");
  207. hud.label.text = @"Importing";
  208. [sender setEnabled:YES];
  209. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  210. NSString *documentsDirectory = [paths objectAtIndex:0];
  211. [[[ALAssetsLibrary alloc] init] writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", documentsDirectory,@"tempVideo.mp4"]] completionBlock:^(NSURL *assetURL, NSError *error) {
  212. if(assetURL) {
  213. hud.label.text = @"DONE!";
  214. [hud hideAnimated:YES];
  215. } else {
  216. hud.label.text = @"ERROR. Try Again.";
  217. }
  218. }];
  219. });
  220. }
  221. });
  222. [[[UIApplication sharedApplication] keyWindow].rootViewController dismissViewControllerAnimated:YES completion:^{
  223. }];
  224. }]];
  225. // Present action sheet.
  226. [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:actionSheet animated:YES completion:nil];
  227. }
  228. %end
  229. //%hook FLVideoContentHolderView
  230. //FL_doubleTapOnpost
  231. /*
  232. %hook FLAVPlayerLayerView
  233. -(id)init {
  234. NSLog(@"IW HAVE BEEN INITIATEDDDDDDDDDDDDDD");
  235. UILongPressGestureRecognizer *longPress = [[[UILongPressGestureRecognizer alloc]
  236. initWithTarget:self
  237. action:@selector(handleLongPress:)] autorelease];
  238. longPress.minimumPressDuration = 2.0;
  239. [self addGestureRecognizer:longPress];
  240. return %orig;
  241. }
  242. %new
  243. -(void)handleLongPress:(UILongPressGestureRecognizer *)sender
  244. {
  245. NSLog(@"Video URL: %@", self.videoView.videoURL);
  246. UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  247. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  248. // Cancel button tappped.
  249. [[[UIApplication sharedApplication] keyWindow].rootViewController dismissViewControllerAnimated:YES completion:^{
  250. }];
  251. }]];
  252. [actionSheet addAction:[UIAlertAction actionWithTitle:@"Save Image" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  253. UIImage *snapshot = [self.photoView image];
  254. [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^
  255. {
  256. PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:snapshot];
  257. changeRequest.creationDate = [NSDate date];
  258. }
  259. completionHandler:^(BOOL success, NSError *error)
  260. {
  261. if (success)
  262. {
  263. NSLog(@"successfully saved");
  264. }
  265. else
  266. {
  267. NSLog(@"error saving to photos: %@", error);
  268. }
  269. }];
  270. [[[UIApplication sharedApplication] keyWindow].rootViewController dismissViewControllerAnimated:YES completion:^{
  271. }];
  272. }]];
  273. // Present action sheet.
  274. [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:actionSheet animated:YES completion:nil];
  275. }*/