Etar-Calendar icon indicating copy to clipboard operation
Etar-Calendar copied to clipboard

Bug: Scrolling to January 1970

Open EukalyptusX opened this issue 2 years ago • 14 comments

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

Screenshot_20220424-094445~4

Screenshot_20220424-094454

EukalyptusX avatar Apr 24 '22 07:04 EukalyptusX

I'm not sure if this is somehow related.

https://github.com/Etar-Group/Etar-Calendar/issues/1036

EukalyptusX avatar Apr 24 '22 08:04 EukalyptusX

This does not happen, if you leave the app in the background after scrolling back to the current month (April). Then everything is fine. :-)

EukalyptusX avatar Apr 24 '22 08:04 EukalyptusX

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.

Gitsaibot avatar Apr 24 '22 15:04 Gitsaibot

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: TimeIssue

Gitsaibot avatar Apr 25 '22 16:04 Gitsaibot

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.

rugk avatar Apr 26 '22 22:04 rugk

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

Gitsaibot avatar May 20 '22 04:05 Gitsaibot

@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.

Gitsaibot avatar Aug 01 '22 19:08 Gitsaibot

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.

jonas-haeusler avatar Aug 08 '22 23:08 jonas-haeusler

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.

jonas-haeusler avatar Sep 11 '22 21:09 jonas-haeusler

Has anyone tested this. On my phone the patch has no effect!?

Gitsaibot avatar Sep 12 '22 15:09 Gitsaibot

submodule still needs to be updated, see https://github.com/Etar-Group/Etar-Calendar/pull/1232

jonas-haeusler avatar Sep 12 '22 19:09 jonas-haeusler

I did it already localy for testing but the bug persists. Did it work on your phone?

Gitsaibot avatar Sep 12 '22 20:09 Gitsaibot

it does. did you run the aarGen task before compiling?

jonas-haeusler avatar Sep 12 '22 21:09 jonas-haeusler

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.

Gitsaibot avatar Sep 13 '22 17:09 Gitsaibot

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

glocalglocal avatar Nov 12 '22 18:11 glocalglocal