Kaydet (Commit) 9e425891 authored tarafından jan Iversen's avatar jan Iversen

iOS, iCloud picker added

Use documentPicker instead of own programming

Change-Id: Ibd4e0f987254830aeaba1140ec1f84b649ca1387
üst af63fbad
...@@ -9,16 +9,19 @@ import UIKit ...@@ -9,16 +9,19 @@ import UIKit
class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDocumentMenuDelegate class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelegate
{ {
func documentMenu(_: UIDocumentMenuViewController, didPickDocumentPicker: UIDocumentPickerViewController) public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL)
{ {
} }
func documentMenuWasCancelled(_: UIDocumentMenuViewController) func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController)
{ {
} }
// Show sidemenu (part of documentcontroller) // Show sidemenu (part of documentcontroller)
@IBAction func doMenu(_ sender: UIBarButtonItem) @IBAction func doMenu(_ sender: UIBarButtonItem)
{ {
...@@ -72,86 +75,44 @@ class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDo ...@@ -72,86 +75,44 @@ class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDo
func actionNew(_ name : String)
{
// JIX Close active documents if any
// Start new (with default name
// Only interact with DocumentBrowser
}
func actionOpen()
{
let importMenu = UIDocumentMenuViewController(documentTypes: [], in: .import)
// let importMenu = UIDocumentMenuViewController(documentTypes: ["com.jani.Editors.docx",
// "com.jani.Editors.doc",
// "com.jani.Editors.xlsx",
// "com.jani.Editors.xls",
// "com.jani.Editors.pptx",
// "com.jani.Editors.ppt",
// "com.jani.Editors.pdf",
// "com.jani.Editors.odt",
// "com.jani.Editors.ods",
// "com.jani.Editors.odp"], in: .import)
importMenu.delegate = self
self.present(importMenu, animated: true, completion: nil)
// JIX Close active documents if any
// Present FileManager
// performSegue(withIdentifier: "showFileManager", sender: self)
// start DocumentBrowser with new document
}
// Called when returning from filemanager
@IBAction func returned(segue: UIStoryboardSegue)
{
// JIX actually open document
print("I returned")
}
func actionDelete() func actionMenuSelected(_ tag : Int)
{ {
// JIX Close active documents if any switch tag
// Delete document {
} case 1: // New
print("menu New to be done")
case 2: // Open...
let openMenu = UIDocumentPickerViewController(documentTypes: ["public.content"], in: .open)
openMenu.delegate = self
self.present(openMenu, animated: true, completion: nil)
print("menu Open... to be done")
case 3: // Save
print("menu Save to be done")
func actionSave() case 4: // Save as...
{ print("menu Save as... to be done")
// call save in DocumentBrowser
}
case 5: // Save as PDF...
print("menu Save as PDF... to be done")
case 6: // Print...
print("menu Print... to be done")
func actionSaveAs(_ name : String) case 7: // Copy TO iPad
{ print("menu Copy TO iPad to be done")
// call saveas in DocumentBrowser
} case 8: // Delete FROM iPad
print("menu Delete FROM iPad to be done")
case 9: // Move FROM iPad
print("menu Move FROM iPad to be done")
default: // should not happen
func actionPDF() print("unknown menu" + String(tag))
{ }
// call savePDF in documentBrowser
}
func actionPrint()
{
// call print in DocumentBrowser
} }
...@@ -161,9 +122,9 @@ class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDo ...@@ -161,9 +122,9 @@ class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDo
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
// let path = Bundle.main.path(forResource: "Info", ofType: "plist") // let path = Bundle.main.path(forResource: "Info", ofType: "plist")
// let dict = NSDictionary(contentsOfFile: path!) // let dict = NSDictionary(contentsOfFile: path!)
// let tableData = dict!.object(forKey: "CFBundleDocumentTypes") // let tableData = dict!.object(forKey: "CFBundleDocumentTypes")
} }
...@@ -178,15 +139,9 @@ class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDo ...@@ -178,15 +139,9 @@ class DocumentController: UIViewController, DocumentActionsControlDelegate, UIDo
// Protocol for action popover callback // Protocol for action popover callback
protocol DocumentActionsControlDelegate protocol MenuDelegate
{ {
func actionNew(_ name : String) func actionMenuSelected(_ tag : Int)
func actionOpen()
func actionDelete()
func actionSave()
func actionSaveAs(_ name : String)
func actionPDF()
func actionPrint()
} }
...@@ -194,78 +149,38 @@ protocol DocumentActionsControlDelegate ...@@ -194,78 +149,38 @@ protocol DocumentActionsControlDelegate
class DocumentActions: UITableViewController class DocumentActions: UITableViewController
{ {
// Pointer to callback class // Pointer to callback class
var delegate : DocumentActionsControlDelegate? var delegate : MenuDelegate?
var isDocActive : Bool = false var isDocActive : Bool = false
// Calling class might enable/disable each button // Calling class might enable/disable each button
@IBOutlet weak var buttonNew: UIButton! @IBOutlet weak var buttonNew: UIButton!
@IBOutlet weak var buttonOpen: UIButton! @IBOutlet weak var buttonOpen: UIButton!
@IBOutlet weak var buttonDelete: UIButton!
@IBOutlet weak var buttonSave: UIButton! @IBOutlet weak var buttonSave: UIButton!
@IBOutlet weak var buttonSaveAs: UIButton! @IBOutlet weak var buttonSaveAs: UIButton!
@IBOutlet weak var buttonPDF: UIButton! @IBOutlet weak var buttonSaveAsPDF: UIButton!
@IBOutlet weak var buttonPrint: UIButton! @IBOutlet weak var buttonPrint: UIButton!
@IBOutlet weak var buttonCopyTOiPad: UIButton!
@IBOutlet weak var buttonDeleteFROMiPad: UIButton!
@IBOutlet weak var buttonMoveFROMiPad: UIButton!
// Actions
@IBAction func doOpen(_ sender: UIButton)
{
delegate?.actionOpen()
dismiss(animated: false)
}
@IBAction func doDelete(_ sender: UIButton)
{
delegate?.actionDelete()
dismiss(animated: false)
}
@IBAction func doSave(_ sender: UIButton)
{
delegate?.actionSave()
dismiss(animated: false)
}
// Actions
@IBAction func doPDF(_ sender: UIButton) @IBAction func actionMenuSelect(_ sender: UIButton)
{
delegate?.actionPDF()
dismiss(animated: false)
}
@IBAction func doPrint(_ sender: UIButton)
{ {
delegate?.actionPrint()
dismiss(animated: false) dismiss(animated: false)
delegate?.actionMenuSelected(sender.tag)
} }
override func viewDidLoad() override func viewDidLoad()
{ {
super.viewDidLoad() super.viewDidLoad()
buttonDelete.isEnabled = isDocActive buttonDeleteFROMiPad.isEnabled = isDocActive
buttonSave.isEnabled = isDocActive buttonSave.isEnabled = isDocActive
buttonSaveAs.isEnabled = isDocActive buttonSaveAs.isEnabled = isDocActive
buttonPDF.isEnabled = isDocActive buttonSaveAsPDF.isEnabled = isDocActive
buttonPrint.isEnabled = isDocActive buttonPrint.isEnabled = isDocActive
} }
// Last stop before displaying popover
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
// let vc = segue.destination as! setNameAction
// vc.delegateDoc = self.delegate
// vc.protocolActionToPerform = (segue.identifier == "showNew") ? 2 : 3
}
} }
...@@ -363,7 +363,7 @@ ...@@ -363,7 +363,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.4.6</string> <string>0.4.7</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment