diff --git a/Kiwix-iOS/Controller/Library/BookDetailController.swift b/Kiwix-iOS/Controller/Library/BookDetailController.swift index c1301808..df977a89 100644 --- a/Kiwix-iOS/Controller/Library/BookDetailController.swift +++ b/Kiwix-iOS/Controller/Library/BookDetailController.swift @@ -110,7 +110,8 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN let download = UIAlertAction(title: Strings.SpaceAlert.downloadAnyway, style: .Destructive, handler: { (alert) in startDownload() }) - let alertController = UIAlertController(title: Strings.SpaceAlert.spaceAlert, message: Strings.SpaceAlert.message, actions: [download, cancel]) + let alertController = UIAlertController(title: Strings.SpaceAlert.spaceAlert, message: Strings.SpaceAlert.message, preferredStyle: .Alert) + [download, cancel].forEach({ alertController.addAction($0) }) presentViewController(alertController, animated: true, completion: nil) } else { startDownload() @@ -119,8 +120,9 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN guard let url = book.url else {return} UIPasteboard.generalPasteboard().string = url.absoluteString let action = UIAlertAction(title: LocalizedStrings.Common.ok, style: .Cancel, handler: nil) - let alert = UIAlertController(title: Strings.CopyURLAlert.succeed, message: "", actions: [action]) - presentViewController(alert, animated: true, completion: nil) + let alertController = UIAlertController(title: Strings.CopyURLAlert.succeed, message: nil, preferredStyle: .Alert) + alertController.addAction(action) + presentViewController(alertController, animated: true, completion: nil) default: return } diff --git a/Kiwix-iOS/Controller/Library/CloudBooksController.swift b/Kiwix-iOS/Controller/Library/CloudBooksController.swift index ba253501..260318da 100644 --- a/Kiwix-iOS/Controller/Library/CloudBooksController.swift +++ b/Kiwix-iOS/Controller/Library/CloudBooksController.swift @@ -78,23 +78,29 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel func refreshAutomatically() { guard let date = Preference.libraryLastRefreshTime else { - refresh() + refresh(invokedByUser: false) return } guard date.timeIntervalSinceNow < -86400 else {return} - refresh() + refresh(invokedByUser: false) } - func refresh() { + func refresh(invokedByUser invokedByUser: Bool) { let operation = RefreshLibraryOperation() operation.addObserver(DidFinishObserver { (operation, errors) in NSOperationQueue.mainQueue().addOperationWithBlock({ self.refreshControl?.endRefreshing() }) - let t = ReachabilityCondition.Error.NotReachable -// if let error = errors.first { -// guard error == ReachabilityCondition.Error.NotReachable else {return} -// } + + if let error = errors.first as? ReachabilityCondition.Error{ + guard error == ReachabilityCondition.Error.NotReachable && invokedByUser == true else {return} + let cancel = UIAlertAction(title: LocalizedStrings.Common.ok, style: .Cancel, handler: nil) + let alertController = UIAlertController(title: NSLocalizedString("Network Required", comment: "Network Required Alert"), + message: NSLocalizedString("Unable to connect to server. Please check your Internet connection.", comment: "Network Required Alert"), + preferredStyle: .Alert) + alertController.addAction(cancel) + self.presentViewController(alertController, animated: true, completion: nil) + } }) GlobalQueue.shared.addOperation(operation) } diff --git a/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift b/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift index c3a24d06..79abd4f0 100644 --- a/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift +++ b/Kiwix-iOS/Controller/Library/EmptyTableConfigExtension.swift @@ -11,12 +11,30 @@ import DZNEmptyDataSet extension CloudBooksController { + func imageForEmptyDataSet(scrollView: UIScrollView!) -> UIImage! { + return UIImage(named: "CloudColor") + } + func titleForEmptyDataSet(scrollView: UIScrollView!) -> NSAttributedString! { - let string = NSLocalizedString("Library is Empty", comment: "") + let string = NSLocalizedString("There are some books in the cloud", comment: "Cloud Book Controller") let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(18), NSForegroundColorAttributeName: UIColor.darkGrayColor()] return NSAttributedString(string: string, attributes: attributes) } + func buttonTitleForEmptyDataSet(scrollView: UIScrollView!, forState state: UIControlState) -> NSAttributedString! { + let string = NSLocalizedString("Refresh", comment: "Cloud Book Controller") + let attributes = [NSFontAttributeName: UIFont.boldSystemFontOfSize(17), NSForegroundColorAttributeName: AppColors.theme] + return NSAttributedString(string: string, attributes: attributes) + } + + func emptyDataSetDidTapButton(scrollView: UIScrollView!) { + refresh(invokedByUser: true) + } + + func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { + return -navigationController!.navigationBar.frame.height + } + } extension DownloadTasksController { diff --git a/Kiwix-iOS/Controller/Setting/SettingSearchHistoryTBVC.swift b/Kiwix-iOS/Controller/Setting/SettingSearchHistoryTBVC.swift index da1da8e7..66b9e9db 100644 --- a/Kiwix-iOS/Controller/Setting/SettingSearchHistoryTBVC.swift +++ b/Kiwix-iOS/Controller/Setting/SettingSearchHistoryTBVC.swift @@ -37,14 +37,16 @@ class SettingSearchHistoryTBVC: UITableViewController { let delete = UIAlertAction(title: LocalizedStrings.delete, style: .Destructive) { (action) in Preference.recentSearchTerms = [] let ok = UIAlertAction(title: LocalizedStrings.ok, style: .Default, handler: nil) - let alert = UIAlertController(title: NSLocalizedString("Your search history has been cleared.", comment: "Setting: Search History"), message: "", actions: [ok]) - self.presentViewController(alert, animated: true, completion: nil) + let alertController = UIAlertController(title: NSLocalizedString("Your search history has been cleared.", comment: "Setting: Search History"), message: nil, preferredStyle: .Alert) + alertController.addAction(ok) + self.presentViewController(alertController, animated: true, completion: nil) } let cancel = UIAlertAction(title: LocalizedStrings.cancel, style: .Cancel, handler: nil) - let alert = UIAlertController(title: NSLocalizedString("Are you sure?", comment: "Setting: Search History"), - message: NSLocalizedString("This action is not recoverable.", comment: "Setting: Search History"), - actions: [delete, cancel]) - presentViewController(alert, animated: true, completion: nil) + let alertController = UIAlertController(title: NSLocalizedString("Are you sure?", comment: "Setting: Search History"), + message: NSLocalizedString("This action is not recoverable.", comment: "Setting: Search History"), + preferredStyle: .Alert) + [delete, cancel].forEach({ alertController.addAction($0) }) + presentViewController(alertController, animated: true, completion: nil) tableView.deselectRowAtIndexPath(indexPath, animated: true) } diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 96eedae7..e3344e52 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.7.1729 + 1.7.1757 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/iOSExtensions.swift b/Kiwix-iOS/iOSExtensions.swift index e4ca965f..94d8057e 100644 --- a/Kiwix-iOS/iOSExtensions.swift +++ b/Kiwix-iOS/iOSExtensions.swift @@ -81,26 +81,5 @@ extension UIColor { class AppColors { static let hasPicTintColor = UIColor(red: 1, green: 0.5, blue: 0, alpha: 1) static let hasIndexTintColor = UIColor(red: 0.304706, green: 0.47158, blue: 1, alpha: 1) -} - -extension UITableView { - - func setBackgroundText(text: String?) { - let label = UILabel() - label.textAlignment = .Center - label.text = text - label.font = UIFont.boldSystemFontOfSize(20.0) - label.numberOfLines = 0 - label.textColor = UIColor.grayColor() - backgroundView = label - } -} - -// MARK: - View Controller - -extension UIAlertController { - convenience init(title: String, message: String, style: UIAlertControllerStyle = .Alert, actions:[UIAlertAction]) { - self.init(title: title, message: message , preferredStyle: style) - for action in actions {addAction(action)} - } + static let theme = UIColor(red: 71/255, green: 128/255, blue: 182/255, alpha: 1) } diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index 72eefee4..dc289807 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.7.2244 + 1.7.2292 NSExtension NSExtensionMainStoryboard diff --git a/Kiwix/CoreData/Classes/Book+CoreDataProperties.swift b/Kiwix/CoreData/Classes/Book+CoreDataProperties.swift index 88acc22c..95e76667 100644 --- a/Kiwix/CoreData/Classes/Book+CoreDataProperties.swift +++ b/Kiwix/CoreData/Classes/Book+CoreDataProperties.swift @@ -30,7 +30,7 @@ extension Book { @NSManaged var meta4URL: String? @NSManaged var publisher: String? @NSManaged var title: String? - @NSManaged var articles: NSSet? + @NSManaged var articles: Set
@NSManaged var downloadTask: DownloadTask? @NSManaged var language: Language? diff --git a/Kiwix/Operations/RefreshLibraryOperation.swift b/Kiwix/Operations/RefreshLibraryOperation.swift index 921e7232..008992ea 100644 --- a/Kiwix/Operations/RefreshLibraryOperation.swift +++ b/Kiwix/Operations/RefreshLibraryOperation.swift @@ -14,7 +14,7 @@ class RefreshLibraryOperation: GroupOperation { private(set) var hasUpdate = false private(set) var firstTime = false - init() { + init(invokedByUser: Bool = false) { let retrive = Retrive() let process = Process() process.injectResultFromDependency(retrive)