From ca54706f45bdc4cddc7b1fa7c072db76ffe100d7 Mon Sep 17 00:00:00 2001 From: Fabian Bender <91562175+Fabtron@users.noreply.github.com> Date: Tue, 7 Jan 2025 08:11:26 +0100 Subject: [PATCH 1/3] Add camera permission granted listener (#234) --- CHANGELOG.md | 1 + .../java/io/snabble/sdk/ui/scanner/SelfScanningFragment.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 997fbb2919..0e95bbe671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## UNRELEASED ### Added +* ui: Add listener to `SelfScanningFragment` to react to camera permission changes ### Changed ### Removed ### Fixed diff --git a/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningFragment.kt b/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningFragment.kt index a158632cb3..71484d820e 100644 --- a/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningFragment.kt +++ b/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningFragment.kt @@ -58,6 +58,7 @@ open class SelfScanningFragment : BaseFragment(), MenuProvider { createSelfScanningView() requireView().announceForAccessibility(getString(R.string.Snabble_Scanner_Accessibility_eventBackInScanner)) explainScanner() + onCameraPermissionGrantedListener?.invoke() } else { canAskAgain = ActivityCompat.shouldShowRequestPermissionRationale( requireActivity(), @@ -67,6 +68,11 @@ open class SelfScanningFragment : BaseFragment(), MenuProvider { } } + /** + * Add a listener to get notified if the camera permission has been granted + */ + var onCameraPermissionGrantedListener: (() -> Unit)? = null + override fun onCreateActualView( inflater: LayoutInflater, container: ViewGroup?, From 263172488d35e7f041335740282d3571fc115f48 Mon Sep 17 00:00:00 2001 From: Fabian Bender <91562175+Fabtron@users.noreply.github.com> Date: Tue, 7 Jan 2025 08:35:27 +0100 Subject: [PATCH 2/3] Receive origin type from paymentMethodDescriptor (Apps-888) (#235) --- CHANGELOG.md | 1 + .../sdk/checkout/DefaultCheckoutApi.kt | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e95bbe671..e15e0791f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## UNRELEASED ### Added * ui: Add listener to `SelfScanningFragment` to react to camera permission changes +* core: Receive origin type from `PaymentMethodDesricptor` in case it is not set by default ### Changed ### Removed ### Fixed diff --git a/core/src/main/java/io/snabble/sdk/checkout/DefaultCheckoutApi.kt b/core/src/main/java/io/snabble/sdk/checkout/DefaultCheckoutApi.kt index 28bd188a60..1e7e864daf 100644 --- a/core/src/main/java/io/snabble/sdk/checkout/DefaultCheckoutApi.kt +++ b/core/src/main/java/io/snabble/sdk/checkout/DefaultCheckoutApi.kt @@ -11,7 +11,6 @@ import okhttp3.* import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.toRequestBody import java.io.IOException -import java.lang.Exception import java.net.HttpURLConnection.HTTP_CONFLICT import java.net.HttpURLConnection.HTTP_FORBIDDEN import java.net.HttpURLConnection.HTTP_NOT_FOUND @@ -209,6 +208,9 @@ class DefaultCheckoutApi(private val project: Project, } } + val originType = paymentCredentials?.type?.originType + ?: getOriginTypeFromPaymentMethodDescriptor(paymentMethod = paymentMethod) + val checkoutProcessRequest = CheckoutProcessRequest( paymentMethod = paymentMethod, signedCheckoutInfo = signedCheckoutInfo, @@ -217,22 +219,24 @@ class DefaultCheckoutApi(private val project: Project, paymentInformation = when (paymentCredentials?.type) { PaymentCredentials.Type.EXTERNAL_BILLING -> { PaymentInformation( - originType = paymentCredentials.type?.originType, + originType = originType, encryptedOrigin = paymentCredentials.encryptedData, subject = paymentCredentials.additionalData["subject"] ) } + PaymentCredentials.Type.CREDIT_CARD_PSD2 -> { PaymentInformation( - originType = paymentCredentials.type?.originType, + originType = originType, encryptedOrigin = paymentCredentials.encryptedData, validUntil = SimpleDateFormat("yyyy/MM/dd").format(Date(paymentCredentials.validTo)), cardNumber = paymentCredentials.obfuscatedId, ) } + PaymentCredentials.Type.GIROPAY -> { PaymentInformation( - originType = paymentCredentials.type?.originType, + originType = originType, encryptedOrigin = paymentCredentials.encryptedData, deviceID = paymentCredentials.additionalData["deviceID"], deviceName = paymentCredentials.additionalData["deviceName"], @@ -243,7 +247,7 @@ class DefaultCheckoutApi(private val project: Project, null -> null else -> { PaymentInformation( - originType = paymentCredentials.type?.originType, + originType = originType, encryptedOrigin = paymentCredentials.encryptedData ) } @@ -320,7 +324,14 @@ class DefaultCheckoutApi(private val project: Project, }) } + private fun getOriginTypeFromPaymentMethodDescriptor(paymentMethod: PaymentMethod): String? = + project.paymentMethodDescriptors + .firstOrNull { it.paymentMethod == paymentMethod } + ?.acceptedOriginTypes + ?.get(0) + companion object { + private val JSON: MediaType = "application/json".toMediaType() } } From f2b61804a423d29ead265a6a8fef433b84c6397c Mon Sep 17 00:00:00 2001 From: Fabian Bender <91562175+Fabtron@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:06:37 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15e0791f2..2103afe157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,15 @@ All notable changes to this project will be documented in this file. ## UNRELEASED ### Added -* ui: Add listener to `SelfScanningFragment` to react to camera permission changes -* core: Receive origin type from `PaymentMethodDesricptor` in case it is not set by default ### Changed ### Removed ### Fixed +## [0.80.3] +### Added +* ui: Add listener to `SelfScanningFragment` to react to camera permission changes +* core: Receive origin type from `PaymentMethodDesricptor` in case it is not set by default + ## [0.80.2] ### Fixed * ui: Add missing focus to the product search field after opening the `ProductSearchView`