Add deadline warning days to agenda; bugfixes

Query events for the agenda that are due in some number of days.

Include completed items that have a date within the span.

Fix bug in spanToNDays where for span == "Month" or "Year" the sign is
wrong. Fix another bug that when span == "Month" or "Year", nDays == 0.

Fix database connection leaks (seen in logcat when running an agenda
query after previously running one (either the same or another)). Make
sure we close the db in AgendaFragment and wrap OrgQueryBuilder's
cursor.close() in a finally block.

Prevent repeated allocation and deallocation of the variables in
matchesAgendaQuery by combining it with its calling method, getNodes,
and moving the variables outside the loop.