Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,14 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0710;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = FolioReader;
TargetAttributes = {
1A42C2881C0E3882000F2137 = {
CreatedOnToolsVersion = 7.1.1;
DevelopmentTeam = 32F2T8EJ6G;
LastSwiftMigration = 0800;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand All @@ -286,10 +289,15 @@
};
CA10C1301C572A4B0049165D = {
CreatedOnToolsVersion = 7.3;
DevelopmentTeam = 32F2T8EJ6G;
LastSwiftMigration = 0800;
ProvisioningStyle = Automatic;
TestTargetID = 1A42C2881C0E3882000F2137;
};
D12066621D65FABD006E1D18 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 32F2T8EJ6G;
ProvisioningStyle = Automatic;
};
};
};
Expand Down Expand Up @@ -665,8 +673,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -710,8 +720,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -730,7 +742,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -740,36 +752,48 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5C8EADB52E1D834750CD7D23 /* Pods-Example.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
1A42C29D1C0E3883000F2137 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F4CBB0C2C0FDFA3E1648DB43 /* Pods-Example.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Release;
};
CA10C1391C572A4B0049165D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3CE90B4095B5C7E6237EEBDD /* Pods-FolioReaderTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = FolioReaderTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Debug;
Expand All @@ -778,12 +802,16 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 8E1BE6465444C567F5D1B8E6 /* Pods-FolioReaderTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = FolioReaderTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Release;
Expand All @@ -792,8 +820,11 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D7C82C879F323C6E960F882B /* Pods-StoryboardExample.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = StoryboardExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -806,8 +837,11 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1D4790507F22E69298DC06E1 /* Pods-StoryboardExample.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = StoryboardExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 5 additions & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ target 'FolioReaderTests' do
testing_pods
end

# ensure testability is set https://github.com/CocoaPods/CocoaPods/issues/4505

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Force add version
config.build_settings['SWIFT_VERSION'] = '2.3'

# ensure testability is set https://github.com/CocoaPods/CocoaPods/issues/4505
if config.name == 'Debug'
config.build_settings['ENABLE_TESTABILITY'] = 'YES'
end
Expand Down
7 changes: 2 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ PODS:
- AEXML (3.0.0)
- FolioReaderKit (0.9.3):
- AEXML (= 3.0)
- FontBlaster (= 2.1.4)
- JSQWebViewController (~> 3.0)
- MenuItemKit (= 1.1.3)
- RealmSwift (~> 1.0)
- SSZipArchive (= 1.5)
- ZFDragableModalTransition (~> 0.6)
- FontBlaster (2.1.4)
- JSQWebViewController (3.0.0)
- MenuItemKit (1.1.3)
- Nimble (4.1.0)
Expand All @@ -32,8 +30,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
AEXML: 716fb0a8decba4a3517324a71fee3685b30233d2
FolioReaderKit: a8f6f5aa4f8c2488e42bff609ae10e3cb31c348e
FontBlaster: b780f709b8f705638d0c80a1ecdfb23b3077d0a6
FolioReaderKit: 16cbbf673d457016e80ec6230090e70059d3e144
JSQWebViewController: eaa6bd68d9e1426ae25ade99c9bbde4c6cdd4120
MenuItemKit: 11c448d9172936ee79ebb78f36dffd396020a9e5
Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19
Expand All @@ -43,6 +40,6 @@ SPEC CHECKSUMS:
SSZipArchive: 29daace2bccb90a47de2837744da397728ff9207
ZFDragableModalTransition: 0d294eaaba6edfcb9839595de765f9ca06a4b524

PODFILE CHECKSUM: 617d506c4ff6fef0fcf4032d9acdc7ee8ad208e9
PODFILE CHECKSUM: 55962a6106e53da04861e4602fc98856987b97b3

COCOAPODS: 1.0.1
1 change: 0 additions & 1 deletion FolioReaderKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Pod::Spec.new do |s|
s.dependency 'MenuItemKit', '1.1.3'
s.dependency 'ZFDragableModalTransition', '~> 0.6'
s.dependency 'AEXML', '3.0'
s.dependency 'FontBlaster', '2.1.4'
s.dependency 'JSQWebViewController', '~> 3.0'
s.dependency 'RealmSwift', '~> 1.0'
# s.dependency 'SMSegmentView'
Expand Down
4 changes: 2 additions & 2 deletions Source/EPUBCore/FREpubParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ class FREpubParser: NSObject, SSZipArchiveDelegate {
let tocData = try NSData(contentsOfFile: tocPath, options: .DataReadingMappedAlways)
let xmlDoc = try AEXMLDocument(xmlData: tocData)

if let nav = xmlDoc.root["body"]["nav"].first, itemsList = nav["ol"]["li"].all {
if let nav = xmlDoc.root["body"]["nav"].first, let itemsList = nav["ol"]["li"].all {
tocItems = itemsList
} else if let nav = findNavTag(xmlDoc.root["body"]), itemsList = nav["ol"]["li"].all {
} else if let nav = findNavTag(xmlDoc.root["body"]), let itemsList = nav["ol"]["li"].all {
tocItems = itemsList
}
}
Expand Down
4 changes: 4 additions & 0 deletions Source/FolioReaderCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICo
enableScrollBetweenChapters(scrollEnabled: true)
view.addSubview(collectionView)

if #available(iOS 10.0, *) {
collectionView.prefetchingEnabled = false
}

// Register cell classes
collectionView!.registerClass(FolioReaderPage.self, forCellWithReuseIdentifier: reuseIdentifier)

Expand Down
1 change: 0 additions & 1 deletion Source/FolioReaderContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import UIKit
import FontBlaster

var readerConfig: FolioReaderConfig!
var book: FRBook!
Expand Down
14 changes: 7 additions & 7 deletions Source/FolioReaderKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public class FolioReader: NSObject {
// MARK: - Get Cover Image

/**
Read Cover Image and Return an IUImage
Read Cover Image and Return an `UIImage`
*/
public class func getCoverImage(epubPath: String) -> UIImage? {
return FREpubParser().parseCoverImage(epubPath)
Expand Down Expand Up @@ -606,11 +606,11 @@ internal extension UIImage {
CGContextSetBlendMode(context, CGBlendMode.Normal)

let rect = CGRectMake(0, 0, self.size.width, self.size.height) as CGRect
CGContextClipToMask(context, rect, self.CGImage)
CGContextClipToMask(context, rect, self.CGImage!)
tintColor.setFill()
CGContextFillRect(context, rect)

let newImage = UIGraphicsGetImageFromCurrentImageContext() as UIImage
let newImage = UIGraphicsGetImageFromCurrentImageContext()! as UIImage
UIGraphicsEndImageContext()

return newImage
Expand All @@ -633,11 +633,11 @@ internal extension UIImage {
UIColor.whiteColor().setFill()
}

CGContextFillRect(context, rect)
CGContextFillRect(context!, rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

return image
return image!
}

/**
Expand All @@ -651,7 +651,7 @@ internal extension UIImage {
layer.renderInContext(UIGraphicsGetCurrentContext()!)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
return img!
}

/**
Expand All @@ -665,7 +665,7 @@ internal extension UIImage {
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
return img!
}
}

Expand Down
32 changes: 16 additions & 16 deletions Source/FolioReaderPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGesture

shouldShowBar = false

let decoded = url.absoluteString.stringByRemovingPercentEncoding as String!
let decoded = url.absoluteString!.stringByRemovingPercentEncoding as String!
let rect = CGRectFromString(decoded.substringFromIndex(decoded.startIndex.advancedBy(12)))

webView.createMenu(options: true)
Expand All @@ -198,7 +198,7 @@ public class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGesture
return false
} else if url.scheme == "play-audio" {

let decoded = url.absoluteString.stringByRemovingPercentEncoding as String!
let decoded = url.absoluteString!.stringByRemovingPercentEncoding as String!
let playID = decoded.substringFromIndex(decoded.startIndex.advancedBy(13))
let chapter = FolioReader.sharedInstance.readerCenter?.getCurrentChapter()
let href = chapter != nil ? chapter!.href : "";
Expand Down Expand Up @@ -246,7 +246,7 @@ public class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGesture
} else if url.scheme == "mailto" {
print("Email")
return true
} else if url.absoluteString != "about:blank" && url.scheme.containsString("http") && navigationType == .LinkClicked {
} else if url.absoluteString != "about:blank" && url.scheme!.containsString("http") && navigationType == .LinkClicked {

if #available(iOS 9.0, *) {
let safariVC = SFSafariViewController(URL: request.URL!)
Expand All @@ -263,19 +263,19 @@ public class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGesture
// Check if the url is a custom class based onClick listerner
var isClassBasedOnClickListenerScheme = false
for listener in readerConfig.classBasedOnClickListeners {
if
url.scheme == listener.schemeName,
let absoluteURLString = request.URL?.absoluteString,
range = absoluteURLString.rangeOfString("/clientX=") {
let baseURL = absoluteURLString.substringToIndex(range.startIndex)
let positionString = absoluteURLString.substringFromIndex(range.startIndex)
if let point = getEventTouchPoint(fromPositionParameterString: positionString) {
let attributeContentString = (baseURL.stringByReplacingOccurrencesOfString("\(url.scheme)://", withString: "").stringByRemovingPercentEncoding)
// Call the on click action block
listener.onClickAction(attributeContent: attributeContentString, touchPointRelativeToWebView: point)
// Mark the scheme as class based click listener scheme
isClassBasedOnClickListenerScheme = true
}

if url.scheme == listener.schemeName,
let absoluteURLString = request.URL?.absoluteString,
let range = absoluteURLString.rangeOfString("/clientX=") {
let baseURL = absoluteURLString.substringToIndex(range.startIndex)
let positionString = absoluteURLString.substringFromIndex(range.startIndex)
if let point = getEventTouchPoint(fromPositionParameterString: positionString) {
let attributeContentString = (baseURL.stringByReplacingOccurrencesOfString("\(url.scheme)://", withString: "").stringByRemovingPercentEncoding)
// Call the on click action block
listener.onClickAction(attributeContent: attributeContentString, touchPointRelativeToWebView: point)
// Mark the scheme as class based click listener scheme
isClassBasedOnClickListenerScheme = true
}
}
}

Expand Down
18 changes: 10 additions & 8 deletions Source/FolioReaderPageIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ class FolioReaderPageIndicator: UIView {
pagesLabel.textColor = isNight(UIColor(white: 5, alpha: 0.6), UIColor(white: 0, alpha: 0.9))
}

override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
// Set the shadow color to the final value of the animation is done
if let _keyPath = anim.valueForKeyPath("keyPath") as? String where _keyPath == "shadowColor" {
let color = isNight(readerConfig.nightModeBackground, UIColor.whiteColor())
layer.shadowColor = color.CGColor
}
}

private func reloadViewWithPage(page: Int) {
let pagesRemaining = FolioReader.needsRTLChange ? totalPages-(totalPages-page+1) : totalPages-page

Expand All @@ -110,3 +102,13 @@ class FolioReaderPageIndicator: UIView {
reloadView(updateShadow: false)
}
}

extension FolioReaderPageIndicator: CAAnimationDelegate {
func animationDidStop(anim: CAAnimation, finished flag: Bool) {
// Set the shadow color to the final value of the animation is done
if let keyPath = anim.valueForKeyPath("keyPath") as? String where keyPath == "shadowColor" {
let color = isNight(readerConfig.nightModeBackground, UIColor.whiteColor())
layer.shadowColor = color.CGColor
}
}
}
Loading