diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 2b10348505..7ad1224ebd 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -13,11 +13,11 @@ jobs:
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Checkout
- uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v2
+ uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
with:
- java-version: '11'
+ java-version: '17'
distribution: 'adopt'
- name: Build
run: ./gradlew clean build -x test -x ktlintMainSourceSetCheck
@@ -30,11 +30,11 @@ jobs:
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Checkout
- uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v2
+ uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
with:
- java-version: '11'
+ java-version: '17'
distribution: 'adopt'
- name: Lint
run: ./gradlew ktlintCheck
@@ -50,7 +50,7 @@ jobs:
scripts: ${{ 'src/main/assets/_scripts' }}
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Install dependencies
run: yarn --cwd "$scripts" install --frozen-lockfile
- name: Lint
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 1f26b6f284..a672e828d9 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -13,13 +13,13 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --prune --unshallow
- name: Set up Python
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v4
with:
python-version: 3.6
@@ -28,9 +28,9 @@ jobs:
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material mike
- - uses: actions/setup-java@v2
+ - uses: actions/setup-java@v3
with:
- java-version: 11
+ java-version: 17
distribution: 'adopt'
- name: Get current Readium version
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 32bd05c089..1b8a9556a8 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
ref: develop
- - name: Set up JDK 11
- uses: actions/setup-java@v2
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
with:
distribution: adopt
- java-version: 11
+ java-version: 17
# Builds the release artifacts of the library
- name: Release build
diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml
deleted file mode 100644
index bc444dead9..0000000000
--- a/.idea/kotlinScripting.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index e1eea1d6b9..fdf8d994a6 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index a1921290d7..ba84dead13 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,8 @@ A [Test App](test-app) demonstrates how to integrate the Readium Kotlin toolkit
| Readium | Android min SDK | Android compile SDK | Kotlin compiler | Gradle |
|---------|-----------------|---------------------|-----------------|--------|
-| latest | 21 | 33 | 1.7.10 | 6.9.3 |
+| latest | 21 | 33 | 1.9.0 | 8.6.0 |
+| 2.3.0 | 21 | 33 | 1.7.10 | 6.9.3 |
## Setting Up Readium
diff --git a/build.gradle.kts b/build.gradle.kts
index b606887482..b4f09459ba 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -12,6 +12,7 @@ plugins {
id("io.github.gradle-nexus.publish-plugin") apply true
id("org.jetbrains.dokka") apply true
id("org.jetbrains.kotlin.android") apply false
+ id("com.google.devtools.ksp") apply false
id("org.jlleitschuh.gradle.ktlint") apply true
}
diff --git a/gradle.properties b/gradle.properties
index c064741c76..cac7c68c14 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -19,5 +19,3 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
-
-android.disableAutomaticComponentCreation=true
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 962365e7d1..8522fc42fd 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,58 +1,58 @@
[versions]
-androidx-activity = "1.6.1"
-androidx-appcompat = "1.5.1"
-androidx-browser = "1.4.0"
+androidx-activity = "1.7.2"
+androidx-appcompat = "1.6.1"
+androidx-browser = "1.5.0"
androidx-cardview = "1.0.0"
-androidx-compose-compiler = "1.3.2"
-androidx-compose-animation = "1.3.0-beta03"
-androidx-compose-foundation = "1.3.0-beta03"
-androidx-compose-material = "1.3.0-beta03"
-androidx-compose-material3 = "1.0.0-beta03"
-androidx-compose-runtime = "1.3.0-beta03"
+androidx-compose-compiler = "1.5.0"
+androidx-compose-animation = "1.4.3"
+androidx-compose-foundation = "1.4.3"
+androidx-compose-material = "1.4.3"
+androidx-compose-material3 = "1.1.1"
+androidx-compose-runtime = "1.4.3"
androidx-compose-theme-adapter = "1.1.19"
-androidx-compose-ui = "1.3.0-beta03"
+androidx-compose-ui = "1.4.3"
androidx-constraintlayout = "2.1.4"
-androidx-core = "1.9.0"
+androidx-core = "1.10.1"
androidx-datastore = "1.0.0"
-androidx-expresso-core = "3.4.0"
-androidx-ext-junit = "1.1.3"
-androidx-fragment-ktx = "1.5.4"
+androidx-expresso-core = "3.5.1"
+androidx-ext-junit = "1.1.5"
+androidx-fragment-ktx = "1.6.0"
androidx-legacy = "1.0.0"
-androidx-lifecycle = "2.5.1"
+androidx-lifecycle = "2.6.1"
androidx-lifecycle-extensions = "2.2.0"
androidx-media = "1.6.0"
androidx-media2 = "1.2.1"
-androidx-media3 = "1.0.0-rc01"
+androidx-media3 = "1.1.0"
androidx-navigation = "2.5.2"
androidx-paging = "3.1.1"
-androidx-recyclerview = "1.2.1"
-androidx-room = "2.4.3"
+androidx-recyclerview = "1.3.0"
+androidx-room = "2.5.2"
androidx-viewpager2 = "1.0.0"
-androidx-webkit = "1.5.0"
+androidx-webkit = "1.7.0"
-assertj = "3.23.1"
+assertj = "3.24.2"
-dokka = "1.7.20"
+dokka = "1.8.20"
-google-exoplayer = "2.18.1"
-google-material = "1.7.0"
+google-exoplayer = "2.19.0"
+google-material = "1.9.0"
-joda-time = "2.12.1"
-jsoup = "1.15.3"
+joda-time = "2.12.5"
+jsoup = "1.16.1"
junit = "4.13.2"
-kotlin = "1.7.20"
-kotlinx-coroutines = "1.6.4"
-kotlinx-coroutines-test = "1.6.4"
-kotlinx-serialization-json = "1.4.1"
+kotlin = "1.9.0"
+kotlinx-coroutines = "1.7.2"
+kotlinx-coroutines-test = "1.7.2"
+kotlinx-serialization-json = "1.5.1"
pdfium = "1.8.2"
pdf-viewer = "2.8.2"
-picasso = "2.71828"
+picasso = "2.8"
pspdfkit = "8.4.1"
-robolectric = "4.9"
+robolectric = "4.10.3"
timber = "5.0.1"
@@ -119,7 +119,7 @@ junit = { group = "junit", name = "junit", version.ref = "junit" }
kotlin-gradle = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
-kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
+kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index aa991fceae..40dbbfc089 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Mon Jul 01 10:00:22 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/readium/adapters/pdfium/build.gradle.kts b/readium/adapters/pdfium/build.gradle.kts
index 8021c8dee7..1a9666c037 100644
--- a/readium/adapters/pdfium/build.gradle.kts
+++ b/readium/adapters/pdfium/build.gradle.kts
@@ -13,7 +13,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -21,11 +21,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
diff --git a/readium/adapters/pdfium/pdfium-document/build.gradle.kts b/readium/adapters/pdfium/pdfium-document/build.gradle.kts
index 6113dec3c1..7092a1eb87 100644
--- a/readium/adapters/pdfium/pdfium-document/build.gradle.kts
+++ b/readium/adapters/pdfium/pdfium-document/build.gradle.kts
@@ -13,7 +13,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -21,11 +21,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
diff --git a/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts b/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts
index ae5f0e9b78..24bb4c9d5e 100644
--- a/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts
+++ b/readium/adapters/pdfium/pdfium-navigator/build.gradle.kts
@@ -14,7 +14,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -22,11 +22,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
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/adapters/pdfium/navigator/PdfiumEngineProvider.kt
index 9f2d1c5e1d..4f77e99a57 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/adapters/pdfium/navigator/PdfiumEngineProvider.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.adapters.pdfium.navigator
import org.readium.r2.navigator.SimplePresentation
@@ -11,6 +13,7 @@ import org.readium.r2.navigator.VisualNavigator
import org.readium.r2.navigator.pdf.PdfDocumentFragmentInput
import org.readium.r2.navigator.pdf.PdfEngineProvider
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.publication.Metadata
import org.readium.r2.shared.publication.Publication
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/adapters/pdfium/navigator/PdfiumPreferencesEditor.kt
index c4d0b2b768..3e87db15a7 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/adapters/pdfium/navigator/PdfiumPreferencesEditor.kt
@@ -4,11 +4,14 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.adapters.pdfium.navigator
import org.readium.r2.navigator.extensions.format
import org.readium.r2.navigator.preferences.*
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.publication.Metadata
/**
diff --git a/readium/adapters/pspdfkit/build.gradle.kts b/readium/adapters/pspdfkit/build.gradle.kts
index e09623883c..93796feb4d 100644
--- a/readium/adapters/pspdfkit/build.gradle.kts
+++ b/readium/adapters/pspdfkit/build.gradle.kts
@@ -13,7 +13,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -21,11 +21,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
diff --git a/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts b/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts
index a8ab144c29..28fc38dace 100644
--- a/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts
+++ b/readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts
@@ -13,7 +13,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -21,11 +21,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
diff --git a/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts b/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts
index 0b9a53a6e3..5cc58bd06a 100644
--- a/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts
+++ b/readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts
@@ -14,7 +14,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -22,11 +22,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
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/adapters/pspdfkit/navigator/PsPdfKitDocumentFragment.kt
index f302faec1d..05999ce0c9 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/adapters/pspdfkit/navigator/PsPdfKitDocumentFragment.kt
@@ -192,9 +192,9 @@ internal class PsPdfKitDocumentFragment(
}
private val allowedTextSelectionItems = listOf(
- R.id.pspdf__text_selection_toolbar_item_share,
- R.id.pspdf__text_selection_toolbar_item_copy,
- R.id.pspdf__text_selection_toolbar_item_speak
+ com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_share,
+ com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_copy,
+ com.pspdfkit.R.id.pspdf__text_selection_toolbar_item_speak
)
override fun onPrepareTextSelectionPopupToolbar(toolbar: PdfTextSelectionPopupToolbar) {
diff --git a/readium/lcp/build.gradle.kts b/readium/lcp/build.gradle.kts
index 2d4fd94f66..7644551196 100644
--- a/readium/lcp/build.gradle.kts
+++ b/readium/lcp/build.gradle.kts
@@ -8,23 +8,23 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("plugin.parcelize")
- kotlin("kapt")
+ id("com.google.devtools.ksp")
}
android {
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
allWarningsAsErrors = true
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
@@ -37,6 +37,9 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
}
}
+ buildFeatures {
+ buildConfig = true
+ }
namespace = "org.readium.r2.lcp"
}
@@ -63,8 +66,7 @@ dependencies {
implementation(libs.androidx.browser)
implementation(libs.bundles.room)
- kapt(libs.androidx.room.compiler)
- kapt("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0")
+ ksp(libs.androidx.room.compiler)
// Tests
testImplementation(libs.junit)
diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/persistence/LcpDatabase.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/persistence/LcpDatabase.kt
index d877001a6c..c45a0f5fd5 100644
--- a/readium/lcp/src/main/java/org/readium/r2/lcp/persistence/LcpDatabase.kt
+++ b/readium/lcp/src/main/java/org/readium/r2/lcp/persistence/LcpDatabase.kt
@@ -35,8 +35,8 @@ internal abstract class LcpDatabase : RoomDatabase() {
return tempInstance
}
val MIGRATION_1_2 = object : Migration(1, 2) {
- override fun migrate(database: SupportSQLiteDatabase) {
- database.execSQL(
+ override fun migrate(db: SupportSQLiteDatabase) {
+ db.execSQL(
"""
CREATE TABLE passphrases (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -47,15 +47,15 @@ internal abstract class LcpDatabase : RoomDatabase() {
)
""".trimIndent()
)
- database.execSQL(
+ db.execSQL(
"""
INSERT INTO passphrases (license_id, provider, user_id, passphrase)
SELECT id, origin, userId, passphrase FROM Transactions
""".trimIndent()
)
- database.execSQL("DROP TABLE Transactions")
+ db.execSQL("DROP TABLE Transactions")
- database.execSQL(
+ db.execSQL(
"""
CREATE TABLE new_Licenses (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -66,14 +66,14 @@ internal abstract class LcpDatabase : RoomDatabase() {
)
""".trimIndent()
)
- database.execSQL(
+ db.execSQL(
"""
INSERT INTO new_Licenses (license_id, right_print, right_copy, registered)
SELECT id, printsLeft, copiesLeft, registered FROM Licenses
""".trimIndent()
)
- database.execSQL("DROP TABLE Licenses")
- database.execSQL("ALTER TABLE new_Licenses RENAME TO licenses")
+ db.execSQL("DROP TABLE Licenses")
+ db.execSQL("ALTER TABLE new_Licenses RENAME TO licenses")
}
}
synchronized(this) {
diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/service/LcpClient.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/service/LcpClient.kt
index f361d9a522..39d90c3944 100644
--- a/readium/lcp/src/main/java/org/readium/r2/lcp/service/LcpClient.kt
+++ b/readium/lcp/src/main/java/org/readium/r2/lcp/service/LcpClient.kt
@@ -31,7 +31,7 @@ internal object LcpClient {
}
private val instance: Any by lazy {
- klass.newInstance()
+ klass.getDeclaredConstructor().newInstance()
}
private val klass: Class<*> by lazy {
diff --git a/readium/navigator-media2/build.gradle.kts b/readium/navigator-media2/build.gradle.kts
index 2512435bf7..1febcb40f4 100644
--- a/readium/navigator-media2/build.gradle.kts
+++ b/readium/navigator-media2/build.gradle.kts
@@ -13,7 +13,7 @@ plugins {
android {
resourcePrefix = "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -21,11 +21,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
diff --git a/readium/navigator/build.gradle.kts b/readium/navigator/build.gradle.kts
index e357ad38a6..225149273c 100644
--- a/readium/navigator/build.gradle.kts
+++ b/readium/navigator/build.gradle.kts
@@ -15,7 +15,7 @@ android {
// FIXME: This doesn't pass the lint because some resources don't start with readium_ yet. We need to rename all resources for the next major version.
// resourcePrefix "readium_"
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
@@ -23,11 +23,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
@@ -44,6 +44,7 @@ android {
}
buildFeatures {
viewBinding = true
+ buildConfig = true
}
namespace = "org.readium.r2.navigator"
}
@@ -70,8 +71,6 @@ dependencies {
implementation(libs.bundles.media3)
implementation(libs.androidx.viewpager2)
implementation(libs.androidx.webkit)
- // Needed to avoid a crash with API 31, see https://stackoverflow.com/a/69152986/1474476
- implementation("androidx.work:work-runtime-ktx:2.7.1")
implementation(libs.bundles.media2)
// ExoPlayer is used by the Audio Navigator.
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 58cfd18d27..7e75a6dc94 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
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(InternalReadiumApi::class)
+
package org.readium.r2.navigator
import android.content.Context
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt
index 1ef8a4b0c8..a36ec14cce 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt
@@ -7,6 +7,8 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.cbz
import android.app.Activity
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFactory.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFactory.kt
index 41714aec1c..55fc021ae5 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFactory.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFactory.kt
@@ -4,9 +4,12 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.epub
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.publication.Link
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/epub/EpubNavigatorFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt
index 571bcaa24e..1cfcbdcc0b 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
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.epub
import android.content.SharedPreferences
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorViewModel.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorViewModel.kt
index 8d33368173..98f9d9c8ad 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorViewModel.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorViewModel.kt
@@ -4,7 +4,7 @@
* available in the top-level LICENSE file of the project.
*/
-@file:OptIn(ExperimentalReadiumApi::class)
+@file:OptIn(ExperimentalReadiumApi::class, InternalReadiumApi::class)
package org.readium.r2.navigator.epub
@@ -32,6 +32,7 @@ import org.readium.r2.navigator.util.createViewModelFactory
import org.readium.r2.shared.COLUMN_COUNT_REF
import org.readium.r2.shared.DelicateReadiumApi
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.SCROLL_REF
import org.readium.r2.shared.extensions.addPrefix
import org.readium.r2.shared.extensions.mapStateIn
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt
index f045ea843e..aca3b42d25 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.epub
import org.readium.r2.navigator.epub.css.Layout
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/R2EpubActivity.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/R2EpubActivity.kt
index fb0e46b428..4fc9ce6990 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/R2EpubActivity.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/R2EpubActivity.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.epub
import android.app.Activity
@@ -31,6 +33,7 @@ import org.readium.r2.navigator.pager.R2PagerAdapter
import org.readium.r2.navigator.pager.R2ViewPager
import org.readium.r2.navigator.util.CompositeFragmentFactory
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.getPublication
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Locator
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 602444cf12..9e71528e1d 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
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.epub
import android.app.Application
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/fxl/R2FXLLayout.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/fxl/R2FXLLayout.kt
index 48f1ed9c64..9bbce37b35 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/fxl/R2FXLLayout.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/fxl/R2FXLLayout.kt
@@ -7,6 +7,8 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.epub.fxl
import android.annotation.SuppressLint
@@ -29,6 +31,7 @@ import java.util.Locale
import kotlin.math.min
import kotlin.math.roundToInt
import kotlin.math.roundToLong
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.equalsDelta
class R2FXLLayout : FrameLayout {
@@ -299,8 +302,7 @@ class R2FXLLayout : FrameLayout {
dispatchOnLongTap(e)
}
}
-
- override fun onScroll(e1: MotionEvent, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
+ override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
var consumed = false
if (e2.pointerCount == 1 && !scaleDetector!!.isInProgress) {
// only drag if we have one pointer and aren't already scaling
@@ -319,7 +321,7 @@ class R2FXLLayout : FrameLayout {
return consumed
}
- override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
+ override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
val scale = scale
val newScale = scale.coerceIn(minScale, maxScale)
if (newScale.equalsDelta(scale)) {
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 38c1d8928f..c11bcce10b 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
@@ -7,6 +7,8 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.extensions
import java.util.*
@@ -70,5 +72,5 @@ internal val Locator.Locations.time: Duration? get() =
*/
@OptIn(ExperimentalTime::class)
internal fun Locator.Locations.timeWithDuration(duration: Duration?): Duration? =
- let(duration, progression) { d, p -> (p * d.inSeconds).seconds }
+ let(duration, progression) { d, p -> (p * d.inWholeSeconds).seconds }
?: time
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/image/ImageNavigatorFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/image/ImageNavigatorFragment.kt
index 6aaca39a90..2b704d16dd 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/image/ImageNavigatorFragment.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/image/ImageNavigatorFragment.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.image
import android.content.Context
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsContentIterator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsContentIterator.kt
index 04e738242b..fba7b26b9f 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsContentIterator.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsContentIterator.kt
@@ -4,9 +4,12 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.media3.tts
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.publication.Locator
import org.readium.r2.shared.publication.Publication
import org.readium.r2.shared.publication.html.cssSelector
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt
index 8240d0573e..c46992df13 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/TtsNavigator.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.media3.tts
import android.app.Application
@@ -19,6 +21,7 @@ import org.readium.r2.navigator.media3.api.SynchronizedMediaNavigator
import org.readium.r2.navigator.media3.tts.session.TtsSessionAdapter
import org.readium.r2.navigator.preferences.Configurable
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.mapStateIn
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Locator
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt
index b8a47e159e..10e1ec91da 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/android/AndroidTtsPreferencesEditor.kt
@@ -4,11 +4,14 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.media3.tts.android
import org.readium.r2.navigator.extensions.format
import org.readium.r2.navigator.preferences.*
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.publication.Metadata
import org.readium.r2.shared.util.Language
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt
index a50c7ac9f2..e1077344f2 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media3/tts/session/TtsSessionAdapter.kt
@@ -193,6 +193,16 @@ internal class TtsSessionAdapter(
override fun moveMediaItems(fromIndex: Int, toIndex: Int, newIndex: Int) {
}
+ override fun replaceMediaItem(index: Int, mediaItem: MediaItem) {
+ }
+
+ override fun replaceMediaItems(
+ fromIndex: Int,
+ toIndex: Int,
+ mediaItems: MutableList
+ ) {
+ }
+
override fun removeMediaItem(index: Int) {
}
@@ -425,9 +435,6 @@ internal class TtsSessionAdapter(
onStop()
}
- @Deprecated("Deprecated in Java")
- override fun stop(reset: Boolean) {}
-
override fun release() {
streamVolumeManager.release()
audioFocusManager.release()
@@ -704,18 +711,34 @@ internal class TtsSessionAdapter(
streamVolumeManager.setVolume(volume)
}
+ override fun setDeviceVolume(volume: Int, flags: Int) {
+ streamVolumeManager.setVolume(volume)
+ }
+
override fun increaseDeviceVolume() {
streamVolumeManager.increaseVolume()
}
+ override fun increaseDeviceVolume(flags: Int) {
+ streamVolumeManager.increaseVolume()
+ }
+
override fun decreaseDeviceVolume() {
streamVolumeManager.decreaseVolume()
}
+ override fun decreaseDeviceVolume(flags: Int) {
+ streamVolumeManager.decreaseVolume()
+ }
+
override fun setDeviceMuted(muted: Boolean) {
streamVolumeManager.setMuted(muted)
}
+ override fun setDeviceMuted(muted: Boolean, flags: Int) {
+ streamVolumeManager.setMuted(muted)
+ }
+
private fun notifyListenersPlaybackChanged(
previousPlaybackInfo: TtsPlayer.Playback,
playbackInfo: TtsPlayer.Playback,
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt
index ab9166b00a..9c44dc2411 100755
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt
@@ -7,7 +7,7 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
-@file:OptIn(ExperimentalReadiumApi::class)
+@file:OptIn(ExperimentalReadiumApi::class, InternalReadiumApi::class)
package org.readium.r2.navigator.pager
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFactory.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFactory.kt
index 6522ff8825..62f8701982 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFactory.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFactory.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.pdf
import androidx.fragment.app.FragmentFactory
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFragment.kt
index ec69069945..9d628adac1 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFragment.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorFragment.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.pdf
import android.graphics.PointF
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorViewModel.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorViewModel.kt
index e67c11608e..6ebcfe16a2 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorViewModel.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/pdf/PdfNavigatorViewModel.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.pdf
import android.app.Application
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/preferences/ProgressionStrategy.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/preferences/ProgressionStrategy.kt
index 04bcc633e0..c323cdc9c5 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/preferences/ProgressionStrategy.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/preferences/ProgressionStrategy.kt
@@ -4,8 +4,11 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.preferences
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.equalsDelta
/**
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/tts/PublicationSpeechSynthesizer.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/tts/PublicationSpeechSynthesizer.kt
index d96c6c5ae5..9d88067b69 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/tts/PublicationSpeechSynthesizer.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/tts/PublicationSpeechSynthesizer.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.navigator.tts
import android.content.Context
@@ -15,6 +17,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import org.readium.r2.shared.DelicateReadiumApi
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.tryOrLog
import org.readium.r2.shared.publication.Locator
import org.readium.r2.shared.publication.Publication
diff --git a/readium/opds/build.gradle.kts b/readium/opds/build.gradle.kts
index 749f173f10..f2a20936c1 100644
--- a/readium/opds/build.gradle.kts
+++ b/readium/opds/build.gradle.kts
@@ -11,18 +11,18 @@ plugins {
}
android {
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
diff --git a/readium/shared/build.gradle.kts b/readium/shared/build.gradle.kts
index 219216d124..dd764d046f 100644
--- a/readium/shared/build.gradle.kts
+++ b/readium/shared/build.gradle.kts
@@ -12,15 +12,15 @@ plugins {
}
android {
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
allWarningsAsErrors = true
@@ -38,6 +38,9 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
}
}
+ buildFeatures {
+ buildConfig = true
+ }
namespace = "org.readium.r2.shared"
}
diff --git a/readium/shared/src/main/java/org/readium/r2/shared/fetcher/HttpFetcher.kt b/readium/shared/src/main/java/org/readium/r2/shared/fetcher/HttpFetcher.kt
index 69afb00589..45997a1e10 100644
--- a/readium/shared/src/main/java/org/readium/r2/shared/fetcher/HttpFetcher.kt
+++ b/readium/shared/src/main/java/org/readium/r2/shared/fetcher/HttpFetcher.kt
@@ -10,6 +10,7 @@ import android.webkit.URLUtil
import java.io.InputStream
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.read
import org.readium.r2.shared.extensions.tryOrLog
import org.readium.r2.shared.publication.Link
@@ -33,6 +34,7 @@ import timber.log.Timber
* @param client HTTP client used to perform HTTP requests.
* @param baseUrl Base URL from which relative HREF are served.
*/
+@OptIn(InternalReadiumApi::class)
class HttpFetcher(
private val client: HttpClient,
private val baseUrl: String? = null,
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 c3ece07f08..170eb55ebe 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
@@ -4,7 +4,7 @@
* available in the top-level LICENSE file of the project.
*/
-@file:OptIn(InternalReadiumApi::class)
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
@file:Suppress("DEPRECATION")
package org.readium.r2.shared.publication
diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/JavaZip.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/archive/JavaZip.kt
index c0e5901e23..6c5be567a4 100644
--- a/readium/shared/src/main/java/org/readium/r2/shared/util/archive/JavaZip.kt
+++ b/readium/shared/src/main/java/org/readium/r2/shared/util/archive/JavaZip.kt
@@ -7,7 +7,7 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
-@file:OptIn(InternalReadiumApi::class)
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
package org.readium.r2.shared.util.archive
diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpClient.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpClient.kt
index 4f18fbb3ab..c092913960 100644
--- a/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpClient.kt
+++ b/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpClient.kt
@@ -4,6 +4,8 @@
* available in the top-level LICENSE file of the project.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.shared.util.http
import java.io.InputStream
@@ -11,6 +13,7 @@ import java.nio.charset.Charset
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.json.JSONObject
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.util.Try
import org.readium.r2.shared.util.flatMap
import org.readium.r2.shared.util.mediatype.MediaType
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 f4b63e8f5b..53556c87d4 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
@@ -7,6 +7,8 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.shared.util.pdf
import android.content.Context
@@ -14,6 +16,7 @@ import android.graphics.Bitmap
import java.io.File
import kotlin.reflect.KClass
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.fetcher.Resource
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Publication
diff --git a/readium/streamer/build.gradle.kts b/readium/streamer/build.gradle.kts
index 0d30a46089..d2dd5f3696 100644
--- a/readium/streamer/build.gradle.kts
+++ b/readium/streamer/build.gradle.kts
@@ -11,15 +11,15 @@ plugins {
}
android {
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
testOptions {
unitTests.isIncludeAndroidResources = true
@@ -31,6 +31,9 @@ android {
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
)
}
+ buildFeatures {
+ buildConfig = true
+ }
buildTypes {
getByName("release") {
isMinifyEnabled = false
diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/pdf/PdfParser.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/pdf/PdfParser.kt
index 69121026d4..5627e6ba5d 100644
--- a/readium/streamer/src/main/java/org/readium/r2/streamer/parser/pdf/PdfParser.kt
+++ b/readium/streamer/src/main/java/org/readium/r2/streamer/parser/pdf/PdfParser.kt
@@ -7,12 +7,15 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.streamer.parser.pdf
import android.content.Context
import java.io.File
import kotlinx.coroutines.runBlocking
import org.readium.r2.shared.ExperimentalReadiumApi
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.PdfSupport
import org.readium.r2.shared.fetcher.Fetcher
import org.readium.r2.shared.fetcher.FileFetcher
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 f7864ae0dc..b350286196 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
@@ -7,12 +7,15 @@
* LICENSE file present in the project repository where this source code is maintained.
*/
+@file:OptIn(org.readium.r2.shared.InternalReadiumApi::class)
+
package org.readium.r2.streamer.parser.readium
import android.content.Context
import java.io.File
import java.io.FileNotFoundException
import kotlinx.coroutines.runBlocking
+import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.PdfSupport
import org.readium.r2.shared.drm.DRM
import org.readium.r2.shared.fetcher.*
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 8fb9509680..402673ef62 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -18,13 +18,16 @@ pluginManagement {
// it to integrate Readium in submodules.
// See https://github.com/readium/kotlin-toolkit/pull/97
plugins {
- id("com.android.application") version ("7.3.1")
- id("com.android.library") version ("7.3.1")
+ id("com.android.application") version ("8.4.0")
+ id("com.android.library") version ("8.4.0")
id("io.github.gradle-nexus.publish-plugin") version ("1.1.0")
- id("org.jetbrains.dokka") version ("1.7.20")
- id("org.jetbrains.kotlin.android") version ("1.7.20")
- id("org.jetbrains.kotlin.plugin.serialization") version ("1.7.10")
+ id("org.jetbrains.dokka") version ("1.8.20")
+ id("org.jetbrains.kotlin.android") version ("1.9.0")
+ id("org.jetbrains.kotlin.plugin.serialization") version ("1.9.0")
id("org.jlleitschuh.gradle.ktlint") version ("11.0.0")
+ // Make sure to align with the Kotlin version.
+ // See https://github.com/google/ksp/releases
+ id("com.google.devtools.ksp") version ("1.9.0-1.0.12")
}
}
dependencyResolutionManagement {
diff --git a/test-app/build.gradle.kts b/test-app/build.gradle.kts
index b83699267c..082dd5f770 100644
--- a/test-app/build.gradle.kts
+++ b/test-app/build.gradle.kts
@@ -7,12 +7,12 @@
plugins {
id("com.android.application")
kotlin("android")
- kotlin("kapt")
+ id("com.google.devtools.ksp")
kotlin("plugin.parcelize")
}
android {
- compileSdk = 33
+ compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 33
@@ -28,11 +28,11 @@ android {
ndk.abiFilters.add("x86_64")
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}
composeOptions {
@@ -41,6 +41,7 @@ android {
buildFeatures {
viewBinding = true
compose = true
+ buildConfig = true
}
buildTypes {
getByName("release") {
@@ -107,7 +108,7 @@ dependencies {
// Room database
implementation(libs.bundles.room)
- kapt(libs.androidx.room.compiler)
+ ksp(libs.androidx.room.compiler)
// Tests
testImplementation(libs.junit)
diff --git a/test-app/src/main/AndroidManifest.xml b/test-app/src/main/AndroidManifest.xml
index 129d540698..0311776449 100644
--- a/test-app/src/main/AndroidManifest.xml
+++ b/test-app/src/main/AndroidManifest.xml
@@ -15,6 +15,8 @@
+
+
)
.bind(navigator, viewLifecycleOwner)
- viewLifecycleOwner.lifecycleScope.launchWhenStarted {
- // Display page number labels if the book contains a `page-list` navigation document.
- (navigator as? DecorableNavigator)?.applyPageNumberDecorations()
+ viewLifecycleOwner.lifecycleScope.launch {
+ viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
+ // Display page number labels if the book contains a `page-list` navigation document.
+ (navigator as? DecorableNavigator)?.applyPageNumberDecorations()
+ }
}
}
@@ -220,7 +225,7 @@ class EpubReaderFragment : VisualReaderFragment(), EpubNavigatorFragment.Listene
}
})
- menuSearchView.findViewById(R.id.search_close_btn).setOnClickListener {
+ menuSearchView.findViewById(androidx.appcompat.R.id.search_close_btn).setOnClickListener {
menuSearchView.requestFocus()
model.cancelSearch()
menuSearchView.setQuery("", false)
diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderActivity.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderActivity.kt
index e3b1465a38..d46e1ed4c9 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderActivity.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderActivity.kt
@@ -38,10 +38,8 @@ open class ReaderActivity : AppCompatActivity() {
private val model: ReaderViewModel by viewModels()
- override fun getDefaultViewModelProviderFactory(): ViewModelProvider.Factory {
- val arguments = ReaderActivityContract.parseIntent(this)
- return ReaderViewModel.createFactory(application as Application, arguments)
- }
+ override val defaultViewModelProviderFactory: ViewModelProvider.Factory
+ get() = ReaderViewModel.createFactory(application as Application, ReaderActivityContract.parseIntent(this))
private lateinit var binding: ActivityReaderBinding
private lateinit var readerFragment: BaseReaderFragment
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 b88905de3c..e81c8dde7d 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
@@ -359,76 +359,79 @@ abstract class VisualReaderFragment : BaseReaderFragment(), VisualNavigator.List
}
}
- private fun showHighlightPopupWithStyle(style: Highlight.Style) = viewLifecycleOwner.lifecycleScope.launchWhenResumed {
- // Get the rect of the current selection to know where to position the highlight
- // popup.
- (navigator as? SelectableNavigator)?.currentSelection()?.rect?.let { selectionRect ->
- showHighlightPopup(selectionRect, style)
+ private fun showHighlightPopupWithStyle(style: Highlight.Style) =
+ viewLifecycleOwner.lifecycleScope.launch {
+ // Get the rect of the current selection to know where to position the highlight
+ // popup.
+ (navigator as? SelectableNavigator)?.currentSelection()?.rect?.let { selectionRect ->
+ showHighlightPopup(selectionRect, style)
+ }
}
- }
private fun showHighlightPopup(rect: RectF, style: Highlight.Style, highlightId: Long? = null) =
- viewLifecycleOwner.lifecycleScope.launchWhenResumed {
- if (popupWindow?.isShowing == true) return@launchWhenResumed
+ viewLifecycleOwner.lifecycleScope.launch {
+ viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
+ if (popupWindow?.isShowing == true) return@repeatOnLifecycle
- model.activeHighlightId.value = highlightId
+ model.activeHighlightId.value = highlightId
- val isReverse = (rect.top > 60)
- val popupView = layoutInflater.inflate(
- if (isReverse) R.layout.view_action_mode_reverse else R.layout.view_action_mode,
- null,
- false
- )
- popupView.measure(
- View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
- View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
- )
+ val isReverse = (rect.top > 60)
+ val popupView = layoutInflater.inflate(
+ if (isReverse) R.layout.view_action_mode_reverse else R.layout.view_action_mode,
+ null,
+ false
+ )
+ popupView.measure(
+ View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
+ View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
+ )
- popupWindow = PopupWindow(
- popupView,
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT
- ).apply {
- isFocusable = true
- setOnDismissListener {
- model.activeHighlightId.value = null
+ popupWindow = PopupWindow(
+ popupView,
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT
+ ).apply {
+ isFocusable = true
+ setOnDismissListener {
+ model.activeHighlightId.value = null
+ }
}
- }
- val x = rect.left
- val y = if (isReverse) rect.top else rect.bottom + rect.height()
+ val x = rect.left
+ val y = if (isReverse) rect.top else rect.bottom + rect.height()
- popupWindow?.showAtLocation(popupView, Gravity.NO_GRAVITY, x.toInt(), y.toInt())
+ popupWindow?.showAtLocation(popupView, Gravity.NO_GRAVITY, x.toInt(), y.toInt())
- val highlight = highlightId?.let { model.highlightById(it) }
- popupView.run {
- findViewById(R.id.notch).run {
- setX(rect.left * 2)
- }
+ val highlight = highlightId?.let { model.highlightById(it) }
+ popupView.run {
+ findViewById(R.id.notch).run {
+ setX(rect.left * 2)
+ }
- fun selectTint(view: View) {
- val tint = highlightTints[view.id] ?: return
- selectHighlightTint(highlightId, style, tint)
- }
+ fun selectTint(view: View) {
+ val tint = highlightTints[view.id] ?: return
+ selectHighlightTint(highlightId, style, tint)
+ }
- findViewById(R.id.red).setOnClickListener(::selectTint)
- findViewById(R.id.green).setOnClickListener(::selectTint)
- findViewById(R.id.blue).setOnClickListener(::selectTint)
- findViewById(R.id.yellow).setOnClickListener(::selectTint)
- findViewById(R.id.purple).setOnClickListener(::selectTint)
+ findViewById(R.id.red).setOnClickListener(::selectTint)
+ findViewById(R.id.green).setOnClickListener(::selectTint)
+ findViewById(R.id.blue).setOnClickListener(::selectTint)
+ findViewById(R.id.yellow).setOnClickListener(::selectTint)
+ findViewById(R.id.purple).setOnClickListener(::selectTint)
- findViewById(R.id.annotation).setOnClickListener {
- popupWindow?.dismiss()
- showAnnotationPopup(highlightId)
- }
- findViewById(R.id.del).run {
- visibility = if (highlight != null) View.VISIBLE else View.GONE
- setOnClickListener {
- highlightId?.let {
- model.deleteHighlight(highlightId)
- }
+ findViewById(R.id.annotation).setOnClickListener {
popupWindow?.dismiss()
- mode?.finish()
+ showAnnotationPopup(highlightId)
+ }
+ findViewById(R.id.del).run {
+ visibility = if (highlight != null) View.VISIBLE else View.GONE
+ setOnClickListener {
+ highlightId?.let {
+ model.deleteHighlight(highlightId)
+ }
+ popupWindow?.dismiss()
+ mode?.finish()
+ }
}
}
}
@@ -439,71 +442,91 @@ abstract class VisualReaderFragment : BaseReaderFragment(), VisualNavigator.List
style: Highlight.Style,
@ColorInt tint: Int
) =
- viewLifecycleOwner.lifecycleScope.launchWhenResumed {
- if (highlightId != null) {
- model.updateHighlightStyle(highlightId, style, tint)
- } else {
- (navigator as? SelectableNavigator)?.let { navigator ->
- navigator.currentSelection()?.let { selection ->
- model.addHighlight(locator = selection.locator, style = style, tint = tint)
+ viewLifecycleOwner.lifecycleScope.launch {
+ viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
+ if (highlightId != null) {
+ model.updateHighlightStyle(highlightId, style, tint)
+ } else {
+ (navigator as? SelectableNavigator)?.let { navigator ->
+ navigator.currentSelection()?.let { selection ->
+ model.addHighlight(
+ locator = selection.locator,
+ style = style,
+ tint = tint
+ )
+ }
+ navigator.clearSelection()
}
- navigator.clearSelection()
}
- }
- popupWindow?.dismiss()
- mode?.finish()
- }
-
- private fun showAnnotationPopup(highlightId: Long? = null) = viewLifecycleOwner.lifecycleScope.launchWhenResumed {
- val activity = activity ?: return@launchWhenResumed
- val view = layoutInflater.inflate(R.layout.popup_note, null, false)
- val note = view.findViewById(R.id.note)
- val alert = AlertDialog.Builder(activity)
- .setView(view)
- .create()
-
- fun dismiss() {
- alert.dismiss()
- mode?.finish()
- (activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
- .hideSoftInputFromWindow(note.applicationWindowToken, InputMethodManager.HIDE_NOT_ALWAYS)
+ popupWindow?.dismiss()
+ mode?.finish()
+ }
}
- with(view) {
- val highlight = highlightId?.let { model.highlightById(it) }
- if (highlight != null) {
- note.setText(highlight.annotation)
- findViewById(R.id.sidemark).setBackgroundColor(highlight.tint)
- findViewById(R.id.select_text).text = highlight.locator.text.highlight
-
- findViewById(R.id.positive).setOnClickListener {
- val text = note.text.toString()
- model.updateHighlightAnnotation(highlight.id, annotation = text)
- dismiss()
+ private fun showAnnotationPopup(highlightId: Long? = null) =
+ viewLifecycleOwner.lifecycleScope.launch {
+ viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
+ val activity = activity ?: return@repeatOnLifecycle
+ val view = layoutInflater.inflate(R.layout.popup_note, null, false)
+ val note = view.findViewById(R.id.note)
+ val alert = AlertDialog.Builder(activity)
+ .setView(view)
+ .create()
+
+ fun dismiss() {
+ alert.dismiss()
+ mode?.finish()
+ (activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
+ .hideSoftInputFromWindow(
+ note.applicationWindowToken,
+ InputMethodManager.HIDE_NOT_ALWAYS
+ )
}
- } else {
- val tint = highlightTints.values.random()
- findViewById(R.id.sidemark).setBackgroundColor(tint)
- val navigator = navigator as? SelectableNavigator ?: return@launchWhenResumed
- val selection = navigator.currentSelection() ?: return@launchWhenResumed
- navigator.clearSelection()
- findViewById(R.id.select_text).text = selection.locator.text.highlight
-
- findViewById(R.id.positive).setOnClickListener {
- model.addHighlight(locator = selection.locator, style = Highlight.Style.HIGHLIGHT, tint = tint, annotation = note.text.toString())
- dismiss()
+
+ with(view) {
+ val highlight = highlightId?.let { model.highlightById(it) }
+ if (highlight != null) {
+ note.setText(highlight.annotation)
+ findViewById(R.id.sidemark).setBackgroundColor(highlight.tint)
+ findViewById(R.id.select_text).text =
+ highlight.locator.text.highlight
+
+ findViewById(R.id.positive).setOnClickListener {
+ val text = note.text.toString()
+ model.updateHighlightAnnotation(highlight.id, annotation = text)
+ dismiss()
+ }
+ } else {
+ val tint = highlightTints.values.random()
+ findViewById(R.id.sidemark).setBackgroundColor(tint)
+ val navigator =
+ navigator as? SelectableNavigator ?: return@repeatOnLifecycle
+ val selection = navigator.currentSelection() ?: return@repeatOnLifecycle
+ navigator.clearSelection()
+ findViewById(R.id.select_text).text =
+ selection.locator.text.highlight
+
+ findViewById(R.id.positive).setOnClickListener {
+ model.addHighlight(
+ locator = selection.locator,
+ style = Highlight.Style.HIGHLIGHT,
+ tint = tint,
+ annotation = note.text.toString()
+ )
+ dismiss()
+ }
+ }
+
+ findViewById(R.id.negative).setOnClickListener {
+ dismiss()
+ }
}
- }
- findViewById(R.id.negative).setOnClickListener {
- dismiss()
+ alert.show()
}
}
- alert.show()
- }
-
fun updateSystemUiVisibility() {
if (navigatorFragment.isHidden)
requireActivity().showSystemUi()
diff --git a/test-app/src/main/java/org/readium/r2/testapp/utils/LifecycleMedia2SessionService.kt b/test-app/src/main/java/org/readium/r2/testapp/utils/LifecycleMedia2SessionService.kt
index 7a26c0c4dc..8c781f1761 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/utils/LifecycleMedia2SessionService.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/utils/LifecycleMedia2SessionService.kt
@@ -57,7 +57,6 @@ abstract class LifecycleMedia2SessionService : MediaSessionService(), LifecycleO
super.onDestroy()
}
- override fun getLifecycle(): Lifecycle {
- return lifecycleDispatcher.lifecycle
- }
+ override val lifecycle: Lifecycle
+ get() = lifecycleDispatcher.lifecycle
}