Revert "All-day events do not span two days"

This reverts commit 19dc8872ca94c44c8094886c17f9b62160ac76cb.

Conflicts:
	src/com/android/calendar/CalendarController.java
	src/com/android/calendar/agenda/AgendaListView.java
	src/com/android/calendar/agenda/AgendaWindowAdapter.java

Change-Id: Ib7491b17294a4bb1988a92979d399d00d5e8ee2d
diff --git a/src/com/android/calendar/CalendarController.java b/src/com/android/calendar/CalendarController.java
index ffe1d3f..e0961b5 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.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 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 @@
             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 @@
         }
 
         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 @@
         } 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 @@
         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 @@
                 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 @@
                     if (mToBeRemovedEventHandlers.contains(key)) {
                         continue;
                     }
-                    if (DEBUG) {
-                        Log.d(TAG, "   " + getReadableEventType(event)
-                                + " - " + eventHandler.getClass().getSimpleName());
-                    }
                     eventHandler.handleEvent(event);
                     handled = true;
                 }
@@ -858,8 +825,10 @@
         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 @@
         } 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=");