From e1a96c55507ccd4d287d3621c25f05519a2a10eb Mon Sep 17 00:00:00 2001 From: Oleg Koretsky Date: Wed, 27 Nov 2024 12:54:31 +0200 Subject: [PATCH] Make the confetti fit the screen and fade --- .../AccountsOverviewFragment.kt | 40 +- .../res/layout/fragment_accounts_overview.xml | 5 +- app/src/main/res/raw/confetti.json | 31666 +--------------- 3 files changed, 30 insertions(+), 31681 deletions(-) diff --git a/app/src/main/java/com/concordium/wallet/ui/account/accountsoverview/AccountsOverviewFragment.kt b/app/src/main/java/com/concordium/wallet/ui/account/accountsoverview/AccountsOverviewFragment.kt index fef9eb34..843cb19b 100644 --- a/app/src/main/java/com/concordium/wallet/ui/account/accountsoverview/AccountsOverviewFragment.kt +++ b/app/src/main/java/com/concordium/wallet/ui/account/accountsoverview/AccountsOverviewFragment.kt @@ -1,12 +1,17 @@ package com.concordium.wallet.ui.account.accountsoverview import android.animation.Animator +import android.animation.AnimatorListenerAdapter import android.content.Intent import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.ViewGroup.LayoutParams +import android.view.animation.AccelerateDecelerateInterpolator +import android.view.animation.AccelerateInterpolator import androidx.constraintlayout.widget.ConstraintSet import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams @@ -33,9 +38,9 @@ import com.concordium.wallet.ui.base.BaseFragment import com.concordium.wallet.ui.cis2.SendTokenActivity import com.concordium.wallet.ui.more.export.ExportActivity import com.concordium.wallet.ui.more.notifications.NotificationsPermissionDialog -import com.concordium.wallet.ui.onboarding.OnboardingState import com.concordium.wallet.ui.onboarding.OnboardingFragment import com.concordium.wallet.ui.onboarding.OnboardingSharedViewModel +import com.concordium.wallet.ui.onboarding.OnboardingState import com.concordium.wallet.ui.onramp.CcdOnrampSitesActivity import com.concordium.wallet.util.KeyCreationVersion import com.concordium.wallet.util.Log @@ -71,7 +76,7 @@ class AccountsOverviewFragment : BaseFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { binding = FragmentAccountsOverviewBinding.inflate(inflater, container, false) onboardingBinding = FragmentOnboardingBinding.inflate(layoutInflater) @@ -330,26 +335,33 @@ class AccountsOverviewFragment : BaseFragment() { } private fun initializeAnimation() { - binding.confettiAnimation.addAnimatorListener(object : Animator.AnimatorListener { - override fun onAnimationStart(p0: Animator) {} + val handler = Handler(Looper.getMainLooper()) + binding.confettiAnimation.addAnimatorListener(object : AnimatorListenerAdapter() { + override fun onAnimationStart(p0: Animator) { + handler.postDelayed({ + binding.confettiAnimation.animate() + .setInterpolator(AccelerateInterpolator()) + .alpha(0f) + .scaleXBy(0.3f) + .scaleYBy(0.3f) + .setDuration(900) + .setListener(object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + cancelAnimation() + } + }) + }, 800) + } override fun onAnimationEnd(p0: Animator) { cancelAnimation() } - - override fun onAnimationCancel(p0: Animator) {} - - override fun onAnimationRepeat(p0: Animator) {} - }) - binding.confettiAnimation.addAnimatorPauseListener(object : Animator.AnimatorPauseListener { + binding.confettiAnimation.addAnimatorPauseListener(object : AnimatorListenerAdapter() { override fun onAnimationPause(p0: Animator) { cancelAnimation() } - - override fun onAnimationResume(p0: Animator) {} - }) } @@ -504,4 +516,4 @@ class AccountsOverviewFragment : BaseFragment() { } //endregion -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/fragment_accounts_overview.xml b/app/src/main/res/layout/fragment_accounts_overview.xml index 57839f74..fdd58cf2 100644 --- a/app/src/main/res/layout/fragment_accounts_overview.xml +++ b/app/src/main/res/layout/fragment_accounts_overview.xml @@ -113,8 +113,8 @@ layout="@layout/list_item_accounts_overview_ccd_onramp_banner" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="32dp" - android:layout_marginHorizontal="@dimen/activity_vertical_margin" /> + android:layout_marginHorizontal="@dimen/activity_vertical_margin" + android:layout_marginTop="32dp" />