UIApplication Build Type Identifier

This commit is contained in:
Chris Li 2016-07-06 15:57:15 -04:00
parent 288fb65a7e
commit 1ad927d7ea
6 changed files with 33 additions and 20 deletions

View File

@ -63,12 +63,12 @@ class SearchController: UIViewController, UISearchBarDelegate, UIGestureRecogniz
if delayed { if delayed {
let previousSearchText = searchText let previousSearchText = searchText
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(275 * USEC_PER_SEC)), dispatch_get_main_queue()) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(275 * USEC_PER_SEC)), dispatch_get_main_queue()) {
print("\(previousSearchText), \(self.searchText)") //print("\(previousSearchText), \(self.searchText)")
guard previousSearchText == self.searchText else {return} guard previousSearchText == self.searchText else {return}
self.searchResultTBVC?.startSearch(self.searchText) self.searchResultTBVC?.startSearch(self.searchText)
} }
} else { } else {
searchResultTBVC?.startSearch(self.searchText) searchResultTBVC?.startSearch(searchText)
} }
} }

View File

@ -92,7 +92,11 @@ class SearchResultTBVC: UIViewController, UITableViewDataSource, UITableViewDele
func configureArticleCell(cell: ArticleCell, result: SearchResult) { func configureArticleCell(cell: ArticleCell, result: SearchResult) {
guard let book = Book.fetch(result.bookID, context: UIApplication.appDelegate.managedObjectContext) else {return} guard let book = Book.fetch(result.bookID, context: UIApplication.appDelegate.managedObjectContext) else {return}
cell.titleLabel.text = result.title + "(\(result.distance), \(result.probability ?? -1), \(String(format: "%.4f", result.score)))" if UIApplication.buildStatus == .Alpha {
cell.titleLabel.text = result.title + result.rankInfo
} else {
cell.titleLabel.text = result.title
}
cell.hasPicIndicator.backgroundColor = book.hasPic ? UIColor.havePicTintColor : UIColor.lightGrayColor() cell.hasPicIndicator.backgroundColor = book.hasPic ? UIColor.havePicTintColor : UIColor.lightGrayColor()
cell.favIcon.image = book.favIcon != nil ? UIImage(data: book.favIcon!) : nil cell.favIcon.image = book.favIcon != nil ? UIImage(data: book.favIcon!) : nil
} }

View File

@ -9,14 +9,10 @@
import UIKit import UIKit
class SettingTBVC: UITableViewController { class SettingTBVC: UITableViewController {
private(set) var sectionHeader = [LocalizedStrings.library, LocalizedStrings.reading,LocalizedStrings.misc]
let alpha = true private(set) var cellTextlabels = [[LocalizedStrings.libraryAutoRefresh, LocalizedStrings.libraryUseCellularData, LocalizedStrings.libraryBackup],
let sectionHeader = [LocalizedStrings.library, LocalizedStrings.reading,LocalizedStrings.misc, "Search"]
let cellTextlabels = [[LocalizedStrings.libraryAutoRefresh, LocalizedStrings.libraryUseCellularData, LocalizedStrings.libraryBackup],
[LocalizedStrings.fontSize, LocalizedStrings.adjustLayout], [LocalizedStrings.fontSize, LocalizedStrings.adjustLayout],
[LocalizedStrings.rateKiwix, LocalizedStrings.about], [LocalizedStrings.rateKiwix, LocalizedStrings.about]]
["Boost Factor 🚀"]]
let dateComponentsFormatter: NSDateComponentsFormatter = { let dateComponentsFormatter: NSDateComponentsFormatter = {
let formatter = NSDateComponentsFormatter() let formatter = NSDateComponentsFormatter()
@ -29,6 +25,11 @@ class SettingTBVC: UITableViewController {
title = LocalizedStrings.settings title = LocalizedStrings.settings
clearsSelectionOnViewWillAppear = true clearsSelectionOnViewWillAppear = true
showRateKiwixIfNeeded() showRateKiwixIfNeeded()
if UIApplication.buildStatus == .Alpha {
sectionHeader.append("Search")
cellTextlabels.append(["Boost Factor 🚀"])
}
} }
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
@ -79,12 +80,16 @@ class SettingTBVC: UITableViewController {
} }
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? { override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
if section == tableView.numberOfSections - 1 { guard section == tableView.numberOfSections - 1 else {return nil}
let versionString = String(format: LocalizedStrings.versionString, NSBundle.appShortVersion) + (alpha ? " Alpha" : "") var footnote = String(format: LocalizedStrings.versionString, NSBundle.appShortVersion)
let buildNumString = "Build " + NSBundle.buildVersion switch UIApplication.buildStatus {
return [versionString, buildNumString].joinWithSeparator("\n") case .Alpha, .Beta:
} else { footnote += (UIApplication.buildStatus == .Alpha ? " Alpha" : " Beta")
return nil footnote += "\n"
footnote += "Build " + NSBundle.buildVersion
return footnote
case .Release:
return footnote
} }
} }

View File

@ -36,7 +36,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1518</string> <string>1523</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -35,14 +35,14 @@ extension NSManagedObjectContext {
// MARK: - UI // MARK: - UI
enum BuildType { enum BuildStatus {
case Alpha, Beta, Release case Alpha, Beta, Release
} }
extension UIApplication { extension UIApplication {
var buildType: BuildType { class var buildStatus: BuildStatus {
get { get {
return .Alpha return .Beta
} }
} }
} }

View File

@ -209,4 +209,8 @@ class SearchResult: CustomStringConvertible {
parts.append("dist: \(distance)") parts.append("dist: \(distance)")
return parts.joinWithSeparator(", ") return parts.joinWithSeparator(", ")
} }
var rankInfo: String {
return "(\(distance), \(probability ?? -1), \(String(format: "%.4f", score)))"
}
} }