no calender event

Post your questions and help other users.

Moderator: Martin

User avatar
Micha
Posts: 46
Joined: 27 Dec 2017 23:04

no calender event

Post by Micha » 31 Dec 2017 08:38

Hello again,

now I want to trigger "there's no calender event this day in calender xy".
I don't know how to make the negation in a trigger.

Micha

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: no calender event

Post by Desmanto » 31 Dec 2017 10:17

I also don't know any negation for calendar. Trigger no calendar won't works because it is an event. It must happen first.
You probably need to use Trigger time, and trigger at 00:00 everyday to check for any possible future calendar event.

Put the trigger Time at 00:00. Use action Query Content Provider, choose Examples and pick "All current calendar events".
The projection you need should be the startDay.
But maybe you might wanna try to uncheck the projection so it list all available field, and check Include Header row, result type as table.
Use debug dialog to check which variable you need.

If it is really startDay you need, then just use this, minus current time (getDate()). If the result is more than 24 hours, then there is no calendar event today, continue to your main flow.
Beware of the timezone, make sure you adjust your calculation accordingly
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Micha
Posts: 46
Joined: 27 Dec 2017 23:04

Re: no calender event

Post by Micha » 31 Dec 2017 12:45

Thank you very much. The most of your description I found. But where is the debug dialog?

Micha

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: no calender event

Post by Desmanto » 31 Dec 2017 13:54

Add a new condition, new > Debug dialog. Add it after the element you want to check the variable for. This is one of the most powerful feature from Automagic. You will soon use it so frequently.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Micha
Posts: 46
Joined: 27 Dec 2017 23:04

Re: no calender event

Post by Micha » 01 Jan 2018 12:12

Many thanks,

I need the columns calendar_displayName and allDay. I don't get the next event but actual event (allday events from actual day).

But how I can get a list of all the allday events from one special calendar named "Hamburg"? And how I can evaluate the result? I need a condition to test if the list is empty.

Once again: happy new year!

Micha

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: no calender event

Post by Desmanto » 01 Jan 2018 13:58

At the Content URI, you can see the full uri. There are two triggertime at the end, those denote the beginning and end. Change it to date you want. Or you can add days to it.
Content URI : content://com.android.calendar/instances/when/{triggertime}/{addDays(triggertime,30)}
Add 30 will show you all events from 30 days ahead. Since you ask "in this day", I assume it is today, thus I don't change it in the first post. You can set the beginning as well to cover other days.

At the projection, choose any field you need. The in the Selection, filter any field you need. Do Special Calendar named "Hamburg" means the calendar_displayName field? If yes, the in the selection, put
Selection : calendar_displayName like ?
Selection Arguments : %Hamburg%
The keyword like is to filter any calendar_displayName field that has "Hamburg" in it (case insensitive).
? denotes the argumet which can be replace with variable.
Enclosing % sign is for the like filter, meaning there can be any text before and after.
Hamburg can be replaced with variable, such as : %{filter}%
If you need exact match, change the like to equal sign : calendar_displayName = ?. Then remove the %, as it is not relevant for exact match : Hamburg

This filter work similar to SQL query, but without "WHERE" phrase.

You can change the result type to list and then check for the list using expression. Remember to uncheck the header row after you got the field you need, as the first row will counted as the result as well.

Code: Select all

isEmpty(event_titles)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Micha
Posts: 46
Joined: 27 Dec 2017 23:04

Re: no calender event

Post by Micha » 01 Jan 2018 14:33

Perfect! It works fine.
So far I have only allDay events in my calender.

How should I program it, if I wanted to say: look only for allDay events? I need two conditions in the where clause...

Micha

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: no calender event

Post by Desmanto » 01 Jan 2018 14:42

Just add : and allDay = 1 to the Selection.

Selection : calendar_displayName like ? and allDay = 1

AND logic will make sure only when both condition fulfilled, then the row is valid for the filter.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Micha
Posts: 46
Joined: 27 Dec 2017 23:04

Re: no calender event

Post by Micha » 01 Jan 2018 14:51

Very good, thank you. No other questions in this thread.

Micha

User avatar
Micha
Posts: 46
Joined: 27 Dec 2017 23:04

Re: no calender event

Post by Micha » 01 Jan 2018 16:40

Sorry, I have still another question...

Now I want to realize another flow, where I have to check the calender name and the title of the event.
calendar_displayName like ? and title like %conference% does not work. How I can realize the two conditions in this selection?

Micha
(Sorry for submitting too early.)

Post Reply