Skip to content

Commit 32d8867

Browse files
authored
Extensions for 3rd-party image libraries (#27)
* ADD: extensions for Glide and Picasso * ADD: extensions for Coil and Fresco * FIX: Gradle build issues with Coil and Fresco extensions * FIX: native library loading issue in Fresco extension * FIX: image view reference in responsive method call
1 parent 81c2c58 commit 32d8867

File tree

39 files changed

+592
-13
lines changed

39 files changed

+592
-13
lines changed

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Thu Jun 08 16:25:53 IST 2023
1+
#Fri Jun 23 01:05:00 IST 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

imagekit-coil-extension/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

imagekit-coil-extension/build.gradle

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'maven-publish'
5+
}
6+
7+
android {
8+
namespace = "com.imagekit.android.coil_extension"
9+
compileSdkVersion 33
10+
11+
defaultConfig {
12+
minSdkVersion 21
13+
targetSdkVersion 33
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
consumerProguardFiles "consumer-rules.pro"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
kotlinOptions {
30+
jvmTarget = '1.8'
31+
}
32+
publishing {
33+
publications {
34+
release(MavenPublication) {
35+
groupId = group
36+
artifactId = 'imagekit-coil-extension'
37+
version = '1.0.0'
38+
39+
afterEvaluate {
40+
from components.release
41+
}
42+
}
43+
}
44+
}
45+
}
46+
47+
dependencies {
48+
49+
implementation project(":imagekit")
50+
api "io.coil-kt:coil:2.4.0"
51+
52+
testImplementation 'junit:junit:4.13.2'
53+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
54+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
55+
}

imagekit-coil-extension/consumer-rules.pro

Whitespace-only changes.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.imagekit.android.coil_extension
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.example.imagekit.android.coil_extension.test", appContext.packageName)
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.imagekit.android.coil_extension" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.imagekit.android.coil_extension
2+
3+
import android.graphics.drawable.Drawable
4+
import coil.request.ImageRequest
5+
import com.imagekit.android.ImagekitUrlConstructor
6+
7+
fun ImagekitUrlConstructor.createWithCoil(
8+
placeholderImage: Drawable? = null,
9+
errorImage: Drawable? = null
10+
): ImageRequest.Builder = ImageRequest.Builder(context)
11+
.data(create())
12+
.placeholder(placeholderImage)
13+
.error(errorImage)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.imagekit.android.coil_extension
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

imagekit-fresco-extension/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'maven-publish'
5+
}
6+
7+
android {
8+
namespace = "com.imagekit.android.fresco_extension"
9+
compileSdkVersion 33
10+
11+
defaultConfig {
12+
minSdkVersion 21
13+
targetSdkVersion 33
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
consumerProguardFiles "consumer-rules.pro"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
kotlinOptions {
30+
jvmTarget = '1.8'
31+
}
32+
publishing {
33+
publications {
34+
release(MavenPublication) {
35+
groupId = group
36+
artifactId = 'imagekit-fresco-extension'
37+
version = '1.0.0'
38+
39+
afterEvaluate {
40+
from components.release
41+
}
42+
}
43+
}
44+
}
45+
}
46+
47+
dependencies {
48+
49+
implementation project(":imagekit")
50+
api "com.facebook.fresco:fresco:3.0.0"
51+
api('com.facebook.fresco:nativeimagetranscoder') {
52+
version {
53+
strictly '2.6.0'
54+
}
55+
}
56+
57+
testImplementation 'junit:junit:4.13.2'
58+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
59+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
60+
}

imagekit-fresco-extension/consumer-rules.pro

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.imagekit.android.fresco_extension
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.example.imagekit.android.fresco_extension.test", appContext.packageName)
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.imagekit.android.fresco_extension" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.imagekit.android.fresco_extension
2+
3+
import android.net.Uri
4+
import android.view.View
5+
import com.facebook.drawee.backends.pipeline.Fresco
6+
import com.facebook.drawee.view.DraweeView
7+
import com.facebook.drawee.view.SimpleDraweeView
8+
import com.facebook.imagepipeline.request.ImageRequest
9+
import com.facebook.imagepipeline.request.ImageRequestBuilder
10+
import com.facebook.imagepipeline.request.Postprocessor
11+
import com.imagekit.android.ImagekitUrlConstructor
12+
13+
fun ImagekitUrlConstructor.createWithFresco(
14+
postprocessor: Postprocessor? = null
15+
): ImageRequest = ImageRequestBuilder
16+
.newBuilderWithSource(Uri.parse(create()))
17+
.setPostprocessor(postprocessor)
18+
.build()
19+
20+
fun ImageRequest.buildWithTarget(view: SimpleDraweeView) {
21+
view.controller = Fresco.newDraweeControllerBuilder()
22+
.setImageRequest(this)
23+
.setOldController(view.controller)
24+
.build()
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.imagekit.android.fresco_extension
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

imagekit-glide-extension/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

imagekit-glide-extension/build.gradle

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'maven-publish'
5+
}
6+
7+
group = 'com.github.imagekit-developer'
8+
9+
android {
10+
compileSdkVersion 33
11+
12+
defaultConfig {
13+
namespace = "com.imagekit.android.glide_extension"
14+
minSdkVersion 21
15+
targetSdkVersion 33
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
consumerProguardFiles "consumer-rules.pro"
19+
}
20+
21+
buildTypes {
22+
release {
23+
minifyEnabled false
24+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
compileOptions {
28+
sourceCompatibility JavaVersion.VERSION_1_8
29+
targetCompatibility JavaVersion.VERSION_1_8
30+
}
31+
kotlinOptions {
32+
jvmTarget = '1.8'
33+
}
34+
35+
publishing {
36+
publications {
37+
release(MavenPublication) {
38+
groupId = group
39+
artifactId = 'imagekit-glide-extension'
40+
version = '1.0.0'
41+
42+
afterEvaluate {
43+
from components.release
44+
}
45+
}
46+
}
47+
}
48+
}
49+
50+
dependencies {
51+
52+
implementation project(":imagekit")
53+
api "com.github.bumptech.glide:glide:4.15.1"
54+
55+
testImplementation 'junit:junit:4.13.2'
56+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
57+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
58+
}

imagekit-glide-extension/consumer-rules.pro

Whitespace-only changes.

0 commit comments

Comments
 (0)