Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 11 additions & 8 deletions buildSrc/src/main/kotlin/readium.library-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
// FIXME: For now, we cannot use the versions catalog in precompiled scripts: https://github.com/gradle/gradle/issues/15383
Expand All @@ -21,16 +22,11 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
isCoreLibraryDesugaringEnabled = true
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
allWarningsAsErrors = true
}

testOptions {
unitTests.isIncludeAndroidResources = true
}
Expand All @@ -50,10 +46,17 @@ android {

kotlin {
explicitApi()

compilerOptions {
freeCompilerArgs.add("-Xannotation-default-target=param-property")
jvmTarget = JvmTarget.JVM_11
allWarningsAsErrors = true
}
}

dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
//noinspection UseTomlInstead
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
}

mavenPublishing {
Expand Down
21 changes: 14 additions & 7 deletions demos/navigator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
kotlin("android")
Expand All @@ -10,7 +12,7 @@ android {
compileSdk = (property("android.compileSdk") as String).toInt()

defaultConfig {
minSdk = 23
minSdk = (property("android.minSdk") as String).toInt()
targetSdk = (property("android.targetSdk") as String).toInt()

applicationId = "org.readium.navigator.demo"
Expand All @@ -22,14 +24,11 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
isCoreLibraryDesugaringEnabled = true
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}

buildFeatures {
viewBinding = true
compose = true
Expand Down Expand Up @@ -59,6 +58,14 @@ android {
namespace = "org.readium.demo.navigator"
}

kotlin {

compilerOptions {
jvmTarget = JvmTarget.JVM_11
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}

dependencies {
implementation(project(":readium:readium-shared"))
implementation(project(":readium:readium-streamer"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.readium.r2.shared.publication.epub.pageList
*
* This is an example of a custom Decoration Style declaration.
*/
data class DecorationStyleAnnotationMark(@ColorInt val tint: Int) : Decoration.Style
data class DecorationStyleAnnotationMark(@param:ColorInt val tint: Int) : Decoration.Style

/**
* Decoration Style for a page number label.
Expand Down
46 changes: 23 additions & 23 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
[versions]

kotlin = "2.1.21"
agp = "8.10.1"
kotlin = "2.2.20"
agp = "8.13.0"
desugar_jdk_libs = "2.1.5"
gradle-maven-publish-plugin = "0.32.0"

androidx-activity = "1.10.1"
androidx-activity = "1.11.0"
androidx-annotation = "1.9.1"
androidx-appcompat = "1.7.0"
androidx-browser = "1.8.0"
androidx-appcompat = "1.7.1"
androidx-browser = "1.9.0"
androidx-cardview = "1.0.0"
androidx-compose-animation = "1.8.2"
androidx-compose-foundation = "1.8.2"
androidx-compose-material = "1.8.2"
androidx-compose-animation = "1.9.2"
androidx-compose-foundation = "1.9.2"
androidx-compose-material = "1.9.2"
androidx-compose-material-icons = "1.7.8"
androidx-compose-material3 = "1.3.2"
androidx-compose-runtime = "1.8.2"
androidx-compose-ui = "1.8.2"
androidx-compose-material3 = "1.4.0"
androidx-compose-runtime = "1.9.2"
androidx-compose-ui = "1.9.2"
androidx-constraintlayout = "2.2.1"
androidx-core = "1.16.0"
androidx-core = "1.17.0"
androidx-datastore = "1.1.7"
androidx-fragment-ktx = "1.8.7"
androidx-fragment-ktx = "1.8.9"
androidx-legacy = "1.0.0"
androidx-lifecycle = "2.9.0"
androidx-media3 = "1.7.1"
androidx-navigation = "2.9.0"
androidx-lifecycle = "2.9.4"
androidx-media3 = "1.8.0"
androidx-navigation = "2.9.5"
androidx-paging = "3.3.6"
androidx-recyclerview = "1.4.0"
androidx-room = "2.7.1"
androidx-room = "2.8.1"
androidx-viewpager2 = "1.1.0"
androidx-webkit = "1.13.0"
androidx-webkit = "1.14.0"

assertj = "3.27.3"
assertj = "3.27.6"

dokka = "1.9.20"

google-material = "1.12.0"
google-material = "1.13.0"

joda-time = "2.14.0"
#Do not upgrade without fixing unit tests in HtmlResourceContentIteratorTest and regression testing
Expand All @@ -52,7 +52,7 @@ kotlinx-collections-immutable = "0.4.0"

# Make sure to align with the Kotlin version.
# See https://github.com/google/ksp/releases
ksp = "2.1.21-2.0.1"
ksp = "2.2.20-2.0.3"

ktlint = "12.1.1"

Expand All @@ -62,8 +62,8 @@ pdf-viewer = "3.2.8"
picasso = "2.8"
pspdfkit = "8.4.1"

robolectric = "4.14.1"
mockk = "1.14.2"
robolectric = "4.16"
mockk = "1.14.6"

timber = "5.0.1"

Expand Down
6 changes: 4 additions & 2 deletions readium/lcp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ plugins {

android {
namespace = "org.readium.r2.lcp"
}

kotlinOptions {
kotlin {
compilerOptions {
// See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041
freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility")
freeCompilerArgs.add("-Xconsistent-data-class-copy-visibility")
}
}

Expand Down
7 changes: 6 additions & 1 deletion readium/navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ android {
}

kotlinOptions {
}
}

kotlin {
compilerOptions {
// See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041
freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility")
freeCompilerArgs.add("-Xconsistent-data-class-copy-visibility")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.core.content.ContextCompat
/** returns true if the resolved layout direction of the content view in this
* activity is ViewCompat.LAYOUT_DIRECTION_RTL. Otherwise false. */
internal fun Activity.layoutDirectionIsRTL(): Boolean {
return findViewById<View?>(android.R.id.content).layoutDirection == View.LAYOUT_DIRECTION_RTL
return findViewById<View>(android.R.id.content).layoutDirection == View.LAYOUT_DIRECTION_RTL
}

@ColorInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import androidx.viewpager.widget.ViewPager;

import org.readium.r2.navigator.preferences.ReadingProgression;
import org.readium.r2.shared.InternalReadiumApi;

import java.util.HashMap;

Expand All @@ -44,7 +45,8 @@
* <code>OnPageChangeListener</code>s so that clients can be agnostic to layout direction and
* modifications are kept internal to <code>RtlViewPager</code>.
*/
class R2RTLViewPager extends ViewPager {
@InternalReadiumApi
public class R2RTLViewPager extends ViewPager {
public ReadingProgression direction = ReadingProgression.LTR;
private int mLayoutDirection = ViewCompat.LAYOUT_DIRECTION_LTR;
private HashMap<OnPageChangeListener, ReversingOnPageChangeListener> mPageChangeListeners = new HashMap<>();
Expand All @@ -59,9 +61,9 @@ public R2RTLViewPager(Context context, AttributeSet attrs) {
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
super.onRtlPropertiesChanged(layoutDirection);
int viewCompatLayoutDirection = layoutDirection == View.LAYOUT_DIRECTION_RTL ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR;
int viewCompatLayoutDirection = layoutDirection == View.LAYOUT_DIRECTION_RTL ? View.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR;
if (direction == ReadingProgression.RTL) {
viewCompatLayoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL;
viewCompatLayoutDirection = View.LAYOUT_DIRECTION_RTL;
}
if (viewCompatLayoutDirection != mLayoutDirection) {
PagerAdapter adapter = super.getAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import org.readium.r2.navigator.BuildConfig.DEBUG
import org.readium.r2.shared.InternalReadiumApi
import timber.log.Timber

internal class R2ViewPager : R2RTLViewPager {
// See https://youtrack.jetbrains.com/issue/KTLC-271 for visibility issue.
@InternalReadiumApi
Copy link
Member Author

@qnga qnga Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin/Java interop isn't as good as we thought. This is the easiest workaround.

public class R2ViewPager : R2RTLViewPager {

internal enum class PublicationType {
EPUB,
Expand All @@ -29,8 +32,8 @@ internal class R2ViewPager : R2RTLViewPager {

internal lateinit var publicationType: PublicationType

constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
internal constructor(context: Context) : super(context)
internal constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

override fun setCurrentItem(item: Int) {
super.setCurrentItem(item, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.content.Context
import android.media.AudioFocusRequest
import android.media.AudioManager
import android.media.AudioManager.OnAudioFocusChangeListener
import android.os.Build
import android.os.Handler
import androidx.annotation.IntDef
import androidx.annotation.RequiresApi
Expand All @@ -30,7 +31,6 @@ import androidx.media3.common.Player
import androidx.media3.common.util.Log
import androidx.media3.common.util.Util
import java.util.Objects
import org.readium.navigator.media.tts.session.AudioFocusManager.PlayerControl

@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
/** Manages requesting and responding to changes in audio focus.
Expand Down Expand Up @@ -186,7 +186,7 @@ internal class AudioFocusManager(
return PLAYER_COMMAND_PLAY_WHEN_READY
}
val requestResult =
if (Util.SDK_INT >= 26) requestAudioFocusV26() else requestAudioFocusDefault()
if (Build.VERSION.SDK_INT >= 26) requestAudioFocusV26() else requestAudioFocusDefault()
return if (requestResult == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
setAudioFocusState(AUDIO_FOCUS_STATE_HAVE_FOCUS)
PLAYER_COMMAND_PLAY_WHEN_READY
Expand All @@ -200,7 +200,7 @@ internal class AudioFocusManager(
if (audioFocusState == AUDIO_FOCUS_STATE_NO_FOCUS) {
return
}
if (Util.SDK_INT >= 26) {
if (Build.VERSION.SDK_INT >= 26) {
abandonAudioFocusV26()
} else {
abandonAudioFocusDefault()
Expand Down Expand Up @@ -407,11 +407,8 @@ internal class AudioFocusManager(
->
AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
C.USAGE_ASSISTANT ->
if (Util.SDK_INT >= 19) {
AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
} else {
AUDIOFOCUS_GAIN_TRANSIENT
}
AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE

C.USAGE_ASSISTANCE_ACCESSIBILITY -> {
if (audioAttributes.contentType == C.AUDIO_CONTENT_TYPE_SPEECH) {
// Voice shouldn't be interrupted by other playback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.media.AudioManager
import android.os.Build
import android.os.Handler
import androidx.media3.common.C
import androidx.media3.common.util.Assertions
import androidx.media3.common.util.Log
import androidx.media3.common.util.Util

@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
/** A manager that wraps [AudioManager] to control/listen audio stream volume. */
Expand Down Expand Up @@ -82,7 +82,7 @@ internal class StreamVolumeManager(context: Context, eventHandler: Handler, list
* Gets the minimum volume for the current audio stream. It can be changed if [ ][.setStreamType] is called.
*/
val minVolume: Int
get() = if (Util.SDK_INT >= 28) audioManager.getStreamMinVolume(streamType) else 0
get() = if (Build.VERSION.SDK_INT >= 28) audioManager.getStreamMinVolume(streamType) else 0

/**
* Gets the maximum volume for the current audio stream. It can be changed if [ ][.setStreamType] is called.
Expand Down Expand Up @@ -138,16 +138,11 @@ internal class StreamVolumeManager(context: Context, eventHandler: Handler, list

/** Sets the mute state of the current audio stream. */
fun setMuted(muted: Boolean) {
if (Util.SDK_INT >= 23) {
audioManager.adjustStreamVolume(
streamType,
if (muted) AudioManager.ADJUST_MUTE else AudioManager.ADJUST_UNMUTE,
VOLUME_FLAGS
)
} else {
@Suppress("Deprecation")
audioManager.setStreamMute(streamType, muted)
}
audioManager.adjustStreamVolume(
streamType,
if (muted) AudioManager.ADJUST_MUTE else AudioManager.ADJUST_UNMUTE,
VOLUME_FLAGS
)
updateVolumeAndNotifyIfChanged()
}

Expand Down Expand Up @@ -210,11 +205,7 @@ internal class StreamVolumeManager(context: Context, eventHandler: Handler, list
audioManager: AudioManager,
streamType: @C.StreamType Int,
): Boolean {
return if (Util.SDK_INT >= 23) {
audioManager.isStreamMute(streamType)
} else {
getVolumeFromManager(audioManager, streamType) == 0
}
return audioManager.isStreamMute(streamType)
}
}
}
Loading
Loading