Skip to content

Commit

Permalink
iOS 1.9.7 (#160)
Browse files Browse the repository at this point in the history
* Build number

* bump build

* Search queue

* ZimMultiReader search update

* Search Operations remove dependency

* Remove dependencies in library refresh and scan

* remove procedure kit

* Migrate to swift 5

* fix bar button issue

* SwiftyUserDefaults Update

* Update switch cases

* remove unused keys

* Upgrade realm version

* search result table readable width

* Disable layout constraint break point

* Update library master controller data source

* migrate language config

* Fix issues in info.plist

* Add a change log

* update readme
  • Loading branch information
automactic authored Jul 8, 2019
1 parent 9368a19 commit bef93e8
Show file tree
Hide file tree
Showing 32 changed files with 256 additions and 364 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "submodules/ProcedureKit"]
path = submodules/ProcedureKit
url = /~https://github.com/ProcedureKit/ProcedureKit.git
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## 1.9.7 (Jul 7, 2019)

- fix: memory usage issue when performing searches
- maintance updates:
- swift 5.2, version bump of libkiwix, realm and SwiftyUserDefaults
- removed third party library ProcedureKit, now use Foundation.OperationQueue to handle async tasks

## 1.9.6 (May 10, 2019)

- updated user feedback email address to `contact.kiwix.org`
- dropped support for external indexes
- improved iOS 12 support
- new version of libkiwix and Swift 4.2
64 changes: 21 additions & 43 deletions Kiwix.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "_NSLayoutConstraintNumberExceedsLimit"
moduleName = "">
<Locations>
<Location
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "_NSLayoutConstraintNumberExceedsLimit"
Expand Down
10 changes: 3 additions & 7 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ target 'iOS' do
platform :ios, '10.0'
use_frameworks!

pod 'SwiftyUserDefaults'
pod 'ProcedureKit', :path => 'submodules/ProcedureKit'
# pod 'ProcedureKit/All', :path => 'submodules/ProcedureKit'
pod 'SwiftyUserDefaults', '~> 4.0'
pod 'RealmSwift'
end

target 'macOS' do
platform :osx, '10.10'
platform :osx, '10.11'
use_frameworks!

pod 'SwiftyUserDefaults'
# pod 'ProcedureKit', :path => 'submodules/ProcedureKit'
pod 'SwiftyUserDefaults', '~> 4.0'
pod 'RealmSwift'
end

target 'WikiMed' do
platform :ios, '10.0'
use_frameworks!

pod 'ProcedureKit', :path => 'submodules/ProcedureKit'
end
33 changes: 12 additions & 21 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
PODS:
- ProcedureKit (5.2.0):
- ProcedureKit/Standard (= 5.2.0)
- ProcedureKit/Standard (5.2.0)
- Realm (3.14.1):
- Realm/Headers (= 3.14.1)
- Realm/Headers (3.14.1)
- RealmSwift (3.14.1):
- Realm (= 3.14.1)
- SwiftyUserDefaults (3.0.1)
- Realm (3.17.0):
- Realm/Headers (= 3.17.0)
- Realm/Headers (3.17.0)
- RealmSwift (3.17.0):
- Realm (= 3.17.0)
- SwiftyUserDefaults (4.0.0)

DEPENDENCIES:
- ProcedureKit (from `submodules/ProcedureKit`)
- RealmSwift
- SwiftyUserDefaults
- SwiftyUserDefaults (~> 4.0)

SPEC REPOS:
/~https://github.com/cocoapods/specs.git:
- Realm
- RealmSwift
- SwiftyUserDefaults

EXTERNAL SOURCES:
ProcedureKit:
:path: submodules/ProcedureKit

SPEC CHECKSUMS:
ProcedureKit: deafeab083a0c5e45e4b02379e0ffa316d03db29
Realm: e12c9c2387d05c5bba3a9c394838f5870e85763b
RealmSwift: a82eab9b04c3e1616082c7e17aa300740847769c
SwiftyUserDefaults: 3d273b1739b68ada3145dc754a70ec775bc5c8be
Realm: b30db41ff34fc858ffc25ba8d44a82c164e7ccd0
RealmSwift: fe733e459d60dc7b6971d4cbee2eb4854097d12c
SwiftyUserDefaults: 6a1951df1daa19337862b677dd9a4b9bd4c288cd

PODFILE CHECKSUM: a61f112cfe6e38dfdd6bce8817f1cd1e124cf7d7
PODFILE CHECKSUM: aef950eaf9fe0f90666e247d9c0e3157ac76b317

COCOAPODS: 1.6.1
COCOAPODS: 1.7.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Kiwix for iOS & macOS
<img src="https://img.shields.io/badge/Swift-4.1-orange.svg" alt="Drawing="/>
<img src="https://img.shields.io/badge/Swift-5.2-orange.svg" alt="Drawing="/>

This is the home for Kiwix apps on iOS and macOS.

Expand Down
2 changes: 1 addition & 1 deletion Shared/Network/NetworkActivityIndicatorController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NetworkActivityController {
}

func taskDidFinish(identifier: String) {
guard let index = taskIdentifiers.index(of: identifier) else {
guard let index = taskIdentifiers.firstIndex(of: identifier) else {
return
}
taskIdentifiers.remove(at: index)
Expand Down
72 changes: 24 additions & 48 deletions Shared/Preference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,33 @@ class Preference {

// MARK: - Library

class var libraryAutoRefreshDisabled: Bool {
get{return Defaults[.libraryAutoRefreshDisabled]}
set{Defaults[.libraryAutoRefreshDisabled] = newValue}
}

class var libraryRefreshAllowCellularData: Bool {
get{return !Defaults[.libraryRefreshNotAllowCellularData]}
set{Defaults[.libraryRefreshNotAllowCellularData] = !newValue}
}

class var libraryRefreshInterval: TimeInterval {
get{return Defaults[.libraryRefreshInterval] ?? 3600.0 * 24}
set{Defaults[.libraryRefreshInterval] = newValue}
}

class LangFilter {
class var sortByAlphabeticalAsc: Bool {
get{return Defaults[.langFilterSortByAlphabeticalAsc]}
set{Defaults[.langFilterSortByAlphabeticalAsc] = newValue}
}

class var displayInOriginalLocale: Bool {
get{return Defaults[.langFilterNameDisplayInOriginalLocale]}
set{Defaults[.langFilterNameDisplayInOriginalLocale] = newValue}
}
}
// class var libraryAutoRefreshDisabled: Bool {
// get{return Defaults[.libraryAutoRefreshDisabled]}
// set{Defaults[.libraryAutoRefreshDisabled] = newValue}
// }
//
// class var libraryRefreshAllowCellularData: Bool {
// get{return !Defaults[.libraryRefreshNotAllowCellularData]}
// set{Defaults[.libraryRefreshNotAllowCellularData] = !newValue}
// }
//
// class var libraryRefreshInterval: TimeInterval {
// get{return Defaults[.libraryRefreshInterval] ?? 3600.0 * 24}
// set{Defaults[.libraryRefreshInterval] = newValue}
// }
}

extension DefaultsKeys {
static let hasSubscribedToCloudKitChanges = DefaultsKey<Bool>("hasSubscribedToCloudKitChanges")
static let activeUseHistory = DefaultsKey<[Date]>("activeUseHistory")
static let haveRateKiwix = DefaultsKey<Bool>("haveRateKiwix")


static let recentSearchTexts = DefaultsKey<[String]>("recentSearchTexts")

static let webViewZoomScale = DefaultsKey<Double?>("webViewZoomScale")
static let backupDocumentDirectory = DefaultsKey<Bool>("backupDocumentDirectory")
static let externalLinkLoadingPolicy = DefaultsKey<Int>("externalLinkLoadingPolicy")

static let libraryAutoRefreshDisabled = DefaultsKey<Bool>("libraryAutoRefreshDisabled")
static let libraryRefreshNotAllowCellularData = DefaultsKey<Bool>("libraryRefreshNotAllowCellularData")
static let libraryLastRefreshTime = DefaultsKey<Date?>("libraryLastRefreshTime")
static let libraryHasShownLanguageFilterAlert = DefaultsKey<Bool>("libraryHasShownLanguageFilterAlert")
static let libraryRefreshInterval = DefaultsKey<Double?>("libraryRefreshInterval")
static let libraryFilterLanguageCodes = DefaultsKey<[String]>("libraryFilterLanguageCodes")

static let langFilterSortByAlphabeticalAsc = DefaultsKey<Bool>("langFilterSortByAlphabeticalAsc")
static let langFilterNameDisplayInOriginalLocale = DefaultsKey<Bool>("langFilterNameDisplayInOriginalLocale")


// static let hasSubscribedToCloudKitChanges = DefaultsKey<Bool>("hasSubscribedToCloudKitChanges")
// static let activeUseHistory = DefaultsKey<[Date]>("activeUseHistory")
// static let haveRateKiwix = DefaultsKey<Bool>("haveRateKiwix")
//
//
// static let libraryAutoRefreshDisabled = DefaultsKey<Bool>("libraryAutoRefreshDisabled")
// static let libraryRefreshNotAllowCellularData = DefaultsKey<Bool>("libraryRefreshNotAllowCellularData")
// static let libraryLastRefreshTime = DefaultsKey<Date?>("libraryLastRefreshTime")
// static let libraryHasShownLanguageFilterAlert = DefaultsKey<Bool>("libraryHasShownLanguageFilterAlert")
// static let libraryRefreshInterval = DefaultsKey<Double?>("libraryRefreshInterval")
}

// MARK: - Rate
Expand Down
42 changes: 10 additions & 32 deletions Shared/Procedure/Queue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,20 @@
// Copyright © 2017 Chris Li. All rights reserved.
//

import ProcedureKit

class Queue: ProcedureQueue {
static let shared = Queue()
override private init() {}
class LibraryOperationQueue: OperationQueue {
static let shared = LibraryOperationQueue()
private(set) weak var lastLibraryRefreshOperation: LibraryRefreshOperation?

var isRefreshingLibrary: Bool {
if let procedure = currentRefreshLibraryProcedure {
print("getter unwrapped: \(operations.contains(procedure))")
return operations.contains(procedure)
} else {
return false
}
}

private(set) weak var currentRefreshLibraryProcedure: LibraryRefreshProcedure?

func add(libraryRefreshProcedure procedure: LibraryRefreshProcedure) {
guard currentRefreshLibraryProcedure == nil else {return}
addOperation(procedure)
currentRefreshLibraryProcedure = procedure
}

private (set) weak var refreshLibraryProcedure: LibraryRefreshProcedure?
func add(libraryRefresh procedure: LibraryRefreshProcedure) {
guard refreshLibraryProcedure == nil else {return}
addOperation(procedure)
self.refreshLibraryProcedure = procedure
override init() {
super.init()
maxConcurrentOperationCount = 1
}

private weak var scan: ScanProcedure?
func add(scanProcedure: ScanProcedure) {
if let previous = scan {
scanProcedure.addDependency(previous)
override func addOperation(_ op: Operation) {
if let operation = op as? LibraryRefreshOperation {
lastLibraryRefreshOperation = operation
}
addOperation(scanProcedure)
self.scan = scanProcedure
super.addOperation(op)
}
}
14 changes: 6 additions & 8 deletions Shared/Procedure/SearchProcedure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
// Copyright © 2017 Chris Li. All rights reserved.
//

import ProcedureKit

class SearchProcedure: Procedure {
class SearchProcedure: Operation {
let searchText: String
let ids: Set<ZimFileID>
let extractSnippet: Bool
Expand All @@ -24,22 +23,21 @@ class SearchProcedure: Procedure {
name = "Search Procedure"
}

override func execute() {
guard searchText.count > 0 else {finish(); return}
override func main() {
guard searchText.count > 0 else {return}
addIndexedSearchResults()
addTitleSearchResults()
sort()
finish()
}

private func addIndexedSearchResults() {
guard !isCancelled else { ZimMultiReader.shared.stopIndexSearch(); return }
defer { ZimMultiReader.shared.stopIndexSearch() }
guard !isCancelled else { return }
ZimMultiReader.shared.startIndexSearch(searchText: searchText, zimFileIDs: ids)
while let result = ZimMultiReader.shared.getNextIndexSearchResult(extractSnippet: extractSnippet) {
guard !isCancelled else { ZimMultiReader.shared.stopIndexSearch(); return }
guard !isCancelled else { return }
results.insert(result)
}
ZimMultiReader.shared.stopIndexSearch();
}

private func addTitleSearchResults() {
Expand Down
52 changes: 23 additions & 29 deletions Shared/Procedure/SearchQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,42 @@
// Copyright © 2018 Chris Li. All rights reserved.
//

import ProcedureKit
import SwiftyUserDefaults

class SearchQueue: ProcedureQueue, ProcedureQueueDelegate {
class SearchQueue: OperationQueue {
weak var eventDelegate: SearchQueueEvents?
private var operationsObserver: NSKeyValueObservation?

override init() {
super.init()
delegate = self
maxConcurrentOperationCount = 1
operationsObserver = observe(\.operations, options: [.new, .old], changeHandler: { (operation, change) in
guard let oldOperations = change.oldValue, let newOperations = change.newValue else {return}
if (newOperations.count > oldOperations.count) {
// did start search
guard oldOperations.count == 0 else {return}
DispatchQueue.main.async {
self.eventDelegate?.searchStarted()
}
} else {
// did finish search operation
guard newOperations.count == 0, let operation = oldOperations.last as? SearchProcedure else {return}
DispatchQueue.main.async {
if operation.isCancelled {
self.eventDelegate?.searchFinished(searchText: "", results: [])
} else {
self.eventDelegate?.searchFinished(searchText: operation.searchText, results: operation.sortedResults)
}
}
}
})
}

func enqueue(searchText: String, zimFileIDs: Set<ZimFileID>) {
cancelAllOperations()
let procedure = SearchProcedure(term: searchText, ids: zimFileIDs, extractSnippet: !Defaults[.searchResultExcludeSnippet])
addOperation(procedure)
}

func cancelAll() {
operations.forEach({ $0.cancel() })
}

func procedureQueue(_ queue: ProcedureQueue, willAddProcedure procedure: Procedure, context: Any?) -> ProcedureFuture? {
if queue.operationCount == 0 {
DispatchQueue.main.async {
self.eventDelegate?.searchStarted()
}
} else {
cancelAll()
}
return nil
}

func procedureQueue(_ queue: ProcedureQueue, didFinishProcedure procedure: Procedure, with error: Error?) {
guard queue.operationCount == 0, let procedure = procedure as? SearchProcedure else {return}
DispatchQueue.main.async {
if procedure.isCancelled {
self.eventDelegate?.searchFinished(searchText: "", results: [])
} else {
self.eventDelegate?.searchFinished(searchText: procedure.searchText, results: procedure.sortedResults)
}
}
}
}

protocol SearchQueueEvents: class {
Expand Down
Loading

0 comments on commit bef93e8

Please sign in to comment.