From 338bef49e5fcf33ee286e62c0941521793efafbc Mon Sep 17 00:00:00 2001 From: Vrajendra Date: Wed, 27 Mar 2024 17:14:32 +0530 Subject: [PATCH 01/16] - Updated readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74fb6de..5160241 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,14 @@ Lassi is simplest way to pick media (either image, video, audio or doc) ### Key features -* Android 13 support +* Android 14 support * Simple implementation * Set your own custom styles * Filter by particular media type * Filter videos by min and max time * Enable/disable camera from LassiOption * You can open System Default view for file selection by using MediaType.FILE_TYPE_WITH_SYSTEM_VIEW +* Photo Picker feature integration # Usage From 3acd1638d4200bf536b057fe5ece3da9a58e668e Mon Sep 17 00:00:00 2001 From: Vrajendra Date: Wed, 27 Mar 2024 19:01:05 +0530 Subject: [PATCH 02/16] - Updated readme - Removed unnecessary code --- README.md | 9 ++++++++ .../main/java/com/lassi/app/MainActivity.kt | 23 ++----------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5160241..ea7b035 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,15 @@ Lassi is simplest way to pick media (either image, video, audio or doc) * Option - 2. To localize text content of Lassi picker with multiple language options, define language-specific string resource file in your project and update values of string resource keys mentioned in below link with your desired language. * [Lassi String Resources](https://github.com/Mindinventory/Lassi-Android/blob/931e147ebe6282bd1629858b5a9f29fe5a0b8b32/lassi/src/main/res/values/strings.xml) +### Way of utilizing Photo Picker + ```kotlin + val intent = val intent = Lassi(this) + .with(LassiOption.CAMERA_AND_GALLERY) + .setMediaType(MediaType.PHOTO_PICKER) + ``` + + + ### Document access permission note If Android device SDK is >= 30 and wants to access document (only for choose the non media file) then add ```android.permission.MANAGE_EXTERNAL_STORAGE``` permission in your app otherwise library won't allow to access documents. Kindly check sample app for more detail. If you don't want to give Manage External Storage permission and wants to get files with system default view then You can use `OR` option from Step 1 and give required file type of document. diff --git a/app/src/main/java/com/lassi/app/MainActivity.kt b/app/src/main/java/com/lassi/app/MainActivity.kt index 4d298cf..d3da458 100644 --- a/app/src/main/java/com/lassi/app/MainActivity.kt +++ b/app/src/main/java/com/lassi/app/MainActivity.kt @@ -218,34 +218,15 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { val intent = lassi.with(LassiOption.CAMERA_AND_GALLERY).setMaxCount(4) .setAscSort(SortingOption.ASCENDING).setGridSize(2) .setMediaType(MediaType.PHOTO_PICKER) - .setPlaceHolder(R.drawable.ic_image_placeholder) - .setErrorDrawable(R.drawable.ic_image_placeholder) - .setSelectionDrawable(R.drawable.ic_checked_media) .setStatusBarColor(R.color.colorPrimaryDark) .setToolbarColor(R.color.colorPrimary) .setToolbarResourceColor(android.R.color.white) - .setAlertDialogNegativeButtonColor(R.color.cherry_red) - .setAlertDialogPositiveButtonColor(R.color.emerald_green) .setProgressBarColor(R.color.colorAccent) .setGalleryBackgroundColor(R.color.colorGrey) .setCropType(CropImageView.CropShape.OVAL).setCropAspectRatio(1, 1) - .setCompressionRatio(10).setMinFileSize(0).setMaxFileSize(Int.MAX_VALUE.toLong()) - .enableActualCircleCrop() + .setCompressionRatio(10) .setCustomLimitExceedingErrorMessage("Selected item exceeded the limit!") - .setSupportedFileTypes( - "jpg", - "jpeg", - "png", - "webp", - "gif", - "mp4", - "mkv", - "webm", - "avi", - "flv", - "3gp" - ).enableFlip() - .enableRotate().build() + .build() receiveData.launch(intent) } } From 611347c4462f6db2e81b2468297f974165fc3ce0 Mon Sep 17 00:00:00 2001 From: Vrajendra Date: Wed, 27 Mar 2024 19:03:42 +0530 Subject: [PATCH 03/16] - Updated readme --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ea7b035..e1f35a1 100644 --- a/README.md +++ b/README.md @@ -148,13 +148,11 @@ Lassi is simplest way to pick media (either image, video, audio or doc) * [Lassi String Resources](https://github.com/Mindinventory/Lassi-Android/blob/931e147ebe6282bd1629858b5a9f29fe5a0b8b32/lassi/src/main/res/values/strings.xml) ### Way of utilizing Photo Picker - ```kotlin - val intent = val intent = Lassi(this) +```kotlin + val intent = Lassi(this) .with(LassiOption.CAMERA_AND_GALLERY) .setMediaType(MediaType.PHOTO_PICKER) - ``` - - +``` ### Document access permission note If Android device SDK is >= 30 and wants to access document (only for choose the non media file) then add ```android.permission.MANAGE_EXTERNAL_STORAGE``` permission in your app otherwise library won't allow to access documents. Kindly check sample app for more detail. From 9f3b307a8bf943e574e6d9e356c22819590704e4 Mon Sep 17 00:00:00 2001 From: Vrajendra Date: Wed, 27 Mar 2024 19:12:34 +0530 Subject: [PATCH 04/16] - Updated readme --- README.md | 8 ++++++++ app/src/main/java/com/lassi/app/MainActivity.kt | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e1f35a1..5e1f96b 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,14 @@ Lassi is simplest way to pick media (either image, video, audio or doc) val intent = Lassi(this) .with(LassiOption.CAMERA_AND_GALLERY) .setMediaType(MediaType.PHOTO_PICKER) + .setMaxCount(4) + .setStatusBarColor(R.color.colorPrimaryDark) + .setToolbarColor(R.color.colorPrimary) + .setToolbarResourceColor(android.R.color.white) + .setProgressBarColor(R.color.colorAccent) + .setGalleryBackgroundColor(R.color.colorGrey) + .setCustomLimitExceedingErrorMessage("Selected item exceeded the limit!") + .build() ``` ### Document access permission note diff --git a/app/src/main/java/com/lassi/app/MainActivity.kt b/app/src/main/java/com/lassi/app/MainActivity.kt index d3da458..b62477d 100644 --- a/app/src/main/java/com/lassi/app/MainActivity.kt +++ b/app/src/main/java/com/lassi/app/MainActivity.kt @@ -216,15 +216,12 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { R.id.btnPhotoPicker -> { val intent = lassi.with(LassiOption.CAMERA_AND_GALLERY).setMaxCount(4) - .setAscSort(SortingOption.ASCENDING).setGridSize(2) .setMediaType(MediaType.PHOTO_PICKER) .setStatusBarColor(R.color.colorPrimaryDark) .setToolbarColor(R.color.colorPrimary) .setToolbarResourceColor(android.R.color.white) .setProgressBarColor(R.color.colorAccent) .setGalleryBackgroundColor(R.color.colorGrey) - .setCropType(CropImageView.CropShape.OVAL).setCropAspectRatio(1, 1) - .setCompressionRatio(10) .setCustomLimitExceedingErrorMessage("Selected item exceeded the limit!") .build() receiveData.launch(intent) From be7ab6ce216ff9080d6c606eca252e7004e5f679 Mon Sep 17 00:00:00 2001 From: Hanif Shaikh Date: Tue, 15 Oct 2024 13:06:31 +0530 Subject: [PATCH 05/16] - Bifurcate of the image and video for photo picker. - Added VIDEO_PICKER and PHOTO_VIDEO_PICKER MediaType for image and video. --- .../main/java/com/lassi/app/MainActivity.kt | 32 +++++++++++-- app/src/main/res/layout/activity_main.xml | 45 ++++++++++++++++++- app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + .../java/com/lassi/domain/media/MediaType.kt | 4 +- .../mediadirectory/FolderFragment.kt | 30 ++++++++++--- 6 files changed, 101 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/lassi/app/MainActivity.kt b/app/src/main/java/com/lassi/app/MainActivity.kt index b62477d..ccdc45b 100644 --- a/app/src/main/java/com/lassi/app/MainActivity.kt +++ b/app/src/main/java/com/lassi/app/MainActivity.kt @@ -8,7 +8,6 @@ import android.os.Build import android.os.Bundle import android.os.Environment import android.provider.Settings -import android.util.Log import android.view.View import android.webkit.MimeTypeMap import androidx.activity.result.contract.ActivityResultContracts @@ -21,7 +20,6 @@ import com.lassi.common.utils.KeyUtils import com.lassi.data.media.MiMedia import com.lassi.domain.media.LassiOption import com.lassi.domain.media.MediaType -import com.lassi.domain.media.MultiLangConfig import com.lassi.domain.media.SortingOption import com.lassi.presentation.builder.Lassi import com.lassi.presentation.common.decoration.GridSpacingItemDecoration @@ -47,7 +45,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { it.btnImageCapture.setOnClickListener(this) it.btnVideoCapture.setOnClickListener(this) it.btnDocumentSystemIntent.setOnClickListener(this) + it.btnPhotoVideoPicker.setOnClickListener(this) it.btnPhotoPicker.setOnClickListener(this) + it.btnVideoMediaPicker.setOnClickListener(this) it.rvSelectedMedia.adapter = selectedMediaAdapter it.rvSelectedMedia.addItemDecoration(GridSpacingItemDecoration(2, 10)) } @@ -72,7 +72,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { setSortByDateLbl = "Trier par date" ) } - binding.btnPhotoPicker.visibility = View.VISIBLE + binding.btnPhotoVideoPicker.visibility = View.VISIBLE } override fun onClick(v: View?) { @@ -214,6 +214,19 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { receiveData.launch(intent) } + R.id.btnPhotoVideoPicker -> { + val intent = lassi.with(LassiOption.CAMERA_AND_GALLERY).setMaxCount(4) + .setMediaType(MediaType.PHOTO_VIDEO_PICKER) + .setStatusBarColor(R.color.colorPrimaryDark) + .setToolbarColor(R.color.colorPrimary) + .setToolbarResourceColor(android.R.color.white) + .setProgressBarColor(R.color.colorAccent) + .setGalleryBackgroundColor(R.color.colorGrey) + .setCustomLimitExceedingErrorMessage("Selected item exceeded the limit!") + .build() + receiveData.launch(intent) + } + R.id.btnPhotoPicker -> { val intent = lassi.with(LassiOption.CAMERA_AND_GALLERY).setMaxCount(4) .setMediaType(MediaType.PHOTO_PICKER) @@ -226,6 +239,19 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { .build() receiveData.launch(intent) } + + R.id.btnVideoMediaPicker -> { + val intent = lassi.with(LassiOption.CAMERA_AND_GALLERY).setMaxCount(4) + .setMediaType(MediaType.VIDEO_PICKER) + .setStatusBarColor(R.color.colorPrimaryDark) + .setToolbarColor(R.color.colorPrimary) + .setToolbarResourceColor(android.R.color.white) + .setProgressBarColor(R.color.colorAccent) + .setGalleryBackgroundColor(R.color.colorGrey) + .setCustomLimitExceedingErrorMessage("Selected item exceeded the limit!") + .build() + receiveData.launch(intent) + } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f620172..08e7ad4 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -152,14 +152,14 @@ app:layout_constraintTop_toBottomOf="@+id/btnDocumentSystemIntent" />