From 154a609cc9bcd4a82d07910c4de28a00db1467a9 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Mon, 7 Oct 2024 22:40:08 +0300 Subject: [PATCH] challeng to be only in october --- .../ui/dashboard/DashboardActivity.kt | 20 +++++++++++++++---- .../ui/dashboard/DashboardActivity.kt.lite | 20 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt index 36dad7f287..0f36530fb3 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt @@ -77,6 +77,9 @@ import org.ole.planet.myplanet.utilities.MarkdownDialog import org.ole.planet.myplanet.utilities.TimeUtils.formatDate import org.ole.planet.myplanet.utilities.Utilities import org.ole.planet.myplanet.utilities.Utilities.toast +import java.time.LocalDate +import java.time.temporal.ChronoUnit +import java.util.Calendar import java.util.Date import java.util.UUID import kotlin.math.ceil @@ -233,12 +236,21 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N } }) - if (settings.getString("serverURL", "") == "https://${BuildConfig.PLANET_LEARNING_URL}") { - challengeDialog() + val calendar = Calendar.getInstance() + val currentMonth = calendar.get(Calendar.MONTH) + + if (currentMonth == Calendar.OCTOBER) { + if (settings.getString("serverURL", "") == "https://${BuildConfig.PLANET_LEARNING_URL}") { + val today = LocalDate.now() + val endOfMonth = today.withDayOfMonth(today.lengthOfMonth()) + val remainingDays = ChronoUnit.DAYS.between(today, endOfMonth).toInt() + + challengeDialog(remainingDays) + } } } - private fun challengeDialog() { + private fun challengeDialog(remainingDays: Int) { val markdownContent = """ ## myPlanet issues challenge @@ -246,7 +258,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N get ready for virtual intern github issues challenge! - **duration:** 30 days + **duration:** $remainingDays days remaining ## steps to participate: - Find an issue on myPlanet diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite index 4e9834cfcb..49e40fa188 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite @@ -77,6 +77,9 @@ import org.ole.planet.myplanet.utilities.MarkdownDialog import org.ole.planet.myplanet.utilities.TimeUtils.formatDate import org.ole.planet.myplanet.utilities.Utilities import org.ole.planet.myplanet.utilities.Utilities.toast +import java.time.LocalDate +import java.time.temporal.ChronoUnit +import java.util.Calendar import java.util.Date import java.util.UUID import kotlin.math.ceil @@ -233,12 +236,21 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N } }) - if (settings.getString("serverURL", "") == "https://${BuildConfig.PLANET_LEARNING_URL}") { - challengeDialog() + val calendar = Calendar.getInstance() + val currentMonth = calendar.get(Calendar.MONTH) + + if (currentMonth == Calendar.OCTOBER) { + if (settings.getString("serverURL", "") == "https://${BuildConfig.PLANET_LEARNING_URL}") { + val today = LocalDate.now() + val endOfMonth = today.withDayOfMonth(today.lengthOfMonth()) + val remainingDays = ChronoUnit.DAYS.between(today, endOfMonth).toInt() + + challengeDialog(remainingDays) + } } } - private fun challengeDialog() { + private fun challengeDialog(remainingDays: Int) { val markdownContent = """ ## myPlanet issues challenge @@ -246,7 +258,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N get ready for virtual intern github issues challenge! - **duration:** 30 days + **duration:** $remainingDays days remaining ## steps to participate: - Find an issue on myPlanet