diff --git a/Kiwix-iOS/Controller/Alerts.swift b/Kiwix-iOS/Controller/Alerts.swift index 385f957c..0570c28a 100644 --- a/Kiwix-iOS/Controller/Alerts.swift +++ b/Kiwix-iOS/Controller/Alerts.swift @@ -38,7 +38,7 @@ class RemoveBookConfirmationAlert: AlertOperation { super.init(presentAlertFrom: context) title = NSLocalizedString("Remove this book?", comment: "Library, Delete Alert") - message = NSLocalizedString("This operation is not recoverable. All bookmarks in this book will also be removed!", comment: "Library, Delete Alert") + message = NSLocalizedString("Only the zim file will be removed. All bookmarks related to this book will still be kept.", comment: "Library, Delete Alert") addActionWithTitle(LocalizedStrings.remove, style: .Destructive) { _ in let operation = RemoveBookOperation(bookID: bookID) GlobalQueue.shared.addOperation(operation) diff --git a/Kiwix-iOS/Controller/Library/LocalBooksController.swift b/Kiwix-iOS/Controller/Library/LocalBooksController.swift index 1a6df356..69d44b54 100644 --- a/Kiwix-iOS/Controller/Library/LocalBooksController.swift +++ b/Kiwix-iOS/Controller/Library/LocalBooksController.swift @@ -89,27 +89,22 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel // MARK: Other Data Source override 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]? { - 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 { - return fetchedResultController.sectionForSectionIndexTitle(title, atIndex: index) + guard let stateRaw = fetchedResultController.sections?[section].name else {return nil} + switch stateRaw { + case "2": + return LocalizedStrings.local + case "3": + return LocalizedStrings.retainedByBookmarks + case "4": + return LocalizedStrings.purgeable + default: + return nil + } } // MARK: - Table View Delegate 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} - guard headerText != "" else {return 0.0} return 20.0 } @@ -143,11 +138,11 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel let managedObjectContext = NSManagedObjectContext.mainQueueContext lazy var fetchedResultController: NSFetchedResultsController = { let fetchRequest = NSFetchRequest(entityName: "Book") - let langDescriptor = NSSortDescriptor(key: "language.name", ascending: true) + let stateDescriptor = NSSortDescriptor(key: "stateRaw", ascending: true) let titleDescriptor = NSSortDescriptor(key: "title", ascending: true) - fetchRequest.sortDescriptors = [langDescriptor, titleDescriptor] + fetchRequest.sortDescriptors = [stateDescriptor, titleDescriptor] fetchRequest.predicate = NSPredicate(format: "stateRaw >= 2") - let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext, sectionNameKeyPath: "language.name", cacheName: "LocalFRC" + NSBundle.buildVersion) + let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext, sectionNameKeyPath: "stateRaw", cacheName: "LocalFRC" + NSBundle.buildVersion) fetchedResultsController.delegate = self fetchedResultsController.performFetch(deleteCache: false) return fetchedResultsController @@ -197,5 +192,7 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel class LocalizedStrings{ static let local = NSLocalizedString("Local", comment: "Library, local tab") static let remove = NSLocalizedString("Remove", comment: "Library, local tab") + static let retainedByBookmarks = NSLocalizedString("Retained by Bookmarks", comment: "Library, local tab") + static let purgeable = NSLocalizedString("Purgeable", comment: "Library, local tab") } } diff --git a/Kiwix-iOS/Controller/Search/SearchBooksVC.swift b/Kiwix-iOS/Controller/Search/SearchBooksVC.swift index 2e9f3546..f5620b96 100644 --- a/Kiwix-iOS/Controller/Search/SearchBooksVC.swift +++ b/Kiwix-iOS/Controller/Search/SearchBooksVC.swift @@ -75,7 +75,7 @@ class SearchBooksController: UIViewController, UITableViewDelegate, UITableViewD let langDescriptor = NSSortDescriptor(key: "language.name", ascending: true) let titleDescriptor = NSSortDescriptor(key: "title", ascending: true) fetchRequest.sortDescriptors = [langDescriptor, titleDescriptor] - fetchRequest.predicate = NSPredicate(format: "isLocal == true") + fetchRequest.predicate = NSPredicate(format: "stateRaw == 2") let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext, sectionNameKeyPath: "language.name", cacheName: "ScopeFRC") fetchedResultsController.delegate = self fetchedResultsController.performFetch(deleteCache: false) diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 6886b31c..6c7d8c31 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.8.1070 + 1.8.1089 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index 6ad39a9c..85f38a4e 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.8.1074 + 1.8.1093 NSExtension NSExtensionMainStoryboard diff --git a/Kiwix/Operations/ScanLocalBookOperation.swift b/Kiwix/Operations/ScanLocalBookOperation.swift index 84314b7a..3cd886ac 100644 --- a/Kiwix/Operations/ScanLocalBookOperation.swift +++ b/Kiwix/Operations/ScanLocalBookOperation.swift @@ -73,10 +73,14 @@ class ScanLocalBookOperation: Operation { for id in removedZimFileIDs { guard let book = localBooks[id] else {continue} - if let _ = book.meta4URL { - book.state = .Cloud + if book.articles.filter({ $0.isBookmarked }).count > 0 { + book.state = .Retained } else { - context.deleteObject(book) + if let _ = book.meta4URL { + book.state = .Cloud + } else { + context.deleteObject(book) + } } } diff --git a/Kiwix/Tools/StringTools.swift b/Kiwix/Tools/StringTools.swift index 71f85359..1d9a7920 100644 --- a/Kiwix/Tools/StringTools.swift +++ b/Kiwix/Tools/StringTools.swift @@ -54,6 +54,7 @@ class LocalizedStrings { class Library { static let spaceNotEnough = NSLocalizedString("Space Not Enough", comment: "Library") + } diff --git a/Kiwix/ZimMultiReader/ZimMultiReader.swift b/Kiwix/ZimMultiReader/ZimMultiReader.swift index 1218a1df..81ae2834 100644 --- a/Kiwix/ZimMultiReader/ZimMultiReader.swift +++ b/Kiwix/ZimMultiReader/ZimMultiReader.swift @@ -88,8 +88,7 @@ class ZimMultiReader: NSObject, DirectoryMonitorDelegate { // MARK: - Loading System - func data(host: String, contentURLString: String) -> [String: AnyObject]? { - let id = pidMap[host] ?? host + func data(id: String, contentURLString: String) -> [String: AnyObject]? { guard let reader = readers[id] else {return nil} return reader.dataWithContentURLString(contentURLString) as? [String: AnyObject] }