From 7b10fdfea9fb2a777adc73137af7cf05d67261c7 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 29 Aug 2016 10:36:07 -0400 Subject: [PATCH] Pull Down refresh ago string --- .../Controller/Library/CloudBooksController.swift | 11 +++++++---- Kiwix-iOS/Info.plist | 2 +- Kiwix-iOSWidgets/Bookmarks/Info.plist | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Kiwix-iOS/Controller/Library/CloudBooksController.swift b/Kiwix-iOS/Controller/Library/CloudBooksController.swift index 00400bb3..8fc72041 100644 --- a/Kiwix-iOS/Controller/Library/CloudBooksController.swift +++ b/Kiwix-iOS/Controller/Library/CloudBooksController.swift @@ -262,7 +262,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel class RefreshLibControl: UIRefreshControl { static let pullDownToRefresh = NSLocalizedString("Pull Down To Refresh", comment: "Refresh Library Control") - static let lastRefresh = NSLocalizedString("Last Refresh", comment: "Refresh Library Control") + static let lastRefresh = NSLocalizedString("Last Refresh: %@ ago", comment: "Refresh Library Control") override var hidden: Bool { didSet { @@ -274,9 +274,12 @@ class RefreshLibControl: UIRefreshControl { private func updateTitle() { let string: String = { guard let lastRefreshTime = Preference.libraryLastRefreshTime else {return RefreshLibControl.pullDownToRefresh} - let formatter = NSDateFormatter() - formatter.dateFormat = "MMM d, h:mm a" - return "Last Refresh" + ": " + formatter.stringFromDate(lastRefreshTime) + let interval = lastRefreshTime.timeIntervalSinceNow * -1 + let formatter = NSDateComponentsFormatter() + formatter.unitsStyle = .Abbreviated + formatter.allowedUnits = [.Day, .Hour, .Minute] + let string = formatter.stringFromTimeInterval(interval) ?? "" + return String(format: RefreshLibControl.lastRefresh, string) }() let attributes = [NSForegroundColorAttributeName: UIColor.blackColor()] attributedTitle = NSAttributedString(string: string, attributes: attributes) diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index e7a04c12..954e5cd5 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.7.1486 + 1.7.1499 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index c77585ee..4f09b453 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.7.1839 + 1.7.1856 NSExtension NSExtensionMainStoryboard