Skip to content

Commit

Permalink
Coil 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawnnypoo committed Nov 5, 2024
1 parent a6763c2 commit 5d573fb
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 91 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
name: Build
on: [pull_request, push]

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Build the app
- name: Checkout
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Configure JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Test
run: ./gradlew build
35 changes: 35 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Release

on:
push:
tags:
- '*'
env:
RELEASE_SIGNING_ENABLED: true

jobs:
publish:

runs-on: ubuntu-latest
if: github.repository == 'Commit451/coil-transformations'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Set version
run: sed -i "s/VERSION_NAME=0.0.1/VERSION_NAME=$GITHUB_REF_NAME/" gradle.properties

- name: Release to Maven Central
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
2 changes: 1 addition & 1 deletion .jitpack.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jdk: openjdk11
jdk: openjdk17
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## [3.0.0] - November 5, 2024
- Updates to support Coil 3.0

## [2.0.0] - March 16, 2022
- Updates to support Coil 2.0

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:Suppress("NOTHING_TO_INLINE", "unused")
@file:Suppress("unused")

package coiltransformations

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ android.useAndroidX=true

# Config
minSdk=21
targetSdk=32
coilVersion=2.0.0
targetSdk=35
coilVersion=3.0.0

GROUP=com.commit451.coiltransformations
# Overwritten by CI
VERSION_NAME=1.0.0
VERSION_NAME=0.0.1

POM_NAME=Transformations for Coil
POM_DESCRIPTION=Various transformations for Coil
Expand Down
22 changes: 11 additions & 11 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

dependencies {
implementation(project(":transformations"))
implementation(project(":transformations-gpu"))
implementation(project(":transformations-face-detection"))
implementation("io.coil-kt:coil:${project.coilVersion}")
implementation("io.coil-kt.coil3:coil-compose:${project.coilVersion}")

implementation("androidx.appcompat:appcompat:1.4.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
implementation("androidx.recyclerview:recyclerview:1.3.2")

implementation("com.google.android.material:material:1.5.0")
implementation("com.google.android.material:material:1.12.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
package com.commit451.coiltransformations.sample

import android.app.Application
import android.util.Log
import coil.Coil
import coil.ImageLoader
import coil.memory.MemoryCache
import coil.util.DebugLogger
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.request.crossfade
import coil3.util.DebugLogger

class App : Application() {

override fun onCreate() {
super.onCreate()
Coil.setImageLoader {
SingletonImageLoader.setSafe {
ImageLoader.Builder(this)
.logger(DebugLogger(level = Log.DEBUG))
.memoryCache(MemoryCache.Builder(this).maxSizePercent(0.5).build())
.logger(DebugLogger())
.crossfade(true)
.build()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.commit451.coiltransformations.sample

import androidx.annotation.DrawableRes
import coil.transform.Transformation
import coil3.transform.Transformation

data class Image(
val transformation: Transformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import android.widget.TextView
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import coil.load
import com.commit451.coiltransformations.facedetection.CenterOnFaceTransformation
import coil3.load
import coil3.request.transformations
import com.commit451.coiltransformations.sample.ImageListAdapter.ViewHolder

class ImageListAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import androidx.core.view.isVisible
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil3.load
import coil3.request.transformations

class MainActivity : AppCompatActivity() {

Expand Down
13 changes: 5 additions & 8 deletions transformations-face-detection/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "1.8"
}
libraryVariants.all {
generateBuildConfigProvider?.configure { enabled = false }
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

dependencies {
api("io.coil-kt:coil-base:${project.coilVersion}")
api("com.google.mlkit:face-detection:16.1.5")
api("io.coil-kt.coil3:coil-core:${project.coilVersion}")
api("com.google.mlkit:face-detection:16.1.7")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.graphics.Bitmap
import android.graphics.Rect
import android.util.Log
import android.util.LruCache
import coil.size.Size
import coil.transform.Transformation
import coil3.size.Size
import coil3.transform.Transformation
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.face.FaceDetection
import com.google.mlkit.vision.face.FaceDetectorOptions
Expand All @@ -29,7 +29,7 @@ import kotlin.coroutines.resumeWithException
class CenterOnFaceTransformation constructor(
private val cache: LruCache<String, String>? = null,
val zoom: Int
) : Transformation {
) : Transformation() {

companion object {
private const val TAG = "CenterOnFaceTransform"
Expand Down
11 changes: 4 additions & 7 deletions transformations-gpu/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "1.8"
}
libraryVariants.all {
generateBuildConfigProvider?.configure { enabled = false }
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

dependencies {
api("io.coil-kt:coil-base:${project.coilVersion}")
api("io.coil-kt.coil3:coil-core:${project.coilVersion}")
api("jp.co.cyberagent.android:gpuimage:2.1.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.commit451.coiltransformations.gpu

import android.content.Context
import android.graphics.Bitmap
import coil.size.Size
import coil.transform.Transformation
import coil3.size.Size
import coil3.transform.Transformation
import jp.co.cyberagent.android.gpuimage.GPUImage
import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter

Expand All @@ -14,7 +14,7 @@ import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter
*/
abstract class GPUFilterTransformation(
private val context: Context
) : Transformation {
) : Transformation() {

/**
* Create the [GPUImageFilter] to apply to this [Transformation]
Expand Down
13 changes: 5 additions & 8 deletions transformations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "1.8"
}
libraryVariants.all {
generateBuildConfigProvider?.configure { enabled = false }
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

dependencies {
api("io.coil-kt:coil-base:${project.coilVersion}")
api("androidx.core:core-ktx:1.7.0")
api("io.coil-kt.coil3:coil-core:${project.coilVersion}")
api("androidx.core:core-ktx:1.15.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import android.renderscript.ScriptIntrinsicBlur
import androidx.annotation.RequiresApi
import androidx.core.graphics.applyCanvas
import androidx.core.graphics.createBitmap
import coil.size.Size
import coil.transform.Transformation
import coil3.size.Size
import coil3.transform.Transformation
import com.commit451.coiltransformations.Util.safeConfig

/**
Expand All @@ -29,7 +29,7 @@ class BlurTransformation @JvmOverloads constructor(
private val context: Context,
private val radius: Float = DEFAULT_RADIUS,
private val sampling: Float = DEFAULT_SAMPLING
) : Transformation {
) : Transformation() {

init {
require(radius in 0.0..25.0) { "radius must be in [0, 25]." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.commit451.coiltransformations
import android.graphics.*
import androidx.annotation.ColorInt
import androidx.core.graphics.createBitmap
import coil.size.Size
import coil.transform.Transformation
import coil3.size.Size
import coil3.transform.Transformation
import com.commit451.coiltransformations.Util.safeConfig

/**
Expand All @@ -13,7 +13,7 @@ import com.commit451.coiltransformations.Util.safeConfig
*/
class ColorFilterTransformation(
@ColorInt private val color: Int
) : Transformation {
) : Transformation() {

override val cacheKey: String = "${ColorFilterTransformation::class.java.name}-$color"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.RectF
import androidx.core.graphics.createBitmap
import coil.size.Size
import coil.size.pxOrElse
import coil.transform.Transformation
import coil3.size.Size
import coil3.size.pxOrElse
import coil3.transform.Transformation
import com.commit451.coiltransformations.Util.safeConfig
import kotlin.math.max

Expand All @@ -16,7 +16,7 @@ import kotlin.math.max
*/
class CropTransformation(
private val cropType: CropType = CropType.CENTER
) : Transformation {
) : Transformation() {

enum class CropType {
TOP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import android.graphics.ColorMatrixColorFilter
import android.graphics.Paint
import androidx.core.graphics.applyCanvas
import androidx.core.graphics.createBitmap
import coil.size.Size
import coil.transform.Transformation
import coil3.size.Size
import coil3.transform.Transformation
import com.commit451.coiltransformations.Util.safeConfig

/**
* A [Transformation] that converts an image to shades of gray.
*/
class GrayscaleTransformation : Transformation {
class GrayscaleTransformation : Transformation() {

override val cacheKey: String = GrayscaleTransformation::class.java.name

Expand Down
Loading

0 comments on commit 5d573fb

Please sign in to comment.