diff --git a/.gitignore b/.gitignore index 578cc80a4b..eb12cd5541 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,5 @@ lint/reports/ # Docs docs/readium +docs/index.md +docs/package-list \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 02eec38335..47338f0595 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,36 +6,11 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial -buildscript { - val kotlinVersion by extra("1.6.10") - val dokkaVersion by extra("1.5.30") - - repositories { - google() - jcenter() - mavenLocal() - mavenCentral() - maven(url = "https://jitpack.io") - maven(url = "https://s3.amazonaws.com/repo.commonsware.com") - } - dependencies { - classpath("com.android.tools.build:gradle:7.0.4") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion") - } -} - -apply(plugin = "org.jetbrains.dokka") - -allprojects { - repositories { - google() - jcenter() - mavenLocal() - mavenCentral() - maven(url = "https://jitpack.io") - maven(url = "https://s3.amazonaws.com/repo.commonsware.com") - } +plugins { + id("com.android.application") version ("7.1.0") apply false + id("com.android.library") version ("7.1.0") apply false + id("org.jetbrains.kotlin.android") version ("1.6.10") apply false + id("org.jetbrains.dokka") version ("1.6.10") apply true } subprojects { diff --git a/readium/lcp/build.gradle.kts b/readium/lcp/build.gradle.kts index e0183d2115..9e129f175a 100644 --- a/readium/lcp/build.gradle.kts +++ b/readium/lcp/build.gradle.kts @@ -55,13 +55,13 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") api(project(":readium:shared")) - implementation("androidx.constraintlayout:constraintlayout:2.1.2") + implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("androidx.core:core-ktx:1.7.0") - implementation("com.google.android.material:material:1.4.0") + implementation("com.google.android.material:material:1.5.0") implementation("com.jakewharton.timber:timber:5.0.1") implementation("com.mcxiaoke.koi:async:0.5.5") { exclude(module = "support-v4") @@ -74,7 +74,7 @@ dependencies { implementation("androidx.browser:browser:1.4.0") // Room database - val roomVersion = "2.4.0" + val roomVersion = "2.4.1" implementation("androidx.room:room-runtime:$roomVersion") implementation("androidx.room:room-ktx:$roomVersion") kapt("androidx.room:room-compiler:$roomVersion") diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/service/DeviceService.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/service/DeviceService.kt index a50f7af1c2..da632f921b 100644 --- a/readium/lcp/src/main/java/org/readium/r2/lcp/service/DeviceService.kt +++ b/readium/lcp/src/main/java/org/readium/r2/lcp/service/DeviceService.kt @@ -9,9 +9,12 @@ package org.readium.r2.lcp.service +import android.Manifest import android.bluetooth.BluetoothManager import android.content.Context import android.content.SharedPreferences +import android.content.pm.PackageManager +import androidx.core.app.ActivityCompat import org.readium.r2.lcp.license.model.LicenseDocument import org.readium.r2.lcp.license.model.components.Link import timber.log.Timber @@ -36,7 +39,15 @@ internal class DeviceService(private val repository: DeviceRepository, private v context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager val bluetoothName = try { - bluetoothManager.adapter.name + if (ActivityCompat.checkSelfPermission( + context, + Manifest.permission.BLUETOOTH_CONNECT + ) != PackageManager.PERMISSION_GRANTED + ) { + null + } else { + bluetoothManager.adapter.name + } } catch (e: Exception) { Timber.e(e) null diff --git a/readium/navigator-media2/build.gradle.kts b/readium/navigator-media2/build.gradle.kts index 6e96ae14c2..bb00fa18d7 100644 --- a/readium/navigator-media2/build.gradle.kts +++ b/readium/navigator-media2/build.gradle.kts @@ -13,7 +13,7 @@ plugins { } android { - resourcePrefix = "readium_" + resourcePrefix = "readium_" compileSdk = 31 @@ -61,8 +61,8 @@ dependencies { api(project(":readium:shared")) api(project(":readium:navigator")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") implementation("com.jakewharton.timber:timber:5.0.1") diff --git a/readium/navigator/build.gradle.kts b/readium/navigator/build.gradle.kts index 8ea9893be3..27ca2bbdc3 100644 --- a/readium/navigator/build.gradle.kts +++ b/readium/navigator/build.gradle.kts @@ -62,9 +62,9 @@ dependencies { api(project(":readium:shared")) implementation("androidx.activity:activity-ktx:1.4.0") - implementation("androidx.appcompat:appcompat:1.4.0") + implementation("androidx.appcompat:appcompat:1.4.1") implementation("androidx.browser:browser:1.4.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.2") + implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.fragment:fragment-ktx:1.4.0") implementation("androidx.legacy:legacy-support-core-ui:1.0.0") @@ -92,12 +92,12 @@ dependencies { api("com.google.android.exoplayer:extension-mediasession:2.16.1") api("com.google.android.exoplayer:extension-media2:2.16.1") api("com.google.android.exoplayer:extension-workmanager:2.16.1") - implementation("com.google.android.material:material:1.4.0") + implementation("com.google.android.material:material:1.5.0") implementation("com.jakewharton.timber:timber:5.0.1") implementation("com.shopgun.android:utils:1.0.9") implementation("joda-time:joda-time:2.10.13") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") // AM NOTE: needs to stay this version for now (June 24,2020) //noinspection GradleDependency implementation("org.jsoup:jsoup:1.14.3") diff --git a/readium/opds/build.gradle.kts b/readium/opds/build.gradle.kts index 3e2a368271..7d24433244 100644 --- a/readium/opds/build.gradle.kts +++ b/readium/opds/build.gradle.kts @@ -53,11 +53,11 @@ dependencies { api(project(":readium:shared")) - implementation("androidx.appcompat:appcompat:1.4.0") + implementation("androidx.appcompat:appcompat:1.4.1") implementation("com.jakewharton.timber:timber:5.0.1") implementation("joda-time:joda-time:2.10.13") implementation("nl.komponents.kovenant:kovenant:3.3.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") // Tests testImplementation("junit:junit:4.13.2") diff --git a/readium/shared/build.gradle.kts b/readium/shared/build.gradle.kts index 215097bd9c..5058c61d6d 100644 --- a/readium/shared/build.gradle.kts +++ b/readium/shared/build.gradle.kts @@ -55,7 +55,7 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - implementation("androidx.appcompat:appcompat:1.4.0") + implementation("androidx.appcompat:appcompat:1.4.1") implementation("androidx.browser:browser:1.4.0") implementation("com.github.kittinunf.fuel:fuel-android:2.3.1") implementation("com.github.kittinunf.fuel:fuel:2.3.1") @@ -68,14 +68,14 @@ dependencies { implementation("nl.komponents.kovenant:kovenant-jvm:3.3.0") implementation("nl.komponents.kovenant:kovenant:3.3.0") implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.10") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") implementation("org.jsoup:jsoup:1.14.3") // Tests testImplementation("junit:junit:4.13.2") - testImplementation("org.assertj:assertj-core:3.21.0") + testImplementation("org.assertj:assertj-core:3.22.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.6.10") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.2") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0") testImplementation("org.robolectric:robolectric:4.7.3") androidTestImplementation("androidx.test.ext:junit:1.1.3") diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/LocatorServiceTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/LocatorServiceTest.kt index 3db53332bc..5f3109f080 100644 --- a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/LocatorServiceTest.kt +++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/LocatorServiceTest.kt @@ -7,7 +7,7 @@ package org.readium.r2.shared.publication.services import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runBlockingTest +import kotlinx.coroutines.test.runTest import org.junit.Test import org.readium.r2.shared.publication.Link import org.readium.r2.shared.publication.Locator @@ -19,7 +19,7 @@ class LocatorServiceTest { // locate(Locator) checks that the href exists. @Test - fun `locate from Locator`() = runBlockingTest { + fun `locate from Locator`() = runTest { val service = createService(readingOrder = listOf( Link(href = "chap1", type = "application/xml"), Link(href = "chap2", type = "application/xml"), @@ -30,14 +30,14 @@ class LocatorServiceTest { } @Test - fun `locate from Locator with empty reading order`() = runBlockingTest { + fun `locate from Locator with empty reading order`() = runTest { val service = createService(readingOrder = emptyList()) val locator = Locator(href = "chap2", type = "text/html", text = Locator.Text(highlight = "Highlight")) assertNull(service.locate(locator)) } @Test - fun `locate from Locator not found`() = runBlockingTest { + fun `locate from Locator not found`() = runTest { val service = createService(readingOrder = listOf( Link(href = "chap1", type = "application/xml"), Link(href = "chap3", type = "application/xml") @@ -47,7 +47,7 @@ class LocatorServiceTest { } @Test - fun `locate from progression`() = runBlockingTest { + fun `locate from progression`() = runTest { val service = createService(positions = positionsFixtures) assertEquals(Locator( @@ -116,14 +116,14 @@ class LocatorServiceTest { } @Test - fun `locate from incorrect progression`() = runBlockingTest { + fun `locate from incorrect progression`() = runTest { val service = createService(positions = positionsFixtures) assertNull(service.locateProgression(-0.2)) assertNull(service.locateProgression(1.2)) } @Test - fun `locate from progression with empty positions`() = runBlockingTest { + fun `locate from progression with empty positions`() = runTest { val service = createService(positions = emptyList()) assertNull(service.locateProgression(0.5)) } diff --git a/readium/streamer/build.gradle.kts b/readium/streamer/build.gradle.kts index 8af74a4f8c..059b1090ab 100644 --- a/readium/streamer/build.gradle.kts +++ b/readium/streamer/build.gradle.kts @@ -1,5 +1,3 @@ -import android.annotation.SuppressLint - /* * Copyright 2018 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -59,7 +57,7 @@ dependencies { api(project(":readium:shared")) - implementation("androidx.appcompat:appcompat:1.4.0") + implementation("androidx.appcompat:appcompat:1.4.1") @Suppress("GradleDependency") implementation("com.github.barteksc:pdfium-android:1.8.2") implementation("com.jakewharton.timber:timber:5.0.1") @@ -78,11 +76,11 @@ dependencies { exclude(module = "support-v4") } implementation("joda-time:joda-time:2.10.13") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") // Tests testImplementation("junit:junit:4.13.2") - testImplementation("org.assertj:assertj-core:3.21.0") + testImplementation("org.assertj:assertj-core:3.22.0") testImplementation("org.robolectric:robolectric:4.7.3") androidTestImplementation("androidx.test.ext:junit:1.1.3") androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") diff --git a/settings.gradle.kts b/settings.gradle.kts index 269ec8cdc1..79e5331c3a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,6 +10,23 @@ pluginManagement { repositories { gradlePluginPortal() + google() + jcenter() + mavenLocal() + mavenCentral() + maven(url = "https://jitpack.io") + maven(url = "https://s3.amazonaws.com/repo.commonsware.com") + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + jcenter() + mavenLocal() + mavenCentral() + maven(url = "https://jitpack.io") + maven(url = "https://s3.amazonaws.com/repo.commonsware.com") } } diff --git a/test-app/build.gradle.kts b/test-app/build.gradle.kts index b3172dd711..a20d63be9c 100644 --- a/test-app/build.gradle.kts +++ b/test-app/build.gradle.kts @@ -73,10 +73,10 @@ dependencies { implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.activity:activity-ktx:1.4.0") - implementation("androidx.appcompat:appcompat:1.4.0") + implementation("androidx.appcompat:appcompat:1.4.1") implementation("androidx.browser:browser:1.4.0") implementation("androidx.cardview:cardview:1.0.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.2") + implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("androidx.fragment:fragment-ktx:1.4.0") implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") @@ -93,12 +93,12 @@ dependencies { implementation("com.github.edrlab.nanohttpd:nanohttpd-nanolets:master-SNAPSHOT") { exclude(group = "org.parboiled") } - implementation("com.google.android.material:material:1.4.0") + implementation("com.google.android.material:material:1.5.0") implementation("com.jakewharton.timber:timber:5.0.1") // AM NOTE: needs to stay this version for now (June 24,2020) implementation("com.squareup.picasso:picasso:2.71828") implementation("joda-time:joda-time:2.10.13") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") // AM NOTE: needs to stay this version for now (June 24,2020) implementation("org.jsoup:jsoup:1.14.3") @@ -106,13 +106,13 @@ dependencies { implementation("androidx.media2:media2-player:1.2.0") // Room database - val roomVersion = "2.4.0" + val roomVersion = "2.4.1" implementation("androidx.room:room-runtime:$roomVersion") implementation("androidx.room:room-ktx:$roomVersion") kapt("androidx.room:room-compiler:$roomVersion") implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") - kapt ("androidx.lifecycle:lifecycle-compiler:2.4.0") + kapt("androidx.lifecycle:lifecycle-compiler:2.4.0") // Tests testImplementation("junit:junit:4.13.2") diff --git a/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfFragment.kt index ca8200dd04..8c5212b292 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfFragment.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfFragment.kt @@ -81,9 +81,9 @@ class BookshelfFragment : Fragment() { ) } - bookshelfViewModel.books.observe(viewLifecycleOwner, { + bookshelfViewModel.books.observe(viewLifecycleOwner) { bookshelfAdapter.submitList(it) - }) + } // FIXME embedded dialogs like this are ugly binding.bookshelfAddBookFab.setOnClickListener { @@ -116,7 +116,7 @@ class BookshelfFragment : Fragment() { val url = urlEditText.text.toString() val uri = Uri.parse(url) binding.bookshelfProgressBar.visibility = View.VISIBLE - bookshelfViewModel.importPublicationFromUri(uri, url) + bookshelfViewModel.importPublicationFromUri(uri) urlDialog.dismiss() } } diff --git a/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfViewModel.kt b/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfViewModel.kt index 0f40676fe9..1790d4b08a 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfViewModel.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfViewModel.kt @@ -105,18 +105,16 @@ class BookshelfViewModel(application: Application) : AndroidViewModel(applicatio } fun importPublicationFromUri( - uri: Uri, - sourceUrl: String? = null + uri: Uri ) = viewModelScope.launch { uri.copyToTempFile(r2Application, r2Directory) ?.let { - importPublication(it, sourceUrl) + importPublication(it) } } private suspend fun importPublication( - sourceFile: File, - sourceUrl: String? = null + sourceFile: File ) { val sourceMediaType = sourceFile.mediaType() val publicationAsset: FileAsset = 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 66cf3561f8..5d4a7a7985 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 @@ -122,9 +122,9 @@ open class ReaderActivity : AppCompatActivity() { null } - readerClass?.let { readerClass -> + readerClass?.let { it -> supportFragmentManager.commitNow { - replace(R.id.activity_container, readerClass, Bundle(), READER_FRAGMENT_TAG) + replace(R.id.activity_container, it, Bundle(), READER_FRAGMENT_TAG) } }