forked from jens/Automation
calendar trigger
This commit is contained in:
parent
67238bd2f0
commit
b6bf31589a
@ -645,7 +645,7 @@ public class ActivityManageRule extends Activity
|
|||||||
else if(types[i].toString().equals(Trigger_Enum.subSystemState.toString()))
|
else if(types[i].toString().equals(Trigger_Enum.subSystemState.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.subsystemstate));
|
items.add(new Item(typesLong[i].toString(), R.drawable.subsystemstate));
|
||||||
else if(types[i].toString().equals(Trigger_Enum.calendarEvent.toString()))
|
else if(types[i].toString().equals(Trigger_Enum.calendarEvent.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.calendar));
|
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||||
else
|
else
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import com.jens.automation2.AutomationService;
|
import com.jens.automation2.AutomationService;
|
||||||
import com.jens.automation2.Miscellaneous;
|
import com.jens.automation2.Miscellaneous;
|
||||||
@ -95,8 +96,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
|
|
||||||
public static class CalendarEvent
|
public static class CalendarEvent
|
||||||
{
|
{
|
||||||
public String id, title, description, location, availability;
|
public String calendarId, eventId, title, description, location, availability;
|
||||||
public Calendar start, end;
|
public Calendar start, end;
|
||||||
|
public boolean allDay;
|
||||||
|
|
||||||
public boolean isCurrentActive()
|
public boolean isCurrentActive()
|
||||||
{
|
{
|
||||||
@ -107,10 +109,17 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
|
|
||||||
public static List<CalendarEvent> readCalendarEvents(Context context)
|
public static List<CalendarEvent> readCalendarEvents(Context context)
|
||||||
{
|
{
|
||||||
Cursor cursor = context.getContentResolver()
|
Cursor cursor;
|
||||||
.query(
|
|
||||||
|
// if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO)
|
||||||
|
// cursor = context.getContentResolver().query(
|
||||||
|
// Uri.parse("content://calendar/calendars"),
|
||||||
|
// new String[] { "calendar_id", "title", "description", "dtstart", "dtend", "eventLocation", "availability" },
|
||||||
|
// null, null, null);
|
||||||
|
// else
|
||||||
|
cursor = context.getContentResolver().query(
|
||||||
Uri.parse("content://com.android.calendar/events"),
|
Uri.parse("content://com.android.calendar/events"),
|
||||||
new String[] { "calendar_id", "title", "description", "dtstart", "dtend", "eventLocation", "availability" },
|
new String[] { "calendar_id", "original_id", "title", "description", "allDay", "dtstart", "dtend", "eventLocation", "availability" },
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
@ -124,13 +133,15 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
CalendarEvent event = new CalendarEvent();
|
CalendarEvent event = new CalendarEvent();
|
||||||
event.id = cursor.getString(1);
|
event.calendarId = cursor.getString(0);
|
||||||
|
event.eventId = cursor.getString(1);
|
||||||
event.title = cursor.getString(2);
|
event.title = cursor.getString(2);
|
||||||
event.description = cursor.getString(3);
|
event.description = cursor.getString(3);
|
||||||
event.start = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(4)));
|
event.allDay = cursor.getString(4).equals("1");
|
||||||
event.end = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(5)));
|
event.start = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(5)));
|
||||||
event.location = cursor.getString(6);
|
event.end = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(6)));
|
||||||
event.availability = cursor.getString(7);
|
event.location = cursor.getString(7);
|
||||||
|
event.availability = cursor.getString(8);
|
||||||
eventlist.add(event);
|
eventlist.add(event);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -138,6 +149,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
cursor.moveToNext();
|
cursor.moveToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(cursor != null)
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
return eventlist;
|
return eventlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user