[UI] Add eggfall. (#22)

* Add eggfall

* Add egg.png

* Add more eggs

* [Gradle] Update android-snowfall to a fork.

* [Eggfall] Add randomizing egg images.

* [UI] Restore snowfall icon. Add separate eggfall setting.

* [Eggfall] Limit eggfall to near-easter date only.

Co-authored-by: GitHub <noreply@github.com>
Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
This commit is contained in:
Mateusz Idziejczak 2021-04-12 17:18:53 +02:00 committed by GitHub
parent 634ef16bc5
commit b48b5589f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 123 additions and 6 deletions

View File

@ -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"

View File

@ -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) {

View File

@ -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 }

View File

@ -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(),

View File

@ -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
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Mateusz Idziejczak 2021-4-3.
-->
<com.jetradarmobile.snowfall.SnowfallView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:snowflakeAlphaMax="250"
app:snowflakeAlphaMin="150"
app:snowflakeSizeMax="32dp"
app:snowflakeSizeMin="16dp"
app:snowflakesNum="70" />

View File

@ -967,6 +967,8 @@
<string name="settings_theme_open_drawer_on_back_pressed_text">Öffnen Sie das Menü mit der Zurück-Taste</string>
<string name="settings_theme_snowfall_subtext">Schlittenfahrt im Schnee</string>
<string name="settings_theme_snowfall_text">Jingle Bells, Jingle Bells</string>
<string name="settings_theme_eggfall_subtext">Brrrr</string>
<string name="settings_theme_eggfall_text">Bajo jajo, bajo jajo</string>
<string name="settings_theme_theme_pink">Rosa</string>
<string name="settings_theme_theme_system">System</string>
<string name="settings_theme_theme_text">Thema</string>

View File

@ -969,6 +969,8 @@
<string name="settings_theme_open_drawer_on_back_pressed_text">Back button opens drawer</string>
<string name="settings_theme_snowfall_subtext">Jingle all the way</string>
<string name="settings_theme_snowfall_text">Jingle bells, Jingle bells</string>
<string name="settings_theme_eggfall_subtext">Brrrr</string>
<string name="settings_theme_eggfall_text">Bajo jajo, bajo jajo</string>
<string name="settings_theme_theme_pink">Pink</string>
<string name="settings_theme_theme_system">System</string>
<string name="settings_theme_theme_text">Theme</string>

View File

@ -1034,6 +1034,8 @@
<string name="settings_theme_open_drawer_on_back_pressed_text">Otwieraj menu przyciskiem wstecz</string>
<string name="settings_theme_snowfall_subtext">Dzwonią dzwonki sań</string>
<string name="settings_theme_snowfall_text">Pada śnieg, pada śnieg</string>
<string name="settings_theme_eggfall_subtext">Brrrr</string>
<string name="settings_theme_eggfall_text">Bajo jajo, bajo jajo</string>
<string name="settings_theme_theme_pink">Różowy</string>
<string name="settings_theme_theme_system">Systemowy</string>
<string name="settings_theme_theme_text">Motyw</string>