diff --git a/Kiwix-iOS/Controller/Library/CloudBooksController.swift b/Kiwix-iOS/Controller/Library/CloudBooksController.swift index 4ed5b97c..c3402be3 100644 --- a/Kiwix-iOS/Controller/Library/CloudBooksController.swift +++ b/Kiwix-iOS/Controller/Library/CloudBooksController.swift @@ -26,8 +26,8 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel override func viewDidLoad() { super.viewDidLoad() -// tableView.emptyDataSetSource = self -// tableView.emptyDataSetDelegate = self + tableView.emptyDataSetSource = self + tableView.emptyDataSetDelegate = self tableView.tableFooterView = UIView() refreshControl = RefreshLibControl() diff --git a/Kiwix-iOS/Controller/Library/DownloadTasksController.swift b/Kiwix-iOS/Controller/Library/DownloadTasksController.swift index 11f8abf8..60e10a29 100644 --- a/Kiwix-iOS/Controller/Library/DownloadTasksController.swift +++ b/Kiwix-iOS/Controller/Library/DownloadTasksController.swift @@ -10,8 +10,9 @@ import UIKit import CoreData import DZNEmptyDataSet -class DownloadTasksController: UITableViewController, NSFetchedResultsControllerDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate { +class DownloadTasksController: UIViewController, NSFetchedResultsControllerDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate { + @IBOutlet weak var tableView: UITableView! var timer: NSTimer? // MARK: - Override @@ -84,16 +85,16 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController // MARK: - TableView Data Source - override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + func numberOfSectionsInTableView(tableView: UITableView) -> Int { return fetchedResultController.sections?.count ?? 0 } - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { guard let sectionInfo = fetchedResultController.sections?[section] else {return 0} return sectionInfo.numberOfObjects } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) self.configureCell(cell, atIndexPath: indexPath) return cell @@ -137,19 +138,19 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController // MARK: Other Data Source - override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { guard tableView.numberOfSections > 1 else {return nil} guard let languageName = fetchedResultController.sections?[section].name else {return nil} return languageName } - override func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { + func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { let sectionIndexTitles = fetchedResultController.sectionIndexTitles guard sectionIndexTitles.count > 2 else {return nil} return sectionIndexTitles } - override func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { + func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { return fetchedResultController.sectionForSectionIndexTitle(title, atIndex: index) } @@ -167,13 +168,13 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController // header.textLabel?.font = UIFont.boldSystemFontOfSize(14) // } // - override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { return true } - override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {} + func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {} - override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { + func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { guard let downloadTask = self.fetchedResultController.objectAtIndexPath(indexPath) as? DownloadTask else {return nil} var actions = [UITableViewRowAction]() diff --git a/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift b/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift index d00019cb..c3a24d06 100644 --- a/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift +++ b/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift @@ -26,9 +26,6 @@ extension DownloadTasksController { return NSAttributedString(string: string, attributes: attributes) } - func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { - return scrollView.contentInset.top - 64 - } } extension LocalBooksController { @@ -37,10 +34,6 @@ extension LocalBooksController { let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(18), NSForegroundColorAttributeName: UIColor.darkGrayColor()] return NSAttributedString(string: string, attributes: attributes) } - - func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { - return scrollView.contentInset.top - 64 - } } extension BookDetailController { @@ -49,10 +42,6 @@ extension BookDetailController { let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(18), NSForegroundColorAttributeName: UIColor.darkGrayColor()] return NSAttributedString(string: string, attributes: attributes) } - - func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { - return scrollView.contentInset.top - 64 - } } extension LanguageFilterController { @@ -62,7 +51,7 @@ extension LanguageFilterController { return NSAttributedString(string: string, attributes: attributes) } - func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { - return scrollView.contentInset.top - 64 - } +// func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { +// return scrollView.contentInset.top - 64 +// } } diff --git a/Kiwix-iOS/Controller/Library/LocalBooksController.swift b/Kiwix-iOS/Controller/Library/LocalBooksController.swift index 98b487d2..44f40c38 100644 --- a/Kiwix-iOS/Controller/Library/LocalBooksController.swift +++ b/Kiwix-iOS/Controller/Library/LocalBooksController.swift @@ -11,13 +11,15 @@ import CoreData import Operations import DZNEmptyDataSet -class LocalBooksController: UITableViewController, NSFetchedResultsControllerDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate { +class LocalBooksController: UIViewController, NSFetchedResultsControllerDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate { + + @IBOutlet weak var tableView: UITableView! // MARK: - Override required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - title = "" + title = "Local" tabBarItem.title = LocalizedStrings.LibraryTabTitle.local tabBarItem.image = UIImage(named: "Folder") tabBarItem.selectedImage = UIImage(named: "FolderFilled") @@ -61,16 +63,16 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel // MARK: - TableView Data Source - override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + func numberOfSectionsInTableView(tableView: UITableView) -> Int { return fetchedResultController.sections?.count ?? 0 } - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { guard let sectionInfo = fetchedResultController.sections?[section] else {return 0} return sectionInfo.numberOfObjects } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) self.configureCell(cell, atIndexPath: indexPath) return cell @@ -89,43 +91,43 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel // MARK: Other Data Source - override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { guard tableView.numberOfSections > 1 else {return nil} guard let languageName = fetchedResultController.sections?[section].name else {return nil} return languageName } - override func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { + func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { let sectionIndexTitles = fetchedResultController.sectionIndexTitles guard sectionIndexTitles.count > 2 else {return nil} return sectionIndexTitles } - override func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { + func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { return fetchedResultController.sectionForSectionIndexTitle(title, atIndex: index) } // MARK: - Table View Delegate - override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + 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} guard headerText != "" else {return 0.0} return 20.0 } - override func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { + func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { guard let header = view as? UITableViewHeaderFooterView else {return} header.textLabel?.font = UIFont.boldSystemFontOfSize(14) } - override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { return true } - override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {} + func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {} - override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { + func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { let delete = UITableViewRowAction(style: .Destructive, title: LocalizedStrings.delete) { (action, indexPath) -> Void in guard let book = self.fetchedResultController.objectAtIndexPath(indexPath) as? Book else {return} self.managedObjectContext.performBlock({ () -> Void in diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index e149d340..77e1a9cb 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.7.1606 + 1.7.1634 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/Storyboard/Library.storyboard b/Kiwix-iOS/Storyboard/Library.storyboard index 72ad8deb..8ee3be3a 100644 --- a/Kiwix-iOS/Storyboard/Library.storyboard +++ b/Kiwix-iOS/Storyboard/Library.storyboard @@ -11,14 +11,15 @@ + - + - + @@ -107,10 +108,10 @@ + - @@ -126,8 +127,8 @@ - - + + @@ -335,199 +336,227 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -685,6 +714,6 @@ - + diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index 32a7f390..c230eeec 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.7.2035 + 1.7.2073 NSExtension NSExtensionMainStoryboard diff --git a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 551a8289..dbfe494b 100644 --- a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -19,21 +19,5 @@ landmarkType = "5"> - - - - diff --git a/Kiwix/Operations/RefreshLibraryOperation.swift b/Kiwix/Operations/RefreshLibraryOperation.swift index e7bb5b51..921e7232 100644 --- a/Kiwix/Operations/RefreshLibraryOperation.swift +++ b/Kiwix/Operations/RefreshLibraryOperation.swift @@ -12,6 +12,7 @@ import Operations class RefreshLibraryOperation: GroupOperation { private(set) var hasUpdate = false + private(set) var firstTime = false init() { let retrive = Retrive() @@ -22,6 +23,7 @@ class RefreshLibraryOperation: GroupOperation { process.addObserver(DidFinishObserver { (operation, errors) in guard let operation = operation as? Process else {return} self.hasUpdate = operation.hasUpdate + self.firstTime = operation.firstTime }) } } @@ -50,6 +52,7 @@ private class Retrive: Operation, ResultOperationType { private class Process: Operation, NSXMLParserDelegate, AutomaticInjectionOperationType { var requirement: NSData? private(set) var hasUpdate = false + private(set) var firstTime = false private let context: NSManagedObjectContext private var oldBookIDs = Set() private var newBookIDs = Set() @@ -110,6 +113,7 @@ private class Process: Operation, NSXMLParserDelegate, AutomaticInjectionOperati }) saveManagedObjectContexts() + firstTime = Preference.libraryLastRefreshTime == nil Preference.libraryLastRefreshTime = NSDate() } diff --git a/Kiwix/Operations/UIOperations.swift b/Kiwix/Operations/UIOperations.swift index 78c7299c..79d95721 100644 --- a/Kiwix/Operations/UIOperations.swift +++ b/Kiwix/Operations/UIOperations.swift @@ -11,17 +11,6 @@ import Operations // MARK: - Alerts -class SpaceNotEnoughAlert: AlertOperation { - let comment = "Library: Download Space Not Enough Alert" - init(book: Book, presentationContext: CloudBooksController) { - super.init(presentAlertFrom: presentationContext) - - title = NSLocalizedString("Space Not Enough", comment: comment) - message = NSLocalizedString("You don't have enough remaining space to download this book.", comment: comment) - addActionWithTitle(LocalizedStrings.ok) - } -} - class RefreshLibraryLanguageFilterAlert: AlertOperation { let comment = "Library: Language Filter Alert" let context = UIApplication.appDelegate.managedObjectContext @@ -79,13 +68,13 @@ class RefreshLibraryLanguageFilterAlert: AlertOperation { } class RefreshLibraryInternetRequiredAlert: AlertOperation { - let comment = "Library: Internet Required Alert" + let comment = "Library, Internet Required Alert" init(presentationContext: CloudBooksController) { super.init(presentAlertFrom: presentationContext) - title = NSLocalizedString("Internet Connection Required", comment: comment) - message = NSLocalizedString("You need to connect to the Internet to refresh the library.", comment: comment) - addActionWithTitle(LocalizedStrings.ok) + title = NSLocalizedString("Internet Required", comment: comment) + message = NSLocalizedString("Please connect to the Internet to refresh library.", comment: comment) + addActionWithTitle(LocalizedStrings.Common.ok) } }