Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ lint/reports/

# Docs
docs/readium
docs/index.md
docs/package-list
35 changes: 5 additions & 30 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions readium/lcp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions readium/navigator-media2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
}

android {
resourcePrefix = "readium_"
resourcePrefix = "readium_"

compileSdk = 31

Expand Down Expand Up @@ -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")

Expand Down
10 changes: 5 additions & 5 deletions readium/navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions readium/opds/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions readium/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"),
Expand All @@ -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")
Expand All @@ -47,7 +47,7 @@ class LocatorServiceTest {
}

@Test
fun `locate from progression`() = runBlockingTest {
fun `locate from progression`() = runTest {
val service = createService(positions = positionsFixtures)

assertEquals(Locator(
Expand Down Expand Up @@ -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))
}
Expand Down
8 changes: 3 additions & 5 deletions readium/streamer/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
12 changes: 6 additions & 6 deletions test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -93,26 +93,26 @@ 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")

implementation("androidx.media2:media2-session:1.2.0")
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Loading