forked from github/wulkanowy-mirror
Block app timezone to polish timezone (#1598)
This commit is contained in:
@ -13,13 +13,8 @@ import io.github.wulkanowy.ui.modules.about.license.LicenseFragment
|
||||
import io.github.wulkanowy.ui.modules.debug.DebugFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.getCompatDrawable
|
||||
import io.github.wulkanowy.utils.openAppInMarket
|
||||
import io.github.wulkanowy.utils.openEmailClient
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import io.github.wulkanowy.utils.toLocalDateTime
|
||||
import io.github.wulkanowy.utils.*
|
||||
import java.time.Instant
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
@ -38,7 +33,7 @@ class AboutFragment : BaseFragment<FragmentAboutBinding>(R.layout.fragment_about
|
||||
override val versionRes: Triple<String, String, Drawable?>?
|
||||
get() = context?.run {
|
||||
val buildTimestamp =
|
||||
appInfo.buildTimestamp.toLocalDateTime().toFormattedString("yyyy-MM-dd")
|
||||
Instant.ofEpochMilli(appInfo.buildTimestamp).toFormattedString("yyyy-MM-dd")
|
||||
val versionSignature =
|
||||
"${appInfo.versionName}-${appInfo.buildFlavor} (${appInfo.versionCode}), $buildTimestamp"
|
||||
Triple(
|
||||
|
@ -37,9 +37,7 @@ import io.github.wulkanowy.utils.left
|
||||
import io.github.wulkanowy.utils.nickOrName
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import timber.log.Timber
|
||||
import java.time.Duration
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.*
|
||||
import java.util.Timer
|
||||
import javax.inject.Inject
|
||||
import kotlin.concurrent.timer
|
||||
@ -291,7 +289,7 @@ class DashboardAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView
|
||||
var dateToNavigate = LocalDate.now()
|
||||
|
||||
fun updateLessonState() {
|
||||
val currentDateTime = LocalDateTime.now()
|
||||
val currentDateTime = Instant.now()
|
||||
val currentDate = LocalDate.now()
|
||||
val tomorrowDate = currentDate.plusDays(1)
|
||||
|
||||
@ -361,7 +359,7 @@ class DashboardAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView
|
||||
binding: ItemDashboardLessonsBinding,
|
||||
header: TimetableHeader? = null,
|
||||
) {
|
||||
val currentDateTime = LocalDateTime.now()
|
||||
val currentDateTime = Instant.now()
|
||||
val nextLessons = timetableToShow.filter { it.end.isAfter(currentDateTime) }
|
||||
.sortedBy { it.start }
|
||||
|
||||
@ -386,7 +384,7 @@ class DashboardAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView
|
||||
private fun updateFirstLessonView(
|
||||
binding: ItemDashboardLessonsBinding,
|
||||
firstLesson: Timetable?,
|
||||
currentDateTime: LocalDateTime
|
||||
currentDateTime: Instant
|
||||
) {
|
||||
val context = binding.root.context
|
||||
val sansSerifFont = Typeface.create("sans-serif", Typeface.NORMAL)
|
||||
|
@ -15,8 +15,8 @@ import io.github.wulkanowy.utils.nextOrSameSchoolDay
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import javax.inject.Inject
|
||||
|
||||
class DashboardPresenter @Inject constructor(
|
||||
@ -532,7 +532,7 @@ class DashboardPresenter @Inject constructor(
|
||||
student = student,
|
||||
semester = semester,
|
||||
forceRefresh = forceRefresh,
|
||||
startDate = LocalDateTime.now()
|
||||
startDate = Instant.now(),
|
||||
)
|
||||
}.onEach {
|
||||
when (it.status) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
package io.github.wulkanowy.ui.modules.debug.notification.mock
|
||||
|
||||
import io.github.wulkanowy.data.db.entities.Conference
|
||||
import java.time.LocalDateTime
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
|
||||
val debugConferenceItems = listOf(
|
||||
generateConference(
|
||||
@ -53,6 +54,6 @@ private fun generateConference(title: String, subject: String) = Conference(
|
||||
diaryId = 0,
|
||||
agenda = "",
|
||||
conferenceId = 0,
|
||||
date = LocalDateTime.now().plusMinutes(10),
|
||||
date = Instant.now().plus(Duration.ofMinutes(10)),
|
||||
presentOnConference = "",
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.debug.notification.mock
|
||||
|
||||
import io.github.wulkanowy.data.db.entities.Message
|
||||
import java.time.LocalDateTime
|
||||
import java.time.Instant
|
||||
|
||||
val debugMessageItems = listOf(
|
||||
generateMessage("Kowalski Jan", "Tytuł"),
|
||||
@ -24,7 +24,7 @@ private fun generateMessage(sender: String, subject: String) = Message(
|
||||
messageId = 0,
|
||||
senderId = 0,
|
||||
recipient = "",
|
||||
date = LocalDateTime.now(),
|
||||
date = Instant.now(),
|
||||
folderId = 0,
|
||||
unread = true,
|
||||
removed = false,
|
||||
|
@ -1,8 +1,9 @@
|
||||
package io.github.wulkanowy.ui.modules.debug.notification.mock
|
||||
|
||||
import io.github.wulkanowy.data.db.entities.Timetable
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import kotlin.random.Random
|
||||
|
||||
val debugTimetableItems = listOf(
|
||||
@ -24,8 +25,8 @@ private fun generateTimetable(subject: String, room: String, roomOld: String) =
|
||||
diaryId = 0,
|
||||
date = LocalDate.now().minusDays(Random.nextLong(0, 8)),
|
||||
number = 1,
|
||||
start = LocalDateTime.now().plusHours(1),
|
||||
end = LocalDateTime.now(),
|
||||
start = Instant.now(),
|
||||
end = Instant.now().plus(Duration.ofHours(1)),
|
||||
subjectOld = "",
|
||||
group = "",
|
||||
room = room,
|
||||
|
@ -19,7 +19,8 @@ import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.flowWithResource
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import timber.log.Timber
|
||||
import java.time.LocalDate
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainPresenter @Inject constructor(
|
||||
@ -158,11 +159,11 @@ class MainPresenter @Inject constructor(
|
||||
prefRepository.inAppReviewCount++
|
||||
|
||||
if (prefRepository.inAppReviewDate == null) {
|
||||
prefRepository.inAppReviewDate = LocalDate.now()
|
||||
prefRepository.inAppReviewDate = Instant.now()
|
||||
}
|
||||
|
||||
if (!prefRepository.isAppReviewDone && prefRepository.inAppReviewCount >= 50 &&
|
||||
LocalDate.now().minusDays(14).isAfter(prefRepository.inAppReviewDate)
|
||||
Instant.now().minus(Duration.ofDays(14)).isAfter(prefRepository.inAppReviewDate)
|
||||
) {
|
||||
view?.showInAppReview()
|
||||
prefRepository.isAppReviewDone = true
|
||||
|
@ -79,9 +79,7 @@ class SyncPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun setSyncDateInView() {
|
||||
val lastSyncDate = preferencesRepository.lasSyncDate
|
||||
|
||||
if (lastSyncDate.year == 1970) return
|
||||
val lastSyncDate = preferencesRepository.lasSyncDate ?: return
|
||||
|
||||
view?.setLastSyncDate(lastSyncDate.toFormattedString("dd.MM.yyyy HH:mm:ss"))
|
||||
}
|
||||
|
@ -15,15 +15,10 @@ import io.github.wulkanowy.data.db.entities.Timetable
|
||||
import io.github.wulkanowy.data.enums.TimetableMode
|
||||
import io.github.wulkanowy.databinding.ItemTimetableBinding
|
||||
import io.github.wulkanowy.databinding.ItemTimetableSmallBinding
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.isJustFinished
|
||||
import io.github.wulkanowy.utils.isShowTimeUntil
|
||||
import io.github.wulkanowy.utils.left
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import io.github.wulkanowy.utils.until
|
||||
import io.github.wulkanowy.utils.*
|
||||
import timber.log.Timber
|
||||
import java.time.LocalDateTime
|
||||
import java.util.Timer
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.concurrent.timer
|
||||
|
||||
@ -167,7 +162,7 @@ class TimetableAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPreviousLesson(position: Int): LocalDateTime? {
|
||||
private fun getPreviousLesson(position: Int): Instant? {
|
||||
return items.filter { it.isStudentPlan }
|
||||
.getOrNull(position - 1 - items.filterIndexed { i, item -> i < position && !item.isStudentPlan }.size)
|
||||
?.let {
|
||||
|
@ -16,7 +16,7 @@ import io.github.wulkanowy.utils.capitalise
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import java.time.LocalDateTime
|
||||
import java.time.Instant
|
||||
|
||||
class TimetableDialog : DialogFragment() {
|
||||
|
||||
@ -192,7 +192,7 @@ class TimetableDialog : DialogFragment() {
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setTime(start: LocalDateTime, end: LocalDateTime) {
|
||||
private fun setTime(start: Instant, end: Instant) {
|
||||
binding.timetableDialogTimeValue.text =
|
||||
"${start.toFormattedString("HH:mm")} - ${end.toFormattedString("HH:mm")}"
|
||||
}
|
||||
|
@ -10,11 +10,9 @@ import io.github.wulkanowy.utils.lastSchoolDayInSchoolYear
|
||||
import io.github.wulkanowy.utils.toLocalDate
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.LocalTime
|
||||
import java.time.*
|
||||
import java.time.temporal.ChronoUnit
|
||||
import java.util.UUID
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AdditionalLessonAddPresenter @Inject constructor(
|
||||
@ -138,8 +136,8 @@ class AdditionalLessonAddPresenter @Inject constructor(
|
||||
TimetableAdditional(
|
||||
studentId = semester.studentId,
|
||||
diaryId = semester.diaryId,
|
||||
start = LocalDateTime.of(date, start),
|
||||
end = LocalDateTime.of(date, end),
|
||||
start = ZonedDateTime.of(date, start, ZoneId.systemDefault()).toInstant(),
|
||||
end = ZonedDateTime.of(date, end, ZoneId.systemDefault()).toInstant(),
|
||||
date = date.plusWeeks(it),
|
||||
subject = subject
|
||||
).apply {
|
||||
|
@ -29,7 +29,6 @@ import io.github.wulkanowy.utils.toFormattedString
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import timber.log.Timber
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneOffset
|
||||
|
||||
class TimetableWidgetFactory(
|
||||
private val timetableRepository: TimetableRepository,
|
||||
@ -77,7 +76,7 @@ class TimetableWidgetFactory(
|
||||
if (date == LocalDate.now() && todayLastLessonEndTimestamp != null) {
|
||||
sharedPref.putLong(
|
||||
key = getTodayLastLessonEndDateTimeWidgetKey(appWidgetId),
|
||||
value = todayLastLessonEndTimestamp.toEpochSecond(ZoneOffset.UTC),
|
||||
value = todayLastLessonEndTimestamp.epochSecond,
|
||||
sync = true
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user