diff --git a/LightshowManager/LightshowDownloadOrAddView.swift b/LightshowManager/LightshowDownloadOrAddView.swift new file mode 100644 index 0000000..502181c --- /dev/null +++ b/LightshowManager/LightshowDownloadOrAddView.swift @@ -0,0 +1,32 @@ + +// +// StudentTableViewController.swift +// SchoolList8 +// +// Created by Quentin Millardet on 14/10/2020. +// + +import UIKit + +class LightshowDownloadOrAddView: UIViewController{ + + @IBOutlet weak var alertMessage: UILabel! + @IBOutlet weak var alertIcon: UIImageView! + + var teslacamFolder : Bool = false; + + + override func viewDidLoad() { + super.viewDidLoad() + Thread.sleep(forTimeInterval: 3.0) + + teslacamFolder = (UIApplication.shared.delegate as! AppDelegate).teslacamFolder + self.alertMessage.isHidden = !teslacamFolder + self.alertIcon.isHidden = !teslacamFolder + + } + // Permet de passer des informations à une vue avant que celle-ci ne soit créee + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + + } +} diff --git a/LightshowManager/ViewController.swift b/LightshowManager/ViewController.swift index 7406e0f..53ce00b 100644 --- a/LightshowManager/ViewController.swift +++ b/LightshowManager/ViewController.swift @@ -16,13 +16,12 @@ class ViewController: UIViewController, UIDocumentPickerDelegate { override func viewDidLoad() { super.viewDidLoad() model = (UIApplication.shared.delegate as! AppDelegate).model - // Do any additional setup after loading the view. } @IBAction func selectFolder(_ sender: Any) { - + print("ici") // Create a document picker for directories. let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder]) @@ -51,6 +50,8 @@ class ViewController: UIViewController, UIDocumentPickerDelegate { // Use file coordination for reading and writing any of the URL’s content. var error: NSError? = nil + + var teslacamFolder = false; NSFileCoordinator().coordinate(readingItemAt: url, error: &error) { (url) in let keys : [URLResourceKey] = [.nameKey, .isDirectoryKey] @@ -66,15 +67,18 @@ class ViewController: UIViewController, UIDocumentPickerDelegate { for case let file as URL in fileList { + if (file.lastPathComponent.lowercased().contains("teslacam")){ + print("ici") + teslacamFolder = true + } + + let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "network") logger.debug("chosen file: \(file.relativeString)") let filename = file.lastPathComponent; - - if (filename.contains(".mp3") || filename.contains(".fseq") ){ - model?.setStudentAtIndex(model?.getStudentCount() ?? 0, withdraw: filename ) - } + model?.setStudentAtIndex(model?.getStudentCount() ?? 0, withdraw: filename ) // Start accessing the content's security-scoped URL. guard file.startAccessingSecurityScopedResource() else { @@ -91,6 +95,8 @@ class ViewController: UIViewController, UIDocumentPickerDelegate { file.stopAccessingSecurityScopedResource() } } + + (UIApplication.shared.delegate as! AppDelegate).teslacamFolder = teslacamFolder }