From 0c472e5ef221bf822c8286b9bad64f6dd9ce835e Mon Sep 17 00:00:00 2001 From: Marton Zeisler Date: Wed, 14 Aug 2019 13:23:27 +0200 Subject: [PATCH] Upload UI for video and documents --- .../document.imageset/Contents.json | 21 ++++++++ .../document.imageset/document.png | Bin 0 -> 748 bytes .../videoFloaty.imageset/Contents.json | 21 ++++++++ .../videoFloaty.imageset/video.png | Bin 0 -> 1869 bytes AmahiAnywhere/AmahiAnywhere/Info.plist | 2 + .../Files/FilesViewController.swift | 49 ++++++++++++++++-- 6 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/Contents.json create mode 100644 AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/document.png create mode 100644 AmahiAnywhere/AmahiAnywhere/Assets.xcassets/videoFloaty.imageset/Contents.json create mode 100644 AmahiAnywhere/AmahiAnywhere/Assets.xcassets/videoFloaty.imageset/video.png diff --git a/AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/Contents.json b/AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/Contents.json new file mode 100644 index 00000000000..1774ab0aa42 --- /dev/null +++ b/AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "document.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/document.png b/AmahiAnywhere/AmahiAnywhere/Assets.xcassets/document.imageset/document.png new file mode 100644 index 0000000000000000000000000000000000000000..a0d1a28908fd0c5aa419c52640b0593caed3e2e8 GIT binary patch literal 748 zcmVPx%rb$FWR9Fe^SvyVyF$@i#k^)3SK|=)%B{T>M4zP$DASgKkCxAO}1PZROD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Xyy~}$NmzJ8Twe7H|@Z&lZspsV~o%Nc{>tL0e)62UN rfAZ!PP}7ngZST2UqoZysn_g(jEfus6SD>Yem&3|b@% literal 0 HcmV?d00001 diff --git a/AmahiAnywhere/AmahiAnywhere/Info.plist b/AmahiAnywhere/AmahiAnywhere/Info.plist index 610cb8b0ebf..2773c857286 100644 --- a/AmahiAnywhere/AmahiAnywhere/Info.plist +++ b/AmahiAnywhere/AmahiAnywhere/Info.plist @@ -29,6 +29,8 @@ NSCameraUsageDescription Please allow access to your camera to take pictures for your HDA server + NSMicrophoneUsageDescription + Please allow access to your microphone to record a video for upload NSPhotoLibraryAddUsageDescription Please allow access to your photo library to select photos for upload UIBackgroundModes diff --git a/AmahiAnywhere/AmahiAnywhere/Presentation/Files/FilesViewController.swift b/AmahiAnywhere/AmahiAnywhere/Presentation/Files/FilesViewController.swift index d891aa71eae..29aae385603 100644 --- a/AmahiAnywhere/AmahiAnywhere/Presentation/Files/FilesViewController.swift +++ b/AmahiAnywhere/AmahiAnywhere/Presentation/Files/FilesViewController.swift @@ -11,6 +11,7 @@ import Lightbox import AVFoundation import GoogleCast import Floaty +import MobileCoreServices class FilesViewController: BaseUIViewController, GCKRemoteMediaClientListener { @@ -90,6 +91,9 @@ class FilesViewController: BaseUIViewController, GCKRemoteMediaClientListener { let interactor = Interactor() + let documentUploadTypes = [kUTTypePDF as String, kUTTypeText as String, kUTTypeImage as String] + var documentPicker: UIDocumentPickerViewController! + override func viewDidLoad() { super.viewDidLoad() setupNotifications() @@ -112,11 +116,30 @@ class FilesViewController: BaseUIViewController, GCKRemoteMediaClientListener { imagePicker.delegate = self } + func setupDocumentPicker(){ + documentPicker = UIDocumentPickerViewController(documentTypes: documentUploadTypes, in: .import) + documentPicker.delegate = self + documentPicker.allowsMultipleSelection = false + documentPicker.modalPresentationStyle = .formSheet + } + func setupFloaty(){ - floaty.addItem("Upload an image", icon: UIImage(named: "camera")) { (item) in - self.uploadImageTapped() + self.uploadImageVideoTapped(isTypePhoto: true) + } + + floaty.addItem("Upload a video", icon: UIImage(named: "videoFloaty")) { (item) in + self.uploadImageVideoTapped(isTypePhoto: false) } + + floaty.addItem("Upload a document", icon: UIImage(named: "document")) { (item) in + self.uploadDocumentTapped() + } + + } + + @objc func uploadDocumentTapped(){ + self.present(documentPicker, animated: true, completion: nil) } @objc func expiredAuthTokenHDA(){ @@ -130,7 +153,10 @@ class FilesViewController: BaseUIViewController, GCKRemoteMediaClientListener { self.present(alertVC, animated: true, completion: nil) } - func uploadImageTapped(){ + func uploadImageVideoTapped(isTypePhoto: Bool){ + imagePicker.mediaTypes = isTypePhoto ? [kUTTypeImage as String] : [kUTTypeMovie as String] + let libraryTitle = isTypePhoto ? "Photo Library" : "Video Library" + let alertVC = UIAlertController(title: "Select your source", message: nil, preferredStyle: .actionSheet) alertVC.addAction(UIAlertAction(title: "Camera", style: .default, handler: { (_) in @@ -138,7 +164,7 @@ class FilesViewController: BaseUIViewController, GCKRemoteMediaClientListener { self.present(self.imagePicker, animated: true, completion: nil) })) - alertVC.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: { (_) in + alertVC.addAction(UIAlertAction(title: libraryTitle, style: .default, handler: { (_) in self.imagePicker.sourceType = .photoLibrary self.present(self.imagePicker, animated: true, completion: nil) })) @@ -201,6 +227,10 @@ class FilesViewController: BaseUIViewController, GCKRemoteMediaClientListener { if imagePicker == nil{ setupImagePicker() } + + if documentPicker == nil{ + setupDocumentPicker() + } } func setupNotifications(){ @@ -553,3 +583,14 @@ extension FilesViewController: UIViewControllerTransitioningDelegate { return interactor.hasStarted ? interactor : nil } } + +extension FilesViewController: UIDocumentPickerDelegate{ + func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { + guard let myURL = urls.first else { + return + } + + print("selected document url : \(myURL)") + } + +}