Skip to content

Commit f68510f

Browse files
committed
Allow user to disable confetti animation
1 parent 245b0eb commit f68510f

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class ListHabitsScreen
224224
}
225225

226226
override fun showConfetti(color: PaletteColor, x: Float, y: Float) {
227+
if (preferences.isConfettiAnimationDisabled) return
227228
val baseColor = themeSwitcher.currentTheme!!.color(color).toInt()
228229
rootView.get().konfettiView.start(
229230
Party(

uhabits-android/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,6 @@
233233
<string name="activity_not_found">No app was found to support this action</string>
234234
<string name="pref_midnight_delay_title">Extend day a few hours past midnight</string>
235235
<string name="pref_midnight_delay_description">Wait until 3:00 AM to show a new day. Useful if you typically go to sleep after midnight. Requires app restart.</string>
236+
<string name="pref_animations_title">Disable animations</string>
237+
<string name="pref_animations_description">Disable confetti animation after adding a checkmark.</string>
236238
</resources>

uhabits-android/src/main/res/xml/preferences.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@
6767
android:title="@string/use_pure_black"
6868
app:iconSpaceReserved="false" />
6969

70+
<SwitchPreferenceCompat
71+
android:defaultValue="false"
72+
android:key="pref_disable_animation"
73+
android:summary="@string/pref_animations_description"
74+
android:title="@string/pref_animations_title"
75+
app:iconSpaceReserved="false" />
76+
7077
<ListPreference
7178
android:defaultValue="255"
7279
android:entries="@array/widget_opacity_entries"

uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/preferences/Preferences.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ open class Preferences(private val storage: Storage) {
135135
storage.putBoolean("pref_short_toggle", enabled)
136136
}
137137

138+
var isConfettiAnimationDisabled: Boolean
139+
get() = storage.getBoolean("pref_disable_animation", false)
140+
set(enabled) {
141+
storage.putBoolean("pref_disable_animation", enabled)
142+
}
143+
138144
fun removeListener(listener: Listener) {
139145
listeners.remove(listener)
140146
}

0 commit comments

Comments
 (0)