Skip to content

Commit fba9d53

Browse files
committed
Rename easter egg to snowfall
Signed-off-by: Sunik Kupfer <kupfer@bitfire.at>
1 parent 01898f3 commit fba9d53

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

app/src/main/java/at/bitfire/icsdroid/ui/WinterEasterEgg.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,57 +42,56 @@ import kotlinx.coroutines.launch
4242
import java.time.MonthDay
4343
import kotlin.time.Duration
4444

45-
private val hideWinterEasterEgg = booleanPreferencesKey("hideWinterEasterEgg")
45+
private val hideSnowfall = booleanPreferencesKey("hideWinterEasterEgg")
4646

47-
fun Context.hideWinterEasterEggFlow(): Flow<Boolean> = dataStore.data.map { it[hideWinterEasterEgg] ?: false }
48-
suspend fun Context.hideWinterEasterEgg(hide: Boolean) {
47+
fun Context.hideSnowfall(): Flow<Boolean> = dataStore.data.map { it[hideSnowfall] ?: false }
48+
suspend fun Context.hideSnowfall(hide: Boolean) {
4949
// save setting
50-
dataStore.edit { it[hideWinterEasterEgg] = hide }
50+
dataStore.edit { it[hideSnowfall] = hide }
5151
}
5252

5353
/**
54-
* Determines whether the winter easter egg should be displayed.
54+
* Determines whether snowfall (the winter easter egg) should be displayed.
5555
*
56-
* It is displayed from December 20th to December 31st.
56+
* It is active from December 20th to December 31st.
5757
*/
58-
fun displayWinterEasterEgg(): Boolean {
59-
// return true // Uncomment for testing
58+
fun inSnowySeason(): Boolean {
6059
val now = MonthDay.now()
6160
return now >= MonthDay.of(12, 20) && now <= MonthDay.of(12, 31)
6261
}
6362

6463
@Composable
6564
fun WinterEasterEggToggleButton() {
66-
val shouldDisplay = remember { displayWinterEasterEgg() }
67-
if (!shouldDisplay) return
65+
val inSnowySeason = remember { inSnowySeason() }
66+
if (!inSnowySeason) return
6867

6968
val context = LocalContext.current
7069
val scope = rememberCoroutineScope()
7170

72-
val easterEggDisabled by context.hideWinterEasterEggFlow().collectAsState(false)
71+
val snowfallDisabled by context.hideSnowfall().collectAsState(false)
7372

7473
IconButton(
7574
onClick = {
7675
scope.launch(Dispatchers.IO) {
77-
context.hideWinterEasterEgg(!easterEggDisabled)
76+
context.hideSnowfall(!snowfallDisabled)
7877
}
7978
}
8079
) {
8180
Icon(
82-
if (easterEggDisabled) Icons.Rounded.AcUnit else Icons.Rounded.ModeCoolOff,
83-
stringResource(if (easterEggDisabled) R.string.winter_easter_egg_enable else R.string.winter_easter_egg_disable)
81+
if (snowfallDisabled) Icons.Rounded.AcUnit else Icons.Rounded.ModeCoolOff,
82+
stringResource(if (snowfallDisabled) R.string.snowfall_enable else R.string.snowfall_disable)
8483
)
8584
}
8685
}
8786

8887
@Composable
8988
fun WinterEasterEgg() {
90-
val shouldDisplay = remember { displayWinterEasterEgg() }
89+
val shouldDisplay = remember { inSnowySeason() }
9190
if (!shouldDisplay) return
9291

9392
val context = LocalContext.current
94-
val easterEggDisabled by context.hideWinterEasterEggFlow().collectAsState(false)
95-
if (easterEggDisabled) return
93+
val snowfallDisabled by context.hideSnowfall().collectAsState(false)
94+
if (snowfallDisabled) return
9695

9796
ConfettiKit(
9897
modifier = Modifier

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ along with this program. If not, see <a href="https://www.gnu.org/licenses/">ht
159159
<item quantity="other">%d subscriptions imported</item>
160160
</plurals>
161161

162-
<!-- Winter Easter Egg -->
163-
<string name="winter_easter_egg_disable">Disable Easter Egg</string>
164-
<string name="winter_easter_egg_enable">Enable Easter Egg</string>
162+
<!-- Snowfall Winter Easter Egg -->
163+
<string name="snowfall_disable">Disable Snowfall</string>
164+
<string name="snowfall_enable">Enable Snowfall</string>
165165

166166
</resources>

0 commit comments

Comments
 (0)