Skip to content

Commit d4939eb

Browse files
authored
Merge pull request #49 from Dhaval2404/feature/v1.6
v1.6 Release
2 parents f5c60a3 + 4f08aef commit d4939eb

File tree

56 files changed

+778
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+778
-286
lines changed

CHANGELOG.md

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

77
## [Unreleased]
88

9+
## [1.6] - 2020-01-06
10+
### Changed
11+
* Improved UI/UX of sample app
12+
* Removed Bitmap Deprecated Property [#33](https://github.com/Dhaval2404/ImagePicker/issues/33) (Special Thanks to [nauhalf](https://github.com/nauhalf))
13+
* Camera opens twice when "Don't keep activities" option is ON [#41](https://github.com/Dhaval2404/ImagePicker/issues/41) (Special Thanks to [benji101](https://github.com/benji101))
14+
* Fixed uCrop Crash Issue [#42](https://github.com/Dhaval2404/ImagePicker/issues/42)
15+
916
## [1.5] - 2019-10-14
1017
### Added
1118
* Added Option for Dynamic Crop Ratio. Let User choose aspect ratio [#36](https://github.com/Dhaval2404/ImagePicker/issues/36) (Special Thanks to [Dor-Sloim](https://github.com/Dor-Sloim))

README.md

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

4949
```groovy
50-
implementation 'com.github.dhaval2404:imagepicker:1.5'
50+
implementation 'com.github.dhaval2404:imagepicker:1.6'
5151
```
5252

5353
**If you are yet to Migrate on AndroidX, Use support build artifact:**
@@ -225,6 +225,13 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w
225225
226226
# ✔️Changelog
227227
228+
### Version: 1.6
229+
230+
* Improved UI/UX of sample app
231+
* Removed Bitmap Deprecated Property [#33](https://github.com/Dhaval2404/ImagePicker/issues/33) (Special Thanks to [nauhalf](https://github.com/nauhalf))
232+
* Camera opens twice when "Don't keep activities" option is ON [#41](https://github.com/Dhaval2404/ImagePicker/issues/41) (Special Thanks to [benji101](https://github.com/benji101))
233+
* Fixed uCrop Crash Issue [#42](https://github.com/Dhaval2404/ImagePicker/issues/42)
234+
228235
### Version: 1.5
229236
230237
* Fixed app crash issue, due to Camera Permission in manifest [#34](https://github.com/Dhaval2404/ImagePicker/issues/34)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
maven { url "https://jitpack.io" }
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.5.1'
11+
classpath 'com.android.tools.build:gradle:3.5.3'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1313

1414
//jcenter plugins

imagepicker/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
defaultConfig {
1414
minSdkVersion 19
1515
targetSdkVersion 28
16-
versionCode 6
17-
versionName "1.5"
16+
versionCode 7
17+
versionName "1.6"
1818

1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2020
}
@@ -43,10 +43,10 @@ dependencies {
4343

4444
implementation 'androidx.core:core-ktx:1.1.0'
4545
implementation 'androidx.appcompat:appcompat:1.1.0'
46-
implementation "androidx.exifinterface:exifinterface:1.0.0"
46+
implementation "androidx.exifinterface:exifinterface:1.1.0"
4747

4848
//More Info: https://github.com/Yalantis/uCrop
49-
implementation 'com.github.yalantis:ucrop:2.2.2'
49+
implementation 'com.github.yalantis:ucrop:2.2.4'
5050

5151
//More Info: https://github.com/florent37/InlineActivityResult
5252
compileOnly 'com.github.florent37:inline-activity-result-kotlin:1.0.1'
@@ -69,7 +69,7 @@ ext {
6969
siteUrl = 'https://github.com/Dhaval2404/ImagePicker/'
7070
gitUrl = 'https://github.com/Dhaval2404/ImagePicker.git'
7171

72-
libraryVersion = '1.5'
72+
libraryVersion = '1.6'
7373
//If you are uploading new library try : gradlew install
7474
//If you are updating existing library then execute: gradlew bintrayUpload
7575
//In both the case don't forgot to put bintray credentials in local.properties file.

imagepicker/src/androidTest/java/com/github/dhaval2404/imagepicker/ExampleInstrumentedTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ class ExampleInstrumentedTest {
1717

1818
assertEquals("com.github.dhaval2404.imagepicker.test", appContext.packageName)
1919
}
20-
}
20+
}

imagepicker/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
55
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
6-
<uses-permission android:name="android.permission.CAMERA" />
76

87
<application>
98

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

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import android.content.Intent
66
import android.net.Uri
77
import android.os.Bundle
88
import android.util.Log
9-
import androidx.fragment.app.FragmentActivity
9+
import androidx.appcompat.app.AppCompatActivity
1010
import com.github.dhaval2404.imagepicker.constant.ImageProvider
1111
import com.github.dhaval2404.imagepicker.provider.CameraProvider
1212
import com.github.dhaval2404.imagepicker.provider.CompressionProvider
@@ -21,11 +21,16 @@ import java.io.File
2121
* @version 1.0
2222
* @since 04 January 2019
2323
*/
24-
class ImagePickerActivity : FragmentActivity() {
24+
class ImagePickerActivity : AppCompatActivity() {
2525

2626
companion object {
2727
private const val TAG = "image_picker"
2828

29+
/**
30+
* Key to Save/Retrieve Image File state
31+
*/
32+
private const val STATE_IMAGE_FILE = "state.image_file"
33+
2934
internal fun getCancelledIntent(context: Context): Intent {
3035
val intent = Intent()
3136
val message = context.getString(R.string.error_task_cancelled)
@@ -39,37 +44,68 @@ class ImagePickerActivity : FragmentActivity() {
3944
private lateinit var mCropProvider: CropProvider
4045
private lateinit var mCompressionProvider: CompressionProvider
4146

42-
private var mOriginalFile: File? = null
47+
/** File provided by GalleryProvider or CameraProvider */
48+
private var mImageFile: File? = null
49+
50+
/** File provided by CropProvider */
4351
private var mCropFile: File? = null
4452

4553
override fun onCreate(savedInstanceState: Bundle?) {
4654
super.onCreate(savedInstanceState)
47-
loadBundle()
55+
restoreInstanceState(savedInstanceState)
56+
loadBundle(savedInstanceState)
57+
}
58+
59+
/**
60+
* Restore saved state
61+
*/
62+
private fun restoreInstanceState(savedInstanceState: Bundle?) {
63+
if (savedInstanceState != null) {
64+
mImageFile = savedInstanceState.getSerializable(STATE_IMAGE_FILE) as File?
65+
}
66+
}
67+
68+
/**
69+
* Save all appropriate activity state.
70+
*/
71+
public override fun onSaveInstanceState(outState: Bundle) {
72+
outState.putSerializable(STATE_IMAGE_FILE, mImageFile)
73+
mCameraProvider?.onSaveInstanceState(outState)
74+
mCropProvider.onSaveInstanceState(outState)
75+
super.onSaveInstanceState(outState)
4876
}
4977

5078
/**
5179
* Parse Intent Bundle and initialize variables
5280
*/
53-
private fun loadBundle() {
81+
private fun loadBundle(savedInstanceState: Bundle?) {
82+
// Create Crop Provider
5483
mCropProvider = CropProvider(this)
84+
mCropProvider.onRestoreInstanceState(savedInstanceState)
85+
86+
// Create Compression Provider
5587
mCompressionProvider = CompressionProvider(this)
5688

57-
val bundle = intent?.extras
58-
val provider = bundle?.getSerializable(ImagePicker.EXTRA_IMAGE_PROVIDER) as ImageProvider?
89+
// Retrieve Image Provider
90+
val provider: ImageProvider? =
91+
intent?.getSerializableExtra(ImagePicker.EXTRA_IMAGE_PROVIDER) as ImageProvider?
5992

60-
// Create provider object and start process
93+
// Create Gallery/Camera Provider
6194
when (provider) {
6295
ImageProvider.GALLERY -> {
6396
mGalleryProvider = GalleryProvider(this)
64-
mGalleryProvider?.startIntent()
97+
// Pick Gallery Image
98+
savedInstanceState ?: mGalleryProvider?.startIntent()
6599
}
66100
ImageProvider.CAMERA -> {
67101
mCameraProvider = CameraProvider(this)
68-
mCameraProvider?.startIntent()
102+
mCameraProvider?.onRestoreInstanceState(savedInstanceState)
103+
// Pick Camera Image
104+
savedInstanceState ?: mCameraProvider?.startIntent()
69105
}
70106
else -> {
71-
Log.e(TAG, "Image provider can not be null")
72107
// Something went Wrong! This case should never happen
108+
Log.e(TAG, "Image provider can not be null")
73109
setError(getString(R.string.error_task_cancelled))
74110
}
75111
}
@@ -111,7 +147,7 @@ class ImagePickerActivity : FragmentActivity() {
111147
* @param file Capture/Gallery image file
112148
*/
113149
fun setImage(file: File) {
114-
mOriginalFile = file
150+
mImageFile = file
115151
when {
116152
mCropProvider.isCropEnabled() -> mCropProvider.startIntent(file)
117153
mCompressionProvider.isCompressionRequired(file) -> mCompressionProvider.compress(file)
@@ -132,8 +168,8 @@ class ImagePickerActivity : FragmentActivity() {
132168
mCameraProvider?.let {
133169
// Delete Camera file after crop. Else there will be two image for the same action.
134170
// In case of Gallery Provider, we will get original image path, so we will not delete that.
135-
mOriginalFile?.delete()
136-
mOriginalFile = null
171+
mImageFile?.delete()
172+
mImageFile = null
137173
}
138174

139175
if (mCompressionProvider.isCompressionRequired(file)) {
@@ -153,7 +189,7 @@ class ImagePickerActivity : FragmentActivity() {
153189
mCameraProvider?.let {
154190
// Delete Camera file after Compress. Else there will be two image for the same action.
155191
// In case of Gallery Provider, we will get original image path, so we will not delete that.
156-
mOriginalFile?.delete()
192+
mImageFile?.delete()
157193
}
158194

159195
// If crop file is not null, Delete it after crop
@@ -195,4 +231,4 @@ class ImagePickerActivity : FragmentActivity() {
195231
setResult(ImagePicker.RESULT_ERROR, intent)
196232
finish()
197233
}
198-
}
234+
}

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/constant/ImageProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ enum class ImageProvider {
1111
GALLERY,
1212
CAMERA,
1313
BOTH
14-
}
14+
}

imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/listener/ResultListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ package com.github.dhaval2404.imagepicker.listener
1111
internal interface ResultListener<T> {
1212

1313
fun onResult(t: T?)
14-
}
14+
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.dhaval2404.imagepicker.provider
22

33
import android.content.ContextWrapper
4+
import android.os.Bundle
45
import android.widget.Toast
56
import com.github.dhaval2404.imagepicker.ImagePickerActivity
67

@@ -55,4 +56,19 @@ abstract class BaseProvider(protected val activity: ImagePickerActivity) : Conte
5556
*/
5657
protected open fun onFailure() {
5758
}
58-
}
59+
60+
/**
61+
* Save all appropriate provider state.
62+
*/
63+
open fun onSaveInstanceState(outState: Bundle) {
64+
}
65+
66+
/**
67+
* Restores the saved state for all Providers.
68+
*
69+
* @param savedInstanceState the Bundle returned by {@link #onSaveInstanceState()}
70+
* @see #onSaveInstanceState()
71+
*/
72+
open fun onRestoreInstanceState(savedInstanceState: Bundle?) {
73+
}
74+
}

0 commit comments

Comments
 (0)