Skip to content

Commit 3871eb5

Browse files
authored
Merge pull request #98 from ismoy/develop
refactor: Enhance gallery selection, add MIME type validation, and re…
2 parents 40990fd + 95704e8 commit 3871eb5

79 files changed

Lines changed: 927 additions & 653 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ npm install imagepickerkmp
6262
```kotlin
6363
var showCamera by remember { mutableStateOf(false) }
6464
var capturedPhoto by remember { mutableStateOf<PhotoResult?>(null) }
65+
var mimeTypeMismatchMessage by remember { mutableStateOf<String?>(null) }
66+
6567

6668
if (showCamera) {
6769
ImagePickerLauncher(
@@ -70,7 +72,9 @@ if (showCamera) {
7072
capturedPhoto = result
7173
showCamera = false
7274
},
73-
onError = { showCamera = false },
75+
onError = {
76+
showCamera = false
77+
},
7478
onDismiss = { showCamera = false }
7579
)
7680
)
@@ -101,9 +105,13 @@ if (showGallery) {
101105
println("Location: ${exifData?.location}")
102106
}
103107
},
104-
onError = { showGallery = false },
108+
onError = { it->
109+
showGallery = false
110+
mimeTypeMismatchMessage = it.message
111+
},
105112
onDismiss = { showGallery = false },
106-
allowMultiple = true
113+
allowMultiple = true,
114+
mimeTypeMismatchMessage = "Only allows PNG images"
107115
)
108116
}
109117

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ plugins {
77
id("jacoco")
88
}
99

10-
version = "1.0.32"
10+
version = "1.0.33"

detekt.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ style:
1818
MaxLineLength:
1919
active: true
2020
maxLineLength: 120
21+
excludeCommentStatements: true
2122
TrailingWhitespace:
2223
active: false
2324
UnusedImports:
@@ -88,8 +89,7 @@ comments:
8889
CommentOverPrivateFunction:
8990
active: true
9091
EndOfSentenceFormat:
91-
active: true
92-
endOfSentenceFormat: '[.?!]([ \t\n\r]+|$)'
92+
active: false
9393
UndocumentedPublicClass:
9494
active: true
9595
UndocumentedPublicFunction:

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/camera/CameraController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import kotlinx.coroutines.withContext
2323
import java.io.File
2424

2525

26-
class CameraController(
26+
internal class CameraController(
2727
private val context: Context,
2828
private val lifecycleOwner: LifecycleOwner,
2929
private val fileManager: FileManager

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/camera/CameraXManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import io.github.ismoy.imagepickerkmp.domain.models.PhotoResult
88
/**
99
* High-level manager for camera operations, providing an interface to start, stop, and control the camera.
1010
*/
11-
class CameraXManager(
11+
internal class CameraXManager(
1212
private val cameraController: CameraController,
1313
private val imageProcessor: io.github.ismoy.imagepickerkmp.data.processors.ImageProcessor
1414
) {

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/managers/FileManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.util.Locale
1313
*
1414
* Provides methods to create image files and convert files to URI strings.
1515
*/
16-
class FileManager(private val context: Context) {
16+
internal class FileManager(private val context: Context) {
1717

1818
fun createImageFile(): File {
1919
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/processors/ImageOrientationCorrector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import java.io.FileOutputStream
2424
* SOLID: Single Responsibility - Only handles orientation correction
2525
* SOLID: Open/Closed - Can be extended for different correction algorithms
2626
*/
27-
class ImageOrientationCorrector {
27+
internal class ImageOrientationCorrector {
2828

2929
@SuppressLint("ExifInterface")
3030
fun correctImageOrientation(imageFile: File, cameraType: CameraType): File {

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/processors/ImageProcessor.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@ import java.io.File
1919
import java.io.FileOutputStream
2020
import androidx.core.graphics.scale
2121

22-
/**
23-
* Handles image processing operations such as orientation correction and photo result creation.
24-
*
25-
* SOLID: Single Responsibility - Only handles image processing operations
26-
* SOLID: Dependency Inversion - Dependencies injected via constructor
27-
*/
28-
class ImageProcessor(
22+
23+
internal class ImageProcessor(
2924
private val context: Context,
3025
private val fileManager: io.github.ismoy.imagepickerkmp.data.managers.FileManager,
3126
private val orientationCorrector: ImageOrientationCorrector

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/processors/ProcessImageWithCompression.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.graphics.Bitmap
44
import androidx.core.graphics.scale
55
import io.github.ismoy.imagepickerkmp.domain.models.CompressionLevel
66

7-
fun processImageWithCompression(
7+
internal fun processImageWithCompression(
88
bitmap: Bitmap,
99
compressionLevel: CompressionLevel
1010
): Bitmap {

library/src/androidMain/kotlin/io/github/ismoy/imagepickerkmp/data/processors/SaveCompressedImage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import io.github.ismoy.imagepickerkmp.domain.models.CompressionLevel
55
import java.io.File
66
import java.io.FileOutputStream
77

8-
fun saveCompressedImage(
8+
internal fun saveCompressedImage(
99
bitmap: Bitmap,
1010
originalFile: File,
1111
compressionLevel: CompressionLevel

0 commit comments

Comments
 (0)