Cloud Controller Update

Internet Alert
Background Image button text
refresh button
This commit is contained in:
Chris Li 2016-09-06 17:08:21 -04:00
parent 8cb6f20c2c
commit 7f5be0822a
9 changed files with 50 additions and 43 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.7.1729</string>
<string>1.7.1757</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -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)
}

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.7.2244</string>
<string>1.7.2292</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>

View File

@ -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<Article>
@NSManaged var downloadTask: DownloadTask?
@NSManaged var language: Language?

View File

@ -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)