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()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.subsystemstate));
|
||||
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
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
@ -95,8 +96,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
|
||||
public static class CalendarEvent
|
||||
{
|
||||
public String id, title, description, location, availability;
|
||||
public String calendarId, eventId, title, description, location, availability;
|
||||
public Calendar start, end;
|
||||
public boolean allDay;
|
||||
|
||||
public boolean isCurrentActive()
|
||||
{
|
||||
@ -107,10 +109,17 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
|
||||
public static List<CalendarEvent> readCalendarEvents(Context context)
|
||||
{
|
||||
Cursor cursor = context.getContentResolver()
|
||||
.query(
|
||||
Cursor cursor;
|
||||
|
||||
// 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"),
|
||||
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);
|
||||
|
||||
cursor.moveToFirst();
|
||||
@ -124,13 +133,15 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
try
|
||||
{
|
||||
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.description = cursor.getString(3);
|
||||
event.start = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(4)));
|
||||
event.end = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(5)));
|
||||
event.location = cursor.getString(6);
|
||||
event.availability = cursor.getString(7);
|
||||
event.allDay = cursor.getString(4).equals("1");
|
||||
event.start = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(5)));
|
||||
event.end = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(6)));
|
||||
event.location = cursor.getString(7);
|
||||
event.availability = cursor.getString(8);
|
||||
eventlist.add(event);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -138,6 +149,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
cursor.moveToNext();
|
||||
}
|
||||
|
||||
if(cursor != null)
|
||||
cursor.close();
|
||||
|
||||
return eventlist;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user