|
@@ -946,7 +946,42 @@
|
|
|
#pragma mark ===== Save selected File =====
|
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
|
|
|
|
--(void)saveSelectedFilesSelector:(NSString *)path didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
|
|
|
+- (void)saveToPhotoAlbum:(tableMetadata *)metadata
|
|
|
+{
|
|
|
+ NSString *fileNamePath = [CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView];
|
|
|
+ PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
|
|
|
+
|
|
|
+ if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image] && status == PHAuthorizationStatusAuthorized) {
|
|
|
+
|
|
|
+ UIImage *image = [UIImage imageWithContentsOfFile:fileNamePath];
|
|
|
+
|
|
|
+ if (image)
|
|
|
+ UIImageWriteToSavedPhotosAlbum(image, self, @selector(saveSelectedFilesSelector: didFinishSavingWithError: contextInfo:), nil);
|
|
|
+ else
|
|
|
+ [appDelegate messageNotification:@"_save_selected_files_" description:@"_file_not_saved_cameraroll_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([metadata.typeFile isEqualToString: k_metadataTypeFile_video] && status == PHAuthorizationStatusAuthorized) {
|
|
|
+
|
|
|
+ if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(fileNamePath)) {
|
|
|
+
|
|
|
+ UISaveVideoAtPathToSavedPhotosAlbum(fileNamePath, self, @selector(saveSelectedFilesSelector: didFinishSavingWithError: contextInfo:), nil);
|
|
|
+ } else {
|
|
|
+ [appDelegate messageNotification:@"_save_selected_files_" description:@"_file_not_saved_cameraroll_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (status != PHAuthorizationStatusAuthorized) {
|
|
|
+
|
|
|
+ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_access_photo_not_enabled_", nil) message:NSLocalizedString(@"_access_photo_not_enabled_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
|
|
|
+
|
|
|
+ [alertController addAction:okAction];
|
|
|
+ [self presentViewController:alertController animated:YES completion:nil];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)saveSelectedFilesSelector:(NSString *)path didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
|
|
|
{
|
|
|
if (error)
|
|
|
[appDelegate messageNotification:@"_save_selected_files_" description:@"_file_not_saved_cameraroll_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
|
|
@@ -1133,39 +1168,9 @@
|
|
|
// Save to Photo Album
|
|
|
if ([selector isEqualToString:selectorSave] && [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
|
|
|
|
|
|
- NSString *fileNamePath = [CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView];
|
|
|
- PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
|
|
|
-
|
|
|
- if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image] && status == PHAuthorizationStatusAuthorized) {
|
|
|
-
|
|
|
- UIImage *image = [UIImage imageWithContentsOfFile:fileNamePath];
|
|
|
-
|
|
|
- if (image)
|
|
|
- UIImageWriteToSavedPhotosAlbum(image, self, @selector(saveSelectedFilesSelector: didFinishSavingWithError: contextInfo:), nil);
|
|
|
- else
|
|
|
- [appDelegate messageNotification:@"_save_selected_files_" description:@"_file_not_saved_cameraroll_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
|
|
|
- }
|
|
|
-
|
|
|
- if ([metadata.typeFile isEqualToString: k_metadataTypeFile_video] && status == PHAuthorizationStatusAuthorized) {
|
|
|
-
|
|
|
- if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(fileNamePath)) {
|
|
|
-
|
|
|
- UISaveVideoAtPathToSavedPhotosAlbum(fileNamePath, self, @selector(saveSelectedFilesSelector: didFinishSavingWithError: contextInfo:), nil);
|
|
|
- } else {
|
|
|
- [appDelegate messageNotification:@"_save_selected_files_" description:@"_file_not_saved_cameraroll_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (status != PHAuthorizationStatusAuthorized) {
|
|
|
-
|
|
|
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_access_photo_not_enabled_", nil) message:NSLocalizedString(@"_access_photo_not_enabled_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
|
|
|
-
|
|
|
- [alertController addAction:okAction];
|
|
|
- [self presentViewController:alertController animated:YES completion:nil];
|
|
|
- }
|
|
|
-
|
|
|
[[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl fileID:fileID action:k_action_MOD];
|
|
|
+
|
|
|
+ [self saveToPhotoAlbum:metadata];
|
|
|
}
|
|
|
|
|
|
// Copy File
|