From 47f6cc6909665e4f6f8d85f29bfd588688463c66 Mon Sep 17 00:00:00 2001 From: Isaac Katzenelson Date: Thu, 28 Jun 2012 18:56:16 -0700 Subject: Support non-standard VIEW intent format Change-Id: I329d1e48b5f5c1ba6f7cf318489c2ab9564abbaa --- src/com/android/calendar/EventInfoActivity.java | 34 ++++++++++++++++++++++--- src/com/android/calendar/EventInfoFragment.java | 4 ++- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src/com') diff --git a/src/com/android/calendar/EventInfoActivity.java b/src/com/android/calendar/EventInfoActivity.java index 1cf9f504..2b4c8a13 100644 --- a/src/com/android/calendar/EventInfoActivity.java +++ b/src/com/android/calendar/EventInfoActivity.java @@ -29,6 +29,9 @@ import android.net.Uri; import android.os.Bundle; import android.provider.CalendarContract.Attendees; import android.util.Log; +import android.widget.Toast; + +import java.util.List; public class EventInfoActivity extends Activity { // implements CalendarController.EventHandler, SearchView.OnQueryTextListener, @@ -46,7 +49,7 @@ public class EventInfoActivity extends Activity { // Get the info needed for the fragment Intent intent = getIntent(); int attendeeResponse = 0; - mEventId = 0; + mEventId = -1; boolean isDialog = false; if (icicle != null) { @@ -63,13 +66,38 @@ public class EventInfoActivity extends Activity { Uri data = intent.getData(); if (data != null) { try { - mEventId = Long.parseLong(data.getLastPathSegment()); + List pathSegments = data.getPathSegments(); + int size = pathSegments.size(); + if (size > 2 && "EventTime".equals(pathSegments.get(2))) { + // Support non-standard VIEW intent format: + //dat = content://com.android.calendar/events/[id]/EventTime/[start]/[end] + mEventId = Long.parseLong(pathSegments.get(1)); + if (size > 4) { + mStartMillis = Long.parseLong(pathSegments.get(3)); + mEndMillis = Long.parseLong(pathSegments.get(4)); + } + } else { + mEventId = Long.parseLong(data.getLastPathSegment()); + } } catch (NumberFormatException e) { - Log.wtf(TAG,"No event id"); + if (mEventId == -1) { + // do nothing here , deal with it later + } else if (mStartMillis == 0 || mEndMillis ==0) { + // Parsing failed on the start or end time , make sure the times were not + // pulled from the intent's extras and reset them. + mStartMillis = 0; + mEndMillis = 0; + } } } } + if (mEventId == -1) { + Log.w(TAG, "No event id"); + Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show(); + finish(); + } + // If we do not support showing full screen event info in this configuration, // close the activity and show the event in AllInOne. Resources res = getResources(); diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java index 4cfeadee..a8b3cb08 100644 --- a/src/com/android/calendar/EventInfoFragment.java +++ b/src/com/android/calendar/EventInfoFragment.java @@ -398,7 +398,9 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange // if the activity is finishing, then close the cursor and return final Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { - cursor.close(); + if (cursor != null) { + cursor.close(); + } return; } -- cgit v1.2.3