From ff0098856506e7070f044303aa296180d24a50a0 Mon Sep 17 00:00:00 2001 From: IrynaTsymbaliuk Date: Wed, 6 Apr 2022 13:24:40 +0400 Subject: [PATCH] Added test variable --- .../mysterium/vpn/ui/base/BaseViewModel.kt | 5 +- .../up/card/currency/CardCurrencyActivity.kt | 133 ------------------ .../up/card/summary/CardSummaryActivity.kt | 2 +- 3 files changed, 5 insertions(+), 135 deletions(-) delete mode 100644 android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/currency/CardCurrencyActivity.kt diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt index e3f900ecf..f4e806dfc 100644 --- a/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt +++ b/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt @@ -141,6 +141,9 @@ class BaseViewModel(useCaseProvider: UseCaseProvider) : ViewModel() { .getGateways() .map { Gateway.from(it.name) } .toMutableList() - .apply { remove(Gateway.PAYPAL) } + .apply { + add(Gateway.CARDINITY) // for testing purpose only + remove(Gateway.PAYPAL) + } } } diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/currency/CardCurrencyActivity.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/currency/CardCurrencyActivity.kt deleted file mode 100644 index f3f408f6d..000000000 --- a/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/currency/CardCurrencyActivity.kt +++ /dev/null @@ -1,133 +0,0 @@ -package updated.mysterium.vpn.ui.top.up.card.currency - -import android.content.Intent -import android.os.Bundle -import android.util.Log -import android.view.View -import network.mysterium.vpn.R -import network.mysterium.vpn.databinding.ActivityCardCurrencyBinding -import org.koin.android.ext.android.inject -import updated.mysterium.vpn.common.countries.CountriesUtil -import updated.mysterium.vpn.common.extensions.onItemSelected -import updated.mysterium.vpn.model.top.up.CurrencyCardItem -import updated.mysterium.vpn.ui.base.BaseActivity -import updated.mysterium.vpn.ui.top.up.card.summary.CardSummaryActivity -import updated.mysterium.vpn.ui.top.up.card.summary.HintSpinnerArrayAdapter - -class CardCurrencyActivity : BaseActivity() { - - companion object { - const val CRYPTO_AMOUNT_EXTRA_KEY = "CRYPTO_AMOUNT_EXTRA_KEY" - private const val TAG = "CardCurrencyActivity" - } - - private lateinit var binding: ActivityCardCurrencyBinding - private val viewModel: CardCurrencyViewModel by inject() - private val adapter = CardCurrencyAdapter() - private var selectedCountry: String? = null - set(value) { - field = value - checkValidData() - } - private var selectedCurrency: String? = null - set(value) { - field = value - checkValidData() - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityCardCurrencyBinding.inflate(layoutInflater) - setContentView(binding.root) - configure() - bind() - } - - private fun configure() { - setUpCountriesSpinner() - setUpCurrencies() - } - - private fun bind() { - binding.confirmButton.setOnClickListener { - navigateToSummary() - } - binding.backButton.setOnClickListener { - finish() - } - } - - private fun setUpCurrencies() { - viewModel.getCurrencies().observe(this) { - it.onSuccess { currencies -> - currencies?.let { - inflateCurrencies(currencies) - } - } - - it.onFailure { error -> - Log.e(TAG, error.localizedMessage ?: error.toString()) - } - } - } - - private fun setUpCountriesSpinner() { - val countriesList = CountriesUtil.getAllPaymentCountries() - val hintItem = getString(R.string.card_payment_country_hint) - val countriesAdapterItems: List = mutableListOf(hintItem).apply { - addAll( - countriesList.map { - it.fullName - } - ) - } - val spinnerAdapter = HintSpinnerArrayAdapter( - this, - R.layout.item_spinner_payment_country, - countriesAdapterItems - ) - binding.countriesSpinner.apply { - binding.countrySpinnerFrame.setOnClickListener { - performClick() - } - adapter = spinnerAdapter - onItemSelected { position -> - spinnerAdapter.selectedPosition = position - if (position != 0) { - val countryFullName = countriesAdapterItems[position] - countriesList.find { - it.fullName == countryFullName - }?.code?.let { countryCode -> - selectedCountry = countryCode - } - } - } - } - } - - private fun inflateCurrencies(currencies: List) { - adapter.replaceAll(currencies) - adapter.onItemSelected = { - selectedCurrency = it.currency - } - binding.currenciesRecyclerView.adapter = adapter - } - - private fun checkValidData() { - if (selectedCountry != null && selectedCurrency != null) { - binding.confirmButton.isEnabled = true - binding.confirmButtonShadow.visibility = View.VISIBLE - } - } - - private fun navigateToSummary() { - intent.extras?.getInt(CRYPTO_AMOUNT_EXTRA_KEY)?.let { mystAmount -> - val intent = Intent(this, CardSummaryActivity::class.java).apply { - putExtra(CardSummaryActivity.CRYPTO_AMOUNT_EXTRA_KEY, mystAmount) - putExtra(CardSummaryActivity.CRYPTO_CURRENCY_EXTRA_KEY, selectedCurrency) - putExtra(CardSummaryActivity.COUNTRY_EXTRA_KEY, selectedCountry) - } - startActivity(intent) - } - } -} diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/summary/CardSummaryActivity.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/summary/CardSummaryActivity.kt index 6d0e0f16e..605d15b97 100644 --- a/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/summary/CardSummaryActivity.kt +++ b/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/summary/CardSummaryActivity.kt @@ -37,7 +37,7 @@ class CardSummaryActivity : BaseActivity() { finish() } binding.confirmButton.setOnClickListener { - viewModel.billingDataSource.launchBillingFlow(this@CardSummaryActivity, "10_usd") + viewModel.billingDataSource.launchBillingFlow(this@CardSummaryActivity, "test") } binding.cancelButton.setOnClickListener { navigateToHome()