marinofaggiana 4 лет назад
Родитель
Сommit
43ae984045

+ 0 - 6
Nextcloud.xcodeproj/project.pbxproj

@@ -197,7 +197,6 @@
 		F77B0E5F1D118A16002130FE /* NCSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE4311BAC0268006C0017 /* NCSettings.m */; };
 		F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42D1BAC0268006C0017 /* CCManageAccount.m */; };
 		F77B0ED11D118A16002130FE /* Acknowledgements.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42A1BAC0268006C0017 /* Acknowledgements.m */; };
-		F77B0ED51D118A16002130FE /* PHAsset+Utility.m in Sources */ = {isa = PBXBuildFile; fileRef = F777F0311C29717F00CE81CB /* PHAsset+Utility.m */; };
 		F77B0ED91D118A16002130FE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F67BAD1A24D27800EE80DA /* main.m */; };
 		F77B0F611D118A16002130FE /* Acknowledgements.rtf in Resources */ = {isa = PBXBuildFile; fileRef = F7ACE42B1BAC0268006C0017 /* Acknowledgements.rtf */; };
 		F77B0F631D118A16002130FE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F7E70DE91A24DE4100E1B66A /* Localizable.strings */; };
@@ -571,8 +570,6 @@
 		F77444F322281649000D5EB0 /* NCGridMediaCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCGridMediaCell.swift; sourceTree = "<group>"; };
 		F77444F422281649000D5EB0 /* NCGridMediaCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCGridMediaCell.xib; sourceTree = "<group>"; };
 		F77444F7222816D5000D5EB0 /* NCPickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCPickerViewController.swift; sourceTree = "<group>"; };
-		F777F0301C29717F00CE81CB /* PHAsset+Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PHAsset+Utility.h"; sourceTree = "<group>"; };
-		F777F0311C29717F00CE81CB /* PHAsset+Utility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PHAsset+Utility.m"; sourceTree = "<group>"; };
 		F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+Menu.swift"; sourceTree = "<group>"; };
 		F78071071EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+MainThread.h"; sourceTree = "<group>"; };
 		F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNotificationCenter+MainThread.m"; sourceTree = "<group>"; };
@@ -1267,8 +1264,6 @@
 			children = (
 				F7BFCCC01B68C21900548E76 /* CCManageLocation.h */,
 				F7BFCCC11B68C21900548E76 /* CCManageLocation.m */,
-				F777F0301C29717F00CE81CB /* PHAsset+Utility.h */,
-				F777F0311C29717F00CE81CB /* PHAsset+Utility.m */,
 			);
 			path = "ManageLocation+ManageAsset";
 			sourceTree = "<group>";
@@ -2160,7 +2155,6 @@
 				F7E4D9C422ED929B003675FD /* NCShareComments.swift in Sources */,
 				F717402E24F699A5000C87D5 /* NCFavorite.swift in Sources */,
 				F74DE14325135B6800917068 /* NCTransfers.swift in Sources */,
-				F77B0ED51D118A16002130FE /* PHAsset+Utility.m in Sources */,
 				F755E6462525946C008DAB45 /* NCCollectionViewCommon.swift in Sources */,
 				F77B0ED91D118A16002130FE /* main.m in Sources */,
 			);

+ 0 - 61
iOSClient/ManageLocation+ManageAsset/PHAsset+Utility.h

@@ -1,61 +0,0 @@
-//
-//  PHAsset+Utilities.h
-//
-//  Created by Zakk Hoyt on 9/22/14.
-//  Copyright (c) 2014 Zakk Hoyt. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-@import Photos;
-
-typedef void (^PHAssetBoolBlock)(BOOL success);
-typedef void (^PHAssetMetadataBlock)(NSDictionary *metadata);
-typedef void (^PHAssetAssetBoolBlock)(PHAsset *asset, BOOL success);
-
-@interface PHAsset (Utilities)
-
-/*!
- @method        saveToAlbum:completionBlock
- @description   Save a copy of a PHAsset to a photo album. Will create the album if it doesn't exist.
- @param         title                  The title of the album.
- @param         completionBlock        This block is passed a BOOL for success.  This parameter may be nil.
- */
--(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completionBlock;
-
-/*!
- @method        requestMetadataWithCompletionBlock
- @description   Get metadata dictionary of an asset (the kind with {Exif}, {GPS}, etc...
- @param         completionBlock        This block is passed a dictionary of metadata properties. See ImageIO framework for parsing/reading these. This parameter may be nil.
- */
--(void)requestMetadataWithCompletionBlock:(PHAssetMetadataBlock)completionBlock;
-
-/*!
- @method        updateLocation:creationDate:completionBlock
- @description   Update the location and date of an existing asset
- @param         location               A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations.
- @param         creationDate           An NSDate to be written to the PHAsset.
- @param         completionBlock        This block is passed the PHAsset updated with location/date (if applied) and BOOL for success. This parameter may be nil.
- */
--(void)updateLocation:(CLLocation*)location creationDate:(NSDate*)creationDate completionBlock:(PHAssetBoolBlock)completionBlock;
-
-/*!
- @method        saveImageToCameraRoll:location:completionBlock
- @description   Save an image to camera roll with optional completion (returns PHAsset in completion block)
- @param         location               A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations. This parameter may be nil.
- @param         creationDate           An NSDate to be written to the PHAsset.
- @param         completionBlock        Returns the PHAsset which was written and BOOL for success. This parameter may be nil.
- */
-+(void)saveImageToCameraRoll:(UIImage*)image location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock;
-
-/*!
- @method        saveVideoAtURL:location:completionBlock
- @description   Save a video to camera roll with optional completion (returns PHAsset in completion block)
- @param         location               A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations. This parameter may be nil.
- @param         creationDate           An NSDate to be written to the PHAsset.
- @param         completionBlock        Returns the PHAsset which was written and BOOL for success. This parameter may be nil.
- */
-+(void)saveVideoAtURL:(NSURL*)url location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock;
-
-@end
-
-

+ 0 - 141
iOSClient/ManageLocation+ManageAsset/PHAsset+Utility.m

@@ -1,141 +0,0 @@
-//
-//  PHAsset+Utilities.m
-//
-//  Created by Zakk Hoyt on 9/22/14.
-//  Copyright (c) 2014 Zakk Hoyt. All rights reserved.
-//
-
-#import "PHAsset+Utility.h"
-#import "NCBridgeSwift.h"
-
-@import Photos;
-@implementation PHAsset (Utilities)
-
-#pragma mark Public methods
-
--(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completionBlock{
-    void (^saveAssetCollection)(PHAssetCollection *assetCollection) = ^(PHAssetCollection *assetCollection){
-        [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
-            PHAssetCollectionChangeRequest *changeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:assetCollection];
-            [changeRequest addAssets:@[self]];
-        } completionHandler:^(BOOL success, NSError *error) {
-            if(success == NO) {
-                [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Failed to add PHAsset to album %@ error: %@", title, error]];
-            }
-            return completionBlock(success);
-        }];
-    };
-    
-    PHAssetCollection *assetCollection = [self albumWithTitle:title];
-    if(assetCollection){
-        // Album exists
-        saveAssetCollection(assetCollection);
-    } else {
-        // Need to create album before saving
-        // Create new album (will create duplicates)
-        [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
-            [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:title];
-        } completionHandler:^(BOOL success, NSError *error) {
-            if (!success) {
-                [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Error creating album: %@", error]];
-            } else {
-                PHAssetCollection *assetCollection = [self albumWithTitle:title];
-                saveAssetCollection(assetCollection);
-            }
-        }];
-    }
-}
-
--(void)requestMetadataWithCompletionBlock:(PHAssetMetadataBlock)completionBlock{
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        PHContentEditingInputRequestOptions *editOptions = [[PHContentEditingInputRequestOptions alloc]init];
-        editOptions.networkAccessAllowed = YES;
-        [self requestContentEditingInputWithOptions:editOptions completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
-            CIImage *image = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL];
-            dispatch_async(dispatch_get_main_queue(), ^{
-                completionBlock(image.properties);
-            });
-        }];
-    });
-}
-
--(void)updateLocation:(CLLocation*)location creationDate:(NSDate*)creationDate completionBlock:(PHAssetBoolBlock)completionBlock{
-    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
-        PHAssetChangeRequest *assetRequest = [PHAssetChangeRequest changeRequestForAsset:self];
-        if(location) assetRequest.location = location;
-        if(creationDate) assetRequest.creationDate = creationDate;
-    } completionHandler:^(BOOL success, NSError *error) {
-        if(success){
-            completionBlock(YES);
-        } else {
-            completionBlock(NO);
-        }
-    }];
-}
-
-
-+(void)saveImageToCameraRoll:(UIImage*)image location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock{
-    __block PHObjectPlaceholder *placeholderAsset = nil;
-    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
-        PHAssetChangeRequest *newAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
-        newAssetRequest.location = location;
-        newAssetRequest.creationDate = [NSDate date];
-        placeholderAsset = newAssetRequest.placeholderForCreatedAsset;
-    } completionHandler:^(BOOL success, NSError *error) {
-        if(success){
-            PHAsset *asset = [self getAssetFromlocalIdentifier:placeholderAsset.localIdentifier];
-            completionBlock(asset, YES);
-        } else {
-            completionBlock(nil, NO);
-        }
-    }];
-}
-
-+(void)saveVideoAtURL:(NSURL*)url location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock{
-    __block PHObjectPlaceholder *placeholderAsset = nil;
-    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
-        PHAssetChangeRequest *newAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:url];
-        newAssetRequest.location = location;
-        newAssetRequest.creationDate = [NSDate date];
-        placeholderAsset = newAssetRequest.placeholderForCreatedAsset;
-    } completionHandler:^(BOOL success, NSError *error) {
-        if(success){
-            PHAsset *asset = [self getAssetFromlocalIdentifier:placeholderAsset.localIdentifier];
-            completionBlock(asset, YES);
-        } else {
-            completionBlock(nil, NO);
-        }
-    }];
-}
-
-#pragma mark Private helpers
-
--(PHAssetCollection*)albumWithTitle:(NSString*)title{
-    // Check if album exists. If not, create it.
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"localizedTitle == %@", title];
-    PHFetchOptions *options = [[PHFetchOptions alloc]init];
-    options.predicate = predicate;
-    PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:options];
-    if(result.count){
-        return result[0];
-    }
-    return nil;
-    
-}
-
-+(PHAsset*)getAssetFromlocalIdentifier:(NSString*)localIdentifier{
-    if(localIdentifier == nil){
-        [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Cannot get asset from localID because it is nil"]];
-        return nil;
-    }
-    
-    PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:@[localIdentifier] options:nil];
-    
-    if(result.count){
-        return result[0];
-    }
-    return nil;
-}
-
-@end
-