Skip to content

Commit

Permalink
Merge pull request #627 from qdsfdhvh/master
Browse files Browse the repository at this point in the history
Version to 1.8.4
  • Loading branch information
qdsfdhvh authored Oct 9, 2024
2 parents 7e6dbc9 + 9fcb770 commit 6c16fab
Show file tree
Hide file tree
Showing 22 changed files with 212 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CompareScreenshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/StoreScreenshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
+ api("io.github.qdsfdhvh:image-loader:1.8.3")
+ api("io.github.qdsfdhvh:image-loader:1.8.4")
// optional - Compose Multiplatform Resources Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-compose-resources:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-compose-resources:1.8.4")
// optional - Moko Resources Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.8.4")
// optional - Blur Interceptor (only support bitmap)
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.8.4")
}
}
val jvmMain by getting {
dependencies {
// optional - ImageIO Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.8.4")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import co.touchlab.kermit.Logger
import com.seiko.imageloader.demo.data.imageJsonData
import com.seiko.imageloader.model.ImageRequest
import com.seiko.imageloader.option.SizeResolver
import com.seiko.imageloader.rememberImagePainter
import com.seiko.imageloader.ui.AutoSizeImage
import io.github.qdsfdhvh.imageloader.demo.common.Res
import org.jetbrains.compose.resources.ExperimentalResourceApi

Expand All @@ -54,6 +58,40 @@ fun OtherImagesScene(
verticalArrangement = Arrangement.spacedBy(6.dp),
modifier = Modifier.padding(innerPadding).fillMaxSize(),
) {
item {
Text("Test same svg with different size")
}
item {
Row {
val density = LocalDensity.current
Image(
rememberImagePainter(
remember {
ImageRequest("https://cdn.alza.cz/Foto/category/40/18901355.svg") {
size(SizeResolver(density, 50.dp))
}
},
),
contentDescription = null,
modifier = Modifier.size(50.dp),
)
Spacer(Modifier.width(6.dp))
Image(
rememberImagePainter("https://cdn.alza.cz/Foto/category/40/18901355.svg"),
contentDescription = null,
modifier = Modifier.size(146.dp),
)
Spacer(Modifier.width(6.dp))
AutoSizeImage(
"https://cdn.alza.cz/Foto/category/40/18901355.svg",
contentDescription = null,
modifier = Modifier.size(77.dp),
)
}
}
item {
Text("Test image change")
}
item {
Column {
Row {
Expand Down Expand Up @@ -129,11 +167,18 @@ fun OtherImagesScene(

@Composable
private fun TestSvgImage(url: String) {
val density = LocalDensity.current
Image(
painter = rememberImagePainter(url),
painter = rememberImagePainter(
remember {
ImageRequest(url) {
size(SizeResolver(density, 55.dp))
}
},
),
contentDescription = null,
modifier = Modifier
.size(50.dp)
.size(55.dp)
.background(color = Color.Red),
contentScale = ContentScale.FillWidth,
)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object ProjectVersion {
private const val monir = "8"

// backwards compatible bug fixes
private const val path = "3"
private const val path = "4"
const val version = "$major.$monir.$path"
}

Expand Down
10 changes: 5 additions & 5 deletions docs/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
+ api("io.github.qdsfdhvh:image-loader:1.8.3")
+ api("io.github.qdsfdhvh:image-loader:1.8.4")
// optional - Moko Resources Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.8.4")
// optional - Blur Interceptor (only support bitmap)
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.8.4")
}
}
val jvmMain by getting {
dependencies {
// optional - ImageIO Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.8.3")
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.8.4")
}
}
}
Expand All @@ -38,7 +38,7 @@ Copy the following snippets if you are using [gradle version catalog](https://do

```xml title="libs.versions.toml"
[versions]
image-loader = "1.8.3"
image-loader = "1.8.4"

[libraries]
image-loader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "image-loader" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.seiko.imageloader.component.keyer

import androidx.compose.ui.geometry.isSpecified
import com.seiko.imageloader.BitmapConfig
import com.seiko.imageloader.option.Options
import com.seiko.imageloader.option.Scale
Expand Down Expand Up @@ -35,6 +36,9 @@ class KtorUrlKeyer : Keyer {
if (options.maxImageSize != Options.DEFAULT_MAX_IMAGE_SIZE) {
append("-maxSize${options.maxImageSize}")
}
if (options.size.isSpecified) {
append("-size=${options.size}")
}
}
}
}
2 changes: 1 addition & 1 deletion extension/moko-resources/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ kotlin {
commonMain {
dependencies {
implementation(projects.imageLoader)
implementation("dev.icerock.moko:resources:0.24.2")
implementation("dev.icerock.moko:resources:0.24.3")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ internal actual fun createSVGPainter(source: BufferedSource, density: Density, o
dom = AndroidSvgDom(dom),
density = density,
requestSize = options.size,
bitmapConfig = options.bitmapConfig,
)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@ package com.seiko.imageloader.util
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.geometry.isSpecified
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ImageBitmapConfig
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.IntSize
import com.seiko.imageloader.BitmapConfig
import com.seiko.imageloader.component.decoder.SvgDom
import kotlin.math.ceil

@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
internal class SVGPainter(
private val dom: SvgDom,
private val density: Density,
private val requestSize: Size = Size.Unspecified,
bitmapConfig: BitmapConfig = BitmapConfig.ARGB_8888,
) : Painter() {

private val imageBitmapConfig = when (bitmapConfig) {
BitmapConfig.ARGB_8888 -> ImageBitmapConfig.Argb8888
BitmapConfig.RGBA_F16 -> ImageBitmapConfig.F16
BitmapConfig.ALPHA_8 -> ImageBitmapConfig.Alpha8
BitmapConfig.HARDWARE -> ImageBitmapConfig.Gpu
}

private val defaultSizePx: Size = run {
if (requestSize.isSpecified) {
return@run requestSize
Expand Down Expand Up @@ -44,7 +55,7 @@ internal class SVGPainter(
private var colorFilter: ColorFilter? = null

// with caching into bitmap FPS is 3x-4x higher (tested with idea-logo.svg with 30x30 icons)
private val drawCache = DrawCache()
private val drawCache = androidx.compose.ui.graphics.vector.DrawCache()

override fun applyAlpha(alpha: Float): Boolean {
this.alpha = alpha
Expand All @@ -58,10 +69,13 @@ internal class SVGPainter(

override fun DrawScope.onDraw() {
if (previousDrawSize != size) {
previousDrawSize = size

drawCache.drawCachedImage(
IntSize(ceil(size.width).toInt(), ceil(size.height).toInt()),
config = imageBitmapConfig,
size = IntSize(ceil(size.width).toInt(), ceil(size.height).toInt()),
density = this,
layoutDirection,
layoutDirection = layoutDirection,
) {
drawSvg(size)
}
Expand All @@ -75,4 +89,23 @@ internal class SVGPainter(
dom.draw(canvas, size)
}
}

override fun hashCode(): Int {
var result = dom.hashCode()
result = 31 * result + density.hashCode()
result = 31 * result + requestSize.hashCode()
result = 31 * result + imageBitmapConfig.hashCode()
return result
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is SVGPainter) return false

if (dom != other.dom) return false
if (density != other.density) return false
if (requestSize != other.requestSize) return false
if (imageBitmapConfig != other.imageBitmapConfig) return false
return true
}
}
20 changes: 10 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
[versions]
agp = "8.6.0"
agp = "8.7.0"
compose-multiplatform = "1.6.11"
kotlin = "2.0.0"
kotlinx-coroutines = "1.8.1"
kotlinx-serialization = "1.7.2"
kotlinx-coroutines = "1.9.0"
kotlinx-serialization = "1.7.3"
androidx-core-ktx = "1.13.1"
androidx-collection = "1.4.3"
androidx-collection = "1.4.4"
androidx-appcompat = "1.7.0"
androidx-exifinterface = "1.3.7"
androidx-activity-compose = "1.9.1"
androidx-lifecycle-runtime-ktx = "2.8.4"
androidx-activity-compose = "1.9.2"
androidx-lifecycle-runtime-ktx = "2.8.6"
spotless = "6.25.0"
ktlint = "0.50.0"
publish = "0.29.0"
dokka = "1.9.20"
ktor = "3.0.0-beta-2"
okio = "3.9.0"
ktor = "3.0.0-rc-1"
okio = "3.9.1"
uri-kmp = "0.0.18"
kermit = "2.0.4"
androidsvg = "1.4"
benchmark = "1.3.0"
benchmark = "1.3.2"
junit = "4.13.2"
androidx-test-junit = "1.2.1"
androidx-test-espresso = "3.6.1"
androidx-test-uiautomator = "2.3.0"
profileinstaller = "1.3.1"
profileinstaller = "1.4.1"
roborazzi = "1.26.0"
poko = "0.16.0"
turbine = "1.0.0"
Expand Down
Loading

0 comments on commit 6c16fab

Please sign in to comment.