Razeeman / Android-SimpleTimeTracker

Simple app that tracks time.
GNU General Public License v3.0
536 stars 68 forks source link

[Bug] ICS file export events UIDs are not consistent #154

Closed jlheflin closed 5 months ago

jlheflin commented 5 months ago

Hello! I have been using this amazing app for the past few days and honestly it is so feature packed that I just want to say thank you. I've noticed a small issue, when exporting the ICS file from the app, event UIDs are not consistent between exports. Here is an example from two exports of the same event:

Export 1:

BEGIN:VCALENDAR
PRODID:-//Simple Time Tracker//EN
VERSION:2.0
BEGIN:VEVENT
DTSTART:20240122T145000Z
DTEND:20240122T154000Z
UID:0287a093-18bf-4220-bee3-a58b29b1131a@stt
SUMMARY:CHEM 324
DESCRIPTION:Categories: Class, Work\nRecord tags: Class\n
END:VEVENT

Export 2:

BEGIN:VCALENDAR
PRODID:-//Simple Time Tracker//EN
VERSION:2.0
BEGIN:VEVENT
DTSTART:20240122T145000Z
DTEND:20240122T154000Z
UID:26b791a5-8997-4ae2-ba33-0b29146ccb86@stt
SUMMARY:CHEM 324
DESCRIPTION:Categories: Class, Work\nRecord tags: Class\n
END:VEVENT

I do not have much experience with ICS file formats, so this may not necessarily be a bug.

Razeeman commented 5 months ago

Hello! Thank you for pointing this out. I'm also not familiar this ICS so just made them unique on every export. Turns out this is not how it is supposed to be https://stackoverflow.com/a/25970005. Will try to fix this in the latest update.

jlheflin commented 5 months ago

Hey Razeeman, I'm trying to understand the structure of the app a little better, I don't have any experience with android app development but I was going to try my hand at implementing this fix on my own. I was able to edit the ICS export file and have a build that produces consistent UIDs, but it is dependent upon the record name, the time started, and time ended. This isn't exactly useful, since it poses a lot of restriction on what you can do post export (if you change the times, it changes the UID), so my thought was to try and generate a random UUID for each record at creation and then get that UUID each time an ICS file is exported.

My issue is that I don't really know where the Records are created in the app structure. If I knew where that was I could probably implement the UUID generation.

(This is mostly for my own fun, I don't necessarily think you'll be seeing a pull request from me but I think I can get it implemented.)

jlheflin commented 5 months ago

As of update 1.36 the issue seems to be fixed. Thank you!

Razeeman commented 5 months ago

Soory for the late reply. Yes, UID generation was changed in the latest release. Records are stored in the SQLite database, and there they have unique ids which conveniently can be used in the export.

Records are created here https://github.com/Razeeman/Android-SimpleTimeTracker/blob/448dc248962a048bbebe98633e886911d83edf2d/data_local/src/main/java/com/example/util/simpletimetracker/data_local/repo/RecordRepoImpl.kt#L120 through here https://github.com/Razeeman/Android-SimpleTimeTracker/blob/448dc248962a048bbebe98633e886911d83edf2d/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/AddRecordMediator.kt#L14