Skip to content

Commit 8626ecf

Browse files
committed
Disable confetti if animations are disabled globally
Fixes #2170
1 parent a1bf456 commit 8626ecf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/list/ListHabitsScreen.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import android.app.Activity
2323
import android.content.Context
2424
import android.content.Intent
2525
import android.os.Bundle
26+
import android.provider.Settings
2627
import androidx.appcompat.app.AppCompatActivity
2728
import dagger.Lazy
2829
import nl.dionsegijn.konfetti.core.Party
@@ -226,6 +227,12 @@ class ListHabitsScreen
226227
override fun showConfetti(color: PaletteColor, x: Float, y: Float) {
227228
if (x == 0f && y == 0f) return
228229
if (preferences.isConfettiAnimationDisabled) return
230+
if (Settings.Global.getFloat(
231+
activity.contentResolver,
232+
Settings.Global.ANIMATOR_DURATION_SCALE,
233+
1f
234+
) == 0f
235+
) return
229236
val baseColor = themeSwitcher.currentTheme!!.color(color).toInt()
230237
rootView.get().konfettiView.start(
231238
Party(
@@ -299,30 +306,36 @@ class ListHabitsScreen
299306
command.selected.size
300307
)
301308
}
309+
302310
is ChangeHabitColorCommand -> {
303311
return activity.resources.getQuantityString(
304312
R.plurals.toast_habits_changed,
305313
command.selected.size
306314
)
307315
}
316+
308317
is CreateHabitCommand -> {
309318
return activity.resources.getString(R.string.toast_habit_created)
310319
}
320+
311321
is DeleteHabitsCommand -> {
312322
return activity.resources.getQuantityString(
313323
R.plurals.toast_habits_deleted,
314324
command.selected.size
315325
)
316326
}
327+
317328
is EditHabitCommand -> {
318329
return activity.resources.getQuantityString(R.plurals.toast_habits_changed, 1)
319330
}
331+
320332
is UnarchiveHabitsCommand -> {
321333
return activity.resources.getQuantityString(
322334
R.plurals.toast_habits_unarchived,
323335
command.selected.size
324336
)
325337
}
338+
326339
else -> return null
327340
}
328341
}
@@ -335,9 +348,11 @@ class ListHabitsScreen
335348
adapter.refresh()
336349
activity.showMessage(activity.resources.getString(R.string.habits_imported))
337350
}
351+
338352
ImportDataTask.NOT_RECOGNIZED -> {
339353
activity.showMessage(activity.resources.getString(R.string.file_not_recognized))
340354
}
355+
341356
else -> {
342357
activity.showMessage(activity.resources.getString(R.string.could_not_import))
343358
}

0 commit comments

Comments
 (0)