Skip to content

Commit

Permalink
Merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjith-zuper committed Sep 15, 2023
2 parents 8466f9b + 13e3bea commit 51d7a51
Show file tree
Hide file tree
Showing 41 changed files with 457 additions and 272 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: set up JDK 1.8
uses: actions/setup-java@v1
- name: set up JDK 11
uses: actions/setup-java@v2.4.0
with:
java-version: 1.8
distribution: adopt-openj9
java-version: '11'

- name: Cache Gradle
uses: actions/cache@v2
Expand All @@ -28,7 +29,7 @@ jobs:
gradle-
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build -x lint

- name: Build test
run: ./gradlew sample:assembleAndroidTest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Github
.fork/

# Idea
**/*.iml
.idea/
Expand Down
76 changes: 40 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ And add this to your module's `build.gradle`

```groovy
dependencies {
implementation 'com.github.esafirm:android-image-picker:x.y.z'
implementation 'com.github.esafirm:android-image-picker:x.y.z'
}
```

Expand All @@ -49,15 +49,16 @@ change `x.y.z` to version in the [release page](https://github.com/esafirm/andro

For full example, please refer to the `sample` app.

Also you can browse the issue labeled as question [here](https://github.com/esafirm/android-image-picker/issues?utf8=%E2%9C%93&q=label%3Aquestion+)
Also you can browse the issue labeled as
question [here](https://github.com/esafirm/android-image-picker/issues?utf8=%E2%9C%93&q=label%3Aquestion+)

## Start image picker activity

The simplest way to start

```kotlin
val launcher = registerImagePicker {
// handle result here
// handle result here
}

launcher.launch()
Expand All @@ -67,33 +68,35 @@ Complete features of what you can do with ImagePicker

```kotlin
val config = ImagePickerConfig {
mode = ImagePickerMode.SINGLE // default is multi image mode
language = "in" // Set image picker language
theme = R.style.ImagePickerTheme

// set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker
returnMode = if (returnAfterCapture) ReturnMode.ALL else ReturnMode.NONE

isFolderMode = folderMode // set folder mode (false by default)
isIncludeVideo = includeVideo // include video (false by default)
isOnlyVideo = onlyVideo // include video (false by default)
arrowColor = Color.RED // set toolbar arrow up color
folderTitle = "Folder" // folder selection title
imageTitle = "Tap to select" // image selection title
doneButtonText = "DONE" // done button text
limit = 10 // max images can be selected (99 by default)
isShowCamera = true // show camera or not (true by default)
savePath = ImagePickerSavePath("Camera") // captured image directory name ("Camera" folder by default)
savePath = ImagePickerSavePath(Environment.getExternalStorageDirectory().path, isRelative = false) // can be a full path

excludedImages = images.toFiles() // don't show anything on this selected images
selectedImages = images // original selected images, used in multi mode
mode = ImagePickerMode.SINGLE // default is multi image mode
language = "in" // Set image picker language
theme = R.style.ImagePickerTheme

// set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker
returnMode = if (returnAfterCapture) ReturnMode.ALL else ReturnMode.NONE

isFolderMode = folderMode // set folder mode (false by default)
isIncludeVideo = includeVideo // include video (false by default)
isOnlyVideo = onlyVideo // include video (false by default)
arrowColor = Color.RED // set toolbar arrow up color
folderTitle = "Folder" // folder selection title
imageTitle = "Tap to select" // image selection title
doneButtonText = "DONE" // done button text
limit = 10 // max images can be selected (99 by default)
isShowCamera = true // show camera or not (true by default)
savePath = ImagePickerSavePath("Camera") // captured image directory name ("Camera" folder by default)
savePath =
ImagePickerSavePath(Environment.getExternalStorageDirectory().path, isRelative = false) // can be a full path

excludedImages = images.toFiles() // don't show anything on this selected images
selectedImages = images // original selected images, used in multi mode
}
```

If you want to call it outside `Activity` or `Fragment`, you can get the `Intent` with `createImagePickerIntent`

> Please note: handling in `onActivityResult` is not recommended since it's already deprecated in favor of the new result API
> Please note: handling in `onActivityResult` is not recommended since it's already deprecated in favor of the new
> result API
```kotlin
val intent = createImagePickerIntent(context, ImagePickerConfig())
Expand All @@ -102,13 +105,14 @@ startActivityForResult(intent, RC_IMAGE_PICKER)

## Receive result

when you're done picking images, result will be returned on launcher callback with type `List<Image>`. This list cannot be null but can be empty
when you're done picking images, result will be returned on launcher callback with type `List<Image>`. This list cannot
be null but can be empty

```kotlin
val launcher = registerImagePicker { result: List<Image> ->
result.forEach { image ->
println(image)
}
result.forEach { image ->
println(image)
}
}
```

Expand All @@ -125,15 +129,15 @@ You also still can use the `DefaultCameraModule` but discouraged to do it.

# Wiki

- [Custom components](https://github.com/esafirm/android-image-picker/blob/master/docs/custom_components.md)
- [Using another image library](https://github.com/esafirm/android-image-picker/blob/master/docs/another_image_library.md)
- [Return mode](https://github.com/esafirm/android-image-picker/blob/master/docs/return_mode.md)
- [Save location](https://github.com/esafirm/android-image-picker/blob/master/docs/save_location.md)

- [Custom components](https://github.com/esafirm/android-image-picker/blob/main/docs/custom_components.md)
- [Using another image library](https://github.com/esafirm/android-image-picker/blob/main/docs/another_image_library.md)
- [Return mode](https://github.com/esafirm/android-image-picker/blob/main/docs/return_mode.md)
- [Save location](https://github.com/esafirm/android-image-picker/blob/main/docs/save_location.md)

# Version 2.x.x

If you still use the previous version, you can check `2.x` branch in [here](https://github.com/esafirm/android-image-picker/tree/2.x)
If you still use the previous version, you can check `2.x` branch
in [here](https://github.com/esafirm/android-image-picker/tree/2.x)

# Support Me!

Expand All @@ -149,4 +153,4 @@ Would you help me achieving this goals?

# License

MIT @ Esa Firman
MIT @ Esa Firman
16 changes: 7 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
buildscript {
ext.kotlin_version = '1.4.32'
ext.core_ktx_version = '1.3.2'
ext.kotlin_version = '1.7.20'
ext.core_ktx_version = '1.9.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

ext {
sdk = [
compileSdk: 30,
targetSdk : 30,
minSdk : 21
compileSdk: 33,
targetSdk : 33,
minSdk : 21
]
}

Expand All @@ -25,10 +24,9 @@ allprojects {
mavenCentral()
google()
maven { url "https://jitpack.io" }
jcenter()
}
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
25 changes: 18 additions & 7 deletions docs/custom_components.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# Custom Components

You also can change how to process the image and how to get the image files through `ImageLoader` and `ImageFileLoader`
To change this, simply set it on `ImagePickerComponentHolder`
To change this, first, create custom `ImagePickerComponents`.
You could inherit from `DefaultImagePickerComponents` or directly implements from `ImagePickerComponents` interface.

```java
ImagePickerComponentHolder.getInstance()
.setImageLoader(new GrayScaleImageLoader())
.setImageFileLoader(new WebpImageFileLoader())
```
```kotlin
class CustomImagePickerComponents(
context: Context
) : DefaultImagePickerComponents(context.applicationContext) {
override val imageLoader: ImageLoader
get() = GrayscaleImageLoader()
}
```

Happy coding!
Then, use it by calling `setInternalComponent` on `ImagePickerComponentsHolder`.
```kotlin
ImagePickerComponentsHolder.setInternalComponent(
CustomImagePickerComponents(context)
)
```

Happy coding!
19 changes: 13 additions & 6 deletions docs/save_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

By default, ImagePicker will try to save the image generated from camera to `Environment.DIRECTORY_PICTURES` with directory name `"Camera"`.

You can change the directory name only by using:
You can change the directory name by using:

```java
ImagePicker.create(activity).imageDirectory(String dirName)
```
```kotlin
val config = ImagePickerConfig {
savePath = ImagePickerSavePath(dirName)
}
```

Or you can change the full path of the save location by using:

```java
ImagePicker.create(activity).imageFullDirectory(String fullPath)
```kotlin
val config = ImagePickerConfig {
savePath = ImagePickerSavePath(
path = fullPath,
isRelative = false,
)
}
```
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.useAndroidX=true
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1g
org.gradle.jvmargs=-Xmx2g
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
32 changes: 18 additions & 14 deletions imagepicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'
plugins {
id "com.android.library"
id "kotlin-android"
id "kotlin-parcelize"
}

group = 'com.github.ZupersoftSolutions'

Expand All @@ -13,8 +14,6 @@ android {
defaultConfig {
minSdkVersion sdk.minSdk
targetSdkVersion sdk.targetSdk
versionCode 1
versionName "1.0"
}

buildFeatures {
Expand All @@ -33,33 +32,38 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
lint {
abortOnError false
}

testOptions {
unitTests.all {
useJUnitPlatform()
}
}

resourcePrefix "ef_"
namespace 'com.esafirm.imagepicker'
}

task sourcesJar(type: Jar) {
tasks.register("sourcesJar", Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier.set('sources')
}

artifacts {
archives sourcesJar
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.github.bumptech.glide:glide:4.11.0"
implementation "com.github.bumptech.glide:glide:4.14.2"
implementation 'androidx.recyclerview:recyclerview:1.2.1'

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.appcompat:appcompat:1.5.1'

implementation "androidx.core:core-ktx:$core_ktx_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

testImplementation platform("org.junit:junit-bom:5.7.1")
testImplementation platform("org.junit:junit-bom:5.9.1")
testImplementation "org.junit.jupiter:junit-jupiter"
testImplementation 'com.natpryce:hamkrest:1.8.0.1'
}
12 changes: 8 additions & 4 deletions imagepicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.esafirm.imagepicker">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />

<!-- Tiramisu and above -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

<application>
<activity
Expand Down
Loading

0 comments on commit 51d7a51

Please sign in to comment.