From 03bc7b8c7a5e950125245be70397f6439f49a8a6 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Fri, 20 Sep 2024 19:44:00 +0530 Subject: [PATCH 1/4] SK-1691 Fix bug in card brand choice --- Skyflow/src/main/kotlin/Skyflow/TextField.kt | 23 +++++++++++++------ .../com/Skyflow/CardBrandChoiceActivity.kt | 8 +++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Skyflow/src/main/kotlin/Skyflow/TextField.kt b/Skyflow/src/main/kotlin/Skyflow/TextField.kt index bb1884c..b7b1e7d 100644 --- a/Skyflow/src/main/kotlin/Skyflow/TextField.kt +++ b/Skyflow/src/main/kotlin/Skyflow/TextField.kt @@ -84,6 +84,7 @@ class TextField @JvmOverloads constructor( internal var cardType = CardType.EMPTY internal var isCustomCardBrandSelected = false + private var isCardMetadataUpdated = false private var dAWidth = 0 private var cIWidth = 0 @@ -282,6 +283,14 @@ class TextField @JvmOverloads constructor( } } + private fun invokeUserOnChangeListener() { + if (userOnchangeListener !== null) { + userOnchangeListener?.let { + it((state as StateforText).getState(optionsForLogging.env)) + } + } + } + fun on(eventName: EventName, handler: (state: JSONObject) -> Unit) { when (eventName) { EventName.CHANGE -> this.userOnchangeListener = handler @@ -307,8 +316,12 @@ class TextField @JvmOverloads constructor( } fun update(updateCollectOptions: CollectElementOptions) { + isCardMetadataUpdated = true this.options.cardMetadata = updateCollectOptions.cardMetadata this.setupField(this.collectInput, this.options) + if (updateCollectOptions.cardMetadata.scheme.size < 2) { + invokeUserOnChangeListener() + } } @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -358,12 +371,7 @@ class TextField @JvmOverloads constructor( } else if (options.enableCopy) { removeIcon() } - - if (userOnchangeListener !== null) { - userOnchangeListener?.let { - it((state as StateforText).getState(optionsForLogging.env)) - } - } + invokeUserOnChangeListener() onBeginEditing?.invoke() } @@ -412,7 +420,7 @@ class TextField @JvmOverloads constructor( var icons = arrayOf(cardImage) var layerDrawable = LayerDrawable(icons) - if (options.cardMetadata.scheme.size > 1) { + if (isCardMetadataUpdated && options.cardMetadata.scheme.size > 1) { icons = arrayOf(cardImage, dropdownArrow) layerDrawable = LayerDrawable(icons) layerDrawable.setLayerInset(0, 0, 0, dAWidth, 0) @@ -443,6 +451,7 @@ class TextField @JvmOverloads constructor( updateCardChoice(selectedCardType, true) changeCardIcon(selectedCardType) inputField.setSelection(inputField.length()) + invokeUserOnChangeListener() true } diff --git a/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt b/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt index dbe4cb2..cf6c449 100644 --- a/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt +++ b/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt @@ -103,16 +103,16 @@ class CardBrandChoiceActivity : AppCompatActivity() { val cvv = collectContainer.create(this, cvvInput) cardNumber.on(EventName.FOCUS) { state -> - Log.d(TAG, "focus: sate $state") + Log.d(TAG, "focus: state $state") } cardNumber.on(EventName.BLUR) { state -> - Log.d(TAG, "blur: sate $state") + Log.d(TAG, "blur: state $state") } var calledUpdate = false cardNumber.on(EventName.CHANGE) { state -> - Log.d(TAG, "change: sate $state") + Log.d(TAG, "change: state $state") val value = state.getString("value") if (value.length < 8 && calledUpdate) { calledUpdate = false @@ -138,7 +138,7 @@ class CardBrandChoiceActivity : AppCompatActivity() { } cardNumber.on(EventName.READY) { state -> - Log.d(TAG, "ready: sate $state") + Log.d(TAG, "ready: state $state") } val parent = findViewById(R.id.parent) From b4bdf820929e1c43cee550c271523747fe116eae Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Tue, 24 Sep 2024 12:35:27 +0530 Subject: [PATCH 2/4] SK-1691 Update sample for card brand choice feature --- .../java/com/Skyflow/CardBrandChoiceActivity.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt b/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt index cf6c449..b6d3217 100644 --- a/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt +++ b/samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt @@ -110,19 +110,17 @@ class CardBrandChoiceActivity : AppCompatActivity() { Log.d(TAG, "blur: state $state") } - var calledUpdate = false + var scheme = arrayOf() cardNumber.on(EventName.CHANGE) { state -> Log.d(TAG, "change: state $state") val value = state.getString("value") - if (value.length < 8 && calledUpdate) { - calledUpdate = false - cardNumber.update(CollectElementOptions(cardMetadata = CardMetadata(arrayOf()))) - } else if (value.length >= 8 && !calledUpdate) { - calledUpdate = true + if (value.length < 8 && scheme.isNotEmpty()) { + scheme = arrayOf() + cardNumber.update(CollectElementOptions(cardMetadata = CardMetadata(scheme))) + } else if (value.length >= 8 && scheme.isEmpty()) { binLookup(value, object : Callback { override fun onSuccess(responseBody: Any) { - println(responseBody as JSONArray) - val scheme = getCardSchemes(responseBody) + scheme = getCardSchemes(responseBody as JSONArray) runOnUiThread(kotlinx.coroutines.Runnable { cardNumber.update( CollectElementOptions(cardMetadata = CardMetadata(scheme)) From 76c6e42296a6b370dc9a244cf89576489bf033e4 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Wed, 11 Dec 2024 08:34:14 +0000 Subject: [PATCH 3/4] [AUTOMATED] Private Release 1.25.0-dev.7d29da5 --- Skyflow/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Skyflow/build.gradle b/Skyflow/build.gradle index 405af66..c24cb19 100644 --- a/Skyflow/build.gradle +++ b/Skyflow/build.gradle @@ -10,7 +10,7 @@ ext { mGroupId = "com.skyflowapi.android" mArtifactId = "skyflow-android-sdk" mVersionCode = 1 - mVersionName = "1.25.0" + mVersionName = "1.25.0-dev.7d29da5" mLibraryName = "skyflow-android" mLibraryDescription = "Skyflow’s android SDK can be used to securely collect, tokenize, and display sensitive data in the mobile without exposing your front-end infrastructure to sensitive data." From fd79b174bf32443ec6399da113b89db475ec1599 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Thu, 9 Jan 2025 17:47:39 +0530 Subject: [PATCH 4/4] SK-1691 Update changelog --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25c3ed0..c8a2166 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,17 @@ All notable changes to this project will be documented in this file. -## [1.24.1] - 2024-09-09 +## [1.25.1] - 2025-01-09 +### Fixed +- Fixed `onChange` listener not firing in card brand choice dropdown selection. + +## [1.25.0] - 2024-09-11 ### Added -- Fixed element state for card brand choice +- Updated error messages for various scenarios. + +## [1.24.1] - 2024-09-09 +### Fixed +- Fixed element state for card brand choice. ## [1.24.0] - 2024-09-03 ### Added