Skip to content

Commit d4c5842

Browse files
authored
Merge pull request #99 from Dhaval2404/feature/v1.7.3
v1.7.3 Release
2 parents 1febc4c + 1bb352d commit d4c5842

File tree

9 files changed

+40
-12
lines changed

9 files changed

+40
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.7.3] - 2020-07-18
10+
### Changed
11+
* Fixed PNG image saved as JPG after crop issue [#94](https://github.com/Dhaval2404/ImagePicker/issues/94)
12+
913
## [1.7.2] - 2020-07-14
1014
### Changed
1115
* Fixed .crop() opening gallery or camera twice [#32](https://github.com/Dhaval2404/ImagePicker/issues/32)
@@ -66,9 +70,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6670
* Crop Image(Its based on [uCrop](https://github.com/Yalantis/uCrop))
6771
* Compress Image(Compress image based on resolution and size)
6872
* Handle Runtime Permission for Camera and Storage
69-
* Retrive Image Result as File, File Path as String or Uri object
73+
* Retrieve Image Result as File, File Path as String or Uri object
7074

7175
[Unreleased]: https://github.com/Dhaval2404/ImagePicker/compare/v2.0...HEAD
76+
[1.7.3]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.2...v1.7.3
7277
[1.7.2]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.1...v1.7.2
7378
[1.7.1]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7...v1.7.1
7479
[1.7]: https://github.com/Dhaval2404/ImagePicker/compare/v1.6...v1.7

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w
5454
```
5555

5656
```groovy
57-
implementation 'com.github.dhaval2404:imagepicker:1.7.2'
57+
implementation 'com.github.dhaval2404:imagepicker:1.7.3'
5858
```
5959

6060
**If you are yet to Migrate on AndroidX, Use support build artifact:**
@@ -270,9 +270,12 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w
270270
271271
* Added option to limit MIME types while choosing a gallery image (Special Thanks to [Marchuck](https://github.com/Marchuck))
272272
* Introduced ImageProviderInterceptor, Can be used for analytics (Special Thanks to [Marchuck](https://github.com/Marchuck))
273+
* Fixed .crop() opening gallery or camera twice [#32](https://github.com/Dhaval2404/ImagePicker/issues/32)
273274
* Fixed FileProvider of the library clashes with the FileProvider of the app [#51](https://github.com/Dhaval2404/ImagePicker/issues/51) (Special Thanks to [OyaCanli](https://github.com/OyaCanli))
274275
* Added option to set Storage Directory [#52](https://github.com/Dhaval2404/ImagePicker/issues/52)
275276
* Fixed NullPointerException in FileUriUtils.getPathFromRemoteUri() [#61](https://github.com/Dhaval2404/ImagePicker/issues/61) (Special Thanks to [himphen](https://github.com/himphen))
277+
* Fixed UCropActivity Crash Android 4.4 (KiKat) [#82](https://github.com/Dhaval2404/ImagePicker/issues/82)
278+
* Fixed PNG image saved as JPG after crop issue [#94](https://github.com/Dhaval2404/ImagePicker/issues/94)
276279
277280
### Version: 1.6
278281

imagepicker/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
defaultConfig {
1414
minSdkVersion 19
1515
targetSdkVersion 28
16-
versionCode 10
17-
versionName "1.7.2"
16+
versionCode 11
17+
versionName "1.7.3"
1818

1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2020
}
@@ -72,7 +72,7 @@ ext {
7272
siteUrl = 'https://github.com/Dhaval2404/ImagePicker/'
7373
gitUrl = 'https://github.com/Dhaval2404/ImagePicker.git'
7474

75-
libraryVersion = '1.7.2'
75+
libraryVersion = '1.7.3'
7676
//If you are uploading new library try : gradlew install
7777
//If you are updating existing library then execute: gradlew bintrayUpload
7878
//In both the case don't forgot to put bintray credentials in local.properties file.

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/ImagePickerFileProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.dhaval2404.imagepicker;
1+
package com.github.dhaval2404.imagepicker
22

33
import androidx.core.content.FileProvider
44

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CropProvider.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.util.Log
99
import com.github.dhaval2404.imagepicker.ImagePicker
1010
import com.github.dhaval2404.imagepicker.ImagePickerActivity
1111
import com.github.dhaval2404.imagepicker.R
12+
import com.github.dhaval2404.imagepicker.util.FileUriUtils
1213
import com.github.dhaval2404.imagepicker.util.FileUtil
1314
import com.yalantis.ucrop.UCrop
1415
import java.io.File
@@ -103,7 +104,9 @@ class CropProvider(activity: ImagePickerActivity) : BaseProvider(activity) {
103104
*/
104105
@Throws(IOException::class)
105106
private fun cropImage(file: File) {
106-
mCropImageFile = FileUtil.getImageFile(dir = mFileDir)
107+
val uri = Uri.fromFile(file)
108+
val extension = FileUriUtils.getImageExtension(uri)
109+
mCropImageFile = FileUtil.getImageFile(dir = mFileDir, extension = extension)
107110

108111
if (mCropImageFile == null || !mCropImageFile!!.exists()) {
109112
Log.e(TAG, "Failed to create crop image file")
@@ -112,7 +115,8 @@ class CropProvider(activity: ImagePickerActivity) : BaseProvider(activity) {
112115
}
113116

114117
val options = UCrop.Options()
115-
val uCrop = UCrop.of(Uri.fromFile(file), Uri.fromFile(mCropImageFile))
118+
options.setCompressionFormat(FileUtil.getCompressFormat(extension))
119+
val uCrop = UCrop.of(uri, Uri.fromFile(mCropImageFile))
116120
.withOptions(options)
117121

118122
if (mCropAspectX > 0 && mCropAspectY > 0) {

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/GalleryProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class GalleryProvider(activity: ImagePickerActivity) :
3434
private const val PERMISSION_INTENT_REQ_CODE = 4262
3535
}
3636

37-
//Mime types restrictions for gallery. By default all mime types are valid
37+
// Mime types restrictions for gallery. By default all mime types are valid
3838
private val mimeTypes: Array<String>
3939

4040
init {

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/util/FileUriUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ object FileUriUtils {
182182

183183
/** @return extension of image with dot, or default .jpg if it none.
184184
*/
185-
private fun getImageExtension(uriImage: Uri): String {
185+
fun getImageExtension(uriImage: Uri): String {
186186
var extension: String? = null
187187

188188
try {

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/util/FileUtil.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.dhaval2404.imagepicker.util
22

3+
import android.graphics.Bitmap
34
import android.os.Environment
45
import android.os.StatFs
56
import java.io.File
@@ -83,4 +84,19 @@ object FileUtil {
8384
val blockSize = stat.blockSizeLong
8485
return availBlocks * blockSize
8586
}
87+
88+
/**
89+
* Get Bitmap Compress Format
90+
*
91+
* @param extension Image File Extension
92+
* @return Bitmap CompressFormat
93+
*/
94+
fun getCompressFormat(extension: String): Bitmap.CompressFormat {
95+
return when {
96+
extension.contains("png", ignoreCase = true) -> Bitmap.CompressFormat.PNG
97+
extension.contains("webp", ignoreCase = true) -> Bitmap.CompressFormat.WEBP
98+
else -> Bitmap.CompressFormat.JPEG
99+
}
100+
}
101+
86102
}

sample/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "com.github.dhaval2404.imagepicker.sample"
1313
minSdkVersion 19
1414
targetSdkVersion 28
15-
versionCode 10
16-
versionName "1.7.2"
15+
versionCode 11
16+
versionName "1.7.3"
1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
vectorDrawables.useSupportLibrary = true
1919
}

0 commit comments

Comments
 (0)