From febbbd975282cc32a8a08b78de5ac080fc65ba45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Menu?= Date: Mon, 1 Jul 2024 09:57:39 +0200 Subject: [PATCH] Upgrade to Kotlin 1.9.0 and bump dependencies --- .github/workflows/checks.yml | 18 +- .github/workflows/docs.yml | 8 +- .github/workflows/publish.yml | 8 +- .idea/kotlinc.xml | 2 +- README.md | 3 +- build.gradle.kts | 1 + gradle.properties | 2 - gradle/libs.versions.toml | 64 ++--- gradle/wrapper/gradle-wrapper.properties | 3 +- readium/adapters/pdfium/build.gradle.kts | 8 +- .../pdfium/pdfium-document/build.gradle.kts | 8 +- .../pdfium/pdfium-navigator/build.gradle.kts | 8 +- readium/adapters/pspdfkit/build.gradle.kts | 8 +- .../pspdfkit-document/build.gradle.kts | 8 +- .../pspdfkit-navigator/build.gradle.kts | 8 +- .../navigator/PsPdfKitDocumentFragment.kt | 6 +- readium/lcp/build.gradle.kts | 16 +- .../readium/r2/lcp/persistence/LcpDatabase.kt | 16 +- .../org/readium/r2/lcp/service/LcpClient.kt | 2 +- readium/navigator-media2/build.gradle.kts | 8 +- readium/navigator/build.gradle.kts | 11 +- .../r2/navigator/epub/fxl/R2FXLLayout.kt | 5 +- .../r2/navigator/extensions/Locator.kt | 2 +- .../media3/tts/session/TtsSessionAdapter.kt | 29 ++- readium/opds/build.gradle.kts | 8 +- readium/shared/build.gradle.kts | 9 +- readium/streamer/build.gradle.kts | 9 +- settings.gradle.kts | 13 +- test-app/build.gradle.kts | 13 +- test-app/src/main/AndroidManifest.xml | 2 + .../r2/testapp/reader/EpubReaderFragment.kt | 15 +- .../r2/testapp/reader/ReaderActivity.kt | 6 +- .../r2/testapp/reader/VisualReaderFragment.kt | 233 ++++++++++-------- .../utils/LifecycleMedia2SessionService.kt | 5 +- 34 files changed, 313 insertions(+), 252 deletions(-) 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/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 46b9be992c..404a7bee15 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 a32be7e185..b83ae79e70 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 31ce3a0f4d..ad9adf810a 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/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/epub/fxl/R2FXLLayout.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/fxl/R2FXLLayout.kt index 48f1ed9c64..883e3e8e79 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 @@ -299,8 +299,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 +318,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..498fd2712c 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 @@ -70,5 +70,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/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/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/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/settings.gradle.kts b/settings.gradle.kts index c1b9f5d53a..cbc752086c 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..32f19b54ab 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,7 +359,8 @@ abstract class VisualReaderFragment : BaseReaderFragment(), VisualNavigator.List } } - private fun showHighlightPopupWithStyle(style: Highlight.Style) = viewLifecycleOwner.lifecycleScope.launchWhenResumed { + 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 -> @@ -368,67 +369,69 @@ abstract class VisualReaderFragment : BaseReaderFragment(), VisualNavigator.List } 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 }