Skip to content

Commit 528bb00

Browse files
authored
Merge pull request #142 from Dhaval2404/feature/v1.8
v1.8 Released
2 parents 5721153 + 63efbe4 commit 528bb00

File tree

28 files changed

+397
-120
lines changed

28 files changed

+397
-120
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [1.8] - 2020-12-22
10+
### Added
11+
* Added dialog dismiss listener (Special Thanks to [kibotu](https://github.com/kibotu))
12+
* Added text localization (Special Thanks to [yamin8000](https://github.com/yamin8000) and Jose Bravo)
13+
### Changed
14+
* Fixed crash issue on missing camera app [#69](https://github.com/Dhaval2404/ImagePicker/issues/69)
15+
* Fixed issue selecting images from download folder [#86](https://github.com/Dhaval2404/ImagePicker/issues/86)
16+
* Fixed exif information lost issue [#121](https://github.com/Dhaval2404/ImagePicker/issues/121)
17+
* Fixed crash issue on large image crop [#122](https://github.com/Dhaval2404/ImagePicker/issues/122)
18+
* Fixed saving image in cache issue [#127](https://github.com/Dhaval2404/ImagePicker/issues/127)
19+
820
## [1.7.5] - 2020-08-30
921
### Changed
1022
* Added Polish text translation [#115](https://github.com/Dhaval2404/ImagePicker/issues/115) (Special Thanks to [MarcelKijanka](https://github.com/MarcelKijanka))
@@ -81,6 +93,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8193
* Retrieve Image Result as File, File Path as String or Uri object
8294

8395
[Unreleased]: https://github.com/Dhaval2404/ImagePicker/compare/v2.0...HEAD
96+
[1.8]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.5...v1.8
8497
[1.7.5]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.4...v1.7.5
8598
[1.7.4]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.3...v1.7.4
8699
[1.7.3]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.2...v1.7.3

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w
2929
* Capture Camera Image
3030
* Crop Image(Crop image based on provided aspect ratio or let user choose one)
3131
* Compress Image(Compress image based on provided resolution and size)
32-
* Retrive Image Result as File, File Path as String or Uri object
32+
* Retrieve Image Result as File, File Path as String or Uri object
3333
* Handle Runtime Permission for Camera and Storage
3434

3535
# 🎬Preview
@@ -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.5'
57+
implementation 'com.github.dhaval2404:imagepicker:1.8'
5858
```
5959

6060
**If you are yet to Migrate on AndroidX, Use support build artifact:**
@@ -214,6 +214,16 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w
214214
}
215215
.start()
216216
```
217+
* Intercept Dialog dismiss event
218+
219+
```kotlin
220+
ImagePicker.with(this)
221+
.setDismissListener {
222+
// Handle dismiss event
223+
Log.d("ImagePicker", "onDismiss");
224+
}
225+
.start()
226+
```
217227
218228
* Specify Directory to store captured, cropped or compressed images
219229
@@ -266,6 +276,16 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w
266276
267277
# ✔️Changelog
268278
279+
### Version: 1.8
280+
281+
* Added dialog dismiss listener (Special Thanks to [kibotu](https://github.com/kibotu))
282+
* Added text localization (Special Thanks to [yamin8000](https://github.com/yamin8000) and Jose Bravo)
283+
* Fixed crash issue on missing camera app [#69](https://github.com/Dhaval2404/ImagePicker/issues/69)
284+
* Fixed issue selecting images from download folder [#86](https://github.com/Dhaval2404/ImagePicker/issues/86)
285+
* Fixed exif information lost issue [#121](https://github.com/Dhaval2404/ImagePicker/issues/121)
286+
* Fixed crash issue on large image crop [#122](https://github.com/Dhaval2404/ImagePicker/issues/122)
287+
* Fixed saving image in cache issue [#127](https://github.com/Dhaval2404/ImagePicker/issues/127)
288+
269289
### Version: 1.7
270290
271291
* Added option to limit MIME types while choosing a gallery image (Special Thanks to [Marchuck](https://github.com/Marchuck))
@@ -327,7 +347,7 @@ We'll be really happy if you sent us links to your projects where you use our co
327347
328348
## License
329349
330-
Copyright 2019, The Android Open Source Project
350+
Copyright 2019-2020, Dhaval Patel
331351
332352
Licensed under the Apache License, Version 2.0 (the "License");
333353
you may not use this file except in compliance with the License.

imagepicker/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
defaultConfig {
1414
minSdkVersion 19
1515
targetSdkVersion 28
16-
versionCode 13
17-
versionName "1.7.5"
16+
versionCode 14
17+
versionName "1.8"
1818

1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2020
}
@@ -49,7 +49,7 @@ dependencies {
4949
implementation "androidx.exifinterface:exifinterface:1.1.0"
5050

5151
//More Info: https://github.com/Yalantis/uCrop
52-
implementation 'com.github.yalantis:ucrop:2.2.5'
52+
implementation 'com.github.yalantis:ucrop:2.2.6'
5353

5454
//More Info: https://github.com/florent37/InlineActivityResult
5555
compileOnly 'com.github.florent37:inline-activity-result-kotlin:1.0.4'
@@ -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.5'
75+
libraryVersion = '1.8'
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/ImagePicker.kt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.widget.Toast
77
import androidx.appcompat.app.AppCompatActivity
88
import androidx.fragment.app.Fragment
99
import com.github.dhaval2404.imagepicker.constant.ImageProvider
10+
import com.github.dhaval2404.imagepicker.listener.DismissListener
1011
import com.github.dhaval2404.imagepicker.listener.ResultListener
1112
import com.github.dhaval2404.imagepicker.util.DialogHelper
1213
import com.github.florent37.inlineactivityresult.kotlin.startForResult
@@ -27,6 +28,8 @@ open class ImagePicker {
2728
const val RESULT_ERROR = 64
2829

2930
internal const val EXTRA_IMAGE_PROVIDER = "extra.image_provider"
31+
internal const val EXTRA_CAMERA_DEVICE = "extra.camera_device"
32+
3033
internal const val EXTRA_IMAGE_MAX_SIZE = "extra.image_max_size"
3134
internal const val EXTRA_CROP = "extra.crop"
3235
internal const val EXTRA_CROP_X = "extra.crop_x"
@@ -118,6 +121,11 @@ open class ImagePicker {
118121

119122
private var imageProviderInterceptor: ((ImageProvider) -> Unit)? = null
120123

124+
/**
125+
* Dialog dismiss event listener
126+
*/
127+
private var dismissListener: DismissListener? = null
128+
121129
/**
122130
* File Directory
123131
*
@@ -249,6 +257,26 @@ open class ImagePicker {
249257
return this
250258
}
251259

260+
/**
261+
* Sets the callback that will be called when the dialog is dismissed for any reason.
262+
*/
263+
fun setDismissListener(listener: DismissListener): Builder {
264+
this.dismissListener = listener
265+
return this
266+
}
267+
268+
/**
269+
* Sets the callback that will be called when the dialog is dismissed for any reason.
270+
*/
271+
fun setDismissListener(listener: (() -> Unit)): Builder {
272+
this.dismissListener = object : DismissListener {
273+
override fun onDismiss() {
274+
listener.invoke()
275+
}
276+
}
277+
return this
278+
}
279+
252280
/**
253281
* Start Image Picker Activity
254282
*/
@@ -292,7 +320,7 @@ open class ImagePicker {
292320
startActivity(reqCode)
293321
}
294322
}
295-
})
323+
}, dismissListener)
296324
}
297325

298326
/**
@@ -310,7 +338,7 @@ open class ImagePicker {
310338
completionHandler?.invoke(Activity.RESULT_CANCELED, intent)
311339
}
312340
}
313-
})
341+
}, dismissListener)
314342
}
315343

316344
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.github.dhaval2404.imagepicker.listener
2+
3+
/**
4+
* Interface used to allow the creator of a dialog to run some code when the
5+
* dialog is dismissed.
6+
*
7+
* @author Dhaval Patel
8+
* @version 1.8
9+
* @since 19 December 2020
10+
*/
11+
interface DismissListener {
12+
13+
/**
14+
* This method will be invoked when the dialog is dismissed.
15+
*/
16+
fun onDismiss()
17+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CameraProvider(activity: ImagePickerActivity) : BaseProvider(activity) {
6666
private var mFileDir: File? = null
6767

6868
init {
69-
val bundle = activity.intent.extras!!
69+
val bundle = activity.intent.extras ?: Bundle()
7070

7171
// Get File Directory
7272
val fileDir = bundle.getString(ImagePicker.EXTRA_SAVE_DIRECTORY)
@@ -102,6 +102,11 @@ class CameraProvider(activity: ImagePickerActivity) : BaseProvider(activity) {
102102
* Start Camera Capture Intent
103103
*/
104104
fun startIntent() {
105+
if (!IntentUtils.isCameraAppAvailable(this)) {
106+
setError(R.string.error_camera_app_not_found)
107+
return
108+
}
109+
105110
checkPermission()
106111
}
107112

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import android.annotation.SuppressLint
44
import android.graphics.Bitmap
55
import android.graphics.BitmapFactory
66
import android.os.AsyncTask
7+
import android.os.Bundle
78
import com.github.dhaval2404.imagepicker.ImagePicker
89
import com.github.dhaval2404.imagepicker.ImagePickerActivity
10+
import com.github.dhaval2404.imagepicker.util.ExifDataCopier
911
import com.github.dhaval2404.imagepicker.util.FileUriUtils
1012
import com.github.dhaval2404.imagepicker.util.FileUtil
1113
import com.github.dhaval2404.imagepicker.util.ImageUtil
@@ -32,7 +34,7 @@ class CompressionProvider(activity: ImagePickerActivity) : BaseProvider(activity
3234
private var mFileDir: File? = null
3335

3436
init {
35-
val bundle = activity.intent.extras!!
37+
val bundle = activity.intent.extras ?: Bundle()
3638

3739
// Get Max Width/Height parameter from Intent
3840
mMaxWidth = bundle.getInt(ImagePicker.EXTRA_MAX_WIDTH, 0)
@@ -143,6 +145,9 @@ class CompressionProvider(activity: ImagePickerActivity) : BaseProvider(activity
143145
}
144146
} while (isCompressionRequired(newFile!!))
145147

148+
// Copy Exif Data
149+
ExifDataCopier.copyExif(file, newFile)
150+
146151
return newFile
147152
}
148153

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CropProvider(activity: ImagePickerActivity) : BaseProvider(activity) {
4343
private var mFileDir: File? = null
4444

4545
init {
46-
val bundle = activity.intent.extras!!
46+
val bundle = activity.intent.extras ?: Bundle()
4747

4848
// Get Max Width/Height parameter from Intent
4949
mMaxWidth = bundle.getInt(ImagePicker.EXTRA_MAX_WIDTH, 0)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.github.dhaval2404.imagepicker.provider
33
import android.Manifest
44
import android.app.Activity
55
import android.content.Intent
6+
import android.os.Bundle
67
import androidx.core.app.ActivityCompat.requestPermissions
78
import com.github.dhaval2404.imagepicker.ImagePicker
89
import com.github.dhaval2404.imagepicker.ImagePickerActivity
@@ -38,7 +39,7 @@ class GalleryProvider(activity: ImagePickerActivity) :
3839
private val mimeTypes: Array<String>
3940

4041
init {
41-
val bundle = activity.intent.extras!!
42+
val bundle = activity.intent.extras ?: Bundle()
4243

4344
mimeTypes = bundle.getStringArray(ImagePicker.EXTRA_MIME_TYPES) ?: emptyArray()
4445
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.view.LayoutInflater
55
import androidx.appcompat.app.AlertDialog
66
import com.github.dhaval2404.imagepicker.R
77
import com.github.dhaval2404.imagepicker.constant.ImageProvider
8+
import com.github.dhaval2404.imagepicker.listener.DismissListener
89
import com.github.dhaval2404.imagepicker.listener.ResultListener
910
import kotlinx.android.synthetic.main.dialog_choose_app.view.*
1011

@@ -21,7 +22,11 @@ internal object DialogHelper {
2122
* Show Image Provide Picker Dialog. This will streamline the code to pick/capture image
2223
*
2324
*/
24-
fun showChooseAppDialog(context: Context, listener: ResultListener<ImageProvider>) {
25+
fun showChooseAppDialog(
26+
context: Context,
27+
listener: ResultListener<ImageProvider>,
28+
dismissListener: DismissListener?
29+
) {
2530
val layoutInflater = LayoutInflater.from(context)
2631
val customView = layoutInflater.inflate(R.layout.dialog_choose_app, null)
2732

@@ -34,6 +39,9 @@ internal object DialogHelper {
3439
.setNegativeButton(R.string.action_cancel) { _, _ ->
3540
listener.onResult(null)
3641
}
42+
.setOnDismissListener {
43+
dismissListener?.onDismiss()
44+
}
3745
.show()
3846

3947
// Handle Camera option click

0 commit comments

Comments
 (0)