From 60bb27fa943569189e463cfe989917008fbd92cd Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:46:12 +0200 Subject: [PATCH 01/19] feat(health-sdk): Upgrade targetSdk PM-92 --- health-sdk/sdk/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/health-sdk/sdk/build.gradle.kts b/health-sdk/sdk/build.gradle.kts index 4161936612..406c38767a 100644 --- a/health-sdk/sdk/build.gradle.kts +++ b/health-sdk/sdk/build.gradle.kts @@ -19,7 +19,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From fc2833dc67a74cd856632f0c43996d5a0c2700b5 Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:47:23 +0200 Subject: [PATCH 02/19] feat(core-api-library): Upgrade targetSdk PM-92 --- core-api-library/shared-tests/build.gradle.kts | 3 ++- health-api-library/library/build.gradle.kts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core-api-library/shared-tests/build.gradle.kts b/core-api-library/shared-tests/build.gradle.kts index b112ac1b65..3e274d9a70 100644 --- a/core-api-library/shared-tests/build.gradle.kts +++ b/core-api-library/shared-tests/build.gradle.kts @@ -14,7 +14,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/health-api-library/library/build.gradle.kts b/health-api-library/library/build.gradle.kts index ceed6bda6e..99e2f041d3 100644 --- a/health-api-library/library/build.gradle.kts +++ b/health-api-library/library/build.gradle.kts @@ -24,7 +24,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From fea9c0733a6fbb0b08f950543547bc1aced061c9 Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:49:06 +0200 Subject: [PATCH 03/19] feat(core-api-library): Upgrade targetSd, fix related test PM-92 --- core-api-library/library/build.gradle.kts | 3 ++- .../gini/android/core/api/DocumentRemoteSourceTest.kt | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core-api-library/library/build.gradle.kts b/core-api-library/library/build.gradle.kts index b39e4c95d2..fb9bfba157 100644 --- a/core-api-library/library/build.gradle.kts +++ b/core-api-library/library/build.gradle.kts @@ -16,7 +16,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/core-api-library/library/src/test/java/net/gini/android/core/api/DocumentRemoteSourceTest.kt b/core-api-library/library/src/test/java/net/gini/android/core/api/DocumentRemoteSourceTest.kt index 6e155d52ab..95a2fdc71d 100644 --- a/core-api-library/library/src/test/java/net/gini/android/core/api/DocumentRemoteSourceTest.kt +++ b/core-api-library/library/src/test/java/net/gini/android/core/api/DocumentRemoteSourceTest.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest import net.gini.android.core.api.response.PaymentRequestResponse +import net.gini.android.core.api.response.PaymentResponse import net.gini.android.core.api.test.DocumentRemoteSourceForTests import net.gini.android.core.api.test.MockGiniApiType import okhttp3.RequestBody @@ -213,6 +214,14 @@ class DocumentRemoteSourceTest { return Response.success(listOf(PaymentRequestResponse(null, null, "", "", null, "", "", ""))) } + override suspend fun getPayment( + bearer: Map, + id: String + ): Response { + bearerAuthHeader = bearer["Authorization"] + return Response.success(PaymentResponse("", "", "", null, "", "" )) + } + override suspend fun getFile(bearer: Map, location: String): Response { bearerAuthHeader = bearer["Authorization"] return Response.success("response".toResponseBody()) From 59a412a230d5637d61b3ff4261f041693022ed19 Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:52:29 +0200 Subject: [PATCH 04/19] feat(capture-sdk): Upgrade targetSdk PM-92 --- capture-sdk/default-network/build.gradle.kts | 3 ++- capture-sdk/sdk/build.gradle.kts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/capture-sdk/default-network/build.gradle.kts b/capture-sdk/default-network/build.gradle.kts index 1cf57ee0e7..743efb34e2 100644 --- a/capture-sdk/default-network/build.gradle.kts +++ b/capture-sdk/default-network/build.gradle.kts @@ -25,7 +25,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/capture-sdk/sdk/build.gradle.kts b/capture-sdk/sdk/build.gradle.kts index e05a32e130..6297c1473b 100644 --- a/capture-sdk/sdk/build.gradle.kts +++ b/capture-sdk/sdk/build.gradle.kts @@ -24,7 +24,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From 52e1146f442e2045198ef43e64effffb04f12bfd Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:53:30 +0200 Subject: [PATCH 05/19] feat(bank-sdk): Upgrade targetSdk PM-92 --- bank-sdk/sdk/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bank-sdk/sdk/build.gradle.kts b/bank-sdk/sdk/build.gradle.kts index 47789333f2..45da470834 100644 --- a/bank-sdk/sdk/build.gradle.kts +++ b/bank-sdk/sdk/build.gradle.kts @@ -26,7 +26,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From a2709a16cbca29c4acb386d22d52648e4bfb5fbb Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:54:57 +0200 Subject: [PATCH 06/19] feat(bank-api): Upgrade targetSdk PM-92 --- bank-api-library/library/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bank-api-library/library/build.gradle.kts b/bank-api-library/library/build.gradle.kts index f98be00893..74c6a6b5e5 100644 --- a/bank-api-library/library/build.gradle.kts +++ b/bank-api-library/library/build.gradle.kts @@ -19,7 +19,8 @@ android { } defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() + testOptions.targetSdk = libs.versions.android.targetSdk.get().toInt() + lint.targetSdk = libs.versions.android.targetSdk.get().toInt() // Use the test runner with JUnit4 support testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From 9aac2c4e99e3ac40203a323150af367c6826da45 Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 10:56:31 +0200 Subject: [PATCH 07/19] feat(gini-mobile-android): Upgrade gradle wrapper, libs targetSdk PM-85 --- gradle/libs.versions.toml | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ed81015169..5f5c16a257 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] android-compileSdk = "34" android-minSdk = "21" -android-targetSdk = "33" +android-targetSdk = "34" kotlin = "1.8.20" -android-gradle-plugin = "8.2.1" +android-gradle-plugin = "8.4.2" dokka = "1.7.20" androidx-lifecycle = "2.7.0" androidx-camera = "1.3.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cbaf4e4640..a6f0bdd495 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed Sep 29 16:01:46 CEST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 1e3dda721c79c49cc7fdc5c34a928f77646862cc Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 3 Jul 2024 11:55:18 +0200 Subject: [PATCH 08/19] feat(gini_mobile_android): Upgrade roboelectric Old roboelectric lib doesn't support sdk 34, so some unit tests fails PM-92 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5f5c16a257..9473f032d9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -83,7 +83,7 @@ mlkit-textrecognition = "com.google.android.gms:play-services-mlkit-text-recogni apachecommons-imaging = "org.apache.commons:commons-imaging:1.0-alpha2" completableFuture = "org.glassfish.jersey.bundles.repackaged:jersey-jsr166e:2.25.1" truth = "com.google.truth:truth:1.1.3" -robolectric = "org.robolectric:robolectric:4.9" +robolectric = "org.robolectric:robolectric:4.12.2" dexter = "com.karumi:dexter:6.2.3" logback-android-core = "com.github.tony19:logback-android-core:1.1.1-6" logback-android-classic = "com.github.tony19:logback-android-classic:1.1.1-6" From 9daed17736f7525f8340d16fc35b6dd9ad869270 Mon Sep 17 00:00:00 2001 From: jackkray Date: Mon, 8 Jul 2024 11:41:03 +0200 Subject: [PATCH 09/19] ci(mobile-android): Change readLocalPropertiesToMap to readLocalPropertiesToMapSilent We need to mute readLocalPropertiesToMap, because during lint check call of injectProperties task throw an error PM-85 --- bank-api-library/library/build.gradle.kts | 2 +- bank-sdk/sdk/build.gradle.kts | 5 +++-- capture-sdk/default-network/build.gradle.kts | 2 +- health-api-library/library/build.gradle.kts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bank-api-library/library/build.gradle.kts b/bank-api-library/library/build.gradle.kts index 74c6a6b5e5..2a820657cf 100644 --- a/bank-api-library/library/build.gradle.kts +++ b/bank-api-library/library/build.gradle.kts @@ -114,7 +114,7 @@ tasks.register("injectTestProperties") { doFirst { propertiesMap.clear() - propertiesMap.putAll(readLocalPropertiesToMap(project, + propertiesMap.putAll(readLocalPropertiesToMapSilent(project, listOf("testClientId", "testClientSecret", "testApiUri", "testUserCenterUri", "testHealthApiUri"))) } diff --git a/bank-sdk/sdk/build.gradle.kts b/bank-sdk/sdk/build.gradle.kts index 45da470834..6d137fad0b 100644 --- a/bank-sdk/sdk/build.gradle.kts +++ b/bank-sdk/sdk/build.gradle.kts @@ -148,8 +148,9 @@ tasks.register("injectTestProperties") { doFirst { propertiesMap.clear() - propertiesMap.putAll(readLocalPropertiesToMap(project, - listOf("testClientId", "testClientSecret", "testApiUri", "testUserCenterUri"))) + propertiesMap.putAll(readLocalPropertiesToMapSilent(project, + listOf("testClientId", "testClientSecret", "testApiUri", "testUserCenterUri")) + ) } destinations.put( diff --git a/capture-sdk/default-network/build.gradle.kts b/capture-sdk/default-network/build.gradle.kts index 743efb34e2..98b43ac86c 100644 --- a/capture-sdk/default-network/build.gradle.kts +++ b/capture-sdk/default-network/build.gradle.kts @@ -120,7 +120,7 @@ tasks.register("injectTestProperties") { doFirst { propertiesMap.clear() - propertiesMap.putAll(readLocalPropertiesToMap(project, + propertiesMap.putAll(readLocalPropertiesToMapSilent(project, listOf("testClientId", "testClientSecret", "testApiUri", "testUserCenterUri"))) } diff --git a/health-api-library/library/build.gradle.kts b/health-api-library/library/build.gradle.kts index 99e2f041d3..fc85ee1657 100644 --- a/health-api-library/library/build.gradle.kts +++ b/health-api-library/library/build.gradle.kts @@ -125,7 +125,7 @@ tasks.register("injectTestProperties") { doFirst { propertiesMap.clear() - propertiesMap.putAll(readLocalPropertiesToMap(project, + propertiesMap.putAll(readLocalPropertiesToMapSilent(project, listOf("testClientId", "testClientSecret", "testApiUri", "testUserCenterUri", "testBankApiUri"))) } From b241fe31f9e3606544135fed455c17ed661ec1e2 Mon Sep 17 00:00:00 2001 From: jackkray Date: Wed, 10 Jul 2024 18:52:13 +0200 Subject: [PATCH 10/19] feat(capture-sdk): Use new photo-picker. Now we are using new photo picker, for devices that doesn't have backdrop version, we use the same approach with list of apps PP-198 --- capture-sdk/sdk/src/main/AndroidManifest.xml | 11 +++ .../capture/camera/CameraFragmentImpl.java | 9 ++ .../fileimport/FileChooserFragment.kt | 88 ++++++++++++++++--- .../providerchooser/ProvidersAdapter.java | 41 ++++++--- .../ProvidersAppItemSelectedListener.java | 2 +- .../ProvidersAppWrapperItem.java | 31 +++++++ .../providerchooser/ProvidersItem.java | 3 +- 7 files changed, 159 insertions(+), 26 deletions(-) create mode 100644 capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppWrapperItem.java diff --git a/capture-sdk/sdk/src/main/AndroidManifest.xml b/capture-sdk/sdk/src/main/AndroidManifest.xml index f2d08a4813..605aeb22bb 100644 --- a/capture-sdk/sdk/src/main/AndroidManifest.xml +++ b/capture-sdk/sdk/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -18,6 +19,16 @@ + + + + + + + uriList) { + if (mFragment.getActivity() == null) + return; + + handleMultiPageDocumentAndCallListener(mFragment.getActivity(), new Intent(Intent.ACTION_PICK), uriList); + } + private boolean isImage(@NonNull final Intent data, @NonNull final Activity activity) { return IntentHelper.hasMimeTypeWithPrefix(data, activity, MimeType.IMAGE_PREFIX.asString()); } diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index f70df41fbb..16bdcea39d 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -7,6 +7,7 @@ import android.app.Dialog import android.content.Context import android.content.Intent import android.content.pm.ResolveInfo +import android.net.Uri import android.os.Build import android.os.Bundle import android.os.Parcelable @@ -15,7 +16,9 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.PickVisualMediaRequest import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.content.ContextCompat import androidx.fragment.app.setFragmentResult import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.GridLayoutManager @@ -30,6 +33,7 @@ import net.gini.android.capture.R import net.gini.android.capture.databinding.GcFragmentFileChooserBinding import net.gini.android.capture.internal.fileimport.providerchooser.ProvidersAdapter import net.gini.android.capture.internal.fileimport.providerchooser.ProvidersAppItem +import net.gini.android.capture.internal.fileimport.providerchooser.ProvidersAppWrapperItem import net.gini.android.capture.internal.fileimport.providerchooser.ProvidersItem import net.gini.android.capture.internal.fileimport.providerchooser.ProvidersSectionItem import net.gini.android.capture.internal.fileimport.providerchooser.ProvidersSeparatorItem @@ -57,6 +61,7 @@ class FileChooserFragment : BottomSheetDialogFragment() { private var docImportEnabledFileTypes: DocumentImportEnabledFileTypes? = null private var binding: GcFragmentFileChooserBinding by autoCleared() private var chooseFileLauncher: ActivityResultLauncher? = null + private var pickMedia: ActivityResultLauncher? = null private lateinit var mUserAnalyticsEventTracker: UserAnalyticsEventTracker private val screenName: UserAnalyticsScreen = UserAnalyticsScreen.Camera @@ -152,6 +157,32 @@ class FileChooserFragment : BottomSheetDialogFragment() { }) } } + + val photoPickType = + if (FeatureConfiguration.isMultiPageEnabled()) + ActivityResultContracts.PickMultipleVisualMedia() + else + ActivityResultContracts.PickVisualMedia() + + + pickMedia = registerForActivityResult(photoPickType) { uri -> + findNavController().popBackStack() + if (uri != null) { + val lst = when(uri){ + is Uri -> listOf(uri) + is List<*> -> uri.filterIsInstance().takeIf { it.size == uri.size } + ?: throw IllegalArgumentException("List contains non-Uri elements") + else -> throw IllegalArgumentException("uri is neither Uri nor List") + } + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, FileChooserResult.FilesSelectedUri(lst)) + }) + } else { + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, FileChooserResult.Cancelled) + }) + } + } } private fun getGridSpanCount(): Int = @@ -164,15 +195,18 @@ class FileChooserFragment : BottomSheetDialogFragment() { private fun populateFileProviders() { val providerItems: MutableList = ArrayList() - var imageProviderItems: List = ArrayList() + var imageProviderItems: List = arrayListOf() var pdfProviderItems: List = ArrayList() if (shouldShowImageProviders()) { val imagePickerResolveInfos = queryImagePickers(requireContext()) val imageProviderResolveInfos = queryImageProviders(requireContext()) - imageProviderItems = getImageProviderItems( - imagePickerResolveInfos, - imageProviderResolveInfos - ) + + imageProviderItems = + if (ActivityResultContracts.PickVisualMedia.isPhotoPickerAvailable(requireContext())) { + getPhotoPickerProvider() + } else { + getImageProviderItems(imagePickerResolveInfos, imageProviderResolveInfos) + } } if (shouldShowPdfProviders()) { val pdfProviderResolveInfos = queryPdfProviders(requireContext()) @@ -204,12 +238,26 @@ class FileChooserFragment : BottomSheetDialogFragment() { } } - private fun launchApp(item: ProvidersAppItem) { - item.intent.setClassName( - item.resolveInfo.activityInfo.packageName, - item.resolveInfo.activityInfo.name - ) - chooseFileLauncher?.launch(item.intent) + private fun launchApp(item: ProvidersItem) { + when (item) { + is ProvidersAppItem -> { + item.intent.setClassName( + item.resolveInfo.activityInfo.packageName, + item.resolveInfo.activityInfo.name + ) + chooseFileLauncher?.launch(item.intent) + } + + is ProvidersAppWrapperItem -> { + pickMedia?.launch( + PickVisualMediaRequest( + ActivityResultContracts.PickVisualMedia.SingleMimeType( + MimeType.IMAGE_WILDCARD.asString() + ) + ) + ) + } + } } private fun getImageProviderItems( @@ -233,6 +281,23 @@ class FileChooserFragment : BottomSheetDialogFragment() { } } + private fun getPhotoPickerProvider(): List { + val providerList = + ContextCompat.getDrawable(requireContext(), (R.drawable.gc_photo_tip_align)) + ?.let { image -> + listOf( + ProvidersSectionItem(getString(R.string.gc_file_chooser_fotos_section_header)), + ProvidersAppWrapperItem( + image, + getString(R.string.gc_file_chooser_fotos_section_header) + ) + ) + } ?: run { + emptyList() + } + return providerList + } + private fun getPdfProviderItems(pdfProviderResolveInfos: List): List = mutableListOf().apply { if (pdfProviderResolveInfos.isNotEmpty()) { @@ -340,6 +405,7 @@ class FileChooserFragment : BottomSheetDialogFragment() { @Parcelize sealed class FileChooserResult : Parcelable { data class FilesSelected(val dataIntent: Intent) : FileChooserResult() + data class FilesSelectedUri(val list: List) : FileChooserResult() data class Error(val error: GiniCaptureError) : FileChooserResult() object Cancelled : FileChooserResult() } diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java index 7a672cb21f..37270307fa 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java @@ -40,12 +40,14 @@ public int getItemViewType(final int position) { @Override public ProvidersItemViewHolder onCreateViewHolder(final ViewGroup parent, - final int viewType) { + final int viewType) { switch (ProvidersItem.FileProviderItemType.fromOrdinal(viewType)) { case SECTION: return createSectionItemViewHolder(parent); case APP: - return createAppItemViewHolder(parent); + return createAppItemViewHolder(parent, ProvidersItem.FileProviderItemType.APP); + case APP_WRAPPER_PHOTO_PICKER: + return createAppItemViewHolder(parent, ProvidersItem.FileProviderItemType.APP_WRAPPER_PHOTO_PICKER); case SEPARATOR: return createSeparatorItemViewHolder(parent); default: @@ -62,10 +64,12 @@ private ProvidersItemViewHolder createSectionItemViewHolder( } @NonNull - private ProvidersItemViewHolder createAppItemViewHolder(@NonNull final ViewGroup parent) { + private ProvidersItemViewHolder createAppItemViewHolder( + @NonNull final ViewGroup parent, + @NonNull ProvidersItem.FileProviderItemType providerItemType) { final View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gc_item_file_provider_app, parent, false); - return new ProvidersAppItemViewHolder(itemView); + return new ProvidersAppItemViewHolder(itemView, providerItemType); } private ProvidersItemViewHolder createSeparatorItemViewHolder(@NonNull final ViewGroup parent) { @@ -83,6 +87,8 @@ public void onBindViewHolder(final ProvidersItemViewHolder holder, final int pos case APP: bindAppItemViewHolder((ProvidersAppItemViewHolder) holder, position); break; + case APP_WRAPPER_PHOTO_PICKER: + bindAppWrapperItemViewHolder((ProvidersAppItemViewHolder) holder, position); case SEPARATOR: break; default: @@ -101,13 +107,22 @@ private void bindAppItemViewHolder(@NonNull final ProvidersAppItemViewHolder hol final ProvidersAppItem item = (ProvidersAppItem) mItems.get(position); holder.icon.setImageDrawable(item.getResolveInfo().loadIcon(mContext.getPackageManager())); holder.label.setText(item.getResolveInfo().loadLabel(mContext.getPackageManager())); - holder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View view) { - final ProvidersAppItem item = - (ProvidersAppItem) mItems.get(holder.getAdapterPosition()); - mItemSelectedListener.onItemSelected(item); - } + holder.itemView.setOnClickListener(view -> { + final ProvidersAppItem item1 = + (ProvidersAppItem) mItems.get(holder.getAdapterPosition()); + mItemSelectedListener.onItemSelected(item1); + }); + } + + private void bindAppWrapperItemViewHolder(@NonNull final ProvidersAppItemViewHolder holder, + final int position) { + final ProvidersAppWrapperItem item = (ProvidersAppWrapperItem) mItems.get(position); + holder.icon.setImageDrawable(item.getDrawableIcon()); + holder.label.setText(item.getText()); + holder.itemView.setOnClickListener(view -> { + final ProvidersAppWrapperItem item1 = + (ProvidersAppWrapperItem) mItems.get(holder.getAdapterPosition()); + mItemSelectedListener.onItemSelected(item1); }); } @@ -123,8 +138,8 @@ private static class ProvidersAppItemViewHolder extends ProvidersItemViewHolder @NonNull final TextView label; - ProvidersAppItemViewHolder(@NonNull final View itemView) { - super(itemView, ProvidersItem.FileProviderItemType.APP); + ProvidersAppItemViewHolder(@NonNull final View itemView, @NonNull ProvidersItem.FileProviderItemType providerItemType) { + super(itemView, providerItemType); icon = itemView.findViewById(R.id.gc_app_icon); label = itemView.findViewById(R.id.gc_app_label); } diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppItemSelectedListener.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppItemSelectedListener.java index 9324d0de5b..f6e16751ef 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppItemSelectedListener.java +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppItemSelectedListener.java @@ -9,5 +9,5 @@ */ public interface ProvidersAppItemSelectedListener { - void onItemSelected(@NonNull final ProvidersAppItem item); + void onItemSelected(@NonNull final ProvidersItem item); } diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppWrapperItem.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppWrapperItem.java new file mode 100644 index 0000000000..7dee3c5b82 --- /dev/null +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAppWrapperItem.java @@ -0,0 +1,31 @@ +package net.gini.android.capture.internal.fileimport.providerchooser; + +import android.graphics.drawable.Drawable; + +import androidx.annotation.NonNull; + +/** + * Internal use only. + * + * @suppress + */ +public class ProvidersAppWrapperItem extends ProvidersItem { + + private final Drawable mIcon; + private final String mText; + + public ProvidersAppWrapperItem(@NonNull final Drawable icon, @NonNull final String text) { + super(FileProviderItemType.APP_WRAPPER_PHOTO_PICKER); + mIcon = icon; + mText = text; + } + + public Drawable getDrawableIcon() { + return mIcon; + } + + public String getText() { + return mText; + } + +} diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersItem.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersItem.java index 97749a19a3..408c20573b 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersItem.java +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersItem.java @@ -53,7 +53,8 @@ FileProviderItemType getType() { enum FileProviderItemType { SECTION, SEPARATOR, - APP; + APP, + APP_WRAPPER_PHOTO_PICKER; static FileProviderItemType fromOrdinal(final int ordinal) { if (ordinal >= values().length) { From 83842da86b770ee127101fbb95e135d89444f022 Mon Sep 17 00:00:00 2001 From: jackkray Date: Thu, 11 Jul 2024 10:01:18 +0200 Subject: [PATCH 11/19] feat(capture-sdk): Refactoring Fix switch issue PP-198 --- .../internal/fileimport/providerchooser/ProvidersAdapter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java index 37270307fa..6930e1b65b 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java @@ -89,6 +89,7 @@ public void onBindViewHolder(final ProvidersItemViewHolder holder, final int pos break; case APP_WRAPPER_PHOTO_PICKER: bindAppWrapperItemViewHolder((ProvidersAppItemViewHolder) holder, position); + break; case SEPARATOR: break; default: From 04eddb4674ccc9a5d0e4ab9c84a3da7d1aebbea3 Mon Sep 17 00:00:00 2001 From: jackkray Date: Thu, 11 Jul 2024 11:41:34 +0200 Subject: [PATCH 12/19] feat(capture-sdk): Fix infinite loading Empty list returns with multiply photo choosing PP-198, PM-91 --- .../internal/fileimport/FileChooserFragment.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index 16bdcea39d..937ce19def 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -168,15 +168,21 @@ class FileChooserFragment : BottomSheetDialogFragment() { pickMedia = registerForActivityResult(photoPickType) { uri -> findNavController().popBackStack() if (uri != null) { - val lst = when(uri){ + val listOfUri = when(uri){ is Uri -> listOf(uri) is List<*> -> uri.filterIsInstance().takeIf { it.size == uri.size } ?: throw IllegalArgumentException("List contains non-Uri elements") else -> throw IllegalArgumentException("uri is neither Uri nor List") } - setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.FilesSelectedUri(lst)) - }) + if (listOfUri.isNotEmpty()) { + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, FileChooserResult.FilesSelectedUri(listOfUri)) + }) + } else { + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, FileChooserResult.Cancelled) + }) + } } else { setFragmentResult(REQUEST_KEY, Bundle().apply { putParcelable(RESULT_KEY, FileChooserResult.Cancelled) From c7dd4fc7120251920dcfe843fc62d12003fb566d Mon Sep 17 00:00:00 2001 From: jackkray Date: Thu, 11 Jul 2024 13:24:32 +0200 Subject: [PATCH 13/19] refactoring(capture-sdk): Refactoring ProviderAdapter, FileChooseFragment Fix review issues with code naming, and exception throw PP-198 --- .../fileimport/FileChooserFragment.kt | 38 +++++++++++-------- .../providerchooser/ProvidersAdapter.java | 8 ++-- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index 937ce19def..486e4b242c 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -159,28 +159,34 @@ class FileChooserFragment : BottomSheetDialogFragment() { } val photoPickType = - if (FeatureConfiguration.isMultiPageEnabled()) - ActivityResultContracts.PickMultipleVisualMedia() - else + if (FeatureConfiguration.isMultiPageEnabled()) { + ActivityResultContracts.PickMultipleVisualMedia(maxItems = 10) + } else { ActivityResultContracts.PickVisualMedia() - + } pickMedia = registerForActivityResult(photoPickType) { uri -> findNavController().popBackStack() if (uri != null) { - val listOfUri = when(uri){ - is Uri -> listOf(uri) - is List<*> -> uri.filterIsInstance().takeIf { it.size == uri.size } - ?: throw IllegalArgumentException("List contains non-Uri elements") - else -> throw IllegalArgumentException("uri is neither Uri nor List") - } - if (listOfUri.isNotEmpty()) { - setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.FilesSelectedUri(listOfUri)) - }) - } else { + try { + val uriList = when(uri){ + is Uri -> listOf(uri) + is List<*> -> uri.filterIsInstance().takeIf { it.size == uri.size } + ?: throw IllegalArgumentException("List contains non-Uri elements") + else -> throw IllegalArgumentException("uri is neither Uri nor List") + } + if (uriList.isNotEmpty()) { + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, FileChooserResult.FilesSelectedUri(uriList)) + }) + } else { + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, FileChooserResult.Cancelled) + }) + } + } catch (e: IllegalArgumentException) { setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.Cancelled) + putParcelable(RESULT_KEY, FileChooserResult.Error(GiniCaptureError(GiniCaptureError.ErrorCode.DOCUMENT_IMPORT, e.message))) }) } } else { diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java index 6930e1b65b..8728015502 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/providerchooser/ProvidersAdapter.java @@ -109,9 +109,9 @@ private void bindAppItemViewHolder(@NonNull final ProvidersAppItemViewHolder hol holder.icon.setImageDrawable(item.getResolveInfo().loadIcon(mContext.getPackageManager())); holder.label.setText(item.getResolveInfo().loadLabel(mContext.getPackageManager())); holder.itemView.setOnClickListener(view -> { - final ProvidersAppItem item1 = + final ProvidersAppItem selectedItem = (ProvidersAppItem) mItems.get(holder.getAdapterPosition()); - mItemSelectedListener.onItemSelected(item1); + mItemSelectedListener.onItemSelected(selectedItem); }); } @@ -121,9 +121,9 @@ private void bindAppWrapperItemViewHolder(@NonNull final ProvidersAppItemViewHol holder.icon.setImageDrawable(item.getDrawableIcon()); holder.label.setText(item.getText()); holder.itemView.setOnClickListener(view -> { - final ProvidersAppWrapperItem item1 = + final ProvidersAppWrapperItem selectedItem = (ProvidersAppWrapperItem) mItems.get(holder.getAdapterPosition()); - mItemSelectedListener.onItemSelected(item1); + mItemSelectedListener.onItemSelected(selectedItem); }); } From 05e96a0bd45c8252c589ffec136c387dffe9c27e Mon Sep 17 00:00:00 2001 From: jackkray Date: Thu, 11 Jul 2024 17:18:30 +0200 Subject: [PATCH 14/19] refactoring(capture-sdk): Refactoring FileChooserFragment Fix review issues PP-198 --- .../fileimport/FileChooserFragment.kt | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index 486e4b242c..10987eba47 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -165,34 +165,33 @@ class FileChooserFragment : BottomSheetDialogFragment() { ActivityResultContracts.PickVisualMedia() } - pickMedia = registerForActivityResult(photoPickType) { uri -> + pickMedia = registerForActivityResult(photoPickType) { activityResultUriList -> findNavController().popBackStack() - if (uri != null) { - try { - val uriList = when(uri){ - is Uri -> listOf(uri) - is List<*> -> uri.filterIsInstance().takeIf { it.size == uri.size } - ?: throw IllegalArgumentException("List contains non-Uri elements") - else -> throw IllegalArgumentException("uri is neither Uri nor List") - } - if (uriList.isNotEmpty()) { - setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.FilesSelectedUri(uriList)) - }) - } else { - setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.Cancelled) - }) - } - } catch (e: IllegalArgumentException) { - setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.Error(GiniCaptureError(GiniCaptureError.ErrorCode.DOCUMENT_IMPORT, e.message))) - }) + val resultList = handleUriList(activityResultUriList) + setFragmentResult(REQUEST_KEY, Bundle().apply { + putParcelable(RESULT_KEY, resultList) + }) + } + } + + private fun handleUriList(activityResultUriList: Any?): FileChooserResult { + return if (activityResultUriList == null) { + FileChooserResult.Cancelled + } else { + try { + val uriList = when(activityResultUriList){ + is Uri -> listOf(activityResultUriList) + is List<*> -> activityResultUriList.filterIsInstance().takeIf { it.size == activityResultUriList.size } + ?: throw IllegalArgumentException("List contains non-Uri elements") + else -> throw IllegalArgumentException("uri is neither Uri nor List") } - } else { - setFragmentResult(REQUEST_KEY, Bundle().apply { - putParcelable(RESULT_KEY, FileChooserResult.Cancelled) - }) + if (uriList.isNotEmpty()) { + FileChooserResult.FilesSelectedUri(uriList) + } else { + FileChooserResult.Cancelled + } + } catch (e: IllegalArgumentException) { + FileChooserResult.Error(GiniCaptureError(GiniCaptureError.ErrorCode.DOCUMENT_IMPORT, e.message)) } } } From c8e1bfa4b65c36ca45613a08e36488d8cbfbfc04 Mon Sep 17 00:00:00 2001 From: jackkray Date: Fri, 12 Jul 2024 12:51:56 +0200 Subject: [PATCH 15/19] feat(capture-sdk): Add sdk version check for photo picker Use new photo picker only from API26+ PP-198 --- .../capture/internal/fileimport/FileChooserFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index 10987eba47..de8a426edf 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -213,7 +213,9 @@ class FileChooserFragment : BottomSheetDialogFragment() { val imageProviderResolveInfos = queryImageProviders(requireContext()) imageProviderItems = - if (ActivityResultContracts.PickVisualMedia.isPhotoPickerAvailable(requireContext())) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && + ActivityResultContracts.PickVisualMedia.isPhotoPickerAvailable(requireContext()) + ) { getPhotoPickerProvider() } else { getImageProviderItems(imagePickerResolveInfos, imageProviderResolveInfos) From 6438cbdaf5cc8ffe4f30c66bfe4432f493068522 Mon Sep 17 00:00:00 2001 From: jackkray Date: Mon, 22 Jul 2024 12:02:19 +0200 Subject: [PATCH 16/19] feat(capture-sdk): Add icon for photo picker PP-198 --- .../fileimport/FileChooserFragment.kt | 2 +- .../res/drawable/gc_photo_picker_app_icon.xml | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 capture-sdk/sdk/src/main/res/drawable/gc_photo_picker_app_icon.xml diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index de8a426edf..af73cbd607 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -296,7 +296,7 @@ class FileChooserFragment : BottomSheetDialogFragment() { private fun getPhotoPickerProvider(): List { val providerList = - ContextCompat.getDrawable(requireContext(), (R.drawable.gc_photo_tip_align)) + ContextCompat.getDrawable(requireContext(), (R.drawable.gc_photo_picker_app_icon)) ?.let { image -> listOf( ProvidersSectionItem(getString(R.string.gc_file_chooser_fotos_section_header)), diff --git a/capture-sdk/sdk/src/main/res/drawable/gc_photo_picker_app_icon.xml b/capture-sdk/sdk/src/main/res/drawable/gc_photo_picker_app_icon.xml new file mode 100644 index 0000000000..b0b85b2c1d --- /dev/null +++ b/capture-sdk/sdk/src/main/res/drawable/gc_photo_picker_app_icon.xml @@ -0,0 +1,30 @@ + + + + + + From fb7b804d1e92a2255a512ab2636885eb7ec14464 Mon Sep 17 00:00:00 2001 From: Alpar Szotyori Date: Tue, 6 Aug 2024 14:14:56 +0200 Subject: [PATCH 17/19] refactor(capture-sdk): Reduce line length to fix the `MaxLineLength` detekt issue PM-86 --- .../capture/internal/fileimport/FileChooserFragment.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt index af73cbd607..933241dc85 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/fileimport/FileChooserFragment.kt @@ -181,8 +181,11 @@ class FileChooserFragment : BottomSheetDialogFragment() { try { val uriList = when(activityResultUriList){ is Uri -> listOf(activityResultUriList) - is List<*> -> activityResultUriList.filterIsInstance().takeIf { it.size == activityResultUriList.size } - ?: throw IllegalArgumentException("List contains non-Uri elements") + is List<*> -> { + activityResultUriList.filterIsInstance().takeIf { + it.size == activityResultUriList.size + } ?: throw IllegalArgumentException("List contains non-Uri elements") + } else -> throw IllegalArgumentException("uri is neither Uri nor List") } if (uriList.isNotEmpty()) { From 57353e7d08e375b24e2ad50285546e66afb83686 Mon Sep 17 00:00:00 2001 From: Alpar Szotyori Date: Tue, 6 Aug 2024 14:17:06 +0200 Subject: [PATCH 18/19] feat(bank-sdk): Disable backups for example app PM-86, PM-96 --- bank-sdk/example-app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bank-sdk/example-app/src/main/AndroidManifest.xml b/bank-sdk/example-app/src/main/AndroidManifest.xml index 806bed0e97..0761fff595 100644 --- a/bank-sdk/example-app/src/main/AndroidManifest.xml +++ b/bank-sdk/example-app/src/main/AndroidManifest.xml @@ -4,7 +4,7 @@ Date: Wed, 7 Aug 2024 16:28:48 +0200 Subject: [PATCH 19/19] fix(capture-sdk): Fix degraded IBAN recognition performance when using CameraX `setTargetResolution()` has been deprecated and unfortunately also broken. For resolution selection to work again we need to use `setResolutionSelecter()`. We omitted to do that for the `ImageAnalysis` CameraX use case and this caused the preview image resolution to be too small (e.g., 720x480) for text recognition to work well. By using `setResolutionSelector()` we get a higher resolution preview image (e.g., 1440x1080) again. PM-86 --- .../capture/internal/camera/api/camerax/CameraXController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/camera/api/camerax/CameraXController.kt b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/camera/api/camerax/CameraXController.kt index f76c590713..7ba42658d4 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/camera/api/camerax/CameraXController.kt +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/internal/camera/api/camerax/CameraXController.kt @@ -135,7 +135,7 @@ internal class CameraXController(val activity: Activity) : CameraInterface { val imageAnalysis = ImageAnalysis.Builder() .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) - .setTargetResolution(targetResolution) + .setResolutionSelector(resolutionSelector) .setTargetRotation(targetRotation) .build() imageAnalysisUseCase = imageAnalysis