summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorjan Iversen <jani@libreoffice.org>2017-03-13 13:03:40 +0100
committerjan iversen <jani@libreoffice.org>2017-03-21 11:24:57 +0000
commit4e26af2df9d26aba83f61ba7ea0fbe876d4ed288 (patch)
treed4e082ed9859cac7a838611d91039fe6d63d2c72 /ios
parent2d7159501ecb500e662d32401e10ef65e7e8ea98 (diff)
ios LibreOfficeLight FileManager actions
Adding dialogue handling for filemanager Change-Id: I9db782e04f80f18421be23e158034a80497d8b12 Reviewed-on: https://gerrit.libreoffice.org/35489 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@libreoffice.org>
Diffstat (limited to 'ios')
-rwxr-xr-xios/experimental/LibreOfficeLight/LibreOfficeLight/FileManagerController.swift188
-rwxr-xr-xios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard33
2 files changed, 172 insertions, 49 deletions
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/FileManagerController.swift b/ios/experimental/LibreOfficeLight/LibreOfficeLight/FileManagerController.swift
index e0328549380b..e5b1df3d1ac8 100755
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/FileManagerController.swift
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/FileManagerController.swift
@@ -17,7 +17,7 @@ private class FileStorage
// Start path for the 2 storage locations
private let baseLocalDocPath : URL
private let baseCloudDocPath : URL?
- private var currrentDocPath : URL? {
+ private var currentDocPath : URL? {
get {
return storageIsLocal ? baseLocalDocPath : baseCloudDocPath
}
@@ -54,11 +54,18 @@ private class FileStorage
}
+ func isSubDirectory() -> Bool
+ {
+ return currentDir != currentDocPath
+ }
+
+
func selectStorage(_ doSwitch : Bool) -> Bool
{
if doSwitch {
storageIsLocal = !storageIsLocal
+ buildFileList()
}
return storageIsLocal
}
@@ -77,7 +84,7 @@ private class FileStorage
func leaveDirectory()
{
// step up for active storage, and only if not in root
- if currentDir != currrentDocPath {
+ if isSubDirectory() {
currentDir = currentDir.deletingLastPathComponent()
buildFileList()
}
@@ -89,7 +96,8 @@ private class FileStorage
{
let newDir = currentDir.appendingPathComponent(name)
try! filemgr.createDirectory(at: newDir, withIntermediateDirectories: true, attributes: nil)
- enterDirectory(name + "/")
+ currentDir = currentDir.appendingPathComponent(name)
+ buildFileList()
}
@@ -122,6 +130,7 @@ private class FileStorage
{
try! filemgr.moveItem(at: currentDir.appendingPathComponent(name),
to: (storageIsLocal ? localDir : cloudDir).appendingPathComponent(name))
+ buildFileList()
}
@@ -150,6 +159,8 @@ private class FileStorage
baseLocalDocPath = filemgr.urls(for: .documentDirectory, in: .userDomainMask)[0]
baseCloudDocPath = nil
localDir = baseLocalDocPath
+
+ // JIX, fix add support for iCloud
cloudDir = baseLocalDocPath
buildFileList()
}
@@ -157,47 +168,84 @@ private class FileStorage
-class FileManagerController : UITableViewController
+class FileManagerController : UITableViewController, actionsControlDelegate
{
+ // Housekeeping variables
private var fileData = FileStorage()
+ private var selectedRow : IndexPath?
-
- func showFiles()
+
+ // Toogle between local and cloud storage
+ @IBAction func doSelectStorage(_ sender: UIBarButtonItem)
{
-
+ sender.title = fileData.selectStorage(true) ? "iCloud" : "iPad"
+ reloadData()
}
- @IBAction func doSelectStorage(_ sender: UIBarButtonItem)
+ // Last stop before displaying popover
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
- if fileData.selectStorage(true) {
- sender.title = "iCloud"
- }
- else {
- sender.title = "iPad"
+ let vc = segue.destination as! FileManagerActions
+ vc.delegate = self
+ vc.inFileSelect = (selectedRow != nil)
+ vc.inSubDirectory = fileData.isSubDirectory()
+ }
+
+
+
+ func actionOpen()
+ {
+ if selectedRow != nil {
+ let currentCell = tableView.cellForRow(at: selectedRow!) as! FileManagerCell
+ if currentCell.isDirectory {
+ fileData.enterDirectory(currentCell.fileName)
+ reloadData()
+ } else {
+ // JIX delegate to Document
+ }
}
- showFiles()
}
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
-
- if segue.identifier == "ShowAttractionDetails" {
-
-// let detailViewController = segue.destination
-// as! AttractionDetailViewController
-
-// let myIndexPath = self.tableView.indexPathForSelectedRow!
-// let row = myIndexPath.row
-// detailViewController.webSite = webAddresses[row]
+ func actionDelete()
+ {
+ if selectedRow != nil {
+ let currentCell = self.tableView.cellForRow(at: selectedRow!) as! FileManagerCell
+ fileData.deleteFileDirectory(currentCell.fileName)
+ reloadData()
}
}
+ func actionUploadDownload()
+ {
+ // JIX filemanager copy
+ }
+
+
+
+ func actionLevelUp()
+ {
+ fileData.leaveDirectory()
+ reloadData()
+ }
+
+
+
+ func actionCreateDirectory(_ name : String)
+ {
+ fileData.createDirectory(name)
+ reloadData()
+ }
+
+
+
+ // Table handling functions
override func numberOfSections(in tableView: UITableView) -> Int
{
return 1
@@ -229,18 +277,32 @@ class FileManagerController : UITableViewController
}
return cell
}
+
+
+
+ // Select a row (file) and show actions
+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
+ {
+ selectedRow = indexPath
+ performSegue(withIdentifier: "showActions", sender: self)
+ }
-
- // MARK: - ViewController basic
- override func viewDidLoad()
+
+
+ // Support function
+ func reloadData()
{
- super.viewDidLoad()
- showFiles()
+ selectedRow = nil
+ tableView.reloadData()
}
+
}
+
+
+// Space holder for extra information needed to do the right thing for each action
class FileManagerCell: UITableViewCell {
-
+
@IBOutlet weak var fileLabel: UILabel!
var isDirectory : Bool = false
var fileName : String = ""
@@ -248,37 +310,83 @@ class FileManagerCell: UITableViewCell {
+// Protocol for action popover callback
+protocol actionsControlDelegate
+{
+ func actionOpen()
+ func actionDelete()
+ func actionUploadDownload()
+ func actionLevelUp()
+ func actionCreateDirectory(_ name : String)
+}
+
+
+
+// Action popover dialog
class FileManagerActions : UITableViewController
{
+ // Pointer to callback class
+ var delegate : actionsControlDelegate?
+ var inSubDirectory : Bool = false
+ var inFileSelect : Bool = false
+
+ // Calling class might enable/disable each button
@IBOutlet weak var buttonUploadDownload: UIButton!
@IBOutlet weak var buttonDelete: UIButton!
@IBOutlet weak var buttonOpen: UIButton!
@IBOutlet weak var buttonLevelUp: UIButton!
@IBOutlet weak var buttonCreateDirectory: UIButton!
-
- @IBAction func doOpen(_ sender: UIButton) {
+ @IBOutlet weak var editDirectoryName: UITextField!
+
+
+ // Actions
+ @IBAction func doOpen(_ sender: UIButton)
+ {
+ delegate?.actionOpen()
dismiss(animated: false)
}
- @IBAction func doDelete(_ sender: UIButton) {
+
+
+
+ @IBAction func doDelete(_ sender: UIButton)
+ {
+ delegate?.actionDelete()
dismiss(animated: false)
}
- @IBAction func doUploadDownload(_ sender: UIButton) {
+
+
+
+ @IBAction func doUploadDownload(_ sender: UIButton)
+ {
+ delegate?.actionDelete()
dismiss(animated: false)
}
- @IBAction func doLevelUp(_ sender: UIButton) {
+
+
+ @IBAction func doLevelUp(_ sender: UIButton)
+ {
+ delegate?.actionLevelUp()
dismiss(animated: false)
}
- @IBAction func doCreateDirectory(_ sender: UIButton) {
+
+ @IBAction func doCreateDirectory(_ sender: UIButton)
+ {
+ if editDirectoryName.text != "type name" {
+ delegate?.actionCreateDirectory(editDirectoryName.text!)
+ }
+ dismiss(animated: false)
}
- // MARK: - ViewController basic
-
-
+
+
override func viewDidLoad()
{
super.viewDidLoad()
- // Do any additional setup after loading the view.
+ buttonLevelUp.isEnabled = inSubDirectory
+ buttonOpen.isEnabled = inFileSelect
+ buttonDelete.isEnabled = inFileSelect
+ buttonUploadDownload.isEnabled = inFileSelect
}
}
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard b/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard
index 0c32c6c790c7..35fa0d50834e 100755
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard
@@ -105,7 +105,7 @@
</leftBarButtonItems>
<barButtonItem key="rightBarButtonItem" systemItem="action" id="IgM-Gx-FQp">
<connections>
- <segue destination="5ff-kT-49H" kind="popoverPresentation" popoverAnchorBarButtonItem="IgM-Gx-FQp" id="If5-Nv-a7W">
+ <segue destination="5ff-kT-49H" kind="popoverPresentation" identifier="showActions" popoverAnchorBarButtonItem="IgM-Gx-FQp" id="If5-Nv-a7W">
<popoverArrowDirection key="popoverArrowDirection" up="YES" down="YES" left="YES" right="YES"/>
</segue>
</connections>
@@ -122,7 +122,7 @@
<objects>
<tableViewController autoresizesArchivedViewToFullSize="NO" title="File Manager Actions" modalTransitionStyle="crossDissolve" modalPresentationStyle="overCurrentContext" clearsSelectionOnViewWillAppear="NO" id="5ff-kT-49H" customClass="FileManagerActions" customModule="LibreOfficeLight" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="30" sectionHeaderHeight="28" sectionFooterHeight="28" id="2t6-op-1gZ">
- <rect key="frame" x="0.0" y="0.0" width="134" height="150"/>
+ <rect key="frame" x="0.0" y="0.0" width="134" height="180"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<sections>
@@ -195,7 +195,6 @@
<state key="normal" title="Level up"/>
<connections>
<action selector="doLevelUp:" destination="5ff-kT-49H" eventType="touchUpInside" id="fM6-nH-5Z1"/>
- <action selector="doOpen:" destination="5ff-kT-49H" eventType="touchUpInside" id="kNJ-PT-8Y6"/>
</connections>
</button>
</subviews>
@@ -213,14 +212,29 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Create directory"/>
<connections>
- <action selector="doCreateDirectory:" destination="5ff-kT-49H" eventType="touchUpInside" id="58c-Ul-UIL"/>
- <action selector="doLevelUp:" destination="5ff-kT-49H" eventType="touchUpInside" id="4pP-76-PsI"/>
- <action selector="doOpen:" destination="5ff-kT-49H" eventType="touchUpInside" id="gZm-0c-D2v"/>
+ <action selector="doCreateDirectory:" destination="5ff-kT-49H" eventType="touchUpInside" id="oJG-8y-O2q"/>
</connections>
</button>
</subviews>
</tableViewCellContentView>
</tableViewCell>
+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="Va5-1U-paI">
+ <rect key="frame" x="0.0" y="150" width="134" height="30"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Va5-1U-paI" id="LW9-jL-3U7">
+ <rect key="frame" x="0.0" y="0.0" width="134" height="29"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="type name" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Lms-Tp-Xtt">
+ <rect key="frame" x="8" y="0.0" width="118" height="30"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <nil key="textColor"/>
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <textInputTraits key="textInputTraits"/>
+ </textField>
+ </subviews>
+ </tableViewCellContentView>
+ </tableViewCell>
</cells>
</tableViewSection>
</sections>
@@ -229,23 +243,24 @@
<outlet property="delegate" destination="5ff-kT-49H" id="LEX-V1-HLr"/>
</connections>
</tableView>
- <value key="contentSizeForViewInPopover" type="size" width="134" height="150"/>
+ <value key="contentSizeForViewInPopover" type="size" width="134" height="180"/>
<nil key="simulatedStatusBarMetrics"/>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
- <size key="freeformSize" width="134" height="150"/>
+ <size key="freeformSize" width="134" height="180"/>
<connections>
<outlet property="buttonCreateDirectory" destination="5Rk-LW-Ub9" id="4oy-Px-rKR"/>
<outlet property="buttonDelete" destination="IQ3-hK-KmM" id="GNv-Wu-Gdw"/>
<outlet property="buttonLevelUp" destination="fNi-5u-PqA" id="phL-bi-HaC"/>
<outlet property="buttonOpen" destination="BSN-dd-e84" id="j4Q-KH-UFt"/>
<outlet property="buttonUploadDownload" destination="ZSm-By-dJs" id="oVW-Nt-Pfx"/>
+ <outlet property="editDirectoryName" destination="Lms-Tp-Xtt" id="ztl-WH-mbg"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gPn-3u-MDl" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="1930" y="1201"/>
+ <point key="canvasLocation" x="1929.6875" y="1200.5859375"/>
</scene>
<!--Print Manager-->
<scene sceneID="viJ-XJ-htc">