Skip to content

Commit c2f1a19

Browse files
authored
Merge pull request #1471 from NYPL-Simplified/release/simplye/3.7.1
Merge SimplyE 3.7.1 release to master
2 parents f7ef3e3 + fe699ce commit c2f1a19

29 files changed

+373
-250
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "NYPLAEToolkit"]
1414
path = NYPLAEToolkit
1515
url = git@github.com:NYPL-Simplified/NYPLAEToolkit.git
16+
[submodule "CardCreator-iOS"]
17+
path = CardCreator-iOS
18+
url = https://github.com/NYPL-Simplified/CardCreator-iOS.git

CardCreator-iOS

Submodule CardCreator-iOS added at 1df9982

Cartfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json"
22
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
3-
github "NYPL-Simplified/CardCreator-iOS" "master"
43
github "NYPL-Simplified/NYPLAudiobookToolkit" "master"
54
github "NYPL-Simplified/PDFRendererProvider-iOS" "master"
65
github "NYPL-Simplified/audiobook-ios-overdrive" "master"

Cartfile.resolved

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" "8.3.0"
2-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json" "8.3.0"
3-
github "NYPL-Simplified/CardCreator-iOS" "da625611d48c15677996e3ca17e65f2590b2392e"
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" "8.5.0"
2+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json" "8.5.0"
43
github "NYPL-Simplified/NYPLAudiobookToolkit" "5d78bc5c6ca56d45c867a3e69fef35bc2ade7db2"
54
github "NYPL-Simplified/PDFRendererProvider-iOS" "8ef188721398304dd19b93f83194b7492a827c48"
65
github "NYPL-Simplified/audiobook-ios-overdrive" "f4416dbb4f59ead32a57c9bf409f0eb76488b82a"
76
github "PureLayout/PureLayout" "v3.1.9"
87
github "cezheng/Fuzi" "3.1.3"
98
github "dexman/Minizip" "1.4.0"
109
github "krzyzanowskim/CryptoSwift" "1.4.1"
11-
github "readium/GCDWebServer" "3.7.0"
12-
github "readium/r2-lcp-swift" "fc90d561ff2e2d7d90d8b2b13d988a615aa5e669"
13-
github "readium/r2-navigator-swift" "e469b7d635cd9e3885335adb9d546c028ee8f120"
14-
github "readium/r2-shared-swift" "b0f0c6b5b18161a587c8dcb10c1cdc2e6e4d4949"
15-
github "readium/r2-streamer-swift" "ae5cbaaed41fdba60c0758928d18a7ce386a4638"
10+
github "readium/GCDWebServer" "3.7.1"
11+
github "readium/r2-lcp-swift" "e92214773b09884fd068690658ed60c2af0f44aa"
12+
github "readium/r2-navigator-swift" "0a3e458dcbc8859f035443912fc01d8c1d739ec8"
13+
github "readium/r2-shared-swift" "7c66c3b7eb8711946b4fca4a1cce8f5ae0bc6bfe"
14+
github "readium/r2-streamer-swift" "85b6dc4af741be53f71c92ad0563875651115afc"
1615
github "scinfu/SwiftSoup" "2.3.2"
1716
github "stephencelis/SQLite.swift" "0.12.2"
1817
github "weichsel/ZIPFoundation" "0.9.11"

Simplified.xcodeproj/project.pbxproj

Lines changed: 135 additions & 36 deletions
Large diffs are not rendered by default.

Simplified.xcodeproj/xcshareddata/xcschemes/SimplyE.xcscheme

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@
8282
ReferencedContainer = "container:tenprintcover-ios/TenPrintCover.xcodeproj">
8383
</BuildableReference>
8484
</TestableReference>
85+
<TestableReference
86+
skipped = "NO">
87+
<BuildableReference
88+
BuildableIdentifier = "primary"
89+
BlueprintIdentifier = "73EEE7DE247F274E00A06D14"
90+
BuildableName = "NYPLCardCreatorTests.xctest"
91+
BlueprintName = "NYPLCardCreatorTests"
92+
ReferencedContainer = "container:CardCreator-iOS/NYPLCardCreator.xcodeproj">
93+
</BuildableReference>
94+
</TestableReference>
8595
</Testables>
8696
</TestAction>
8797
<LaunchAction

Simplified/AxisService/Read/NYPLAxisBookReadingAdapter.swift

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,28 @@ struct NYPLAxisBookReadingAdapter {
3131
self.downloader = downloader
3232
}
3333

34-
/// Downloads license file for the book associated with the given asset, validates it, extracts encrypted `AES` key, and decrypts it
35-
/// using our private key.
36-
///
37-
/// - Note:
38-
/// We need to download license every time the user attempts to open book for reading. Upon downloading
39-
/// the license, we validate it and extract the encrypted `AES` key for unlocking content. The key itself
40-
/// needs to be decrypted before it can be used.
34+
/// Given an asset on disk, obtains the R2 ProtectedAsset needed to open
35+
/// a book for reading.
4136
///
4237
/// - Parameters:
43-
/// - asset: File Asset (NYPLBook file)
44-
/// - completion: ProtectedAsset Tuple or `Publication.OpeningError`
45-
func handleAsset(asset: FileAsset,
46-
fetcher: Fetcher,
47-
completion: @escaping ProtectedAssetCompletion) {
38+
/// - asset: R2 book asset on disk associated to a NYPLBook
39+
/// - completion: Returns a R2 tuple containing the PublicationAsset and
40+
/// its Content Protection, or an error.
41+
func openAsset(_ asset: FileAsset,
42+
fetcher: Fetcher,
43+
completion: @escaping ProtectedAssetCompletion) {
4844

49-
let license = NYPLAxisLicenseService(
50-
axisItemDownloader: downloader, cypher: decryptor.cypher,
51-
errorLogger: NYPLAxisErrorLogsAdapter(), parentDirectory: asset.url)
45+
let licenseService = NYPLAxisLicenseService(axisItemDownloader: downloader,
46+
cypher: decryptor.cypher,
47+
errorLogger: NYPLAxisErrorLogsAdapter(),
48+
parentDirectory: asset.url)
5249

53-
license.extractAESKey { (result) in
50+
// we decrypt the encrypted key (used to unlock content) and use that
51+
// to get the ProtectedAsset
52+
licenseService.extractAESKey { result in
5453
switch result {
5554
case .success(let key):
56-
let protectedAsset = self.getProtecedAsset(
55+
let protectedAsset = self.getProtectedAsset(
5756
from: asset, key: key, fetcher: fetcher)
5857
completion(.success(protectedAsset))
5958
case .failure(let error):
@@ -64,12 +63,12 @@ struct NYPLAxisBookReadingAdapter {
6463

6564
/// Generates ProtectedAsset from given asset
6665
/// - Parameters:
67-
/// - asset: File Asset (NYPLBook file)
68-
/// - key: AES key provided by Axis to unlock book content
69-
/// - completion: ProtectedAsset Tuple or `Publication.OpeningError`
70-
private func getProtecedAsset(from asset: FileAsset,
71-
key: Data,
72-
fetcher: Fetcher) -> ProtectedAsset {
66+
/// - asset: R2 book asset on disk associated to a NYPLBook
67+
/// - key: Key provided by Axis to unlock book content
68+
/// - fetcher: R2 object used to fetch publication data
69+
private func getProtectedAsset(from asset: FileAsset,
70+
key: Data,
71+
fetcher: Fetcher) -> ProtectedAsset {
7372

7473
let transformingFetcher = TransformingFetcher(fetcher: fetcher) {
7574
return decryptor.decrypt(resource: $0, withKey: key)

Simplified/Book/UI/NYPLBookButtonsView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
@property (nonatomic, readonly) BOOL showReturnButtonIfApplicable;
3131

3232
- (void)configureForBookDetailsContext;
33+
- (void)setReadButtonAccessibilityLabelWithMessage:(NSString *) message;
3334

3435
@end

Simplified/Book/UI/NYPLBookButtonsView.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ - (void)updateButtons
207207
case NYPLBookContentTypeAudiobook:
208208
buttonInfo = @{ButtonKey: self.readButton,
209209
TitleKey: NSLocalizedString(@"Listen", nil),
210-
HintKey: [NSString stringWithFormat:NSLocalizedString(@"Opens audiobook %@ for listening", nil), self.book.title],
210+
HintKey: self.readButton.timeRemainingString ?: @"",
211211
AddIndicatorKey: @(YES)};
212212
break;
213213
case NYPLBookContentTypePDF:
214214
case NYPLBookContentTypeEPUB:
215215
buttonInfo = @{ButtonKey: self.readButton,
216216
TitleKey: NSLocalizedString(@"Read", nil),
217-
HintKey: [NSString stringWithFormat:NSLocalizedString(@"Opens %@ for reading", nil), self.book.title],
217+
HintKey: self.readButton.timeRemainingString ?: @"",
218218
AddIndicatorKey: @(YES)};
219219
break;
220220
case NYPLBookContentTypeUnsupported:
@@ -353,6 +353,10 @@ - (void)setState:(NYPLBookButtonsState const)state
353353
[self updateButtons];
354354
}
355355

356+
- (void)setReadButtonAccessibilityLabelWithMessage:(NSString *) message {
357+
self.readButton.accessibilityLabel = [NSString stringWithFormat:@"%@\n%@", message, NSLocalizedString(@"Read", nil)];
358+
}
359+
356360
#pragma mark - Button actions
357361

358362
- (void)didSelectReturn

Simplified/Book/UI/NYPLBookDetailNormalView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
+ (instancetype)new NS_UNAVAILABLE;
1010
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
1111

12+
- (NSString *)messageStringForNYPLBookButtonStateSuccessful;
13+
1214
@end

0 commit comments

Comments
 (0)