Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize modules and packages #404

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
66 changes: 66 additions & 0 deletions readium/adapters/exoplayer/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"
}

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)
}
3 changes: 3 additions & 0 deletions readium/adapters/exoplayer/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,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

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

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

import android.net.Uri
import androidx.media3.common.C.LENGTH_UNSET
Expand All @@ -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(
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

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

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

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

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

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

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

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

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

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

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
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
2 changes: 1 addition & 1 deletion readium/adapters/pdfium/pdfium-document/build.gradle.kts
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
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
2 changes: 1 addition & 1 deletion readium/adapters/pdfium/pdfium-navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {
buildFeatures {
viewBinding = true
}
namespace = "org.readium.adapters.pdfium.navigator"
namespace = "org.readium.adapter.pdfium.navigator"
}

kotlin {
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.adapters.pdfium.navigator
package org.readium.adapter.pdfium.navigator

import org.readium.r2.navigator.preferences.ReadingProgression
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.adapters.pdfium.navigator
package org.readium.adapter.pdfium.navigator

import android.graphics.PointF
import android.os.Bundle
Expand All @@ -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
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.adapters.pdfium.navigator
package org.readium.adapter.pdfium.navigator

import android.graphics.PointF
import com.github.barteksc.pdfviewer.PDFView
Expand All @@ -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.
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.adapters.pdfium.navigator
package org.readium.adapter.pdfium.navigator

import org.readium.r2.navigator.pdf.PdfNavigatorFactory
import org.readium.r2.navigator.pdf.PdfNavigatorFragment
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.adapters.pdfium.navigator
package org.readium.adapter.pdfium.navigator

import kotlinx.serialization.Serializable
import org.readium.r2.navigator.preferences.Axis
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.adapters.pdfium.navigator
package org.readium.adapter.pdfium.navigator

import org.readium.r2.navigator.extensions.format
import org.readium.r2.navigator.preferences.*
Expand Down
Loading