summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/calendar/AllInOneActivity.java16
-rw-r--r--src/com/android/calendar/CalendarController.java16
-rw-r--r--src/com/android/calendar/CalendarUtils.java5
-rw-r--r--src/com/android/calendar/Event.java54
-rw-r--r--src/com/android/calendar/EventInfoActivity.java12
-rw-r--r--src/com/android/calendar/GoogleCalendarUriIntentFilter.java8
-rw-r--r--src/com/android/calendar/SearchActivity.java8
-rw-r--r--src/com/android/calendar/Utils.java4
-rw-r--r--src/com/android/calendar/alerts/AlertActivity.java4
-rw-r--r--src/com/android/calendar/alerts/AlertService.java2
-rw-r--r--src/com/android/calendar/event/EditEventActivity.java8
-rw-r--r--src/com/android/calendar/widget/CalendarAppWidgetProvider.java8
12 files changed, 99 insertions, 46 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java
index 1f3961ce..12509fa0 100644
--- a/src/com/android/calendar/AllInOneActivity.java
+++ b/src/com/android/calendar/AllInOneActivity.java
@@ -16,8 +16,8 @@
package com.android.calendar;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS;
import static com.android.calendar.CalendarController.EVENT_ATTENDEE_RESPONSE;
@@ -294,8 +294,8 @@ public class AllInOneActivity extends Activity implements EventHandler,
try {
mViewEventId = Long.valueOf(data.getLastPathSegment());
if (mViewEventId != -1) {
- mIntentEventStartMillis = intent.getLongExtra(EVENT_BEGIN_TIME, 0);
- mIntentEventEndMillis = intent.getLongExtra(EVENT_END_TIME, 0);
+ mIntentEventStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
+ mIntentEventEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
mIntentAttendeeResponse = intent.getIntExtra(
ATTENDEE_STATUS, CalendarController.ATTENDEE_NO_RESPONSE);
timeMillis = mIntentEventStartMillis;
@@ -505,8 +505,8 @@ public class AllInOneActivity extends Activity implements EventHandler,
eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
}
- long begin = intent.getLongExtra(EVENT_BEGIN_TIME, -1);
- long end = intent.getLongExtra(EVENT_END_TIME, -1);
+ long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
+ long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
info = new EventInfo();
if (end != -1) {
info.endTime = new Time();
@@ -894,8 +894,8 @@ public class AllInOneActivity extends Activity implements EventHandler,
intent.setClassName(this, EventInfoActivity.class.getName());
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(EVENT_BEGIN_TIME, event.startTime.toMillis(false));
- intent.putExtra(EVENT_END_TIME, event.endTime.toMillis(false));
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false));
+ intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false));
intent.putExtra(EVENT_ATTENDEE_RESPONSE, (int)event.extraLong);
startActivity(intent);
} else {
diff --git a/src/com/android/calendar/CalendarController.java b/src/com/android/calendar/CalendarController.java
index 1dfc8f7a..8c654438 100644
--- a/src/com/android/calendar/CalendarController.java
+++ b/src/com/android/calendar/CalendarController.java
@@ -16,8 +16,8 @@
package com.android.calendar;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import com.android.calendar.event.EditEventActivity;
@@ -543,8 +543,8 @@ public class CalendarController {
private void launchCreateEvent(long startMillis, long endMillis) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(mContext, EditEventActivity.class.getName());
- intent.putExtra(EVENT_BEGIN_TIME, startMillis);
- intent.putExtra(EVENT_END_TIME, endMillis);
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis);
+ intent.putExtra(EXTRA_EVENT_END_TIME, endMillis);
mEventId = -1;
mContext.startActivity(intent);
}
@@ -554,16 +554,16 @@ public class CalendarController {
Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId);
intent.setData(eventUri);
// intent.setClassName(mContext, EventInfoActivity.class.getName());
- intent.putExtra(EVENT_BEGIN_TIME, startMillis);
- intent.putExtra(EVENT_END_TIME, endMillis);
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis);
+ intent.putExtra(EXTRA_EVENT_END_TIME, endMillis);
mContext.startActivity(intent);
}
private void launchEditEvent(long eventId, long startMillis, long endMillis, boolean edit) {
Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId);
Intent intent = new Intent(Intent.ACTION_EDIT, uri);
- intent.putExtra(EVENT_BEGIN_TIME, startMillis);
- intent.putExtra(EVENT_END_TIME, endMillis);
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis);
+ intent.putExtra(EXTRA_EVENT_END_TIME, endMillis);
intent.setClass(mContext, EditEventActivity.class);
intent.putExtra(EVENT_EDIT_ON_LAUNCH, edit);
mEventId = eventId;
diff --git a/src/com/android/calendar/CalendarUtils.java b/src/com/android/calendar/CalendarUtils.java
index 886e92e7..f7f95d8b 100644
--- a/src/com/android/calendar/CalendarUtils.java
+++ b/src/com/android/calendar/CalendarUtils.java
@@ -49,6 +49,9 @@ public class CalendarUtils {
private static final String[] TIMEZONE_TYPE_ARGS = { CalendarCache.TIMEZONE_KEY_TYPE };
private static final String[] TIMEZONE_INSTANCES_ARGS =
{ CalendarCache.TIMEZONE_KEY_INSTANCES };
+ public static final String[] CALENDAR_CACHE_POJECTION = {
+ CalendarCache.KEY, CalendarCache.VALUE
+ };
private static StringBuilder mSB = new StringBuilder(50);
private static Formatter mF = new Formatter(mSB, Locale.getDefault());
@@ -280,7 +283,7 @@ public class CalendarUtils {
if (mHandler == null) {
mHandler = new AsyncTZHandler(context.getContentResolver());
}
- mHandler.startQuery(0, context, CalendarCache.URI, CalendarCache.POJECTION,
+ mHandler.startQuery(0, context, CalendarCache.URI, CALENDAR_CACHE_POJECTION,
null, null, null);
}
if (mTZQueryInProgress) {
diff --git a/src/com/android/calendar/Event.java b/src/com/android/calendar/Event.java
index 950b0a35..126c6063 100644
--- a/src/com/android/calendar/Event.java
+++ b/src/com/android/calendar/Event.java
@@ -16,12 +16,17 @@
package com.android.calendar;
+import android.content.ContentResolver;
+import android.content.ContentUris;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
+import android.net.Uri;
import android.os.Debug;
+import android.provider.CalendarContract;
import android.provider.CalendarContract.Attendees;
+import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Instances;
import android.text.TextUtils;
@@ -30,6 +35,7 @@ import android.text.format.Time;
import android.util.Log;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
@@ -260,10 +266,10 @@ public class Event implements Cloneable {
whereAllday += hideString;
}
- cEvents = Instances.query(context.getContentResolver(), EVENT_PROJECTION,
+ cEvents = instancesQuery(context.getContentResolver(), EVENT_PROJECTION,
start - DateUtils.DAY_IN_MILLIS, end + DateUtils.DAY_IN_MILLIS, where,
null, SORT_EVENTS_BY);
- cAllday = Instances.query(context.getContentResolver(), EVENT_PROJECTION,
+ cAllday = instancesQuery(context.getContentResolver(), EVENT_PROJECTION,
start - DateUtils.DAY_IN_MILLIS, end + DateUtils.DAY_IN_MILLIS, whereAllday,
null, SORT_ALLDAY_BY);
@@ -290,6 +296,50 @@ public class Event implements Cloneable {
}
/**
+ * Performs a query to return all visible instances in the given range
+ * that match the given selection. This is a blocking function and
+ * should not be done on the UI thread. This will cause an expansion of
+ * recurring events to fill this time range if they are not already
+ * expanded and will slow down for larger time ranges with many
+ * recurring events.
+ *
+ * @param cr The ContentResolver to use for the query
+ * @param projection The columns to return
+ * @param begin The start of the time range to query in UTC millis since
+ * epoch
+ * @param end The end of the time range to query in UTC millis since
+ * epoch
+ * @param selection Filter on the query as an SQL WHERE statement
+ * @param selectionArgs Args to replace any '?'s in the selection
+ * @param orderBy How to order the rows as an SQL ORDER BY statement
+ * @return A Cursor of instances matching the selection
+ */
+ private static final Cursor instancesQuery(ContentResolver cr, String[] projection, long begin,
+ long end, String selection, String[] selectionArgs, String orderBy) {
+ String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?";
+ String[] WHERE_CALENDARS_ARGS = {"1"};
+ String DEFAULT_SORT_ORDER = "begin ASC";
+
+ Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
+ ContentUris.appendId(builder, begin);
+ ContentUris.appendId(builder, end);
+ if (TextUtils.isEmpty(selection)) {
+ selection = WHERE_CALENDARS_SELECTED;
+ selectionArgs = WHERE_CALENDARS_ARGS;
+ } else {
+ selection = "(" + selection + ") AND " + WHERE_CALENDARS_SELECTED;
+ if (selectionArgs != null && selectionArgs.length > 0) {
+ selectionArgs = Arrays.copyOf(selectionArgs, selectionArgs.length + 1);
+ selectionArgs[selectionArgs.length - 1] = WHERE_CALENDARS_ARGS[0];
+ } else {
+ selectionArgs = WHERE_CALENDARS_ARGS;
+ }
+ }
+ return cr.query(builder.build(), projection, selection, selectionArgs,
+ orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
+ }
+
+ /**
* Adds all the events from the cursors to the events list.
*
* @param events The list of events
diff --git a/src/com/android/calendar/EventInfoActivity.java b/src/com/android/calendar/EventInfoActivity.java
index 4ba67a37..f8079005 100644
--- a/src/com/android/calendar/EventInfoActivity.java
+++ b/src/com/android/calendar/EventInfoActivity.java
@@ -15,8 +15,8 @@
*/
package com.android.calendar;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import static com.android.calendar.CalendarController.ATTENDEE_NO_RESPONSE;
import static com.android.calendar.CalendarController.EVENT_ATTENDEE_RESPONSE;
import static com.android.calendar.CalendarController.EVENT_EDIT_ON_LAUNCH;
@@ -81,8 +81,8 @@ public class EventInfoActivity extends Activity {
attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE);
isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG);
} else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
- mStartMillis = intent.getLongExtra(EVENT_BEGIN_TIME, 0);
- mEndMillis = intent.getLongExtra(EVENT_END_TIME, 0);
+ mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
+ mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
attendeeResponse = intent.getIntExtra(EVENT_ATTENDEE_RESPONSE, ATTENDEE_NO_RESPONSE);
Uri data = intent.getData();
if (data != null) {
@@ -126,8 +126,8 @@ public class EventInfoActivity extends Activity {
case R.id.info_action_edit:
Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
Intent intent = new Intent(Intent.ACTION_EDIT, uri);
- intent.putExtra(EVENT_BEGIN_TIME, mStartMillis);
- intent.putExtra(EVENT_END_TIME, mEndMillis);
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME, mStartMillis);
+ intent.putExtra(EXTRA_EVENT_END_TIME, mEndMillis);
intent.setClass(this, EditEventActivity.class);
intent.putExtra(EVENT_EDIT_ON_LAUNCH, true);
startActivity(intent);
diff --git a/src/com/android/calendar/GoogleCalendarUriIntentFilter.java b/src/com/android/calendar/GoogleCalendarUriIntentFilter.java
index f3710b37..75532d97 100644
--- a/src/com/android/calendar/GoogleCalendarUriIntentFilter.java
+++ b/src/com/android/calendar/GoogleCalendarUriIntentFilter.java
@@ -17,8 +17,8 @@
package com.android.calendar;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS;
import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED;
import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED;
@@ -129,8 +129,8 @@ public class GoogleCalendarUriIntentFilter extends Activity {
// Send intent to calendar app
Uri calendarUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId);
intent = new Intent(Intent.ACTION_VIEW, calendarUri);
- intent.putExtra(EVENT_BEGIN_TIME, startMillis);
- intent.putExtra(EVENT_END_TIME, endMillis);
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME, startMillis);
+ intent.putExtra(EXTRA_EVENT_END_TIME, endMillis);
if (attendeeStatus != ATTENDEE_STATUS_NONE) {
intent.putExtra(ATTENDEE_STATUS, attendeeStatus);
}
diff --git a/src/com/android/calendar/SearchActivity.java b/src/com/android/calendar/SearchActivity.java
index 8aff2607..8708d149 100644
--- a/src/com/android/calendar/SearchActivity.java
+++ b/src/com/android/calendar/SearchActivity.java
@@ -15,8 +15,8 @@
*/
package com.android.calendar;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import android.app.ActionBar;
import android.app.Activity;
@@ -181,10 +181,10 @@ public class SearchActivity extends Activity
Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
intent.setData(eventUri);
// intent.setClassName(this, EventInfoActivity.class.getName());
- intent.putExtra(EVENT_BEGIN_TIME,
+ intent.putExtra(EXTRA_EVENT_BEGIN_TIME,
event.startTime != null ? event.startTime.toMillis(true) : -1);
intent.putExtra(
- EVENT_END_TIME, event.endTime != null ? event.endTime.toMillis(true) : -1);
+ EXTRA_EVENT_END_TIME, event.endTime != null ? event.endTime.toMillis(true) : -1);
startActivity(intent);
}
mCurrentEventId = event.id;
diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java
index cb37b5be..1ac50e03 100644
--- a/src/com/android/calendar/Utils.java
+++ b/src/com/android/calendar/Utils.java
@@ -16,7 +16,7 @@
package com.android.calendar;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
import com.android.calendar.CalendarController.ViewType;
@@ -306,7 +306,7 @@ public class Utils {
// If the time was specified, then use that. Otherwise, use the current
// time.
Uri data = intent.getData();
- long millis = intent.getLongExtra(EVENT_BEGIN_TIME, -1);
+ long millis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
if (millis == -1 && data != null && data.isHierarchical()) {
List<String> path = data.getPathSegments();
if (path.size() == 2 && path.get(0).equals("time")) {
diff --git a/src/com/android/calendar/alerts/AlertActivity.java b/src/com/android/calendar/alerts/AlertActivity.java
index dc0017e2..0305ca6b 100644
--- a/src/com/android/calendar/alerts/AlertActivity.java
+++ b/src/com/android/calendar/alerts/AlertActivity.java
@@ -188,8 +188,8 @@ public class AlertActivity extends Activity implements OnClickListener {
Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendEncodedPath("events/" + id);
eventIntent.setData(builder.build());
- eventIntent.putExtra(CalendarContract.EVENT_BEGIN_TIME, startMillis);
- eventIntent.putExtra(CalendarContract.EVENT_END_TIME, endMillis);
+ eventIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startMillis);
+ eventIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endMillis);
alertActivity.startActivity(eventIntent);
alertActivity.finish();
diff --git a/src/com/android/calendar/alerts/AlertService.java b/src/com/android/calendar/alerts/AlertService.java
index b6caa0c4..35d1d2cf 100644
--- a/src/com/android/calendar/alerts/AlertService.java
+++ b/src/com/android/calendar/alerts/AlertService.java
@@ -108,7 +108,7 @@ public class AlertService extends Service {
return;
}
- if (!action.equals(android.provider.CalendarContract.EVENT_REMINDER_ACTION)
+ if (!action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER)
&& !action.equals(Intent.ACTION_LOCALE_CHANGED)) {
Log.w(TAG, "Invalid action: " + action);
return;
diff --git a/src/com/android/calendar/event/EditEventActivity.java b/src/com/android/calendar/event/EditEventActivity.java
index 99b65812..9381621e 100644
--- a/src/com/android/calendar/event/EditEventActivity.java
+++ b/src/com/android/calendar/event/EditEventActivity.java
@@ -16,8 +16,8 @@
package com.android.calendar.event;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import android.app.ActionBar;
import android.app.FragmentTransaction;
@@ -104,8 +104,8 @@ public class EditEventActivity extends AbstractCalendarActivity {
eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
}
- long begin = intent.getLongExtra(EVENT_BEGIN_TIME, -1);
- long end = intent.getLongExtra(EVENT_END_TIME, -1);
+ long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
+ long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
if (end != -1) {
info.endTime = new Time();
info.endTime.set(end);
diff --git a/src/com/android/calendar/widget/CalendarAppWidgetProvider.java b/src/com/android/calendar/widget/CalendarAppWidgetProvider.java
index a0648b37..b34fd2d5 100644
--- a/src/com/android/calendar/widget/CalendarAppWidgetProvider.java
+++ b/src/com/android/calendar/widget/CalendarAppWidgetProvider.java
@@ -16,8 +16,8 @@
package com.android.calendar.widget;
-import static android.provider.CalendarContract.EVENT_BEGIN_TIME;
-import static android.provider.CalendarContract.EVENT_END_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
+import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
import com.android.calendar.R;
import com.android.calendar.Utils;
@@ -206,8 +206,8 @@ public class CalendarAppWidgetProvider extends AppWidgetProvider {
}
Uri data = Uri.parse(dataString);
fillInIntent.setData(data);
- fillInIntent.putExtra(EVENT_BEGIN_TIME, start);
- fillInIntent.putExtra(EVENT_END_TIME, end);
+ fillInIntent.putExtra(EXTRA_EVENT_BEGIN_TIME, start);
+ fillInIntent.putExtra(EXTRA_EVENT_END_TIME, end);
return fillInIntent;
}