Marino Faggiana vor 6 Jahren
Ursprung
Commit
3d0dba61da

+ 12 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -288,6 +288,7 @@
 		F75AE3C71E9D12900088BB09 /* SwiftyAvatar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75AE3C61E9D12900088BB09 /* SwiftyAvatar.swift */; };
 		F75EDFBD1E8C112F00E6F369 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */; };
 		F75EDFBF1E8C116D00E6F369 /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */; };
+		F761855A2198A2B500A65DC4 /* NCPhotosPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76185592198A2B500A65DC4 /* NCPhotosPickerViewController.swift */; };
 		F7622FAD2175FCC0000383FF /* ActionSheetMargin.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7622F712175FCC0000383FF /* ActionSheetMargin.swift */; };
 		F7622FAE2175FCC0000383FF /* ActionSheetItemHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7622F722175FCC0000383FF /* ActionSheetItemHandler.swift */; };
 		F7622FAF2175FCC0000383FF /* ActionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7622F732175FCC0000383FF /* ActionSheet.swift */; };
@@ -1064,6 +1065,7 @@
 		F75CDBF51DF063AD00116AD0 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; name = .gitignore; path = ../.gitignore; sourceTree = "<group>"; };
 		F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; };
 		F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
+		F76185592198A2B500A65DC4 /* NCPhotosPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCPhotosPickerViewController.swift; sourceTree = "<group>"; };
 		F7622F712175FCC0000383FF /* ActionSheetMargin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheetMargin.swift; sourceTree = "<group>"; };
 		F7622F722175FCC0000383FF /* ActionSheetItemHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheetItemHandler.swift; sourceTree = "<group>"; };
 		F7622F732175FCC0000383FF /* ActionSheet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheet.swift; sourceTree = "<group>"; };
@@ -1748,6 +1750,7 @@
 				F78ACD4D219043E70088454D /* Layout */,
 				F78ACD3E21903BA20088454D /* Cell */,
 				F78ACD5921904E460088454D /* ActionSheetHeaderView */,
+				F76185582198A28E00A65DC4 /* NCPhotosPickerViewController */,
 				F70211FA1BAC56E9003FC03E /* CCMain.h */,
 				F70211FB1BAC56E9003FC03E /* CCMain.m */,
 				F7226EDB1EE4089300EBECB1 /* Main.storyboard */,
@@ -2309,6 +2312,14 @@
 			path = SwiftyAvatar;
 			sourceTree = "<group>";
 		};
+		F76185582198A28E00A65DC4 /* NCPhotosPickerViewController */ = {
+			isa = PBXGroup;
+			children = (
+				F76185592198A2B500A65DC4 /* NCPhotosPickerViewController.swift */,
+			);
+			path = NCPhotosPickerViewController;
+			sourceTree = "<group>";
+		};
 		F7622F6F2175FCC0000383FF /* Sheeeeeeeeet */ = {
 			isa = PBXGroup;
 			children = (
@@ -4132,6 +4143,7 @@
 				F7F54D0A1E5B14C800E19C62 /* MWPhotoBrowser.m in Sources */,
 				F762CB081EACB66200B38484 /* XLFormOptionsViewController.m in Sources */,
 				F73CC0721E813DFF006E3047 /* BKPasscodeLockScreenManager.m in Sources */,
+				F761855A2198A2B500A65DC4 /* NCPhotosPickerViewController.swift in Sources */,
 				F73B4F101F470D9100BBEE4B /* nsSBCharSetProber.cpp in Sources */,
 				F762CB0E1EACB66200B38484 /* NSExpression+XLFormAdditions.m in Sources */,
 				F73B4F071F470D9100BBEE4B /* nsEscSM.cpp in Sources */,

+ 3 - 1
iOSClient/Main/CCMain.m

@@ -792,7 +792,9 @@
 
 - (void)openAssetsPickerController
 {
-    [[NCMainCommon sharedInstance] openPhotosPickerViewController:self phAssets:^(NSArray<PHAsset *> * _Nonnull assets) {
+    NCPhotosPickerViewController *viewController = [[NCPhotosPickerViewController alloc] init:self];
+    
+    [viewController openPhotosPickerViewControllerWithPhAssets:^(NSArray<PHAsset *> * _Nonnull assets) {
         if (assets.count > 0) {
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                 NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];

+ 77 - 0
iOSClient/Main/NCPhotosPickerViewController/NCPhotosPickerViewController.swift

@@ -0,0 +1,77 @@
+//
+//  NCPhotosPickerViewController.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 11/11/2018.
+//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import Foundation
+
+class NCPhotosPickerViewController: NSObject {
+    
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    var sourceViewController : UIViewController
+
+    @objc init (_ viewController : UIViewController) {
+        sourceViewController = viewController
+    }
+    
+    @objc func openPhotosPickerViewController(phAssets: @escaping ([PHAsset]) -> ()) {
+        
+        var selectedPhAssets = [PHAsset]()
+        var configure = TLPhotosPickerConfigure()
+        
+        configure.cancelTitle = NSLocalizedString("_cancel_", comment: "")
+        configure.defaultCameraRollTitle = NSLocalizedString("_camera_roll_", comment: "")
+        configure.doneTitle = NSLocalizedString("_done_", comment: "")
+        configure.emptyMessage = NSLocalizedString("_no_albums_", comment: "")
+        configure.tapHereToChange = NSLocalizedString("_tap_here_to_change_", comment: "")
+        
+        configure.maxSelectedAssets = Int(k_pickerControllerMax)
+        configure.selectedColor = NCBrandColor.sharedInstance.brand
+        
+        let viewController = TLPhotosPickerViewController(withTLPHAssets: { (assets) in
+            
+            for asset: TLPHAsset in assets {
+                if asset.phAsset != nil {
+                    selectedPhAssets.append(asset.phAsset!)
+                }
+            }
+            
+            phAssets(selectedPhAssets)
+            
+        }, didCancel: nil)
+        
+        viewController.didExceedMaximumNumberOfSelection = { (picker) in
+            self.appDelegate.messageNotification("_info_", description: "_limited_dimension_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
+        }
+        
+        viewController.handleNoAlbumPermissions = { (picker) in
+            self.appDelegate.messageNotification("_info_", description: "_denied_album_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
+        }
+        
+        viewController.handleNoCameraPermissions = { (picker) in
+            self.appDelegate.messageNotification("_info_", description: "_denied_camera_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
+        }
+        
+        viewController.configure = configure
+        
+        sourceViewController.present(viewController, animated: true, completion: nil)
+    }
+}