From 074627f6e14ba9c4795c77209bd4d052b4d62d2d Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Sat, 28 Jun 2025 16:03:22 -0500 Subject: [PATCH] Disable confetti if animations are disabled globally Fixes #2170 --- .../activities/habits/list/ListHabitsScreen.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/list/ListHabitsScreen.kt b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/list/ListHabitsScreen.kt index 074f22f75..e54e06c86 100644 --- a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/list/ListHabitsScreen.kt +++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/list/ListHabitsScreen.kt @@ -23,6 +23,7 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.os.Bundle +import android.provider.Settings import androidx.appcompat.app.AppCompatActivity import dagger.Lazy import nl.dionsegijn.konfetti.core.Party @@ -226,6 +227,12 @@ class ListHabitsScreen override fun showConfetti(color: PaletteColor, x: Float, y: Float) { if (x == 0f && y == 0f) return if (preferences.isConfettiAnimationDisabled) return + if (Settings.Global.getFloat( + activity.contentResolver, + Settings.Global.ANIMATOR_DURATION_SCALE, + 1f + ) == 0f + ) return val baseColor = themeSwitcher.currentTheme!!.color(color).toInt() rootView.get().konfettiView.start( Party( @@ -299,30 +306,36 @@ class ListHabitsScreen command.selected.size ) } + is ChangeHabitColorCommand -> { return activity.resources.getQuantityString( R.plurals.toast_habits_changed, command.selected.size ) } + is CreateHabitCommand -> { return activity.resources.getString(R.string.toast_habit_created) } + is DeleteHabitsCommand -> { return activity.resources.getQuantityString( R.plurals.toast_habits_deleted, command.selected.size ) } + is EditHabitCommand -> { return activity.resources.getQuantityString(R.plurals.toast_habits_changed, 1) } + is UnarchiveHabitsCommand -> { return activity.resources.getQuantityString( R.plurals.toast_habits_unarchived, command.selected.size ) } + else -> return null } } @@ -335,9 +348,11 @@ class ListHabitsScreen adapter.refresh() activity.showMessage(activity.resources.getString(R.string.habits_imported)) } + ImportDataTask.NOT_RECOGNIZED -> { activity.showMessage(activity.resources.getString(R.string.file_not_recognized)) } + else -> { activity.showMessage(activity.resources.getString(R.string.could_not_import)) }