Skip to content
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

Update compile sdk to 35. #2456

Merged
merged 5 commits into from
Sep 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SystemCallbacksTest {

assertEquals(8_000_000, memoryCache.size)

@Suppress("DEPRECATION")
systemCallbacks.onTrimMemory(TRIM_MEMORY_COMPLETE)

assertEquals(0, memoryCache.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.ComponentCallbacks2
import android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND
import android.content.ComponentCallbacks2.TRIM_MEMORY_COMPLETE
import android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW
import android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN
import android.content.Context
import android.content.res.Configuration
import coil3.RealImageLoader
Expand All @@ -21,6 +20,7 @@ internal actual fun SystemCallbacks(
* it be freed automatically by the garbage collector. If the [imageLoader] is freed, it unregisters
* its callbacks.
*/
@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")
internal class AndroidSystemCallbacks(
imageLoader: RealImageLoader,
) : SystemCallbacks, ComponentCallbacks2 {
Expand Down Expand Up @@ -55,8 +55,10 @@ internal class AndroidSystemCallbacks(
"trimMemory, level=$level"
}
if (level >= TRIM_MEMORY_BACKGROUND) {
// The app is in the background.
imageLoader.memoryCache?.clear()
} else if (level in TRIM_MEMORY_RUNNING_LOW until TRIM_MEMORY_UI_HIDDEN) {
} else if (level >= TRIM_MEMORY_RUNNING_LOW) {
// The app is in the foreground, but is running low on memory.
imageLoader.memoryCache?.apply { trimToSize(size / 2) }
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ org.jetbrains.compose.experimental.wasm.enabled=true

# Config
minSdk=21
targetSdk=34
compileSdk=34
targetSdk=35
compileSdk=35

# Maven
SONATYPE_HOST=DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onRoot
import androidx.test.ext.junit.runners.AndroidJUnit4
import coil3.ImageLoader
import coil3.compose.AsyncImage
import coil3.compose.rememberAsyncImagePainter
import coil3.test.FakeImageLoaderEngine
import coil3.test.intercept
import coil3.test.utils.ComposeTestActivity
import coil3.test.utils.RobolectricTest
import com.github.takahirom.roborazzi.RoborazziRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.GraphicsMode

@RunWith(AndroidJUnit4::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
class RoborazziComposeTestAndroid {
class RoborazziComposeTestAndroid : RobolectricTest() {

@get:Rule
val composeTestRule = createAndroidComposeRule<ComposeTestActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ import android.widget.ImageView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import coil3.ImageLoader
import coil3.request.ImageRequest
import coil3.request.target
import coil3.test.FakeImageLoaderEngine
import coil3.test.intercept
import coil3.test.utils.RobolectricTest
import coil3.test.utils.ViewTestActivity
import coil3.test.utils.activity
import com.github.takahirom.roborazzi.RoborazziRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.GraphicsMode

@RunWith(AndroidJUnit4::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
class RoborazziViewTest {
class RoborazziViewTest : RobolectricTest() {

@get:Rule
val activityRule = activityScenarioRule<ViewTestActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import okio.source
import org.junit.Assume
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
actual abstract class AndroidJUnit4Test

@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34])
actual abstract class RobolectricTest

actual val context: PlatformContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import okio.ByteString.Companion.toByteString
import okio.blackholeSink
import okio.fakefilesystem.FakeFileSystem

abstract class AbstractNetworkFetcherTest : AndroidJUnit4Test() {
abstract class AbstractNetworkFetcherTest : RobolectricTest() {

lateinit var fileSystem: FakeFileSystem
lateinit var diskCache: DiskCache
Expand Down