Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.calendar; |
| 18 | |
RoboErik | a27a886 | 2011-06-23 15:26:23 -0700 | [diff] [blame] | 19 | import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME; |
| 20 | import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME; |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 21 | import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY; |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 22 | import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS; |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 23 | |
Erik | 5f62079 | 2010-10-27 12:42:01 -0700 | [diff] [blame] | 24 | import com.android.calendar.event.EditEventActivity; |
Michael Chan | 2aeb8d9 | 2011-07-10 13:32:09 -0700 | [diff] [blame] | 25 | import com.android.calendar.selectcalendars.SelectVisibleCalendarsActivity; |
Erik | 5f62079 | 2010-10-27 12:42:01 -0700 | [diff] [blame] | 26 | |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 27 | import android.accounts.Account; |
Andy McFadden | 7dcd301 | 2011-11-17 13:47:13 -0800 | [diff] [blame] | 28 | import android.accounts.AccountManager; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 29 | import android.app.Activity; |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 30 | import android.app.SearchManager; |
| 31 | import android.app.SearchableInfo; |
| 32 | import android.content.ComponentName; |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 33 | import android.content.ContentResolver; |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 34 | import android.content.ContentUris; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 35 | import android.content.Context; |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 36 | import android.content.Intent; |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 37 | import android.database.Cursor; |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 38 | import android.net.Uri; |
Erik | 7116ba4 | 2010-07-23 10:13:36 -0700 | [diff] [blame] | 39 | import android.os.AsyncTask; |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 40 | import android.os.Bundle; |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 41 | import android.provider.CalendarContract.Attendees; |
RoboErik | a7c0390 | 2011-06-14 11:06:44 -0700 | [diff] [blame] | 42 | import android.provider.CalendarContract.Calendars; |
| 43 | import android.provider.CalendarContract.Events; |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 44 | import android.text.TextUtils; |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 45 | import android.text.format.Time; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 46 | import android.util.Log; |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 47 | import android.util.Pair; |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 48 | |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 49 | import java.util.Iterator; |
| 50 | import java.util.LinkedHashMap; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 51 | import java.util.LinkedList; |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 52 | import java.util.Map.Entry; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 53 | import java.util.WeakHashMap; |
| 54 | |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 55 | public class CalendarController { |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 56 | private static final boolean DEBUG = false; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 57 | private static final String TAG = "CalendarController"; |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 58 | private static final String REFRESH_SELECTION = Calendars.SYNC_EVENTS + "=?"; |
| 59 | private static final String[] REFRESH_ARGS = new String[] { "1" }; |
RoboErik | 0e1e624 | 2011-05-05 15:25:02 -0700 | [diff] [blame] | 60 | private static final String REFRESH_ORDER = Calendars.ACCOUNT_NAME + "," |
| 61 | + Calendars.ACCOUNT_TYPE; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 62 | |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 63 | public static final String EVENT_EDIT_ON_LAUNCH = "editMode"; |
| 64 | |
Erik | 981874e | 2010-10-05 16:52:52 -0700 | [diff] [blame] | 65 | public static final int MIN_CALENDAR_YEAR = 1970; |
| 66 | public static final int MAX_CALENDAR_YEAR = 2036; |
| 67 | public static final int MIN_CALENDAR_WEEK = 0; |
| 68 | public static final int MAX_CALENDAR_WEEK = 3497; // weeks between 1/1/1970 and 1/1/2037 |
| 69 | |
Isaac Katzenelson | 60f01c2 | 2011-06-03 15:42:01 -0700 | [diff] [blame] | 70 | public static final String EVENT_ATTENDEE_RESPONSE = "attendeeResponse"; |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 71 | |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 72 | private final Context mContext; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 73 | |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 74 | // This uses a LinkedHashMap so that we can replace fragments based on the |
| 75 | // view id they are being expanded into since we can't guarantee a reference |
| 76 | // to the handler will be findable |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 77 | private final LinkedHashMap<Integer,EventHandler> eventHandlers = |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 78 | new LinkedHashMap<Integer,EventHandler>(5); |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 79 | private final LinkedList<Integer> mToBeRemovedEventHandlers = new LinkedList<Integer>(); |
| 80 | private final LinkedHashMap<Integer, EventHandler> mToBeAddedEventHandlers = new LinkedHashMap< |
Erik | cb81189 | 2010-09-28 13:44:19 -0700 | [diff] [blame] | 81 | Integer, EventHandler>(); |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 82 | private Pair<Integer, EventHandler> mFirstEventHandler; |
| 83 | private Pair<Integer, EventHandler> mToBeAddedFirstEventHandler; |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 84 | private volatile int mDispatchInProgressCounter = 0; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 85 | |
Michael Chan | 0558def | 2010-07-22 21:30:32 -0700 | [diff] [blame] | 86 | private static WeakHashMap<Context, CalendarController> instances = |
| 87 | new WeakHashMap<Context, CalendarController>(); |
| 88 | |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 89 | private final WeakHashMap<Object, Long> filters = new WeakHashMap<Object, Long>(1); |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 90 | |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 91 | private int mViewType = -1; |
Michael Chan | 85e5509 | 2010-07-27 15:18:40 -0700 | [diff] [blame] | 92 | private int mDetailViewType = -1; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 93 | private int mPreviousViewType = -1; |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 94 | private long mEventId = -1; |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 95 | private final Time mTime = new Time(); |
RoboErik | c8e0f21 | 2011-10-13 17:57:39 -0700 | [diff] [blame] | 96 | private long mDateFlags = 0; |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 97 | |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 98 | private final Runnable mUpdateTimezone = new Runnable() { |
RoboErik | 4679f60 | 2011-03-24 15:39:40 -0700 | [diff] [blame] | 99 | @Override |
| 100 | public void run() { |
| 101 | mTime.switchTimezone(Utils.getTimeZone(mContext, this)); |
| 102 | } |
| 103 | }; |
| 104 | |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 105 | /** |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 106 | * One of the event types that are sent to or from the controller |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 107 | */ |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 108 | public interface EventType { |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 109 | final long CREATE_EVENT = 1L; |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 110 | |
| 111 | // Simple view of an event |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 112 | final long VIEW_EVENT = 1L << 1; |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 113 | |
| 114 | // Full detail view in read only mode |
| 115 | final long VIEW_EVENT_DETAILS = 1L << 2; |
| 116 | |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 117 | // full detail view in edit mode |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 118 | final long EDIT_EVENT = 1L << 3; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 119 | |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 120 | final long DELETE_EVENT = 1L << 4; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 121 | |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 122 | final long GO_TO = 1L << 5; |
Erik | 954c871 | 2010-08-06 10:12:34 -0700 | [diff] [blame] | 123 | |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 124 | final long LAUNCH_SETTINGS = 1L << 6; |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 125 | |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 126 | final long EVENTS_CHANGED = 1L << 7; |
| 127 | |
| 128 | final long SEARCH = 1L << 8; |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 129 | |
| 130 | // User has pressed the home key |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 131 | final long USER_HOME = 1L << 9; |
Erik | eaafa2b | 2010-12-23 14:30:37 -0800 | [diff] [blame] | 132 | |
| 133 | // date range has changed, update the title |
| 134 | final long UPDATE_TITLE = 1L << 10; |
Michael Chan | 2aeb8d9 | 2011-07-10 13:32:09 -0700 | [diff] [blame] | 135 | |
| 136 | // select which calendars to display |
| 137 | final long LAUNCH_SELECT_VISIBLE_CALENDARS = 1L << 11; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 138 | } |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 141 | * One of the Agenda/Day/Week/Month view types |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 142 | */ |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 143 | public interface ViewType { |
Michael Chan | d6734db | 2010-07-22 00:48:08 -0700 | [diff] [blame] | 144 | final int DETAIL = -1; |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 145 | final int CURRENT = 0; |
| 146 | final int AGENDA = 1; |
| 147 | final int DAY = 2; |
| 148 | final int WEEK = 3; |
| 149 | final int MONTH = 4; |
Erik | dd95df5 | 2010-08-27 09:31:18 -0700 | [diff] [blame] | 150 | final int EDIT = 5; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 153 | public static class EventInfo { |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 154 | |
| 155 | private static final long ATTENTEE_STATUS_MASK = 0xFF; |
| 156 | private static final long ALL_DAY_MASK = 0x100; |
| 157 | private static final int ATTENDEE_STATUS_NONE_MASK = 0x01; |
| 158 | private static final int ATTENDEE_STATUS_ACCEPTED_MASK = 0x02; |
| 159 | private static final int ATTENDEE_STATUS_DECLINED_MASK = 0x04; |
| 160 | private static final int ATTENDEE_STATUS_TENTATIVE_MASK = 0x08; |
| 161 | |
Mason Tang | 00b8c1a | 2010-08-23 12:02:00 -0700 | [diff] [blame] | 162 | public long eventType; // one of the EventType |
| 163 | public int viewType; // one of the ViewType |
| 164 | public long id; // event id |
| 165 | public Time selectedTime; // the selected time in focus |
| 166 | public Time startTime; // start of a range of time. |
| 167 | public Time endTime; // end of a range of time. |
| 168 | public int x; // x coordinate in the activity space |
| 169 | public int y; // y coordinate in the activity space |
| 170 | public String query; // query for a user search |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 171 | public ComponentName componentName; // used in combination with query |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * For EventType.VIEW_EVENT: |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 175 | * It is the default attendee response and an all day event indicator. |
| 176 | * Set to Attendees.ATTENDEE_STATUS_NONE, Attendees.ATTENDEE_STATUS_ACCEPTED, |
| 177 | * Attendees.ATTENDEE_STATUS_DECLINED, or Attendees.ATTENDEE_STATUS_TENTATIVE. |
| 178 | * To signal the event is an all-day event, "or" ALL_DAY_MASK with the response. |
| 179 | * Alternatively, use buildViewExtraLong(), getResponse(), and isAllDay(). |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 180 | * <p> |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 181 | * For EventType.CREATE_EVENT: |
| 182 | * Set to {@link #EXTRA_CREATE_ALL_DAY} for creating an all-day event. |
| 183 | * <p> |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 184 | * For EventType.GO_TO: |
| 185 | * Set to {@link #EXTRA_GOTO_TIME} to go to the specified date/time. |
| 186 | * Set to {@link #EXTRA_GOTO_DATE} to consider the date but ignore the time. |
Michael Chan | fb0ec22 | 2011-08-12 17:39:30 -0700 | [diff] [blame] | 187 | * Set to {@link #EXTRA_GOTO_BACK_TO_PREVIOUS} if back should bring back previous view. |
RoboErik | 5b87252 | 2011-10-03 17:24:50 -0700 | [diff] [blame] | 188 | * Set to {@link #EXTRA_GOTO_TODAY} if this is a user request to go to the current time. |
Michael Chan | fb0ec22 | 2011-08-12 17:39:30 -0700 | [diff] [blame] | 189 | * <p> |
| 190 | * For EventType.UPDATE_TITLE: |
| 191 | * Set formatting flags for Utils.formatDateRange |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 192 | */ |
| 193 | public long extraLong; |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 194 | |
| 195 | public boolean isAllDay() { |
| 196 | if (eventType != EventType.VIEW_EVENT) { |
| 197 | Log.wtf(TAG, "illegal call to isAllDay , wrong event type " + eventType); |
| 198 | return false; |
| 199 | } |
| 200 | return ((extraLong & ALL_DAY_MASK) != 0) ? true : false; |
| 201 | } |
| 202 | |
| 203 | public int getResponse() { |
| 204 | if (eventType != EventType.VIEW_EVENT) { |
| 205 | Log.wtf(TAG, "illegal call to getResponse , wrong event type " + eventType); |
| 206 | return Attendees.ATTENDEE_STATUS_NONE; |
| 207 | } |
| 208 | |
| 209 | int response = (int)(extraLong & ATTENTEE_STATUS_MASK); |
| 210 | switch (response) { |
| 211 | case ATTENDEE_STATUS_NONE_MASK: |
| 212 | return Attendees.ATTENDEE_STATUS_NONE; |
| 213 | case ATTENDEE_STATUS_ACCEPTED_MASK: |
| 214 | return Attendees.ATTENDEE_STATUS_ACCEPTED; |
| 215 | case ATTENDEE_STATUS_DECLINED_MASK: |
| 216 | return Attendees.ATTENDEE_STATUS_DECLINED; |
| 217 | case ATTENDEE_STATUS_TENTATIVE_MASK: |
| 218 | return Attendees.ATTENDEE_STATUS_TENTATIVE; |
| 219 | default: |
| 220 | Log.wtf(TAG,"Unknown attendee response " + response); |
| 221 | } |
| 222 | return ATTENDEE_STATUS_NONE_MASK; |
| 223 | } |
| 224 | |
| 225 | // Used to build the extra long for a VIEW event. |
| 226 | public static long buildViewExtraLong(int response, boolean allDay) { |
| 227 | long extra = allDay ? ALL_DAY_MASK : 0; |
| 228 | |
| 229 | switch (response) { |
| 230 | case Attendees.ATTENDEE_STATUS_NONE: |
| 231 | extra |= ATTENDEE_STATUS_NONE_MASK; |
| 232 | break; |
| 233 | case Attendees.ATTENDEE_STATUS_ACCEPTED: |
| 234 | extra |= ATTENDEE_STATUS_ACCEPTED_MASK; |
| 235 | break; |
| 236 | case Attendees.ATTENDEE_STATUS_DECLINED: |
| 237 | extra |= ATTENDEE_STATUS_DECLINED_MASK; |
| 238 | break; |
| 239 | case Attendees.ATTENDEE_STATUS_TENTATIVE: |
| 240 | extra |= ATTENDEE_STATUS_TENTATIVE_MASK; |
| 241 | break; |
| 242 | default: |
| 243 | Log.wtf(TAG,"Unknown attendee response " + response); |
| 244 | extra |= ATTENDEE_STATUS_NONE_MASK; |
| 245 | break; |
| 246 | } |
| 247 | return extra; |
| 248 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 251 | /** |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 252 | * Pass to the ExtraLong parameter for EventType.CREATE_EVENT to create |
| 253 | * an all-day event |
| 254 | */ |
| 255 | public static final long EXTRA_CREATE_ALL_DAY = 0x10; |
| 256 | |
| 257 | /** |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 258 | * Pass to the ExtraLong parameter for EventType.GO_TO to signal the time |
| 259 | * can be ignored |
| 260 | */ |
| 261 | public static final long EXTRA_GOTO_DATE = 1; |
Michael Chan | fb0ec22 | 2011-08-12 17:39:30 -0700 | [diff] [blame] | 262 | public static final long EXTRA_GOTO_TIME = 2; |
| 263 | public static final long EXTRA_GOTO_BACK_TO_PREVIOUS = 4; |
RoboErik | 5b87252 | 2011-10-03 17:24:50 -0700 | [diff] [blame] | 264 | public static final long EXTRA_GOTO_TODAY = 8; |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 265 | |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 266 | public interface EventHandler { |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 267 | long getSupportedEventTypes(); |
| 268 | void handleEvent(EventInfo event); |
| 269 | |
| 270 | /** |
Erik | 954c871 | 2010-08-06 10:12:34 -0700 | [diff] [blame] | 271 | * This notifies the handler that the database has changed and it should |
| 272 | * update its view. |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 273 | */ |
| 274 | void eventsChanged(); |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Michael Chan | 0558def | 2010-07-22 21:30:32 -0700 | [diff] [blame] | 277 | /** |
| 278 | * Creates and/or returns an instance of CalendarController associated with |
| 279 | * the supplied context. It is best to pass in the current Activity. |
| 280 | * |
| 281 | * @param context The activity if at all possible. |
| 282 | */ |
| 283 | public static CalendarController getInstance(Context context) { |
| 284 | synchronized (instances) { |
| 285 | CalendarController controller = instances.get(context); |
| 286 | if (controller == null) { |
| 287 | controller = new CalendarController(context); |
| 288 | instances.put(context, controller); |
| 289 | } |
| 290 | return controller; |
| 291 | } |
| 292 | } |
| 293 | |
Erik | ed61b48 | 2010-08-13 13:59:50 -0700 | [diff] [blame] | 294 | /** |
| 295 | * Removes an instance when it is no longer needed. This should be called in |
| 296 | * an activity's onDestroy method. |
| 297 | * |
| 298 | * @param context The activity used to create the controller |
| 299 | */ |
| 300 | public static void removeInstance(Context context) { |
| 301 | instances.remove(context); |
| 302 | } |
| 303 | |
Michael Chan | 0558def | 2010-07-22 21:30:32 -0700 | [diff] [blame] | 304 | private CalendarController(Context context) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 305 | mContext = context; |
RoboErik | 4679f60 | 2011-03-24 15:39:40 -0700 | [diff] [blame] | 306 | mUpdateTimezone.run(); |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 307 | mTime.setToNow(); |
Michael Chan | 85e5509 | 2010-07-27 15:18:40 -0700 | [diff] [blame] | 308 | mDetailViewType = Utils.getSharedPreference(mContext, |
Daisuke Miyakawa | 4b441bd | 2010-09-16 14:55:36 -0700 | [diff] [blame] | 309 | GeneralPreferences.KEY_DETAILED_VIEW, |
| 310 | GeneralPreferences.DEFAULT_DETAILED_VIEW); |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 311 | } |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 312 | |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 313 | public void sendEventRelatedEvent(Object sender, long eventType, long eventId, long startMillis, |
RoboErik | 87f993f | 2011-02-03 17:47:20 -0800 | [diff] [blame] | 314 | long endMillis, int x, int y, long selectedMillis) { |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 315 | // TODO: pass the real allDay status or at least a status that says we don't know the |
| 316 | // status and have the receiver query the data. |
| 317 | // The current use of this method for VIEW_EVENT is by the day view to show an EventInfo |
| 318 | // so currently the missing allDay status has no effect. |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 319 | sendEventRelatedEventWithExtra(sender, eventType, eventId, startMillis, endMillis, x, y, |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 320 | EventInfo.buildViewExtraLong(Attendees.ATTENDEE_STATUS_NONE, false), |
| 321 | selectedMillis); |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 322 | } |
| 323 | |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 324 | /** |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 325 | * Helper for sending New/View/Edit/Delete events |
| 326 | * |
| 327 | * @param sender object of the caller |
| 328 | * @param eventType one of {@link EventType} |
| 329 | * @param eventId event id |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 330 | * @param startMillis start time |
| 331 | * @param endMillis end time |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 332 | * @param x x coordinate in the activity space |
| 333 | * @param y y coordinate in the activity space |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 334 | * @param extraLong default response value for the "simple event view" and all day indication. |
| 335 | * Use Attendees.ATTENDEE_STATUS_NONE for no response. |
RoboErik | 87f993f | 2011-02-03 17:47:20 -0800 | [diff] [blame] | 336 | * @param selectedMillis The time to specify as selected |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 337 | */ |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 338 | public void sendEventRelatedEventWithExtra(Object sender, long eventType, long eventId, |
RoboErik | 87f993f | 2011-02-03 17:47:20 -0800 | [diff] [blame] | 339 | long startMillis, long endMillis, int x, int y, long extraLong, long selectedMillis) { |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 340 | EventInfo info = new EventInfo(); |
| 341 | info.eventType = eventType; |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 342 | if (eventType == EventType.EDIT_EVENT || eventType == EventType.VIEW_EVENT_DETAILS) { |
Erik | 5f62079 | 2010-10-27 12:42:01 -0700 | [diff] [blame] | 343 | info.viewType = ViewType.CURRENT; |
Erik | dd95df5 | 2010-08-27 09:31:18 -0700 | [diff] [blame] | 344 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 345 | info.id = eventId; |
RoboErik | 4679f60 | 2011-03-24 15:39:40 -0700 | [diff] [blame] | 346 | info.startTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone)); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 347 | info.startTime.set(startMillis); |
RoboErik | 87f993f | 2011-02-03 17:47:20 -0800 | [diff] [blame] | 348 | if (selectedMillis != -1) { |
RoboErik | 4679f60 | 2011-03-24 15:39:40 -0700 | [diff] [blame] | 349 | info.selectedTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone)); |
RoboErik | 87f993f | 2011-02-03 17:47:20 -0800 | [diff] [blame] | 350 | info.selectedTime.set(selectedMillis); |
| 351 | } else { |
| 352 | info.selectedTime = info.startTime; |
| 353 | } |
RoboErik | 4679f60 | 2011-03-24 15:39:40 -0700 | [diff] [blame] | 354 | info.endTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone)); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 355 | info.endTime.set(endMillis); |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 356 | info.x = x; |
| 357 | info.y = y; |
Michael Chan | deced89 | 2010-12-10 15:59:35 -0800 | [diff] [blame] | 358 | info.extraLong = extraLong; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 359 | this.sendEvent(sender, info); |
| 360 | } |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 361 | |
| 362 | /** |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 363 | * Helper for sending non-calendar-event events |
| 364 | * |
| 365 | * @param sender object of the caller |
| 366 | * @param eventType one of {@link EventType} |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 367 | * @param start start time |
| 368 | * @param end end time |
Michael Chan | d6734db | 2010-07-22 00:48:08 -0700 | [diff] [blame] | 369 | * @param eventId event id |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 370 | * @param viewType {@link ViewType} |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 371 | */ |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 372 | public void sendEvent(Object sender, long eventType, Time start, Time end, long eventId, |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 373 | int viewType) { |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 374 | sendEvent(sender, eventType, start, end, start, eventId, viewType, EXTRA_GOTO_TIME, null, |
| 375 | null); |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | /** |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 379 | * sendEvent() variant with extraLong, search query, and search component name. |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 380 | */ |
| 381 | public void sendEvent(Object sender, long eventType, Time start, Time end, long eventId, |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 382 | int viewType, long extraLong, String query, ComponentName componentName) { |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 383 | sendEvent(sender, eventType, start, end, start, eventId, viewType, extraLong, query, |
| 384 | componentName); |
| 385 | } |
| 386 | |
| 387 | public void sendEvent(Object sender, long eventType, Time start, Time end, Time selected, |
| 388 | long eventId, int viewType, long extraLong, String query, ComponentName componentName) { |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 389 | EventInfo info = new EventInfo(); |
| 390 | info.eventType = eventType; |
| 391 | info.startTime = start; |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 392 | info.selectedTime = selected; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 393 | info.endTime = end; |
| 394 | info.id = eventId; |
| 395 | info.viewType = viewType; |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 396 | info.query = query; |
| 397 | info.componentName = componentName; |
Michael Chan | 46a8b11 | 2010-12-14 16:36:27 -0800 | [diff] [blame] | 398 | info.extraLong = extraLong; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 399 | this.sendEvent(sender, info); |
| 400 | } |
| 401 | |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 402 | public void sendEvent(Object sender, final EventInfo event) { |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 403 | // TODO Throw exception on invalid events |
| 404 | |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 405 | if (DEBUG) { |
| 406 | Log.d(TAG, eventInfoToString(event)); |
| 407 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 408 | |
| 409 | Long filteredTypes = filters.get(sender); |
| 410 | if (filteredTypes != null && (filteredTypes.longValue() & event.eventType) != 0) { |
| 411 | // Suppress event per filter |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 412 | if (DEBUG) { |
| 413 | Log.d(TAG, "Event suppressed"); |
| 414 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 415 | return; |
| 416 | } |
| 417 | |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 418 | mPreviousViewType = mViewType; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 419 | |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 420 | // Fix up view if not specified |
Michael Chan | d6734db | 2010-07-22 00:48:08 -0700 | [diff] [blame] | 421 | if (event.viewType == ViewType.DETAIL) { |
Michael Chan | 85e5509 | 2010-07-27 15:18:40 -0700 | [diff] [blame] | 422 | event.viewType = mDetailViewType; |
| 423 | mViewType = mDetailViewType; |
Michael Chan | d6734db | 2010-07-22 00:48:08 -0700 | [diff] [blame] | 424 | } else if (event.viewType == ViewType.CURRENT) { |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 425 | event.viewType = mViewType; |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 426 | } else if (event.viewType != ViewType.EDIT) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 427 | mViewType = event.viewType; |
Michael Chan | 85e5509 | 2010-07-27 15:18:40 -0700 | [diff] [blame] | 428 | |
Erik | 63cd053 | 2011-01-26 14:16:03 -0800 | [diff] [blame] | 429 | if (event.viewType == ViewType.AGENDA || event.viewType == ViewType.DAY |
| 430 | || (Utils.getAllowWeekForDetailView() && event.viewType == ViewType.WEEK)) { |
Michael Chan | 85e5509 | 2010-07-27 15:18:40 -0700 | [diff] [blame] | 431 | mDetailViewType = mViewType; |
| 432 | } |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 435 | if (DEBUG) { |
| 436 | Log.e(TAG, "vvvvvvvvvvvvvvv"); |
| 437 | Log.e(TAG, "Start " + (event.startTime == null ? "null" : event.startTime.toString())); |
| 438 | Log.e(TAG, "End " + (event.endTime == null ? "null" : event.endTime.toString())); |
| 439 | Log.e(TAG, "Select " + (event.selectedTime == null ? "null" : event.selectedTime.toString())); |
| 440 | Log.e(TAG, "mTime " + (mTime == null ? "null" : mTime.toString())); |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 441 | } |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 442 | |
| 443 | long startMillis = 0; |
| 444 | if (event.startTime != null) { |
| 445 | startMillis = event.startTime.toMillis(false); |
| 446 | } |
| 447 | |
| 448 | // Set mTime if selectedTime is set |
| 449 | if (event.selectedTime != null && event.selectedTime.toMillis(false) != 0) { |
| 450 | mTime.set(event.selectedTime); |
| 451 | } else { |
| 452 | if (startMillis != 0) { |
| 453 | // selectedTime is not set so set mTime to startTime iff it is not |
| 454 | // within start and end times |
| 455 | long mtimeMillis = mTime.toMillis(false); |
| 456 | if (mtimeMillis < startMillis |
| 457 | || (event.endTime != null && mtimeMillis > event.endTime.toMillis(false))) { |
| 458 | mTime.set(event.startTime); |
| 459 | } |
| 460 | } |
| 461 | event.selectedTime = mTime; |
| 462 | } |
RoboErik | c8e0f21 | 2011-10-13 17:57:39 -0700 | [diff] [blame] | 463 | // Store the formatting flags if this is an update to the title |
| 464 | if (event.eventType == EventType.UPDATE_TITLE) { |
| 465 | mDateFlags = event.extraLong; |
| 466 | } |
Michael Chan | f0868f6 | 2011-01-11 19:37:35 -0800 | [diff] [blame] | 467 | |
| 468 | // Fix up start time if not specified |
| 469 | if (startMillis == 0) { |
| 470 | event.startTime = mTime; |
| 471 | } |
| 472 | if (DEBUG) { |
| 473 | Log.e(TAG, "Start " + (event.startTime == null ? "null" : event.startTime.toString())); |
| 474 | Log.e(TAG, "End " + (event.endTime == null ? "null" : event.endTime.toString())); |
| 475 | Log.e(TAG, "Select " + (event.selectedTime == null ? "null" : event.selectedTime.toString())); |
| 476 | Log.e(TAG, "mTime " + (mTime == null ? "null" : mTime.toString())); |
| 477 | Log.e(TAG, "^^^^^^^^^^^^^^^"); |
| 478 | } |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 479 | |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 480 | // Store the eventId if we're entering edit event |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 481 | if ((event.eventType |
| 482 | & (EventType.CREATE_EVENT | EventType.EDIT_EVENT | EventType.VIEW_EVENT_DETAILS)) |
| 483 | != 0) { |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 484 | if (event.id > 0) { |
| 485 | mEventId = event.id; |
| 486 | } else { |
| 487 | mEventId = -1; |
| 488 | } |
| 489 | } |
| 490 | |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 491 | boolean handled = false; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 492 | synchronized (this) { |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 493 | mDispatchInProgressCounter ++; |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 494 | |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 495 | if (DEBUG) { |
| 496 | Log.d(TAG, "sendEvent: Dispatching to " + eventHandlers.size() + " handlers"); |
| 497 | } |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 498 | // Dispatch to event handler(s) |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 499 | if (mFirstEventHandler != null) { |
| 500 | // Handle the 'first' one before handling the others |
| 501 | EventHandler handler = mFirstEventHandler.second; |
| 502 | if (handler != null && (handler.getSupportedEventTypes() & event.eventType) != 0 |
| 503 | && !mToBeRemovedEventHandlers.contains(mFirstEventHandler.first)) { |
| 504 | handler.handleEvent(event); |
| 505 | handled = true; |
| 506 | } |
| 507 | } |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 508 | for (Iterator<Entry<Integer, EventHandler>> handlers = |
| 509 | eventHandlers.entrySet().iterator(); handlers.hasNext();) { |
| 510 | Entry<Integer, EventHandler> entry = handlers.next(); |
| 511 | int key = entry.getKey(); |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 512 | if (mFirstEventHandler != null && key == mFirstEventHandler.first) { |
| 513 | // If this was the 'first' handler it was already handled |
| 514 | continue; |
| 515 | } |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 516 | EventHandler eventHandler = entry.getValue(); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 517 | if (eventHandler != null |
| 518 | && (eventHandler.getSupportedEventTypes() & event.eventType) != 0) { |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 519 | if (mToBeRemovedEventHandlers.contains(key)) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 520 | continue; |
| 521 | } |
| 522 | eventHandler.handleEvent(event); |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 523 | handled = true; |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 524 | } |
| 525 | } |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 526 | |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 527 | mDispatchInProgressCounter --; |
Erik | cb81189 | 2010-09-28 13:44:19 -0700 | [diff] [blame] | 528 | |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 529 | if (mDispatchInProgressCounter == 0) { |
| 530 | |
| 531 | // Deregister removed handlers |
| 532 | if (mToBeRemovedEventHandlers.size() > 0) { |
| 533 | for (Integer zombie : mToBeRemovedEventHandlers) { |
| 534 | eventHandlers.remove(zombie); |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 535 | if (mFirstEventHandler != null && zombie.equals(mFirstEventHandler.first)) { |
| 536 | mFirstEventHandler = null; |
| 537 | } |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 538 | } |
| 539 | mToBeRemovedEventHandlers.clear(); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 540 | } |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 541 | // Add new handlers |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 542 | if (mToBeAddedFirstEventHandler != null) { |
| 543 | mFirstEventHandler = mToBeAddedFirstEventHandler; |
| 544 | mToBeAddedFirstEventHandler = null; |
| 545 | } |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 546 | if (mToBeAddedEventHandlers.size() > 0) { |
| 547 | for (Entry<Integer, EventHandler> food : mToBeAddedEventHandlers.entrySet()) { |
| 548 | eventHandlers.put(food.getKey(), food.getValue()); |
| 549 | } |
Erik | cb81189 | 2010-09-28 13:44:19 -0700 | [diff] [blame] | 550 | } |
| 551 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 552 | } |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 553 | |
| 554 | if (!handled) { |
Erik | 6b858fc | 2010-09-15 18:59:04 -0700 | [diff] [blame] | 555 | // Launch Settings |
| 556 | if (event.eventType == EventType.LAUNCH_SETTINGS) { |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 557 | launchSettings(); |
| 558 | return; |
| 559 | } |
| 560 | |
Michael Chan | 2aeb8d9 | 2011-07-10 13:32:09 -0700 | [diff] [blame] | 561 | // Launch Calendar Visible Selector |
| 562 | if (event.eventType == EventType.LAUNCH_SELECT_VISIBLE_CALENDARS) { |
| 563 | launchSelectVisibleCalendars(); |
| 564 | return; |
| 565 | } |
| 566 | |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 567 | // Create/View/Edit/Delete Event |
| 568 | long endTime = (event.endTime == null) ? -1 : event.endTime.toMillis(false); |
| 569 | if (event.eventType == EventType.CREATE_EVENT) { |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 570 | launchCreateEvent(event.startTime.toMillis(false), endTime, |
| 571 | event.extraLong == EXTRA_CREATE_ALL_DAY); |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 572 | return; |
| 573 | } else if (event.eventType == EventType.VIEW_EVENT) { |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 574 | launchViewEvent(event.id, event.startTime.toMillis(false), endTime, |
| 575 | event.getResponse()); |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 576 | return; |
| 577 | } else if (event.eventType == EventType.EDIT_EVENT) { |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 578 | launchEditEvent(event.id, event.startTime.toMillis(false), endTime, true); |
| 579 | return; |
| 580 | } else if (event.eventType == EventType.VIEW_EVENT_DETAILS) { |
| 581 | launchEditEvent(event.id, event.startTime.toMillis(false), endTime, false); |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 582 | return; |
| 583 | } else if (event.eventType == EventType.DELETE_EVENT) { |
| 584 | launchDeleteEvent(event.id, event.startTime.toMillis(false), endTime); |
| 585 | return; |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 586 | } else if (event.eventType == EventType.SEARCH) { |
| 587 | launchSearch(event.id, event.query, event.componentName); |
| 588 | return; |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 589 | } |
| 590 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 593 | /** |
| 594 | * Adds or updates an event handler. This uses a LinkedHashMap so that we can |
| 595 | * replace fragments based on the view id they are being expanded into. |
| 596 | * |
| 597 | * @param key The view id or placeholder for this handler |
| 598 | * @param eventHandler Typically a fragment or activity in the calendar app |
| 599 | */ |
| 600 | public void registerEventHandler(int key, EventHandler eventHandler) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 601 | synchronized (this) { |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 602 | if (mDispatchInProgressCounter > 0) { |
Erik | cb81189 | 2010-09-28 13:44:19 -0700 | [diff] [blame] | 603 | mToBeAddedEventHandlers.put(key, eventHandler); |
| 604 | } else { |
| 605 | eventHandlers.put(key, eventHandler); |
| 606 | } |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 607 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 608 | } |
| 609 | |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 610 | public void registerFirstEventHandler(int key, EventHandler eventHandler) { |
| 611 | synchronized (this) { |
| 612 | registerEventHandler(key, eventHandler); |
| 613 | if (mDispatchInProgressCounter > 0) { |
| 614 | mToBeAddedFirstEventHandler = new Pair<Integer, EventHandler>(key, eventHandler); |
| 615 | } else { |
| 616 | mFirstEventHandler = new Pair<Integer, EventHandler>(key, eventHandler); |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 621 | public void deregisterEventHandler(Integer key) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 622 | synchronized (this) { |
Isaac Katzenelson | ccf565b | 2011-04-27 14:40:08 -0700 | [diff] [blame] | 623 | if (mDispatchInProgressCounter > 0) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 624 | // To avoid ConcurrencyException, stash away the event handler for now. |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 625 | mToBeRemovedEventHandlers.add(key); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 626 | } else { |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 627 | eventHandlers.remove(key); |
RoboErik | 3864be0 | 2011-07-25 15:56:50 -0700 | [diff] [blame] | 628 | if (mFirstEventHandler != null && mFirstEventHandler.first == key) { |
| 629 | mFirstEventHandler = null; |
| 630 | } |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 631 | } |
| 632 | } |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 633 | } |
| 634 | |
Paul Westbrook | 61310b7 | 2011-10-07 15:43:00 -0700 | [diff] [blame] | 635 | public void deregisterAllEventHandlers() { |
| 636 | synchronized (this) { |
| 637 | if (mDispatchInProgressCounter > 0) { |
| 638 | // To avoid ConcurrencyException, stash away the event handler for now. |
| 639 | mToBeRemovedEventHandlers.addAll(eventHandlers.keySet()); |
| 640 | } else { |
| 641 | eventHandlers.clear(); |
| 642 | mFirstEventHandler = null; |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 647 | // FRAG_TODO doesn't work yet |
Erik | 2525119 | 2010-07-12 15:30:14 -0700 | [diff] [blame] | 648 | public void filterBroadcasts(Object sender, long eventTypes) { |
Michael Chan | 83b0fe3 | 2010-07-08 16:46:26 -0700 | [diff] [blame] | 649 | filters.put(sender, eventTypes); |
| 650 | } |
| 651 | |
Mason Tang | 8e3d430 | 2010-07-12 17:39:30 -0700 | [diff] [blame] | 652 | /** |
| 653 | * @return the time that this controller is currently pointed at |
| 654 | */ |
| 655 | public long getTime() { |
| 656 | return mTime.toMillis(false); |
| 657 | } |
| 658 | |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 659 | /** |
RoboErik | c8e0f21 | 2011-10-13 17:57:39 -0700 | [diff] [blame] | 660 | * @return the last set of date flags sent with |
| 661 | * {@link EventType#UPDATE_TITLE} |
| 662 | */ |
| 663 | public long getDateFlags() { |
| 664 | return mDateFlags; |
| 665 | } |
| 666 | |
| 667 | /** |
Erik | 144edfa | 2010-11-22 14:23:49 -0800 | [diff] [blame] | 668 | * Set the time this controller is currently pointed at |
| 669 | * |
| 670 | * @param millisTime Time since epoch in millis |
| 671 | */ |
| 672 | public void setTime(long millisTime) { |
| 673 | mTime.set(millisTime); |
| 674 | } |
| 675 | |
| 676 | /** |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 677 | * @return the last event ID the edit view was launched with |
| 678 | */ |
| 679 | public long getEventId() { |
| 680 | return mEventId; |
| 681 | } |
| 682 | |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 683 | public int getViewType() { |
| 684 | return mViewType; |
| 685 | } |
| 686 | |
| 687 | public int getPreviousViewType() { |
| 688 | return mPreviousViewType; |
| 689 | } |
Mason Tang | 8e3d430 | 2010-07-12 17:39:30 -0700 | [diff] [blame] | 690 | |
Michael Chan | 2aeb8d9 | 2011-07-10 13:32:09 -0700 | [diff] [blame] | 691 | private void launchSelectVisibleCalendars() { |
| 692 | Intent intent = new Intent(Intent.ACTION_VIEW); |
Michael Chan | 07d9fee | 2011-07-25 09:41:21 -0700 | [diff] [blame] | 693 | intent.setClass(mContext, SelectVisibleCalendarsActivity.class); |
Michael Chan | 2aeb8d9 | 2011-07-10 13:32:09 -0700 | [diff] [blame] | 694 | intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| 695 | mContext.startActivity(intent); |
| 696 | } |
| 697 | |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 698 | private void launchSettings() { |
| 699 | Intent intent = new Intent(Intent.ACTION_VIEW); |
Michael Chan | 07d9fee | 2011-07-25 09:41:21 -0700 | [diff] [blame] | 700 | intent.setClass(mContext, CalendarSettingsActivity.class); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 701 | intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 702 | mContext.startActivity(intent); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 703 | } |
| 704 | |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 705 | private void launchCreateEvent(long startMillis, long endMillis, boolean allDayEvent) { |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 706 | Intent intent = new Intent(Intent.ACTION_VIEW); |
Michael Chan | 07d9fee | 2011-07-25 09:41:21 -0700 | [diff] [blame] | 707 | intent.setClass(mContext, EditEventActivity.class); |
RoboErik | a27a886 | 2011-06-23 15:26:23 -0700 | [diff] [blame] | 708 | intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis); |
| 709 | intent.putExtra(EXTRA_EVENT_END_TIME, endMillis); |
Michael Chan | edecd9a | 2011-08-24 23:58:48 -0700 | [diff] [blame] | 710 | intent.putExtra(EXTRA_EVENT_ALL_DAY, allDayEvent); |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 711 | mEventId = -1; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 712 | mContext.startActivity(intent); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 715 | public void launchViewEvent(long eventId, long startMillis, long endMillis, int response) { |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 716 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 717 | Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId); |
| 718 | intent.setData(eventUri); |
Michael Chan | 07d9fee | 2011-07-25 09:41:21 -0700 | [diff] [blame] | 719 | intent.setClass(mContext, AllInOneActivity.class); |
RoboErik | a27a886 | 2011-06-23 15:26:23 -0700 | [diff] [blame] | 720 | intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis); |
| 721 | intent.putExtra(EXTRA_EVENT_END_TIME, endMillis); |
Isaac Katzenelson | 6bcafcf | 2012-05-02 18:25:36 -0700 | [diff] [blame^] | 722 | intent.putExtra(ATTENDEE_STATUS, response); |
Isaac Katzenelson | 4024dee | 2011-09-29 14:40:46 -0700 | [diff] [blame] | 723 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 724 | mContext.startActivity(intent); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 727 | private void launchEditEvent(long eventId, long startMillis, long endMillis, boolean edit) { |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 728 | Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId); |
| 729 | Intent intent = new Intent(Intent.ACTION_EDIT, uri); |
RoboErik | a27a886 | 2011-06-23 15:26:23 -0700 | [diff] [blame] | 730 | intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis); |
| 731 | intent.putExtra(EXTRA_EVENT_END_TIME, endMillis); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 732 | intent.setClass(mContext, EditEventActivity.class); |
Erik | a7694ee | 2010-12-07 15:46:18 -0800 | [diff] [blame] | 733 | intent.putExtra(EVENT_EDIT_ON_LAUNCH, edit); |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 734 | mEventId = eventId; |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 735 | mContext.startActivity(intent); |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 736 | } |
| 737 | |
Michael Chan | 1881a89 | 2011-02-08 18:16:58 -0800 | [diff] [blame] | 738 | // private void launchAlerts() { |
| 739 | // Intent intent = new Intent(); |
| 740 | // intent.setClass(mContext, AlertActivity.class); |
| 741 | // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 742 | // mContext.startActivity(intent); |
| 743 | // } |
| 744 | |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 745 | private void launchDeleteEvent(long eventId, long startMillis, long endMillis) { |
| 746 | launchDeleteEventAndFinish(null, eventId, startMillis, endMillis, -1); |
| 747 | } |
| 748 | |
| 749 | private void launchDeleteEventAndFinish(Activity parentActivity, long eventId, long startMillis, |
| 750 | long endMillis, int deleteWhich) { |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 751 | DeleteEventHelper deleteEventHelper = new DeleteEventHelper(mContext, parentActivity, |
Michael Chan | 9e89dca | 2010-07-13 17:56:09 -0700 | [diff] [blame] | 752 | parentActivity != null /* exit when done */); |
| 753 | deleteEventHelper.delete(startMillis, endMillis, eventId, deleteWhich); |
| 754 | } |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 755 | |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 756 | private void launchSearch(long eventId, String query, ComponentName componentName) { |
| 757 | final SearchManager searchManager = |
| 758 | (SearchManager)mContext.getSystemService(Context.SEARCH_SERVICE); |
| 759 | final SearchableInfo searchableInfo = searchManager.getSearchableInfo(componentName); |
| 760 | final Intent intent = new Intent(Intent.ACTION_SEARCH); |
| 761 | intent.putExtra(SearchManager.QUERY, query); |
| 762 | intent.setComponent(searchableInfo.getSearchActivity()); |
RoboErik | 2bd5cc0 | 2011-07-28 14:19:54 -0700 | [diff] [blame] | 763 | intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
Daisuke Miyakawa | 6d2e6f7 | 2010-09-17 10:30:54 -0700 | [diff] [blame] | 764 | mContext.startActivity(intent); |
| 765 | } |
| 766 | |
Andy McFadden | 7dcd301 | 2011-11-17 13:47:13 -0800 | [diff] [blame] | 767 | /** |
| 768 | * Performs a manual refresh of calendars in all known accounts. |
| 769 | */ |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 770 | public void refreshCalendars() { |
Andy McFadden | 7dcd301 | 2011-11-17 13:47:13 -0800 | [diff] [blame] | 771 | Account[] accounts = AccountManager.get(mContext).getAccounts(); |
| 772 | Log.d(TAG, "Refreshing " + accounts.length + " accounts"); |
| 773 | |
| 774 | String authority = Calendars.CONTENT_URI.getAuthority(); |
| 775 | for (int i = 0; i < accounts.length; i++) { |
| 776 | if (Log.isLoggable(TAG, Log.DEBUG)) { |
| 777 | Log.d(TAG, "Refreshing calendars for: " + accounts[i]); |
| 778 | } |
| 779 | Bundle extras = new Bundle(); |
| 780 | extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); |
| 781 | ContentResolver.requestSync(accounts[i], authority, extras); |
| 782 | } |
Erik | ba1b94a | 2010-07-20 17:50:50 -0700 | [diff] [blame] | 783 | } |
| 784 | |
Erik | dd95df5 | 2010-08-27 09:31:18 -0700 | [diff] [blame] | 785 | // Forces the viewType. Should only be used for initialization. |
| 786 | public void setViewType(int viewType) { |
| 787 | mViewType = viewType; |
| 788 | } |
| 789 | |
Erik | 7b92da2 | 2010-09-23 14:55:22 -0700 | [diff] [blame] | 790 | // Sets the eventId. Should only be used for initialization. |
| 791 | public void setEventId(long eventId) { |
| 792 | mEventId = eventId; |
| 793 | } |
| 794 | |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 795 | private String eventInfoToString(EventInfo eventInfo) { |
| 796 | String tmp = "Unknown"; |
| 797 | |
| 798 | StringBuilder builder = new StringBuilder(); |
Michael Chan | ab29d9e | 2010-07-21 06:08:47 -0700 | [diff] [blame] | 799 | if ((eventInfo.eventType & EventType.GO_TO) != 0) { |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 800 | tmp = "Go to time/event"; |
| 801 | } else if ((eventInfo.eventType & EventType.CREATE_EVENT) != 0) { |
| 802 | tmp = "New event"; |
| 803 | } else if ((eventInfo.eventType & EventType.VIEW_EVENT) != 0) { |
| 804 | tmp = "View event"; |
Michael Chan | 6d4ce6e | 2011-01-11 11:15:16 -0800 | [diff] [blame] | 805 | } else if ((eventInfo.eventType & EventType.VIEW_EVENT_DETAILS) != 0) { |
| 806 | tmp = "View details"; |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 807 | } else if ((eventInfo.eventType & EventType.EDIT_EVENT) != 0) { |
| 808 | tmp = "Edit event"; |
| 809 | } else if ((eventInfo.eventType & EventType.DELETE_EVENT) != 0) { |
| 810 | tmp = "Delete event"; |
Michael Chan | 2aeb8d9 | 2011-07-10 13:32:09 -0700 | [diff] [blame] | 811 | } else if ((eventInfo.eventType & EventType.LAUNCH_SELECT_VISIBLE_CALENDARS) != 0) { |
| 812 | tmp = "Launch select visible calendars"; |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 813 | } else if ((eventInfo.eventType & EventType.LAUNCH_SETTINGS) != 0) { |
| 814 | tmp = "Launch settings"; |
Erik | 3f348f3 | 2010-08-10 13:17:19 -0700 | [diff] [blame] | 815 | } else if ((eventInfo.eventType & EventType.EVENTS_CHANGED) != 0) { |
| 816 | tmp = "Refresh events"; |
Mason Tang | 4003d1c | 2010-08-17 13:50:45 -0700 | [diff] [blame] | 817 | } else if ((eventInfo.eventType & EventType.SEARCH) != 0) { |
| 818 | tmp = "Search"; |
Michael Chan | 6d4ce6e | 2011-01-11 11:15:16 -0800 | [diff] [blame] | 819 | } else if ((eventInfo.eventType & EventType.USER_HOME) != 0) { |
| 820 | tmp = "Gone home"; |
| 821 | } else if ((eventInfo.eventType & EventType.UPDATE_TITLE) != 0) { |
| 822 | tmp = "Update title"; |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 823 | } |
| 824 | builder.append(tmp); |
| 825 | builder.append(": id="); |
| 826 | builder.append(eventInfo.id); |
Michael Chan | d6734db | 2010-07-22 00:48:08 -0700 | [diff] [blame] | 827 | builder.append(", selected="); |
| 828 | builder.append(eventInfo.selectedTime); |
| 829 | builder.append(", start="); |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 830 | builder.append(eventInfo.startTime); |
Michael Chan | d6734db | 2010-07-22 00:48:08 -0700 | [diff] [blame] | 831 | builder.append(", end="); |
Michael Chan | 3458a17 | 2010-07-13 17:58:21 -0700 | [diff] [blame] | 832 | builder.append(eventInfo.endTime); |
| 833 | builder.append(", viewType="); |
| 834 | builder.append(eventInfo.viewType); |
| 835 | builder.append(", x="); |
| 836 | builder.append(eventInfo.x); |
| 837 | builder.append(", y="); |
| 838 | builder.append(eventInfo.y); |
| 839 | return builder.toString(); |
| 840 | } |
Michael Chan | 4970159 | 2010-06-30 11:04:03 -0700 | [diff] [blame] | 841 | } |