Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8fc2516
WIP
qnga Apr 20, 2023
30b1ebe
WIP 2
qnga May 11, 2023
0546f5f
WIP 3
qnga May 12, 2023
210130f
Working version
qnga May 24, 2023
86d516c
Remove the HTTP server
qnga May 25, 2023
421d3b9
Deprecate navigator activities
qnga May 28, 2023
9d8deed
Prefix navigator's resources with readium_
qnga May 28, 2023
191da25
Remove old settings API
qnga May 29, 2023
5c0d15a
New working version
qnga Jun 5, 2023
e104f4f
Various changes
qnga Jun 7, 2023
a40ed4e
Turn AssetAnalyzer into AssetRetriever
qnga Jun 11, 2023
342ccd2
Improve resource package
qnga Jun 11, 2023
beed329
Various fixes
qnga Jun 12, 2023
6011615
Refactor Url and add ContentResourceFactory
qnga Jun 15, 2023
05f4f45
Introduce ProtectionRetriever
qnga Jun 20, 2023
3f69838
Fix HttpResource
qnga Jun 22, 2023
579a51e
Various fixes including support for manifests
qnga Jun 22, 2023
b8e7edd
Add support for adding files from shared storage
qnga Jun 22, 2023
b449a49
Various fixes
qnga Jun 23, 2023
99f1532
Various changes
qnga Jun 24, 2023
631d2eb
Improve error handling
qnga Jun 27, 2023
4b58bb1
Rework error handling
qnga Jul 2, 2023
05b7013
Fixes in LcpContentProtection
qnga Jul 3, 2023
9e9fd33
Various fixes
qnga Jul 4, 2023
63cf6a0
Cosmetic Change
qnga Jul 6, 2023
7ee4d88
Merge branch 'v3' of github.com:readium/kotlin-toolkit into refactor-…
qnga Jul 6, 2023
fc614e7
Various changes
qnga Jul 6, 2023
1cc6d7d
Various changes
qnga Jul 6, 2023
a9278ba
Small fix
qnga Jul 6, 2023
da941f0
Merge branch 'v3' of github.com:readium/kotlin-toolkit into refactor-…
qnga Jul 8, 2023
b5de53a
Various changes in shared
qnga Jul 9, 2023
e25e022
Cosmetic changes
qnga Jul 9, 2023
4e40f83
Fix ZAB
qnga Jul 9, 2023
456c7e9
Various fixes
qnga Jul 9, 2023
9d670bf
Various changes
qnga Jul 10, 2023
70baf6a
Merge branch 'v3' into prepare-v3
qnga Jul 10, 2023
85f7b1f
Merge branch 'refactor-streamer' into prepare-v3
qnga Jul 10, 2023
f3b5f71
Reorganize deprecated symbols
qnga Jul 10, 2023
a282ffc
Resource renaming
qnga Jul 10, 2023
43d31cf
Clean up Publication
qnga Jul 11, 2023
77cb0ce
Remove ReadingProgression.BTT/TTB/AUTO
qnga Jul 11, 2023
54220cc
Deprecate putting publications into intents.
qnga Jul 12, 2023
a0dffec
Remove highlight.js
qnga Jul 12, 2023
7e58eee
Clean up R2BasicWebView
qnga Jul 13, 2023
030d96d
Various changes
qnga Jul 14, 2023
33aa0e5
Small changes
qnga Jul 14, 2023
7559426
Fix resource prefixe
qnga Jul 14, 2023
34715dd
Rename SimpleError to MessageError
qnga Jul 14, 2023
a7d8099
Refactor ContentProtection.Scheme and HTTP-related MediaType extensions
qnga Jul 16, 2023
c704a70
Various changes
qnga Jul 17, 2023
7255b2a
Merge branch 'v3' of github.com:readium/kotlin-toolkit into refactor-…
qnga Jul 17, 2023
0000ebe
Merge branch 'v3' into refactor-streamer
mickael-menu Jul 17, 2023
5cce4d1
Merge branch 'refactor-streamer' into prepare-v3
mickael-menu Jul 17, 2023
3c9a904
Update XML file headers
mickael-menu Jul 21, 2023
2e0194d
Deprecate more stuff in the web views
mickael-menu Jul 21, 2023
c01044a
More deprecation, and sort initialLocator vs initialPreferences
mickael-menu Jul 21, 2023
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
1 change: 1 addition & 0 deletions readium/lcp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
}

android {
resourcePrefix = "readium_"

compileSdk = 33
defaultConfig {
Expand Down
11 changes: 4 additions & 7 deletions readium/lcp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<!--
~ Module: r2-lcp-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.
-->
Copyright 2023 Readium Foundation. All rights reserved.
Use of this source code is governed by the BSD-style license
available in the top-level LICENSE file of the project.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

Expand Down
64 changes: 32 additions & 32 deletions readium/lcp/src/main/java/org/readium/r2/lcp/LcpException.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ sealed class LcpException(
) : this(userMessageId, *args, quantity = quantity, cause = cause)

/** The interaction is not available with this License. */
object LicenseInteractionNotAvailable : LcpException(R.string.r2_lcp_exception_license_interaction_not_available)
object LicenseInteractionNotAvailable : LcpException(R.string.readium_lcp_exception_license_interaction_not_available)

/** This License's profile is not supported by liblcp. */
object LicenseProfileNotSupported : LcpException(R.string.r2_lcp_exception_license_profile_not_supported)
object LicenseProfileNotSupported : LcpException(R.string.readium_lcp_exception_license_profile_not_supported)

/** Failed to retrieve the Certificate Revocation List. */
object CrlFetching : LcpException(R.string.r2_lcp_exception_crl_fetching)
object CrlFetching : LcpException(R.string.readium_lcp_exception_crl_fetching)

/** A network request failed with the given exception. */
class Network(override val cause: Throwable?) : LcpException(R.string.r2_lcp_exception_network, cause = cause)
class Network(override val cause: Throwable?) : LcpException(R.string.readium_lcp_exception_network, cause = cause)

/**
* An unexpected LCP exception occurred. Please post an issue on r2-lcp-kotlin with the error
* message and how to reproduce it.
*/
class Runtime(override val message: String) : LcpException(R.string.r2_lcp_exception_runtime)
class Runtime(override val message: String) : LcpException(R.string.readium_lcp_exception_runtime)

/** An unknown low-level exception was reported. */
class Unknown(override val cause: Throwable?) : LcpException(R.string.r2_lcp_exception_unknown)
class Unknown(override val cause: Throwable?) : LcpException(R.string.readium_lcp_exception_unknown)

/**
* Errors while checking the status of the License, using the Status Document.
Expand All @@ -59,13 +59,13 @@ sealed class LcpException(
constructor(@StringRes userMessageId: Int, vararg args: Any) : this(userMessageId, *args, quantity = null)
constructor(@PluralsRes userMessageId: Int, quantity: Int, vararg args: Any) : this(userMessageId, *args, quantity = quantity)

class Cancelled(val date: Date) : LicenseStatus(R.string.r2_lcp_exception_license_status_cancelled, date)
class Cancelled(val date: Date) : LicenseStatus(R.string.readium_lcp_exception_license_status_cancelled, date)

class Returned(val date: Date) : LicenseStatus(R.string.r2_lcp_exception_license_status_returned, date)
class Returned(val date: Date) : LicenseStatus(R.string.readium_lcp_exception_license_status_returned, date)

class NotStarted(val start: Date) : LicenseStatus(R.string.r2_lcp_exception_license_status_not_started, start)
class NotStarted(val start: Date) : LicenseStatus(R.string.readium_lcp_exception_license_status_not_started, start)

class Expired(val end: Date) : LicenseStatus(R.string.r2_lcp_exception_license_status_expired, end)
class Expired(val end: Date) : LicenseStatus(R.string.readium_lcp_exception_license_status_expired, end)

/**
* If the license has been revoked, the user message should display the number of devices which
Expand All @@ -74,7 +74,7 @@ sealed class LcpException(
* appear (certainly not "The license was registered by 0 devices").
*/
class Revoked(val date: Date, val devicesCount: Int) :
LicenseStatus(R.plurals.r2_lcp_exception_license_status_revoked, devicesCount, date, devicesCount)
LicenseStatus(R.plurals.readium_lcp_exception_license_status_revoked, devicesCount, date, devicesCount)
}

/**
Expand All @@ -83,13 +83,13 @@ sealed class LcpException(
sealed class Renew(@StringRes userMessageId: Int) : LcpException(userMessageId) {

/** Your publication could not be renewed properly. */
object RenewFailed : Renew(R.string.r2_lcp_exception_renew_renew_failed)
object RenewFailed : Renew(R.string.readium_lcp_exception_renew_renew_failed)

/** Incorrect renewal period, your publication could not be renewed. */
class InvalidRenewalPeriod(val maxRenewDate: Date?) : Renew(R.string.r2_lcp_exception_renew_invalid_renewal_period)
class InvalidRenewalPeriod(val maxRenewDate: Date?) : Renew(R.string.readium_lcp_exception_renew_invalid_renewal_period)

/** An unexpected error has occurred on the licensing server. */
object UnexpectedServerError : Renew(R.string.r2_lcp_exception_renew_unexpected_server_error)
object UnexpectedServerError : Renew(R.string.readium_lcp_exception_renew_unexpected_server_error)
}

/**
Expand All @@ -98,29 +98,29 @@ sealed class LcpException(
sealed class Return(@StringRes userMessageId: Int) : LcpException(userMessageId) {

/** Your publication could not be returned properly. */
object ReturnFailed : Return(R.string.r2_lcp_exception_return_return_failed)
object ReturnFailed : Return(R.string.readium_lcp_exception_return_return_failed)

/** Your publication has already been returned before or is expired. */

object AlreadyReturnedOrExpired : Return(R.string.r2_lcp_exception_return_already_returned_or_expired)
object AlreadyReturnedOrExpired : Return(R.string.readium_lcp_exception_return_already_returned_or_expired)

/** An unexpected error has occurred on the licensing server. */
object UnexpectedServerError : Return(R.string.r2_lcp_exception_return_unexpected_server_error)
object UnexpectedServerError : Return(R.string.readium_lcp_exception_return_unexpected_server_error)
}

/**
* Errors while parsing the License or Status JSON Documents.
*/
sealed class Parsing(@StringRes userMessageId: Int = R.string.r2_lcp_exception_parsing) : LcpException(userMessageId) {
sealed class Parsing(@StringRes userMessageId: Int = R.string.readium_lcp_exception_parsing) : LcpException(userMessageId) {

/** The JSON is malformed and can't be parsed. */
object MalformedJSON : Parsing(R.string.r2_lcp_exception_parsing_malformed_json)
object MalformedJSON : Parsing(R.string.readium_lcp_exception_parsing_malformed_json)

/** The JSON is not representing a valid License Document. */
object LicenseDocument : Parsing(R.string.r2_lcp_exception_parsing_license_document)
object LicenseDocument : Parsing(R.string.readium_lcp_exception_parsing_license_document)

/** The JSON is not representing a valid Status Document. */
object StatusDocument : Parsing(R.string.r2_lcp_exception_parsing_status_document)
object StatusDocument : Parsing(R.string.readium_lcp_exception_parsing_status_document)

/** Invalid Link. */
object Link : Parsing()
Expand All @@ -141,39 +141,39 @@ sealed class LcpException(
sealed class Container(@StringRes userMessageId: Int) : LcpException(userMessageId) {

/** Can't access the container, it's format is wrong. */
object OpenFailed : Container(R.string.r2_lcp_exception_container_open_failed)
object OpenFailed : Container(R.string.readium_lcp_exception_container_open_failed)

/** The file at given relative path is not found in the Container. */
class FileNotFound(val path: String) : Container(R.string.r2_lcp_exception_container_file_not_found)
class FileNotFound(val path: String) : Container(R.string.readium_lcp_exception_container_file_not_found)

/** Can't read the file at given relative path in the Container. */
class ReadFailed(val path: String) : Container(R.string.r2_lcp_exception_container_read_failed)
class ReadFailed(val path: String) : Container(R.string.readium_lcp_exception_container_read_failed)

/** Can't write the file at given relative path in the Container. */
class WriteFailed(val path: String) : Container(R.string.r2_lcp_exception_container_write_failed)
class WriteFailed(val path: String) : Container(R.string.readium_lcp_exception_container_write_failed)
}

/**
* An error occurred while checking the integrity of the License, it can't be retrieved.
*/
sealed class LicenseIntegrity(@StringRes userMessageId: Int) : LcpException(userMessageId) {

object CertificateRevoked : LicenseIntegrity(R.string.r2_lcp_exception_license_integrity_certificate_revoked)
object CertificateRevoked : LicenseIntegrity(R.string.readium_lcp_exception_license_integrity_certificate_revoked)

object InvalidCertificateSignature : LicenseIntegrity(R.string.r2_lcp_exception_license_integrity_invalid_certificate_signature)
object InvalidCertificateSignature : LicenseIntegrity(R.string.readium_lcp_exception_license_integrity_invalid_certificate_signature)

object InvalidLicenseSignatureDate : LicenseIntegrity(R.string.r2_lcp_exception_license_integrity_invalid_license_signature_date)
object InvalidLicenseSignatureDate : LicenseIntegrity(R.string.readium_lcp_exception_license_integrity_invalid_license_signature_date)

object InvalidLicenseSignature : LicenseIntegrity(R.string.r2_lcp_exception_license_integrity_invalid_license_signature)
object InvalidLicenseSignature : LicenseIntegrity(R.string.readium_lcp_exception_license_integrity_invalid_license_signature)

object InvalidUserKeyCheck : LicenseIntegrity(R.string.r2_lcp_exception_license_integrity_invalid_user_key_check)
object InvalidUserKeyCheck : LicenseIntegrity(R.string.readium_lcp_exception_license_integrity_invalid_user_key_check)
}

sealed class Decryption(@StringRes userMessageId: Int) : LcpException(userMessageId) {

object ContentKeyDecryptError : Decryption(R.string.r2_lcp_exception_decryption_content_key_decrypt_error)
object ContentKeyDecryptError : Decryption(R.string.readium_lcp_exception_decryption_content_key_decrypt_error)

object ContentDecryptError : Decryption(R.string.r2_lcp_exception_decryption_content_decrypt_error)
object ContentDecryptError : Decryption(R.string.readium_lcp_exception_decryption_content_decrypt_error)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class LcpDialogAuthentication : LcpAuthenticating {

val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
@SuppressLint("InflateParams") // https://stackoverflow.com/q/26404951/1474476
val dialogView = inflater.inflate(R.layout.r2_lcp_auth_dialog, null)
val dialogView = inflater.inflate(R.layout.readium_lcp_auth_dialog, null)

val title = dialogView.findViewById(R.id.r2_title) as TextView
val description = dialogView.findViewById(R.id.r2_description) as TextView
Expand All @@ -85,16 +85,16 @@ class LcpDialogAuthentication : LcpAuthenticating {

when (reason) {
LcpAuthenticating.AuthenticationReason.PassphraseNotFound -> {
title.text = context.getString(R.string.r2_lcp_dialog_reason_passphraseNotFound)
title.text = context.getString(R.string.readium_lcp_dialog_reason_passphraseNotFound)
}
LcpAuthenticating.AuthenticationReason.InvalidPassphrase -> {
title.text = context.getString(R.string.r2_lcp_dialog_reason_invalidPassphrase)
passwordLayout.error = context.getString(R.string.r2_lcp_dialog_reason_invalidPassphrase)
title.text = context.getString(R.string.readium_lcp_dialog_reason_invalidPassphrase)
passwordLayout.error = context.getString(R.string.readium_lcp_dialog_reason_invalidPassphrase)
}
}

val provider = tryOr(license.provider) { Uri.parse(license.provider).host }
description.text = context.getString(R.string.r2_lcp_dialog_prompt, provider)
description.text = context.getString(R.string.readium_lcp_dialog_prompt, provider)

hint.text = license.hint

Expand Down Expand Up @@ -129,12 +129,12 @@ class LcpDialogAuthentication : LcpAuthenticating {

private fun showHelpDialog(context: Context, links: List<Link>) {
val titles = links.map {
it.title ?: tryOr(context.getString(R.string.r2_lcp_dialog_support)) {
it.title ?: tryOr(context.getString(R.string.readium_lcp_dialog_support)) {
when (Uri.parse(it.href).scheme) {
"http", "https" -> context.getString(R.string.r2_lcp_dialog_support_web)
"tel" -> context.getString(R.string.r2_lcp_dialog_support_phone)
"mailto" -> context.getString(R.string.r2_lcp_dialog_support_mail)
else -> context.getString(R.string.r2_lcp_dialog_support)
"http", "https" -> context.getString(R.string.readium_lcp_dialog_support_web)
"tel" -> context.getString(R.string.readium_lcp_dialog_support_phone)
"mailto" -> context.getString(R.string.readium_lcp_dialog_support_mail)
else -> context.getString(R.string.readium_lcp_dialog_support)
}
}
}.toTypedArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@string/r2_lcp_dialog_cancel"
android:text="@string/readium_lcp_dialog_cancel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down Expand Up @@ -85,7 +85,7 @@
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@string/r2_lcp_dialog_continue"
android:text="@string/readium_lcp_dialog_continue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/r2_passwordLayout" />
Expand All @@ -98,7 +98,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:background="@android:color/transparent"
android:text="@string/r2_lcp_dialog_forgotPassphrase"
android:text="@string/readium_lcp_dialog_forgotPassphrase"
android:textAlignment="viewStart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -112,7 +112,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:background="@android:color/transparent"
android:text="@string/r2_lcp_dialog_help"
android:text="@string/readium_lcp_dialog_help"
android:textAlignment="viewStart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
Expand Down
Loading