Etar-Calendar
Etar-Calendar copied to clipboard
Bug: Scrolling to January 1970
When scrolling in monthly view to a different month in the future, closing and reopening Etar (just put it in the background - do not force close), it says 'January 1970', but it still shows the monthly calender of June 2022 or whatever. If you now again put Etar in background and reopen it, it shows the monthly view for January 1970.
I'm using: Google Pixel 6 Stock ROM Android 12 Etar 1.0.30 from F-Droid
I'm not sure if this is somehow related.
https://github.com/Etar-Group/Etar-Calendar/issues/1036
This does not happen, if you leave the app in the background after scrolling back to the current month (April). Then everything is fine. :-)
It doesn't occur in version 1.0.29, so I think it's related to the changes in the time API. Maybe @chirayudesai and @mikeNG can have a look. I also looked at #1036 and reverted it, but it is not causing the problem.
I have found the place that is responsible for the error. But I am not quite clear about the cause and therefore need your help:
BTW it is reproducible for me by just locking the screen and unlocking it. But only if you scrolled/currently show a different month than the current month.
I dug a little deeper...
old api did this:
set(Time that) Copy the value of that to this Time object.
the new one in (.../calendarcommon2/Time.java) had this two functions:
public void set(long millis) {
clearCalendar();
mCalendar.setTimeInMillis(millis);
readFieldsFromCalendar();
}
public void set(Time other) {
clearCalendar();
mCalendar.setTimeZone(other.getTimeZone());
mCalendar.setTimeInMillis(other.mCalendar.getTimeInMillis());
readFieldsFromCalendar();
}
We use the second one and it seems that mCalendar.setTimeInMillis(other.mCalendar.getTimeInMillis());
always returns "1970"
The question now is what must be in the time object for this line to work?
mSelectedDay.set(time)
Any Idea? @chirayudesai and @mikeNG
@theimpulson Maybe you have an idea how to solve the problem or what needs to be done so that the line: mCalendar.setTimeInMillis(other.mCalendar.getTimeInMillis()); returns the correct date.
this seems to be a bug within the calendarcommon2 (Etar-Group/android_frameworks_opt_calendar) lib:
when calling set(Time other)
on the same instance that is passed into the method, the underlying calendar instance of the Time
object will be cleared, causing Calendar.getTimeInMillis()
to update/recompute the time from the cleared calendar instance, resulting in the invalid date.
so either don't pass the same instance here (coming from here) or patch the calendarcommon2 lib to do nothing when being called on itself.
i patched the calendarcommon2 lib as described above.
please see https://github.com/Etar-Group/android_frameworks_opt_calendar/pull/2 for the patched lib and https://github.com/Etar-Group/Etar-Calendar/pull/1231 for the modification and outstanding update of the git submodule.
this will require someone with push permission on https://github.com/Etar-Group/android_frameworks_opt_calendar to create the rebase
branch (and optionally update the repo description).
thank you.
Has anyone tested this. On my phone the patch has no effect!?
submodule still needs to be updated, see https://github.com/Etar-Group/Etar-Calendar/pull/1232
I did it already localy for testing but the bug persists. Did it work on your phone?
it does. did you run the aarGen
task before compiling?
Something like that, the aar files were not regenerated due to a permissions error on my end. With the newly generated files everything works. Thanks for the pull request.
After a year of using the app, I noticed this today for the first time. It must have started very recently, because it happens all the time and it is impossible to miss. I don't think I changed anything to do with the calendars.
Android 7, Etar 1.0.30