mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-24 04:03:03 -04:00
Several Improvements
This commit is contained in:
parent
bd429fa1f4
commit
4cc59ab187
@ -103,6 +103,8 @@
|
||||
97C11F961C6D1F120048C867 /* LibraryTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C11F951C6D1F120048C867 /* LibraryTabBarController.swift */; };
|
||||
97CCC4E81C1F0D970041DAEE /* BarButtonItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97CCC4E71C1F0D970041DAEE /* BarButtonItems.swift */; };
|
||||
97DA06C71CB6DA3400EBA609 /* LibraryLocalBookDetailTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DA06C61CB6DA3400EBA609 /* LibraryLocalBookDetailTBVC.swift */; };
|
||||
97DF23551CE807A1003E1E5A /* GlobalOperationQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DF23541CE807A1003E1E5A /* GlobalOperationQueue.swift */; };
|
||||
97DF23571CE8083C003E1E5A /* LibraryScanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DF23561CE8083C003E1E5A /* LibraryScanOperation.swift */; };
|
||||
97E067241C52980F0079C13C /* MainVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E067231C52980F0079C13C /* MainVC.swift */; };
|
||||
97E067261C52AA000079C13C /* MainVCWebViewD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E067251C52AA000079C13C /* MainVCWebViewD.swift */; };
|
||||
97E067281C52AC360079C13C /* MainVCOtherD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E067271C52AC360079C13C /* MainVCOtherD.swift */; };
|
||||
@ -289,6 +291,8 @@
|
||||
97C11F951C6D1F120048C867 /* LibraryTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryTabBarController.swift; sourceTree = "<group>"; };
|
||||
97CCC4E71C1F0D970041DAEE /* BarButtonItems.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarButtonItems.swift; sourceTree = "<group>"; };
|
||||
97DA06C61CB6DA3400EBA609 /* LibraryLocalBookDetailTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryLocalBookDetailTBVC.swift; sourceTree = "<group>"; };
|
||||
97DF23541CE807A1003E1E5A /* GlobalOperationQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlobalOperationQueue.swift; sourceTree = "<group>"; };
|
||||
97DF23561CE8083C003E1E5A /* LibraryScanOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryScanOperation.swift; sourceTree = "<group>"; };
|
||||
97E067231C52980F0079C13C /* MainVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVC.swift; sourceTree = "<group>"; };
|
||||
97E067251C52AA000079C13C /* MainVCWebViewD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVCWebViewD.swift; sourceTree = "<group>"; };
|
||||
97E067271C52AC360079C13C /* MainVCOtherD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVCOtherD.swift; sourceTree = "<group>"; };
|
||||
@ -822,9 +826,11 @@
|
||||
97E5712A1CA0525300FF4F1D /* Operation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97DF23541CE807A1003E1E5A /* GlobalOperationQueue.swift */,
|
||||
970103F91C6824FA00DC48F6 /* RefreshLibraryOperation.swift */,
|
||||
97B50C7E1CA1E4810010BD79 /* UIOperations.swift */,
|
||||
973970EC1CB9A04C00350507 /* SearchOperation.swift */,
|
||||
97DF23561CE8083C003E1E5A /* LibraryScanOperation.swift */,
|
||||
);
|
||||
name = Operation;
|
||||
sourceTree = "<group>";
|
||||
@ -1073,6 +1079,7 @@
|
||||
97E570FC1CA0500400FF4F1D /* AlertOperation.swift in Sources */,
|
||||
97E5710C1CA0500400FF4F1D /* LocationCapability-iOS.swift in Sources */,
|
||||
97E571001CA0500400FF4F1D /* CalendarCondition.swift in Sources */,
|
||||
97DF23551CE807A1003E1E5A /* GlobalOperationQueue.swift in Sources */,
|
||||
97E571121CA0500400FF4F1D /* NegatedCondition.swift in Sources */,
|
||||
97E571251CA0500400FF4F1D /* TimeoutObserver.swift in Sources */,
|
||||
970103FB1C6824FA00DC48F6 /* RefreshLibraryOperation.swift in Sources */,
|
||||
@ -1140,6 +1147,7 @@
|
||||
9714D8D71C6E5C2600AABCA7 /* LTBarButtonItem.swift in Sources */,
|
||||
97E571221CA0500400FF4F1D /* ReachabilityCondition.swift in Sources */,
|
||||
97E570FE1CA0500400FF4F1D /* BlockOperation.swift in Sources */,
|
||||
97DF23571CE8083C003E1E5A /* LibraryScanOperation.swift in Sources */,
|
||||
973381631C331D660016CEFB /* ArticleCells.swift in Sources */,
|
||||
97E571211CA0500400FF4F1D /* PushCapability-OSX.swift in Sources */,
|
||||
97E571241CA0500400FF4F1D /* SilentCondition.swift in Sources */,
|
||||
|
@ -21,11 +21,5 @@ extension UIApplication {
|
||||
guard settings.types.contains(UIUserNotificationType.Badge) else {return}
|
||||
//UIApplication.sharedApplication().applicationIconBadgeNumber = downloader.taskCount ?? 0
|
||||
}
|
||||
|
||||
// MARK: - App Delegate Accessor
|
||||
|
||||
class var appDelegate: AppDelegate {
|
||||
return UIApplication.sharedApplication().delegate as! AppDelegate
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import UIKit
|
||||
|
||||
class Book: NSManagedObject {
|
||||
|
||||
// MARK: - Add/Update Book
|
||||
// MARK: - Add Book
|
||||
|
||||
class func add(metadata: [String: AnyObject], context: NSManagedObjectContext) -> Book? {
|
||||
guard let book = insert(Book.self, context: context) else {return nil}
|
||||
@ -44,7 +44,7 @@ class Book: NSManagedObject {
|
||||
if let favIcon = metadata["favicon"] as? NSData {
|
||||
book.favIcon = favIcon
|
||||
} else if let favIcon = metadata["favicon"] as? String {
|
||||
book.favIcon = NSData(base64EncodedString: favIcon, options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
|
||||
book.favIcon = NSData(base64EncodedString: favIcon, options: .IgnoreUnknownCharacters)
|
||||
}
|
||||
|
||||
if let meta4url = book.meta4URL {
|
||||
@ -89,14 +89,33 @@ class Book: NSManagedObject {
|
||||
|
||||
var dateFormatted: String? {
|
||||
guard let date = date else {return nil}
|
||||
return Utilities.formattedDateStringFromDate(date)
|
||||
|
||||
let formatter = NSDateFormatter()
|
||||
formatter.dateFormat = "MM-dd-yyyy"
|
||||
formatter.dateStyle = .MediumStyle
|
||||
return formatter.stringFromDate(date)
|
||||
}
|
||||
|
||||
var fileSizeFormatted: String? {
|
||||
return Utilities.formattedFileSizeStringFromByteCount(fileSize)
|
||||
return NSByteCountFormatter.stringFromByteCount(fileSize, countStyle: .File)
|
||||
}
|
||||
|
||||
var articleCountFormatted: String? {
|
||||
func formattedNumberStringFromDouble(num: Double) -> String {
|
||||
let sign = ((num < 0) ? "-" : "" )
|
||||
let abs = fabs(num)
|
||||
guard abs >= 1000.0 else {
|
||||
if abs - Double(Int(abs)) == 0 {
|
||||
return "\(sign)\(Int(abs))"
|
||||
} else {
|
||||
return "\(sign)\(abs)"
|
||||
}
|
||||
}
|
||||
let exp: Int = Int(log10(abs) / log10(1000))
|
||||
let units: [String] = ["K","M","G","T","P","E"]
|
||||
let roundedNum: Double = round(10 * abs / pow(1000.0,Double(exp))) / 10;
|
||||
return "\(sign)\(roundedNum)\(units[exp-1])"
|
||||
}
|
||||
return Utilities.formattedNumberStringFromDouble(Double(articleCount)) + (articleCount >= 1 ? " articles" : " article")
|
||||
}
|
||||
|
||||
@ -143,8 +162,6 @@ class Book: NSManagedObject {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - States
|
||||
|
||||
var spaceState: BookSpaceState {
|
||||
|
@ -10,6 +10,14 @@ import Foundation
|
||||
import CoreData
|
||||
import UIKit
|
||||
|
||||
// MARK: - App Delegate Accessor
|
||||
|
||||
extension UIApplication {
|
||||
class var appDelegate: AppDelegate {
|
||||
return UIApplication.sharedApplication().delegate as! AppDelegate
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
extension UIStoryboard {
|
||||
|
18
Kiwix/GlobalOperationQueue.swift
Normal file
18
Kiwix/GlobalOperationQueue.swift
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// GlobalOperationQueue.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 5/14/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class GlobalOperationQueue: OperationQueue {
|
||||
static let sharedInstance = GlobalOperationQueue()
|
||||
|
||||
var isRefreshingLibrary: Bool {
|
||||
let op = operation(String(RefreshLibraryOperation))
|
||||
return op != nil
|
||||
}
|
||||
}
|
@ -32,11 +32,11 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.5</string>
|
||||
<string>1.5.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>201605091</string>
|
||||
<string>1</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -102,7 +102,7 @@ class LibraryOnlineTBVC: UITableViewController, NSFetchedResultsControllerDelega
|
||||
configureMessage()
|
||||
configureRotatingStatus()
|
||||
configureEmptyTableBackground()
|
||||
UIApplication.globalOperationQueue.addOperation(refreshOperation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(refreshOperation)
|
||||
}
|
||||
|
||||
// MARK: - ToolBar Button
|
||||
|
13
Kiwix/LibraryScanOperation.swift
Normal file
13
Kiwix/LibraryScanOperation.swift
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// LibraryScanOperation.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 5/14/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class LibraryScanOperation: Operation {
|
||||
|
||||
}
|
@ -45,5 +45,23 @@
|
||||
<string>%d download tasks</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>%d articles</key>
|
||||
<dict>
|
||||
<key>NSStringLocalizedFormatKey</key>
|
||||
<string>%#@articles@</string>
|
||||
<key>articles</key>
|
||||
<dict>
|
||||
<key>NSStringFormatSpecTypeKey</key>
|
||||
<string>NSStringPluralRuleType</string>
|
||||
<key>NSStringFormatValueTypeKey</key>
|
||||
<string>d</string>
|
||||
<key>zero</key>
|
||||
<string>No download task</string>
|
||||
<key>one</key>
|
||||
<string>%d download task</string>
|
||||
<key>other</key>
|
||||
<string>%d download tasks</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
@ -23,7 +23,7 @@ class Network: NSObject, NSURLSessionDelegate, NSURLSessionDownloadDelegate, NSU
|
||||
lazy var session: NSURLSession = {
|
||||
let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("org.kiwix.www")
|
||||
configuration.allowsCellularAccess = false
|
||||
configuration.discretionary = true
|
||||
configuration.discretionary = false
|
||||
return NSURLSession(configuration: configuration, delegate: self, delegateQueue: nil)
|
||||
}()
|
||||
|
||||
|
@ -31,19 +31,19 @@ extension Utilities {
|
||||
return formatter.stringFromNumber(number)
|
||||
}
|
||||
|
||||
class func formattedNumberStringFromDouble(var num: Double) -> String {
|
||||
class func formattedNumberStringFromDouble(num: Double) -> String {
|
||||
let sign = ((num < 0) ? "-" : "" )
|
||||
num = fabs(num)
|
||||
guard num >= 1000.0 else {
|
||||
if num - Double(Int(num)) == 0 {
|
||||
return "\(sign)\(Int(num))"
|
||||
let abs = fabs(num)
|
||||
guard abs >= 1000.0 else {
|
||||
if abs - Double(Int(abs)) == 0 {
|
||||
return "\(sign)\(Int(abs))"
|
||||
} else {
|
||||
return "\(sign)\(num)"
|
||||
return "\(sign)\(abs)"
|
||||
}
|
||||
}
|
||||
let exp: Int = Int(log10(num) / log10(1000))
|
||||
let exp: Int = Int(log10(abs) / log10(1000))
|
||||
let units: [String] = ["K","M","G","T","P","E"]
|
||||
let roundedNum: Double = round(10 * num / pow(1000.0,Double(exp))) / 10;
|
||||
let roundedNum: Double = round(10 * abs / pow(1000.0,Double(exp))) / 10;
|
||||
return "\(sign)\(roundedNum)\(units[exp-1])"
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,10 @@ What you need:
|
||||
1. Make sure Xcode is at least launched once and commnad line tool is installed
|
||||
2. Install Macports
|
||||
3. sudo port install autoconf automake libtool
|
||||
|
||||
<!--HomeBrew:
|
||||
* brew install autoconf automake libtool gettext
|
||||
* brew link --force gettext-->
|
||||
|
||||
### Compile xz-5.2.2
|
||||
1. Download xz-5.2.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user