diff --git a/Kiwix-iOS/Controller/Library/CloudBooksController.swift b/Kiwix-iOS/Controller/Library/CloudBooksController.swift index 65927309..6bc86238 100644 --- a/Kiwix-iOS/Controller/Library/CloudBooksController.swift +++ b/Kiwix-iOS/Controller/Library/CloudBooksController.swift @@ -9,7 +9,7 @@ import UIKit import CoreData -class CloudBooksController: UITableViewController, NSFetchedResultsControllerDelegate, TableCellDelegate{ +class CloudBooksController: UITableViewController, NSFetchedResultsControllerDelegate { var bookDetailController = UIStoryboard.libraryNew.initViewController(BookDetailController.self)! @@ -17,7 +17,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel super.viewDidLoad() title = "" navigationController?.view.backgroundColor = UIColor.whiteColor() - splitViewController?.tabBarItem.title = "Cloud" + tabBarItem.title = "Cloud" } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { @@ -36,23 +36,8 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel } - // MARK: - TableCellDelegate - - func didTapOnAccessoryViewForCell(cell: UITableViewCell) { - guard let indexPath = tableView.indexPathForCell(cell), - let book = fetchedResultController.objectAtIndexPath(indexPath) as? Book else {return} - switch book.spaceState { - case .Enough: - Network.sharedInstance.download(book) - //case .Caution: - // TODO: - Switch to a global op queue - //Network.sharedInstance.operationQueue.addOperation(SpaceCautionAlert(book: book, presentationContext: self)) - //case .NotEnough: - // TODO: - Switch to a global op queue - //Network.sharedInstance.operationQueue.addOperation(SpaceNotEnoughAlert(book: book, presentationContext: self)) - default: - break - } + @IBAction func dismissSelf(sender: UIBarButtonItem) { + dismissViewControllerAnimated(true, completion: nil) } // MARK: - TableView Data Source @@ -102,10 +87,6 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel // MARK: - Table View Delegate - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - guard let book = fetchedResultController.objectAtIndexPath(indexPath) as? Book else {return} - } - override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { guard tableView.numberOfSections > 1 else {return 0.0} guard let headerText = self.tableView(tableView, titleForHeaderInSection: section) else {return 0.0} diff --git a/Kiwix-iOS/Controller/Main/MainController.swift b/Kiwix-iOS/Controller/Main/MainController.swift index caa0f067..a2661969 100644 --- a/Kiwix-iOS/Controller/Main/MainController.swift +++ b/Kiwix-iOS/Controller/Main/MainController.swift @@ -225,7 +225,7 @@ class MainController: UIViewController { func showLibraryButtonTapped() { guard let viewController = libraryNewController ?? UIStoryboard.libraryNew.instantiateInitialViewController() else {return} - viewController.modalPresentationStyle = .OverFullScreen + viewController.modalPresentationStyle = .FullScreen libraryNewController = viewController presentViewController(viewController, animated: true, completion: nil) } diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 4a914fcf..623bb0d3 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.7.873 + 1.7.882 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/Model/Utilities.swift b/Kiwix-iOS/Model/Utilities.swift index a897bbf6..f78a0d1f 100644 --- a/Kiwix-iOS/Model/Utilities.swift +++ b/Kiwix-iOS/Model/Utilities.swift @@ -35,17 +35,3 @@ class Utilities: NSObject { } } } - -extension UIDevice { - class var availableDiskSpace: Int64? { - do { - let docDirPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true).first! - let systemAttributes = try NSFileManager.defaultManager().attributesOfFileSystemForPath(docDirPath) - guard let freeSize = systemAttributes[NSFileSystemFreeSize] as? NSNumber else {return nil} - return freeSize.longLongValue - } catch let error as NSError { - print("Fetch system disk free space failed, error: \(error.localizedDescription)") - return nil - } - } -} \ No newline at end of file diff --git a/Kiwix-iOS/Storyboard/LibraryNew.storyboard b/Kiwix-iOS/Storyboard/LibraryNew.storyboard index d5c4e943..08935634 100644 --- a/Kiwix-iOS/Storyboard/LibraryNew.storyboard +++ b/Kiwix-iOS/Storyboard/LibraryNew.storyboard @@ -26,7 +26,7 @@ - + @@ -151,7 +151,13 @@ - + + + + + + + @@ -374,7 +380,7 @@ - + @@ -453,7 +459,10 @@ + + + - + diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index e321e55e..c032a593 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.7.928 + 1.7.942 NSExtension NSExtensionMainStoryboard diff --git a/Kiwix/CoreData/Book.swift b/Kiwix/CoreData/Book.swift index 7c504517..ff2b1b66 100644 --- a/Kiwix/CoreData/Book.swift +++ b/Kiwix/CoreData/Book.swift @@ -181,18 +181,14 @@ class Book: NSManagedObject { // MARK: - States var spaceState: BookSpaceState { - #if os(iOS) || os(watchOS) || os(tvOS) - let freeSpaceInBytes = UIDevice.availableDiskSpace ?? INT64_MAX - if (0.8 * Double(freeSpaceInBytes)) > Double(fileSize) { - return .Enough - } else if freeSpaceInBytes < fileSize{ - return .NotEnough - } else { - return .Caution - } - #elseif os(OSX) + guard let freeSpaceInBytes = UIDevice.availableDiskSpace?.freeSize else {return .Enough} + if (0.8 * Double(freeSpaceInBytes)) > Double(fileSize) { return .Enough - #endif + } else if freeSpaceInBytes < fileSize{ + return .NotEnough + } else { + return .Caution + } } } diff --git a/Kiwix/Extensions.swift b/Kiwix/Extensions.swift index cba5bd1d..29bf2a11 100644 --- a/Kiwix/Extensions.swift +++ b/Kiwix/Extensions.swift @@ -70,4 +70,13 @@ extension NSFileManager { } } +extension UIDevice { + class var availableDiskSpace: (freeSize: Int64, totalSize: Int64)? { + let docDirPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true).first! + guard let systemAttributes = try? NSFileManager.defaultManager().attributesOfFileSystemForPath(docDirPath) else {return nil} + guard let freeSize = systemAttributes[NSFileSystemFreeSize] as? Int64, + let totalSize = systemAttributes[NSFileSystemSize] as? Int64 else {return nil} + return (freeSize, totalSize) + } +}