Skip to content

Commit

Permalink
Merge branch 'v3' into fix/opds-models
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu authored Oct 9, 2023
2 parents ecf59a9 + 845a44c commit 00b6bdb
Show file tree
Hide file tree
Showing 352 changed files with 1,579 additions and 1,155 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ All notable changes to this project will be documented in this file. Take a look
* Scroll mode: jumping between two EPUB resources with a horizontal swipe triggers the `Navigator.Listener.onJumpToLocator()` callback.
* This can be used to allow the user to go back to their previous location if they swiped across chapters by mistake.
* Support for keyboard events in the EPUB, PDF and image navigators. See `VisualNavigator.addInputListener()`.
* Support for non-linear EPUB resources with an opt-in in reading apps (contributed by @chrfalch in [#375](https://github.com/readium/kotlin-toolkit/pull/375) and [#376](https://github.com/readium/kotlin-toolkit/pull/376)).
1. Override loading non-linear resources with `VisualNavigator.Listener.shouldJumpToLink()`.
2. Present a new `EpubNavigatorFragment` by providing a custom `readingOrder` with only this resource to the constructor.


#### Streamer

Expand Down
18 changes: 18 additions & 0 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,28 @@ val MIGRATION_HREF = object : Migration(1, 2) {
}
```

### LcpDialogAuthentication now supports configuration changes.

You no longer need to pass an activity, fragment or view as `sender` to `retrievePassphrase`.
Instead, call `onParentViewAttachedToWindow` every time you have a
view attached to a window available as anchor and `onParentViewDetachedFromWindow` every time it
gets detached. You can monitor these events by setting a `View.OnAttachStateChangeListener` on your
view.

See the [test-app](https://github.com/readium/kotlin-toolkit/blob/01d6c7936accea2d6b953d435e669260676e8c99/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfFragment.kt#L68)
for an example.

### All resources now have the prefix `readium_`.

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 |
Expand Down
66 changes: 66 additions & 0 deletions readium/adapters/exoplayer/audio/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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.audio"
}

kotlin {
explicitApi()
}

rootProject.ext["publish.artifactId"] = "readium-navigator-exoplayer-audio"
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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* available in the top-level LICENSE file of the project.
*/

package org.readium.r2.navigator.media3.exoplayer
package org.readium.adapter.exoplayer.audio

import androidx.media3.common.ForwardingPlayer
import androidx.media3.exoplayer.ExoPlaybackException
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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import android.net.Uri
import androidx.media3.common.C.LENGTH_UNSET
Expand All @@ -16,18 +16,18 @@ 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(
internal sealed class ExoPlayerDataSourceException(message: String, cause: Throwable?) : IOException(
message,
cause
) {
public class NotOpened(message: String) : ExoPlayerDataSourceException(message, null)
public class NotFound(message: String) : ExoPlayerDataSourceException(message, null)
public class ReadFailed(uri: Uri, offset: Int, readLength: Int, cause: Throwable) : ExoPlayerDataSourceException(
class NotOpened(message: String) : ExoPlayerDataSourceException(message, null)
class NotFound(message: String) : ExoPlayerDataSourceException(message, null)
class ReadFailed(uri: Uri, offset: Int, readLength: Int, cause: Throwable) : ExoPlayerDataSourceException(
"Failed to read $readLength bytes of URI $uri at offset $offset.",
cause
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import org.readium.r2.shared.ExperimentalReadiumApi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import android.app.Application
import androidx.media3.common.*
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import org.readium.r2.navigator.preferences.Configurable
import org.readium.r2.shared.ExperimentalReadiumApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import org.readium.r2.navigator.extensions.format
import org.readium.r2.navigator.preferences.DoubleIncrement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import kotlinx.serialization.json.Json
import org.readium.r2.navigator.preferences.PreferencesSerializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import org.readium.r2.navigator.preferences.Configurable
import org.readium.r2.shared.ExperimentalReadiumApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import org.readium.r2.shared.ExperimentalReadiumApi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.audio

import kotlin.time.Duration
import kotlin.time.ExperimentalTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.readium.r2.navigator.audio
package org.readium.adapter.exoplayer.audio

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 {
Expand Down
52 changes: 52 additions & 0 deletions readium/adapters/exoplayer/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.adapter.exoplayer"
}

kotlin {
explicitApi()
}

rootProject.ext["publish.artifactId"] = "readium-adapter-exoplayer"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:adapters:exoplayer:readium-adapter-exoplayer-audio"))
}
2 changes: 1 addition & 1 deletion readium/adapters/pdfium/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
}
}
namespace = "org.readium.adapters.pdfium"
namespace = "org.readium.adapter.pdfium"
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
buildFeatures {
viewBinding = true
}
namespace = "org.readium.adapters.pdfium.document"
namespace = "org.readium.adapter.pdfium.document"
}

kotlin {
Expand Down
3 changes: 3 additions & 0 deletions readium/adapters/pdfium/document/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading

0 comments on commit 00b6bdb

Please sign in to comment.