From 5a9bebaa26a3fee183d539b3a60c4505efb15a35 Mon Sep 17 00:00:00 2001 From: Chuijia Kong Date: Thu, 12 Oct 2023 17:23:29 +1100 Subject: [PATCH 1/2] Added the ability to select images in jpeg or jpg format. --- .../fragment/ImageToPdfFragment.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java b/app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java index 130f3aa3..a36f4f7f 100755 --- a/app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java +++ b/app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java @@ -65,6 +65,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; @@ -297,10 +298,21 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case INTENT_REQUEST_GET_IMAGES: - mImagesUri.clear(); - mUnarrangedImagesUri.clear(); - mImagesUri.addAll(Matisse.obtainPathResult(data)); - mUnarrangedImagesUri.addAll(mImagesUri); + // Handle image selection here + ArrayList selectedImageUris = new ArrayList<>(); + List selectedUris = Matisse.obtainResult(data); + for (Uri uri : selectedUris) { + String realPath = mFileUtils.getUriRealPath(uri); + if (realPath != null) { + String lowerCasePath = realPath.toLowerCase(); + if (lowerCasePath.endsWith(".jpg") || lowerCasePath.endsWith(".jpeg") || lowerCasePath.endsWith(".png")) { + selectedImageUris.add(realPath); + } + } + } + // Add the selected images to mImagesUri + mImagesUri.addAll(selectedImageUris); + if (mImagesUri.size() > 0) { mNoOfImages.setText(String.format(mActivity.getResources() .getString(R.string.images_selected), mImagesUri.size())); From 20edae6d5004831eb7867085acef152ed7d1782b Mon Sep 17 00:00:00 2001 From: Chuijia Kong Date: Fri, 27 Oct 2023 01:44:59 +1100 Subject: [PATCH 2/2]