From 597cfcf7ce2813d067dc34a543fe3e6593b3d74c Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 27 Apr 2012 08:43:27 -0700 Subject: [PATCH] Add preliminary support for viewing events Bug: 5011918 Change-Id: I573ed44b09f5e695d04fd081ea8af221fb396d94 --- email2/AndroidManifest.xml | 17 +++++++ .../email/activity/ActivityHelper.java | 12 ----- .../android/email/activity/EventViewer.java | 50 +++++++++++++++++++ .../android/email/provider/EmailProvider.java | 4 ++ 4 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 email2/src/com/android/email/activity/EventViewer.java diff --git a/email2/AndroidManifest.xml b/email2/AndroidManifest.xml index 895e21724..5b9d56969 100644 --- a/email2/AndroidManifest.xml +++ b/email2/AndroidManifest.xml @@ -117,6 +117,23 @@ + + + + + + + + diff --git a/email2/src/com/android/email/activity/ActivityHelper.java b/email2/src/com/android/email/activity/ActivityHelper.java index 62d21f67d..ebab0e54a 100644 --- a/email2/src/com/android/email/activity/ActivityHelper.java +++ b/email2/src/com/android/email/activity/ActivityHelper.java @@ -75,18 +75,6 @@ public final class ActivityHelper { return result; } - /** - * Open Calendar app with specific time - */ - public static void openCalendar(Activity activity, long epochEventStartTime) { - Uri uri = Uri.parse("content://com.android.calendar/time/" + epochEventStartTime); - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(uri); - intent.putExtra("VIEW", "DAY"); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); - activity.startActivity(intent); - } - /** * If configured via debug flags, inhibit hardware graphics acceleration. Must be called * early in onCreate(). diff --git a/email2/src/com/android/email/activity/EventViewer.java b/email2/src/com/android/email/activity/EventViewer.java new file mode 100644 index 000000000..0a50c33e6 --- /dev/null +++ b/email2/src/com/android/email/activity/EventViewer.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2012, Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email.activity; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; + +import com.android.emailcommon.mail.MeetingInfo; +import com.android.emailcommon.mail.PackedString; +import com.android.emailcommon.provider.EmailContent.Message; +import com.android.emailcommon.utility.Utility; + +public class EventViewer extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Uri uri = getIntent().getData(); + long messageId = Long.parseLong(uri.getLastPathSegment()); + Message msg = Message.restoreMessageWithId(this, messageId); + if (msg == null) { + finish(); + } else { + PackedString info = new PackedString(msg.mMeetingInfo); + long time = Utility.parseEmailDateTimeToMillis(info.get(MeetingInfo.MEETING_DTSTART)); + uri = Uri.parse("content://com.android.calendar/time/" + time); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(uri); + intent.putExtra("VIEW", "DAY"); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + startActivity(intent); + finish(); + } + } +} diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index ca5f3f9ca..9fb259b8d 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -2289,6 +2289,10 @@ outer: com.android.mail.providers.Attachment.toJSONArray(uiAtts)); } } + if ((msg.mFlags & Message.FLAG_INCOMING_MEETING_INVITE) != 0) { + values.put(UIProvider.MessageColumns.EVENT_INTENT_URI, + "content://ui.email2.android.com/event/" + msg.mId); + } StringBuilder sb = genSelect(sMessageViewMap, uiProjection, values); sb.append(" FROM " + Message.TABLE_NAME + "," + Body.TABLE_NAME + " WHERE " + Body.MESSAGE_KEY + "=" + Message.TABLE_NAME + "." + Message.RECORD_ID + " AND " +