Skip to content

Update to SDK 35 #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 4, 2024
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: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Readium | Android min SDK | Android compile SDK | Kotlin compiler (✻) | Gradle (✻) |
|-----------|-----------------|---------------------|---------------------|------------|
| `develop` | 21 | 34 | 1.9.24 | 8.10.2 |
| `develop` | 21 | 35 | 1.9.24 | 8.10.2 |
| 3.0.0 | 21 | 34 | 1.9.24 | 8.6.0 |
| 2.3.0 | 21 | 33 | 1.7.10 | 6.9.3 |

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pom.groupId=org.readium.kotlin-toolkit
pom.version=3.0.1

android.minSdk=21
android.compileSdk=34
android.targetSdk=34
android.compileSdk=35
android.targetSdk=35

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ androidx-compose-material3 = "1.3.1"
androidx-compose-runtime = "1.7.5"
androidx-compose-ui = "1.7.5"
androidx-constraintlayout = "2.2.0"
androidx-core = "1.13.1"
androidx-core = "1.15.0"
androidx-datastore = "1.1.1"
androidx-fragment-ktx = "1.8.5"
androidx-legacy = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public class HtmlResourceContentIterator internal constructor(
if (node.isBlock) {
assert(breadcrumbs.last().element == node)
flushText()
breadcrumbs.removeLast()
breadcrumbs.removeAt(breadcrumbs.lastIndex)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ public interface MemoryObserver {
* Level of memory trim.
*/
public enum class Level {
Moderate, Low, Critical;
/**
* The process has gone on to the LRU list. This is a good opportunity to clean up resources
* that can efficiently and quickly be re-built if the user returns to the app.
*/
Background,

/**
* The process had been showing a user interface, and is no longer doing so. Large
* allocations with the UI should be released at this point to allow memory to be better
* managed.
*/
UiHidden;

public companion object {
public fun fromLevel(level: Int): Level =
when {
level <= ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE -> Moderate
level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW -> Low
else -> Critical
when (level) {
ComponentCallbacks2.TRIM_MEMORY_BACKGROUND -> Background
ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN -> UiHidden
else -> Background
}
}
}
Expand All @@ -40,6 +51,8 @@ public interface MemoryObserver {
public fun asComponentCallbacks2(observer: MemoryObserver): ComponentCallbacks2 =
object : ComponentCallbacks2 {
override fun onConfigurationChanged(config: Configuration) {}

@Deprecated("Deprecated in Java")
override fun onLowMemory() {}

override fun onTrimMemory(level: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public class InMemoryCache<V> : Cache<V> {

@OptIn(DelicateCoroutinesApi::class)
override fun onTrimMemory(level: MemoryObserver.Level) {
if (level == MemoryObserver.Level.Critical) {
if (level == MemoryObserver.Level.Background) {
GlobalScope.launch { transaction { clear() } }
}
}
Expand Down
9 changes: 9 additions & 0 deletions test-app/src/main/java/org/readium/r2/testapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
package org.readium.r2.testapp

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
Expand All @@ -24,7 +27,13 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.container)) { v, insets ->
val statusBars = insets.getInsets(WindowInsetsCompat.Type.statusBars())
v.setPadding(statusBars.left, statusBars.top, statusBars.right, statusBars.bottom)
insets
}

val navView: BottomNavigationView = findViewById(R.id.nav_view)
val navHostFragment =
Expand Down