diff --git a/docs/migration-guide.md b/docs/migration-guide.md index b2f0e82900..ffca599f4f 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -93,6 +93,13 @@ for an example. To avoid conflicts when merging your app resources, all resources declared in the Readium toolkit now have the prefix `readium_`. This means that you must rename any layouts or strings you have overridden. Here is a comprehensive list of the changes. +### Pdfium and PSPDFKit adapters' namespaces slightly changed + +`org.readium.adapters.pspdfkit.document` moved to `org.readium.adapter.pdspdfKit.document` +`org.readium.adapters.pspdfkit.navigator` moved to `org.readium.adapter.pdspdfKit.navigator` +`org.readium.adapters.pdfium.document` moved to `org.readium.adapter.pdfium.document` +`org.readium.adapters.pdfium.navigator` moved to `org.readium.adapter.pdfium.navigator` + #### Layouts | Deprecated | New | diff --git a/readium/adapters/exoplayer/build.gradle.kts b/readium/adapters/exoplayer/build.gradle.kts new file mode 100644 index 0000000000..984679a172 --- /dev/null +++ b/readium/adapters/exoplayer/build.gradle.kts @@ -0,0 +1,66 @@ +/* + * Copyright 2022 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +plugins { + id("com.android.library") + kotlin("android") + kotlin("plugin.parcelize") + kotlin("plugin.serialization") +} + +android { + resourcePrefix = "readium_" + + compileSdk = 34 + + defaultConfig { + minSdk = 21 + targetSdk = 34 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=org.readium.r2.shared.InternalReadiumApi" + ) + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt")) + } + } + buildFeatures { + viewBinding = true + } + namespace = "org.readium.adapter.exoplayer" +} + +kotlin { + explicitApi() +} + +rootProject.ext["publish.artifactId"] = "readium-navigator-exoplayer" +apply(from = "$rootDir/scripts/publish-module.gradle") + +dependencies { + api(project(":readium:readium-shared")) + api(project(":readium:navigators:media:readium-navigator-media-audio")) + + implementation(libs.androidx.media3.common) + implementation(libs.androidx.media3.exoplayer) + implementation(libs.timber) + implementation(libs.bundles.coroutines) + implementation(libs.kotlinx.serialization.json) + + // Tests + testImplementation(libs.junit) +} diff --git a/readium/adapters/exoplayer/src/main/AndroidManifest.xml b/readium/adapters/exoplayer/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..2d10029868 --- /dev/null +++ b/readium/adapters/exoplayer/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoAudiobookPlayer.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoAudiobookPlayer.kt similarity index 94% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoAudiobookPlayer.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoAudiobookPlayer.kt index 0c8b874ae1..92cd9735ac 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoAudiobookPlayer.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoAudiobookPlayer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import androidx.media3.common.ForwardingPlayer import androidx.media3.exoplayer.ExoPlaybackException @@ -12,7 +12,6 @@ import androidx.media3.exoplayer.ExoPlayer import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.ExperimentalTime -import org.readium.r2.navigator.media3.audio.SmartSeeker import timber.log.Timber /** diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerAliases.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerAliases.kt similarity index 75% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerAliases.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerAliases.kt index 591ca73642..2a09db751a 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerAliases.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerAliases.kt @@ -4,10 +4,10 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer -import org.readium.r2.navigator.media3.audio.AudioNavigator -import org.readium.r2.navigator.media3.audio.AudioNavigatorFactory +import org.readium.navigator.media.audio.AudioNavigator +import org.readium.navigator.media.audio.AudioNavigatorFactory import org.readium.r2.shared.ExperimentalReadiumApi @OptIn(ExperimentalReadiumApi::class) diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerDataSource.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerDataSource.kt similarity index 97% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerDataSource.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerDataSource.kt index 9622b69cbd..bcd3e2bc49 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerDataSource.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerDataSource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import android.net.Uri import androidx.media3.common.C.LENGTH_UNSET @@ -16,9 +16,9 @@ import androidx.media3.datasource.TransferListener import java.io.IOException import kotlinx.coroutines.runBlocking import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.buffered import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.buffered import org.readium.r2.shared.util.toUrl public sealed class ExoPlayerDataSourceException(message: String, cause: Throwable?) : IOException( diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerDefaults.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerDefaults.kt similarity index 93% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerDefaults.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerDefaults.kt index b987c214c9..444636dd78 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerDefaults.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerDefaults.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerEngine.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerEngine.kt similarity index 97% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerEngine.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerEngine.kt index abb2aace60..8c5f0907fe 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerEngine.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerEngine.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import android.app.Application import androidx.media3.common.* @@ -19,12 +19,12 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import org.readium.r2.navigator.media3.audio.AudioEngine +import org.readium.navigator.media.audio.AudioEngine import org.readium.r2.shared.ExperimentalReadiumApi -import org.readium.r2.shared.units.Hz -import org.readium.r2.shared.units.hz import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.toUri +import org.readium.r2.shared.util.units.Hz +import org.readium.r2.shared.util.units.hz /** * An [AudioEngine] based on Media3 ExoPlayer. diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerEngineProvider.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerEngineProvider.kt similarity index 92% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerEngineProvider.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerEngineProvider.kt index 821eb2d2e4..e73753bc50 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerEngineProvider.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerEngineProvider.kt @@ -4,16 +4,16 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import android.app.Application import androidx.media3.datasource.DataSource import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +import org.readium.navigator.media.audio.AudioEngineProvider +import org.readium.navigator.media.common.DefaultMediaMetadataProvider +import org.readium.navigator.media.common.MediaMetadataProvider import org.readium.r2.navigator.extensions.time -import org.readium.r2.navigator.media3.api.DefaultMediaMetadataProvider -import org.readium.r2.navigator.media3.api.MediaMetadataProvider -import org.readium.r2.navigator.media3.audio.AudioEngineProvider import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferences.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferences.kt similarity index 94% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferences.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferences.kt index e8b59e229d..8a0db3323c 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferences.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferences.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferencesEditor.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferencesEditor.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferencesEditor.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferencesEditor.kt index 5a95dce985..d1bad79f9e 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferencesEditor.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferencesEditor.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import org.readium.r2.navigator.extensions.format import org.readium.r2.navigator.preferences.DoubleIncrement diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferencesSerializer.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferencesSerializer.kt similarity index 94% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferencesSerializer.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferencesSerializer.kt index f4a46e0f96..ef6a33f2f3 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerPreferencesSerializer.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerPreferencesSerializer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import kotlinx.serialization.json.Json import org.readium.r2.navigator.preferences.PreferencesSerializer diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerSettings.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerSettings.kt similarity index 91% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerSettings.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerSettings.kt index ff57ca358b..9fac074e79 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerSettings.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerSettings.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerSettingsResolver.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerSettingsResolver.kt similarity index 92% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerSettingsResolver.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerSettingsResolver.kt index 7165ee3bda..8de9ff5ff3 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/exoplayer/ExoPlayerSettingsResolver.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/ExoPlayerSettingsResolver.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.exoplayer +package org.readium.adapter.exoplayer import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/SmartSeeker.kt b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/SmartSeeker.kt similarity index 97% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/SmartSeeker.kt rename to readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/SmartSeeker.kt index a5890565b3..0388f82da6 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/SmartSeeker.kt +++ b/readium/adapters/exoplayer/src/main/java/org/readium/adapter/exoplayer/SmartSeeker.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.audio +package org.readium.adapter.exoplayer import kotlin.time.Duration import kotlin.time.ExperimentalTime diff --git a/readium/navigator/src/test/java/org/readium/r2/navigator/audio/SmartSeekerTest.kt b/readium/adapters/exoplayer/src/test/java/org/readium/adapter/exoplayer/SmartSeekerTest.kt similarity index 96% rename from readium/navigator/src/test/java/org/readium/r2/navigator/audio/SmartSeekerTest.kt rename to readium/adapters/exoplayer/src/test/java/org/readium/adapter/exoplayer/SmartSeekerTest.kt index 461337c250..089f798aec 100644 --- a/readium/navigator/src/test/java/org/readium/r2/navigator/audio/SmartSeekerTest.kt +++ b/readium/adapters/exoplayer/src/test/java/org/readium/adapter/exoplayer/SmartSeekerTest.kt @@ -1,11 +1,10 @@ -package org.readium.r2.navigator.audio +package org.readium.adapter.exoplayer import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.ExperimentalTime import org.junit.Assert.assertEquals import org.junit.Test -import org.readium.r2.navigator.media3.audio.SmartSeeker @OptIn(ExperimentalTime::class) class SmartSeekerTest { diff --git a/readium/adapters/pdfium/build.gradle.kts b/readium/adapters/pdfium/build.gradle.kts index 6e7c498957..de6e0c5a4e 100644 --- a/readium/adapters/pdfium/build.gradle.kts +++ b/readium/adapters/pdfium/build.gradle.kts @@ -37,7 +37,7 @@ android { proguardFiles(getDefaultProguardFile("proguard-android.txt")) } } - namespace = "org.readium.adapters.pdfium" + namespace = "org.readium.adapter.pdfium" } kotlin { diff --git a/readium/adapters/pdfium/pdfium-document/build.gradle.kts b/readium/adapters/pdfium/pdfium-document/build.gradle.kts index ff8352bb68..c18cdbde30 100644 --- a/readium/adapters/pdfium/pdfium-document/build.gradle.kts +++ b/readium/adapters/pdfium/pdfium-document/build.gradle.kts @@ -40,7 +40,7 @@ android { buildFeatures { viewBinding = true } - namespace = "org.readium.adapters.pdfium.document" + namespace = "org.readium.adapter.pdfium.document" } kotlin { diff --git a/readium/adapters/pdfium/pdfium-document/src/main/java/org/readium/adapters/pdfium/document/PdfiumDocument.kt b/readium/adapters/pdfium/pdfium-document/src/main/java/org/readium/adapter/pdfium/document/PdfiumDocument.kt similarity index 95% rename from readium/adapters/pdfium/pdfium-document/src/main/java/org/readium/adapters/pdfium/document/PdfiumDocument.kt rename to readium/adapters/pdfium/pdfium-document/src/main/java/org/readium/adapter/pdfium/document/PdfiumDocument.kt index 2474a98deb..9f5bd517cf 100644 --- a/readium/adapters/pdfium/pdfium-document/src/main/java/org/readium/adapters/pdfium/document/PdfiumDocument.kt +++ b/readium/adapters/pdfium/pdfium-document/src/main/java/org/readium/adapter/pdfium/document/PdfiumDocument.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.document +package org.readium.adapter.pdfium.document import android.content.Context import android.graphics.Bitmap @@ -18,12 +18,12 @@ import kotlinx.coroutines.withContext import org.readium.r2.shared.InternalReadiumApi import org.readium.r2.shared.extensions.md5 import org.readium.r2.shared.extensions.tryOrNull -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.mapCatching import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.pdf.PdfDocument import org.readium.r2.shared.util.pdf.PdfDocumentFactory +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.mapCatching import org.readium.r2.shared.util.use import timber.log.Timber diff --git a/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts b/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts index 2a99bc1cb1..7afc1d3620 100644 --- a/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts +++ b/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts @@ -41,7 +41,7 @@ android { buildFeatures { viewBinding = true } - namespace = "org.readium.adapters.pdfium.navigator" + namespace = "org.readium.adapter.pdfium.navigator" } kotlin { diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumDefaults.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumDefaults.kt similarity index 93% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumDefaults.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumDefaults.kt index ef02ddd5f3..024509cf3b 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumDefaults.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumDefaults.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import org.readium.r2.navigator.preferences.ReadingProgression import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumDocumentFragment.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumDocumentFragment.kt similarity index 97% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumDocumentFragment.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumDocumentFragment.kt index 2052830ae0..9e8180272b 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumDocumentFragment.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumDocumentFragment.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import android.graphics.PointF import android.os.Bundle @@ -17,17 +17,17 @@ import kotlin.math.roundToInt import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import org.readium.adapters.pdfium.document.PdfiumDocumentFactory +import org.readium.adapter.pdfium.document.PdfiumDocumentFactory import org.readium.r2.navigator.pdf.PdfDocumentFragment import org.readium.r2.navigator.preferences.Axis import org.readium.r2.navigator.preferences.Fit import org.readium.r2.navigator.preferences.ReadingProgression import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.SingleJob import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrElse +import org.readium.r2.shared.util.resource.Resource import timber.log.Timber @ExperimentalReadiumApi diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumEngineProvider.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumEngineProvider.kt similarity index 97% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumEngineProvider.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumEngineProvider.kt index b3e85ec8f1..121008c166 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumEngineProvider.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumEngineProvider.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import android.graphics.PointF import com.github.barteksc.pdfviewer.PDFView @@ -18,8 +18,8 @@ import org.readium.r2.navigator.util.createFragmentFactory import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Metadata import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource /** * Main component to use the PDF navigator with the PDFium adapter. diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumNavigator.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumNavigator.kt similarity index 93% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumNavigator.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumNavigator.kt index 436d7767c7..2086be435c 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumNavigator.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import org.readium.r2.navigator.pdf.PdfNavigatorFactory import org.readium.r2.navigator.pdf.PdfNavigatorFragment diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferences.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferences.kt similarity index 97% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferences.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferences.kt index f1bf321eff..076ab3c43d 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferences.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferences.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import kotlinx.serialization.Serializable import org.readium.r2.navigator.preferences.Axis diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesEditor.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesEditor.kt similarity index 98% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesEditor.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesEditor.kt index 39cdd61240..fefd7eeedd 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesEditor.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesEditor.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import org.readium.r2.navigator.extensions.format import org.readium.r2.navigator.preferences.* diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesFilters.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesFilters.kt similarity index 95% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesFilters.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesFilters.kt index c106dec929..e1898d4967 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesFilters.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesFilters.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import org.readium.r2.navigator.preferences.PreferencesFilter import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesSerializer.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesSerializer.kt similarity index 94% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesSerializer.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesSerializer.kt index b0c3c595aa..f944732e17 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumPreferencesSerializer.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumPreferencesSerializer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import kotlinx.serialization.json.Json import org.readium.r2.navigator.preferences.PreferencesSerializer diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumSettings.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumSettings.kt similarity index 92% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumSettings.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumSettings.kt index 2d4b0bce04..0c8a56af5d 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumSettings.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumSettings.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import org.readium.r2.navigator.preferences.* import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumSettingsResolver.kt b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumSettingsResolver.kt similarity index 97% rename from readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumSettingsResolver.kt rename to readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumSettingsResolver.kt index 376ae3004e..366f21289f 100644 --- a/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapters/pdfium/navigator/PdfiumSettingsResolver.kt +++ b/readium/adapters/pdfium/pdfium-navigator/src/main/java/org/readium/adapter/pdfium/navigator/PdfiumSettingsResolver.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pdfium.navigator +package org.readium.adapter.pdfium.navigator import org.readium.r2.navigator.preferences.Axis import org.readium.r2.navigator.preferences.Fit diff --git a/readium/adapters/pspdfkit/build.gradle.kts b/readium/adapters/pspdfkit/build.gradle.kts index bec4a57193..30ba3d3e8b 100644 --- a/readium/adapters/pspdfkit/build.gradle.kts +++ b/readium/adapters/pspdfkit/build.gradle.kts @@ -37,7 +37,7 @@ android { proguardFiles(getDefaultProguardFile("proguard-android.txt")) } } - namespace = "org.readium.adapters.pspdfkit" + namespace = "org.readium.adapter.pspdfkit" } kotlin { diff --git a/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts b/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts index 8ecbe21d7a..84322e6426 100644 --- a/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts +++ b/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts @@ -40,7 +40,7 @@ android { buildFeatures { viewBinding = true } - namespace = "org.readium.adapters.pspdfkit.document" + namespace = "org.readium.adapter.pspdfkit.document" } kotlin { diff --git a/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapters/pspdfkit/document/PsPdfKitDocument.kt b/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapter/pspdfkit/document/PsPdfKitDocument.kt similarity index 96% rename from readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapters/pspdfkit/document/PsPdfKitDocument.kt rename to readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapter/pspdfkit/document/PsPdfKitDocument.kt index 80f7a2d4d4..c59201e3e8 100644 --- a/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapters/pspdfkit/document/PsPdfKitDocument.kt +++ b/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapter/pspdfkit/document/PsPdfKitDocument.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.document +package org.readium.adapter.pspdfkit.document import android.content.Context import android.graphics.Bitmap @@ -20,11 +20,11 @@ import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.readium.r2.shared.publication.ReadingProgression -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.pdf.PdfDocument import org.readium.r2.shared.util.pdf.PdfDocumentFactory +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry import timber.log.Timber public class PsPdfKitDocumentFactory(context: Context) : PdfDocumentFactory { diff --git a/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapters/pspdfkit/document/ResourceDataProvider.kt b/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapter/pspdfkit/document/ResourceDataProvider.kt similarity index 91% rename from readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapters/pspdfkit/document/ResourceDataProvider.kt rename to readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapter/pspdfkit/document/ResourceDataProvider.kt index 679b811d7d..08b6a22391 100644 --- a/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapters/pspdfkit/document/ResourceDataProvider.kt +++ b/readium/adapters/pspdfkit/pspdfkit-document/src/main/java/org/readium/adapter/pspdfkit/document/ResourceDataProvider.kt @@ -4,15 +4,15 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.document +package org.readium.adapter.pspdfkit.document import com.pspdfkit.document.providers.DataProvider import java.util.* import kotlinx.coroutines.runBlocking -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.synchronized import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.isLazyInitialized +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.synchronized import timber.log.Timber internal class ResourceDataProvider( diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts b/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts index b399ff46bd..98e163027d 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts @@ -41,7 +41,7 @@ android { buildFeatures { viewBinding = true } - namespace = "org.readium.adapters.pspdfkit.navigator" + namespace = "org.readium.adapter.pspdfkit.navigator" } kotlin { diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitDefaults.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitDefaults.kt similarity index 94% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitDefaults.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitDefaults.kt index 6365138cf2..2f1cc0730c 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitDefaults.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitDefaults.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import org.readium.r2.navigator.preferences.ReadingProgression import org.readium.r2.navigator.preferences.Spread diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitDocumentFragment.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitDocumentFragment.kt similarity index 97% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitDocumentFragment.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitDocumentFragment.kt index 3a78ed0b7d..2b36287cab 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitDocumentFragment.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitDocumentFragment.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import android.graphics.PointF import android.os.Bundle @@ -42,8 +42,8 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.readium.adapters.pspdfkit.document.PsPdfKitDocument -import org.readium.adapters.pspdfkit.document.PsPdfKitDocumentFactory +import org.readium.adapter.pspdfkit.document.PsPdfKitDocument +import org.readium.adapter.pspdfkit.document.PsPdfKitDocumentFactory import org.readium.r2.navigator.pdf.PdfDocumentFragment import org.readium.r2.navigator.preferences.Axis import org.readium.r2.navigator.preferences.Fit @@ -53,10 +53,10 @@ import org.readium.r2.navigator.util.createViewModelFactory import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.services.isProtected -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.pdf.cachedIn +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry @ExperimentalReadiumApi public class PsPdfKitDocumentFragment internal constructor( diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitEngineProvider.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitEngineProvider.kt similarity index 97% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitEngineProvider.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitEngineProvider.kt index e094987276..d8698e4c07 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitEngineProvider.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitEngineProvider.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import android.graphics.PointF import com.pspdfkit.configuration.PdfConfiguration @@ -19,8 +19,8 @@ import org.readium.r2.navigator.util.createFragmentFactory import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Metadata import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource /** * Main component to use the PDF navigator with PSPDFKit. diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitNavigator.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitNavigator.kt similarity index 93% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitNavigator.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitNavigator.kt index 2ae95414f3..fe5b6760ba 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitNavigator.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import org.readium.r2.navigator.pdf.PdfNavigatorFactory import org.readium.r2.navigator.pdf.PdfNavigatorFragment diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferences.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferences.kt similarity index 97% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferences.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferences.kt index 3a793387c0..bf7b19440a 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferences.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferences.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import kotlinx.serialization.Serializable import org.readium.r2.navigator.preferences.* diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesEditor.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesEditor.kt similarity index 99% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesEditor.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesEditor.kt index c56496670b..3b1e5842a5 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesEditor.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesEditor.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import org.readium.r2.navigator.extensions.format import org.readium.r2.navigator.preferences.Axis diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesFilters.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesFilters.kt similarity index 96% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesFilters.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesFilters.kt index 6037094664..368b3e23b9 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesFilters.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesFilters.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import org.readium.r2.navigator.preferences.PreferencesFilter import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesSerializer.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesSerializer.kt similarity index 94% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesSerializer.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesSerializer.kt index e6f99faf3c..7348fc655f 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitPreferencesSerializer.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitPreferencesSerializer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import kotlinx.serialization.json.Json import org.readium.r2.navigator.preferences.PreferencesSerializer diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitSettings.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitSettings.kt similarity index 93% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitSettings.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitSettings.kt index c2af317607..e43867feab 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitSettings.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitSettings.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import org.readium.r2.navigator.preferences.* import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitSettingsResolver.kt b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitSettingsResolver.kt similarity index 98% rename from readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitSettingsResolver.kt rename to readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitSettingsResolver.kt index 7e8a80bd50..cfa7e01102 100644 --- a/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapters/pspdfkit/navigator/PsPdfKitSettingsResolver.kt +++ b/readium/adapters/pspdfkit/pspdfkit-navigator/src/main/java/org/readium/adapter/pspdfkit/navigator/PsPdfKitSettingsResolver.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.adapters.pspdfkit.navigator +package org.readium.adapter.pspdfkit.navigator import org.readium.r2.navigator.preferences.Axis import org.readium.r2.navigator.preferences.Fit diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpContentProtection.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpContentProtection.kt index 0498f62511..e62fed24dc 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpContentProtection.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpContentProtection.kt @@ -8,21 +8,21 @@ package org.readium.r2.lcp import org.readium.r2.lcp.auth.LcpPassphraseAuthentication import org.readium.r2.lcp.license.model.LicenseDocument -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.asset.AssetRetriever -import org.readium.r2.shared.asset.AssetType import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.encryption.encryption import org.readium.r2.shared.publication.flatten import org.readium.r2.shared.publication.protection.ContentProtection import org.readium.r2.shared.publication.services.contentProtectionServiceFactory -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.TransformingContainer import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.ThrowableError import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.asset.Asset +import org.readium.r2.shared.util.asset.AssetRetriever +import org.readium.r2.shared.util.asset.AssetType import org.readium.r2.shared.util.flatMap import org.readium.r2.shared.util.getOrElse +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.TransformingContainer internal class LcpContentProtection( private val lcpService: LcpService, diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptor.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptor.kt index ed198891bc..0193a34a09 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptor.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptor.kt @@ -14,19 +14,19 @@ import org.readium.r2.shared.extensions.coerceFirstNonNegative import org.readium.r2.shared.extensions.inflate import org.readium.r2.shared.extensions.requireLengthFitInt import org.readium.r2.shared.publication.encryption.Encryption -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.FailureResource -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.TransformingResource -import org.readium.r2.shared.resource.flatMap -import org.readium.r2.shared.resource.flatMapCatching -import org.readium.r2.shared.resource.mapCatching import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.FailureResource +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.TransformingResource +import org.readium.r2.shared.util.resource.flatMap +import org.readium.r2.shared.util.resource.flatMapCatching +import org.readium.r2.shared.util.resource.mapCatching /** * Decrypts a resource protected with LCP. diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptorTest.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptorTest.kt index 667ace86fc..28da6ca47e 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptorTest.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpDecryptorTest.kt @@ -12,10 +12,10 @@ package org.readium.r2.lcp import kotlin.math.ceil import org.readium.r2.shared.extensions.coerceIn import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.mapCatching import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.mapCatching import org.readium.r2.shared.util.use import timber.log.Timber diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpService.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpService.kt index ca9be6fe46..652b493063 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/LcpService.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/LcpService.kt @@ -26,10 +26,10 @@ import org.readium.r2.lcp.service.LicensesService import org.readium.r2.lcp.service.NetworkService import org.readium.r2.lcp.service.PassphrasesRepository import org.readium.r2.lcp.service.PassphrasesService -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.publication.protection.ContentProtection import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.asset.Asset +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.downloads.DownloadManager import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContainerLicenseContainer.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContainerLicenseContainer.kt index 7f8237bb1b..d7f5856222 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContainerLicenseContainer.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContainerLicenseContainer.kt @@ -8,10 +8,10 @@ package org.readium.r2.lcp.license.container import kotlinx.coroutines.runBlocking import org.readium.r2.lcp.LcpException -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource /** * Access to a License Document stored in a read-only container. diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContentZipLicenseContainer.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContentZipLicenseContainer.kt index 221e09244b..3279c2022d 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContentZipLicenseContainer.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContentZipLicenseContainer.kt @@ -16,8 +16,8 @@ import java.util.UUID import java.util.zip.ZipFile import org.readium.r2.lcp.LcpException import org.readium.r2.lcp.license.model.LicenseDocument -import org.readium.r2.shared.resource.Container import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Container import org.readium.r2.shared.util.toUri internal class ContentZipLicenseContainer( diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LcplResourceLicenseContainer.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LcplResourceLicenseContainer.kt index bb1760a9ce..d3d947a0c7 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LcplResourceLicenseContainer.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LcplResourceLicenseContainer.kt @@ -11,8 +11,8 @@ package org.readium.r2.lcp.license.container import kotlinx.coroutines.runBlocking import org.readium.r2.lcp.LcpException -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource /** * Access a License Document stored in an LCP License Document file (LCPL) readable through a diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LicenseContainer.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LicenseContainer.kt index 9b028300a0..af7f1e1ef3 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LicenseContainer.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LicenseContainer.kt @@ -13,11 +13,11 @@ import android.content.Context import java.io.File import org.readium.r2.lcp.LcpException import org.readium.r2.lcp.license.model.LicenseDocument -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource private val LICENSE_IN_EPUB = Url("META-INF/license.lcpl")!! private val LICENSE_IN_RPF = Url("license.lcpl")!! diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/service/LicensesService.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/service/LicensesService.kt index 5a40127ba9..3200cab9e2 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/service/LicensesService.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/service/LicensesService.kt @@ -31,12 +31,12 @@ import org.readium.r2.lcp.license.container.LicenseContainer import org.readium.r2.lcp.license.container.WritableLicenseContainer import org.readium.r2.lcp.license.container.createLicenseContainer import org.readium.r2.lcp.license.model.LicenseDocument -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.extensions.tryOr import org.readium.r2.shared.extensions.tryOrLog import org.readium.r2.shared.publication.protection.ContentProtection import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.asset.Asset +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.downloads.DownloadManager import org.readium.r2.shared.util.mediatype.FormatRegistry import org.readium.r2.shared.util.mediatype.MediaType @@ -50,7 +50,7 @@ internal class LicensesService( private val network: NetworkService, private val passphrases: PassphrasesService, private val context: Context, - private val assetRetriever: AssetRetriever, + private val assetRetriever: org.readium.r2.shared.util.asset.AssetRetriever, private val mediaTypeRetriever: MediaTypeRetriever, private val downloadManager: DownloadManager ) : LcpService, CoroutineScope by MainScope() { @@ -60,12 +60,12 @@ internal class LicensesService( return isLcpProtected(asset) } - override suspend fun isLcpProtected(asset: Asset): Boolean = + override suspend fun isLcpProtected(asset: org.readium.r2.shared.util.asset.Asset): Boolean = tryOr(false) { when (asset) { - is Asset.Resource -> + is org.readium.r2.shared.util.asset.Asset.Resource -> asset.mediaType == MediaType.LCP_LICENSE_DOCUMENT - is Asset.Container -> { + is org.readium.r2.shared.util.asset.Asset.Container -> { createLicenseContainer(context, asset.container, asset.mediaType).read() true } @@ -118,7 +118,7 @@ internal class LicensesService( } override suspend fun retrieveLicense( - asset: Asset, + asset: org.readium.r2.shared.util.asset.Asset, authentication: LcpAuthenticating, allowUserInteraction: Boolean ): Try = diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/ExoPlayerDataSource.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/ExoPlayerDataSource.kt index 844eef8250..e29a6d677a 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/ExoPlayerDataSource.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/ExoPlayerDataSource.kt @@ -19,9 +19,9 @@ import com.google.android.exoplayer2.upstream.TransferListener import java.io.IOException import kotlinx.coroutines.runBlocking import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.buffered import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.buffered import org.readium.r2.shared.util.toUrl public sealed class ExoPlayerDataSourceException(message: String, cause: Throwable?) : IOException( diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/Navigator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/Navigator.kt index 3cbaa1cda4..897e081750 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/Navigator.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/Navigator.kt @@ -20,8 +20,8 @@ import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.ReadingProgression as PublicationReadingProgression -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource /** * Base interface for a navigator rendering a publication. diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/R2BasicWebView.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/R2BasicWebView.kt index 90f841b3de..822a3f7d54 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/R2BasicWebView.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/R2BasicWebView.kt @@ -46,10 +46,10 @@ import org.readium.r2.shared.extensions.tryOrLog import org.readium.r2.shared.extensions.tryOrNull import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Locator -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.readAsString import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.readAsString import org.readium.r2.shared.util.toUrl import org.readium.r2.shared.util.use import timber.log.Timber diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/audio/PublicationDataSource.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/audio/PublicationDataSource.kt index 9d7a03eb07..db8a19a90c 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/audio/PublicationDataSource.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/audio/PublicationDataSource.kt @@ -19,9 +19,9 @@ import com.google.android.exoplayer2.upstream.TransferListener import java.io.IOException import kotlinx.coroutines.runBlocking import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.buffered import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.buffered import org.readium.r2.shared.util.toUrl internal sealed class PublicationDataSourceException(message: String, cause: Throwable?) : IOException( diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt index ec631a32ee..3668cfa021 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt @@ -86,10 +86,10 @@ import org.readium.r2.shared.publication.epub.EpubLayout import org.readium.r2.shared.publication.presentation.presentation import org.readium.r2.shared.publication.services.isRestricted import org.readium.r2.shared.publication.services.positionsByReadingOrder -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.launchWebBrowser import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource import org.readium.r2.shared.util.toAbsoluteUrl import org.readium.r2.shared.util.toUri diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/HtmlInjector.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/HtmlInjector.kt index 5319be1769..618edfd117 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/HtmlInjector.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/HtmlInjector.kt @@ -12,13 +12,13 @@ import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.epub.EpubLayout import org.readium.r2.shared.publication.presentation.presentation import org.readium.r2.shared.publication.services.isProtected -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.TransformingResource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrElse +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.TransformingResource import timber.log.Timber /** diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/WebViewServer.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/WebViewServer.kt index d168c9645e..6d2a77cc70 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/WebViewServer.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/WebViewServer.kt @@ -19,16 +19,16 @@ import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Href import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceInputStream -import org.readium.r2.shared.resource.StringResource -import org.readium.r2.shared.resource.fallback import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.http.HttpHeaders import org.readium.r2.shared.util.http.HttpRange import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceInputStream +import org.readium.r2.shared.util.resource.StringResource +import org.readium.r2.shared.util.resource.fallback /** * Serves the publication resources and application assets in the EPUB navigator web views. diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Duration.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Duration.kt index c788f2aeae..dd6ea19e67 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Duration.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Duration.kt @@ -11,9 +11,11 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime +import org.readium.r2.shared.InternalReadiumApi @ExperimentalTime -internal fun List.sum(): Duration = +@InternalReadiumApi +public fun List.sum(): Duration = fold(0.seconds) { a, b -> a + b } @JvmName("sumNullable") diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Locator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Locator.kt index 1dd5e51bf6..df8621dcec 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Locator.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Locator.kt @@ -12,6 +12,7 @@ package org.readium.r2.navigator.extensions import java.util.* import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +import org.readium.r2.shared.InternalReadiumApi import org.readium.r2.shared.publication.Locator // FIXME: This should be in r2-shared once this public API is specified. @@ -59,7 +60,8 @@ internal val Locator.Locations.page: Int? get() = * * https://www.w3.org/TR/media-frags/ */ -internal val Locator.Locations.time: Duration? get() = +@InternalReadiumApi +public val Locator.Locations.time: Duration? get() = fragmentParameters["t"]?.toIntOrNull()?.seconds /** diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt index da3d4ed2e9..809a74e148 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt @@ -54,8 +54,8 @@ import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.PublicationId import org.readium.r2.shared.publication.indexOfFirstWithHref -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource import org.readium.r2.shared.util.toUri import timber.log.Timber diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaPlayer.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaPlayer.kt index bc18fab597..92bb181229 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaPlayer.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaPlayer.kt @@ -15,7 +15,7 @@ import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.PublicationId -import org.readium.r2.shared.resource.Resource +import org.readium.r2.shared.util.resource.Resource /** * Media player compatible with Android's MediaSession and handling the playback for diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt index 476607f85b..8c43e811b0 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt @@ -34,8 +34,8 @@ import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.PublicationId import org.readium.r2.shared.publication.services.cover -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource import timber.log.Timber /** diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/syncmedia/GuidedMediaNavigator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/syncmedia/GuidedMediaNavigator.kt deleted file mode 100644 index febdd75110..0000000000 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/syncmedia/GuidedMediaNavigator.kt +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2022 Readium Foundation. All rights reserved. - * Use of this source code is governed by the BSD-style license - * available in the top-level LICENSE file of the project. - */ - -package org.readium.r2.navigator.media3.syncmedia - -import androidx.media3.common.Player -import kotlin.time.Duration -import kotlinx.coroutines.flow.StateFlow -import org.readium.r2.navigator.media3.api.Media3Adapter -import org.readium.r2.navigator.media3.api.MediaNavigator -import org.readium.r2.navigator.media3.api.TextAwareMediaNavigator -import org.readium.r2.navigator.media3.api.TimeBasedMediaNavigator -import org.readium.r2.navigator.media3.audio.AudioNavigator -import org.readium.r2.navigator.preferences.Configurable -import org.readium.r2.shared.ExperimentalReadiumApi -import org.readium.r2.shared.publication.Href -import org.readium.r2.shared.publication.Link -import org.readium.r2.shared.publication.Locator -import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.util.Url - -@ExperimentalReadiumApi -public class GuidedMediaNavigator>( - private val audioNavigator: AudioNavigator -) : - MediaNavigator, - TimeBasedMediaNavigator, - TextAwareMediaNavigator, - Media3Adapter, - Configurable { - - public data class Location( - override val href: Url, - override val offset: Duration, - val fragment: String, - override val textBefore: String?, - override val textAfter: String?, - override val utterance: String, - override val range: IntRange?, - override val utteranceLocator: Locator, - override val tokenLocator: Locator? - ) : TimeBasedMediaNavigator.Location, - TextAwareMediaNavigator.Location - - public data class Playback( - override val state: MediaNavigator.State, - override val playWhenReady: Boolean, - override val index: Int, - override val offset: Duration, - override val buffered: Duration?, - override val utterance: String, - override val range: IntRange? - ) : TimeBasedMediaNavigator.Playback, TextAwareMediaNavigator.Playback - - public data class ReadingOrder( - override val duration: Duration?, - override val items: List - ) : TimeBasedMediaNavigator.ReadingOrder, TextAwareMediaNavigator.ReadingOrder { - - public data class Item( - val href: Href, - override val duration: Duration? - ) : TimeBasedMediaNavigator.ReadingOrder.Item, TextAwareMediaNavigator.ReadingOrder.Item - } - - override val publication: Publication = - audioNavigator.publication - - override val currentLocator: StateFlow = - audioNavigator.currentLocator - - override val playback: StateFlow - get() = TODO("Not yet implemented") - - override val location: StateFlow - get() = TODO("Not yet implemented") - - override val readingOrder: ReadingOrder - get() = TODO("Not yet implemented") - - override fun play() { - audioNavigator.play() - } - - override fun pause() { - audioNavigator.pause() - } - - override fun asMedia3Player(): Player = - audioNavigator.asMedia3Player() - - override val settings: StateFlow = - audioNavigator.settings - - override fun submitPreferences(preferences: P) { - audioNavigator.submitPreferences(preferences) - } - - override fun close() { - audioNavigator.close() - } - - override fun goToPreviousUtterance() { - TODO("Not yet implemented") - } - - override fun goToNextUtterance() { - TODO("Not yet implemented") - } - - override fun hasPreviousUtterance(): Boolean { - TODO("Not yet implemented") - } - - override fun hasNextUtterance(): Boolean { - TODO("Not yet implemented") - } - - override fun go(locator: Locator, animated: Boolean, completion: () -> Unit): Boolean { - TODO("Not yet implemented") - } - - override fun go(link: Link, animated: Boolean, completion: () -> Unit): Boolean { - TODO("Not yet implemented") - } - - override fun goForward(animated: Boolean, completion: () -> Unit): Boolean { - TODO("Not yet implemented") - } - - override fun goBackward(animated: Boolean, completion: () -> Unit): Boolean { - TODO("Not yet implemented") - } - - override fun seek(index: Int, offset: Duration) { - TODO("Not yet implemented") - } -} diff --git a/readium/navigators/media/audio/build.gradle.kts b/readium/navigators/media/audio/build.gradle.kts new file mode 100644 index 0000000000..fcd4d4b97e --- /dev/null +++ b/readium/navigators/media/audio/build.gradle.kts @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +plugins { + id("com.android.library") + kotlin("android") + kotlin("plugin.parcelize") +} + +android { + resourcePrefix = "readium_" + + compileSdk = 34 + + defaultConfig { + minSdk = 21 + targetSdk = 34 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=org.readium.r2.shared.InternalReadiumApi" + ) + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt")) + } + } + buildFeatures { + viewBinding = true + } + namespace = "org.readium.navigators.media.audio" +} + +kotlin { + explicitApi() +} + +rootProject.ext["publish.artifactId"] = "readium-navigator-media-audio" +apply(from = "$rootDir/scripts/publish-module.gradle") + +dependencies { + api(project(":readium:navigators:media:readium-navigator-media-common")) + + implementation(libs.androidx.media3.common) + implementation(libs.androidx.media3.session) + + implementation(libs.androidx.core) + implementation(libs.timber) + implementation(libs.bundles.coroutines) +} diff --git a/readium/navigators/media/audio/src/main/AndroidManifest.xml b/readium/navigators/media/audio/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..2d10029868 --- /dev/null +++ b/readium/navigators/media/audio/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioEngine.kt b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioEngine.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioEngine.kt rename to readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioEngine.kt index a281238027..3f6e657375 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioEngine.kt +++ b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioEngine.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.audio +package org.readium.navigator.media.audio import androidx.media3.common.Player import kotlin.time.Duration diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioEngineProvider.kt b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioEngineProvider.kt similarity index 96% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioEngineProvider.kt rename to readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioEngineProvider.kt index 97d24bc6de..192faba762 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioEngineProvider.kt +++ b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioEngineProvider.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.audio +package org.readium.navigator.media.audio import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.navigator.preferences.PreferencesEditor diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioNavigator.kt b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioNavigator.kt similarity index 97% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioNavigator.kt rename to readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioNavigator.kt index 9ecca3f64d..606dcf2306 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioNavigator.kt +++ b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.audio +package org.readium.navigator.media.audio import android.os.Build import androidx.media3.common.Player @@ -14,12 +14,12 @@ import kotlin.time.ExperimentalTime import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainScope import kotlinx.coroutines.flow.StateFlow +import org.readium.navigator.media.common.Media3Adapter +import org.readium.navigator.media.common.MediaNavigator +import org.readium.navigator.media.common.TimeBasedMediaNavigator import org.readium.r2.navigator.extensions.normalizeLocator import org.readium.r2.navigator.extensions.sum import org.readium.r2.navigator.extensions.time -import org.readium.r2.navigator.media3.api.Media3Adapter -import org.readium.r2.navigator.media3.api.MediaNavigator -import org.readium.r2.navigator.media3.api.TimeBasedMediaNavigator import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.shared.DelicateReadiumApi import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioNavigatorFactory.kt b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioNavigatorFactory.kt similarity index 97% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioNavigatorFactory.kt rename to readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioNavigatorFactory.kt index 17a8c0f0d2..b6e9277f2d 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/AudioNavigatorFactory.kt +++ b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/AudioNavigatorFactory.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.audio +package org.readium.navigator.media.audio import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.navigator.preferences.PreferencesEditor diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/MetadataRetriever.kt b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/MetadataRetriever.kt similarity index 95% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/MetadataRetriever.kt rename to readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/MetadataRetriever.kt index 9d38b0711a..bef288ee84 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/audio/MetadataRetriever.kt +++ b/readium/navigators/media/audio/src/main/java/org/readium/navigator/media/audio/MetadataRetriever.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.audio +package org.readium.navigator.media.audio import android.media.MediaDataSource import android.media.MediaMetadataRetriever @@ -16,8 +16,8 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.runBlocking import org.readium.r2.shared.extensions.tryOrLog -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource @RequiresApi(Build.VERSION_CODES.M) internal class MetadataRetriever( diff --git a/readium/navigators/media/build.gradle.kts b/readium/navigators/media/build.gradle.kts new file mode 100644 index 0000000000..290194c510 --- /dev/null +++ b/readium/navigators/media/build.gradle.kts @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +plugins { + id("com.android.library") + kotlin("android") + kotlin("plugin.parcelize") +} + +android { + resourcePrefix = "readium_" + + compileSdk = 34 + + defaultConfig { + minSdk = 21 + targetSdk = 34 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=org.readium.r2.shared.InternalReadiumApi" + ) + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt")) + } + } + namespace = "org.readium.navigator.media" +} + +kotlin { + explicitApi() +} + +rootProject.ext["publish.artifactId"] = "readium-navigator-media" +apply(from = "$rootDir/scripts/publish-module.gradle") + +dependencies { + api(project(":readium:navigators:media:readium-navigator-media-common")) + api(project(":readium:navigators:media:readium-navigator-media-audio")) + api(project(":readium:navigators:media:readium-navigator-media-tts")) +} diff --git a/readium/navigators/media/common/build.gradle.kts b/readium/navigators/media/common/build.gradle.kts new file mode 100644 index 0000000000..de55505f49 --- /dev/null +++ b/readium/navigators/media/common/build.gradle.kts @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +plugins { + id("com.android.library") + kotlin("android") + kotlin("plugin.parcelize") +} + +android { + resourcePrefix = "readium_" + + compileSdk = 34 + + defaultConfig { + minSdk = 21 + targetSdk = 34 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=org.readium.r2.shared.InternalReadiumApi" + ) + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt")) + } + } + buildFeatures { + viewBinding = true + } + namespace = "org.readium.navigators.media.common" +} + +kotlin { + explicitApi() +} + +rootProject.ext["publish.artifactId"] = "readium-navigator-media-common" +apply(from = "$rootDir/scripts/publish-module.gradle") + +dependencies { + api(project(":readium:readium-shared")) + api(project(":readium:readium-navigator")) + + implementation(libs.androidx.media3.common) + implementation(libs.timber) + implementation(libs.bundles.coroutines) +} diff --git a/readium/navigators/media/common/src/main/AndroidManifest.xml b/readium/navigators/media/common/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..2d10029868 --- /dev/null +++ b/readium/navigators/media/common/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/DefaultMediaMetadataFactory.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/DefaultMediaMetadataFactory.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/DefaultMediaMetadataFactory.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/DefaultMediaMetadataFactory.kt index bc500ae8f5..6f73642bd6 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/DefaultMediaMetadataFactory.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/DefaultMediaMetadataFactory.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import android.graphics.Bitmap import android.net.Uri diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/DefaultMediaMetadataProvider.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/DefaultMediaMetadataProvider.kt similarity index 94% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/DefaultMediaMetadataProvider.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/DefaultMediaMetadataProvider.kt index 18edb295d8..18e5e24dd9 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/DefaultMediaMetadataProvider.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/DefaultMediaMetadataProvider.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import android.net.Uri import org.readium.r2.shared.publication.Publication diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/Media3Adapter.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/Media3Adapter.kt similarity index 52% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/Media3Adapter.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/Media3Adapter.kt index ab58358659..089d48ca61 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/Media3Adapter.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/Media3Adapter.kt @@ -1,4 +1,10 @@ -package org.readium.r2.navigator.media3.api +/* + * Copyright 2022 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +package org.readium.navigator.media.common import androidx.media3.common.Player import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaMetadataFactory.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaMetadataFactory.kt similarity index 94% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaMetadataFactory.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaMetadataFactory.kt index bdeb211e4d..ab8a139c52 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaMetadataFactory.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaMetadataFactory.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import androidx.media3.common.MediaMetadata diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaMetadataProvider.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaMetadataProvider.kt similarity index 91% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaMetadataProvider.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaMetadataProvider.kt index 706932e049..54ca323ab5 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaMetadataProvider.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaMetadataProvider.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import org.readium.r2.shared.publication.Publication diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaNavigator.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaNavigator.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaNavigator.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaNavigator.kt index 932168aa1e..7c0114fd95 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/MediaNavigator.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/MediaNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import kotlinx.coroutines.flow.StateFlow import org.readium.r2.navigator.Navigator diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/TextAwareMediaNavigator.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/TextAwareMediaNavigator.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/TextAwareMediaNavigator.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/TextAwareMediaNavigator.kt index 977fe07aa7..f33613f80b 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/TextAwareMediaNavigator.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/TextAwareMediaNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import kotlinx.coroutines.flow.StateFlow import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/TimeBasedMediaNavigator.kt b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/TimeBasedMediaNavigator.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/TimeBasedMediaNavigator.kt rename to readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/TimeBasedMediaNavigator.kt index adc1cdfc27..82254f3e59 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/api/TimeBasedMediaNavigator.kt +++ b/readium/navigators/media/common/src/main/java/org/readium/navigator/media/common/TimeBasedMediaNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.api +package org.readium.navigator.media.common import kotlin.time.Duration import kotlinx.coroutines.flow.StateFlow diff --git a/readium/navigators/media/src/main/AndroidManifest.xml b/readium/navigators/media/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..2d10029868 --- /dev/null +++ b/readium/navigators/media/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/readium/navigators/media/tts/build.gradle.kts b/readium/navigators/media/tts/build.gradle.kts new file mode 100644 index 0000000000..9e234ea5fc --- /dev/null +++ b/readium/navigators/media/tts/build.gradle.kts @@ -0,0 +1,63 @@ +/* + * Copyright 2022 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +plugins { + id("com.android.library") + kotlin("android") + kotlin("plugin.parcelize") + kotlin("plugin.serialization") +} + +android { + resourcePrefix = "readium_" + + compileSdk = 34 + + defaultConfig { + minSdk = 21 + targetSdk = 34 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=org.readium.r2.shared.InternalReadiumApi" + ) + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt")) + } + } + buildFeatures { + viewBinding = true + } + namespace = "org.readium.navigators.media.tts" +} + +kotlin { + explicitApi() +} + +rootProject.ext["publish.artifactId"] = "readium-navigator-media-tts" +apply(from = "$rootDir/scripts/publish-module.gradle") + +dependencies { + api(project(":readium:navigators:media:readium-navigator-media-common")) + + implementation(libs.androidx.media3.common) + implementation(libs.androidx.media3.session) + + implementation(libs.timber) + implementation(libs.bundles.coroutines) + implementation(libs.kotlinx.serialization.json) +} diff --git a/readium/navigators/media/tts/src/main/AndroidManifest.xml b/readium/navigators/media/tts/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..2d10029868 --- /dev/null +++ b/readium/navigators/media/tts/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsAliases.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsAliases.kt similarity index 66% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsAliases.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsAliases.kt index 2aeacd1c2f..007c9df020 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsAliases.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsAliases.kt @@ -4,12 +4,12 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngine -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferences -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferencesEditor -import org.readium.r2.navigator.media3.tts.android.AndroidTtsSettings +import org.readium.navigator.media.tts.android.AndroidTtsEngine +import org.readium.navigator.media.tts.android.AndroidTtsPreferences +import org.readium.navigator.media.tts.android.AndroidTtsPreferencesEditor +import org.readium.navigator.media.tts.android.AndroidTtsSettings import org.readium.r2.shared.ExperimentalReadiumApi @OptIn(ExperimentalReadiumApi::class) diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngine.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngine.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngine.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngine.kt index b866dd60ae..5b08cad548 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngine.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngine.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngineFacade.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngineFacade.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngineFacade.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngineFacade.kt index 4caff34898..e96eaadada 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngineFacade.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngineFacade.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import java.util.* import kotlinx.coroutines.CancellableContinuation diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngineProvider.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngineProvider.kt similarity index 97% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngineProvider.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngineProvider.kt index e13059035a..da1cb251a5 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsEngineProvider.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsEngineProvider.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import androidx.media3.common.PlaybackException import androidx.media3.common.PlaybackParameters diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsNavigator.kt similarity index 96% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsNavigator.kt index 48185323c7..6fada09064 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsNavigator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import android.app.Application import androidx.media3.common.MediaItem @@ -13,12 +13,12 @@ import androidx.media3.common.Player import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainScope import kotlinx.coroutines.flow.StateFlow +import org.readium.navigator.media.common.Media3Adapter +import org.readium.navigator.media.common.MediaMetadataProvider +import org.readium.navigator.media.common.MediaNavigator +import org.readium.navigator.media.common.TextAwareMediaNavigator +import org.readium.navigator.media.tts.session.TtsSessionAdapter import org.readium.r2.navigator.extensions.normalizeLocator -import org.readium.r2.navigator.media3.api.Media3Adapter -import org.readium.r2.navigator.media3.api.MediaMetadataProvider -import org.readium.r2.navigator.media3.api.MediaNavigator -import org.readium.r2.navigator.media3.api.TextAwareMediaNavigator -import org.readium.r2.navigator.media3.tts.session.TtsSessionAdapter import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.shared.DelicateReadiumApi import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigatorFactory.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsNavigatorFactory.kt similarity index 92% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigatorFactory.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsNavigatorFactory.kt index 250be30a5d..0bebd6f4bb 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigatorFactory.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsNavigatorFactory.kt @@ -4,14 +4,14 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import android.app.Application -import org.readium.r2.navigator.media3.api.DefaultMediaMetadataProvider -import org.readium.r2.navigator.media3.api.MediaMetadataProvider -import org.readium.r2.navigator.media3.tts.android.AndroidTtsDefaults -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngine -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngineProvider +import org.readium.navigator.media.common.DefaultMediaMetadataProvider +import org.readium.navigator.media.common.MediaMetadataProvider +import org.readium.navigator.media.tts.android.AndroidTtsDefaults +import org.readium.navigator.media.tts.android.AndroidTtsEngine +import org.readium.navigator.media.tts.android.AndroidTtsEngineProvider import org.readium.r2.navigator.preferences.PreferencesEditor import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Locator diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsPlayer.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsPlayer.kt similarity index 99% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsPlayer.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsPlayer.kt index 08c4179f1a..0e1fd5919f 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsPlayer.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsPlayer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import android.media.AudioAttributes import android.media.AudioFormat diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsUtteranceIterator.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsUtteranceIterator.kt similarity index 99% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsUtteranceIterator.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsUtteranceIterator.kt index 6baef7866f..83f7be7888 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsUtteranceIterator.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/TtsUtteranceIterator.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts +package org.readium.navigator.media.tts import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Locator diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsDefaults.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsDefaults.kt similarity index 93% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsDefaults.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsDefaults.kt index abdfa3b7db..79d9b9afd4 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsDefaults.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsDefaults.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.util.Language diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsEngine.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsEngine.kt similarity index 99% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsEngine.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsEngine.kt index b3f0453aa0..94303630a2 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsEngine.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsEngine.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import android.annotation.SuppressLint import android.content.Context @@ -20,7 +20,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import org.readium.r2.navigator.media3.tts.TtsEngine +import org.readium.navigator.media.tts.TtsEngine import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.util.Language @@ -100,7 +100,6 @@ public class AndroidTtsEngine private constructor( PackageManager.ResolveInfoFlags.of(0) ) } else { - @Suppress("Deprecation") context.packageManager.queryIntentActivities(intent, 0) } diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsEngineProvider.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsEngineProvider.kt similarity index 96% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsEngineProvider.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsEngineProvider.kt index 5bf0114bed..ce0a9c4d17 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsEngineProvider.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsEngineProvider.kt @@ -4,13 +4,13 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import android.content.Context import androidx.media3.common.PlaybackException import androidx.media3.common.PlaybackException.* import androidx.media3.common.PlaybackParameters -import org.readium.r2.navigator.media3.tts.TtsEngineProvider +import org.readium.navigator.media.tts.TtsEngineProvider import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Publication diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferences.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferences.kt similarity index 92% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferences.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferences.kt index 290035d4f4..4cfa0dc0c8 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferences.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferences.kt @@ -4,10 +4,10 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import kotlinx.serialization.Serializable -import org.readium.r2.navigator.media3.tts.TtsEngine +import org.readium.navigator.media.tts.TtsEngine import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.util.Language diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesEditor.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesEditor.kt index 4dfea8b5a8..55138bf29f 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesEditor.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import org.readium.r2.navigator.extensions.format import org.readium.r2.navigator.preferences.* diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesFilters.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesFilters.kt similarity index 95% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesFilters.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesFilters.kt index fa70124637..4c5523d1c7 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesFilters.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesFilters.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import org.readium.r2.navigator.preferences.PreferencesFilter import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesSerializer.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesSerializer.kt similarity index 94% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesSerializer.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesSerializer.kt index 3e8df9c750..65f6f3676d 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesSerializer.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsPreferencesSerializer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import kotlinx.serialization.json.Json import org.readium.r2.navigator.preferences.PreferencesSerializer diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsSettings.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsSettings.kt similarity index 86% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsSettings.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsSettings.kt index 988739d617..b302f63120 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsSettings.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsSettings.kt @@ -4,9 +4,9 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android -import org.readium.r2.navigator.media3.tts.TtsEngine +import org.readium.navigator.media.tts.TtsEngine import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.util.Language diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsSettingsResolver.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsSettingsResolver.kt similarity index 95% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsSettingsResolver.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsSettingsResolver.kt index 5f2655decf..a51476b61e 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsSettingsResolver.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/android/AndroidTtsSettingsResolver.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.android +package org.readium.navigator.media.tts.android import java.util.* import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/AudioBecomingNoisyManager.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/AudioBecomingNoisyManager.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/AudioBecomingNoisyManager.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/AudioBecomingNoisyManager.kt index 3db95c148f..641589fa66 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/AudioBecomingNoisyManager.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/AudioBecomingNoisyManager.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.readium.r2.navigator.media3.tts.session +package org.readium.navigator.media.tts.session import android.content.BroadcastReceiver import android.content.Context diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/AudioFocusManager.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/AudioFocusManager.kt similarity index 99% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/AudioFocusManager.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/AudioFocusManager.kt index 99853ad115..a25755c44b 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/AudioFocusManager.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/AudioFocusManager.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.readium.r2.navigator.media3.tts.session +package org.readium.navigator.media.tts.session import android.content.Context import android.media.AudioFocusRequest @@ -29,7 +29,7 @@ import androidx.media3.common.C import androidx.media3.common.Player import androidx.media3.common.util.Log import androidx.media3.common.util.Util -import org.readium.r2.navigator.media3.tts.session.AudioFocusManager.PlayerControl +import org.readium.navigator.media.tts.session.AudioFocusManager.PlayerControl @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) /** Manages requesting and responding to changes in audio focus. diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/StreamVolumeManager.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/StreamVolumeManager.kt similarity index 99% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/StreamVolumeManager.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/StreamVolumeManager.kt index a035d4e2f5..7c2ff0b53e 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/StreamVolumeManager.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/StreamVolumeManager.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.readium.r2.navigator.media3.tts.session +package org.readium.navigator.media.tts.session import android.content.BroadcastReceiver import android.content.Context diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/TtsSessionAdapter.kt similarity index 98% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/TtsSessionAdapter.kt index 194a75b365..44a459f5d2 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/TtsSessionAdapter.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.session +package org.readium.navigator.media.tts.session import android.app.Application import android.os.Handler @@ -39,10 +39,10 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import org.readium.r2.navigator.media3.tts.TtsEngine -import org.readium.r2.navigator.media3.tts.TtsPlayer +import org.readium.navigator.media.tts.TtsEngine +import org.readium.navigator.media.tts.TtsPlayer import org.readium.r2.shared.ExperimentalReadiumApi -import org.readium.r2.shared.resource.Resource +import org.readium.r2.shared.util.resource.Resource /** * Adapts the [TtsPlayer] to media3 [Player] interface. @@ -733,6 +733,7 @@ internal class TtsSessionAdapter( return streamVolumeManager.isMuted() } + @Deprecated("Deprecated in Java") override fun setDeviceVolume(volume: Int) { streamVolumeManager.setVolume(volume) } @@ -741,6 +742,7 @@ internal class TtsSessionAdapter( streamVolumeManager.setVolume(volume) } + @Deprecated("Deprecated in Java") override fun increaseDeviceVolume() { streamVolumeManager.increaseVolume() } @@ -749,6 +751,7 @@ internal class TtsSessionAdapter( streamVolumeManager.increaseVolume() } + @Deprecated("Deprecated in Java") override fun decreaseDeviceVolume() { streamVolumeManager.decreaseVolume() } @@ -757,6 +760,7 @@ internal class TtsSessionAdapter( streamVolumeManager.decreaseVolume() } + @Deprecated("Deprecated in Java") override fun setDeviceMuted(muted: Boolean) { streamVolumeManager.setMuted(muted) } @@ -897,7 +901,8 @@ internal class TtsSessionAdapter( } } - private inner class AudioBecomingNoisyManagerListener : AudioBecomingNoisyManager.EventListener { + private inner class AudioBecomingNoisyManagerListener : + AudioBecomingNoisyManager.EventListener { override fun onAudioBecomingNoisy() { playWhenReady = false diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsTimeline.kt b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/TtsTimeline.kt similarity index 96% rename from readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsTimeline.kt rename to readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/TtsTimeline.kt index 22609a9987..271c5b9ab0 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsTimeline.kt +++ b/readium/navigators/media/tts/src/main/java/org/readium/navigator/media/tts/session/TtsTimeline.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.navigator.media3.tts.session +package org.readium.navigator.media.tts.session import androidx.media3.common.C import androidx.media3.common.MediaItem diff --git a/readium/opds/src/main/java/org/readium/r2/opds/OPDS1Parser.kt b/readium/opds/src/main/java/org/readium/r2/opds/OPDS1Parser.kt index 3573b2a73c..a432a42295 100644 --- a/readium/opds/src/main/java/org/readium/r2/opds/OPDS1Parser.kt +++ b/readium/opds/src/main/java/org/readium/r2/opds/OPDS1Parser.kt @@ -13,8 +13,6 @@ import org.joda.time.DateTime import org.readium.r2.shared.extensions.toList import org.readium.r2.shared.extensions.toMap import org.readium.r2.shared.opds.* -import org.readium.r2.shared.parser.xml.ElementNode -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.publication.* import org.readium.r2.shared.toJSON import org.readium.r2.shared.util.Try @@ -25,6 +23,8 @@ import org.readium.r2.shared.util.http.HttpRequest import org.readium.r2.shared.util.http.fetchWithDecoder import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.xml.ElementNode +import org.readium.r2.shared.util.xml.XmlParser public enum class OPDSParserError { MissingTitle diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/Properties.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/Properties.kt index 2343622dd5..7b30dd849a 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/Properties.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/Properties.kt @@ -16,7 +16,7 @@ import org.json.JSONObject import org.readium.r2.shared.JSONable import org.readium.r2.shared.extensions.JSONParceler import org.readium.r2.shared.extensions.toMap -import org.readium.r2.shared.resource.Resource +import org.readium.r2.shared.util.resource.Resource /** * Properties associated to the linked resource. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt index a8e6309142..3afd578a8d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt @@ -27,17 +27,17 @@ import org.readium.r2.shared.publication.services.PositionsService import org.readium.r2.shared.publication.services.WebPositionsService import org.readium.r2.shared.publication.services.content.ContentService import org.readium.r2.shared.publication.services.search.SearchService -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.EmptyContainer -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.fallback import org.readium.r2.shared.util.BaseError import org.readium.r2.shared.util.Closeable import org.readium.r2.shared.util.Error import org.readium.r2.shared.util.ThrowableError import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.EmptyContainer +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.fallback internal typealias ServiceFactory = (Publication.Service.Context) -> Publication.Service? diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtection.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtection.kt index f332fa0ff6..ee925b4e97 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtection.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtection.kt @@ -7,16 +7,16 @@ package org.readium.r2.shared.publication.protection import org.readium.r2.shared.InternalReadiumApi -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.protection.ContentProtection.Scheme import org.readium.r2.shared.publication.services.contentProtectionServiceFactory -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.readAsXml import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.readAsXml +import org.readium.r2.shared.util.xml.ElementNode /** * [ContentProtection] implementation used as a fallback by the Streamer to detect Adept DRM, @@ -27,8 +27,8 @@ public class AdeptFallbackContentProtection : ContentProtection { override val scheme: Scheme = Scheme.Adept - override suspend fun supports(asset: Asset): Boolean { - if (asset !is Asset.Container) { + override suspend fun supports(asset: org.readium.r2.shared.util.asset.Asset): Boolean { + if (asset !is org.readium.r2.shared.util.asset.Asset.Container) { return false } @@ -36,11 +36,11 @@ public class AdeptFallbackContentProtection : ContentProtection { } override suspend fun open( - asset: Asset, + asset: org.readium.r2.shared.util.asset.Asset, credentials: String?, allowUserInteraction: Boolean ): Try { - if (asset !is Asset.Container) { + if (asset !is org.readium.r2.shared.util.asset.Asset.Container) { return Try.failure( Publication.OpenError.UnsupportedAsset("A container asset was expected.") ) @@ -58,7 +58,7 @@ public class AdeptFallbackContentProtection : ContentProtection { return Try.success(protectedFile) } - private suspend fun isAdept(asset: Asset.Container): Boolean { + private suspend fun isAdept(asset: org.readium.r2.shared.util.asset.Asset.Container): Boolean { if (!asset.mediaType.matches(MediaType.EPUB)) { return false } diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtection.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtection.kt index 1462a20311..a02f8d9605 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtection.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtection.kt @@ -15,9 +15,9 @@ import org.readium.r2.shared.UserException import org.readium.r2.shared.publication.LocalizedString import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.services.ContentProtectionService -import org.readium.r2.shared.resource.Container import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container /** * Bridge between a Content Protection technology and the Readium toolkit. @@ -34,7 +34,7 @@ public interface ContentProtection { * Returns if this [ContentProtection] supports the given [asset]. */ public suspend fun supports( - asset: org.readium.r2.shared.asset.Asset + asset: org.readium.r2.shared.util.asset.Asset ): Boolean /** @@ -44,7 +44,7 @@ public interface ContentProtection { * asset can't be successfully opened even in restricted mode. */ public suspend fun open( - asset: org.readium.r2.shared.asset.Asset, + asset: org.readium.r2.shared.util.asset.Asset, credentials: String?, allowUserInteraction: Boolean ): Try diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtectionSchemeRetriever.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtectionSchemeRetriever.kt index 5dad613388..d340d08bad 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtectionSchemeRetriever.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/ContentProtectionSchemeRetriever.kt @@ -6,7 +6,7 @@ package org.readium.r2.shared.publication.protection -import org.readium.r2.shared.asset.Asset +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.mediatype.MediaTypeRetriever /** @@ -22,7 +22,7 @@ public class ContentProtectionSchemeRetriever( AdeptFallbackContentProtection() ) - public suspend fun retrieve(asset: Asset): ContentProtection.Scheme? = + public suspend fun retrieve(asset: org.readium.r2.shared.util.asset.Asset): ContentProtection.Scheme? = contentProtections .firstOrNull { it.supports(asset) } ?.scheme diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtection.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtection.kt index c9a563b4b2..4ecedf082b 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtection.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtection.kt @@ -8,21 +8,21 @@ package org.readium.r2.shared.publication.protection import org.json.JSONObject import org.readium.r2.shared.InternalReadiumApi -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.Manifest import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.encryption.encryption import org.readium.r2.shared.publication.protection.ContentProtection.Scheme import org.readium.r2.shared.publication.services.contentProtectionServiceFactory -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.readAsJson -import org.readium.r2.shared.resource.readAsXml import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.readAsJson +import org.readium.r2.shared.util.resource.readAsXml +import org.readium.r2.shared.util.xml.ElementNode /** * [ContentProtection] implementation used as a fallback by the Streamer to detect LCP DRM @@ -36,18 +36,23 @@ public class LcpFallbackContentProtection( override val scheme: Scheme = Scheme.Lcp - override suspend fun supports(asset: Asset): Boolean = + override suspend fun supports(asset: org.readium.r2.shared.util.asset.Asset): Boolean = when (asset) { - is Asset.Container -> isLcpProtected(asset.container, asset.mediaType) - is Asset.Resource -> asset.mediaType.matches(MediaType.LCP_LICENSE_DOCUMENT) + is org.readium.r2.shared.util.asset.Asset.Container -> isLcpProtected( + asset.container, + asset.mediaType + ) + is org.readium.r2.shared.util.asset.Asset.Resource -> asset.mediaType.matches( + MediaType.LCP_LICENSE_DOCUMENT + ) } override suspend fun open( - asset: Asset, + asset: org.readium.r2.shared.util.asset.Asset, credentials: String?, allowUserInteraction: Boolean ): Try { - if (asset !is Asset.Container) { + if (asset !is org.readium.r2.shared.util.asset.Asset.Container) { return Try.failure( Publication.OpenError.UnsupportedAsset("A container asset was expected.") ) diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/ContentProtectionService.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/ContentProtectionService.kt index 4dc6e23553..e2e0d527b3 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/ContentProtectionService.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/ContentProtectionService.kt @@ -20,12 +20,12 @@ import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.PublicationServicesHolder import org.readium.r2.shared.publication.ServiceFactory import org.readium.r2.shared.publication.protection.ContentProtection -import org.readium.r2.shared.resource.FailureResource -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.StringResource import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.FailureResource +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.StringResource /** * Provides information about a publication's content protection and manages user rights. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/CoverService.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/CoverService.kt index b7f41447cd..e530bf5915 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/CoverService.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/CoverService.kt @@ -17,12 +17,12 @@ import org.readium.r2.shared.extensions.toPng import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.ServiceFactory -import org.readium.r2.shared.resource.BytesResource -import org.readium.r2.shared.resource.FailureResource -import org.readium.r2.shared.resource.LazyResource -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.BytesResource +import org.readium.r2.shared.util.resource.FailureResource +import org.readium.r2.shared.util.resource.LazyResource +import org.readium.r2.shared.util.resource.Resource /** * Provides an easy access to a bitmap version of the publication cover. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/PositionsService.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/PositionsService.kt index 3b8bca0ae3..3229c1e4eb 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/PositionsService.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/PositionsService.kt @@ -20,13 +20,13 @@ import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.PublicationServicesHolder import org.readium.r2.shared.publication.ServiceFactory import org.readium.r2.shared.publication.firstWithMediaType -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.StringResource -import org.readium.r2.shared.resource.readAsString import org.readium.r2.shared.toJSON import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.StringResource +import org.readium.r2.shared.util.resource.readAsString private val positionsMediaType = MediaType("application/vnd.readium.position-list+json")!! diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/ContentService.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/ContentService.kt index 885b8d1e79..65be164989 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/ContentService.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/ContentService.kt @@ -11,7 +11,7 @@ import org.readium.r2.shared.publication.* import org.readium.r2.shared.publication.ServiceFactory import org.readium.r2.shared.publication.services.content.iterators.PublicationContentIterator import org.readium.r2.shared.publication.services.content.iterators.ResourceContentIteratorFactory -import org.readium.r2.shared.resource.Container +import org.readium.r2.shared.util.resource.Container /** * Provides a way to extract the raw [Content] of a [Publication]. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIterator.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIterator.kt index f3ae6937fc..fe97aaae2d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIterator.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIterator.kt @@ -28,12 +28,12 @@ import org.readium.r2.shared.publication.services.content.Content.ImageElement import org.readium.r2.shared.publication.services.content.Content.TextElement import org.readium.r2.shared.publication.services.content.Content.VideoElement import org.readium.r2.shared.publication.services.positionsByReadingOrder -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.readAsString import org.readium.r2.shared.util.Language import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.readAsString import org.readium.r2.shared.util.use import timber.log.Timber diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/PublicationContentIterator.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/PublicationContentIterator.kt index a306fa1c55..825b810738 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/PublicationContentIterator.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/PublicationContentIterator.kt @@ -13,9 +13,9 @@ import org.readium.r2.shared.publication.Manifest import org.readium.r2.shared.publication.PublicationServicesHolder import org.readium.r2.shared.publication.indexOfFirstWithHref import org.readium.r2.shared.publication.services.content.Content -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Either +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource /** * Creates a [Content.Iterator] instance for the [Resource], starting from the diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/SearchService.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/SearchService.kt index 2608074bd0..9a157fefbd 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/SearchService.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/SearchService.kt @@ -15,10 +15,10 @@ import org.readium.r2.shared.UserException import org.readium.r2.shared.publication.LocatorCollection import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.ServiceFactory -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.SuspendingCloseable import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.http.HttpException +import org.readium.r2.shared.util.resource.Resource @ExperimentalReadiumApi public typealias SearchTry = Try diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/StringSearchService.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/StringSearchService.kt index 471a28c216..b86e2b401d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/StringSearchService.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/services/search/StringSearchService.kt @@ -20,12 +20,12 @@ import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.* import org.readium.r2.shared.publication.services.positionsByReadingOrder import org.readium.r2.shared.publication.services.search.SearchService.Options -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.content.DefaultResourceContentExtractorFactory -import org.readium.r2.shared.resource.content.ResourceContentExtractor import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.content.DefaultResourceContentExtractorFactory +import org.readium.r2.shared.util.resource.content.ResourceContentExtractor import timber.log.Timber /** diff --git a/readium/shared/src/main/java/org/readium/r2/shared/asset/Asset.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/asset/Asset.kt similarity index 68% rename from readium/shared/src/main/java/org/readium/r2/shared/asset/Asset.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/asset/Asset.kt index 2650b284b1..af5e850e5d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/asset/Asset.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/asset/Asset.kt @@ -4,11 +4,11 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.asset +package org.readium.r2.shared.util.asset -import org.readium.r2.shared.resource.Container as SharedContainer -import org.readium.r2.shared.resource.Resource as SharedResource import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container as SharedContainer +import org.readium.r2.shared.util.resource.Resource as SharedResource /** * An asset which is either a single resource or a container that holds multiple resources. @@ -18,7 +18,7 @@ public sealed class Asset { /** * Type of the asset source. */ - public abstract val assetType: AssetType + public abstract val assetType: org.readium.r2.shared.util.asset.AssetType /** * Media type of the asset. @@ -39,10 +39,10 @@ public sealed class Asset { public class Resource( override val mediaType: MediaType, public val resource: SharedResource - ) : Asset() { + ) : org.readium.r2.shared.util.asset.Asset() { - override val assetType: AssetType = - AssetType.Resource + override val assetType: org.readium.r2.shared.util.asset.AssetType = + org.readium.r2.shared.util.asset.AssetType.Resource override suspend fun close() { resource.close() @@ -60,13 +60,13 @@ public sealed class Asset { override val mediaType: MediaType, exploded: Boolean, public val container: SharedContainer - ) : Asset() { + ) : org.readium.r2.shared.util.asset.Asset() { - override val assetType: AssetType = + override val assetType: org.readium.r2.shared.util.asset.AssetType = if (exploded) { - AssetType.Directory + org.readium.r2.shared.util.asset.AssetType.Directory } else { - AssetType.Archive + org.readium.r2.shared.util.asset.AssetType.Archive } override suspend fun close() { diff --git a/readium/shared/src/main/java/org/readium/r2/shared/asset/AssetRetriever.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/asset/AssetRetriever.kt similarity index 77% rename from readium/shared/src/main/java/org/readium/r2/shared/asset/AssetRetriever.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/asset/AssetRetriever.kt index 2fbfafafd5..ed57d4f8b9 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/asset/AssetRetriever.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/asset/AssetRetriever.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.asset +package org.readium.r2.shared.util.asset import android.content.ContentResolver import android.content.Context @@ -12,16 +12,6 @@ import android.net.Uri import android.provider.MediaStore import java.io.File import org.readium.r2.shared.extensions.queryProjection -import org.readium.r2.shared.resource.ArchiveFactory -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.ContainerFactory -import org.readium.r2.shared.resource.ContainerMediaTypeSnifferContent -import org.readium.r2.shared.resource.DefaultArchiveFactory -import org.readium.r2.shared.resource.DirectoryContainerFactory -import org.readium.r2.shared.resource.FileResourceFactory -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceFactory -import org.readium.r2.shared.resource.ResourceMediaTypeSnifferContent import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.BaseError import org.readium.r2.shared.util.Either @@ -34,6 +24,16 @@ import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeHints import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.ArchiveFactory +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.ContainerFactory +import org.readium.r2.shared.util.resource.ContainerMediaTypeSnifferContent +import org.readium.r2.shared.util.resource.DirectoryContainerFactory +import org.readium.r2.shared.util.resource.FileResourceFactory +import org.readium.r2.shared.util.resource.FileZipArchiveFactory +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceFactory +import org.readium.r2.shared.util.resource.ResourceMediaTypeSnifferContent import org.readium.r2.shared.util.toUrl /** @@ -55,7 +55,7 @@ public class AssetRetriever( mediaTypeRetriever = mediaTypeRetriever, resourceFactory = FileResourceFactory(mediaTypeRetriever), containerFactory = DirectoryContainerFactory(mediaTypeRetriever), - archiveFactory = DefaultArchiveFactory(mediaTypeRetriever), + archiveFactory = FileZipArchiveFactory(mediaTypeRetriever), contentResolver = context.contentResolver ) } @@ -151,15 +151,25 @@ public class AssetRetriever( .mapFailure { error -> when (error) { is ArchiveFactory.Error.FormatNotSupported -> - Error.ArchiveFormatNotSupported(error) + Error.ArchiveFormatNotSupported( + error + ) is ArchiveFactory.Error.ResourceReading -> error.resourceException.wrap(url) is ArchiveFactory.Error.PasswordsNotSupported -> - Error.ArchiveFormatNotSupported(error) + Error.ArchiveFormatNotSupported( + error + ) } } } - .map { container -> Asset.Container(mediaType, exploded = false, container) } + .map { container -> + Asset.Container( + mediaType, + exploded = false, + container + ) + } } private suspend fun retrieveDirectoryAsset( @@ -168,16 +178,29 @@ public class AssetRetriever( ): Try { return containerFactory.create(url) .map { container -> - Asset.Container(mediaType, exploded = true, container) + Asset.Container( + mediaType, + exploded = true, + container + ) } .mapFailure { error -> when (error) { is ContainerFactory.Error.NotAContainer -> - Error.NotFound(url, error) + Error.NotFound( + url, + error + ) is ContainerFactory.Error.Forbidden -> - Error.Forbidden(url, error) + Error.Forbidden( + url, + error + ) is ContainerFactory.Error.SchemeNotSupported -> - Error.SchemeNotSupported(error.scheme, error) + Error.SchemeNotSupported( + error.scheme, + error + ) } } } @@ -187,7 +210,12 @@ public class AssetRetriever( mediaType: MediaType ): Try { return retrieveResource(url) - .map { resource -> Asset.Resource(mediaType, resource) } + .map { resource -> + Asset.Resource( + mediaType, + resource + ) + } } private suspend fun retrieveResource( @@ -197,11 +225,20 @@ public class AssetRetriever( .mapFailure { error -> when (error) { is ResourceFactory.Error.NotAResource -> - Error.NotFound(url, error) + Error.NotFound( + url, + error + ) is ResourceFactory.Error.Forbidden -> - Error.Forbidden(url, error) + Error.Forbidden( + url, + error + ) is ResourceFactory.Error.SchemeNotSupported -> - Error.SchemeNotSupported(error.scheme, error) + Error.SchemeNotSupported( + error.scheme, + error + ) } } } @@ -209,16 +246,29 @@ public class AssetRetriever( private fun Resource.Exception.wrap(url: AbsoluteUrl): Error = when (this) { is Resource.Exception.Forbidden -> - Error.Forbidden(url, this) + Error.Forbidden( + url, + this + ) is Resource.Exception.NotFound -> - Error.InvalidAsset(this) + Error.InvalidAsset( + this + ) is Resource.Exception.Unavailable, Resource.Exception.Offline -> - Error.Unavailable(this) + Error.Unavailable( + this + ) is Resource.Exception.OutOfMemory -> - Error.OutOfMemory(cause) + Error.OutOfMemory( + cause + ) is Resource.Exception.Other -> - Error.Unknown(this) - else -> Error.Unknown(this) + Error.Unknown( + this + ) + else -> Error.Unknown( + this + ) } /* Sniff unknown assets */ @@ -270,13 +320,20 @@ public class AssetRetriever( ): Asset? { val mediaType = retrieveMediaType(url, Either(container)) ?: return null - return Asset.Container(mediaType, exploded = exploded, container = container) + return Asset.Container( + mediaType, + exploded = exploded, + container = container + ) } private suspend fun retrieve(url: AbsoluteUrl, resource: Resource): Asset? { val mediaType = retrieveMediaType(url, Either(resource)) ?: return null - return Asset.Resource(mediaType, resource = resource) + return Asset.Resource( + mediaType, + resource = resource + ) } private suspend fun retrieveMediaType( diff --git a/readium/shared/src/main/java/org/readium/r2/shared/asset/AssetType.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/asset/AssetType.kt similarity index 93% rename from readium/shared/src/main/java/org/readium/r2/shared/asset/AssetType.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/asset/AssetType.kt index c5731503b7..da1c0f9db8 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/asset/AssetType.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/asset/AssetType.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.asset +package org.readium.r2.shared.util.asset import org.readium.r2.shared.util.MapCompanion diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/downloads/android/AndroidDownloadManager.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/downloads/android/AndroidDownloadManager.kt index 29f8d4bd4f..9851bf812e 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/downloads/android/AndroidDownloadManager.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/downloads/android/AndroidDownloadManager.kt @@ -24,15 +24,15 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.readium.r2.shared.extensions.tryOr -import org.readium.r2.shared.resource.FileResource -import org.readium.r2.shared.units.Hz -import org.readium.r2.shared.units.hz import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.downloads.DownloadManager import org.readium.r2.shared.util.mediatype.FormatRegistry import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.FileResource import org.readium.r2.shared.util.toUri +import org.readium.r2.shared.util.units.Hz +import org.readium.r2.shared.util.units.hz /** * A [DownloadManager] implementation using the Android download service. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpContainer.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpContainer.kt index 332eed5075..10f7e1d62e 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpContainer.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpContainer.kt @@ -6,12 +6,12 @@ package org.readium.r2.shared.util.http -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.FailureResource -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.toEntry import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.FailureResource +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.toEntry /** * Fetches remote resources through HTTP. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResource.kt index 2665e67648..6ccc93be4d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResource.kt @@ -6,13 +6,13 @@ import kotlinx.coroutines.withContext import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.extensions.read import org.readium.r2.shared.extensions.tryOrLog -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.flatMap import org.readium.r2.shared.util.io.CountingInputStream import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry /** Provides access to an external URL. */ @OptIn(ExperimentalReadiumApi::class) diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResourceFactory.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResourceFactory.kt index 9d8ce284b6..0552d4e78f 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResourceFactory.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpResourceFactory.kt @@ -6,10 +6,10 @@ package org.readium.r2.shared.util.http -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceFactory import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceFactory public class HttpResourceFactory( private val httpClient: HttpClient diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/mediatype/MediaTypeSnifferContent.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/mediatype/MediaTypeSnifferContent.kt index 9f7e359e14..7770c5dbee 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/mediatype/MediaTypeSnifferContent.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/mediatype/MediaTypeSnifferContent.kt @@ -7,9 +7,9 @@ import kotlinx.coroutines.withContext import org.json.JSONObject import org.readium.r2.shared.extensions.read import org.readium.r2.shared.extensions.tryOrNull -import org.readium.r2.shared.parser.xml.ElementNode -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.publication.Manifest +import org.readium.r2.shared.util.xml.ElementNode +import org.readium.r2.shared.util.xml.XmlParser /** * Provides read access to an asset content. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/pdf/PdfDocument.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/pdf/PdfDocument.kt index ae193c06ee..152116521a 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/pdf/PdfDocument.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/pdf/PdfDocument.kt @@ -18,13 +18,13 @@ import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.PublicationServicesHolder import org.readium.r2.shared.publication.ReadingProgression import org.readium.r2.shared.publication.services.cacheService -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry import org.readium.r2.shared.util.SuspendingCloseable import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.cache.Cache import org.readium.r2.shared.util.cache.getOrTryPut import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry public interface PdfDocumentFactory { diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/BufferingResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/BufferingResource.kt similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/BufferingResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/BufferingResource.kt index 04366c7e82..5bdf9aed2c 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/BufferingResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/BufferingResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.extensions.coerceIn import org.readium.r2.shared.extensions.contains diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/BytesResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/BytesResource.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/BytesResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/BytesResource.kt index 0441ab7ff5..4a6f4c0589 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/BytesResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/BytesResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import kotlinx.coroutines.runBlocking import org.readium.r2.shared.extensions.read diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/Container.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/Container.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/Container.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/Container.kt index fd44c92f82..db476f78ef 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/Container.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/Container.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.SuspendingCloseable diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/ContentResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/ContentResource.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/ContentResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/ContentResource.kt index 77f913d684..bc40f9dc81 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/ContentResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/ContentResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import android.content.ContentResolver import android.net.Uri diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/DirectoryContainer.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/DirectoryContainer.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/DirectoryContainer.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/DirectoryContainer.kt index 09e534d09d..11212b834e 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/DirectoryContainer.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/DirectoryContainer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.File import kotlinx.coroutines.Dispatchers diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/Factories.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/Factories.kt similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/Factories.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/Factories.kt index 2229e31638..84061ad718 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/Factories.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/Factories.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.BaseError diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/FallbackResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FallbackResource.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/FallbackResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/FallbackResource.kt index 1354b693e3..950e7e05ad 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/FallbackResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FallbackResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.mediatype.MediaType diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/FileChannelResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileChannelResource.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/FileChannelResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileChannelResource.kt index 12933fe741..57cba9ef76 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/FileChannelResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileChannelResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.File import java.io.FileNotFoundException diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/FileResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileResource.kt similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/FileResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileResource.kt index 7af5bb1f1e..d190ee4762 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/FileResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.File import java.io.FileNotFoundException diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/DefaultArchiveFactory.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileZipArchiveFactory.kt similarity index 95% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/DefaultArchiveFactory.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileZipArchiveFactory.kt index 5d38cf3b48..3c100f57fa 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/DefaultArchiveFactory.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/FileZipArchiveFactory.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.File import java.util.zip.ZipException @@ -18,7 +18,7 @@ import org.readium.r2.shared.util.mediatype.MediaTypeRetriever /** * An [ArchiveFactory] to open local ZIP files with Java's [ZipFile]. */ -public class DefaultArchiveFactory( +public class FileZipArchiveFactory( private val mediaTypeRetriever: MediaTypeRetriever ) : ArchiveFactory { diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/LazyResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/LazyResource.kt similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/LazyResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/LazyResource.kt index 84c75f3ff1..dc1dc958e1 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/LazyResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/LazyResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.mediatype.MediaType diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/MediaTypeExt.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/MediaTypeExt.kt similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/MediaTypeExt.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/MediaTypeExt.kt index 3d21057b9d..234e81de85 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/MediaTypeExt.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/MediaTypeExt.kt @@ -1,4 +1,4 @@ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrDefault diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/Resource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/Resource.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/Resource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/Resource.kt index bb8f25fd6c..bd65824f02 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/Resource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/Resource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import android.graphics.Bitmap import android.graphics.BitmapFactory @@ -14,13 +14,13 @@ import java.nio.charset.Charset import org.json.JSONObject import org.readium.r2.shared.R import org.readium.r2.shared.UserException -import org.readium.r2.shared.parser.xml.ElementNode -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.SuspendingCloseable import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.flatMap import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.xml.ElementNode +import org.readium.r2.shared.util.xml.XmlParser public typealias ResourceTry = Try diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/ResourceInputStream.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/ResourceInputStream.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/ResourceInputStream.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/ResourceInputStream.kt index b23e1c5730..2236313478 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/ResourceInputStream.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/ResourceInputStream.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.IOException import java.io.InputStream diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/RoutingContainer.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/RoutingContainer.kt similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/RoutingContainer.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/RoutingContainer.kt index 5a888aa11e..a7fa47e118 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/RoutingContainer.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/RoutingContainer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Url diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/SynchronizedResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/SynchronizedResource.kt similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/SynchronizedResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/SynchronizedResource.kt index c6cef854f2..df18162628 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/SynchronizedResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/SynchronizedResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/TransformingContainer.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/TransformingContainer.kt similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/TransformingContainer.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/TransformingContainer.kt index d23fec78e0..76c5e3ead8 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/TransformingContainer.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/TransformingContainer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.util.Url diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/TransformingResource.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/TransformingResource.kt similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/TransformingResource.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/TransformingResource.kt index 7d1b463487..35ffa1be67 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/TransformingResource.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/TransformingResource.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.readium.r2.shared.extensions.coerceIn import org.readium.r2.shared.extensions.requireLengthFitInt diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/ZipContainer.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/ZipContainer.kt similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/ZipContainer.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/ZipContainer.kt index f62fa402a8..2b8bd22bdd 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/ZipContainer.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/ZipContainer.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.File import java.io.IOException diff --git a/readium/shared/src/main/java/org/readium/r2/shared/resource/content/ResourceContentExtractor.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/content/ResourceContentExtractor.kt similarity index 88% rename from readium/shared/src/main/java/org/readium/r2/shared/resource/content/ResourceContentExtractor.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/resource/content/ResourceContentExtractor.kt index 64136dfe04..8de612337e 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/resource/content/ResourceContentExtractor.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/resource/content/ResourceContentExtractor.kt @@ -4,19 +4,19 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.resource.content +package org.readium.r2.shared.util.resource.content import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.jsoup.Jsoup import org.jsoup.parser.Parser import org.readium.r2.shared.ExperimentalReadiumApi -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.mapCatching -import org.readium.r2.shared.resource.readAsString import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.mapCatching +import org.readium.r2.shared.util.resource.readAsString /** * Extracts pure content from a marked-up (e.g. HTML) or binary (e.g. PDF) resource. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/units/Hertz.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/units/Hertz.kt similarity index 87% rename from readium/shared/src/main/java/org/readium/r2/shared/units/Hertz.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/units/Hertz.kt index 103a52a67a..f4622720e3 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/units/Hertz.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/units/Hertz.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.units +package org.readium.r2.shared.util.units @JvmInline public value class Hz(public val value: Double) diff --git a/readium/shared/src/main/java/org/readium/r2/shared/parser/xml/XmlParser.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/xml/XmlParser.kt similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/parser/xml/XmlParser.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/xml/XmlParser.kt index 3c9af81145..14df5a0cdb 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/parser/xml/XmlParser.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/xml/XmlParser.kt @@ -7,7 +7,7 @@ * LICENSE file present in the project repository where this source code is maintained. */ -package org.readium.r2.shared.parser.xml +package org.readium.r2.shared.util.xml import java.io.IOException import java.io.InputStream diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/BufferedReadableChannel.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/BufferedReadableChannel.kt similarity index 92% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/BufferedReadableChannel.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/BufferedReadableChannel.kt index d4c1d70e7a..9e0d401ede 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/BufferedReadableChannel.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/BufferedReadableChannel.kt @@ -4,11 +4,11 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.util.archive.channel +package org.readium.r2.shared.util.zip import java.nio.ByteBuffer -import org.readium.r2.shared.util.archive.channel.jvm.NonWritableChannelException -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel +import org.readium.r2.shared.util.zip.jvm.NonWritableChannelException +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel internal class BufferedReadableChannel( private val innerChannel: SeekableByteChannel, diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/CachingReadableChannel.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/CachingReadableChannel.kt similarity index 92% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/CachingReadableChannel.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/CachingReadableChannel.kt index 6fc2e49964..7aef0453d8 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/CachingReadableChannel.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/CachingReadableChannel.kt @@ -4,11 +4,11 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.util.archive.channel +package org.readium.r2.shared.util.zip import java.nio.ByteBuffer -import org.readium.r2.shared.util.archive.channel.jvm.NonWritableChannelException -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel +import org.readium.r2.shared.util.zip.jvm.NonWritableChannelException +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel internal class CachingReadableChannel( private val innerChannel: SeekableByteChannel, diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/ChannelZipContainer.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/ChannelZipContainer.kt similarity index 67% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/ChannelZipContainer.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/ChannelZipContainer.kt index d1b32efaae..80eecf39be 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/ChannelZipContainer.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/ChannelZipContainer.kt @@ -4,34 +4,30 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.util.archive.channel +package org.readium.r2.shared.util.zip -import java.io.File import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.readium.r2.shared.extensions.readFully import org.readium.r2.shared.extensions.tryOrLog -import org.readium.r2.shared.resource.ArchiveFactory -import org.readium.r2.shared.resource.ArchiveProperties -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.FailureResource -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceMediaTypeSnifferContent -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.archive import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.RelativeUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url -import org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipArchiveEntry -import org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.io.CountingInputStream import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeHints import org.readium.r2.shared.util.mediatype.MediaTypeRetriever -import org.readium.r2.shared.util.toUrl +import org.readium.r2.shared.util.resource.ArchiveProperties +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.FailureResource +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceMediaTypeSnifferContent +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.archive +import org.readium.r2.shared.util.zip.compress.archivers.zip.ZipArchiveEntry +import org.readium.r2.shared.util.zip.compress.archivers.zip.ZipFile internal class ChannelZipContainer( private val archive: ZipFile, @@ -168,58 +164,3 @@ internal class ChannelZipContainer( } } } - -/** - * An [ArchiveFactory] able to open a ZIP archive served through a stream (e.g. HTTP server, - * content URI, etc.). - */ -public class ChannelZipArchiveFactory( - private val mediaTypeRetriever: MediaTypeRetriever -) : ArchiveFactory { - - override suspend fun create( - resource: Resource, - password: String? - ): Try { - if (password != null) { - return Try.failure(ArchiveFactory.Error.PasswordsNotSupported()) - } - - return try { - val resourceChannel = ResourceChannel(resource) - val channel = wrapBaseChannel(resourceChannel) - val zipFile = ZipFile(channel, true) - val channelZip = ChannelZipContainer(zipFile, resource.source, mediaTypeRetriever) - Try.success(channelZip) - } catch (e: Resource.Exception) { - Try.failure(ArchiveFactory.Error.ResourceReading(e)) - } catch (e: Exception) { - Try.failure(ArchiveFactory.Error.FormatNotSupported(e)) - } - } - - internal fun openFile(file: File): Container { - val fileChannel = FileChannelAdapter(file, "r") - val channel = wrapBaseChannel(fileChannel) - return ChannelZipContainer(ZipFile(channel), file.toUrl(), mediaTypeRetriever) - } - - private fun wrapBaseChannel(channel: SeekableByteChannel): SeekableByteChannel { - val size = channel.size() - return if (size < CACHE_ALL_MAX_SIZE) { - CachingReadableChannel(channel, 0) - } else { - val cacheStart = size - CACHED_TAIL_SIZE - val cachingChannel = CachingReadableChannel(channel, cacheStart) - cachingChannel.cache() - BufferedReadableChannel(cachingChannel, DEFAULT_BUFFER_SIZE) - } - } - - public companion object { - - private const val CACHE_ALL_MAX_SIZE = 5242880 - - private const val CACHED_TAIL_SIZE = 65557 - } -} diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/FileChannelAdapter.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/FileChannelAdapter.java similarity index 92% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/FileChannelAdapter.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/FileChannelAdapter.java index 0263bec965..172c03dbad 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/FileChannelAdapter.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/FileChannelAdapter.java @@ -4,9 +4,9 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.util.archive.channel; +package org.readium.r2.shared.util.zip; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; import java.io.File; import java.io.FileNotFoundException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/HttpChannel.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/HttpChannel.kt similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/HttpChannel.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/HttpChannel.kt index 592edbd2cb..6a0cde1355 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/HttpChannel.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/HttpChannel.kt @@ -4,7 +4,7 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.util.archive.channel +package org.readium.r2.shared.util.zip import java.io.IOException import java.io.InputStream @@ -16,8 +16,6 @@ import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.extensions.readSafe import org.readium.r2.shared.extensions.tryOrLog import org.readium.r2.shared.util.Try -import org.readium.r2.shared.util.archive.channel.jvm.NonWritableChannelException -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel import org.readium.r2.shared.util.getOrThrow import org.readium.r2.shared.util.http.HttpClient import org.readium.r2.shared.util.http.HttpException @@ -25,6 +23,8 @@ import org.readium.r2.shared.util.http.HttpRequest import org.readium.r2.shared.util.http.HttpResponse import org.readium.r2.shared.util.http.head import org.readium.r2.shared.util.io.CountingInputStream +import org.readium.r2.shared.util.zip.jvm.NonWritableChannelException +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel import timber.log.Timber @OptIn(ExperimentalReadiumApi::class) diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/ResourceChannel.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/ResourceChannel.kt similarity index 88% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/ResourceChannel.kt rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/ResourceChannel.kt index 2b1dbcf46e..f8e8943f97 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/ResourceChannel.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/ResourceChannel.kt @@ -4,17 +4,17 @@ * available in the top-level LICENSE file of the project. */ -package org.readium.r2.shared.util.archive.channel +package org.readium.r2.shared.util.zip import java.io.IOException import java.nio.ByteBuffer import kotlinx.coroutines.* -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.util.archive.channel.jvm.ClosedChannelException -import org.readium.r2.shared.util.archive.channel.jvm.NonWritableChannelException -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.getOrThrow +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.zip.jvm.ClosedChannelException +import org.readium.r2.shared.util.zip.jvm.NonWritableChannelException +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel internal class ResourceChannel( private val resource: Resource diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/zip/StreamingZipArchiveFactory.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/StreamingZipArchiveFactory.kt new file mode 100644 index 0000000000..9e75c84309 --- /dev/null +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/StreamingZipArchiveFactory.kt @@ -0,0 +1,72 @@ +/* + * Copyright 2023 Readium Foundation. All rights reserved. + * Use of this source code is governed by the BSD-style license + * available in the top-level LICENSE file of the project. + */ + +package org.readium.r2.shared.util.zip + +import java.io.File +import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.ArchiveFactory +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.toUrl +import org.readium.r2.shared.util.zip.compress.archivers.zip.ZipFile +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel + +/** + * An [ArchiveFactory] able to open a ZIP archive served through a stream (e.g. HTTP server, + * content URI, etc.). + */ +public class StreamingZipArchiveFactory( + private val mediaTypeRetriever: MediaTypeRetriever +) : ArchiveFactory { + + override suspend fun create( + resource: Resource, + password: String? + ): Try { + if (password != null) { + return Try.failure(ArchiveFactory.Error.PasswordsNotSupported()) + } + + return try { + val resourceChannel = ResourceChannel(resource) + val channel = wrapBaseChannel(resourceChannel) + val zipFile = ZipFile(channel, true) + val channelZip = ChannelZipContainer(zipFile, resource.source, mediaTypeRetriever) + Try.success(channelZip) + } catch (e: Resource.Exception) { + Try.failure(ArchiveFactory.Error.ResourceReading(e)) + } catch (e: Exception) { + Try.failure(ArchiveFactory.Error.FormatNotSupported(e)) + } + } + + internal fun openFile(file: File): Container { + val fileChannel = FileChannelAdapter(file, "r") + val channel = wrapBaseChannel(fileChannel) + return ChannelZipContainer(ZipFile(channel), file.toUrl(), mediaTypeRetriever) + } + + private fun wrapBaseChannel(channel: SeekableByteChannel): SeekableByteChannel { + val size = channel.size() + return if (size < CACHE_ALL_MAX_SIZE) { + CachingReadableChannel(channel, 0) + } else { + val cacheStart = size - CACHED_TAIL_SIZE + val cachingChannel = CachingReadableChannel(channel, cacheStart) + cachingChannel.cache() + BufferedReadableChannel(cachingChannel, DEFAULT_BUFFER_SIZE) + } + } + + public companion object { + + private const val CACHE_ALL_MAX_SIZE = 5242880 + + private const val CACHED_TAIL_SIZE = 65557 + } +} diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveEntry.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveEntry.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveEntry.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveEntry.java index 9a4ad730d1..fac7721cc6 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveEntry.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveEntry.java @@ -17,7 +17,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers; +package org.readium.r2.shared.util.zip.compress.archivers; import java.util.Date; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveInputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveInputStream.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveInputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveInputStream.java index d4ee0e0205..d1a7c7caab 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveInputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveInputStream.java @@ -17,7 +17,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers; +package org.readium.r2.shared.util.zip.compress.archivers; import java.io.IOException; import java.io.InputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveOutputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveOutputStream.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveOutputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveOutputStream.java index 3ce0b05965..4fc9fad419 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/ArchiveOutputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/ArchiveOutputStream.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers; +package org.readium.r2.shared.util.zip.compress.archivers; import java.io.File; import java.io.IOException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/EntryStreamOffsets.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/EntryStreamOffsets.java similarity index 95% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/EntryStreamOffsets.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/EntryStreamOffsets.java index b4a3875e01..faf1c296ba 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/EntryStreamOffsets.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/EntryStreamOffsets.java @@ -17,7 +17,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers; +package org.readium.r2.shared.util.zip.compress.archivers; /** * Provides information about ArchiveEntry stream offsets. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/AbstractUnicodeExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/AbstractUnicodeExtraField.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/AbstractUnicodeExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/AbstractUnicodeExtraField.java index f6abd92938..318335985b 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/AbstractUnicodeExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/AbstractUnicodeExtraField.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/CharsetAccessor.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/CharsetAccessor.java similarity index 95% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/CharsetAccessor.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/CharsetAccessor.java index dadd2634cd..c1ff6936bf 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/CharsetAccessor.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/CharsetAccessor.java @@ -23,7 +23,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.nio.charset.Charset; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ExtraFieldParsingBehavior.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ExtraFieldParsingBehavior.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ExtraFieldParsingBehavior.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ExtraFieldParsingBehavior.java index 8185d5b6ac..a3002d28cd 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ExtraFieldParsingBehavior.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ExtraFieldParsingBehavior.java @@ -21,7 +21,7 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.zip.ZipException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ExtraFieldUtils.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ExtraFieldUtils.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ExtraFieldUtils.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ExtraFieldUtils.java index 8ca535d05f..d69a0da0f2 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ExtraFieldUtils.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ExtraFieldUtils.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.ArrayList; import java.util.List; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/GeneralPurposeBit.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/GeneralPurposeBit.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/GeneralPurposeBit.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/GeneralPurposeBit.java index 865b22f4a1..61fed42c14 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/GeneralPurposeBit.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/GeneralPurposeBit.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * Parser/encoder for the "general purpose bit" field in ZIP's local diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/InflaterInputStreamWithStatistics.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/InflaterInputStreamWithStatistics.java similarity index 93% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/InflaterInputStreamWithStatistics.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/InflaterInputStreamWithStatistics.java index 3f40f0d97d..1436b6dd70 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/InflaterInputStreamWithStatistics.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/InflaterInputStreamWithStatistics.java @@ -22,14 +22,14 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.IOException; import java.io.InputStream; import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; -import org.readium.r2.shared.util.archive.channel.compress.utils.InputStreamStatistics; +import org.readium.r2.shared.util.zip.compress.utils.InputStreamStatistics; /** * Helper class to provide statistics diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/NioZipEncoding.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/NioZipEncoding.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/NioZipEncoding.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/NioZipEncoding.java index 211165fee8..874173f894 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/NioZipEncoding.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/NioZipEncoding.java @@ -23,7 +23,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ResourceAlignmentExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ResourceAlignmentExtraField.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ResourceAlignmentExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ResourceAlignmentExtraField.java index 867e822831..06be121b4f 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ResourceAlignmentExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ResourceAlignmentExtraField.java @@ -22,7 +22,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.zip.ZipException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ScatterStatistics.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ScatterStatistics.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ScatterStatistics.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ScatterStatistics.java index d63a2229b0..6228f1e7a5 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ScatterStatistics.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ScatterStatistics.java @@ -22,7 +22,7 @@ * specific language governing permissions and limitations * under the License. */ - package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; + package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * Provides information about a scatter compression run. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ScatterZipOutputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ScatterZipOutputStream.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ScatterZipOutputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ScatterZipOutputStream.java index 3b173b64bb..6ab714827c 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ScatterZipOutputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ScatterZipOutputStream.java @@ -21,10 +21,10 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import org.readium.r2.shared.util.archive.channel.compress.parallel.ScatterGatherBackingStore; -import org.readium.r2.shared.util.archive.channel.compress.utils.BoundedInputStream; +import org.readium.r2.shared.util.zip.compress.parallel.ScatterGatherBackingStore; +import org.readium.r2.shared.util.zip.compress.utils.BoundedInputStream; import java.io.Closeable; import java.io.IOException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/StreamCompressor.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/StreamCompressor.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/StreamCompressor.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/StreamCompressor.java index 585d1b7608..e51f1b42fa 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/StreamCompressor.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/StreamCompressor.java @@ -21,10 +21,10 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; -import org.readium.r2.shared.util.archive.channel.compress.parallel.ScatterGatherBackingStore; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.compress.parallel.ScatterGatherBackingStore; import java.io.Closeable; import java.io.DataOutput; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnicodeCommentExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnicodeCommentExtraField.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnicodeCommentExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnicodeCommentExtraField.java index dc736812ea..dbd283f09d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnicodeCommentExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnicodeCommentExtraField.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * Info-ZIP Unicode Comment Extra Field (0x6375): diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnicodePathExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnicodePathExtraField.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnicodePathExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnicodePathExtraField.java index 20ce6e7298..44cd3a40d3 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnicodePathExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnicodePathExtraField.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * Info-ZIP Unicode Path Extra Field (0x7075): diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnixStat.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnixStat.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnixStat.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnixStat.java index 91950544ff..7fbc208870 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnixStat.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnixStat.java @@ -22,7 +22,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * Constants from stat.h on Unix systems. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnparseableExtraFieldBehavior.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnparseableExtraFieldBehavior.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnparseableExtraFieldBehavior.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnparseableExtraFieldBehavior.java index 73b5a7a4b0..13733f0d6d 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnparseableExtraFieldBehavior.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnparseableExtraFieldBehavior.java @@ -23,7 +23,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.zip.ZipException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnparseableExtraFieldData.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnparseableExtraFieldData.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnparseableExtraFieldData.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnparseableExtraFieldData.java index 1f9a75b749..6c36c57420 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnparseableExtraFieldData.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnparseableExtraFieldData.java @@ -23,7 +23,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.Arrays; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnrecognizedExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnrecognizedExtraField.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnrecognizedExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnrecognizedExtraField.java index 5b768a425f..2715d07e68 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnrecognizedExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnrecognizedExtraField.java @@ -22,7 +22,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.Arrays; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnsupportedZipFeatureException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnsupportedZipFeatureException.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnsupportedZipFeatureException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnsupportedZipFeatureException.java index b581c80f17..dc7e55d975 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/UnsupportedZipFeatureException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/UnsupportedZipFeatureException.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.Serializable; import java.util.zip.ZipException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64ExtendedInformationExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64ExtendedInformationExtraField.java similarity index 82% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64ExtendedInformationExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64ExtendedInformationExtraField.java index 539dc73580..eb30e49e45 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64ExtendedInformationExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64ExtendedInformationExtraField.java @@ -22,12 +22,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.DWORD; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.WORD; - -import org.readium.r2.shared.util.archive.channel.compress.utils.ByteUtils; +import org.readium.r2.shared.util.zip.compress.utils.ByteUtils; import java.util.zip.ZipException; @@ -112,12 +109,12 @@ public Zip64ExtendedInformationExtraField(final ZipEightByteInteger size, private int addSizes(final byte[] data) { int off = 0; if (size != null) { - System.arraycopy(size.getBytes(), 0, data, 0, DWORD); - off += DWORD; + System.arraycopy(size.getBytes(), 0, data, 0, ZipConstants.DWORD); + off += ZipConstants.DWORD; } if (compressedSize != null) { - System.arraycopy(compressedSize.getBytes(), 0, data, off, DWORD); - off += DWORD; + System.arraycopy(compressedSize.getBytes(), 0, data, off, ZipConstants.DWORD); + off += ZipConstants.DWORD; } return off; } @@ -127,22 +124,22 @@ public byte[] getCentralDirectoryData() { final byte[] data = new byte[getCentralDirectoryLength().getValue()]; int off = addSizes(data); if (relativeHeaderOffset != null) { - System.arraycopy(relativeHeaderOffset.getBytes(), 0, data, off, DWORD); - off += DWORD; + System.arraycopy(relativeHeaderOffset.getBytes(), 0, data, off, ZipConstants.DWORD); + off += ZipConstants.DWORD; } if (diskStart != null) { - System.arraycopy(diskStart.getBytes(), 0, data, off, WORD); - off += WORD; // NOSONAR - assignment as documentation + System.arraycopy(diskStart.getBytes(), 0, data, off, ZipConstants.WORD); + off += ZipConstants.WORD; // NOSONAR - assignment as documentation } return data; } @Override public ZipShort getCentralDirectoryLength() { - return new ZipShort((size != null ? DWORD : 0) - + (compressedSize != null ? DWORD : 0) - + (relativeHeaderOffset != null ? DWORD : 0) - + (diskStart != null ? WORD : 0)); + return new ZipShort((size != null ? ZipConstants.DWORD : 0) + + (compressedSize != null ? ZipConstants.DWORD : 0) + + (relativeHeaderOffset != null ? ZipConstants.DWORD : 0) + + (diskStart != null ? ZipConstants.WORD : 0)); } /** @@ -172,7 +169,7 @@ public byte[] getLocalFileDataData() { if (size == null || compressedSize == null) { throw new IllegalArgumentException(LFH_MUST_HAVE_BOTH_SIZES_MSG); } - final byte[] data = new byte[2 * DWORD]; + final byte[] data = new byte[2 * ZipConstants.DWORD]; addSizes(data); return data; } @@ -181,7 +178,7 @@ public byte[] getLocalFileDataData() { @Override public ZipShort getLocalFileDataLength() { - return new ZipShort(size != null ? 2 * DWORD : 0); + return new ZipShort(size != null ? 2 * ZipConstants.DWORD : 0); } /** @@ -214,16 +211,16 @@ public void parseFromCentralDirectoryData(final byte[] buffer, int offset, // * all data is there // * length == 24 -> both sizes and offset // * length % 8 == 4 -> at least we can identify the diskStart field - if (length >= 3 * DWORD + WORD) { + if (length >= 3 * ZipConstants.DWORD + ZipConstants.WORD) { parseFromLocalFileData(buffer, offset, length); - } else if (length == 3 * DWORD) { + } else if (length == 3 * ZipConstants.DWORD) { size = new ZipEightByteInteger(buffer, offset); - offset += DWORD; + offset += ZipConstants.DWORD; compressedSize = new ZipEightByteInteger(buffer, offset); - offset += DWORD; + offset += ZipConstants.DWORD; relativeHeaderOffset = new ZipEightByteInteger(buffer, offset); - } else if (length % DWORD == WORD) { - diskStart = new ZipLong(buffer, offset + length - WORD); + } else if (length % ZipConstants.DWORD == ZipConstants.WORD) { + diskStart = new ZipLong(buffer, offset + length - ZipConstants.WORD); } } @@ -237,23 +234,23 @@ public void parseFromLocalFileData(final byte[] buffer, int offset, final int le // file header return; } - if (length < 2 * DWORD) { + if (length < 2 * ZipConstants.DWORD) { throw new ZipException(LFH_MUST_HAVE_BOTH_SIZES_MSG); } size = new ZipEightByteInteger(buffer, offset); - offset += DWORD; + offset += ZipConstants.DWORD; compressedSize = new ZipEightByteInteger(buffer, offset); - offset += DWORD; - int remaining = length - 2 * DWORD; - if (remaining >= DWORD) { + offset += ZipConstants.DWORD; + int remaining = length - 2 * ZipConstants.DWORD; + if (remaining >= ZipConstants.DWORD) { relativeHeaderOffset = new ZipEightByteInteger(buffer, offset); - offset += DWORD; - remaining -= DWORD; + offset += ZipConstants.DWORD; + remaining -= ZipConstants.DWORD; } - if (remaining >= WORD) { + if (remaining >= ZipConstants.WORD) { diskStart = new ZipLong(buffer, offset); - offset += WORD; // NOSONAR - assignment as documentation - remaining -= WORD; // NOSONAR - assignment as documentation + offset += ZipConstants.WORD; // NOSONAR - assignment as documentation + remaining -= ZipConstants.WORD; // NOSONAR - assignment as documentation } } @@ -278,10 +275,10 @@ public void reparseCentralDirectoryData(final boolean hasUncompressedSize, final boolean hasDiskStart) throws ZipException { if (rawCentralDirectoryData != null) { - final int expectedLength = (hasUncompressedSize ? DWORD : 0) - + (hasCompressedSize ? DWORD : 0) - + (hasRelativeHeaderOffset ? DWORD : 0) - + (hasDiskStart ? WORD : 0); + final int expectedLength = (hasUncompressedSize ? ZipConstants.DWORD : 0) + + (hasCompressedSize ? ZipConstants.DWORD : 0) + + (hasRelativeHeaderOffset ? ZipConstants.DWORD : 0) + + (hasDiskStart ? ZipConstants.WORD : 0); if (rawCentralDirectoryData.length < expectedLength) { throw new ZipException("Central directory zip64 extended" + " information extra field's length" @@ -293,21 +290,21 @@ public void reparseCentralDirectoryData(final boolean hasUncompressedSize, int offset = 0; if (hasUncompressedSize) { size = new ZipEightByteInteger(rawCentralDirectoryData, offset); - offset += DWORD; + offset += ZipConstants.DWORD; } if (hasCompressedSize) { compressedSize = new ZipEightByteInteger(rawCentralDirectoryData, offset); - offset += DWORD; + offset += ZipConstants.DWORD; } if (hasRelativeHeaderOffset) { relativeHeaderOffset = new ZipEightByteInteger(rawCentralDirectoryData, offset); - offset += DWORD; + offset += ZipConstants.DWORD; } if (hasDiskStart) { diskStart = new ZipLong(rawCentralDirectoryData, offset); - offset += WORD; // NOSONAR - assignment as documentation + offset += ZipConstants.WORD; // NOSONAR - assignment as documentation } } } diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64Mode.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64Mode.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64Mode.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64Mode.java index 60c1603973..6d6d306f61 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64Mode.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64Mode.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * The different modes {@link ZipArchiveOutputStream} can operate in. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64RequiredException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64RequiredException.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64RequiredException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64RequiredException.java index a8fa086f7f..1d17bdce36 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/Zip64RequiredException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/Zip64RequiredException.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.zip.ZipException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntry.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntry.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntry.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntry.java index 0bf633d423..ce4f767bae 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntry.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntry.java @@ -21,11 +21,11 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import org.readium.r2.shared.util.archive.channel.compress.archivers.ArchiveEntry; -import org.readium.r2.shared.util.archive.channel.compress.archivers.EntryStreamOffsets; -import org.readium.r2.shared.util.archive.channel.compress.utils.ByteUtils; +import org.readium.r2.shared.util.zip.compress.archivers.ArchiveEntry; +import org.readium.r2.shared.util.zip.compress.archivers.EntryStreamOffsets; +import org.readium.r2.shared.util.zip.compress.utils.ByteUtils; import java.io.File; import java.nio.file.attribute.FileTime; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntryPredicate.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntryPredicate.java similarity index 95% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntryPredicate.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntryPredicate.java index 8036f37b5c..dd330cf36f 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntryPredicate.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntryPredicate.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * A predicate to test if a #ZipArchiveEntry matches a criteria. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntryRequest.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntryRequest.java similarity index 94% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntryRequest.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntryRequest.java index e0b7d635b1..9066ebb792 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveEntryRequest.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveEntryRequest.java @@ -21,9 +21,9 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import org.readium.r2.shared.util.archive.channel.compress.parallel.InputStreamSupplier; +import org.readium.r2.shared.util.zip.compress.parallel.InputStreamSupplier; import java.io.InputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveOutputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveOutputStream.java similarity index 92% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveOutputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveOutputStream.java index c73b04e124..08a93d5180 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipArchiveOutputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipArchiveOutputStream.java @@ -21,23 +21,14 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; - -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.DATA_DESCRIPTOR_MIN_VERSION; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.DEFLATE_MIN_VERSION; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.DWORD; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.INITIAL_VERSION; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.SHORT; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.WORD; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.ZIP64_MAGIC; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.ZIP64_MAGIC_SHORT; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipConstants.ZIP64_MIN_VERSION; -import static org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipLong.putLong; - -import org.readium.r2.shared.util.archive.channel.compress.archivers.ArchiveEntry; -import org.readium.r2.shared.util.archive.channel.compress.archivers.ArchiveOutputStream; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; -import org.readium.r2.shared.util.archive.channel.compress.utils.ByteUtils; +package org.readium.r2.shared.util.zip.compress.archivers.zip; + +import static org.readium.r2.shared.util.zip.compress.archivers.zip.ZipLong.putLong; + +import org.readium.r2.shared.util.zip.compress.archivers.ArchiveEntry; +import org.readium.r2.shared.util.zip.compress.archivers.ArchiveOutputStream; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.compress.utils.ByteUtils; import java.io.ByteArrayOutputStream; import java.io.File; @@ -661,10 +652,10 @@ private byte[] createCentralFileHeader(final ZipArchiveEntry ze) throws IOExcept final EntryMetaData entryMetaData = metaData.get(ze); final boolean needsZip64Extra = hasZip64Extra(ze) - || ze.getCompressedSize() >= ZIP64_MAGIC - || ze.getSize() >= ZIP64_MAGIC - || entryMetaData.offset >= ZIP64_MAGIC - || ze.getDiskNumberStart() >= ZIP64_MAGIC_SHORT + || ze.getCompressedSize() >= ZipConstants.ZIP64_MAGIC + || ze.getSize() >= ZipConstants.ZIP64_MAGIC + || entryMetaData.offset >= ZipConstants.ZIP64_MAGIC + || ze.getDiskNumberStart() >= ZipConstants.ZIP64_MAGIC_SHORT || zip64Mode == Zip64Mode.Always || zip64Mode == Zip64Mode.AlwaysWithCompatibility; @@ -719,11 +710,11 @@ private byte[] createCentralFileHeader(final ZipArchiveEntry ze, final ByteBuffe final int len= CFH_FILENAME_OFFSET + nameLen + extraLength + commentLen; final byte[] buf = new byte[len]; - System.arraycopy(CFH_SIG, 0, buf, CFH_SIG_OFFSET, WORD); + System.arraycopy(CFH_SIG, 0, buf, CFH_SIG_OFFSET, ZipConstants.WORD); // version made by // CheckStyle:MagicNumber OFF - ZipShort.putShort((ze.getPlatform() << 8) | (!hasUsedZip64 ? DATA_DESCRIPTOR_MIN_VERSION : ZIP64_MIN_VERSION), + ZipShort.putShort((ze.getPlatform() << 8) | (!hasUsedZip64 ? ZipConstants.DATA_DESCRIPTOR_MIN_VERSION : ZipConstants.ZIP64_MIN_VERSION), buf, CFH_VERSION_MADE_BY_OFFSET); final int zipMethod = ze.getMethod(); @@ -743,8 +734,8 @@ private byte[] createCentralFileHeader(final ZipArchiveEntry ze, final ByteBuffe // compressed length // uncompressed length putLong(ze.getCrc(), buf, CFH_CRC_OFFSET); - if (ze.getCompressedSize() >= ZIP64_MAGIC - || ze.getSize() >= ZIP64_MAGIC + if (ze.getCompressedSize() >= ZipConstants.ZIP64_MAGIC + || ze.getSize() >= ZipConstants.ZIP64_MAGIC || zip64Mode == Zip64Mode.Always || zip64Mode == Zip64Mode.AlwaysWithCompatibility) { ZipLong.ZIP64_MAGIC.putLong(buf, CFH_COMPRESSED_SIZE_OFFSET); @@ -763,13 +754,13 @@ private byte[] createCentralFileHeader(final ZipArchiveEntry ze, final ByteBuffe // disk number start if(isSplitZip) { - if (ze.getDiskNumberStart() >= ZIP64_MAGIC_SHORT || zip64Mode == Zip64Mode.Always) { - ZipShort.putShort(ZIP64_MAGIC_SHORT, buf, CFH_DISK_NUMBER_OFFSET); + if (ze.getDiskNumberStart() >= ZipConstants.ZIP64_MAGIC_SHORT || zip64Mode == Zip64Mode.Always) { + ZipShort.putShort(ZipConstants.ZIP64_MAGIC_SHORT, buf, CFH_DISK_NUMBER_OFFSET); } else { ZipShort.putShort((int) ze.getDiskNumberStart(), buf, CFH_DISK_NUMBER_OFFSET); } } else { - System.arraycopy(ZERO, 0, buf, CFH_DISK_NUMBER_OFFSET, SHORT); + System.arraycopy(ZERO, 0, buf, CFH_DISK_NUMBER_OFFSET, ZipConstants.SHORT); } // internal file attributes @@ -779,10 +770,10 @@ private byte[] createCentralFileHeader(final ZipArchiveEntry ze, final ByteBuffe putLong(ze.getExternalAttributes(), buf, CFH_EXTERNAL_ATTRIBUTES_OFFSET); // relative offset of LFH - if (entryMetaData.offset >= ZIP64_MAGIC || zip64Mode == Zip64Mode.Always) { - putLong(ZIP64_MAGIC, buf, CFH_LFH_OFFSET); + if (entryMetaData.offset >= ZipConstants.ZIP64_MAGIC || zip64Mode == Zip64Mode.Always) { + putLong(ZipConstants.ZIP64_MAGIC, buf, CFH_LFH_OFFSET); } else { - putLong(Math.min(entryMetaData.offset, ZIP64_MAGIC), buf, CFH_LFH_OFFSET); + putLong(Math.min(entryMetaData.offset, ZipConstants.ZIP64_MAGIC), buf, CFH_LFH_OFFSET); } // file name @@ -829,7 +820,7 @@ private byte[] createLocalFileHeader(final ZipArchiveEntry ze, final ByteBuffer final int len = LFH_FILENAME_OFFSET + nameLen + extra.length; final byte[] buf = new byte[len]; - System.arraycopy(LFH_SIG, 0, buf, LFH_SIG_OFFSET, WORD); + System.arraycopy(LFH_SIG, 0, buf, LFH_SIG_OFFSET, ZipConstants.WORD); //store method in local variable to prevent multiple method calls final int zipMethod = ze.getMethod(); @@ -849,7 +840,7 @@ private byte[] createLocalFileHeader(final ZipArchiveEntry ze, final ByteBuffer if (phased || !(zipMethod == DEFLATED || channel != null)){ putLong(ze.getCrc(), buf, LFH_CRC_OFFSET); } else { - System.arraycopy(LZERO, 0, buf, LFH_CRC_OFFSET, WORD); + System.arraycopy(LZERO, 0, buf, LFH_CRC_OFFSET, ZipConstants.WORD); } // compressed length @@ -864,8 +855,8 @@ private byte[] createLocalFileHeader(final ZipArchiveEntry ze, final ByteBuffer putLong(ze.getCompressedSize(), buf, LFH_COMPRESSED_SIZE_OFFSET); putLong(ze.getSize(), buf, LFH_ORIGINAL_SIZE_OFFSET); } else if (zipMethod == DEFLATED || channel != null) { - System.arraycopy(LZERO, 0, buf, LFH_COMPRESSED_SIZE_OFFSET, WORD); - System.arraycopy(LZERO, 0, buf, LFH_ORIGINAL_SIZE_OFFSET, WORD); + System.arraycopy(LZERO, 0, buf, LFH_COMPRESSED_SIZE_OFFSET, ZipConstants.WORD); + System.arraycopy(LZERO, 0, buf, LFH_ORIGINAL_SIZE_OFFSET, ZipConstants.WORD); } else { // Stored putLong(ze.getSize(), buf, LFH_COMPRESSED_SIZE_OFFSET); putLong(ze.getSize(), buf, LFH_ORIGINAL_SIZE_OFFSET); @@ -944,14 +935,14 @@ public void finish() throws IOException { // calculate the length of end of central directory, as it may be used in writeZip64CentralDirectory final ByteBuffer commentData = this.zipEncoding.encode(comment); final long commentLength = (long) commentData.limit() - commentData.position(); - eocdLength = WORD /* length of EOCD_SIG */ - + SHORT /* number of this disk */ - + SHORT /* disk number of start of central directory */ - + SHORT /* total number of entries on this disk */ - + SHORT /* total number of entries */ - + WORD /* size of central directory */ - + WORD /* offset of start of central directory */ - + SHORT /* zip comment length */ + eocdLength = ZipConstants.WORD /* length of EOCD_SIG */ + + ZipConstants.SHORT /* number of this disk */ + + ZipConstants.SHORT /* disk number of start of central directory */ + + ZipConstants.SHORT /* total number of entries on this disk */ + + ZipConstants.SHORT /* total number of entries */ + + ZipConstants.WORD /* size of central directory */ + + ZipConstants.WORD /* offset of start of central directory */ + + ZipConstants.SHORT /* zip comment length */ + commentLength /* zip comment */; writeZip64CentralDirectory(); @@ -1125,8 +1116,8 @@ private void handleZip64Extra(final ZipArchiveEntry ze, final long lfhOffset, final boolean needsZip64Extra) { if (needsZip64Extra) { final Zip64ExtendedInformationExtraField z64 = getZip64Extra(ze); - if (ze.getCompressedSize() >= ZIP64_MAGIC - || ze.getSize() >= ZIP64_MAGIC + if (ze.getCompressedSize() >= ZipConstants.ZIP64_MAGIC + || ze.getSize() >= ZipConstants.ZIP64_MAGIC || zip64Mode == Zip64Mode.Always || zip64Mode == Zip64Mode.AlwaysWithCompatibility) { z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize())); @@ -1138,9 +1129,9 @@ private void handleZip64Extra(final ZipArchiveEntry ze, final long lfhOffset, } final boolean needsToEncodeLfhOffset = - lfhOffset >= ZIP64_MAGIC || zip64Mode == Zip64Mode.Always; + lfhOffset >= ZipConstants.ZIP64_MAGIC || zip64Mode == Zip64Mode.Always; final boolean needsToEncodeDiskNumberStart = - ze.getDiskNumberStart() >= ZIP64_MAGIC_SHORT || zip64Mode == Zip64Mode.Always; + ze.getDiskNumberStart() >= ZipConstants.ZIP64_MAGIC_SHORT || zip64Mode == Zip64Mode.Always; if (needsToEncodeLfhOffset || needsToEncodeDiskNumberStart) { z64.setRelativeHeaderOffset(new ZipEightByteInteger(lfhOffset)); @@ -1176,7 +1167,7 @@ public boolean isSeekable() { return channel != null; } private boolean isTooLargeForZip32(final ZipArchiveEntry zipArchiveEntry){ - return zipArchiveEntry.getSize() >= ZIP64_MAGIC || zipArchiveEntry.getCompressedSize() >= ZIP64_MAGIC; + return zipArchiveEntry.getSize() >= ZipConstants.ZIP64_MAGIC || zipArchiveEntry.getCompressedSize() >= ZipConstants.ZIP64_MAGIC; } private boolean isZip64Required(final ZipArchiveEntry entry1, final Zip64Mode requestedMode) { return requestedMode == Zip64Mode.Always || requestedMode == Zip64Mode.AlwaysWithCompatibility @@ -1290,8 +1281,8 @@ private void rewriteSizesAndCrc(final boolean actuallyNeedsZip64) final ByteBuffer name = getName(entry.entry); final int nameLen = name.limit() - name.position(); // seek to ZIP64 extra, skip header and size information - channel.position(entry.localDataStart + 3 * WORD + 2 * SHORT - + nameLen + 2 * SHORT); + channel.position(entry.localDataStart + 3 * ZipConstants.WORD + 2 * ZipConstants.SHORT + + nameLen + 2 * ZipConstants.SHORT); // inside the ZIP64 extra uncompressed size comes // first, unlike the LFH, CD or data descriptor writeOut(ZipEightByteInteger.getBytes(entry.entry.getSize())); @@ -1300,7 +1291,7 @@ private void rewriteSizesAndCrc(final boolean actuallyNeedsZip64) if (!actuallyNeedsZip64) { // do some cleanup: // * rewrite version needed to extract - channel.position(entry.localDataStart - 5 * SHORT); + channel.position(entry.localDataStart - 5 * ZipConstants.SHORT); writeOut(ZipShort.getBytes(versionNeededToExtract(entry.entry.getMethod(), false, false))); // * remove ZIP64 extra so it doesn't get written @@ -1493,8 +1484,8 @@ public void setUseZip64(final Zip64Mode mode) { private boolean shouldAddZip64Extra(final ZipArchiveEntry entry, final Zip64Mode mode) { return mode == Zip64Mode.Always || mode == Zip64Mode.AlwaysWithCompatibility - || entry.getSize() >= ZIP64_MAGIC - || entry.getCompressedSize() >= ZIP64_MAGIC + || entry.getSize() >= ZipConstants.ZIP64_MAGIC + || entry.getCompressedSize() >= ZipConstants.ZIP64_MAGIC || (entry.getSize() == ArchiveEntry.SIZE_UNKNOWN && channel != null && mode != Zip64Mode.Never); } @@ -1512,12 +1503,12 @@ private boolean shouldUseZip64EOCD() { numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex(); } final int numOfEntriesOnThisDisk = numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk); - return numberOfThisDisk >= ZIP64_MAGIC_SHORT /* number of this disk */ - || cdDiskNumberStart >= ZIP64_MAGIC_SHORT /* number of the disk with the start of the central directory */ - || numOfEntriesOnThisDisk >= ZIP64_MAGIC_SHORT /* total number of entries in the central directory on this disk */ - || entries.size() >= ZIP64_MAGIC_SHORT /* total number of entries in the central directory */ - || cdLength >= ZIP64_MAGIC /* size of the central directory */ - || cdOffset >= ZIP64_MAGIC; /* offset of start of central directory with respect to + return numberOfThisDisk >= ZipConstants.ZIP64_MAGIC_SHORT /* number of this disk */ + || cdDiskNumberStart >= ZipConstants.ZIP64_MAGIC_SHORT /* number of the disk with the start of the central directory */ + || numOfEntriesOnThisDisk >= ZipConstants.ZIP64_MAGIC_SHORT /* total number of entries in the central directory on this disk */ + || entries.size() >= ZipConstants.ZIP64_MAGIC_SHORT /* total number of entries in the central directory */ + || cdLength >= ZipConstants.ZIP64_MAGIC /* size of the central directory */ + || cdOffset >= ZipConstants.ZIP64_MAGIC; /* offset of start of central directory with respect to the starting disk number */ } @@ -1540,35 +1531,35 @@ private void validateIfZip64IsNeededInEOCD() throws Zip64RequiredException { if (isSplitZip) { numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex(); } - if (numberOfThisDisk >= ZIP64_MAGIC_SHORT) { + if (numberOfThisDisk >= ZipConstants.ZIP64_MAGIC_SHORT) { throw new Zip64RequiredException(Zip64RequiredException .NUMBER_OF_THIS_DISK_TOO_BIG_MESSAGE); } - if (cdDiskNumberStart >= ZIP64_MAGIC_SHORT) { + if (cdDiskNumberStart >= ZipConstants.ZIP64_MAGIC_SHORT) { throw new Zip64RequiredException(Zip64RequiredException .NUMBER_OF_THE_DISK_OF_CENTRAL_DIRECTORY_TOO_BIG_MESSAGE); } final int numOfEntriesOnThisDisk = numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk); - if (numOfEntriesOnThisDisk >= ZIP64_MAGIC_SHORT) { + if (numOfEntriesOnThisDisk >= ZipConstants.ZIP64_MAGIC_SHORT) { throw new Zip64RequiredException(Zip64RequiredException .TOO_MANY_ENTRIES_ON_THIS_DISK_MESSAGE); } // number of entries - if (entries.size() >= ZIP64_MAGIC_SHORT) { + if (entries.size() >= ZipConstants.ZIP64_MAGIC_SHORT) { throw new Zip64RequiredException(Zip64RequiredException .TOO_MANY_ENTRIES_MESSAGE); } - if (cdLength >= ZIP64_MAGIC) { + if (cdLength >= ZipConstants.ZIP64_MAGIC) { throw new Zip64RequiredException(Zip64RequiredException .SIZE_OF_CENTRAL_DIRECTORY_TOO_BIG_MESSAGE); } - if (cdOffset >= ZIP64_MAGIC) { + if (cdOffset >= ZipConstants.ZIP64_MAGIC) { throw new Zip64RequiredException(Zip64RequiredException .ARCHIVE_TOO_BIG_MESSAGE); } @@ -1597,8 +1588,8 @@ private void validateSizeInformation(final Zip64Mode effectiveMode) entry.entry.setCompressedSize(entry.entry.getSize()); } - if ((entry.entry.getSize() >= ZIP64_MAGIC - || entry.entry.getCompressedSize() >= ZIP64_MAGIC) + if ((entry.entry.getSize() >= ZipConstants.ZIP64_MAGIC + || entry.entry.getCompressedSize() >= ZipConstants.ZIP64_MAGIC) && effectiveMode == Zip64Mode.Never) { throw new Zip64RequiredException(Zip64RequiredException .getEntryTooBigMessage(entry.entry)); @@ -1608,16 +1599,16 @@ private void validateSizeInformation(final Zip64Mode effectiveMode) private int versionNeededToExtract(final int zipMethod, final boolean zip64, final boolean usedDataDescriptor) { if (zip64) { - return ZIP64_MIN_VERSION; + return ZipConstants.ZIP64_MIN_VERSION; } if (usedDataDescriptor) { - return DATA_DESCRIPTOR_MIN_VERSION; + return ZipConstants.DATA_DESCRIPTOR_MIN_VERSION; } return versionNeededToExtractMethod(zipMethod); } private int versionNeededToExtractMethod(final int zipMethod) { - return zipMethod == DEFLATED ? DEFLATE_MIN_VERSION : INITIAL_VERSION; + return zipMethod == DEFLATED ? ZipConstants.DEFLATE_MIN_VERSION : ZipConstants.INITIAL_VERSION; } /** @@ -1671,17 +1662,17 @@ protected void writeCentralDirectoryEnd() throws IOException { ? (numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk)) : numberOfEntries; final byte[] numOfEntriesOnThisDiskData = ZipShort - .getBytes(Math.min(numOfEntriesOnThisDisk, ZIP64_MAGIC_SHORT)); + .getBytes(Math.min(numOfEntriesOnThisDisk, ZipConstants.ZIP64_MAGIC_SHORT)); writeCounted(numOfEntriesOnThisDiskData); // number of entries final byte[] num = ZipShort.getBytes(Math.min(numberOfEntries, - ZIP64_MAGIC_SHORT)); + ZipConstants.ZIP64_MAGIC_SHORT)); writeCounted(num); // length and location of CD - writeCounted(ZipLong.getBytes(Math.min(cdLength, ZIP64_MAGIC))); - writeCounted(ZipLong.getBytes(Math.min(cdOffset, ZIP64_MAGIC))); + writeCounted(ZipLong.getBytes(Math.min(cdLength, ZipConstants.ZIP64_MAGIC))); + writeCounted(ZipLong.getBytes(Math.min(cdOffset, ZipConstants.ZIP64_MAGIC))); // ZIP file comment final ByteBuffer data = this.zipEncoding.encode(comment); @@ -1865,19 +1856,19 @@ protected void writeZip64CentralDirectory() throws IOException { // size of zip64 end of central directory, we don't have any variable length // as we don't support the extensible data sector, yet writeOut(ZipEightByteInteger - .getBytes(SHORT /* version made by */ - + SHORT /* version needed to extract */ - + WORD /* disk number */ - + WORD /* disk with central directory */ - + DWORD /* number of entries in CD on this disk */ - + DWORD /* total number of entries */ - + DWORD /* size of CD */ - + (long) DWORD /* offset of CD */ + .getBytes(ZipConstants.SHORT /* version made by */ + + ZipConstants.SHORT /* version needed to extract */ + + ZipConstants.WORD /* disk number */ + + ZipConstants.WORD /* disk with central directory */ + + ZipConstants.DWORD /* number of entries in CD on this disk */ + + ZipConstants.DWORD /* total number of entries */ + + ZipConstants.DWORD /* size of CD */ + + (long) ZipConstants.DWORD /* offset of CD */ )); // version made by and version needed to extract - writeOut(ZipShort.getBytes(ZIP64_MIN_VERSION)); - writeOut(ZipShort.getBytes(ZIP64_MIN_VERSION)); + writeOut(ZipShort.getBytes(ZipConstants.ZIP64_MIN_VERSION)); + writeOut(ZipShort.getBytes(ZipConstants.ZIP64_MIN_VERSION)); // number of this disk int numberOfThisDisk = 0; @@ -1909,10 +1900,10 @@ protected void writeZip64CentralDirectory() throws IOException { if(isSplitZip) { // based on the zip specification, the End Of Central Directory record and // the Zip64 End Of Central Directory locator record must be on the same segment - final int zip64EOCDLOCLength = WORD /* length of ZIP64_EOCD_LOC_SIG */ - + WORD /* disk number of ZIP64_EOCD_SIG */ - + DWORD /* offset of ZIP64_EOCD_SIG */ - + WORD /* total number of disks */; + final int zip64EOCDLOCLength = ZipConstants.WORD /* length of ZIP64_EOCD_LOC_SIG */ + + ZipConstants.WORD /* disk number of ZIP64_EOCD_SIG */ + + ZipConstants.DWORD /* offset of ZIP64_EOCD_SIG */ + + ZipConstants.WORD /* total number of disks */; final long unsplittableContentSize = zip64EOCDLOCLength + eocdLength; ((ZipSplitOutputStream)this.outputStream).prepareToWriteUnsplittableContent(unsplittableContentSize); diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipConstants.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipConstants.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipConstants.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipConstants.java index 17fbdbdc24..cb9c972af3 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipConstants.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipConstants.java @@ -21,7 +21,7 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; /** * Various constants used throughout the package. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEightByteInteger.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEightByteInteger.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEightByteInteger.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEightByteInteger.java index aa9418c8c2..b1cabdde09 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEightByteInteger.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEightByteInteger.java @@ -21,7 +21,7 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.Serializable; import java.math.BigInteger; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEncoding.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEncoding.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEncoding.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEncoding.java index 24fed12401..3a4271fa19 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEncoding.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEncoding.java @@ -23,7 +23,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEncodingHelper.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEncodingHelper.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEncodingHelper.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEncodingHelper.java index fd274885f5..7fbd472f76 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipEncodingHelper.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipEncodingHelper.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipExtraField.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipExtraField.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipExtraField.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipExtraField.java index aebb68e940..176e6cdecd 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipExtraField.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipExtraField.java @@ -22,7 +22,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.zip.ZipException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipFile.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipFile.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipFile.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipFile.java index a787d5bf30..69c2a03b4a 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipFile.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipFile.java @@ -22,15 +22,15 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; - -import org.readium.r2.shared.util.archive.channel.compress.archivers.EntryStreamOffsets; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; -import org.readium.r2.shared.util.archive.channel.compress.utils.BoundedArchiveInputStream; -import org.readium.r2.shared.util.archive.channel.compress.utils.BoundedSeekableByteChannelInputStream; -import org.readium.r2.shared.util.archive.channel.compress.utils.CountingInputStream; -import org.readium.r2.shared.util.archive.channel.compress.utils.IOUtils; -import org.readium.r2.shared.util.archive.channel.compress.utils.InputStreamStatistics; +package org.readium.r2.shared.util.zip.compress.archivers.zip; + +import org.readium.r2.shared.util.zip.compress.archivers.EntryStreamOffsets; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.compress.utils.BoundedArchiveInputStream; +import org.readium.r2.shared.util.zip.compress.utils.BoundedSeekableByteChannelInputStream; +import org.readium.r2.shared.util.zip.compress.utils.CountingInputStream; +import org.readium.r2.shared.util.zip.compress.utils.IOUtils; +import org.readium.r2.shared.util.zip.compress.utils.InputStreamStatistics; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipLong.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipLong.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipLong.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipLong.java index 8628034e6d..aceb66da69 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipLong.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipLong.java @@ -21,11 +21,11 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.Serializable; -import org.readium.r2.shared.util.archive.channel.compress.utils.ByteUtils; +import org.readium.r2.shared.util.zip.compress.utils.ByteUtils; /** * Utility class that represents a four byte integer with conversion diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipMethod.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipMethod.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipMethod.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipMethod.java index 2726e45208..a1fb23b805 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipMethod.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipMethod.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.util.Collections; import java.util.HashMap; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipShort.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipShort.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipShort.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipShort.java index 3f50790eb1..8f3e5377d4 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipShort.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipShort.java @@ -21,9 +21,9 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import org.readium.r2.shared.util.archive.channel.compress.utils.ByteUtils; +import org.readium.r2.shared.util.zip.compress.utils.ByteUtils; import java.io.Serializable; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipSplitOutputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipSplitOutputStream.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipSplitOutputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipSplitOutputStream.java index e6c05d89e0..97695a3bc3 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipSplitOutputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipSplitOutputStream.java @@ -22,9 +22,9 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; -import org.readium.r2.shared.util.archive.channel.compress.utils.FileNameUtils; +import org.readium.r2.shared.util.zip.compress.utils.FileNameUtils; import java.io.File; import java.io.FileOutputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java index 6cabfe77c3..fcd0419394 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java @@ -22,7 +22,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.IOException; import java.nio.ByteBuffer; @@ -32,8 +32,8 @@ import java.util.List; import java.util.Objects; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; -import org.readium.r2.shared.util.archive.channel.compress.utils.MultiReadOnlySeekableByteChannel; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.compress.utils.MultiReadOnlySeekableByteChannel; /** * {@link MultiReadOnlySeekableByteChannel} that knows what a split ZIP archive should look like. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipUtil.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipUtil.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipUtil.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipUtil.java index 5c1f749cf3..838b9e1f38 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/archivers/zip/ZipUtil.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/archivers/zip/ZipUtil.java @@ -21,7 +21,7 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.archivers.zip; +package org.readium.r2.shared.util.zip.compress.archivers.zip; import java.io.IOException; import java.math.BigInteger; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/InputStreamSupplier.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/InputStreamSupplier.java similarity index 94% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/InputStreamSupplier.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/InputStreamSupplier.java index a9b437670e..7d9f8f314b 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/InputStreamSupplier.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/InputStreamSupplier.java @@ -17,7 +17,7 @@ * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.parallel; +package org.readium.r2.shared.util.zip.compress.parallel; import java.io.InputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/ScatterGatherBackingStore.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/ScatterGatherBackingStore.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/ScatterGatherBackingStore.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/ScatterGatherBackingStore.java index 6a8df42335..5a5d7a6d7f 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/ScatterGatherBackingStore.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/ScatterGatherBackingStore.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.parallel; +package org.readium.r2.shared.util.zip.compress.parallel; import java.io.Closeable; import java.io.IOException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/ScatterGatherBackingStoreSupplier.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/ScatterGatherBackingStoreSupplier.java similarity index 94% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/ScatterGatherBackingStoreSupplier.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/ScatterGatherBackingStoreSupplier.java index 395bf2974c..f9a3a5b528 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/parallel/ScatterGatherBackingStoreSupplier.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/parallel/ScatterGatherBackingStoreSupplier.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.parallel; +package org.readium.r2.shared.util.zip.compress.parallel; import java.io.IOException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedArchiveInputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedArchiveInputStream.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedArchiveInputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedArchiveInputStream.java index 4677fd4d56..926df52ea2 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedArchiveInputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedArchiveInputStream.java @@ -16,7 +16,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; import java.io.IOException; import java.io.InputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedInputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedInputStream.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedInputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedInputStream.java index 11fd2ec6f0..23bd67b0f5 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedInputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedInputStream.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; import java.io.IOException; import java.io.InputStream; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedSeekableByteChannelInputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedSeekableByteChannelInputStream.java similarity index 93% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedSeekableByteChannelInputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedSeekableByteChannelInputStream.java index f25e923d4d..6fe865ee3c 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/BoundedSeekableByteChannelInputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/BoundedSeekableByteChannelInputStream.java @@ -16,9 +16,9 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/ByteUtils.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/ByteUtils.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/ByteUtils.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/ByteUtils.java index 7eb01be2d3..8ef7152905 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/ByteUtils.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/ByteUtils.java @@ -16,7 +16,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; import java.io.DataInput; import java.io.DataOutput; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/CountingInputStream.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/CountingInputStream.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/CountingInputStream.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/CountingInputStream.java index 2a5164cb80..016f5f7c43 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/CountingInputStream.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/CountingInputStream.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; import java.io.FilterInputStream; import java.io.IOException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/FileNameUtils.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/FileNameUtils.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/FileNameUtils.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/FileNameUtils.java index e27a8a57ee..27dd488ecf 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/FileNameUtils.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/FileNameUtils.java @@ -16,7 +16,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; import java.io.File; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/IOUtils.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/IOUtils.java similarity index 98% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/IOUtils.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/IOUtils.java index fb4e243e11..a27ae59897 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/IOUtils.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/IOUtils.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; -import org.readium.r2.shared.util.archive.channel.jvm.ReadableByteChannel; +import org.readium.r2.shared.util.zip.jvm.ReadableByteChannel; import java.io.ByteArrayOutputStream; import java.io.Closeable; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/InputStreamStatistics.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/InputStreamStatistics.java similarity index 95% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/InputStreamStatistics.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/InputStreamStatistics.java index a46c791873..7edce418f2 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/InputStreamStatistics.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/InputStreamStatistics.java @@ -16,7 +16,7 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; /** * This interface provides statistics on the current decompression stream. diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/MultiReadOnlySeekableByteChannel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/MultiReadOnlySeekableByteChannel.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/MultiReadOnlySeekableByteChannel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/MultiReadOnlySeekableByteChannel.java index 8739ed2035..e45137892b 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/compress/utils/MultiReadOnlySeekableByteChannel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/compress/utils/MultiReadOnlySeekableByteChannel.java @@ -16,11 +16,11 @@ * */ -package org.readium.r2.shared.util.archive.channel.compress.utils; +package org.readium.r2.shared.util.zip.compress.utils; -import org.readium.r2.shared.util.archive.channel.jvm.ClosedChannelException; -import org.readium.r2.shared.util.archive.channel.jvm.NonWritableChannelException; -import org.readium.r2.shared.util.archive.channel.jvm.SeekableByteChannel; +import org.readium.r2.shared.util.zip.jvm.ClosedChannelException; +import org.readium.r2.shared.util.zip.jvm.NonWritableChannelException; +import org.readium.r2.shared.util.zip.jvm.SeekableByteChannel; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/AsynchronousCloseException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/AsynchronousCloseException.java similarity index 87% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/AsynchronousCloseException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/AsynchronousCloseException.java index a74f2f1b03..17ea7d854b 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/AsynchronousCloseException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/AsynchronousCloseException.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; /** * An {@code AsynchronousCloseException} is thrown when the underlying channel diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ByteChannel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ByteChannel.java similarity index 85% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ByteChannel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ByteChannel.java index 509bf5d808..f55229b0ae 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ByteChannel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ByteChannel.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; /** * A ByteChannel is both readable and writable. *

diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/Channel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/Channel.java similarity index 96% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/Channel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/Channel.java index 3412ebfd92..0e6ec5dddf 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/Channel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/Channel.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; import java.io.Closeable; import java.io.IOException; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ClosedByInterruptException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ClosedByInterruptException.java similarity index 91% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ClosedByInterruptException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ClosedByInterruptException.java index 209a18df83..d15231ba52 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ClosedByInterruptException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ClosedByInterruptException.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; /** * A {@code ClosedByInterruptException} is thrown when a thread is interrupted diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ClosedChannelException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ClosedChannelException.java similarity index 87% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ClosedChannelException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ClosedChannelException.java index 52033cd53d..7a57fca4a4 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ClosedChannelException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ClosedChannelException.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; import java.io.IOException; /** diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/NonReadableChannelException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/NonReadableChannelException.java similarity index 87% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/NonReadableChannelException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/NonReadableChannelException.java index 2bf28970e0..52576227bf 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/NonReadableChannelException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/NonReadableChannelException.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; /** * A {@code NonReadableChannelException} is thrown when attempting to read from diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/NonWritableChannelException.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/NonWritableChannelException.java similarity index 87% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/NonWritableChannelException.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/NonWritableChannelException.java index 88799aa269..bc3a43bc57 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/NonWritableChannelException.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/NonWritableChannelException.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; /** * A {@code NonWritableChannelException} is thrown when attempting to write to a diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ReadableByteChannel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ReadableByteChannel.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ReadableByteChannel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ReadableByteChannel.java index 845898be59..476652dd88 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/ReadableByteChannel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/ReadableByteChannel.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/SeekableByteChannel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/SeekableByteChannel.java similarity index 99% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/SeekableByteChannel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/SeekableByteChannel.java index 19039764da..64a5ceac4b 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/SeekableByteChannel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/SeekableByteChannel.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/WritableByteChannel.java b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/WritableByteChannel.java similarity index 97% rename from readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/WritableByteChannel.java rename to readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/WritableByteChannel.java index 3db47ea6bb..53c07f5679 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/channel/jvm/WritableByteChannel.java +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/zip/jvm/WritableByteChannel.java @@ -1,4 +1,4 @@ -package org.readium.r2.shared.util.archive.channel.jvm; +package org.readium.r2.shared.util.zip.jvm; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/readium/shared/src/test/java/org/readium/r2/shared/TestUtils.kt b/readium/shared/src/test/java/org/readium/r2/shared/TestUtils.kt index 7e7fda0700..e172ba7a7f 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/TestUtils.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/TestUtils.kt @@ -17,7 +17,7 @@ import org.json.JSONObject import org.junit.Assert.assertEquals import org.readium.r2.shared.extensions.toListTest import org.readium.r2.shared.extensions.toMapTest -import org.readium.r2.shared.resource.Resource +import org.readium.r2.shared.util.resource.Resource /** * Asserts that two [JSONObject] are equal. diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationTest.kt index 8676873a11..1718dfbc2e 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationTest.kt @@ -19,12 +19,12 @@ import org.readium.r2.shared.publication.services.PositionsService import org.readium.r2.shared.publication.services.WebPositionsService import org.readium.r2.shared.publication.services.positions import org.readium.r2.shared.publication.services.positionsByReadingOrder -import org.readium.r2.shared.resource.EmptyContainer -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.StringResource -import org.readium.r2.shared.resource.readAsString import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.EmptyContainer +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.StringResource +import org.readium.r2.shared.util.resource.readAsString import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtectionTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtectionTest.kt index 4aebc665e8..7e4e521879 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtectionTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtectionTest.kt @@ -11,8 +11,8 @@ import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.asset.Asset import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.mediatype.MediaType import org.robolectric.RobolectricTestRunner @@ -73,7 +73,7 @@ class AdeptFallbackContentProtectionTest { private fun supports(mediaType: MediaType, resources: Map): Boolean = runBlocking { AdeptFallbackContentProtection().supports( - Asset.Container( + org.readium.r2.shared.util.asset.Asset.Container( mediaType = mediaType, exploded = false, container = TestContainer(resources.mapKeys { Url(it.key)!! }) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtectionTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtectionTest.kt index 99653804a2..62425e30d4 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtectionTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/LcpFallbackContentProtectionTest.kt @@ -11,8 +11,8 @@ import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.asset.Asset import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever import org.robolectric.RobolectricTestRunner @@ -91,7 +91,7 @@ class LcpFallbackContentProtectionTest { private fun supports(mediaType: MediaType, resources: Map): Boolean = runBlocking { LcpFallbackContentProtection(MediaTypeRetriever()).supports( - Asset.Container( + org.readium.r2.shared.util.asset.Asset.Container( mediaType = mediaType, exploded = false, container = TestContainer(resources.mapKeys { Url(it.key)!! }) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/TestContainer.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/TestContainer.kt index 7cab76ff92..e4e0ee9e69 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/TestContainer.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/protection/TestContainer.kt @@ -6,14 +6,14 @@ package org.readium.r2.shared.publication.protection -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.StringResource import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.StringResource class TestContainer(resources: Map = emptyMap()) : Container { diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/CoverServiceTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/CoverServiceTest.kt index 7edfae75be..3f7fafd821 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/CoverServiceTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/CoverServiceTest.kt @@ -20,11 +20,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.readium.r2.shared.publication.* import org.readium.r2.shared.readBlocking -import org.readium.r2.shared.resource.FileResource -import org.readium.r2.shared.resource.ResourceContainer import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.FileResource +import org.readium.r2.shared.util.resource.ResourceContainer import org.readium.r2.shared.util.toAbsoluteUrl import org.robolectric.RobolectricTestRunner diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt index ee75af56e0..4b1b628646 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt @@ -21,9 +21,9 @@ import org.readium.r2.shared.publication.Href import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.readAsString import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.readAsString import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIteratorTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIteratorTest.kt index 9b6d3f0c2b..bc8e1c4d19 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIteratorTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIteratorTest.kt @@ -17,10 +17,10 @@ import org.readium.r2.shared.publication.services.content.Content.AttributeKey.C import org.readium.r2.shared.publication.services.content.Content.AttributeKey.Companion.LANGUAGE import org.readium.r2.shared.publication.services.content.Content.TextElement import org.readium.r2.shared.publication.services.content.Content.TextElement.Segment -import org.readium.r2.shared.resource.StringResource import org.readium.r2.shared.util.Language import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.StringResource import org.robolectric.RobolectricTestRunner @OptIn(ExperimentalReadiumApi::class) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/util/mediatype/MediaTypeRetrieverTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/mediatype/MediaTypeRetrieverTest.kt index 5f3a6e603c..d1e1382f4c 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/util/mediatype/MediaTypeRetrieverTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/mediatype/MediaTypeRetrieverTest.kt @@ -9,15 +9,15 @@ import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.readium.r2.shared.Fixtures -import org.readium.r2.shared.resource.DefaultArchiveFactory import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.FileZipArchiveFactory import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows.shadowOf @RunWith(RobolectricTestRunner::class) class MediaTypeRetrieverTest { - val fixtures = Fixtures("format") + val fixtures = Fixtures("util/mediatype") private val retriever = MediaTypeRetriever() @@ -497,7 +497,7 @@ class MediaTypeRetrieverTest { file: File, hints: MediaTypeHints = MediaTypeHints() ): MediaType? { - val archive = assertNotNull(DefaultArchiveFactory(this).open(file).getOrNull()) + val archive = assertNotNull(FileZipArchiveFactory(this).open(file).getOrNull()) return retrieve( hints, diff --git a/readium/shared/src/test/java/org/readium/r2/shared/resource/BufferingResourceTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/BufferingResourceTest.kt similarity index 97% rename from readium/shared/src/test/java/org/readium/r2/shared/resource/BufferingResourceTest.kt rename to readium/shared/src/test/java/org/readium/r2/shared/util/resource/BufferingResourceTest.kt index 67ac215d2e..1bf64d0fdc 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/resource/BufferingResourceTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/BufferingResourceTest.kt @@ -1,4 +1,4 @@ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -120,7 +120,7 @@ class BufferingResourceTest { } } - private val file = Fixtures("resource").fileAt("epub.epub") + private val file = Fixtures("util/resource").fileAt("epub.epub") private val data = file.readBytes() private val resource = FileResource(file, MediaType.EPUB) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/resource/DirectoryContainerTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/DirectoryContainerTest.kt similarity index 99% rename from readium/shared/src/test/java/org/readium/r2/shared/resource/DirectoryContainerTest.kt rename to readium/shared/src/test/java/org/readium/r2/shared/util/resource/DirectoryContainerTest.kt index 3efe604d40..bc51db10b4 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/resource/DirectoryContainerTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/DirectoryContainerTest.kt @@ -7,7 +7,7 @@ * LICENSE file present in the project repository where this source code is maintained. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import android.webkit.MimeTypeMap import java.nio.charset.StandardCharsets diff --git a/readium/shared/src/test/java/org/readium/r2/shared/resource/ResourceInputStreamTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/ResourceInputStreamTest.kt similarity index 95% rename from readium/shared/src/test/java/org/readium/r2/shared/resource/ResourceInputStreamTest.kt rename to readium/shared/src/test/java/org/readium/r2/shared/util/resource/ResourceInputStreamTest.kt index 698a1eeea6..2e5351bd28 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/resource/ResourceInputStreamTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/ResourceInputStreamTest.kt @@ -1,4 +1,4 @@ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.ByteArrayOutputStream import java.io.File diff --git a/readium/shared/src/test/java/org/readium/r2/shared/resource/ResourcePropertiesTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/ResourcePropertiesTest.kt similarity index 94% rename from readium/shared/src/test/java/org/readium/r2/shared/resource/ResourcePropertiesTest.kt rename to readium/shared/src/test/java/org/readium/r2/shared/util/resource/ResourcePropertiesTest.kt index 5aed6f7f8a..14f495a605 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/resource/ResourcePropertiesTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/ResourcePropertiesTest.kt @@ -1,4 +1,4 @@ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import org.json.JSONObject import org.junit.Assert.assertEquals @@ -6,7 +6,7 @@ import org.junit.Assert.assertNull import org.junit.Test import org.junit.runner.RunWith import org.readium.r2.shared.assertJSONEquals -import org.readium.r2.shared.resource.Resource.Properties +import org.readium.r2.shared.util.resource.Resource.Properties import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/shared/src/test/java/org/readium/r2/shared/resource/ZipContainerTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/ZipContainerTest.kt similarity index 95% rename from readium/shared/src/test/java/org/readium/r2/shared/resource/ZipContainerTest.kt rename to readium/shared/src/test/java/org/readium/r2/shared/util/resource/ZipContainerTest.kt index def541455e..f538bbbd13 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/resource/ZipContainerTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/resource/ZipContainerTest.kt @@ -7,7 +7,7 @@ * LICENSE file present in the project repository where this source code is maintained. */ -package org.readium.r2.shared.resource +package org.readium.r2.shared.util.resource import java.io.File import java.nio.charset.StandardCharsets @@ -19,11 +19,11 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.junit.runner.RunWith import org.readium.r2.shared.util.Url -import org.readium.r2.shared.util.archive.channel.ChannelZipArchiveFactory import org.readium.r2.shared.util.getOrThrow import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever import org.readium.r2.shared.util.use +import org.readium.r2.shared.util.zip.StreamingZipArchiveFactory import org.robolectric.ParameterizedRobolectricTestRunner @RunWith(ParameterizedRobolectricTestRunner::class) @@ -39,7 +39,7 @@ class ZipContainerTest(val sut: suspend () -> Container) { val zipArchive = suspend { assertNotNull( - DefaultArchiveFactory(MediaTypeRetriever()) + FileZipArchiveFactory(MediaTypeRetriever()) .create( FileResource(File(epubZip.path), mediaType = MediaType.EPUB), password = null @@ -49,7 +49,7 @@ class ZipContainerTest(val sut: suspend () -> Container) { } val apacheZipArchive = suspend { - ChannelZipArchiveFactory(MediaTypeRetriever()) + StreamingZipArchiveFactory(MediaTypeRetriever()) .openFile(File(epubZip.path)) } diff --git a/readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/xml/XmlParserTest.kt similarity index 99% rename from readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt rename to readium/shared/src/test/java/org/readium/r2/shared/util/xml/XmlParserTest.kt index 506ce250c8..5d336813ca 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/util/xml/XmlParserTest.kt @@ -7,7 +7,7 @@ * LICENSE file present in the project repository where this source code is maintained. */ -package org.readium.r2.shared.parser.xml +package org.readium.r2.shared.util.xml import java.io.ByteArrayInputStream import javax.xml.XMLConstants diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/any.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/any.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/any.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/any.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook-lcp.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook-lcp.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook-lcp.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook-lcp.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook-package.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook-package.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook-package.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook-package.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook-wrongtype.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook-wrongtype.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook-wrongtype.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook-wrongtype.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/audiobook.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/audiobook.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/cbz.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/cbz.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/cbz.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/cbz.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/divina-package.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/divina-package.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/divina-package.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/divina-package.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/divina.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/divina.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/divina.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/divina.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/epub.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/epub.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/epub.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/epub.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/html-doctype-case.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/html-doctype-case.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/html-doctype-case.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/html-doctype-case.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/html.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/html.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/html.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/html.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/lcpl.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/lcpl.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/lcpl.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/lcpl.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/lpf-index-html.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/lpf-index-html.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/lpf-index-html.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/lpf-index-html.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/lpf.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/lpf.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/lpf.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/lpf.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/opds-authentication.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds-authentication.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/opds-authentication.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds-authentication.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/opds1-entry.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds1-entry.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/opds1-entry.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds1-entry.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/opds1-feed.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds1-feed.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/opds1-feed.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds1-feed.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/opds2-feed.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds2-feed.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/opds2-feed.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds2-feed.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/opds2-publication.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds2-publication.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/opds2-publication.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/opds2-publication.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/pdf-lcp.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/pdf-lcp.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/pdf-lcp.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/pdf-lcp.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/pdf.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/pdf.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/pdf.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/pdf.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/png.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/png.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/png.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/png.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/unknown.zip b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/unknown.zip similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/unknown.zip rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/unknown.zip diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/w3c-wpub.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/w3c-wpub.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/w3c-wpub.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/w3c-wpub.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/webpub-package.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/webpub-package.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/webpub-package.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/webpub-package.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/webpub.json b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/webpub.json similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/webpub.json rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/webpub.json diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/xhtml.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/xhtml.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/xhtml.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/xhtml.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/format/zab.unknown b/readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/zab.unknown similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/format/zab.unknown rename to readium/shared/src/test/resources/org/readium/r2/shared/util/mediatype/zab.unknown diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/directory/subdirectory/hello.mp3 b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/directory/subdirectory/hello.mp3 similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/directory/subdirectory/hello.mp3 rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/directory/subdirectory/hello.mp3 diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/directory/subdirectory/text2.txt b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/directory/subdirectory/text2.txt similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/directory/subdirectory/text2.txt rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/directory/subdirectory/text2.txt diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/directory/text1.txt b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/directory/text1.txt similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/directory/text1.txt rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/directory/text1.txt diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub.epub b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub.epub similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub.epub rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub.epub diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/cover.xhtml b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/cover.xhtml similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/cover.xhtml rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/cover.xhtml diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/css/epub.css b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/css/epub.css similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/css/epub.css rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/css/epub.css diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/css/nav.css b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/css/nav.css similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/css/nav.css rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/css/nav.css diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/images/cover.png b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/images/cover.png similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/images/cover.png rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/images/cover.png diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/nav.xhtml b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/nav.xhtml similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/nav.xhtml rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/nav.xhtml diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/package.opf b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/package.opf similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/package.opf rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/package.opf diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/s04.xhtml b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/s04.xhtml similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/s04.xhtml rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/s04.xhtml diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/toc.ncx b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/toc.ncx similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/EPUB/toc.ncx rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/EPUB/toc.ncx diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/META-INF/container.xml b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/META-INF/container.xml similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/META-INF/container.xml rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/META-INF/container.xml diff --git a/readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/mimetype b/readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/mimetype similarity index 100% rename from readium/shared/src/test/resources/org/readium/r2/shared/resource/epub/mimetype rename to readium/shared/src/test/resources/org/readium/r2/shared/util/resource/epub/mimetype diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/ParserAssetFactory.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/ParserAssetFactory.kt index 30f5deff30..5c1cf41d42 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/ParserAssetFactory.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/ParserAssetFactory.kt @@ -8,18 +8,15 @@ package org.readium.r2.streamer import java.nio.charset.Charset import org.json.JSONObject -import org.readium.r2.shared.asset.Asset import org.readium.r2.shared.extensions.addPrefix import org.readium.r2.shared.publication.Manifest import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceContainer -import org.readium.r2.shared.resource.RoutingContainer import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.MessageError import org.readium.r2.shared.util.ThrowableError import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.getOrThrow import org.readium.r2.shared.util.http.HttpClient @@ -27,6 +24,9 @@ import org.readium.r2.shared.util.http.HttpContainer import org.readium.r2.shared.util.mediatype.FormatRegistry import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceContainer +import org.readium.r2.shared.util.resource.RoutingContainer import org.readium.r2.streamer.parser.PublicationParser internal class ParserAssetFactory( @@ -36,18 +36,18 @@ internal class ParserAssetFactory( ) { suspend fun createParserAsset( - asset: Asset + asset: org.readium.r2.shared.util.asset.Asset ): Try { return when (asset) { - is Asset.Container -> + is org.readium.r2.shared.util.asset.Asset.Container -> createParserAssetForContainer(asset) - is Asset.Resource -> + is org.readium.r2.shared.util.asset.Asset.Resource -> createParserAssetForResource(asset) } } private fun createParserAssetForContainer( - asset: Asset.Container + asset: org.readium.r2.shared.util.asset.Asset.Container ): Try = Try.success( PublicationParser.Asset( @@ -57,7 +57,7 @@ internal class ParserAssetFactory( ) private suspend fun createParserAssetForResource( - asset: Asset.Resource + asset: org.readium.r2.shared.util.asset.Asset.Resource ): Try = if (asset.mediaType.isRwpm) { createParserAssetForManifest(asset) @@ -66,7 +66,7 @@ internal class ParserAssetFactory( } private suspend fun createParserAssetForManifest( - asset: Asset.Resource + asset: org.readium.r2.shared.util.asset.Asset.Resource ): Try { val manifest = asset.resource.readAsRwpm() .mapFailure { Publication.OpenError.InvalidAsset(ThrowableError(it)) } @@ -114,7 +114,7 @@ internal class ParserAssetFactory( } private fun createParserAssetForContent( - asset: Asset.Resource + asset: org.readium.r2.shared.util.asset.Asset.Resource ): Try { // Historically, the reading order of a standalone file contained a single link with the // HREF "/$assetName". This was fragile if the asset named changed, or was different on diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/PublicationFactory.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/PublicationFactory.kt index f6fc5c584d..87af3fa8df 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/PublicationFactory.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/PublicationFactory.kt @@ -8,13 +8,12 @@ package org.readium.r2.streamer import android.content.Context import org.readium.r2.shared.PdfSupport -import org.readium.r2.shared.asset.Asset import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.protection.AdeptFallbackContentProtection import org.readium.r2.shared.publication.protection.ContentProtection import org.readium.r2.shared.publication.protection.LcpFallbackContentProtection -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.asset.Asset import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.http.DefaultHttpClient import org.readium.r2.shared.util.http.HttpClient @@ -22,6 +21,7 @@ import org.readium.r2.shared.util.logging.WarningLogger import org.readium.r2.shared.util.mediatype.FormatRegistry import org.readium.r2.shared.util.mediatype.MediaTypeRetriever import org.readium.r2.shared.util.pdf.PdfDocumentFactory +import org.readium.r2.shared.util.resource.Resource import org.readium.r2.streamer.parser.PublicationParser import org.readium.r2.streamer.parser.audio.AudioParser import org.readium.r2.streamer.parser.epub.EpubParser @@ -132,7 +132,7 @@ public class PublicationFactory( * @return A [Publication] or a [Publication.OpenError] in case of failure. */ public suspend fun open( - asset: Asset, + asset: org.readium.r2.shared.util.asset.Asset, contentProtectionScheme: ContentProtection.Scheme? = null, credentials: String? = null, allowUserInteraction: Boolean, @@ -163,7 +163,7 @@ public class PublicationFactory( } private suspend fun openUnprotected( - asset: Asset, + asset: org.readium.r2.shared.util.asset.Asset, onCreatePublication: Publication.Builder.() -> Unit, warnings: WarningLogger? ): Try { @@ -173,7 +173,7 @@ public class PublicationFactory( } private suspend fun openProtected( - asset: Asset, + asset: org.readium.r2.shared.util.asset.Asset, contentProtectionScheme: ContentProtection.Scheme, credentials: String?, allowUserInteraction: Boolean, diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Container.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Container.kt index 8386687fca..075a6e3874 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Container.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Container.kt @@ -10,11 +10,11 @@ package org.readium.r2.streamer.extensions import java.io.File -import org.readium.r2.shared.parser.xml.ElementNode -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.readAsXml import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.readAsXml import org.readium.r2.shared.util.use +import org.readium.r2.shared.util.xml.ElementNode /** Returns the resource data as an XML Document at the given [path], or null. */ internal suspend fun Container.readAsXmlOrNull(path: String): ElementNode? = diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Link.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Link.kt index d4298e5406..99e674af6a 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Link.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/extensions/Link.kt @@ -7,8 +7,8 @@ package org.readium.r2.streamer.extensions import org.readium.r2.shared.publication.Link -import org.readium.r2.shared.resource.Container import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container internal suspend fun Container.Entry.toLink(mediaType: MediaType? = null): Link = Link( diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/PublicationParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/PublicationParser.kt index 5807151a42..b2ae212ba8 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/PublicationParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/PublicationParser.kt @@ -7,13 +7,13 @@ package org.readium.r2.streamer.parser import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.MessageError import org.readium.r2.shared.util.ThrowableError import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.logging.WarningLogger import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource /** * Parses a Publication from an asset. diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EncryptionParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EncryptionParser.kt index 4cd14be00f..76a0f5fdf4 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EncryptionParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EncryptionParser.kt @@ -6,10 +6,10 @@ package org.readium.r2.streamer.parser.epub -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.encryption.Encryption import org.readium.r2.shared.publication.protection.ContentProtection import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.ElementNode internal object EncryptionParser { fun parse(document: ElementNode): Map = diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscator.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscator.kt index 701f932c7a..c102d9a4bb 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscator.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscator.kt @@ -10,11 +10,11 @@ import com.mcxiaoke.koi.HASH import com.mcxiaoke.koi.ext.toHexBytes import kotlin.experimental.xor import org.readium.r2.shared.publication.encryption.Encryption -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.TransformingResource -import org.readium.r2.shared.resource.flatMap import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.TransformingResource +import org.readium.r2.shared.util.resource.flatMap /** * Deobfuscates fonts according to https://www.w3.org/TR/epub-33/#sec-font-obfuscation diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubParser.kt index 873ab89a82..abbf0ec91d 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubParser.kt @@ -14,15 +14,15 @@ import org.readium.r2.shared.publication.encryption.encryption import org.readium.r2.shared.publication.services.content.DefaultContentService import org.readium.r2.shared.publication.services.content.iterators.HtmlResourceContentIterator import org.readium.r2.shared.publication.services.search.StringSearchService -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.TransformingContainer -import org.readium.r2.shared.resource.readAsXml import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.logging.WarningLogger import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.TransformingContainer +import org.readium.r2.shared.util.resource.readAsXml import org.readium.r2.shared.util.use import org.readium.r2.streamer.extensions.readAsXmlOrNull import org.readium.r2.streamer.parser.PublicationParser diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubPositionsService.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubPositionsService.kt index 280ecb9e01..438bbb9138 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubPositionsService.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/EpubPositionsService.kt @@ -16,11 +16,11 @@ import org.readium.r2.shared.publication.epub.layoutOf import org.readium.r2.shared.publication.presentation.Presentation import org.readium.r2.shared.publication.presentation.presentation import org.readium.r2.shared.publication.services.PositionsService -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.archive import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.archive import org.readium.r2.shared.util.use /** diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/MetadataParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/MetadataParser.kt index f9d9d2f637..c7ea14781d 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/MetadataParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/MetadataParser.kt @@ -6,11 +6,11 @@ package org.readium.r2.streamer.parser.epub -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.Href import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.xml.ElementNode internal class MetadataParser( private val prefixMap: Map, diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParser.kt index a9d5aa4b4a..2680857751 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParser.kt @@ -6,9 +6,9 @@ package org.readium.r2.streamer.parser.epub -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.Link import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.ElementNode internal object NavigationDocumentParser { diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NcxParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NcxParser.kt index 7636003a32..86dbaac117 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NcxParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/NcxParser.kt @@ -6,9 +6,9 @@ package org.readium.r2.streamer.parser.epub -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.Link import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.ElementNode internal object NcxParser { diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/PackageDocument.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/PackageDocument.kt index fb80a903e7..3654281d94 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/PackageDocument.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/PackageDocument.kt @@ -6,10 +6,10 @@ package org.readium.r2.streamer.parser.epub -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.publication.ReadingProgression import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.xml.ElementNode internal data class PackageDocument( val path: Url, diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/SmilParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/SmilParser.kt index bba07c8b2f..4bc4834b9a 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/SmilParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/SmilParser.kt @@ -8,8 +8,8 @@ package org.readium.r2.streamer.parser.epub import org.readium.r2.shared.MediaOverlayNode import org.readium.r2.shared.MediaOverlays -import org.readium.r2.shared.parser.xml.ElementNode import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.ElementNode internal object SmilParser { /* According to https://www.w3.org/publishing/epub3/epub-mediaoverlays.html#sec-overlays-content-conf diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/readium/ReadiumWebPubParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/readium/ReadiumWebPubParser.kt index f85260180d..a3171a99be 100644 --- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/readium/ReadiumWebPubParser.kt +++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/readium/ReadiumWebPubParser.kt @@ -14,7 +14,6 @@ import org.readium.r2.shared.publication.services.PerResourcePositionsService import org.readium.r2.shared.publication.services.cacheServiceFactory import org.readium.r2.shared.publication.services.locatorServiceFactory import org.readium.r2.shared.publication.services.positionsServiceFactory -import org.readium.r2.shared.resource.readAsJson import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrElse @@ -22,6 +21,7 @@ import org.readium.r2.shared.util.logging.WarningLogger import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever import org.readium.r2.shared.util.pdf.PdfDocumentFactory +import org.readium.r2.shared.util.resource.readAsJson import org.readium.r2.streamer.parser.PublicationParser import org.readium.r2.streamer.parser.audio.AudioLocatorService diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/TestUtils.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/TestUtils.kt index f7e1402222..6b18b4dc28 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/TestUtils.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/TestUtils.kt @@ -11,7 +11,7 @@ package org.readium.r2.streamer import kotlinx.coroutines.runBlocking import org.readium.r2.shared.publication.Publication -import org.readium.r2.shared.resource.Resource +import org.readium.r2.shared.util.resource.Resource import org.readium.r2.streamer.parser.PublicationParser internal fun Resource.readBlocking(range: LongRange? = null) = runBlocking { read(range) } diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/ContainerEntryTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/ContainerEntryTest.kt index 5c803032ba..bec497f152 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/ContainerEntryTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/ContainerEntryTest.kt @@ -13,12 +13,12 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt index 24ac2bcbc1..927a477374 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt @@ -13,9 +13,9 @@ import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.publication.encryption.Encryption import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.XmlParser import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt index 7969ec3558..5804a1e29f 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt @@ -14,12 +14,12 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.junit.runner.RunWith import org.readium.r2.shared.publication.encryption.Encryption -import org.readium.r2.shared.resource.DirectoryContainerFactory -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.flatMap import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.getOrThrow import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.DirectoryContainerFactory +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.flatMap import org.readium.r2.shared.util.toAbsoluteUrl import org.readium.r2.streamer.readBlocking import org.robolectric.RobolectricTestRunner diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt index 3cc9beffcc..d6575f495f 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt @@ -18,15 +18,15 @@ import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Properties import org.readium.r2.shared.publication.epub.EpubLayout import org.readium.r2.shared.publication.presentation.Presentation -import org.readium.r2.shared.resource.ArchiveProperties -import org.readium.r2.shared.resource.Container -import org.readium.r2.shared.resource.Resource -import org.readium.r2.shared.resource.ResourceTry -import org.readium.r2.shared.resource.archive import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType +import org.readium.r2.shared.util.resource.ArchiveProperties +import org.readium.r2.shared.util.resource.Container +import org.readium.r2.shared.util.resource.Resource +import org.readium.r2.shared.util.resource.ResourceTry +import org.readium.r2.shared.util.resource.archive import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt index 0f39951f7f..ee468858af 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt @@ -13,10 +13,10 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.assertNotNull import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.publication.Href import org.readium.r2.shared.publication.Link import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.XmlParser import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt index 1cfe20bef1..d090a33f63 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt @@ -13,10 +13,10 @@ import org.assertj.core.api.Assertions import org.junit.Assert.assertNotNull import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.publication.Href import org.readium.r2.shared.publication.Link import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.xml.XmlParser import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/PackageDocumentTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/PackageDocumentTest.kt index 1652416695..ce62a39dbe 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/PackageDocumentTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/PackageDocumentTest.kt @@ -12,7 +12,6 @@ package org.readium.r2.streamer.parser.epub import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.junit.runner.RunWith -import org.readium.r2.shared.parser.xml.XmlParser import org.readium.r2.shared.publication.Href import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Manifest @@ -24,6 +23,7 @@ import org.readium.r2.shared.publication.presentation.* import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.xml.XmlParser import org.robolectric.RobolectricTestRunner fun parsePackageDocument(path: String): Manifest { diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt index dcac8b0a85..2ffd8914bf 100644 --- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt +++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt @@ -18,12 +18,12 @@ import org.junit.Test import org.junit.runner.RunWith import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.firstWithRel -import org.readium.r2.shared.resource.DefaultArchiveFactory -import org.readium.r2.shared.resource.FileResource -import org.readium.r2.shared.resource.ResourceContainer import org.readium.r2.shared.util.Url import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.FileResource +import org.readium.r2.shared.util.resource.FileZipArchiveFactory +import org.readium.r2.shared.util.resource.ResourceContainer import org.readium.r2.shared.util.toUrl import org.readium.r2.streamer.parseBlocking import org.readium.r2.streamer.parser.PublicationParser @@ -37,7 +37,7 @@ class ImageParserTest { private val cbzAsset = runBlocking { val file = fileForResource("futuristic_tales.cbz") val resource = FileResource(file, mediaType = MediaType.CBZ) - val archive = DefaultArchiveFactory(MediaTypeRetriever()).create( + val archive = FileZipArchiveFactory(MediaTypeRetriever()).create( resource, password = null ).getOrNull()!! diff --git a/settings.gradle.kts b/settings.gradle.kts index 9b6225b8f7..0946d6b408 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -68,10 +68,26 @@ include(":readium:navigator") project(":readium:navigator") .name = "readium-navigator" +include(":readium:navigators:media:common") +project(":readium:navigators:media:common") + .name = "readium-navigator-media-common" + +include(":readium:navigators:media:audio") +project(":readium:navigators:media:audio") + .name = "readium-navigator-media-audio" + +include(":readium:navigators:media:tts") +project(":readium:navigators:media:tts") + .name = "readium-navigator-media-tts" + include(":readium:navigator-media2") project(":readium:navigator-media2") .name = "readium-navigator-media2" +include(":readium:adapters:exoplayer") +project(":readium:adapters:exoplayer") + .name = "readium-adapter-exoplayer" + include(":readium:opds") project(":readium:opds") .name = "readium-opds" diff --git a/test-app/build.gradle.kts b/test-app/build.gradle.kts index 49619c39ff..7e68b3830f 100644 --- a/test-app/build.gradle.kts +++ b/test-app/build.gradle.kts @@ -70,6 +70,10 @@ dependencies { implementation(project(":readium:readium-shared")) implementation(project(":readium:readium-streamer")) implementation(project(":readium:readium-navigator")) + implementation(project(":readium:navigators:media:readium-navigator-media-audio")) + implementation(project(":readium:navigators:media:readium-navigator-media-tts")) + // Only required if you want to support audiobooks using ExoPlayer. + implementation(project(":readium:adapters:readium-adapter-exoplayer")) implementation(project(":readium:readium-navigator-media2")) implementation(project(":readium:readium-opds")) implementation(project(":readium:readium-lcp")) diff --git a/test-app/src/main/java/org/readium/r2/testapp/Readium.kt b/test-app/src/main/java/org/readium/r2/testapp/Readium.kt index fe838ddc68..e6cedd4f5c 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/Readium.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/Readium.kt @@ -8,27 +8,27 @@ package org.readium.r2.testapp import android.content.Context import android.view.View -import org.readium.adapters.pdfium.document.PdfiumDocumentFactory +import org.readium.adapter.pdfium.document.PdfiumDocumentFactory import org.readium.r2.lcp.LcpException import org.readium.r2.lcp.LcpService import org.readium.r2.lcp.auth.LcpDialogAuthentication import org.readium.r2.navigator.preferences.FontFamily import org.readium.r2.shared.ExperimentalReadiumApi -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.publication.protection.ContentProtectionSchemeRetriever -import org.readium.r2.shared.resource.CompositeArchiveFactory -import org.readium.r2.shared.resource.CompositeResourceFactory -import org.readium.r2.shared.resource.ContentResourceFactory -import org.readium.r2.shared.resource.DefaultArchiveFactory -import org.readium.r2.shared.resource.DirectoryContainerFactory -import org.readium.r2.shared.resource.FileResourceFactory import org.readium.r2.shared.util.Try -import org.readium.r2.shared.util.archive.channel.ChannelZipArchiveFactory +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.downloads.android.AndroidDownloadManager import org.readium.r2.shared.util.http.DefaultHttpClient import org.readium.r2.shared.util.http.HttpResourceFactory import org.readium.r2.shared.util.mediatype.FormatRegistry import org.readium.r2.shared.util.mediatype.MediaTypeRetriever +import org.readium.r2.shared.util.resource.CompositeArchiveFactory +import org.readium.r2.shared.util.resource.CompositeResourceFactory +import org.readium.r2.shared.util.resource.ContentResourceFactory +import org.readium.r2.shared.util.resource.DirectoryContainerFactory +import org.readium.r2.shared.util.resource.FileResourceFactory +import org.readium.r2.shared.util.resource.FileZipArchiveFactory +import org.readium.r2.shared.util.zip.StreamingZipArchiveFactory import org.readium.r2.streamer.PublicationFactory /** @@ -45,8 +45,8 @@ class Readium(context: Context) { ) private val archiveFactory = CompositeArchiveFactory( - DefaultArchiveFactory(mediaTypeRetriever), - ChannelZipArchiveFactory(mediaTypeRetriever) + FileZipArchiveFactory(mediaTypeRetriever), + StreamingZipArchiveFactory(mediaTypeRetriever) ) private val resourceFactory = CompositeResourceFactory( diff --git a/test-app/src/main/java/org/readium/r2/testapp/data/BookRepository.kt b/test-app/src/main/java/org/readium/r2/testapp/data/BookRepository.kt index d9b5576b3d..cf055f61c2 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/data/BookRepository.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/data/BookRepository.kt @@ -11,11 +11,11 @@ import androidx.lifecycle.LiveData import java.io.File import kotlinx.coroutines.flow.Flow import org.joda.time.DateTime -import org.readium.r2.shared.asset.AssetType import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.indexOfFirstWithHref import org.readium.r2.shared.publication.protection.ContentProtection +import org.readium.r2.shared.util.asset.AssetType import org.readium.r2.shared.util.mediatype.MediaType import org.readium.r2.testapp.data.db.BooksDao import org.readium.r2.testapp.data.model.Book diff --git a/test-app/src/main/java/org/readium/r2/testapp/data/model/Book.kt b/test-app/src/main/java/org/readium/r2/testapp/data/model/Book.kt index bd8a32d16c..2876898cc3 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/data/model/Book.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/data/model/Book.kt @@ -9,9 +9,9 @@ package org.readium.r2.testapp.data.model import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey -import org.readium.r2.shared.asset.AssetType import org.readium.r2.shared.publication.protection.ContentProtection import org.readium.r2.shared.util.AbsoluteUrl +import org.readium.r2.shared.util.asset.AssetType import org.readium.r2.shared.util.mediatype.MediaType @Entity(tableName = Book.TABLE_NAME) diff --git a/test-app/src/main/java/org/readium/r2/testapp/domain/Bookshelf.kt b/test-app/src/main/java/org/readium/r2/testapp/domain/Bookshelf.kt index 480775f0be..e9bbda64fd 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/domain/Bookshelf.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/domain/Bookshelf.kt @@ -12,12 +12,12 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainScope import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.protection.ContentProtectionSchemeRetriever import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.toUrl import org.readium.r2.streamer.PublicationFactory diff --git a/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationError.kt b/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationError.kt index 99e00ed541..82b7343731 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationError.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationError.kt @@ -8,9 +8,9 @@ package org.readium.r2.testapp.domain import androidx.annotation.StringRes import org.readium.r2.shared.UserException -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.util.Error +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.testapp.R sealed class PublicationError(@StringRes userMessageId: Int) : UserException(userMessageId) { diff --git a/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationRetriever.kt b/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationRetriever.kt index 6e42156117..82bddd6057 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationRetriever.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/domain/PublicationRetriever.kt @@ -17,13 +17,13 @@ import org.readium.r2.lcp.LcpException import org.readium.r2.lcp.LcpPublicationRetriever as ReadiumLcpPublicationRetriever import org.readium.r2.lcp.LcpService import org.readium.r2.lcp.license.model.LicenseDocument -import org.readium.r2.shared.asset.Asset -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.opds.images import org.readium.r2.shared.util.AbsoluteUrl import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.asset.Asset +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.downloads.DownloadManager import org.readium.r2.shared.util.getOrElse import org.readium.r2.shared.util.mediatype.FormatRegistry @@ -155,7 +155,7 @@ class LocalPublicationRetriever( } if ( - sourceAsset is Asset.Resource && + sourceAsset is org.readium.r2.shared.util.asset.Asset.Resource && sourceAsset.mediaType.matches(MediaType.LCP_LICENSE_DOCUMENT) ) { if (lcpPublicationRetriever == null) { @@ -332,7 +332,7 @@ class LcpPublicationRetriever( * Retrieves a publication protected with the given license. */ fun retrieve( - licenceAsset: Asset.Resource, + licenceAsset: org.readium.r2.shared.util.asset.Asset.Resource, licenceFile: File, coverUrl: AbsoluteUrl? ) { diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt index 9940f98d83..aaf3dfad02 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt @@ -23,10 +23,10 @@ import kotlin.time.DurationUnit import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch -import org.readium.r2.navigator.media3.api.MediaNavigator -import org.readium.r2.navigator.media3.api.TimeBasedMediaNavigator -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerPreferences -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerSettings +import org.readium.adapter.exoplayer.ExoPlayerPreferences +import org.readium.adapter.exoplayer.ExoPlayerSettings +import org.readium.navigator.media.common.MediaNavigator +import org.readium.navigator.media.common.TimeBasedMediaNavigator import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.Locator @@ -88,7 +88,9 @@ class AudioReaderFragment : BaseReaderFragment(), SeekBar.OnSeekBarChangeListene .launchIn(viewLifecycleOwner.lifecycleScope) } - private fun onPlaybackChanged(playback: TimeBasedMediaNavigator.Playback) { + private fun onPlaybackChanged( + playback: TimeBasedMediaNavigator.Playback + ) { Timber.v("onPlaybackChanged $playback") if (playback.state is MediaNavigator.State.Error) { onPlayerError() @@ -112,7 +114,9 @@ class AudioReaderFragment : BaseReaderFragment(), SeekBar.OnSeekBarChangeListene } } - private fun updateTimeline(playback: TimeBasedMediaNavigator.Playback) { + private fun updateTimeline( + playback: TimeBasedMediaNavigator.Playback + ) { val currentItem = navigator.readingOrder.items[playback.index] binding.timelineBar.max = currentItem.duration?.inWholeSeconds?.toInt() ?: 0 binding.timelineDuration.text = currentItem.duration?.formatElapsedTime() diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/MediaService.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/MediaService.kt index d9d81dc1be..6a69378d4c 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/MediaService.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/MediaService.kt @@ -19,8 +19,8 @@ import androidx.media3.session.MediaSession import androidx.media3.session.MediaSessionService import kotlinx.coroutines.* import kotlinx.coroutines.flow.* -import org.readium.r2.navigator.media3.api.Media3Adapter -import org.readium.r2.navigator.media3.api.MediaNavigator +import org.readium.navigator.media.common.Media3Adapter +import org.readium.navigator.media.common.MediaNavigator import org.readium.r2.shared.ExperimentalReadiumApi import timber.log.Timber diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/MediaServiceFacade.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/MediaServiceFacade.kt index 2a4e6db5f3..70a63a7311 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/MediaServiceFacade.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/MediaServiceFacade.kt @@ -11,7 +11,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.* import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import org.readium.r2.navigator.media3.api.Media3Adapter +import org.readium.navigator.media.common.Media3Adapter import org.readium.r2.shared.ExperimentalReadiumApi /** diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/PdfReaderFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/PdfReaderFragment.kt index 80c80c82b0..ef01f97467 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/PdfReaderFragment.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/PdfReaderFragment.kt @@ -11,9 +11,9 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.commitNow -import org.readium.adapters.pdfium.navigator.PdfiumNavigatorFragment -import org.readium.adapters.pdfium.navigator.PdfiumPreferences -import org.readium.adapters.pdfium.navigator.PdfiumSettings +import org.readium.adapter.pdfium.navigator.PdfiumNavigatorFragment +import org.readium.adapter.pdfium.navigator.PdfiumPreferences +import org.readium.adapter.pdfium.navigator.PdfiumSettings import org.readium.r2.navigator.pdf.PdfNavigatorFragment import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.testapp.R diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderInitData.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderInitData.kt index c8b4978f81..bec5be28c6 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderInitData.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderInitData.kt @@ -8,15 +8,15 @@ package org.readium.r2.testapp.reader -import org.readium.adapters.pdfium.navigator.PdfiumNavigatorFactory -import org.readium.adapters.pdfium.navigator.PdfiumPreferences +import org.readium.adapter.exoplayer.ExoPlayerNavigator +import org.readium.adapter.exoplayer.ExoPlayerNavigatorFactory +import org.readium.adapter.exoplayer.ExoPlayerPreferences +import org.readium.adapter.pdfium.navigator.PdfiumNavigatorFactory +import org.readium.adapter.pdfium.navigator.PdfiumPreferences +import org.readium.navigator.media.tts.AndroidTtsNavigatorFactory +import org.readium.navigator.media.tts.android.AndroidTtsPreferences import org.readium.r2.navigator.epub.EpubNavigatorFactory import org.readium.r2.navigator.epub.EpubPreferences -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerNavigator -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerNavigatorFactory -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerPreferences -import org.readium.r2.navigator.media3.tts.AndroidTtsNavigatorFactory -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferences import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.publication.* import org.readium.r2.testapp.reader.preferences.PreferencesManager diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderRepository.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderRepository.kt index b2dc57d23a..3505d4bb19 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderRepository.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderRepository.kt @@ -11,20 +11,20 @@ import androidx.annotation.StringRes import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences as JetpackPreferences import org.json.JSONObject -import org.readium.adapters.pdfium.navigator.PdfiumEngineProvider +import org.readium.adapter.exoplayer.ExoPlayerEngineProvider +import org.readium.adapter.pdfium.navigator.PdfiumEngineProvider +import org.readium.navigator.media.audio.AudioNavigatorFactory +import org.readium.navigator.media.tts.TtsNavigatorFactory import org.readium.r2.navigator.epub.EpubNavigatorFactory -import org.readium.r2.navigator.media3.audio.AudioNavigatorFactory -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerEngineProvider -import org.readium.r2.navigator.media3.tts.TtsNavigatorFactory import org.readium.r2.navigator.pdf.PdfNavigatorFactory import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.UserException -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.allAreHtml import org.readium.r2.shared.publication.services.isRestricted import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.getOrElse import org.readium.r2.testapp.Readium import org.readium.r2.testapp.data.BookRepository diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt index 347744ad2d..0acab058e3 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt @@ -30,9 +30,9 @@ import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.services.search.SearchIterator import org.readium.r2.shared.publication.services.search.SearchTry import org.readium.r2.shared.publication.services.search.search -import org.readium.r2.shared.resource.Resource import org.readium.r2.shared.util.Try import org.readium.r2.shared.util.Url +import org.readium.r2.shared.util.resource.Resource import org.readium.r2.testapp.Application import org.readium.r2.testapp.data.BookRepository import org.readium.r2.testapp.data.model.Highlight diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt index 5024720eb3..2f0c3ea676 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt @@ -41,10 +41,10 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import kotlinx.parcelize.Parcelize +import org.readium.navigator.media.tts.android.AndroidTtsEngine import org.readium.r2.navigator.* import org.readium.r2.navigator.input.InputListener import org.readium.r2.navigator.input.TapEvent -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngine import org.readium.r2.navigator.util.BaseActionModeCallback import org.readium.r2.navigator.util.DirectionalNavigationAdapter import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/PreferencesManagers.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/PreferencesManagers.kt index d21e0919d2..bbf5d43a55 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/PreferencesManagers.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/PreferencesManagers.kt @@ -19,20 +19,20 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map -import org.readium.adapters.pdfium.navigator.PdfiumPreferences -import org.readium.adapters.pdfium.navigator.PdfiumPreferencesSerializer -import org.readium.adapters.pdfium.navigator.PdfiumPublicationPreferencesFilter -import org.readium.adapters.pdfium.navigator.PdfiumSharedPreferencesFilter +import org.readium.adapter.exoplayer.ExoPlayerPreferences +import org.readium.adapter.exoplayer.ExoPlayerPreferencesSerializer +import org.readium.adapter.pdfium.navigator.PdfiumPreferences +import org.readium.adapter.pdfium.navigator.PdfiumPreferencesSerializer +import org.readium.adapter.pdfium.navigator.PdfiumPublicationPreferencesFilter +import org.readium.adapter.pdfium.navigator.PdfiumSharedPreferencesFilter +import org.readium.navigator.media.tts.android.AndroidTtsPreferences +import org.readium.navigator.media.tts.android.AndroidTtsPreferencesSerializer +import org.readium.navigator.media.tts.android.AndroidTtsPublicationPreferencesFilter +import org.readium.navigator.media.tts.android.AndroidTtsSharedPreferencesFilter import org.readium.r2.navigator.epub.EpubPreferences import org.readium.r2.navigator.epub.EpubPreferencesSerializer import org.readium.r2.navigator.epub.EpubPublicationPreferencesFilter import org.readium.r2.navigator.epub.EpubSharedPreferencesFilter -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerPreferences -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerPreferencesSerializer -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferences -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferencesSerializer -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPublicationPreferencesFilter -import org.readium.r2.navigator.media3.tts.android.AndroidTtsSharedPreferencesFilter import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.navigator.preferences.PreferencesFilter import org.readium.r2.navigator.preferences.PreferencesSerializer diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt index 79e1c2c1bd..1b95beacbe 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt @@ -18,10 +18,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import org.readium.adapters.pdfium.navigator.PdfiumPreferencesEditor +import org.readium.adapter.exoplayer.ExoPlayerPreferencesEditor +import org.readium.adapter.pdfium.navigator.PdfiumPreferencesEditor +import org.readium.navigator.media.tts.android.AndroidTtsEngine import org.readium.r2.navigator.epub.EpubPreferencesEditor -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerPreferencesEditor -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngine import org.readium.r2.navigator.preferences.* import org.readium.r2.navigator.preferences.TextAlign as ReadiumTextAlign import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferencesViewModel.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferencesViewModel.kt index 76afae1c26..6940469f57 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferencesViewModel.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferencesViewModel.kt @@ -14,12 +14,12 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch -import org.readium.adapters.pdfium.navigator.PdfiumPreferences -import org.readium.adapters.pdfium.navigator.PdfiumSettings +import org.readium.adapter.exoplayer.ExoPlayerPreferences +import org.readium.adapter.exoplayer.ExoPlayerSettings +import org.readium.adapter.pdfium.navigator.PdfiumPreferences +import org.readium.adapter.pdfium.navigator.PdfiumSettings import org.readium.r2.navigator.epub.EpubPreferences import org.readium.r2.navigator.epub.EpubSettings -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerPreferences -import org.readium.r2.navigator.media3.exoplayer.ExoPlayerSettings import org.readium.r2.navigator.preferences.Configurable import org.readium.r2.navigator.preferences.PreferencesEditor import org.readium.r2.shared.ExperimentalReadiumApi diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsPreferencesEditor.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsPreferencesEditor.kt index 5ab076d1ea..705156b286 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsPreferencesEditor.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsPreferencesEditor.kt @@ -6,9 +6,9 @@ package org.readium.r2.testapp.reader.tts -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngine -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferences -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferencesEditor +import org.readium.navigator.media.tts.android.AndroidTtsEngine +import org.readium.navigator.media.tts.android.AndroidTtsPreferences +import org.readium.navigator.media.tts.android.AndroidTtsPreferencesEditor import org.readium.r2.navigator.preferences.* import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.util.Language diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsViewModel.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsViewModel.kt index d7de208352..d93d223a53 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsViewModel.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/tts/TtsViewModel.kt @@ -11,15 +11,15 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch +import org.readium.navigator.media.common.MediaNavigator +import org.readium.navigator.media.tts.AndroidTtsNavigator +import org.readium.navigator.media.tts.AndroidTtsNavigatorFactory +import org.readium.navigator.media.tts.TtsNavigator +import org.readium.navigator.media.tts.android.AndroidTtsEngine +import org.readium.navigator.media.tts.android.AndroidTtsPreferences +import org.readium.navigator.media.tts.android.AndroidTtsSettings import org.readium.r2.navigator.Navigator import org.readium.r2.navigator.VisualNavigator -import org.readium.r2.navigator.media3.api.MediaNavigator -import org.readium.r2.navigator.media3.tts.AndroidTtsNavigator -import org.readium.r2.navigator.media3.tts.AndroidTtsNavigatorFactory -import org.readium.r2.navigator.media3.tts.TtsNavigator -import org.readium.r2.navigator.media3.tts.android.AndroidTtsEngine -import org.readium.r2.navigator.media3.tts.android.AndroidTtsPreferences -import org.readium.r2.navigator.media3.tts.android.AndroidTtsSettings import org.readium.r2.shared.ExperimentalReadiumApi import org.readium.r2.shared.UserException import org.readium.r2.shared.publication.Locator @@ -143,7 +143,9 @@ class TtsViewModel private constructor( stop() } is MediaNavigator.State.Error -> { - onPlaybackError(playback.state as TtsNavigator.State.Error) + onPlaybackError( + playback.state as TtsNavigator.State.Error + ) } is MediaNavigator.State.Ready -> {} is MediaNavigator.State.Buffering -> {} diff --git a/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/File.kt b/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/File.kt index b5c784da1a..d31bedebe5 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/File.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/File.kt @@ -16,8 +16,8 @@ import java.net.URL import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ensureActive import kotlinx.coroutines.withContext -import org.readium.r2.shared.asset.AssetRetriever import org.readium.r2.shared.util.Try +import org.readium.r2.shared.util.asset.AssetRetriever import org.readium.r2.shared.util.flatMap import org.readium.r2.shared.util.http.HttpClient import org.readium.r2.shared.util.http.HttpException