From 1f3de45021bc2c710e33daddf58f9e2ea1151e23 Mon Sep 17 00:00:00 2001
From: Danil Yudov <skeptick13@gmail.com>
Date: Wed, 12 Apr 2023 01:59:23 +0500
Subject: [PATCH] Release 1.1.8

---
 README.md                                            |  6 +++---
 .../libres/plugin/LibresImagesGenerationTask.kt      |  1 -
 .../libres/plugin/LibresStringGenerationTask.kt      |  1 -
 .../libres/plugin/images/models/ImageProps.kt        |  4 ++--
 .../libres/plugin/images/models/ImageSetContents.kt  |  6 +++---
 .../images/processing/ImageSpecs+Operations.kt       |  6 +++---
 .../skeptick/libres/plugin/images/processing/Size.kt | 12 ++++++------
 gradle.properties                                    |  2 +-
 gradle/libs.versions.toml                            |  4 ++--
 9 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/README.md b/README.md
index 07e9591..6dbad79 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Resources generation in Kotlin Multiplatform.
 
 buildscript {
     dependencies {
-        classpath("io.github.skeptick.libres:gradle-plugin:1.1.7")
+        classpath("io.github.skeptick.libres:gradle-plugin:1.1.8")
     }
 }
 ```
@@ -119,7 +119,7 @@ MainRes.shared.string.simple_string
 Supported formats:
 - PNG
 - JPG
-- WEBP (iOS 14+)
+- WEBP (Android 4.3+, iOS 14+)
 - SVG (iOS 13+)
 
 For Android SVG are converted to 
@@ -179,7 +179,7 @@ Image size in Figma is **240x89**. Final image name is **pic_(orig)_(240).png**
 kotlin {
     commonMain {
         dependencies {
-            implementation("io.github.skeptick.libres:libres-compose:1.1.7")
+            implementation("io.github.skeptick.libres:libres-compose:1.1.8")
         }
     }
 }
diff --git a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresImagesGenerationTask.kt b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresImagesGenerationTask.kt
index d0f7583..989f1e3 100644
--- a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresImagesGenerationTask.kt
+++ b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresImagesGenerationTask.kt
@@ -44,7 +44,6 @@ abstract class LibresImagesGenerationTask : DefaultTask() {
             }
         }
 
-        outputSourcesDirectories.forEach { it.value.deleteFilesInDirectory() }
         inputDirectory.files
             .takeIf { files -> files.isNotEmpty() }
             ?.map { file -> ImageProps(file) }
diff --git a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresStringGenerationTask.kt b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresStringGenerationTask.kt
index 9ac1aae..797ae7e 100644
--- a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresStringGenerationTask.kt
+++ b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/LibresStringGenerationTask.kt
@@ -25,7 +25,6 @@ abstract class LibresStringGenerationTask : DefaultTask() {
 
     @TaskAction
     fun apply() {
-        outputDirectory.deleteFilesInDirectory()
         inputDirectory.files
             .takeIf { files -> files.isNotEmpty() }
             ?.let { files -> parseStringResources(files, settings.baseLocaleLanguageCode) }
diff --git a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageProps.kt b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageProps.kt
index 49c8d97..1d8ed76 100644
--- a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageProps.kt
+++ b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageProps.kt
@@ -7,7 +7,7 @@ internal class ImageProps(val file: File) {
     val name: String
     val extension: String
     val targetSize: Int?
-    val isNonRepaintable: Boolean
+    val isTintable: Boolean
 
     init {
         val nameWithoutExtension = file.nameWithoutExtension
@@ -15,7 +15,7 @@ internal class ImageProps(val file: File) {
         this.name = nameWithoutExtension.substringBefore("_(").lowercase()
         this.extension = file.extension.lowercase()
         this.targetSize = if (extension != "svg") parameters.firstNotNullOfOrNull { it.groupValues[1].toIntOrNull() } else null
-        this.isNonRepaintable = parameters.any { it.groupValues[1].startsWith("orig") }
+        this.isTintable = parameters.none { it.groupValues[1].startsWith("orig") }
     }
 
     companion object {
diff --git a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageSetContents.kt b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageSetContents.kt
index b217cbb..ff67433 100644
--- a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageSetContents.kt
+++ b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/models/ImageSetContents.kt
@@ -50,9 +50,9 @@ internal fun ImageProps.toImageSetContents() =
         },
         properties = ImageSetContents.Properties(
             preserveVectorRepresentation = if (isVector) true else null,
-            templateRenderingIntent = when (isNonRepaintable) {
-                true -> ImageSetContents.VectorRenderingType.Original
-                false -> ImageSetContents.VectorRenderingType.Template
+            templateRenderingIntent = when (isTintable) {
+                true -> ImageSetContents.VectorRenderingType.Template
+                false -> ImageSetContents.VectorRenderingType.Original
             }
         )
     )
\ No newline at end of file
diff --git a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/ImageSpecs+Operations.kt b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/ImageSpecs+Operations.kt
index a8a2700..e2a02ef 100644
--- a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/ImageSpecs+Operations.kt
+++ b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/ImageSpecs+Operations.kt
@@ -37,9 +37,9 @@ internal fun ImageProps.saveImage(directories: Map<KotlinPlatform, File>) {
             if (!directories.any { it.key in scale.supportedPlatforms }) continue
             val newSideSize = targetSize * scale
             when {
-                src.size().isLessThan(newSideSize) -> error("Image '$name' has too low resolution")
-                src.size().isEqual(newSideSize) -> saveOriginal(scale, directories)
-                else -> resizeAndSave(src, scale, targetSize, directories)
+                src.size() < newSideSize -> error("Image '$name' has too low resolution")
+                src.size() > newSideSize -> resizeAndSave(src, scale, targetSize, directories)
+                else -> saveOriginal(scale, directories)
             }
         }
     }
diff --git a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/Size.kt b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/Size.kt
index 623bc4f..fedf07d 100644
--- a/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/Size.kt
+++ b/gradle-plugin/src/main/java/io/github/skeptick/libres/plugin/images/processing/Size.kt
@@ -13,10 +13,10 @@ internal fun calculateSize(oldSize: Size, newSideSize: Int): Size {
     }
 }
 
-internal fun Size.isLessThan(sideSize: Int): Boolean {
-    return width() < sideSize && height() < sideSize
-}
-
-internal fun Size.isEqual(sideSize: Int): Boolean {
-    return (width() == sideSize && height() <= width()) || (height() == sideSize && width() <= height())
+internal operator fun Size.compareTo(sideSize: Int): Int {
+    return when {
+        width() > sideSize || height() > sideSize -> 1
+        width() < sideSize && height() < sideSize -> -1
+        else -> 0
+    }
 }
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 67795ac..4b4bdac 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -9,7 +9,7 @@ android.disableAutomaticComponentCreation=true
 kotlin.mpp.androidSourceSetLayoutVersion=2
 
 GROUP=io.github.skeptick.libres
-VERSION_NAME=1.1.7
+VERSION_NAME=1.1.8
 
 SONATYPE_HOST=S01
 
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index aea2430..939cac8 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,9 +1,9 @@
 [versions]
 plugin-android = "7.3.0"
 plugin-publish-maven = "0.22.0"
-plugin-multiplatform-compose = "1.3.0"
+plugin-multiplatform-compose = "1.3.1"
 
-kotlin = "1.8.0"
+kotlin = "1.8.10"
 androidx-core = "1.9.0"
 robovm = "1.0.0"
 icu4j = "70.1"