summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.properties2
-rw-r--r--src/com/android/calendar/CalendarController.java77
-rw-r--r--src/com/android/calendar/agenda/AgendaListView.java26
-rw-r--r--src/com/android/calendar/agenda/AgendaWindowAdapter.java24
4 files changed, 39 insertions, 90 deletions
diff --git a/project.properties b/project.properties
index 48ef7f29..a960502c 100644
--- a/project.properties
+++ b/project.properties
@@ -12,6 +12,6 @@
# Project target.
target=android-17
-android.library=true
+android.library=false
android.library.reference.1=../../../frameworks/ex/chips
android.library.reference.2=../../../frameworks/opt/calendar
diff --git a/src/com/android/calendar/CalendarController.java b/src/com/android/calendar/CalendarController.java
index ffe1d3fd..e0961b5a 100644
--- a/src/com/android/calendar/CalendarController.java
+++ b/src/com/android/calendar/CalendarController.java
@@ -16,11 +16,14 @@
package com.android.calendar;
-import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY;
import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY;
import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS;
+import com.android.calendar.event.EditEventActivity;
+import com.android.calendar.selectcalendars.SelectVisibleCalendarsActivity;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
@@ -31,18 +34,18 @@ import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
import android.net.Uri;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.CalendarContract.Attendees;
import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
+import android.text.TextUtils;
import android.text.format.Time;
import android.util.Log;
import android.util.Pair;
-import com.android.calendar.event.EditEventActivity;
-import com.android.calendar.selectcalendars.SelectVisibleCalendarsActivity;
-
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -155,8 +158,8 @@ public class CalendarController {
public int viewType; // one of the ViewType
public long id; // event id
public Time selectedTime; // the selected time in focus
- public Time startTime; // start of a range of time (All day events should be in UTC).
- public Time endTime; // end of a range of time (All day events should be in UTC).
+ public Time startTime; // start of a range of time.
+ public Time endTime; // end of a range of time.
public int x; // x coordinate in the activity space
public int y; // y coordinate in the activity space
public String query; // query for a user search
@@ -335,11 +338,6 @@ public class CalendarController {
startMillis, endMillis, x, y, extraLong, selectedMillis, null, -1);
}
- private static boolean isViewAllDayEvent(long eventType, long extraLong) {
- return (eventType & EventType.VIEW_EVENT) != 0
- && (extraLong & EventInfo.ALL_DAY_MASK) != 0;
- }
-
/**
* Helper for sending New/View/Edit/Delete events
*
@@ -366,13 +364,7 @@ public class CalendarController {
}
info.id = eventId;
-
- if (isViewAllDayEvent(eventType, extraLong)) {
- info.startTime = new Time(Time.TIMEZONE_UTC);
- } else {
- info.startTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
- }
-
+ info.startTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
info.startTime.set(startMillis);
if (selectedMillis != -1) {
info.selectedTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
@@ -380,19 +372,13 @@ public class CalendarController {
} else {
info.selectedTime = info.startTime;
}
-
- if (isViewAllDayEvent(eventType, extraLong)) {
- info.endTime = new Time(Time.TIMEZONE_UTC);
- } else {
- info.endTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
- }
+ info.endTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
info.endTime.set(endMillis);
info.x = x;
info.y = y;
info.extraLong = extraLong;
info.eventTitle = title;
info.calendarId = calendarId;
-
this.sendEvent(sender, info);
}
/**
@@ -435,22 +421,11 @@ public class CalendarController {
this.sendEvent(sender, info);
}
- private static boolean atMidnightUTCTime(Time time) {
- return (time.timezone == Time.TIMEZONE_UTC
- && time.hour == 0 && time.minute == 0 && time.second == 0);
- }
-
public void sendEvent(Object sender, final EventInfo event) {
// TODO Throw exception on invalid events
if (DEBUG) {
- Log.d(TAG, eventInfoToString(event, sender));
- }
-
- if ( (event.eventType & EventType.VIEW_EVENT) != 0
- && (event.extraLong & EventInfo.ALL_DAY_MASK) != 0
- && !atMidnightUTCTime(event.startTime)) {
- Log.wtf(TAG, "All day events must be set to midnight in UTC time");
+ Log.d(TAG, eventInfoToString(event));
}
Long filteredTypes = filters.get(sender);
@@ -548,10 +523,6 @@ public class CalendarController {
EventHandler handler = mFirstEventHandler.second;
if (handler != null && (handler.getSupportedEventTypes() & event.eventType) != 0
&& !mToBeRemovedEventHandlers.contains(mFirstEventHandler.first)) {
- if (DEBUG) {
- Log.d(TAG, " " + getReadableEventType(event)
- + " - " + handler.getClass().getSimpleName());
- }
handler.handleEvent(event);
handled = true;
}
@@ -570,10 +541,6 @@ public class CalendarController {
if (mToBeRemovedEventHandlers.contains(key)) {
continue;
}
- if (DEBUG) {
- Log.d(TAG, " " + getReadableEventType(event)
- + " - " + eventHandler.getClass().getSimpleName());
- }
eventHandler.handleEvent(event);
handled = true;
}
@@ -858,8 +825,10 @@ public class CalendarController {
mEventId = eventId;
}
- private String getReadableEventType(EventInfo eventInfo) {
+ private String eventInfoToString(EventInfo eventInfo) {
String tmp = "Unknown";
+
+ StringBuilder builder = new StringBuilder();
if ((eventInfo.eventType & EventType.GO_TO) != 0) {
tmp = "Go to time/event";
} else if ((eventInfo.eventType & EventType.CREATE_EVENT) != 0) {
@@ -885,21 +854,7 @@ public class CalendarController {
} else if ((eventInfo.eventType & EventType.UPDATE_TITLE) != 0) {
tmp = "Update title";
}
- return tmp;
- }
-
- private String eventInfoToString(EventInfo eventInfo, Object sender) {
-
- StringBuilder builder = new StringBuilder();
- builder.append(getReadableEventType(eventInfo));
-
- if ( (eventInfo.eventType & EventType.VIEW_EVENT) != 0) {
- builder.append(" (")
- .append(sender.getClass().getSimpleName())
- .append("): all day=")
- .append((eventInfo.extraLong & EventInfo.ALL_DAY_MASK) != 0);
- }
-
+ builder.append(tmp);
builder.append(": id=");
builder.append(eventInfo.id);
builder.append(", selected=");
diff --git a/src/com/android/calendar/agenda/AgendaListView.java b/src/com/android/calendar/agenda/AgendaListView.java
index 2ba83225..7970e034 100644
--- a/src/com/android/calendar/agenda/AgendaListView.java
+++ b/src/com/android/calendar/agenda/AgendaListView.java
@@ -192,6 +192,10 @@ public class AgendaListView extends ListView implements OnItemClickListener {
} else {
holderStartTime = startTime;
}
+ if (item.allDay) {
+ startTime = Utils.convertAlldayLocalToUTC(mTime, startTime, mTimeZone);
+ endTime = Utils.convertAlldayLocalToUTC(mTime, endTime, mTimeZone);
+ }
mTime.set(startTime);
CalendarController controller = CalendarController.getInstance(mContext);
controller.sendEventRelatedEventWithExtra(this, EventType.VIEW_EVENT, item.id,
@@ -330,15 +334,11 @@ public class AgendaListView extends ListView implements OnItemClickListener {
if (child == null) {
return false;
}
-
int start = getPositionForView(child);
long milliTime = startTime.toMillis(true);
int childCount = getChildCount();
int eventsInAdapter = mWindowAdapter.getCount();
- if (DEBUG) {
- Log.d(TAG,"id: " + id + ", milliTime (after): " + milliTime);
- }
for (int i = 0; i < childCount; i++) {
if (i + start >= eventsInAdapter) {
break;
@@ -347,30 +347,14 @@ public class AgendaListView extends ListView implements OnItemClickListener {
if (agendaItem == null) {
continue;
}
-
- // If all-day event, it will be in UTC, so convert it to local time for comparison.
- long begin = agendaItem.begin;
- if (agendaItem.allDay) {
- begin = Utils.convertAlldayUtcToLocal(null, begin, mTimeZone);
- }
-
- if (DEBUG) {
- Log.d(TAG," id: " + agendaItem.id + ", startTime: " + agendaItem.begin);
- }
- if (agendaItem.id == id && begin == milliTime) {
+ if (agendaItem.id == id && agendaItem.begin == milliTime) {
View listItem = getChildAt(i);
if (listItem.getTop() <= getHeight() &&
listItem.getTop() >= mWindowAdapter.getStickyHeaderHeight()) {
- if (DEBUG) {
- Log.d(TAG, "MATCH");
- }
return true;
}
}
}
- if (DEBUG) {
- Log.d(TAG, "NO MATCH");
- }
return false;
}
diff --git a/src/com/android/calendar/agenda/AgendaWindowAdapter.java b/src/com/android/calendar/agenda/AgendaWindowAdapter.java
index 78e84c11..6f497b64 100644
--- a/src/com/android/calendar/agenda/AgendaWindowAdapter.java
+++ b/src/com/android/calendar/agenda/AgendaWindowAdapter.java
@@ -625,18 +625,30 @@ public class AgendaWindowAdapter extends BaseAdapter
agendaItem.end = cursor.getLong(AgendaWindowAdapter.INDEX_END);
agendaItem.startDay = cursor.getInt(AgendaWindowAdapter.INDEX_START_DAY);
agendaItem.allDay = cursor.getInt(AgendaWindowAdapter.INDEX_ALL_DAY) != 0;
-
- if (isDayHeader) { // Trim to midnight.
+ if (agendaItem.allDay) { // UTC
+ Time time = new Time(mTimeZone);
+ time.setJulianDay(Time.getJulianDay(agendaItem.begin, 0));
+ agendaItem.begin = time.toMillis(false /* use isDst */);
+ } else if (isDayHeader) { // Trim to midnight.
Time time = new Time(mTimeZone);
time.set(agendaItem.begin);
time.hour = 0;
time.minute = 0;
time.second = 0;
- agendaItem.begin = time.toMillis(false);
- } else {
- agendaItem.id = cursor.getLong(AgendaWindowAdapter.INDEX_EVENT_ID);
+ agendaItem.begin = time.toMillis(false /* use isDst */);
}
+ if (!isDayHeader) {
+ if (agendaItem.allDay) {
+ Time time = new Time(mTimeZone);
+ time.setJulianDay(Time.getJulianDay(agendaItem.end, 0));
+ agendaItem.end = time.toMillis(false /* use isDst */);
+ } else {
+ agendaItem.end = cursor.getLong(AgendaWindowAdapter.INDEX_END);
+ }
+
+ agendaItem.id = cursor.getLong(AgendaWindowAdapter.INDEX_EVENT_ID);
+ }
return agendaItem;
}
@@ -676,8 +688,6 @@ public class AgendaWindowAdapter extends BaseAdapter
AgendaItem item =
buildAgendaItemFromCursor(tempCursor, tempCursorPosition,
false);
- mSelectedVH = new AgendaAdapter.ViewHolder();
- mSelectedVH.allDay = item.allDay;
CalendarController.getInstance(mContext)
.sendEventRelatedEventWithExtra(this, EventType.VIEW_EVENT,
item.id, item.begin, item.end, 0,