Show correct animation in boost fragment.

fork-5.53.8
Greyson Parrelli 2021-11-22 20:47:01 -05:00
rodzic 1627d92009
commit 511abd67c6
4 zmienionych plików z 65 dodań i 2 usunięć

Wyświetl plik

@ -0,0 +1,44 @@
package org.thoughtcrime.securesms.components.settings.app.subscription.boost
import android.animation.Animator
import android.view.View
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieDrawable
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.animation.AnimationCompleteListener
import org.thoughtcrime.securesms.components.settings.PreferenceModel
import org.thoughtcrime.securesms.util.MappingAdapter
import org.thoughtcrime.securesms.util.MappingViewHolder
/**
* A simple mapping model to show a boost animation.
*/
object BoostAnimation {
class Model : PreferenceModel<Model>(isEnabled = true) {
override fun areItemsTheSame(newItem: Model): Boolean = true
}
class ViewHolder(itemView: View) : MappingViewHolder<Model>(itemView) {
private val lottie: LottieAnimationView = findViewById(R.id.boost_animation_view)
override fun bind(model: Model) {
lottie.playAnimation()
lottie.addAnimatorListener(object : AnimationCompleteListener() {
override fun onAnimationEnd(animation: Animator?) {
lottie.removeAnimatorListener(this)
lottie.setMinAndMaxFrame(30, 91)
lottie.repeatMode = LottieDrawable.RESTART
lottie.repeatCount = LottieDrawable.INFINITE
lottie.frame = 30
lottie.playAnimation()
}
})
}
}
fun register(adapter: MappingAdapter) {
adapter.registerFactory(Model::class.java, MappingAdapter.LayoutFactory({ ViewHolder(it) }, R.layout.boost_animation_pref))
}
}

Wyświetl plik

@ -82,6 +82,7 @@ class BoostFragment : DSLSettingsBottomSheetFragment(
GooglePayButton.register(adapter)
Progress.register(adapter)
NetworkFailure.register(adapter)
BoostAnimation.register(adapter)
processingDonationPaymentDialog = MaterialAlertDialogBuilder(requireContext())
.setView(R.layout.processing_payment_dialog)
@ -143,7 +144,7 @@ class BoostFragment : DSLSettingsBottomSheetFragment(
}
return configure {
customPref(BadgePreview.SubscriptionModel(state.boostBadge))
customPref(BoostAnimation.Model())
sectionHeaderPref(
title = DSLSettingsText.from(

Wyświetl plik

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dsl_settings_gutter"
android:layout_marginEnd="@dimen/dsl_settings_gutter"
android:gravity="center_horizontal">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/boost_animation_view"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center_horizontal"
app:lottie_rawRes="@raw/lottie_rocket" />
</FrameLayout>

Wyświetl plik

@ -3974,7 +3974,7 @@
<string name="ManageDonationsFragment__error_getting_subscription">Error getting subscription.</string>
<string name="BoostFragment__give_signal_a_boost">Give Signal a Boost</string>
<string name="BoostFragment__say_thanks_and_earn">Say "Thanks!" and earn the Boost badge for %1$d days.</string>
<string name="BoostFragment__say_thanks_and_earn">Say \"Thanks!\" and earn the Boost badge for %1$d days.</string>
<string name="Boost__enter_custom_amount">Enter Custom Amount</string>
<string name="Boost__one_time_contribution">One-time contribution</string>