plusonelabs / calendar-widget

An calender widget for your Android home screen.
Apache License 2.0
370 stars 127 forks source link

Using CalDAV - No widget sync. after calendar sync. #182

Closed anthraxn8b closed 5 years ago

anthraxn8b commented 9 years ago

When CalDAV syncs my calendar the widget is not updated.

yvolk commented 9 years ago

This is CalDAV deficiency: it doesn't broadcast proper notification on update. Anyway, we have "Refresh" button now in a widget header, which allows you to refresh the Calendar-widget on demand.

anthraxn8b commented 9 years ago

THX!

dmfs commented 9 years ago

Hi @yvolk , this is Marten, the developer of CalDAV-Sync. What broadcast do you mean? AFAIK, there is nothing that a sync adapter needs to send after syncing. If you're talking about ACTION_PROVIDER_CHANGED, that should be sent by the provider itself. What exactly is your widget listening for?

Also, we didn't receive any other reports about this. Widget updates work well with other calendar widgets.

yvolk commented 9 years ago

@dmfs Hi Marten, yes we use this filter for notifications on Calendar data changes:

           <intent-filter>
                <action android:name="android.intent.action.PROVIDER_CHANGED" />
                <data android:scheme="content" />
                <data android:host="com.android.calendar" />
            </intent-filter>

As suggested e.g. here: http://stackoverflow.com/questions/15217723/broadcastreceiver-for-android-calendar-events

As I understand the User's problem, after your app have synced events in some calendar provider, that provider doesn't broadcast this intent. I would suggest for your application to broadcast this intent and not rely on a concrete calendar provider implementation.

dmfs commented 9 years ago

Here is where the calendar provider sends the broadcast: CalendarProvider2.java line 4578

This method is called (indirectly) when events are inserted, updated or deleted.

I'm hesitating to make CalDAV-Sync send this broadcast, because that means on most devices the broadcast is sent twice (which will trigger all listening apps twice and waste precious resources). Also, it feels wrong to send such a broadcast from code that's not a content provider.

Lastly, I doubt, that any calendar app or any other sync app sends this broadcast, since that's the job of the content provider.

@anthraxn8b What kind of device do you use?

yvolk commented 9 years ago

@dmfs Please read this ticket and relax regarding duplicated broadcast: this intent is already sent (at least by some calendar applications...) even on an item selection... https://code.google.com/p/android/issues/detail?id=55675

The notification was not well thought by Android developers, and this mistake still causes confusions by developers of related components.

BTW, official Android documentation doesn't even mention this intent: http://developer.android.com/guide/topics/providers/calendar-provider.html

anthraxn8b commented 9 years ago

Device: Nexus 4 Android version: 4.4.4 Calendar app: aCalendar+ I do not use a google calendar! ;-)

dmfs commented 9 years ago

Presuming that @anthraxn8b is running the stock ROM, I'd say that the CalendarProvider most certainly sends the ACTION_PROVIDER_CHANGED broadcast.

@anthraxn8b do you know how to use adb? Usually the broadcast is logged to the system log like so (just captured the log on my Nexus 5):

10-16 11:05:13.741 27272 27272 I CalendarProvider2: Sending notification intent: Intent { act=android.intent.action.PROVIDER_CHANGED dat=content://com.android.calendar }

by running adb -d logcat you can check if the broadcast appears in the log after CalDAV-Sync synced new or updated events. If your device is rooted you could also use an app like "CatLog".

anthraxn8b commented 6 years ago

@dmfs Sorry, but I am no longer using the Nexus 5. This does not mean that I have no Problems related to calendar syncing any longer :-)

yvolk commented 5 years ago

In 2019 we solved the problem with syncing changes by addition to the Tasks app notification intent, sent directly to the ToDo Agenda app. Otherwise notifications are blocked by Android system. See https://github.com/plusonelabs/calendar-widget/issues/308 and related https://github.com/dmfs/opentasks/issues/822