[Android] Update the Konfetti dependency

Nicolas Pomepuy git at videolan.org
Mon Oct 7 09:59:48 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Oct  4 10:33:57 2024 +0200| [4c1910916bdfb47c26a6968d2b23ee6c1a917adf] | committer: Duncan McNamara

Update the Konfetti dependency

> https://code.videolan.org/videolan/vlc-android/commit/4c1910916bdfb47c26a6968d2b23ee6c1a917adf
---

 application/vlc-android/build.gradle               |  2 +-
 application/vlc-android/res/layout/about.xml       |  2 +-
 .../src/org/videolan/vlc/gui/helpers/UiTools.kt    | 67 +++++++++++++---------
 3 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/application/vlc-android/build.gradle b/application/vlc-android/build.gradle
index 942ac43d53..6963b2705f 100644
--- a/application/vlc-android/build.gradle
+++ b/application/vlc-android/build.gradle
@@ -204,7 +204,7 @@ dependencies {
     api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.ext.kotlinx_version"
     api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinx_version"
 
-    implementation 'nl.dionsegijn:konfetti:1.2.2'
+    implementation 'nl.dionsegijn:konfetti-xml:2.0.4'
     implementation 'com.google.zxing:core:3.4.0'
     implementation "androidx.palette:palette-ktx:1.0.0"
     implementation 'com.jaredrummler:colorpicker:1.1.0'
diff --git a/application/vlc-android/res/layout/about.xml b/application/vlc-android/res/layout/about.xml
index 90e687365f..2e87770a1f 100644
--- a/application/vlc-android/res/layout/about.xml
+++ b/application/vlc-android/res/layout/about.xml
@@ -484,7 +484,7 @@
 
         </androidx.cardview.widget.CardView>
 
-        <nl.dionsegijn.konfetti.KonfettiView
+        <nl.dionsegijn.konfetti.xml.KonfettiView
                 android:id="@+id/konfetti"
                 android:layout_width="0dp"
                 android:layout_height="0dp"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index 1315f28629..4831dcd929 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -72,9 +72,13 @@ import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import com.google.android.material.snackbar.Snackbar
 import kotlinx.coroutines.*
-import nl.dionsegijn.konfetti.KonfettiView
-import nl.dionsegijn.konfetti.models.Shape
-import nl.dionsegijn.konfetti.models.Size
+import nl.dionsegijn.konfetti.core.Party
+import nl.dionsegijn.konfetti.core.Position
+import nl.dionsegijn.konfetti.core.Rotation
+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
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.medialibrary.MLServiceLocator
 import org.videolan.medialibrary.Tools
@@ -104,6 +108,7 @@ import org.videolan.vlc.util.SchedulerCallback
 import org.videolan.vlc.util.ThumbnailsProvider
 import org.videolan.vlc.util.openLinkIfPossible
 import java.security.SecureRandom
+import java.util.concurrent.TimeUnit
 import kotlin.math.min
 
 object UiTools {
@@ -404,30 +409,38 @@ object UiTools {
                 logo.animate().translationY(0F).setStartDelay(75).setDuration(300).setInterpolator(OvershootInterpolator(3.0F)).withEndAction {
                     logoAnimationRunning = false
                 }
-                konfettiView.build()
-                        .addColors(ContextCompat.getColor(activity, R.color.orange200), ContextCompat.getColor(activity, R.color.orange800), ContextCompat.getColor(activity, R.color.orange500))
-                        .setDirection(315.0, 360.0)
-                        .setSpeed(3f, 9f)
-                        .setFadeOutEnabled(true)
-                        .setTimeToLive(2000L)
-                        .addShapes(Shape.Circle, Shape.Square)
-                        .addSizes(Size(4))
-                        .setPosition(logo.x + logo.width - 12.dp, logo.x + logo.width - 12.dp, logo.y + logo.height - 24.dp, logo.y + logo.height + 24.dp)
-                        .setRotationEnabled(false)
-                        .setDelay(275)
-                        .burst(iter * 30)
-                konfettiView.build()
-                        .addColors(ContextCompat.getColor(activity, R.color.orange200), ContextCompat.getColor(activity, R.color.orange800), ContextCompat.getColor(activity, R.color.orange500))
-                        .setDirection(180.0, 225.0)
-                        .setSpeed(3f, 9f)
-                        .setFadeOutEnabled(true)
-                        .setTimeToLive(2000L)
-                        .addShapes(Shape.Circle, Shape.Square)
-                        .addSizes(Size(4))
-                        .setPosition(logo.x + 12.dp, logo.x + 12.dp, logo.y + logo.height - 24.dp, logo.y + logo.height + 24.dp)
-                        .setRotationEnabled(false)
-                        .setDelay(275)
-                        .burst(iter * 30)
+                val partyRight = Party(
+                    colors = listOf(ContextCompat.getColor(activity, R.color.orange200), ContextCompat.getColor(activity, R.color.orange800), ContextCompat.getColor(activity, R.color.orange500)),
+                    angle = 0,
+                    spread = 60,
+                    speed = 3f,
+                    maxSpeed = 18f,
+                    fadeOutEnabled = true,
+                    timeToLive = 2000L,
+                    rotation = Rotation(enabled = false),
+                    shapes = listOf(Shape.Circle),
+                    size = listOf(Size(4), Size(3), Size(2)),
+                    delay = 275,
+                    position = Position.Absolute(logo.x + logo.width - 12.dp, logo.y + logo.height - 24.dp).between(Position.Absolute(logo.x + logo.width - 12.dp, logo.y + logo.height + 24.dp)),
+                    emitter = Emitter(duration = 200, TimeUnit.MILLISECONDS).max(iter*30)
+                )
+                konfettiView.start(partyRight)
+                val partyLeft = Party(
+                    colors = listOf(ContextCompat.getColor(activity, R.color.orange200), ContextCompat.getColor(activity, R.color.orange800), ContextCompat.getColor(activity, R.color.orange500)),
+                    angle = 180,
+                    spread = 60,
+                    speed = 3f,
+                    maxSpeed = 18f,
+                    fadeOutEnabled = true,
+                    timeToLive = 2000L,
+                    rotation = Rotation(enabled = false),
+                    shapes = listOf(Shape.Circle),
+                    size = listOf(Size(4), Size(3), Size(2)),
+                    delay = 275,
+                    position = Position.Absolute(logo.x + 12.dp, logo.y + logo.height - 24.dp).between(Position.Absolute(logo.x + 12.dp, logo.y + logo.height + 24.dp)),
+                    emitter = Emitter(duration = 200, TimeUnit.MILLISECONDS).max(iter*30)
+                )
+                konfettiView.start(partyLeft)
             }
         }
 



More information about the Android mailing list