Skip to content

Commit 4f14468

Browse files
authored
Merge pull request #36 from AniVerma17/hotfix/minification_errors
Add ProGuard rules for Retrofit & RxJava dependencies
2 parents ec89f96 + ef0f17c commit 4f14468

File tree

5 files changed

+55
-41
lines changed

5 files changed

+55
-41
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ allprojects {
5454

5555
In the module build.gradle file, add:
5656
```gradle
57-
implementation 'com.github.imagekit-developer:imagekit-android:<VERSION>'
57+
implementation 'com.github.imagekit-developer.imagekit-android:imagekit-android:<VERSION>'
5858
```
5959

6060
## Usage
@@ -136,7 +136,7 @@ ImageKit.Companion.getInstance()
136136
// https://ik.imagekit.io/your_imagekit_id/medium_cafe_B1iTdD0C.jpg?tr=oi-logo-white_SJwqB4Nfe.png,ox-10,oy-20
137137
ImageKit.getInstance()
138138
.url(
139-
src = https://ik.imagekit.io/your_imagekit_id/medium_cafe_B1iTdD0C.jpg",
139+
src = "https://ik.imagekit.io/your_imagekit_id/medium_cafe_B1iTdD0C.jpg",
140140
transformationPosition = TransformationPosition.PATH
141141
)
142142
.create()
@@ -532,7 +532,7 @@ ImageKit.getInstance().uploader().upload(
532532
.requireNetworkType(UploadPolicy.UploadPolicy.NetworkType.UNMETERED)
533533
.setMaxRetries(5)
534534
.build(),
535-
preprocessor = ImagePreprocess.Builder()
535+
preprocessor = ImageUploadPreprocessor.Builder()
536536
.limit(512, 512)
537537
.rotate(90f)
538538
.build(),
@@ -574,41 +574,41 @@ This code snippet will set the policy to allow the upload request to be placed o
574574

575575
## Upload preprocessing
576576
### Image preprocessing
577-
The `ImagePreprocessor` class encapsulates a set of methods to apply certain transformations to an image before uploading. This will create a copy of the selected image, which will be transformed as per the given parameters before uploading.
577+
The `ImageUploadPreprocessor` class encapsulates a set of methods to apply certain transformations to an image before uploading. This will create a copy of the selected image, which will be transformed as per the given parameters before uploading.
578578

579-
`ImagePreprocessor.Builder` class is responsible for building the ImagePreprocess instances. This class provides following methods to access and modify the policy parameters:
579+
`ImageUploadPreprocessor.Builder` class is responsible for building the ImageUploadPreprocessor instances. This class provides following methods to access and modify the policy parameters:
580580

581581
| Parameter | Type | Description |
582582
|:------------------------------------------------------------------------------------------------------------------------|:--------------------------|:-------------------------------------------------------------------------|
583-
| limit(width: Int, height: Int) | ImagePreprocessor.Builder | Specifies the maximum width and height of the image |
584-
| crop(p1: Point, p2: Point) | ImagePreprocessor.Builder | Specifies the two points on the diagonal of the rectangle to be cropped. |
585-
| format(format: [Bitmap.CompressFormat](https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat)) | ImagePreprocessor.Builder | Specify the target image format. |
586-
| rotate(degrees: Float) | ImagePreprocessor.Builder | Specify the rotation angle of the target image. |
583+
| limit(width: Int, height: Int) | ImageUploadPreprocessor.Builder | Specifies the maximum width and height of the image |
584+
| crop(p1: Point, p2: Point) | ImageUploadPreprocessor.Builder | Specifies the two points on the diagonal of the rectangle to be cropped. |
585+
| format(format: [Bitmap.CompressFormat](https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat)) | ImageUploadPreprocessor.Builder | Specify the target image format. |
586+
| rotate(degrees: Float) | ImageUploadPreprocessor.Builder | Specify the rotation angle of the target image. |
587587

588588
Example code
589589
```kotlin
590-
val preprocessor = ImagePreprocessor.Builder()
590+
val preprocessor = ImageUploadPreprocessor.Builder()
591591
.limit(1280, 720)
592592
.format(Bitmap.CompressFormat.WEBP)
593593
.rotate(45f)
594594
.build()
595595
```
596596
### Video preprocessing
597-
The `VideoPreprocessor` class encapsulates a set of methods to apply certain transformations to a video before uploading. This will create a copy of the selected video, which will be transformed as per the given parameters before uploading.
597+
The `VideoUploadPreprocessor` class encapsulates a set of methods to apply certain transformations to a video before uploading. This will create a copy of the selected video, which will be transformed as per the given parameters before uploading.
598598

599-
`VideoPreprocessor.Builder` class is responsible for building the VideoPreprocess instances. This class provides the following methods to access and modify the policy parameters:
599+
`VideoUploadPreprocessor.Builder` class is responsible for building the VideoUploadPreprocessor instances. This class provides the following methods to access and modify the policy parameters:
600600

601601
| Parameter | Type | Description |
602602
|:-------------------------------------|:--------------------------|:-----------------------------------------------------|
603-
| limit(width: Int, height: Int) | VideoPreprocessor.Builder | Specifies the maximum width and height of the video. |
604-
| frameRate(frameRateValue: Int) | VideoPreprocessor.Builder | Specifies the target frame rate of the video. |
605-
| keyFramesInterval(interval: Int) | VideoPreprocessor.Builder | Specify the target keyframes interval of video. |
606-
| targetAudioBitrateKbps(bitrate: Int) | VideoPreprocessor.Builder | Specify the target audio bitrate of the video. |
607-
| targetVideoBitrateKbps(bitrate: Int) | VideoPreprocessor.Builder | Specify the target video bitrate of the video. |
603+
| limit(width: Int, height: Int) | VideoUploadPreprocessor.Builder | Specifies the maximum width and height of the video. |
604+
| frameRate(frameRateValue: Int) | VideoUploadPreprocessor.Builder | Specifies the target frame rate of the video. |
605+
| keyFramesInterval(interval: Int) | VideoUploadPreprocessor.Builder | Specify the target keyframes interval of video. |
606+
| targetAudioBitrateKbps(bitrate: Int) | VideoUploadPreprocessor.Builder | Specify the target audio bitrate of the video. |
607+
| targetVideoBitrateKbps(bitrate: Int) | VideoUploadPreprocessor.Builder | Specify the target video bitrate of the video. |
608608

609609
Example code
610610
```kotlin
611-
val preprocessor = VideoPreprocessor.Builder()
611+
val preprocessor = VideoUploadPreprocessor.Builder()
612612
.frameRate(90)
613613
.targetAudioBitrateKbps(320)
614614
.targetVideoBitrateKbps(480)
@@ -620,7 +620,7 @@ val preprocessor = VideoPreprocessor.Builder()
620620
### Glide
621621
In the module build.gradle file, add:
622622
```gradle
623-
implementation 'com.github.imagekit-developer:imagekit-glide-extension:1.0.0'
623+
implementation 'com.github.imagekit-developer.imagekit-android:imagekit-glide-extension:<VERSION>'
624624
```
625625
Then add the `createWithGlide()` extension function to the ImageKit URL constructor chain to get Glide's `RequestBuilder` instance to load into any target.
626626
The `placeholderImage` and `errorImage` parameters can be optionally set to pass the drawables to show for placeholder and error states respectively.
@@ -653,7 +653,7 @@ IKGlideExtension.createWithGlide(
653653
### Picasso
654654
In the module build.gradle file, add:
655655
```gradle
656-
implementation 'com.github.imagekit-developer:imagekit-picasso-extension:1.0.0'
656+
implementation 'com.github.imagekit-developer.imagekit-android:imagekit-picasso-extension:<VERSION>'
657657
```
658658
Then add the `createWithPicasso()` extension function to the ImageKit URL constructor chain to get Picasso's `RequestCreator` instance to load into any target.
659659
The `placeholderImage` and `errorImage` parameters can be optionally set to pass the drawables to show for placeholder and error states respectively.
@@ -686,7 +686,7 @@ IKPicassoExtension.createWithPicasso(
686686
### Coil
687687
In the module build.gradle file, add:
688688
```gradle
689-
implementation 'com.github.imagekit-developer:imagekit-coil-extension:1.0.0'
689+
implementation 'com.github.imagekit-developer.imagekit-android:imagekit-coil-extension:<VERSION>'
690690
```
691691
Then add the `createWithCoil()` extension function to the ImageKit URL constructor chain to get Coil's `ImageRequest.Builder` instance to load into any target, which can be enqueued with an `ImageLoader` instance.
692692
The `placeholderImage` and `errorImage` parameters can be optionally set to pass the drawables to show for placeholder and error states respectively.
@@ -726,7 +726,7 @@ Coil.imageLoader(context)
726726
### Fresco
727727
In the module build.gradle file, add:
728728
```gradle
729-
implementation 'com.github.imagekit-developer:imagekit-fresco-extension:1.0.0'
729+
implementation 'com.github.imagekit-developer.imagekit-android:imagekit-fresco-extension:<VERSION>'
730730
```
731731
Then add the `createWithFresco()` extension function to the ImageKit URL constructor chain to get Fresco's `ImageRequest` instance to load into any target, which can be loaded into the controller of target `DraweeView` provided by Fresco by calling the `buildWithTarget()` method.
732732
The `postprocessor` parameter can be optionally set to pass a `Postprocessor` for [post-precessing of images](https://frescolib.org/docs/modifying-image.html).

imagekit/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ android {
2121

2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2323

24-
buildConfigField "String", "API_VERSION", "\"3.0.0\""
24+
buildConfigField "String", "API_VERSION", "\"3.0.1\""
2525
}
2626

2727
buildTypes {
2828
release {
2929
minifyEnabled false
3030
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31+
consumerProguardFiles 'consumer-rules.pro'
3132
}
3233
}
3334

@@ -43,7 +44,7 @@ android {
4344
release(MavenPublication) {
4445
groupId = group
4546
artifactId = 'imagekit-android'
46-
version = '3.0.0'
47+
version = '3.0.1'
4748

4849
afterEvaluate {
4950
from components.release

imagekit/consumer-rules.pro

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Keep rules for Retrofit and its RxJava2 adapter
2+
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
3+
# EnclosingMethod is required to use InnerClasses.
4+
-keepattributes Signature, InnerClasses, EnclosingMethod
5+
# Retrofit does reflection on method and parameter annotations.
6+
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
7+
# Keep annotation default values (e.g., retrofit2.http.Field.encoded).
8+
-keepattributes AnnotationDefault
9+
# Retain service method parameters when optimizing.
10+
-keepclassmembers,allowshrinking,allowobfuscation interface * {
11+
@retrofit2.http.* <methods>;
12+
}
13+
# Ignore JSR 305 annotations for embedding nullability information.
14+
-dontwarn javax.annotation.**
15+
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
16+
-dontwarn kotlin.Unit
17+
# Top-level functions that can only be used by Kotlin.
18+
-dontwarn retrofit2.KotlinExtensions
19+
-dontwarn retrofit2.KotlinExtensions$*
20+
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
21+
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
22+
-if interface * { @retrofit2.http.* <methods>; }
23+
-keep,allowobfuscation interface <1>
24+
# Keep inherited services.
25+
-if interface * { @retrofit2.http.* <methods>; }
26+
-keep,allowobfuscation interface * extends <1>
27+
# R8 full mode strips generic signatures from return types if not kept.
28+
-if interface * { @retrofit2.http.* public *** *(...); }
29+
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
30+
-keep,allowobfuscation,allowshrinking class io.reactivex.Single

imagekit/src/main/java/com/imagekit/android/retrofit/ApiInterface.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.imagekit.android.retrofit
22

3-
import com.imagekit.android.entity.SignatureResponse
43
import io.reactivex.Single
54
import okhttp3.MultipartBody
65
import okhttp3.ResponseBody
@@ -28,9 +27,4 @@ interface ApiInterface {
2827
@Part customMetadata: MultipartBody.Part?,
2928
): Single<ResponseBody>
3029

31-
@GET
32-
fun getSignature(
33-
@Url url: String,
34-
@Query("expire") expire: String
35-
): Single<SignatureResponse>
3630
}

imagekit/src/main/java/com/imagekit/android/retrofit/NetworkManager.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.content.pm.ApplicationInfo
44
import android.util.Log
55
import com.google.gson.Gson
66
import com.imagekit.android.ImageKit
7-
import com.imagekit.android.entity.SignatureResponse
87
import io.reactivex.Single
98
import io.reactivex.android.schedulers.AndroidSchedulers
109
import io.reactivex.schedulers.Schedulers
@@ -57,16 +56,6 @@ internal object NetworkManager {
5756
return apiInterface!!
5857
}
5958

60-
fun getSignature(
61-
endPoint: String,
62-
expire: String
63-
): Single<SignatureResponse> {
64-
return getApiInterface()
65-
.getSignature(endPoint, expire)
66-
.subscribeOn(Schedulers.io())
67-
.observeOn(AndroidSchedulers.mainThread())
68-
}
69-
7059
fun getFileUploadCall(
7160
token: String,
7261
file: Any,

0 commit comments

Comments
 (0)