diff --git a/build.gradle b/build.gradle
index a76ba160be..e79bea2c43 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@
*/
buildscript {
- ext.kotlin_version = '1.5.31'
+ ext.kotlin_version = '1.6.10'
ext.dokka_version = '1.5.30'
repositories {
@@ -17,7 +17,7 @@ buildscript {
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.0.3'
+ classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
}
diff --git a/readium/lcp/build.gradle b/readium/lcp/build.gradle
index ef0f868b71..a3efadd69e 100644
--- a/readium/lcp/build.gradle
+++ b/readium/lcp/build.gradle
@@ -59,10 +59,10 @@ dependencies {
api project(':readium:shared')
- implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
- implementation 'androidx.core:core-ktx:1.6.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
+ implementation 'androidx.core:core-ktx:1.7.0'
implementation 'com.google.android.material:material:1.4.0'
- implementation "com.jakewharton.timber:timber:4.7.1"
+ implementation 'com.jakewharton.timber:timber:5.0.1'
implementation("com.mcxiaoke.koi:async:0.5.5") {
exclude module: 'support-v4'
}
@@ -71,16 +71,15 @@ dependencies {
}
implementation 'joda-time:joda-time:2.10.13'
implementation "org.zeroturnaround:zt-zip:1.14"
- implementation 'androidx.browser:browser:1.3.0'
+ implementation 'androidx.browser:browser:1.4.0'
- final room_version = '2.4.0-beta01'
+ final room_version = '2.4.0'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
+ // Tests
testImplementation "junit:junit:4.13.2"
- testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
-
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
- androidTestImplementation 'androidx.test:runner:1.4.0'
}
diff --git a/readium/lcp/src/main/java/org/readium/r2/lcp/license/LicenseValidation.kt b/readium/lcp/src/main/java/org/readium/r2/lcp/license/LicenseValidation.kt
index ded1fef6e1..2b68951ad7 100644
--- a/readium/lcp/src/main/java/org/readium/r2/lcp/license/LicenseValidation.kt
+++ b/readium/lcp/src/main/java/org/readium/r2/lcp/license/LicenseValidation.kt
@@ -21,9 +21,8 @@ import org.readium.r2.shared.util.getOrElse
import org.readium.r2.shared.util.mediatype.MediaType
import timber.log.Timber
import java.util.*
-import kotlin.time.Duration
+import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
-import kotlin.time.seconds
internal sealed class Either {
class Left(val left: A) : Either()
@@ -316,9 +315,7 @@ internal class LicenseValidation(
private suspend fun fetchStatus(license: LicenseDocument) {
val url = license.url(LicenseDocument.Rel.status, preferredType = MediaType.LCP_STATUS_DOCUMENT).toString()
// Short timeout to avoid blocking the License, since the LSD is optional.
- // FIXME: To remove after bumping to Kotlin 1.6
- @Suppress("DEPRECATION")
- val data = network.fetch(url, timeout = Duration.seconds(5))
+ val data = network.fetch(url, timeout = 5.seconds)
.getOrElse { throw LcpException.Network(it) }
raise(Event.retrievedStatusData(data))
@@ -332,9 +329,7 @@ internal class LicenseValidation(
private suspend fun fetchLicense(status: StatusDocument) {
val url = status.url(StatusDocument.Rel.license, preferredType = MediaType.LCP_LICENSE_DOCUMENT).toString()
// Short timeout to avoid blocking the License, since it can be updated next time.
- // FIXME: To remove after bumping to Kotlin 1.6
- @Suppress("DEPRECATION")
- val data = network.fetch(url, timeout = Duration.seconds(5))
+ val data = network.fetch(url, timeout = 5.seconds)
.getOrElse { throw LcpException.Network(it) }
raise(Event.retrievedLicenseData(data))
diff --git a/readium/navigator/build.gradle b/readium/navigator/build.gradle
index 1886351fd7..9c7bc0ae49 100644
--- a/readium/navigator/build.gradle
+++ b/readium/navigator/build.gradle
@@ -62,35 +62,35 @@ dependencies {
api project(':readium:shared')
- implementation 'androidx.activity:activity-ktx:1.3.1'
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation "androidx.browser:browser:1.3.0"
- implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
- implementation 'androidx.core:core-ktx:1.6.0'
- implementation 'androidx.fragment:fragment-ktx:1.3.6'
+ implementation 'androidx.activity:activity-ktx:1.4.0'
+ implementation 'androidx.appcompat:appcompat:1.4.0'
+ implementation "androidx.browser:browser:1.4.0"
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
+ 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"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
- implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
- implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
- implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
- implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1"
+ implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
+ implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
+ implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.4.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.media:media:1.4.3"
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation "androidx.webkit:webkit:1.4.0"
// Needed to avoid a crash with API 31, see https://stackoverflow.com/a/69152986/1474476
- implementation 'androidx.work:work-runtime-ktx:2.7.0'
+ implementation 'androidx.work:work-runtime-ktx:2.7.1'
implementation "com.duolingo.open:rtl-viewpager:1.0.3"
api "com.github.barteksc:android-pdf-viewer:2.8.2"
// ChrisBane/PhotoView ( for the Zoom handling )
implementation "com.github.chrisbanes:PhotoView:2.3.0"
// ExoPlayer is used by the Audio Navigator.
- api 'com.google.android.exoplayer:exoplayer-core:2.15.1'
- api 'com.google.android.exoplayer:exoplayer-ui:2.15.1'
- api 'com.google.android.exoplayer:extension-mediasession:2.15.1'
- api 'com.google.android.exoplayer:extension-workmanager:2.15.1'
+ api 'com.google.android.exoplayer:exoplayer-core:2.16.1'
+ api 'com.google.android.exoplayer:exoplayer-ui:2.16.1'
+ api 'com.google.android.exoplayer:extension-mediasession:2.16.1'
+ api 'com.google.android.exoplayer:extension-workmanager:2.16.1'
implementation 'com.google.android.material:material:1.4.0'
- implementation "com.jakewharton.timber:timber:4.7.1"
+ 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"
@@ -99,9 +99,8 @@ dependencies {
//noinspection GradleDependency
implementation 'org.jsoup:jsoup:1.14.3'
+ // Tests
testImplementation "junit:junit:4.13.2"
- testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
-
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
- androidTestImplementation 'androidx.test:runner:1.4.0'
}
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 62b5ac5509..c173130a45 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
@@ -322,7 +322,7 @@ class R2FXLLayout : FrameLayout {
// only fling if no scale is needed - scale will happen on ACTION_UP
flingRunnable = FlingRunnable(context)
flingRunnable!!.fling(velocityX.toInt(), velocityY.toInt())
- ViewCompat.postOnAnimation(this@R2FXLLayout, flingRunnable)
+ ViewCompat.postOnAnimation(this@R2FXLLayout, flingRunnable!!)
return true
}
return false
@@ -429,7 +429,7 @@ class R2FXLLayout : FrameLayout {
if (animate) {
animatedZoomRunnable = AnimatedZoomRunnable()
animatedZoomRunnable!!.scale(scale, newScale, this.focusX, this.focusY, true)
- ViewCompat.postOnAnimation(this@R2FXLLayout, animatedZoomRunnable)
+ ViewCompat.postOnAnimation(this@R2FXLLayout, animatedZoomRunnable!!)
} else {
zoomDispatcher.onZoomBegin(newScale)
internalScale(newScale, this.focusX, this.focusY)
@@ -531,7 +531,7 @@ class R2FXLLayout : FrameLayout {
val newScale = NumberUtils.clamp(minScale, scale, maxScale)
scale(scale, newScale, focusX, focusY, true)
if (animatedZoomRunnable!!.doScale() || animatedZoomRunnable!!.doTranslate()) {
- ViewCompat.postOnAnimation(this@R2FXLLayout, animatedZoomRunnable)
+ ViewCompat.postOnAnimation(this@R2FXLLayout, animatedZoomRunnable!!)
return true
}
return false
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt
index 8611227841..c2f40044a9 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/ExoMediaPlayer.kt
@@ -192,7 +192,7 @@ class ExoMediaPlayer(
private inner class PlaybackPreparer : MediaSessionConnector.PlaybackPreparer {
- override fun onCommand(player: Player, controlDispatcher: ControlDispatcher, command: String, extras: Bundle?, cb: ResultReceiver?): Boolean =
+ override fun onCommand(player: Player, command: String, extras: Bundle?, cb: ResultReceiver?): Boolean =
listener?.onCommand(command, extras, cb) ?: false
override fun getSupportedPrepareActions(): Long =
diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/util/ViewModelFactory.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/util/ViewModelFactory.kt
index 8796c19da4..230c9c6500 100644
--- a/readium/navigator/src/main/java/org/readium/r2/navigator/util/ViewModelFactory.kt
+++ b/readium/navigator/src/main/java/org/readium/r2/navigator/util/ViewModelFactory.kt
@@ -16,7 +16,7 @@ import androidx.lifecycle.ViewModelProvider
internal inline fun createViewModelFactory(crossinline factory: () -> T): ViewModelProvider.Factory =
object : ViewModelProvider.Factory {
- override fun create(modelClass: Class): V {
+ override fun create(modelClass: Class): V {
if (!modelClass.isAssignableFrom(T::class.java)) {
throw IllegalAccessException("Unknown ViewModel class")
}
diff --git a/readium/opds/build.gradle b/readium/opds/build.gradle
index 4700ed89be..068efaacc2 100644
--- a/readium/opds/build.gradle
+++ b/readium/opds/build.gradle
@@ -53,25 +53,15 @@ dependencies {
api project(':readium:shared')
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation "com.jakewharton.timber:timber:4.7.1"
+ implementation 'androidx.appcompat:appcompat:1.4.0'
+ 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"
- testImplementation 'androidx.test.ext:junit-ktx:1.1.3'
- testImplementation 'androidx.test:core-ktx:1.4.0'
- testImplementation "junit:junit:4.13.2"
- testImplementation "net.sf.kxml:kxml2:2.3.0"
- testImplementation 'org.assertj:assertj-core:3.19.0'
- testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.5.31"
- testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
- testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0"
- testImplementation "org.json:json:20200518"
- testImplementation "org.mockito:mockito-core:3.3.3"
- testImplementation 'org.robolectric:robolectric:4.5.1'
- testImplementation "xmlpull:xmlpull:1.1.3.1"
-
+ // Tests
+ testImplementation 'junit:junit:4.13.2'
+ testImplementation 'org.robolectric:robolectric:4.7.3'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
- androidTestImplementation 'androidx.test:runner:1.4.0'
}
diff --git a/readium/shared/build.gradle b/readium/shared/build.gradle
index d166be8696..ce1820b694 100644
--- a/readium/shared/build.gradle
+++ b/readium/shared/build.gradle
@@ -56,11 +56,11 @@ afterEvaluate {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation 'androidx.browser:browser:1.3.0'
- implementation "com.github.kittinunf.fuel:fuel-android:2.2.2"
- implementation "com.github.kittinunf.fuel:fuel:2.2.2"
- implementation "com.jakewharton.timber:timber:4.7.1"
+ implementation 'androidx.appcompat:appcompat:1.4.0'
+ 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'
+ implementation 'com.jakewharton.timber:timber:5.0.1'
implementation "joda-time:joda-time:2.10.13"
implementation "nl.komponents.kovenant:kovenant-android:3.3.0"
implementation "nl.komponents.kovenant:kovenant-combine:3.3.0"
@@ -68,25 +68,17 @@ dependencies {
implementation "nl.komponents.kovenant:kovenant-functional:3.3.0"
implementation "nl.komponents.kovenant:kovenant-jvm:3.3.0"
implementation "nl.komponents.kovenant:kovenant:3.3.0"
- implementation "org.jetbrains.kotlin:kotlin-reflect:1.5.31"
+ implementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.10'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
implementation "org.jsoup:jsoup:1.14.3"
- testImplementation 'androidx.test.ext:junit-ktx:1.1.3'
- testImplementation 'androidx.test:core-ktx:1.4.0'
+ // Tests
testImplementation "junit:junit:4.13.2"
- testImplementation "net.sf.kxml:kxml2:2.3.0"
- testImplementation 'org.assertj:assertj-core:3.19.0'
- testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.5.31"
+ testImplementation 'org.assertj:assertj-core:3.21.0'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
- testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0"
- // Latest version of org.json is incompatible with the one bundled in Android, breaking the tests.
- //noinspection GradleDependency
- testImplementation "org.json:json:20200518"
- testImplementation "org.mockito:mockito-core:3.3.3"
- testImplementation 'org.robolectric:robolectric:4.5.1'
- testImplementation "xmlpull:xmlpull:1.1.3.1"
+ testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.2"
+ testImplementation 'org.robolectric:robolectric:4.7.3'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
- androidTestImplementation 'androidx.test:runner:1.4.0'
}
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/extensions/JSONTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/extensions/JSONTest.kt
index 2a16789544..232345e6ca 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/extensions/JSONTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/extensions/JSONTest.kt
@@ -8,6 +8,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class JSONTest {
@Test fun `unpack an empty JSONObject`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/opds/AcquisitionTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/opds/AcquisitionTest.kt
index 041ec8a558..368d7ce0bd 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/opds/AcquisitionTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/opds/AcquisitionTest.kt
@@ -13,9 +13,12 @@ import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.toJSON
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class AcquisitionTest {
@Test fun `parse minimal JSON acquisition`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/opds/AvailabilityTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/opds/AvailabilityTest.kt
index 500ffc851e..40ce7d7a6a 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/opds/AvailabilityTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/opds/AvailabilityTest.kt
@@ -3,9 +3,12 @@ package org.readium.r2.shared.opds
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.extensions.iso8601ToDate
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class AvailabilityTest {
@Test fun `parse JSON availability state`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/opds/CopiesTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/opds/CopiesTest.kt
index d3989e0dd7..4d58ff355b 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/opds/CopiesTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/opds/CopiesTest.kt
@@ -12,8 +12,11 @@ package org.readium.r2.shared.opds
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class CopiesTest {
@Test fun `parse minimal JSON copies`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/opds/HoldsTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/opds/HoldsTest.kt
index 7549aa5d31..b4f2d2f7a9 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/opds/HoldsTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/opds/HoldsTest.kt
@@ -12,8 +12,11 @@ package org.readium.r2.shared.opds
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class HoldsTest {
@Test fun `parse minimal JSON holds`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/opds/PriceTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/opds/PriceTest.kt
index 59991b2528..dc39f9e68e 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/opds/PriceTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/opds/PriceTest.kt
@@ -10,10 +10,14 @@
package org.readium.r2.shared.opds
import org.json.JSONObject
-import org.junit.Assert.*
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PriceTest {
@Test fun `parse JSON price`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt
index 86e94d9e67..bac36c0411 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/parser/xml/XmlParserTest.kt
@@ -10,6 +10,8 @@
package org.readium.r2.shared.parser.xml
import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
import org.xmlpull.v1.XmlPullParserException
import java.io.ByteArrayInputStream
import javax.xml.XMLConstants
@@ -42,6 +44,7 @@ private fun parseXmlString(string: String, namespaceAware: Boolean = true): Elem
return parser.parse(stream)
}
+@RunWith(RobolectricTestRunner::class)
class XmlParserTest {
@Test
fun testNotNamespaceAwareV3() {
@@ -199,6 +202,7 @@ class XmlParserTest {
}
}
+@RunWith(RobolectricTestRunner::class)
class ElementNodeTest {
@Test
fun testCollectText() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/ContributorTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/ContributorTest.kt
index 7b99580a1e..2a484c275e 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/ContributorTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/ContributorTest.kt
@@ -13,9 +13,12 @@ import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.toJSON
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class ContributorTest {
@Test fun `parse JSON string`() {
@@ -193,7 +196,7 @@ class ContributorTest {
assertJSONEquals(
JSONArray("""[
{
- "name": {"und": "Thom Yorke"},
+ "name": {"und": "Thom Yorke"}
},
{
"name": {"en": "Jonny Greenwood", "fr": "Jean Boisvert"},
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/LocalizedStringTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/LocalizedStringTest.kt
index 0c7832dbb6..150d66ca9e 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/LocalizedStringTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/LocalizedStringTest.kt
@@ -13,9 +13,12 @@ import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
import java.util.*
+@RunWith(RobolectricTestRunner::class)
class LocalizedStringTest {
@Test fun `parse JSON string`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/LocatorTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/LocatorTest.kt
index a8edc4ba7a..742e3eb458 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/LocatorTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/LocatorTest.kt
@@ -12,8 +12,11 @@ package org.readium.r2.shared.publication
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class LocatorTest {
@Test fun `parse {Locator} minimal JSON`() {
@@ -296,6 +299,7 @@ class LocatorTest {
}
+@RunWith(RobolectricTestRunner::class)
class LocatorCollectionTest {
@Test fun `parse {LocatorCollection} minimal JSON`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/MetadataTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/MetadataTest.kt
index 9c867ff4c7..93b9f9196f 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/MetadataTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/MetadataTest.kt
@@ -12,9 +12,12 @@ package org.readium.r2.shared.publication
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.extensions.iso8601ToDate
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class MetadataTest {
@Test fun `parse minimal JSON`() {
@@ -79,7 +82,7 @@ class MetadataTest {
"@type": "epub",
"conformsTo": [
"https://readium.org/webpub-manifest/profiles/epub",
- "https://readium.org/webpub-manifest/profiles/pdf",
+ "https://readium.org/webpub-manifest/profiles/pdf"
],
"title": {"en": "Title", "fr": "Titre"},
"subtitle": {"en": "Subtitle", "fr": "Sous-titre"},
@@ -182,7 +185,7 @@ class MetadataTest {
"@type": "epub",
"conformsTo": [
"https://readium.org/webpub-manifest/profiles/epub",
- "https://readium.org/webpub-manifest/profiles/pdf",
+ "https://readium.org/webpub-manifest/profiles/pdf"
],
"title": {"en": "Title", "fr": "Titre"},
"subtitle": {"en": "Subtitle", "fr": "Sous-titre"},
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/PropertiesTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/PropertiesTest.kt
index fd519b0e6f..768c53ef62 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/PropertiesTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/PropertiesTest.kt
@@ -12,8 +12,11 @@ package org.readium.r2.shared.publication
import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PropertiesTest {
@Test fun `parse null JSON`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationCollectionTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationCollectionTest.kt
index a72ac4caf0..bedeb22dab 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationCollectionTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/PublicationCollectionTest.kt
@@ -12,8 +12,11 @@ package org.readium.r2.shared.publication
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PublicationCollectionTest {
@Test fun `parse minimal JSON`() {
@@ -143,7 +146,7 @@ class PublicationCollectionTest {
"links": [
{"href": "/sublink1", "templated": false},
{"href": "/sublink2", "templated": false}
- ],
+ ]
},
"sub3": [
{
@@ -189,7 +192,7 @@ class PublicationCollectionTest {
"links": [
{"href": "/sublink1", "templated": false},
{"href": "/sublink2", "templated": false}
- ],
+ ]
},
"sub3": [
{
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/SubjectTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/SubjectTest.kt
index 8111f026ff..13578e369d 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/SubjectTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/SubjectTest.kt
@@ -13,9 +13,12 @@ import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.toJSON
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class SubjectTest {
@Test fun `parse JSON string`() {
@@ -167,7 +170,7 @@ class SubjectTest {
assertJSONEquals(
JSONArray("""[
{
- "name": {"und": "Fantasy"},
+ "name": {"und": "Fantasy"}
},
{
"name": {"und": "Science Fiction"},
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/archive/PropertiesTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/archive/PropertiesTest.kt
index a2a3124025..9ac63bfd2b 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/archive/PropertiesTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/archive/PropertiesTest.kt
@@ -4,9 +4,12 @@ import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.publication.Properties
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PropertiesTest {
@Test
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/EncryptionTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/EncryptionTest.kt
index 4ec7e76fef..fa6035612f 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/EncryptionTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/EncryptionTest.kt
@@ -12,9 +12,12 @@ package org.readium.r2.shared.publication.encryption
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.extensions.toMap
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class EncryptionTest {
@Test
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/PropertiesTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/PropertiesTest.kt
index 7306ba883b..512e499886 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/PropertiesTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/encryption/PropertiesTest.kt
@@ -11,8 +11,11 @@ package org.readium.r2.shared.publication.encryption
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.publication.Properties
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PropertiesTest {
@Test fun `get Properties {encryption} when available`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/html/DomRangeTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/html/DomRangeTest.kt
index 2329d50bf5..5000a0cdc1 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/html/DomRangeTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/html/DomRangeTest.kt
@@ -11,10 +11,13 @@ package org.readium.r2.shared.publication.html
import org.json.JSONObject
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
+import org.robolectric.RobolectricTestRunner
import kotlin.test.assertEquals
import kotlin.test.assertNull
+@RunWith(RobolectricTestRunner::class)
class DomRangeTest {
@Test fun `parse {DomRange} minimal JSON`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/html/LocatorTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/html/LocatorTest.kt
index 80d46f2402..e4da2a51a4 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/html/LocatorTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/html/LocatorTest.kt
@@ -11,8 +11,11 @@ package org.readium.r2.shared.publication.html
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.publication.Locator
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class LocatorTest {
@Test fun `get Locations {cssSelector} when available`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/opds/PropertiesTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/opds/PropertiesTest.kt
index 56634c1261..7715a9ff90 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/opds/PropertiesTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/opds/PropertiesTest.kt
@@ -12,10 +12,13 @@ package org.readium.r2.shared.publication.opds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.opds.*
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Properties
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PropertiesTest {
@Test fun `get Properties {numberOfItems} when available`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/MetadataTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/MetadataTest.kt
index f71cbed0d5..448a394674 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/MetadataTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/MetadataTest.kt
@@ -11,9 +11,12 @@ package org.readium.r2.shared.publication.presentation
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.publication.LocalizedString
import org.readium.r2.shared.publication.Metadata
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class MetadataTest {
@Test fun `get Metadata {presentation} when available`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/PresentationTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/PresentationTest.kt
index 66d1b060a7..3500bffd91 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/PresentationTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/presentation/PresentationTest.kt
@@ -12,9 +12,12 @@ package org.readium.r2.shared.publication.presentation
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.assertJSONEquals
import org.readium.r2.shared.publication.epub.EpubLayout
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class PresentationTest {
@Test fun `parse null JSON`() {
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt
index 22b07c9e65..9420b04b03 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/publication/services/PositionsServiceTest.kt
@@ -13,13 +13,16 @@ import kotlinx.coroutines.runBlocking
import org.json.JSONObject
import org.junit.Assert
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.extensions.mapNotNull
import org.readium.r2.shared.extensions.optNullableInt
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Locator
import org.readium.r2.shared.publication.Publication
+import org.robolectric.RobolectricTestRunner
import kotlin.test.assertEquals
+@RunWith(RobolectricTestRunner::class)
class PositionsServiceTest {
@Test
diff --git a/readium/shared/src/test/java/org/readium/r2/shared/util/http/ProblemDetailsTest.kt b/readium/shared/src/test/java/org/readium/r2/shared/util/http/ProblemDetailsTest.kt
index d4a9cfef56..bfb45f9269 100644
--- a/readium/shared/src/test/java/org/readium/r2/shared/util/http/ProblemDetailsTest.kt
+++ b/readium/shared/src/test/java/org/readium/r2/shared/util/http/ProblemDetailsTest.kt
@@ -3,7 +3,10 @@ package org.readium.r2.shared.util.http
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class ProblemDetailsTest {
@Test
diff --git a/readium/streamer/build.gradle b/readium/streamer/build.gradle
index b0680f9094..e14624c751 100644
--- a/readium/streamer/build.gradle
+++ b/readium/streamer/build.gradle
@@ -58,13 +58,9 @@ dependencies {
api project(':readium:shared')
- final JACKSON_VERSION = '2.12.4'
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation "com.fasterxml.jackson.core:jackson-annotations:$JACKSON_VERSION"
- implementation "com.fasterxml.jackson.core:jackson-core:$JACKSON_VERSION"
- implementation "com.fasterxml.jackson.core:jackson-databind:$JACKSON_VERSION"
- implementation "com.github.barteksc:pdfium-android:1.7.1"
- implementation "com.jakewharton.timber:timber:4.7.1"
+ implementation 'androidx.appcompat:appcompat:1.4.0'
+ implementation 'com.github.barteksc:pdfium-android:1.9.0'
+ implementation 'com.jakewharton.timber:timber:5.0.1'
//noinspection GradleDependency
implementation ("com.github.edrlab.nanohttpd:nanohttpd:master-SNAPSHOT") {
exclude group: 'org.parboiled'
@@ -84,21 +80,10 @@ dependencies {
implementation "joda-time:joda-time:2.10.13"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
- testImplementation 'androidx.test.ext:junit-ktx:1.1.3'
- testImplementation 'androidx.test:core-ktx:1.4.0'
- testImplementation "junit:junit:4.13.2"
- testImplementation "net.sf.kxml:kxml2:2.3.0"
- testImplementation 'org.assertj:assertj-core:3.19.0'
- testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.5.31"
- testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
- testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0"
- // Latest version of org.json is incompatible with the one bundled in Android, breaking the tests.
- //noinspection GradleDependency
- testImplementation "org.json:json:20200518"
- testImplementation "org.mockito:mockito-core:3.3.3"
- testImplementation 'org.robolectric:robolectric:4.5.1'
- testImplementation "xmlpull:xmlpull:1.1.3.1"
-
+ // Tests
+ testImplementation 'junit:junit:4.13.2'
+ testImplementation 'org.assertj:assertj-core:3.21.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'
- androidTestImplementation 'androidx.test:runner:1.4.0'
}
diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/server/Server.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/server/Server.kt
index d871b87c2a..a762d6dd92 100755
--- a/readium/streamer/src/main/java/org/readium/r2/streamer/server/Server.kt
+++ b/readium/streamer/src/main/java/org/readium/r2/streamer/server/Server.kt
@@ -110,9 +110,6 @@ abstract class AbstractServer(
try { URLDecoder.decode(baseUrl.path, "UTF-8") }
catch (e: Exception) { baseUrl.path }
- if (containsMediaOverlay) {
- setRoute(basePath + MEDIA_OVERLAY_HANDLE, MediaOverlayHandler::class.java, fetcher)
- }
setRoute(basePath + JSON_MANIFEST_HANDLE, ManifestHandler::class.java, fetcher)
setRoute(basePath + MANIFEST_HANDLE, ManifestHandler::class.java, fetcher)
setRoute(basePath + MANIFEST_ITEM_HANDLE, PublicationResourceHandler::class.java, fetcher)
diff --git a/readium/streamer/src/main/java/org/readium/r2/streamer/server/handler/MediaOverlayHandler.kt b/readium/streamer/src/main/java/org/readium/r2/streamer/server/handler/MediaOverlayHandler.kt
deleted file mode 100644
index 80851316ab..0000000000
--- a/readium/streamer/src/main/java/org/readium/r2/streamer/server/handler/MediaOverlayHandler.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Module: r2-streamer-kotlin
- * Developers: Aferdita Muriqi, Clément Baumann
- *
- * Copyright (c) 2018. Readium Foundation. All rights reserved.
- * Use of this source code is governed by a BSD-style license which is detailed in the
- * LICENSE file present in the project repository where this source code is maintained.
- */
-
-package org.readium.r2.streamer.server.handler
-
-import com.fasterxml.jackson.core.JsonProcessingException
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.nanohttpd.protocols.http.IHTTPSession
-import org.nanohttpd.protocols.http.response.IStatus
-import org.nanohttpd.protocols.http.response.Response
-import org.nanohttpd.protocols.http.response.Response.newFixedLengthResponse
-import org.nanohttpd.protocols.http.response.Status
-import org.nanohttpd.router.RouterNanoHTTPD
-import org.readium.r2.shared.MediaOverlays
-import org.readium.r2.shared.util.mediatype.MediaType
-import org.readium.r2.shared.publication.Link
-import org.readium.r2.streamer.server.ServingFetcher
-
-
-class MediaOverlayHandler : RouterNanoHTTPD.DefaultHandler() {
-
- override fun getText(): String {
- return ResponseStatus.FAILURE_RESPONSE
- }
-
- override fun getMimeType(): String {
- return MediaType.READIUM_WEBPUB_MANIFEST.toString()
- }
-
- override fun getStatus(): IStatus {
- return Status.OK
- }
-
- override fun get(uriResource: RouterNanoHTTPD.UriResource?, urlParams: Map?, session: IHTTPSession?): Response {
- val fetcher = uriResource!!.initParameter(ServingFetcher::class.java)
-
- return if (session!!.parameters.containsKey("resource")) {
- val searchQueryPath = session.parameters["resource"]!![0]
- val spines = fetcher.publication.resources
- val objectMapper = ObjectMapper()
- return try {
- val json = objectMapper.writeValueAsString(getMediaOverlay(spines, searchQueryPath))
- newFixedLengthResponse(status, mimeType, json)
- } catch (e: JsonProcessingException) {
- newFixedLengthResponse(status, mimeType, ResponseStatus.FAILURE_RESPONSE)
- }
-
- } else {
- newFixedLengthResponse(status, mimeType, ResponseStatus.FAILURE_RESPONSE)
- }
- }
-
- @Suppress("UNUSED_PARAMETER")
- private fun getMediaOverlay(spines: List, searchQueryPath: String): MediaOverlays? {
- // FIXME: This is not supported until the model is properly specified
- return null
-// for (link in spines) {
-// if (link.href.contains(searchQueryPath)) {
-// return link.mediaOverlays
-// }
-// }
-// return MediaOverlays()
- }
-
-}
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/FileTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/FileTest.kt
index 81731ede90..3cbb27f000 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/FileTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/FileTest.kt
@@ -11,7 +11,7 @@ package org.readium.r2.streamer.extensions
import org.junit.Test
import java.io.File
-import kotlin.test.assertEquals
+import org.junit.Assert.assertEquals
class FileTest {
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/LinkTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/LinkTest.kt
index 2ba7e9ad81..f98793d04c 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/LinkTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/extensions/LinkTest.kt
@@ -11,8 +11,8 @@ package org.readium.r2.streamer.extensions
import org.junit.Test
import org.readium.r2.shared.publication.Link
-import kotlin.test.assertEquals
-import kotlin.test.assertNull
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
class LinkTest {
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/fetcher/HtmlInjectorTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/fetcher/HtmlInjectorTest.kt
index 768a17acda..0598e47097 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/fetcher/HtmlInjectorTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/fetcher/HtmlInjectorTest.kt
@@ -4,7 +4,7 @@ import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.readium.r2.shared.fetcher.StringResource
import org.readium.r2.shared.publication.*
-import kotlin.test.assertEquals
+import org.junit.Assert.assertEquals
class HtmlInjectorTest {
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/audio/AudioLocatorServiceTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/audio/AudioLocatorServiceTest.kt
index bd6016bdb7..9bff5435b6 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/audio/AudioLocatorServiceTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/audio/AudioLocatorServiceTest.kt
@@ -10,7 +10,7 @@ import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Locator
-import kotlin.test.*
+import org.junit.Assert.*
class AudioLocatorServiceTest {
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt
index e75ce95d31..f942173c26 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EncryptionParserTest.kt
@@ -13,7 +13,6 @@ import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.entry
import org.junit.Test
import org.junit.runner.RunWith
-import org.readium.r2.shared.drm.DRM
import org.readium.r2.shared.publication.encryption.Encryption
import org.readium.r2.shared.parser.xml.XmlParser
import org.robolectric.RobolectricTestRunner
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt
index 049dbe958e..c0ba1fb3f7 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubDeobfuscatorTest.kt
@@ -11,6 +11,7 @@ package org.readium.r2.streamer.parser.epub
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.extensions.toMap
import org.readium.r2.shared.fetcher.Fetcher
import org.readium.r2.shared.fetcher.FileFetcher
@@ -19,9 +20,11 @@ import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Properties
import org.readium.r2.shared.publication.encryption.Encryption
import org.readium.r2.streamer.readBlocking
+import org.robolectric.RobolectricTestRunner
import java.io.File
-import kotlin.test.assertNotNull
+import org.junit.Assert.assertNotNull
+@RunWith(RobolectricTestRunner::class)
class EpubDeobfuscatorTest {
private val identifier = "urn:uuid:36d5078e-ff7d-468e-a5f3-f47c14b91f2f"
@@ -35,7 +38,7 @@ class EpubDeobfuscatorTest {
?.path
?.let { File(it).parentFile }
assertNotNull(deobfuscationDir)
- fetcher = FileFetcher("/deobfuscation", deobfuscationDir)
+ fetcher = FileFetcher("/deobfuscation", deobfuscationDir!!)
val fontResult = fetcher.get(Link(href = "/deobfuscation/cut-cut.woff")).readBlocking()
assert(fontResult.isSuccess)
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt
index 42e4e5187c..74e13d20f8 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/EpubPositionsServiceTest.kt
@@ -12,6 +12,7 @@ package org.readium.r2.streamer.parser.epub
import kotlinx.coroutines.runBlocking
import org.junit.Assert.*
import org.junit.Test
+import org.junit.runner.RunWith
import org.readium.r2.shared.fetcher.Fetcher
import org.readium.r2.shared.fetcher.Resource
import org.readium.r2.shared.fetcher.ResourceTry
@@ -21,7 +22,9 @@ import org.readium.r2.shared.publication.Properties
import org.readium.r2.shared.publication.epub.EpubLayout
import org.readium.r2.shared.publication.presentation.Presentation
import org.readium.r2.shared.util.Try
+import org.robolectric.RobolectricTestRunner
+@RunWith(RobolectricTestRunner::class)
class EpubPositionsServiceTest {
@Test
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/MetadataTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/MetadataTest.kt
index 34fb056bb3..0fe5e5b64f 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/MetadataTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/MetadataTest.kt
@@ -19,7 +19,7 @@ import org.readium.r2.shared.publication.epub.EpubLayout
import org.readium.r2.shared.publication.presentation.Presentation
import org.readium.r2.shared.publication.presentation.presentation
import org.robolectric.RobolectricTestRunner
-import kotlin.test.assertNotNull
+import org.junit.Assert.assertNotNull
import org.readium.r2.shared.publication.Link as SharedLink
@RunWith(RobolectricTestRunner::class)
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt
index 43658b9170..b438f6ab7a 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NavigationDocumentParserTest.kt
@@ -16,7 +16,7 @@ import org.junit.runner.RunWith
import org.readium.r2.shared.parser.xml.XmlParser
import org.readium.r2.shared.publication.Link
import org.robolectric.RobolectricTestRunner
-import kotlin.test.assertNotNull
+import org.junit.Assert.assertNotNull
@RunWith(RobolectricTestRunner::class)
class NavigationDocumentParserTest {
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt
index 7951643d23..abe6a8ef71 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/epub/NcxParserTest.kt
@@ -15,7 +15,7 @@ import org.junit.runner.RunWith
import org.readium.r2.shared.parser.xml.XmlParser
import org.readium.r2.shared.publication.Link
import org.robolectric.RobolectricTestRunner
-import kotlin.test.assertNotNull
+import org.junit.Assert.assertNotNull
@RunWith(RobolectricTestRunner::class)
class NcxParserTest {
diff --git a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt
index 8cc96c5c89..65113b6ec1 100644
--- a/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt
+++ b/readium/streamer/src/test/java/org/readium/r2/streamer/parser/image/ImageParserTest.kt
@@ -20,8 +20,8 @@ import org.readium.r2.shared.publication.firstWithRel
import org.readium.r2.shared.util.archive.DefaultArchiveFactory
import org.readium.r2.streamer.parseBlocking
import java.io.File
-import kotlin.test.assertEquals
-import kotlin.test.assertNotNull
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
class ImageParserTest {
@@ -36,7 +36,7 @@ class ImageParserTest {
private fun assetForResource(resource: String): PublicationAsset {
val path = ImageParserTest::class.java.getResource(resource)?.path
assertNotNull(path)
- return FileAsset(File(path))
+ return FileAsset(File(path!!))
}
private fun fetcherForAsset(asset: PublicationAsset): Fetcher = runBlocking {
@@ -62,7 +62,7 @@ class ImageParserTest {
fun `readingOrder is sorted alphabetically`() {
val builder = parser.parseBlocking(cbzAsset, cbzFetcher)
assertNotNull(builder)
- val readingOrder = builder.manifest.readingOrder
+ val readingOrder = builder!!.manifest.readingOrder
.map { it.href.removePrefix("/Cory Doctorow's Futuristic Tales of the Here and Now") }
assertThat(readingOrder)
.containsExactly("/a-fc.jpg", "/x-002.jpg", "/x-003.jpg", "/x-004.jpg")
@@ -72,7 +72,7 @@ class ImageParserTest {
fun `the cover is the first item in the readingOrder`() {
val builder = parser.parseBlocking(cbzAsset, cbzFetcher)
assertNotNull(builder)
- with(builder.manifest.readingOrder) {
+ with(builder!!.manifest.readingOrder) {
assertEquals(
"/Cory Doctorow's Futuristic Tales of the Here and Now/a-fc.jpg",
firstWithRel("cover")?.href)
@@ -83,6 +83,6 @@ class ImageParserTest {
fun `title is based on archive's root directory when any`() {
val builder = parser.parseBlocking(cbzAsset, cbzFetcher)
assertNotNull(builder)
- assertEquals("Cory Doctorow's Futuristic Tales of the Here and Now", builder.manifest.metadata.title)
+ assertEquals("Cory Doctorow's Futuristic Tales of the Here and Now", builder!!.manifest.metadata.title)
}
}
\ No newline at end of file
diff --git a/test-app/build.gradle b/test-app/build.gradle
index 47b2cbf2c2..12cbe12b4d 100644
--- a/test-app/build.gradle
+++ b/test-app/build.gradle
@@ -74,7 +74,7 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation project(':readium:shared')
@@ -83,19 +83,19 @@ dependencies {
implementation project(':readium:opds')
implementation project(':readium:lcp')
- implementation 'androidx.core:core-ktx:1.6.0'
- implementation "androidx.activity:activity-ktx:1.3.1"
- implementation "androidx.appcompat:appcompat:1.3.1"
- implementation "androidx.browser:browser:1.3.0"
+ 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.browser:browser:1.4.0"
implementation "androidx.cardview:cardview:1.0.0"
- implementation "androidx.constraintlayout:constraintlayout:2.1.1"
- implementation "androidx.fragment:fragment-ktx:1.3.6"
- implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
- implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
- implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
+ implementation "androidx.constraintlayout:constraintlayout:2.1.2"
+ 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"
+ implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
- implementation "androidx.paging:paging-runtime-ktx:3.0.1"
+ implementation "androidx.paging:paging-runtime-ktx:3.1.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation "androidx.webkit:webkit:1.4.0"
@@ -108,30 +108,28 @@ dependencies {
exclude group: 'org.parboiled'
}
implementation "com.google.android.material:material:1.4.0"
- implementation "com.jakewharton.timber:timber:4.7.1"
+ implementation 'com.jakewharton.timber:timber:5.0.1'
// AM NOTE: needs to stay this version for now (June 24,2020)
//noinspection GradleDependency
- implementation "com.squareup.picasso:picasso:2.5.2"
+ 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"
// AM NOTE: needs to stay this version for now (June 24,2020)
//noinspection GradleDependency
- implementation 'org.jsoup:jsoup:1.13.1'
+ implementation 'org.jsoup:jsoup:1.14.3'
// Room database
- final room_version = '2.4.0-beta01'
+ final room_version = '2.4.0'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//noinspection LifecycleAnnotationProcessorWithJava8
- kapt "androidx.lifecycle:lifecycle-compiler:2.3.1"
-
- testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
- testImplementation "junit:junit:4.13.2"
-
- androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
- androidTestImplementation "androidx.test:runner:1.4.0"
+ kapt "androidx.lifecycle:lifecycle-compiler:2.4.0"
+ // Tests
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
diff --git a/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfAdapter.kt b/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfAdapter.kt
index 3ed0bb7f44..282d6c3c87 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfAdapter.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookshelfAdapter.kt
@@ -49,7 +49,7 @@ class BookshelfAdapter(
binding.bookshelfTitleText.text = book.title
val coverImageFile =
File("${binding.root.context?.filesDir?.path}/covers/${book.id}.png")
- Picasso.with(binding.root.context)
+ Picasso.get()
.load(coverImageFile)
.placeholder(R.drawable.cover)
.into(binding.bookshelfCoverImage)
diff --git a/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt b/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt
index 8c57b3cf4b..0132246013 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt
@@ -46,11 +46,11 @@ class PublicationAdapter :
binding.catalogListTitleText.text = publication.metadata.title
publication.linkWithRel("http://opds-spec.org/image/thumbnail")?.let { link ->
- Picasso.with(binding.catalogListCoverImage.context).load(link.href)
+ Picasso.get().load(link.href)
.into(binding.catalogListCoverImage)
} ?: run {
if (publication.images.isNotEmpty()) {
- Picasso.with(binding.catalogListCoverImage.context)
+ Picasso.get()
.load(publication.images.first().href).into(binding.catalogListCoverImage)
}
}
diff --git a/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationDetailFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationDetailFragment.kt
index 2e4e3d0163..42d2a9b78b 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationDetailFragment.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationDetailFragment.kt
@@ -46,7 +46,7 @@ class PublicationDetailFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
(activity as MainActivity).supportActionBar?.title = publication?.metadata?.title
- Picasso.with(requireContext()).load(publication?.images?.first()?.href)
+ Picasso.get().load(publication?.images?.first()?.href)
.into(binding.catalogDetailCoverImage)
binding.catalogDetailDescriptionText.text = publication?.metadata?.description
diff --git a/test-app/src/main/java/org/readium/r2/testapp/domain/model/Highlight.kt b/test-app/src/main/java/org/readium/r2/testapp/domain/model/Highlight.kt
index 10f267009e..fe6598a603 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/domain/model/Highlight.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/domain/model/Highlight.kt
@@ -30,6 +30,7 @@ import org.readium.r2.shared.util.MapWithDefaultCompanion
foreignKeys = [
ForeignKey(entity = Book::class, parentColumns = [Book.ID], childColumns = [Highlight.BOOK_ID], onDelete = ForeignKey.CASCADE)
],
+ indices = [Index(value = [Highlight.BOOK_ID])]
)
data class Highlight(
@PrimaryKey(autoGenerate = true)
diff --git a/test-app/src/main/java/org/readium/r2/testapp/drm/LcpManagementViewModel.kt b/test-app/src/main/java/org/readium/r2/testapp/drm/LcpManagementViewModel.kt
index 9663211bc0..1e1ab7dcec 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/drm/LcpManagementViewModel.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/drm/LcpManagementViewModel.kt
@@ -24,7 +24,7 @@ class LcpManagementViewModel(
private val renewListener: LcpLicense.RenewListener,
) : ViewModelProvider.NewInstanceFactory() {
- override fun create(modelClass: Class): T =
+ override fun create(modelClass: Class): T =
modelClass.getDeclaredConstructor(LcpLicense::class.java, LcpLicense.RenewListener::class.java)
.newInstance(lcpLicense, renewListener)
}
diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt
index 164b826259..848743c825 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/reader/AudioReaderFragment.kt
@@ -7,7 +7,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.SeekBar
-import androidx.activity.addCallback
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.asLiveData
import androidx.lifecycle.lifecycleScope
@@ -20,6 +19,7 @@ import org.readium.r2.shared.publication.services.cover
import org.readium.r2.testapp.R
import org.readium.r2.testapp.databinding.FragmentAudiobookBinding
import kotlin.time.Duration
+import kotlin.time.Duration.Companion.seconds
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
@@ -100,7 +100,7 @@ class AudioReaderFragment : BaseReaderFragment() {
override fun onStopTrackingTouch(p0: SeekBar?) {
isSeeking = false
p0?.let { seekBar ->
- mediaNavigator.seekTo(Duration.seconds(seekBar.progress))
+ mediaNavigator.seekTo(seekBar.progress.seconds)
}
}
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 1d367bab9f..d1bf25c057 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
@@ -139,6 +139,7 @@ open class ReaderActivity : AppCompatActivity() {
is ReaderViewModel.Event.Failure -> {
Toast.makeText(this, event.error.getUserMessage(this), Toast.LENGTH_LONG).show()
}
+ else -> {}
}
}
diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderContract.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderContract.kt
index ddf909ac35..56458b5923 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderContract.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderContract.kt
@@ -23,7 +23,7 @@ import org.readium.r2.shared.util.mediatype.MediaType
import java.io.File
import java.net.URL
-class ReaderContract : ActivityResultContract() {
+class ReaderContract : ActivityResultContract() {
data class Input(
val mediaType: MediaType?,
diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt
index 3858c79caf..5e81787cb4 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/reader/ReaderViewModel.kt
@@ -213,7 +213,7 @@ class ReaderViewModel(context: Context, arguments: ReaderContract.Input) : ViewM
class Factory(private val context: Context, private val arguments: ReaderContract.Input)
: ViewModelProvider.NewInstanceFactory() {
- override fun create(modelClass: Class): T =
+ override fun create(modelClass: Class): T =
modelClass.getDeclaredConstructor(Context::class.java, ReaderContract.Input::class.java)
.newInstance(context.applicationContext, arguments)
}
diff --git a/test-app/src/main/java/org/readium/r2/testapp/utils/EventChannel.kt b/test-app/src/main/java/org/readium/r2/testapp/utils/EventChannel.kt
index 2d105f25fc..50b5471fc6 100644
--- a/test-app/src/main/java/org/readium/r2/testapp/utils/EventChannel.kt
+++ b/test-app/src/main/java/org/readium/r2/testapp/utils/EventChannel.kt
@@ -8,11 +8,7 @@
package org.readium.r2.testapp.utils
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.LifecycleObserver
-import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.OnLifecycleEvent
-import androidx.lifecycle.lifecycleScope
+import androidx.lifecycle.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
@@ -39,12 +35,11 @@ class FlowObserver (
private val lifecycleOwner: LifecycleOwner,
private val flow: Flow,
private val collector: suspend (T) -> Unit
-) : LifecycleObserver {
+) : DefaultLifecycleObserver {
private var job: Job? = null
- @OnLifecycleEvent(Lifecycle.Event.ON_START)
- fun onStart() {
+ override fun onStart(owner: LifecycleOwner) {
if (job == null) {
job = lifecycleOwner.lifecycleScope.launch {
flow.collect { collector(it) }
@@ -52,8 +47,7 @@ class FlowObserver (
}
}
- @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
- fun onStop() {
+ override fun onStop(owner: LifecycleOwner) {
job?.cancel()
job = null
}