fix: improve all-day to timed event switch experience (#919)

* uses proper default start time and duration on disabling all-day flag

* edit CHANGELOG.md

* fix code style

* Update CHANGELOG.md

Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com>

* move one-time migration into toggledAllDay method

* apply same logic to tasks as well

* style: remove double empty lines

---------

Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com>

Refs: https://github.com/FossifyOrg/Calendar/issues/917
This commit is contained in:
fm-sys
2025-12-09 16:29:23 +01:00
committed by GitHub
parent 8063e3cdea
commit 03736fd08a
3 changed files with 50 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Use weekday abbreviations instead of single char weekday identifiers ([#103])
- Converting all-day events to timed events now respects default start time and duration ([#917])
### Fixed
- Fixed crashes and freezing affecting some devices ([#889])
@@ -195,6 +196,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#826]: https://github.com/FossifyOrg/Calendar/issues/826
[#870]: https://github.com/FossifyOrg/Calendar/issues/870
[#889]: https://github.com/FossifyOrg/Calendar/issues/889
[#917]: https://github.com/FossifyOrg/Calendar/issues/917
[Unreleased]: https://github.com/FossifyOrg/Calendar/compare/1.8.1...HEAD
[1.8.1]: https://github.com/FossifyOrg/Calendar/compare/1.8.0...1.8.1

View File

@@ -46,6 +46,7 @@ import org.fossify.calendar.extensions.config
import org.fossify.calendar.extensions.eventTypesDB
import org.fossify.calendar.extensions.eventsDB
import org.fossify.calendar.extensions.eventsHelper
import org.fossify.calendar.extensions.getNewEventTimestampFromCode
import org.fossify.calendar.extensions.getRepetitionText
import org.fossify.calendar.extensions.getShortDaysFromBitmask
import org.fossify.calendar.extensions.isXMonthlyRepetition
@@ -205,6 +206,7 @@ class EventActivity : SimpleActivity() {
private var mOriginalEndTS = 0L
private var mIsNewEvent = true
private var mEventColor = 0
private var mConvertedFromOriginalAllDay = false
private lateinit var mEventStartDateTime: DateTime
private lateinit var mEventEndDateTime: DateTime
@@ -1542,6 +1544,33 @@ class EventActivity : SimpleActivity() {
private fun toggleAllDay(isAllDay: Boolean) {
hideKeyboard()
// when converting from all-day to timed for the first time,
// set default start time and duration to avoid spanning into next day
if (!isAllDay && mEvent.getIsAllDay() && !mConvertedFromOriginalAllDay) {
val defaultStartTS = getNewEventTimestampFromCode(Formatter.getDayCodeFromDateTime(mEventStartDateTime))
val defaultStartTime = Formatter.getDateTimeFromTS(defaultStartTS)
val defaultDurationMinutes = config.defaultDuration
val endTime = defaultStartTime.plusMinutes(defaultDurationMinutes)
mEventStartDateTime = mEventStartDateTime.withTime(
defaultStartTime.hourOfDay,
defaultStartTime.minuteOfHour,
0,
0
)
mEventEndDateTime = mEventEndDateTime.withTime(
endTime.hourOfDay,
endTime.minuteOfHour,
0,
0
)
mConvertedFromOriginalAllDay = true
updateStartTexts()
updateEndTexts()
}
mIsAllDayEvent = isAllDay
binding.eventStartTime.beGoneIf(isAllDay)
binding.eventEndTime.beGoneIf(isAllDay)

View File

@@ -46,6 +46,7 @@ class TaskActivity : SimpleActivity() {
private var mLastSavePromptTS = 0L
private var mIsNewTask = true
private var mEventColor = 0
private var mConvertedFromOriginalAllDay = false
private val binding by viewBinding(ActivityTaskBinding::inflate)
@@ -646,6 +647,24 @@ class TaskActivity : SimpleActivity() {
private fun toggleAllDay(isChecked: Boolean) {
hideKeyboard()
// One-time migration: when converting from all-day to timed for the first time,
// set default start time to avoid unexpected time values
if (!isChecked && mTask.getIsAllDay() && !mConvertedFromOriginalAllDay) {
val defaultStartTS = getNewEventTimestampFromCode(Formatter.getDayCodeFromDateTime(mTaskDateTime))
val defaultStartTime = Formatter.getDateTimeFromTS(defaultStartTS)
mTaskDateTime = mTaskDateTime.withTime(
defaultStartTime.hourOfDay,
defaultStartTime.minuteOfHour,
0,
0
)
mConvertedFromOriginalAllDay = true
updateTimeText()
}
mIsAllDayTask = isChecked
binding.taskTime.beGoneIf(isChecked)
}