From 65984146294908203d389b7ca39cdd182c371639 Mon Sep 17 00:00:00 2001 From: "I.Tsymbaliuk" Date: Mon, 7 Feb 2022 19:11:06 +0300 Subject: [PATCH 1/3] Added payment processing banner --- .../up/card/summary/CardSummaryActivity.kt | 34 +++++++++-- .../src/main/res/drawable/icon_clock_five.xml | 16 ++++++ .../main/res/drawable/icon_close_top_up.xml | 12 ++++ .../main/res/layout/activity_card_summary.xml | 5 ++ .../layout/item_payment_processing_banner.xml | 56 +++++++++++++++++++ android/app/src/main/res/values/colors.xml | 3 + android/app/src/main/res/values/strings.xml | 4 ++ android/app/src/main/res/values/styles.xml | 8 +++ 8 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 android/app/src/main/res/drawable/icon_clock_five.xml create mode 100644 android/app/src/main/res/drawable/icon_close_top_up.xml create mode 100644 android/app/src/main/res/layout/item_payment_processing_banner.xml 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 71161852b..fde70943d 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 @@ -1,5 +1,6 @@ package updated.mysterium.vpn.ui.top.up.card.summary +import android.animation.ObjectAnimator import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle @@ -30,6 +31,7 @@ class CardSummaryActivity : BaseActivity() { private const val TAG = "CardSummaryActivity" private const val HTML_MIME_TYPE = "text/html" private const val ENCODING = "utf-8" + private const val paymentCallbackUrl = "https://checkout.cardinity.com/callback/" } private lateinit var binding: ActivityCardSummaryBinding @@ -37,6 +39,7 @@ class CardSummaryActivity : BaseActivity() { private val paymentViewModel: TopUpPaymentViewModel by inject() private val paymentStatusViewModel: PaymentStatusViewModel by inject() private var paymentHtml: String? = null + private var paymentProcessed = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -49,11 +52,11 @@ class CardSummaryActivity : BaseActivity() { } private fun subscribeViewModel() { - paymentStatusViewModel.paymentSuccessfully.observe(this, { paymentStatus -> + paymentStatusViewModel.paymentSuccessfully.observe(this) { paymentStatus -> if (paymentStatus == PaymentStatus.STATUS_PAID) { paymentConfirmed() } - }) + } } private fun bind() { @@ -66,7 +69,13 @@ class CardSummaryActivity : BaseActivity() { binding.closeButton.setOnClickListener { binding.closeButton.visibility = View.GONE binding.webView.visibility = View.GONE - showPaymentPopUp() + if (paymentProcessed) { + showPaymentPopUp() + paymentProcessed = false + } + } + binding.paymentProcessingLayout.closeBannerButton.setOnClickListener { + binding.paymentProcessingLayout.root.visibility = View.GONE } } @@ -75,10 +84,25 @@ class CardSummaryActivity : BaseActivity() { val dialog = createPopUp(bindingPopUp.root, false) bindingPopUp.okayButton.setOnClickListener { dialog.dismiss() + showPaymentProcessingBanner() } dialog.show() } + private fun showPaymentProcessingBanner() { + binding.paymentProcessingLayout.root.visibility = View.VISIBLE + val animationX = + (binding.titleTextView.x + binding.titleTextView.height + resources.getDimension(R.dimen.margin_padding_size_medium)) + ObjectAnimator.ofFloat( + binding.paymentProcessingLayout.root, + "translationY", + animationX + ).apply { + duration = 2000 + start() + } + } + private fun getMystAmount() { val mystAmount = intent.extras?.getInt(CRYPTO_AMOUNT_EXTRA_KEY) binding.mystTextView.text = getString( @@ -125,7 +149,9 @@ class CardSummaryActivity : BaseActivity() { override fun onLoadResource(view: WebView?, url: String?) { super.onLoadResource(view, url) - Log.i(TAG, url.toString()) + if (url?.contains(paymentCallbackUrl) == true) { + paymentProcessed = true + } } } binding.webView.loadDataWithBaseURL(null, htmlData, HTML_MIME_TYPE, ENCODING, null) diff --git a/android/app/src/main/res/drawable/icon_clock_five.xml b/android/app/src/main/res/drawable/icon_clock_five.xml new file mode 100644 index 000000000..928cc060f --- /dev/null +++ b/android/app/src/main/res/drawable/icon_clock_five.xml @@ -0,0 +1,16 @@ + + + + diff --git a/android/app/src/main/res/drawable/icon_close_top_up.xml b/android/app/src/main/res/drawable/icon_close_top_up.xml new file mode 100644 index 000000000..15bb58b5a --- /dev/null +++ b/android/app/src/main/res/drawable/icon_close_top_up.xml @@ -0,0 +1,12 @@ + + + + diff --git a/android/app/src/main/res/layout/activity_card_summary.xml b/android/app/src/main/res/layout/activity_card_summary.xml index 5e546affa..5424f30e8 100644 --- a/android/app/src/main/res/layout/activity_card_summary.xml +++ b/android/app/src/main/res/layout/activity_card_summary.xml @@ -52,6 +52,11 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index 4c01a3a04..a4654244f 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -80,4 +80,7 @@ #3C3857 #503C3857 #703C3857 + + #1A704C60 + #33ED5BAC diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index b8d976f94..1c412265c 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,6 +1,9 @@ MysteriumVPN + + Close + Decentralized global node network Run by people, for people @@ -176,6 +179,7 @@ USD equivalent ≈ $%.2f %1$s %2$s Free Trial + FYI: It takes a few minutes to process payments if you’ve topped up Settings diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index c44a7ddb7..9ed03a288 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -432,6 +432,14 @@ @color/manual_connect_filter_background_white + +