From e439054b1673e308335c8b4b88c4fdac24c0e132 Mon Sep 17 00:00:00 2001 From: DECEMD Date: Fri, 28 Jul 2023 15:57:44 +0300 Subject: [PATCH 1/5] =?UTF-8?q?EACQAPW-5611=20=D0=98=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F=20CVC?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=BD=D0=BE=D0=B9=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=BB=D0=B0=D1=82=D1=8B,=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=BA=D0=B5=20=D1=84=D0=BE=D0=BA=D1=83=D1=81?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/cardpay/CardPayComponent.kt | 40 ++++++++++++++++++- .../mainform/ui/MainPaymentFormActivity.kt | 14 ++++++- .../recurrent/ui/RecurrentPaymentActivity.kt | 1 + .../acquiring/sdk/utils/ViewExtUtil.kt | 24 ++++++++++- .../res/layout/acq_fragment_cvc_input.xml | 1 + 5 files changed, 75 insertions(+), 5 deletions(-) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt index 6f4caa08..f81d6554 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt @@ -1,12 +1,18 @@ package ru.tinkoff.acquiring.sdk.redesign.common.cardpay +import android.view.View +import android.view.ViewGroup import androidx.core.view.isVisible +import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input +import kotlinx.android.synthetic.main.acq_layout_choosen_card.view.cvc_container import ru.tinkoff.acquiring.sdk.R import ru.tinkoff.acquiring.sdk.databinding.AcqCardPayComponentBinding import ru.tinkoff.acquiring.sdk.models.options.screen.PaymentOptions +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.CvcComponent import ru.tinkoff.acquiring.sdk.redesign.common.emailinput.EmailInputComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.redesign.payment.ui.ChosenCardComponent +import ru.tinkoff.acquiring.sdk.ui.component.UiComponent import ru.tinkoff.acquiring.sdk.ui.customview.LoaderButton import ru.tinkoff.acquiring.sdk.utils.KeyboardVisionUtils @@ -14,23 +20,45 @@ import ru.tinkoff.acquiring.sdk.utils.KeyboardVisionUtils * Created by i.golovachev */ class CardPayComponent( + private val root: ViewGroup, + private val initingFocusAndKeyboard: Boolean = false, private val viewBinding: AcqCardPayComponentBinding, private val email: String?, private val onCvcCompleted: (String) -> Unit = {}, private val onEmailInput: (String) -> Unit = {}, private val onEmailVisibleChange: (Boolean) -> Unit = {}, private val onChooseCardClick: () -> Unit = {}, - private val onPayClick: () -> Unit = {} -) { + private val onPayClick: () -> Unit = {}, + private val onChangeCard: (CardChosenModel) -> Unit = {}, + private val onFocusCvc: View.() -> Unit = { + requestFocus() + isEnabled = true + } +): UiComponent { private val loaderButton: LoaderButton = viewBinding.loaderButton.apply { setOnClickListener { onPayClick() } } + + private val cardCvc: CvcComponent = CvcComponent( + root.findViewById(R.id.cvc_container), + initingFocusAndKeyboard, + onDataChange = { b, s -> + onCvcCompleted(s) + }, + onInitScreen = { _, function -> + if(initingFocusAndKeyboard){ + onFocusCvc(root.cvc_container.cvc_input.editText.apply(function)) + } + } + ) + private val emailInputComponent = EmailInputComponent(viewBinding.emailInput.root, onEmailChange = { onEmailInput(it) }, onEmailVisibleChange = { onEmailVisibleChange(it) } ).apply { render(EmailInputComponent.State(email, email != null)) } + private val savedCardComponent = ChosenCardComponent(viewBinding.chosenCard.root, onCvcCompleted = { cvc, _ -> onCvcCompleted(cvc) }, onChangeCard = { onChooseCardClick() } @@ -83,4 +111,12 @@ class CardPayComponent( else KeyboardVisionUtils.hideKeyboard(viewBinding.root) } + + override fun render(state: CardChosenModel) { + root.setOnClickListener { onChangeCard(state) } + } + + fun clearCvc(){ + cardCvc.render(null) + } } \ No newline at end of file diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt index 0487de65..618dd35a 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle +import android.util.Log import android.view.ViewGroup import android.view.WindowManager import android.widget.LinearLayout @@ -17,6 +18,8 @@ import androidx.core.widget.NestedScrollView import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import kotlinx.android.synthetic.main.acq_card_pay_component.view.chosenCard +import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import ru.tinkoff.acquiring.sdk.R @@ -160,6 +163,7 @@ internal class MainPaymentFormActivity : AppCompatActivity() { private val cardPayComponent by lazyUnsafe { CardPayComponent( + this.root, viewBinding = AcqCardPayComponentBinding.bind( findViewById(R.id.acq_main_card_pay) ), @@ -168,7 +172,7 @@ internal class MainPaymentFormActivity : AppCompatActivity() { onEmailInput = cardInputViewModel::email, onEmailVisibleChange = cardInputViewModel::needEmail, onChooseCardClick = viewModel::toChooseCard, - onPayClick = { cardInputViewModel.pay() } + onPayClick = { cardInputViewModel.pay() }, ) } @@ -202,6 +206,9 @@ internal class MainPaymentFormActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.acq_main_from_activity) + + root.chosenCard.cvc_input.setupCvcInput(root, cardPayComponent) + createTitleView() WindowCompat.setDecorFitsSystemWindows(window, false) @@ -234,6 +241,7 @@ internal class MainPaymentFormActivity : AppCompatActivity() { } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + //cardPayComponent.clearCvc() if (requestCode == TransparentActivity.THREE_DS_REQUEST_CODE) { if (resultCode == Activity.RESULT_OK && data != null) { val result = @@ -260,6 +268,8 @@ internal class MainPaymentFormActivity : AppCompatActivity() { viewModel.onBackPressed() } + + private suspend fun updateContent() { combine( cardInputViewModel.paymentStatus, viewModel.formContent @@ -358,6 +368,8 @@ internal class MainPaymentFormActivity : AppCompatActivity() { viewModel.mainFormNav.collect { when (it) { is MainFormNavController.Navigation.ToChooseCard -> { + //cardPayComponent.clearCvc() + Log.d("log", "subscribeOnNav") cardPayComponent.isKeyboardVisible(false) savedCards.launch(it.savedCardsOptions) } diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/recurrent/ui/RecurrentPaymentActivity.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/recurrent/ui/RecurrentPaymentActivity.kt index 486b0310..31d5d804 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/recurrent/ui/RecurrentPaymentActivity.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/recurrent/ui/RecurrentPaymentActivity.kt @@ -60,6 +60,7 @@ internal class RecurrentPaymentActivity : AppCompatActivity() { private val cardPayComponent by lazyUnsafe { CardPayComponent( + binding.root, viewBinding = binding.acqRecurrentFormPay, email = null, onCvcCompleted = rejectedViewModel::inputCvc, diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt index 07200e93..74ec8e56 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt @@ -10,8 +10,10 @@ import android.view.View import android.view.ViewGroup import android.view.ViewParent import androidx.annotation.IdRes -import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment +import kotlinx.android.synthetic.main.acq_card_pay_component.view.chosenCard +import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input +import ru.tinkoff.acquiring.sdk.redesign.common.cardpay.CardPayComponent import kotlin.math.roundToInt import kotlin.math.roundToLong @@ -114,6 +116,21 @@ internal fun ViewGroup.forEachChild(action: (child: View) -> Unit) { } } +internal fun View.setupCvcInput(viewGroup: ViewGroup, cardPayComponent: CardPayComponent) { + val inputField = viewGroup.chosenCard.cvc_input + val inputEditText = viewGroup.chosenCard.cvc_input.editText + + listOf(this, inputField, inputEditText).forEach { view -> + view.apply { + setOnClickListener { + requestFocus() + isEnabled = true + cardPayComponent.clearCvc() + } + } + } +} + internal fun lerp(start: Int, end: Int, fraction: Float): Int { return (start + (end - start) * fraction).roundToInt() } @@ -133,4 +150,7 @@ internal fun Fragment.lazyView(@IdRes id: Int): Lazy = lazyUnsafe { requireView().findViewById(id) } internal fun Activity.lazyView(@IdRes id: Int): Lazy = - lazyUnsafe { findViewById(id) } \ No newline at end of file + lazyUnsafe { findViewById(id) } + +internal fun Activity.lazyView(id: View): Lazy = + lazyUnsafe { this.findViewById(id.id) } \ No newline at end of file diff --git a/ui/src/main/res/layout/acq_fragment_cvc_input.xml b/ui/src/main/res/layout/acq_fragment_cvc_input.xml index bebc8e0b..efc0b18b 100644 --- a/ui/src/main/res/layout/acq_fragment_cvc_input.xml +++ b/ui/src/main/res/layout/acq_fragment_cvc_input.xml @@ -8,4 +8,5 @@ android:minWidth="64dp" android:minHeight="48dp" android:gravity="center" + android:duplicateParentState="true" app:acq_title="@string/acq_label_card_secure" /> \ No newline at end of file From d2e751280b34d89f52e3f0e30ce8db66ef578681 Mon Sep 17 00:00:00 2001 From: DECEMD Date: Mon, 31 Jul 2023 16:12:51 +0300 Subject: [PATCH 2/5] =?UTF-8?q?EACQAPW-5611=20=D0=98=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F=20CVC?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=BD=D0=BE=D0=B9=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=BB=D0=B0=D1=82=D1=8B,=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=BA=D0=B5=20=D1=84=D0=BE=D0=BA=D1=83=D1=81?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D1=82=D1=81=D1=8F-v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redesign/mainform/ui/MainPaymentFormActivity.kt | 10 ++++------ .../java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt index 618dd35a..e6449588 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/mainform/ui/MainPaymentFormActivity.kt @@ -5,7 +5,6 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle -import android.util.Log import android.view.ViewGroup import android.view.WindowManager import android.widget.LinearLayout @@ -207,7 +206,7 @@ internal class MainPaymentFormActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.acq_main_from_activity) - root.chosenCard.cvc_input.setupCvcInput(root, cardPayComponent) + initCvcClickListener(root, cardPayComponent) createTitleView() WindowCompat.setDecorFitsSystemWindows(window, false) @@ -241,7 +240,6 @@ internal class MainPaymentFormActivity : AppCompatActivity() { } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - //cardPayComponent.clearCvc() if (requestCode == TransparentActivity.THREE_DS_REQUEST_CODE) { if (resultCode == Activity.RESULT_OK && data != null) { val result = @@ -268,7 +266,9 @@ internal class MainPaymentFormActivity : AppCompatActivity() { viewModel.onBackPressed() } - + private fun initCvcClickListener(root: ViewGroup, card: CardPayComponent){ + root.chosenCard.cvc_input.setupCvcInput(root, card) + } private suspend fun updateContent() { combine( @@ -368,8 +368,6 @@ internal class MainPaymentFormActivity : AppCompatActivity() { viewModel.mainFormNav.collect { when (it) { is MainFormNavController.Navigation.ToChooseCard -> { - //cardPayComponent.clearCvc() - Log.d("log", "subscribeOnNav") cardPayComponent.isKeyboardVisible(false) savedCards.launch(it.savedCardsOptions) } diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt index 74ec8e56..07b2904c 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/utils/ViewExtUtil.kt @@ -152,5 +152,5 @@ internal fun Fragment.lazyView(@IdRes id: Int): Lazy = internal fun Activity.lazyView(@IdRes id: Int): Lazy = lazyUnsafe { findViewById(id) } -internal fun Activity.lazyView(id: View): Lazy = - lazyUnsafe { this.findViewById(id.id) } \ No newline at end of file +internal fun Activity.lazyView(view: View): Lazy = + lazyUnsafe { this.findViewById(view.id) } \ No newline at end of file From b499716e28eb4372c993efd3cc9f8c6769d4d0a0 Mon Sep 17 00:00:00 2001 From: DECEMD Date: Wed, 2 Aug 2023 12:34:24 +0300 Subject: [PATCH 3/5] =?UTF-8?q?EACQAPW-5611=20=D0=98=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F=20CVC?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=BD=D0=BE=D0=B9=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=BB=D0=B0=D1=82=D1=8B,=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=BA=D0=B5=20=D1=84=D0=BE=D0=BA=D1=83=D1=81?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D1=82=D1=81=D1=8F-v3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/carddatainput/CvcComponent.kt | 2 +- .../carddatainput/EnhancedCvcComponent.kt | 49 +++++++++++++++++++ .../common/cardpay/CardPayComponent.kt | 16 +++--- .../payment/ui/ChosenCardComponent.kt | 19 +++---- 4 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/CvcComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/CvcComponent.kt index 8cc35467..2fd526b9 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/CvcComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/CvcComponent.kt @@ -24,7 +24,7 @@ class CvcComponent( private val onInitScreen: (Boolean, View.() -> Unit) -> Unit = { _, function -> } ) : UiComponent { - private val cvcInput: AcqTextFieldView = root.findViewById(R.id.cvc_input) + internal val cvcInput: AcqTextFieldView = root.findViewById(R.id.cvc_input) val cvc get() = cvcInput.text.orEmpty() init { diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt new file mode 100644 index 00000000..a9795702 --- /dev/null +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt @@ -0,0 +1,49 @@ +package ru.tinkoff.acquiring.sdk.redesign.common.carddatainput + +import android.view.View +import android.view.ViewGroup +import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input +import ru.tinkoff.acquiring.sdk.ui.component.UiComponent + +interface CvcUIComponent : UiComponent { + fun clearCvc() + fun enableCvc(isEnabled: Boolean) +} + +class EnhancedCvcComponent( + private val root: ViewGroup, + private val initingFocusAndKeyboard: Boolean, + private val onFocusCvc: View.() -> Unit, + onInputComplete: (String) -> Unit, + onDataChange: (Boolean, String) -> Unit +) : CvcUIComponent { + + private val cvcComponent: CvcComponent = CvcComponent( + root, + initingFocusAndKeyboard, + onInputComplete, + onDataChange, + onInitScreen = { _, function -> + if(initingFocusAndKeyboard){ + onFocusCvc(root.cvc_input.editText.apply(function)) + } + } + ) + + override fun clearCvc() { + cvcComponent.render(null) + } + + override fun enableCvc(isEnabled: Boolean) = cvcComponent.enable(isEnabled) + + fun enable(isEnable: Boolean) = with(cvcComponent.cvcInput) { + isEnabled = isEnable + editable = isEnable + if (isEnable.not()) { + hideKeyboard() + } + } + + override fun render(state: String?) = cvcComponent.render(state) + +} \ No newline at end of file diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt index f81d6554..aaa0e185 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt @@ -3,12 +3,10 @@ package ru.tinkoff.acquiring.sdk.redesign.common.cardpay import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible -import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input -import kotlinx.android.synthetic.main.acq_layout_choosen_card.view.cvc_container import ru.tinkoff.acquiring.sdk.R import ru.tinkoff.acquiring.sdk.databinding.AcqCardPayComponentBinding import ru.tinkoff.acquiring.sdk.models.options.screen.PaymentOptions -import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.CvcComponent +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.EnhancedCvcComponent import ru.tinkoff.acquiring.sdk.redesign.common.emailinput.EmailInputComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.redesign.payment.ui.ChosenCardComponent @@ -39,19 +37,19 @@ class CardPayComponent( setOnClickListener { onPayClick() } } - private val cardCvc: CvcComponent = CvcComponent( + private val cardCvc: EnhancedCvcComponent = EnhancedCvcComponent( root.findViewById(R.id.cvc_container), initingFocusAndKeyboard, - onDataChange = { b, s -> + onFocusCvc, + onInputComplete = { s -> onCvcCompleted(s) }, - onInitScreen = { _, function -> - if(initingFocusAndKeyboard){ - onFocusCvc(root.cvc_container.cvc_input.editText.apply(function)) - } + onDataChange = { b, s -> + onCvcCompleted(s) } ) + private val emailInputComponent = EmailInputComponent(viewBinding.emailInput.root, onEmailChange = { onEmailInput(it) }, onEmailVisibleChange = { onEmailVisibleChange(it) } diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt index d8dd4d98..1645d7d0 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt @@ -5,10 +5,8 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.core.view.isVisible -import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input -import kotlinx.android.synthetic.main.acq_layout_choosen_card.view.cvc_container import ru.tinkoff.acquiring.sdk.R -import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.CvcComponent +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.EnhancedCvcComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.ui.component.UiComponent import ru.tinkoff.acquiring.sdk.viewmodel.CardLogoProvider @@ -31,16 +29,15 @@ internal class ChosenCardComponent( private val cardLogo: ImageView = root.findViewById(R.id.acq_card_choosen_item_logo) private val cardName: TextView = root.findViewById(R.id.acq_card_choosen_item) private val cardChange: TextView = root.findViewById(R.id.acq_card_change) - private val cardCvc: CvcComponent = CvcComponent( + private val cardCvc: EnhancedCvcComponent = EnhancedCvcComponent( root.findViewById(R.id.cvc_container), initingFocusAndKeyboard, + onFocusCvc, + onInputComplete = { s -> + onCvcCompleted(s, true) + }, onDataChange = { b, s -> onCvcCompleted(s, b) - }, - onInitScreen = { _, function -> - if(initingFocusAndKeyboard){ - onFocusCvc(root.cvc_container.cvc_input.editText.apply(function)) - } } ) @@ -68,8 +65,4 @@ internal class ChosenCardComponent( fun enableCvc(isEnable: Boolean) { cardCvc.enable(isEnable) } - - fun showKeyboard() { - - } } \ No newline at end of file From 84fabd2d4f673ea2958b57c004f32b974790e769 Mon Sep 17 00:00:00 2001 From: DECEMD Date: Thu, 3 Aug 2023 10:25:39 +0300 Subject: [PATCH 4/5] =?UTF-8?q?EACQAPW-5611=20=D0=A0=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=B9=D0=BC=20=D1=84=D0=B0=D1=81=D0=B0=D0=B4=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0=20CVC=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BD=D1=8F=D1=82=D0=BD=D1=8B=D0=B9=20=D0=B8=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D1=8B=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{EnhancedCvcComponent.kt => FocusAtStartCvcComponent.kt} | 2 +- .../acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt | 4 ++-- .../acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/{EnhancedCvcComponent.kt => FocusAtStartCvcComponent.kt} (97%) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusAtStartCvcComponent.kt similarity index 97% rename from ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt rename to ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusAtStartCvcComponent.kt index a9795702..206aa26b 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/EnhancedCvcComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusAtStartCvcComponent.kt @@ -10,7 +10,7 @@ interface CvcUIComponent : UiComponent { fun enableCvc(isEnabled: Boolean) } -class EnhancedCvcComponent( +class FocusAtStartCvcComponent( private val root: ViewGroup, private val initingFocusAndKeyboard: Boolean, private val onFocusCvc: View.() -> Unit, diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt index aaa0e185..b67107b8 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt @@ -6,7 +6,7 @@ import androidx.core.view.isVisible import ru.tinkoff.acquiring.sdk.R import ru.tinkoff.acquiring.sdk.databinding.AcqCardPayComponentBinding import ru.tinkoff.acquiring.sdk.models.options.screen.PaymentOptions -import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.EnhancedCvcComponent +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.FocusAtStartCvcComponent import ru.tinkoff.acquiring.sdk.redesign.common.emailinput.EmailInputComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.redesign.payment.ui.ChosenCardComponent @@ -37,7 +37,7 @@ class CardPayComponent( setOnClickListener { onPayClick() } } - private val cardCvc: EnhancedCvcComponent = EnhancedCvcComponent( + private val cardCvc: FocusAtStartCvcComponent = FocusAtStartCvcComponent( root.findViewById(R.id.cvc_container), initingFocusAndKeyboard, onFocusCvc, diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt index 1645d7d0..6c9f7141 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt @@ -6,7 +6,7 @@ import android.widget.ImageView import android.widget.TextView import androidx.core.view.isVisible import ru.tinkoff.acquiring.sdk.R -import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.EnhancedCvcComponent +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.FocusAtStartCvcComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.ui.component.UiComponent import ru.tinkoff.acquiring.sdk.viewmodel.CardLogoProvider @@ -29,7 +29,7 @@ internal class ChosenCardComponent( private val cardLogo: ImageView = root.findViewById(R.id.acq_card_choosen_item_logo) private val cardName: TextView = root.findViewById(R.id.acq_card_choosen_item) private val cardChange: TextView = root.findViewById(R.id.acq_card_change) - private val cardCvc: EnhancedCvcComponent = EnhancedCvcComponent( + private val cardCvc: FocusAtStartCvcComponent = FocusAtStartCvcComponent( root.findViewById(R.id.cvc_container), initingFocusAndKeyboard, onFocusCvc, From 12b4b5e0cdcb8aede605a34cd0a605346761ef17 Mon Sep 17 00:00:00 2001 From: DECEMD Date: Fri, 4 Aug 2023 13:40:59 +0300 Subject: [PATCH 5/5] =?UTF-8?q?EACQAPW-5611=20=D0=A0=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=B9=D0=BC=20=D1=84=D0=B0=D1=81=D0=B0=D0=B4=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0=20CVC=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BD=D1=8F=D1=82=D0=BD=D1=8B=D0=B9=20=D0=B8=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D1=8B=D0=B9-v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...usAtStartCvcComponent.kt => FocusDecoratorCvcComponent.kt} | 2 +- .../acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt | 4 ++-- .../acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/{FocusAtStartCvcComponent.kt => FocusDecoratorCvcComponent.kt} (97%) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusAtStartCvcComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusDecoratorCvcComponent.kt similarity index 97% rename from ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusAtStartCvcComponent.kt rename to ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusDecoratorCvcComponent.kt index 206aa26b..0b7b9c12 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusAtStartCvcComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusDecoratorCvcComponent.kt @@ -10,7 +10,7 @@ interface CvcUIComponent : UiComponent { fun enableCvc(isEnabled: Boolean) } -class FocusAtStartCvcComponent( +class FocusDecoratorCvcComponent( private val root: ViewGroup, private val initingFocusAndKeyboard: Boolean, private val onFocusCvc: View.() -> Unit, diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt index b67107b8..d282f390 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/common/cardpay/CardPayComponent.kt @@ -6,7 +6,7 @@ import androidx.core.view.isVisible import ru.tinkoff.acquiring.sdk.R import ru.tinkoff.acquiring.sdk.databinding.AcqCardPayComponentBinding import ru.tinkoff.acquiring.sdk.models.options.screen.PaymentOptions -import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.FocusAtStartCvcComponent +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.FocusDecoratorCvcComponent import ru.tinkoff.acquiring.sdk.redesign.common.emailinput.EmailInputComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.redesign.payment.ui.ChosenCardComponent @@ -37,7 +37,7 @@ class CardPayComponent( setOnClickListener { onPayClick() } } - private val cardCvc: FocusAtStartCvcComponent = FocusAtStartCvcComponent( + private val cardCvc: FocusDecoratorCvcComponent = FocusDecoratorCvcComponent( root.findViewById(R.id.cvc_container), initingFocusAndKeyboard, onFocusCvc, diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt index 6c9f7141..3c9b3cf5 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/redesign/payment/ui/ChosenCardComponent.kt @@ -6,7 +6,7 @@ import android.widget.ImageView import android.widget.TextView import androidx.core.view.isVisible import ru.tinkoff.acquiring.sdk.R -import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.FocusAtStartCvcComponent +import ru.tinkoff.acquiring.sdk.redesign.common.carddatainput.FocusDecoratorCvcComponent import ru.tinkoff.acquiring.sdk.redesign.payment.model.CardChosenModel import ru.tinkoff.acquiring.sdk.ui.component.UiComponent import ru.tinkoff.acquiring.sdk.viewmodel.CardLogoProvider @@ -29,7 +29,7 @@ internal class ChosenCardComponent( private val cardLogo: ImageView = root.findViewById(R.id.acq_card_choosen_item_logo) private val cardName: TextView = root.findViewById(R.id.acq_card_choosen_item) private val cardChange: TextView = root.findViewById(R.id.acq_card_change) - private val cardCvc: FocusAtStartCvcComponent = FocusAtStartCvcComponent( + private val cardCvc: FocusDecoratorCvcComponent = FocusDecoratorCvcComponent( root.findViewById(R.id.cvc_container), initingFocusAndKeyboard, onFocusCvc,