Skip to content
This repository was archived by the owner on Jul 29, 2022. It is now read-only.

Commit 986117e

Browse files
Merge pull request #88 from readium/develop
1.1.5
2 parents 5f613ec + a36ec63 commit 986117e

36 files changed

+905
-930
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @aferditamuriqi

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.31'
5-
ext.r2branch = 'develop'
4+
ext.kotlin_version = '1.3.61'
65

76
repositories {
87
google()
98
jcenter()
109
}
1110
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.4.1'
11+
classpath 'com.android.tools.build:gradle:3.5.3'
1312
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1413
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1514
// NOTE: Do not place your application dependencies here; they belong

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

r2-streamer/build.gradle

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,23 @@ apply plugin: 'com.github.dcendents.android-maven'
1414
group='com.github.readium'
1515

1616
android {
17-
flavorDimensions "testapp"
1817

19-
compileSdkVersion 28
18+
compileSdkVersion 29
2019
defaultConfig {
2120
minSdkVersion 21
22-
targetSdkVersion 28
21+
targetSdkVersion 29
2322
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2423
}
24+
compileOptions {
25+
sourceCompatibility 1.8
26+
targetCompatibility 1.8
27+
}
2528
buildTypes {
2629
release {
2730
minifyEnabled false
2831
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2932
}
3033
}
31-
productFlavors {
32-
intTestapp {
33-
dimension "testapp"
34-
}
35-
intTestappWithLcp {
36-
dimension "testapp"
37-
}
38-
devTestapp {
39-
dimension "testapp"
40-
}
41-
devTestappWithLcp {
42-
dimension "testapp"
43-
}
44-
}
45-
46-
// default build flavour
47-
defaultPublishConfig "intTestappDebug"
4834
}
4935

5036
dependencies {
@@ -54,7 +40,7 @@ dependencies {
5440
if (findProject(':r2-shared')) {
5541
implementation project(':r2-shared')
5642
} else {
57-
implementation "com.github.readium:r2-shared-kotlin:1.0.10"
43+
implementation "com.github.readium:r2-shared-kotlin:1.1.6"
5844
}
5945

6046
//TODO conflicting support libraries, excluding these
@@ -65,20 +51,27 @@ dependencies {
6551
implementation('com.mcxiaoke.koi:async:0.5.5') {
6652
exclude module: 'support-v4'
6753
}
68-
implementation "androidx.appcompat:appcompat:1.1.0-beta01"
69-
implementation 'org.nanohttpd:nanohttpd:2.3.2-SNAPSHOT'
70-
implementation 'org.nanohttpd:nanohttpd-nanolets:2.3.2-SNAPSHOT'
71-
implementation 'com.google.code.gson:gson:2.8.2'
54+
implementation "androidx.appcompat:appcompat:1.2.0-alpha01"
55+
56+
implementation ('com.github.edrlab.nanohttpd:nanohttpd:2.3.2') {
57+
exclude group: 'org.parboiled'
58+
}
59+
implementation ('com.github.edrlab.nanohttpd:nanohttpd-nanolets:2.3.2') {
60+
exclude group: 'org.parboiled'
61+
}
62+
63+
implementation 'com.google.code.gson:gson:2.8.5'
7264
implementation 'commons-io:commons-io:2.4'
73-
implementation 'org.zeroturnaround:zt-zip:1.12'
65+
implementation 'org.zeroturnaround:zt-zip:1.13'
7466
implementation 'joda-time:joda-time:2.9.9'
7567
implementation 'nl.komponents.kovenant:kovenant:3.3.0'
7668

7769
final JACKSON_VERSION = '2.8.6'
7870
implementation "com.fasterxml.jackson.core:jackson-core:$JACKSON_VERSION"
7971
implementation "com.fasterxml.jackson.core:jackson-annotations:$JACKSON_VERSION"
8072
implementation "com.fasterxml.jackson.core:jackson-databind:$JACKSON_VERSION"
81-
implementation 'org.jsoup:jsoup:1.11.2'
73+
//noinspection GradleDependency
74+
implementation 'org.jsoup:jsoup:1.10.3'
8275

8376
testImplementation 'junit:junit:4.12'
8477
androidTestImplementation 'androidx.test:runner:1.2.0'

r2-streamer/r2-streamer.iml

Lines changed: 0 additions & 266 deletions
This file was deleted.

r2-streamer/src/androidTest/AndroidManifest.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

r2-streamer/src/main/java/org/readium/r2/streamer/container/ZipArchiveContainer.kt renamed to r2-streamer/src/main/java/org/readium/r2/streamer/container/ArchiveContainer.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.readium.r2.streamer.container
1111

12+
import org.readium.r2.shared.RootFile
13+
import org.readium.r2.shared.drm.DRM
1214
import java.io.ByteArrayOutputStream
1315
import java.io.InputStream
1416
import java.net.URI
@@ -23,13 +25,15 @@ import java.util.zip.ZipFile
2325
*
2426
*/
2527

26-
interface ZipArchiveContainer : Container {
27-
var zipFile: ZipFile
2828

29-
override fun data(relativePath: String): ByteArray {
29+
open class ArchiveContainer(path: String, mimetype: String) : Container {
30+
override var rootFile: RootFile = RootFile(rootPath = path, mimetype = mimetype)
31+
override var drm: DRM? = null
32+
val archive: ZipFile = ZipFile(path)
3033

34+
override fun data(relativePath: String): ByteArray {
3135
val zipEntry = getEntry(relativePath)// ?: return ByteArray(0)
32-
val inputStream = zipFile.getInputStream(zipEntry)
36+
val inputStream = archive.getInputStream(zipEntry)
3337
val outputStream = ByteArrayOutputStream()
3438
var readLength = 0
3539
val buffer = ByteArray(16384)
@@ -39,29 +43,30 @@ interface ZipArchiveContainer : Container {
3943

4044
inputStream.close()
4145
return outputStream.toByteArray()
46+
4247
}
4348

4449
override fun dataLength(relativePath: String): Long {
45-
return zipFile.size().toLong()
50+
return archive.size().toLong()
4651
}
4752

4853
override fun dataInputStream(relativePath: String): InputStream {
49-
return zipFile.getInputStream(getEntry(relativePath))
54+
return archive.getInputStream(getEntry(relativePath))
5055
}
51-
52-
fun getEntry(relativePath: String): ZipEntry? {
56+
57+
private fun getEntry(relativePath: String): ZipEntry? {
5358

5459
val path: String = try {
5560
URI(relativePath).path
5661
} catch (e: Exception) {
5762
relativePath
5863
}
5964

60-
var zipEntry = zipFile.getEntry(path)
65+
var zipEntry = archive.getEntry(path)
6166
if (zipEntry != null)
6267
return zipEntry
6368

64-
val zipEntries = zipFile.entries()
69+
val zipEntries = archive.entries()
6570
while (zipEntries.hasMoreElements()) {
6671
zipEntry = zipEntries.nextElement()
6772
if (path.equals(zipEntry.name, true))

r2-streamer/src/main/java/org/readium/r2/streamer/container/Container.kt

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,63 +9,39 @@
99

1010
package org.readium.r2.streamer.container
1111

12-
import org.readium.r2.shared.Link
1312
import org.readium.r2.shared.RootFile
1413
import org.readium.r2.shared.drm.DRM
15-
import org.readium.r2.shared.parser.xml.XmlParser
1614
import java.io.InputStream
1715

1816
/**
1917
* Container of a publication
2018
*
21-
* @var rootfile : a RootFile class containing the path the publication, the version
19+
* @var rootFile : a RootFile class containing the path the publication, the version
2220
* and the mime type of it
2321
*
2422
* @var drm : contain the brand, scheme, profile and license of DRM if it exist
25-
*
26-
* @var successCreated : used to checked if the Container contains a publication
27-
*
23+
**
2824
* @func data : return the ByteArray content of a file from the publication
2925
*
3026
* @func dataLength : return the length of content
3127
*
3228
* @func dataInputStream : return the InputStream of content
3329
*/
34-
interface Container {
3530

31+
interface Container {
3632
var rootFile: RootFile
37-
3833
var drm: DRM?
39-
40-
var successCreated: Boolean
41-
4234
fun data(relativePath: String): ByteArray
43-
4435
fun dataLength(relativePath: String): Long
45-
4636
fun dataInputStream(relativePath: String): InputStream
4737
}
4838

49-
/**
50-
* EpubContainer
51-
*
52-
* @func xmlDocumentForFile : return the XmlParser of a file
53-
*
54-
* @func xmlDocumentForResource : return the XmlParser of a link
55-
*/
56-
interface EpubContainer : Container {
57-
58-
fun xmlDocumentForFile(relativePath: String): XmlParser
59-
fun xmlDocumentForResource(link: Link?): XmlParser
60-
fun xmlAsByteArray(link: Link?): ByteArray
61-
fun scanForDrm(): DRM?
39+
sealed class ContainerError : Exception() {
40+
object streamInitFailed : ContainerError()
41+
object fileNotFound : ContainerError()
42+
object fileError : ContainerError()
43+
data class missingFile(val path: String) : ContainerError()
44+
data class xmlParse(val underlyingError: Error) : ContainerError()
45+
data class missingLink(val title: String?) : ContainerError()
6246
}
6347

64-
/**
65-
* CbzContainer
66-
*
67-
* @func getFilesList : return the list of every files in a CBZ
68-
*/
69-
interface CbzContainer : Container {
70-
fun getFilesList(): List<String>
71-
}

r2-streamer/src/main/java/org/readium/r2/streamer/container/ContainerCbz.kt

Lines changed: 0 additions & 43 deletions
This file was deleted.

r2-streamer/src/main/java/org/readium/r2/streamer/container/ContainerEpub.kt

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)