From c202c7989282e32b900d97266c0fdd89ad5432f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Fri, 2 Oct 2020 09:19:46 +0200 Subject: [PATCH 1/5] Fix deprecation warnings --- r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift | 4 ++-- r2-navigator-swift/PDF/PDFNavigatorViewController.swift | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift b/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift index 35189be7..8f592436 100644 --- a/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift +++ b/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift @@ -672,7 +672,7 @@ extension EPUBNavigatorViewController { /// This initializer is deprecated. /// `license` is not needed anymore. - @available(*, unavailable, renamed: "init(publication:license:initialLocation:resourcesServer:config:)") + @available(*, unavailable, renamed: "init(publication:initialLocation:resourcesServer:config:)") public convenience init(publication: Publication, license: DRMLicense?, initialLocation: Locator? = nil, resourcesServer: ResourcesServer, config: Configuration = .init()) { self.init(publication: publication, initialLocation: initialLocation, resourcesServer: resourcesServer, config: config) } @@ -681,7 +681,7 @@ extension EPUBNavigatorViewController { /// Replace `pageTransition` by the `animated` property of the `goTo` functions. /// Replace `disableDragAndDrop` by `EditingAction.copy`, since drag and drop is equivalent to copy. /// Replace `initialIndex` and `initialProgression` by `initialLocation`. - @available(*, deprecated, renamed: "init(publication:license:initialLocation:resourcesServer:config:)") + @available(*, deprecated, renamed: "init(publication:initialLocation:resourcesServer:config:)") public convenience init(for publication: Publication, license: DRMLicense? = nil, initialIndex: Int, initialProgression: Double?, pageTransition: PageTransition = .none, disableDragAndDrop: Bool = false, editingActions: [EditingAction] = EditingAction.defaultActions, contentInset: [UIUserInterfaceSizeClass: EPUBContentInsets]? = nil) { fatalError("This initializer is not available anymore.") } diff --git a/r2-navigator-swift/PDF/PDFNavigatorViewController.swift b/r2-navigator-swift/PDF/PDFNavigatorViewController.swift index e60a23d7..3e1fecb5 100644 --- a/r2-navigator-swift/PDF/PDFNavigatorViewController.swift +++ b/r2-navigator-swift/PDF/PDFNavigatorViewController.swift @@ -361,6 +361,7 @@ extension PDFNavigatorViewController { /// This initializer is deprecated. /// `license` is not needed anymore. + @available(*, deprecated, renamed: "init(publication:initialLocation:editingActions:)") public convenience init(publication: Publication, license: DRMLicense?, initialLocation: Locator? = nil, editingActions: [EditingAction] = EditingAction.defaultActions) { self.init(publication: publication, initialLocation: initialLocation, editingActions: editingActions) } From b3b3eacb529a83fb481c8cf7369449fe6a4b1f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Sat, 3 Oct 2020 18:59:56 +0200 Subject: [PATCH 2/5] Update to recommended settings and fix some deprecation notices --- r2-navigator-swift.xcodeproj/project.pbxproj | 4 +++- .../xcschemes/r2-navigator-swift.xcscheme | 24 ++++++++----------- .../EPUB/EPUBNavigatorViewController.swift | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/r2-navigator-swift.xcodeproj/project.pbxproj b/r2-navigator-swift.xcodeproj/project.pbxproj index 6ea10653..f1cc2f3b 100644 --- a/r2-navigator-swift.xcodeproj/project.pbxproj +++ b/r2-navigator-swift.xcodeproj/project.pbxproj @@ -259,7 +259,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1200; ORGANIZATIONNAME = Readium; TargetAttributes = { F3E7D3C21F4D83B000DF166D = { @@ -373,6 +373,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -438,6 +439,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; diff --git a/r2-navigator-swift.xcodeproj/xcshareddata/xcschemes/r2-navigator-swift.xcscheme b/r2-navigator-swift.xcodeproj/xcshareddata/xcschemes/r2-navigator-swift.xcscheme index 7bacb61f..f06fd66f 100644 --- a/r2-navigator-swift.xcodeproj/xcshareddata/xcschemes/r2-navigator-swift.xcscheme +++ b/r2-navigator-swift.xcodeproj/xcshareddata/xcschemes/r2-navigator-swift.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -39,17 +48,6 @@ - - - - - - - - Date: Sat, 3 Oct 2020 19:16:08 +0200 Subject: [PATCH 3/5] Deprecate PageTransition and old APIs --- .../EPUB/EPUBNavigatorViewController.swift | 10 +++++----- .../PDF/PDFNavigatorViewController.swift | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift b/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift index 7e5058e3..fad99e50 100644 --- a/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift +++ b/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift @@ -662,7 +662,7 @@ extension EPUBNavigatorViewController: PaginationViewDelegate { @available(*, deprecated, renamed: "EPUBNavigatorViewController") public typealias NavigatorViewController = EPUBNavigatorViewController -@available(*, deprecated, message: "Use the `animated` parameter of `goTo` functions instead") +@available(*, unavailable, message: "Use the `animated` parameter of `goTo` functions instead") public enum PageTransition { case none case animated @@ -672,7 +672,7 @@ extension EPUBNavigatorViewController { /// This initializer is deprecated. /// `license` is not needed anymore. - @available(*, deprecated, renamed: "init(publication:initialLocation:resourcesServer:config:)") + @available(*, unavailable, renamed: "init(publication:initialLocation:resourcesServer:config:)") public convenience init(publication: Publication, license: DRMLicense?, initialLocation: Locator? = nil, resourcesServer: ResourcesServer, config: Configuration = .init()) { self.init(publication: publication, initialLocation: initialLocation, resourcesServer: resourcesServer, config: config) } @@ -681,14 +681,14 @@ extension EPUBNavigatorViewController { /// Replace `pageTransition` by the `animated` property of the `goTo` functions. /// Replace `disableDragAndDrop` by `EditingAction.copy`, since drag and drop is equivalent to copy. /// Replace `initialIndex` and `initialProgression` by `initialLocation`. - @available(*, deprecated, renamed: "init(publication:initialLocation:resourcesServer:config:)") + @available(*, unavailable, renamed: "init(publication:initialLocation:resourcesServer:config:)") public convenience init(for publication: Publication, license: DRMLicense? = nil, initialIndex: Int, initialProgression: Double?, pageTransition: PageTransition = .none, disableDragAndDrop: Bool = false, editingActions: [EditingAction] = EditingAction.defaultActions, contentInset: [UIUserInterfaceSizeClass: EPUBContentInsets]? = nil) { fatalError("This initializer is not available anymore.") } /// This initializer is deprecated. /// Use the new Configuration object. - @available(*, deprecated, renamed: "init(publication:license:initialLocation:resourcesServer:config:)") + @available(*, unavailable, renamed: "init(publication:license:initialLocation:resourcesServer:config:)") public convenience init(publication: Publication, license: DRMLicense? = nil, initialLocation: Locator? = nil, editingActions: [EditingAction] = EditingAction.defaultActions, contentInset: [UIUserInterfaceSizeClass: EPUBContentInsets]? = nil, resourcesServer: ResourcesServer) { var config = Configuration() config.editingActions = editingActions @@ -698,7 +698,7 @@ extension EPUBNavigatorViewController { self.init(publication: publication, initialLocation: initialLocation, resourcesServer: resourcesServer, config: config) } - @available(*, deprecated, message: "Use the `animated` parameter of `goTo` functions instead") + @available(*, unavailable, message: "Use the `animated` parameter of `goTo` functions instead") public var pageTransition: PageTransition { get { return .none } set {} diff --git a/r2-navigator-swift/PDF/PDFNavigatorViewController.swift b/r2-navigator-swift/PDF/PDFNavigatorViewController.swift index 3e1fecb5..1274b2e1 100644 --- a/r2-navigator-swift/PDF/PDFNavigatorViewController.swift +++ b/r2-navigator-swift/PDF/PDFNavigatorViewController.swift @@ -361,7 +361,7 @@ extension PDFNavigatorViewController { /// This initializer is deprecated. /// `license` is not needed anymore. - @available(*, deprecated, renamed: "init(publication:initialLocation:editingActions:)") + @available(*, unavailable, renamed: "init(publication:initialLocation:editingActions:)") public convenience init(publication: Publication, license: DRMLicense?, initialLocation: Locator? = nil, editingActions: [EditingAction] = EditingAction.defaultActions) { self.init(publication: publication, initialLocation: initialLocation, editingActions: editingActions) } From 405dfcf539ab9bcabffe1438f9280553bf7166b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Wed, 21 Oct 2020 14:37:50 +0200 Subject: [PATCH 4/5] Forbid opening a publication in a restricted state with a navigator --- r2-navigator-swift/CBZ/CBZNavigatorViewController.swift | 2 ++ r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift | 2 ++ r2-navigator-swift/PDF/PDFNavigatorViewController.swift | 2 ++ 3 files changed, 6 insertions(+) diff --git a/r2-navigator-swift/CBZ/CBZNavigatorViewController.swift b/r2-navigator-swift/CBZ/CBZNavigatorViewController.swift index d55d28af..2adc3e86 100644 --- a/r2-navigator-swift/CBZ/CBZNavigatorViewController.swift +++ b/r2-navigator-swift/CBZ/CBZNavigatorViewController.swift @@ -27,6 +27,8 @@ open class CBZNavigatorViewController: UIViewController, VisualNavigator, Loggab private let pageViewController: UIPageViewController public init(publication: Publication, initialLocation: Locator? = nil) { + assert(!publication.isRestricted, "The provided publication is restricted. Check that any DRM was properly unlocked using a Content Protection.") + self.publication = publication self.initialIndex = { guard let initialLocation = initialLocation, let initialIndex = publication.readingOrder.firstIndex(withHREF: initialLocation.href) else { diff --git a/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift b/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift index fad99e50..02316b7c 100644 --- a/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift +++ b/r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift @@ -178,6 +178,8 @@ open class EPUBNavigatorViewController: UIViewController, VisualNavigator, Logga private let resourcesURL: URL? public init(publication: Publication, initialLocation: Locator? = nil, resourcesServer: ResourcesServer, config: Configuration = .init()) { + assert(!publication.isRestricted, "The provided publication is restricted. Check that any DRM was properly unlocked using a Content Protection.") + self.publication = publication self.editingActions = EditingActionsController(actions: config.editingActions, rights: publication.rights) self.userSettings = UserSettings() diff --git a/r2-navigator-swift/PDF/PDFNavigatorViewController.swift b/r2-navigator-swift/PDF/PDFNavigatorViewController.swift index 1274b2e1..7975894f 100644 --- a/r2-navigator-swift/PDF/PDFNavigatorViewController.swift +++ b/r2-navigator-swift/PDF/PDFNavigatorViewController.swift @@ -45,6 +45,8 @@ open class PDFNavigatorViewController: UIViewController, VisualNavigator, Loggab private var tapGestureController: PDFTapGestureController? public init(publication: Publication, initialLocation: Locator? = nil, editingActions: [EditingAction] = EditingAction.defaultActions) { + assert(!publication.isRestricted, "The provided publication is restricted. Check that any DRM was properly unlocked using a Content Protection.") + self.publication = publication self.initialLocation = initialLocation self.editingActions = EditingActionsController(actions: editingActions, rights: publication.rights) From bbeb1c39e2da770ea8d963d8ed02f9096bd266fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Thu, 22 Oct 2020 10:31:25 +0200 Subject: [PATCH 5/5] Update changelog --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acc3f5bb..e2532b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +* Support for the new `Publication` model using the [Content Protection](https://readium.org/architecture/proposals/006-content-protection) for DRM rights and the [Fetcher](https://readium.org/architecture/proposals/002-composite-fetcher-api) for resource access. + * This replaces the `Container` and `DRMLicense` objects which were needed by the navigator before. + +### Fixed + +* Layout of right-to–left EPUB. +* [Various EPUB navigation issues](https://github.com/readium/r2-navigator-swift/pull/142): + * Prevent breaking initial location when calling `updateUserSettings` too soon. + * Fix weird scrolling behavior when double tapping on the edges to turn pages. + * Don't send intermediate incorrect locators when loading a pending locator. +* Optimize positions calculation for LCP protected PDF. + ## [2.0.0-alpha.1] ### Added