diff --git a/app/build.gradle b/app/build.gradle
index 72c03e94..838083cc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -152,6 +152,7 @@ dependencies {
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
// Szkolny.eu libraries/forks
+ implementation "eu.szkolny:android-snowfall:1ca9ea2da3"
implementation "eu.szkolny:agendacalendarview:1799f8ef47"
implementation "eu.szkolny:cafebar:5bf0c618de"
implementation "eu.szkolny.fslogin:lib:2.0.0"
@@ -180,7 +181,6 @@ dependencies {
implementation "com.github.bassaer:chatmessageview:2.0.1"
implementation "com.github.CanHub:Android-Image-Cropper:2.2.2"
implementation "com.github.ChuckerTeam.Chucker:library:3.0.1"
- implementation "com.github.jetradarmobile:android-snowfall:1.2.0"
implementation "com.github.wulkanowy.uonet-request-signer:hebe-jvm:a99ca50a31"
implementation("com.heinrichreimersoftware:material-intro") { version { strictly "1.5.8" } }
implementation "com.hypertrack:hyperlog:0.0.10"
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt
index 8dd83bf2..2cd4f7b7 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt
@@ -21,6 +21,7 @@ import androidx.lifecycle.Observer
import androidx.navigation.NavOptions
import com.danimahardhika.cafebar.CafeBar
import com.google.android.material.dialog.MaterialAlertDialogBuilder
+import com.jetradarmobile.snowfall.SnowfallView
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.utils.colorInt
@@ -81,12 +82,9 @@ import pl.szczodrzynski.edziennik.ui.modules.settings.ProfileManagerFragment
import pl.szczodrzynski.edziennik.ui.modules.settings.SettingsFragment
import pl.szczodrzynski.edziennik.ui.modules.timetable.TimetableFragment
import pl.szczodrzynski.edziennik.ui.modules.webpush.WebPushFragment
-import pl.szczodrzynski.edziennik.utils.SwipeRefreshLayoutNoTouch
-import pl.szczodrzynski.edziennik.utils.Themes
-import pl.szczodrzynski.edziennik.utils.Utils
+import pl.szczodrzynski.edziennik.utils.*
import pl.szczodrzynski.edziennik.utils.Utils.d
import pl.szczodrzynski.edziennik.utils.Utils.dpToPx
-import pl.szczodrzynski.edziennik.utils.appManagerIntentList
import pl.szczodrzynski.edziennik.utils.models.Date
import pl.szczodrzynski.edziennik.utils.models.NavTarget
import pl.szczodrzynski.navlib.*
@@ -470,9 +468,21 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
// IT'S WINTER MY DUDES
val today = Date.getToday()
- if ((today.month == 12 || today.month == 1) && app.config.ui.snowfall) {
+ if ((today.month % 11 == 1) && app.config.ui.snowfall) {
b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false))
}
+ else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) {
+ val eggfall = layoutInflater.inflate(R.layout.eggfall, b.rootFrame, false) as SnowfallView
+ eggfall.setSnowflakeBitmaps(listOf(
+ BitmapFactory.decodeResource(resources, R.drawable.egg1),
+ BitmapFactory.decodeResource(resources, R.drawable.egg2),
+ BitmapFactory.decodeResource(resources, R.drawable.egg3),
+ BitmapFactory.decodeResource(resources, R.drawable.egg4),
+ BitmapFactory.decodeResource(resources, R.drawable.egg5),
+ BitmapFactory.decodeResource(resources, R.drawable.egg6)
+ ))
+ b.rootFrame.addView(eggfall)
+ }
// WHAT'S NEW DIALOG
if (app.config.appVersion < BuildConfig.VERSION_CODE) {
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt
index 7b39383e..f36652a1 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt
@@ -49,6 +49,11 @@ class ConfigUI(private val config: Config) {
get() { mSnowfall = mSnowfall ?: config.values.get("snowfall", false); return mSnowfall ?: false }
set(value) { config.set("snowfall", value); mSnowfall = value }
+ private var mEggfall: Boolean? = null
+ var eggfall: Boolean
+ get() { mEggfall = mEggfall ?: config.values.get("eggfall", false); return mEggfall ?: false }
+ set(value) { config.set("eggfall", value); mEggfall = value }
+
private var mBottomSheetOpened: Boolean? = null
var bottomSheetOpened: Boolean
get() { mBottomSheetOpened = mBottomSheetOpened ?: config.values.get("bottomSheetOpened", false); return mBottomSheetOpened ?: false }
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/cards/SettingsThemeCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/cards/SettingsThemeCard.kt
index 17b108e5..a009279d 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/cards/SettingsThemeCard.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/cards/SettingsThemeCard.kt
@@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.ui.dialogs.settings.MiniMenuConfigDialog
import pl.szczodrzynski.edziennik.ui.dialogs.settings.ThemeChooserDialog
import pl.szczodrzynski.edziennik.ui.modules.settings.SettingsCard
import pl.szczodrzynski.edziennik.ui.modules.settings.SettingsUtil
+import pl.szczodrzynski.edziennik.utils.BigNightUtil
import pl.szczodrzynski.edziennik.utils.Themes
import pl.szczodrzynski.edziennik.utils.models.Date
@@ -36,6 +37,18 @@ class SettingsThemeCard(util: SettingsUtil) : SettingsCard(util) {
}
else null,
+ if (BigNightUtil().isDataWielkanocyNearDzisiaj()) // cool klasa for utility to dzień wielkanocy
+ util.createPropertyItem(
+ text = R.string.settings_theme_eggfall_text,
+ subText = R.string.settings_theme_eggfall_subtext,
+ icon = CommunityMaterial.Icon.cmd_egg_easter,
+ value = configGlobal.ui.eggfall
+ ) { _, it ->
+ configGlobal.ui.eggfall = it
+ activity.recreate()
+ }
+ else null,
+
util.createActionItem(
text = R.string.settings_theme_theme_text,
subText = Themes.getThemeNameRes(),
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/BigNightUtil.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/BigNightUtil.kt
new file mode 100644
index 00000000..c7f57ccc
--- /dev/null
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/BigNightUtil.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) Kuba Szczodrzyński 2021-4-8.
+ */
+
+package pl.szczodrzynski.edziennik.utils
+
+import pl.szczodrzynski.edziennik.utils.models.Date
+import kotlin.math.absoluteValue
+
+// Obliczanie daty wielkanocy - algorytm Gaussa
+// www.algorytm.org
+// (c) 2008 by Tomasz Lubinski
+// http://www.algorytm.org/przetwarzanie-dat/wyznaczanie-daty-wielkanocy-algortym-gaussa/dwg-j.html
+
+class BigNightUtil {
+
+ /* Pobierz wartosc A z tabeli lat */
+ private fun getA(rok: Int) = when {
+ rok <= 1582 -> 15
+ rok <= 1699 -> 22
+ rok <= 1899 -> 23
+ rok <= 2199 -> 24
+ rok <= 2299 -> 25
+ rok <= 2399 -> 26
+ rok <= 2499 -> 25
+ else -> 0
+ }
+
+ /* Pobierz wartosc B z tabeli lat */
+ private fun getB(rok: Int) = when {
+ rok <= 1582 -> 6
+ rok <= 1699 -> 2
+ rok <= 1799 -> 3
+ rok <= 1899 -> 4
+ rok <= 2099 -> 5
+ rok <= 2199 -> 6
+ rok <= 2299 -> 0
+ rok <= 2499 -> 1
+ else -> 0
+ }
+
+ /* oblicz ile dni po 22 marca przypada wielkanoc */
+ private fun Oblicz_Date_wielkanocy(rok: Int): Int {
+ val a = rok % 19
+ val b = rok % 4
+ val c = rok % 7
+ var d = (a * 19 + getA(rok)) % 30
+ val e = (2 * b + 4 * c + 6 * d + getB(rok)) % 7
+ if (d == 29 && e == 6 || d == 28 && e == 6) {
+ d -= 7
+ }
+ return d + e
+ }
+
+ private fun get_dataOf_bigNight(): Date {
+ val date = Date.getToday()
+ date.month = 4
+ date.day = 22 + Oblicz_Date_wielkanocy(date.year)
+ if (date.day > 31)
+ date.day = date.day % 31
+ else
+ date.month = 3
+
+ return date
+ }
+
+ fun isDataWielkanocyNearDzisiaj() =
+ Date.diffDays(Date.getToday(), get_dataOf_bigNight()).absoluteValue < 7
+}
diff --git a/app/src/main/res/drawable/egg1.webp b/app/src/main/res/drawable/egg1.webp
new file mode 100644
index 00000000..94440758
Binary files /dev/null and b/app/src/main/res/drawable/egg1.webp differ
diff --git a/app/src/main/res/drawable/egg2.webp b/app/src/main/res/drawable/egg2.webp
new file mode 100644
index 00000000..bfc8644a
Binary files /dev/null and b/app/src/main/res/drawable/egg2.webp differ
diff --git a/app/src/main/res/drawable/egg3.webp b/app/src/main/res/drawable/egg3.webp
new file mode 100644
index 00000000..886b5ece
Binary files /dev/null and b/app/src/main/res/drawable/egg3.webp differ
diff --git a/app/src/main/res/drawable/egg4.webp b/app/src/main/res/drawable/egg4.webp
new file mode 100644
index 00000000..1b958948
Binary files /dev/null and b/app/src/main/res/drawable/egg4.webp differ
diff --git a/app/src/main/res/drawable/egg5.webp b/app/src/main/res/drawable/egg5.webp
new file mode 100644
index 00000000..2cc48842
Binary files /dev/null and b/app/src/main/res/drawable/egg5.webp differ
diff --git a/app/src/main/res/drawable/egg6.webp b/app/src/main/res/drawable/egg6.webp
new file mode 100644
index 00000000..9dd98d89
Binary files /dev/null and b/app/src/main/res/drawable/egg6.webp differ
diff --git a/app/src/main/res/layout/eggfall.xml b/app/src/main/res/layout/eggfall.xml
new file mode 100644
index 00000000..fbc6a0fc
--- /dev/null
+++ b/app/src/main/res/layout/eggfall.xml
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 3dd3dcfc..3af14e8f 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -967,6 +967,8 @@
Öffnen Sie das Menü mit der Zurück-Taste
Schlittenfahrt im Schnee
Jingle Bells, Jingle Bells
+ Brrrr
+ Bajo jajo, bajo jajo
Rosa
System
Thema
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index 86911c58..4c0c5b89 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -969,6 +969,8 @@
Back button opens drawer
Jingle all the way
Jingle bells, Jingle bells
+ Brrrr
+ Bajo jajo, bajo jajo
Pink
System
Theme
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3b0ee64a..a008fc94 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1034,6 +1034,8 @@
Otwieraj menu przyciskiem wstecz
Dzwonią dzwonki sań
Pada śnieg, pada śnieg
+ Brrrr
+ Bajo jajo, bajo jajo
Różowy
Systemowy
Motyw