Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP and low priority: upgrade konfetti to 2.0.2 #5079

Merged
merged 4 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5079.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade konfetti lib from 1.3.2 to 2.0.2
3 changes: 2 additions & 1 deletion vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ dependencies {
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'

// Chat effects
implementation 'nl.dionsegijn:konfetti:1.3.2'
implementation 'nl.dionsegijn:konfetti-xml:2.0.2'

implementation 'com.github.jetradarmobile:android-snowfall:1.2.1'
// DI
implementation libs.dagger.hilt
Expand Down
37 changes: 24 additions & 13 deletions vector/src/main/java/im/vector/app/core/animations/Konfetti.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ import android.content.Context
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import im.vector.app.R
import nl.dionsegijn.konfetti.KonfettiView
import nl.dionsegijn.konfetti.models.Shape
import nl.dionsegijn.konfetti.models.Size
import nl.dionsegijn.konfetti.core.Angle
import nl.dionsegijn.konfetti.core.Party
import nl.dionsegijn.konfetti.core.Position
import nl.dionsegijn.konfetti.core.Spread
import nl.dionsegijn.konfetti.core.emitter.Emitter
import nl.dionsegijn.konfetti.core.models.Shape
import nl.dionsegijn.konfetti.core.models.Size
import nl.dionsegijn.konfetti.xml.KonfettiView

fun KonfettiView.play() {
val confettiColors = listOf(
Expand All @@ -35,16 +40,22 @@ fun KonfettiView.play() {
R.color.palette_prune,
R.color.palette_kiwi
)
build()
.addColors(confettiColors.toColorInt(context))
.setDirection(0.0, 359.0)
.setSpeed(2f, 5f)
.setFadeOutEnabled(true)
.setTimeToLive(2000L)
.addShapes(Shape.Square, Shape.Circle)
.addSizes(Size(12))
.setPosition(-50f, width + 50f, -50f, -50f)
.streamFor(150, 3000L)
val emitterConfig = Emitter(2000).perSecond(100)
val party = Party(
emitter = emitterConfig,
colors = confettiColors.toColorInt(context),
angle = Angle.Companion.BOTTOM,
spread = Spread.ROUND,
shapes = listOf(Shape.Square, Shape.Circle),
size = listOf(Size(12)),
speed = 2f,
maxSpeed = 5f,
fadeOutEnabled = true,
timeToLive = 2000L,
position = Position.Relative(0.0, 0.0).between(Position.Relative(1.0, 0.0)),
)
reset()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling reset() fixes the issue when displaying the confetti several times (in the timeline)

start(party)
}

@ColorInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="?colorSecondary">

<nl.dionsegijn.konfetti.KonfettiView
<nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/viewKonfetti"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<nl.dionsegijn.konfetti.KonfettiView
<nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/viewKonfetti"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion vector/src/main/res/layout/fragment_timeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:tint="@android:color/black" />

<nl.dionsegijn.konfetti.KonfettiView
<nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/viewKonfetti"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down