Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-240 Integrate R2 changes for having publisher's defaults disabled #1449

Merged
merged 2 commits into from
Jul 19, 2021
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
10 changes: 5 additions & 5 deletions Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ github "NYPL-Simplified/NYPLAudiobookToolkit" "master"
github "NYPL-Simplified/PDFRendererProvider-iOS" "master"
github "NYPL-Simplified/audiobook-ios-overdrive" "master"
github "PureLayout/PureLayout" ~> 3.1.2
github "stephencelis/SQLite.swift" == 0.12.2
github "stephencelis/SQLite.swift" ~> 0.12.2
github "zxingify/zxingify-objc" ~> 3.6
github "readium/r2-lcp-swift" == 2.0.0
github "readium/r2-shared-swift" == 2.0.1
github "readium/r2-streamer-swift" == 2.0.0
github "readium/r2-navigator-swift" == 2.0.0
github "readium/r2-lcp-swift" "develop"
github "readium/r2-shared-swift" "develop"
github "readium/r2-streamer-swift" "develop"
github "readium/r2-navigator-swift" "develop"
18 changes: 9 additions & 9 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" "8.0.0"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json" "8.0.0"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" "8.3.0"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json" "8.3.0"
github "NYPL-Simplified/CardCreator-iOS" "da625611d48c15677996e3ca17e65f2590b2392e"
github "NYPL-Simplified/NYPLAudiobookToolkit" "5d78bc5c6ca56d45c867a3e69fef35bc2ade7db2"
github "NYPL-Simplified/PDFRendererProvider-iOS" "8ef188721398304dd19b93f83194b7492a827c48"
github "NYPL-Simplified/audiobook-ios-overdrive" "f4416dbb4f59ead32a57c9bf409f0eb76488b82a"
github "PureLayout/PureLayout" "3.1.9"
github "PureLayout/PureLayout" "v3.1.9"
github "cezheng/Fuzi" "3.1.3"
github "dexman/Minizip" "1.4.0"
github "edrlab/GCDWebServer" "3.6.3"
github "krzyzanowskim/CryptoSwift" "1.3.8"
github "readium/r2-lcp-swift" "2.0.0"
github "readium/r2-navigator-swift" "2.0.0"
github "readium/r2-shared-swift" "2.0.1"
github "readium/r2-streamer-swift" "2.0.0"
github "krzyzanowskim/CryptoSwift" "1.4.1"
github "readium/GCDWebServer" "3.7.0"
github "readium/r2-lcp-swift" "fc90d561ff2e2d7d90d8b2b13d988a615aa5e669"
github "readium/r2-navigator-swift" "e469b7d635cd9e3885335adb9d546c028ee8f120"
github "readium/r2-shared-swift" "b0f0c6b5b18161a587c8dcb10c1cdc2e6e4d4949"
github "readium/r2-streamer-swift" "ae5cbaaed41fdba60c0758928d18a7ce386a4638"
github "scinfu/SwiftSoup" "2.3.2"
github "stephencelis/SQLite.swift" "0.12.2"
github "weichsel/ZIPFoundation" "0.9.11"
Expand Down
12 changes: 6 additions & 6 deletions Simplified.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5288,7 +5288,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -5347,7 +5347,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -5406,7 +5406,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -5461,7 +5461,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -5753,7 +5753,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -5810,7 +5810,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
22 changes: 0 additions & 22 deletions Simplified/Reader2/BusinessLogic/NYPLR1R2UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class NYPLR1R2UserSettings: NSObject {
self.r2UserSettings = r2UserSettings
super.init()
configR2Fonts()

// this helps with layout on small screens especially when publisher's
// defaults are off.
setHyphenation(true)
}

/// Get associated colors for a specific appearance setting.
Expand Down Expand Up @@ -206,22 +202,4 @@ class NYPLR1R2UserSettings: NSObject {
reference: ReadiumCSSReference.fontFamily.rawValue,
name: ReadiumCSSName.fontFamily.rawValue)
}

private func setHyphenation(_ value: Bool) {
let hyphens = r2UserSettings?.userProperties
.getProperty(reference: ReadiumCSSReference.hyphens.rawValue) as? Switchable
hyphens?.on = value
}
}

// MARK: -

public extension UserProperties {
/// Removes a property matching a CSS reference.
/// - Parameter ref: The CSS reference of the property to be removed.
func removeProperty(forReference ref: ReadiumCSSReference) {
properties.removeAll {
$0.reference == ref.rawValue
}
}
}
21 changes: 14 additions & 7 deletions Simplified/Reader2/UI/NYPLEPUBViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ class NYPLEPUBViewController: NYPLBaseReaderViewController {
initialLocation: Locator?,
resourcesServer: ResourcesServer) {

// this config was suggested by R2 engineers as a way to limit the possible
// race conditions between restoring the initial location without
// interfering with the web view layout timing
// - hyphens = true helps with layout on small screens especially when
// publisher's defaults are off.
// - publisher's defaults = false ensures that font size is changeable
// even for EPUBs that specify a `fontSize: small` value in their CSS.
let settings = UserSettings(hyphens: true, publisherDefaults: false)

// the "preload" settings were suggested by R2 engineers as a way to limit
// the possible race conditions between restoring the initial location
// without interfering with the web view layout timing
// See: https://github.com/readium/r2-navigator-swift/issues/153
var config = EPUBNavigatorViewController.Configuration()
config.preloadPreviousPositionCount = 0
config.preloadNextPositionCount = 0
config.debugState = true
let config = EPUBNavigatorViewController.Configuration(
userSettings: settings,
preloadPreviousPositionCount: 0,
preloadNextPositionCount: 0,
debugState: true)

let navigator = EPUBNavigatorViewController(publication: publication,
initialLocation: initialLocation,
Expand Down