2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.calendar;
19 import static android.provider.Calendar.EVENT_BEGIN_TIME;
20 import static android.provider.Calendar.EVENT_END_TIME;
22 import android.app.Activity;
23 import android.content.ContentResolver;
24 import android.content.ContentUris;
25 import android.content.ContentValues;
26 import android.content.Intent;
27 import android.content.SharedPreferences;
28 import android.content.res.Resources;
29 import android.database.Cursor;
30 import android.graphics.PorterDuff;
31 import android.net.Uri;
32 import android.os.Bundle;
33 import android.pim.EventRecurrence;
34 import android.preference.PreferenceManager;
35 import android.provider.Calendar;
36 import android.provider.Calendar.Attendees;
37 import android.provider.Calendar.Calendars;
38 import android.provider.Calendar.Events;
39 import android.provider.Calendar.Reminders;
40 import android.text.format.DateFormat;
41 import android.text.format.DateUtils;
42 import android.text.format.Time;
43 import android.util.Log;
44 import android.view.KeyEvent;
45 import android.view.Menu;
46 import android.view.MenuItem;
47 import android.view.View;
48 import android.widget.AdapterView;
49 import android.widget.ArrayAdapter;
50 import android.widget.ImageView;
51 import android.widget.LinearLayout;
52 import android.widget.Spinner;
53 import android.widget.TextView;
54 import android.widget.Toast;
56 import java.util.ArrayList;
57 import java.util.Arrays;
59 public class EventInfoActivity extends Activity implements View.OnClickListener,
60 AdapterView.OnItemSelectedListener {
61 private static final int MAX_REMINDERS = 5;
64 * These are the corresponding indices into the array of strings
65 * "R.array.change_response_labels" in the resource file.
67 static final int UPDATE_SINGLE = 0;
68 static final int UPDATE_ALL = 1;
70 private static final String[] EVENT_PROJECTION = new String[] {
71 Events._ID, // 0 do not remove; used in DeleteEventHelper
72 Events.TITLE, // 1 do not remove; used in DeleteEventHelper
73 Events.RRULE, // 2 do not remove; used in DeleteEventHelper
74 Events.ALL_DAY, // 3 do not remove; used in DeleteEventHelper
75 Events.CALENDAR_ID, // 4 do not remove; used in DeleteEventHelper
76 Events.DTSTART, // 5 do not remove; used in DeleteEventHelper
77 Events._SYNC_ID, // 6 do not remove; used in DeleteEventHelper
78 Events.EVENT_TIMEZONE, // 7 do not remove; used in DeleteEventHelper
79 Events.DESCRIPTION, // 8
80 Events.EVENT_LOCATION, // 9
81 Events.HAS_ALARM, // 10
82 Events.ACCESS_LEVEL, // 11
85 private static final int EVENT_INDEX_ID = 0;
86 private static final int EVENT_INDEX_TITLE = 1;
87 private static final int EVENT_INDEX_RRULE = 2;
88 private static final int EVENT_INDEX_ALL_DAY = 3;
89 private static final int EVENT_INDEX_CALENDAR_ID = 4;
90 private static final int EVENT_INDEX_SYNC_ID = 6;
91 private static final int EVENT_INDEX_EVENT_TIMEZONE = 7;
92 private static final int EVENT_INDEX_DESCRIPTION = 8;
93 private static final int EVENT_INDEX_EVENT_LOCATION = 9;
94 private static final int EVENT_INDEX_HAS_ALARM = 10;
95 private static final int EVENT_INDEX_ACCESS_LEVEL = 11;
96 private static final int EVENT_INDEX_COLOR = 12;
98 private static final String[] ATTENDEES_PROJECTION = new String[] {
100 Attendees.ATTENDEE_RELATIONSHIP, // 1
101 Attendees.ATTENDEE_STATUS, // 2
103 private static final int ATTENDEES_INDEX_ID = 0;
104 private static final int ATTENDEES_INDEX_RELATIONSHIP = 1;
105 private static final int ATTENDEES_INDEX_STATUS = 2;
106 private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=%d";
108 static final String[] CALENDARS_PROJECTION = new String[] {
110 Calendars.DISPLAY_NAME, // 1
112 static final int CALENDARS_INDEX_DISPLAY_NAME = 1;
113 static final String CALENDARS_WHERE = Calendars._ID + "=%d";
115 private static final String[] REMINDERS_PROJECTION = new String[] {
117 Reminders.MINUTES, // 1
119 private static final int REMINDERS_INDEX_MINUTES = 1;
120 private static final String REMINDERS_WHERE = Reminders.EVENT_ID + "=%d AND (" +
121 Reminders.METHOD + "=" + Reminders.METHOD_ALERT + " OR " + Reminders.METHOD + "=" +
122 Reminders.METHOD_DEFAULT + ")";
124 private static final int MENU_GROUP_REMINDER = 1;
125 private static final int MENU_GROUP_EDIT = 2;
126 private static final int MENU_GROUP_DELETE = 3;
128 private static final int MENU_ADD_REMINDER = 1;
129 private static final int MENU_EDIT = 2;
130 private static final int MENU_DELETE = 3;
132 private static final int ATTENDEE_NO_RESPONSE = -1;
133 private static final int[] ATTENDEE_VALUES = {
134 ATTENDEE_NO_RESPONSE,
135 Attendees.ATTENDEE_STATUS_ACCEPTED,
136 Attendees.ATTENDEE_STATUS_TENTATIVE,
137 Attendees.ATTENDEE_STATUS_DECLINED,
140 private LinearLayout mRemindersContainer;
143 private long mEventId;
144 private Cursor mEventCursor;
145 private Cursor mAttendeesCursor;
146 private Cursor mCalendarsCursor;
148 private long mStartMillis;
149 private long mEndMillis;
150 private int mVisibility = Calendars.NO_ACCESS;
151 private int mRelationship = Attendees.RELATIONSHIP_ORGANIZER;
153 private ArrayList<Integer> mOriginalMinutes = new ArrayList<Integer>();
154 private ArrayList<LinearLayout> mReminderItems = new ArrayList<LinearLayout>(0);
155 private ArrayList<Integer> mReminderValues;
156 private ArrayList<String> mReminderLabels;
157 private int mDefaultReminderMinutes;
159 private DeleteEventHelper mDeleteEventHelper;
160 private EditResponseHelper mEditResponseHelper;
162 private int mResponseOffset;
163 private int mOriginalAttendeeResponse;
164 private boolean mIsRepeating;
166 // This is called when one of the "remove reminder" buttons is selected.
167 public void onClick(View v) {
168 LinearLayout reminderItem = (LinearLayout) v.getParent();
169 LinearLayout parent = (LinearLayout) reminderItem.getParent();
170 parent.removeView(reminderItem);
171 mReminderItems.remove(reminderItem);
172 updateRemindersVisibility();
175 public void onItemSelected(AdapterView parent, View v, int position, long id) {
176 // If they selected the "No response" option, then don't display the
177 // dialog asking which events to change.
178 if (id == 0 && mResponseOffset == 0) {
182 // If this is not a repeating event, then don't display the dialog
183 // asking which events to change.
188 // If the selection is the same as the original, then don't display the
189 // dialog asking which events to change.
190 int index = findResponseIndexFor(mOriginalAttendeeResponse);
191 if (position == index + mResponseOffset) {
195 // This is a repeating event. We need to ask the user if they mean to
196 // change just this one instance or all instances.
197 mEditResponseHelper.showDialog(mEditResponseHelper.getWhichEvents());
200 public void onNothingSelected(AdapterView parent) {
204 protected void onCreate(Bundle icicle) {
205 super.onCreate(icicle);
208 Intent intent = getIntent();
209 mUri = intent.getData();
210 ContentResolver cr = getContentResolver();
211 mStartMillis = intent.getLongExtra(EVENT_BEGIN_TIME, 0);
212 mEndMillis = intent.getLongExtra(EVENT_END_TIME, 0);
213 mEventCursor = managedQuery(mUri, EVENT_PROJECTION, null, null);
214 if (initEventCursor()) {
215 // The cursor is empty. This can happen if the event was deleted.
220 setContentView(R.layout.event_info_activity);
223 Uri uri = Attendees.CONTENT_URI;
224 String where = String.format(ATTENDEES_WHERE, mEventId);
225 mAttendeesCursor = managedQuery(uri, ATTENDEES_PROJECTION, where, null);
226 initAttendeesCursor();
229 uri = Calendars.CONTENT_URI;
230 where = String.format(CALENDARS_WHERE, mEventCursor.getLong(EVENT_INDEX_CALENDAR_ID));
231 mCalendarsCursor = managedQuery(uri, CALENDARS_PROJECTION, where, null);
232 initCalendarsCursor();
234 Resources res = getResources();
236 if (mVisibility >= Calendars.CONTRIBUTOR_ACCESS &&
237 mRelationship == Attendees.RELATIONSHIP_ATTENDEE) {
238 setTitle(res.getString(R.string.event_info_title_invite));
240 setTitle(res.getString(R.string.event_info_title));
243 // Initialize the reminder values array.
244 Resources r = getResources();
245 String[] strings = r.getStringArray(R.array.reminder_minutes_values);
246 int size = strings.length;
247 ArrayList<Integer> list = new ArrayList<Integer>(size);
248 for (int i = 0 ; i < size ; i++) {
249 list.add(Integer.parseInt(strings[i]));
251 mReminderValues = list;
252 String[] labels = r.getStringArray(R.array.reminder_minutes_labels);
253 mReminderLabels = new ArrayList<String>(Arrays.asList(labels));
255 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
256 String durationString =
257 prefs.getString(CalendarPreferenceActivity.KEY_DEFAULT_REMINDER, "0");
258 mDefaultReminderMinutes = Integer.parseInt(durationString);
260 mRemindersContainer = (LinearLayout) findViewById(R.id.reminders_container);
263 boolean hasAlarm = mEventCursor.getInt(EVENT_INDEX_HAS_ALARM) != 0;
265 uri = Reminders.CONTENT_URI;
266 where = String.format(REMINDERS_WHERE, mEventId);
267 Cursor reminderCursor = cr.query(uri, REMINDERS_PROJECTION, where, null, null);
269 // First pass: collect all the custom reminder minutes (e.g.,
270 // a reminder of 8 minutes) into a global list.
271 while (reminderCursor.moveToNext()) {
272 int minutes = reminderCursor.getInt(REMINDERS_INDEX_MINUTES);
273 EditEvent.addMinutesToList(this, mReminderValues, mReminderLabels, minutes);
276 // Second pass: create the reminder spinners
277 reminderCursor.moveToPosition(-1);
278 while (reminderCursor.moveToNext()) {
279 int minutes = reminderCursor.getInt(REMINDERS_INDEX_MINUTES);
280 mOriginalMinutes.add(minutes);
281 EditEvent.addReminder(this, this, mReminderItems, mReminderValues,
282 mReminderLabels, minutes);
285 reminderCursor.close();
290 updateRemindersVisibility();
292 mDeleteEventHelper = new DeleteEventHelper(this, true /* exit when done */);
293 mEditResponseHelper = new EditResponseHelper(this);
297 protected void onResume() {
299 if (initEventCursor()) {
300 // The cursor is empty. This can happen if the event was deleted.
304 initAttendeesCursor();
305 initCalendarsCursor();
309 * Initializes the event cursor, which is expected to point to the first
310 * (and only) result from a query.
311 * @return true if the cursor is empty.
313 private boolean initEventCursor() {
314 if ((mEventCursor == null) || (mEventCursor.getCount() == 0)) {
317 mEventCursor.moveToFirst();
318 mVisibility = mEventCursor.getInt(EVENT_INDEX_ACCESS_LEVEL);
319 mEventId = mEventCursor.getInt(EVENT_INDEX_ID);
320 String rRule = mEventCursor.getString(EVENT_INDEX_RRULE);
321 mIsRepeating = (rRule != null);
325 private void initAttendeesCursor() {
326 if (mAttendeesCursor != null) {
327 if (mAttendeesCursor.moveToFirst()) {
328 mRelationship = mAttendeesCursor.getInt(ATTENDEES_INDEX_RELATIONSHIP);
333 private void initCalendarsCursor() {
334 if (mCalendarsCursor != null) {
335 mCalendarsCursor.moveToFirst();
340 public void onPause() {
342 if (!isFinishing()) {
345 ContentResolver cr = getContentResolver();
346 ArrayList<Integer> reminderMinutes = EditEvent.reminderItemsToMinutes(mReminderItems,
348 boolean changed = EditEvent.saveReminders(cr, mEventId, reminderMinutes, mOriginalMinutes);
349 changed |= saveResponse(cr);
351 Toast.makeText(this, R.string.saving_event, Toast.LENGTH_SHORT).show();
356 public boolean onCreateOptionsMenu(Menu menu) {
358 item = menu.add(MENU_GROUP_REMINDER, MENU_ADD_REMINDER, 0,
359 R.string.add_new_reminder);
360 item.setIcon(R.drawable.ic_menu_reminder);
361 item.setAlphabeticShortcut('r');
363 item = menu.add(MENU_GROUP_EDIT, MENU_EDIT, 0, R.string.edit_event_label);
364 item.setIcon(android.R.drawable.ic_menu_edit);
365 item.setAlphabeticShortcut('e');
367 item = menu.add(MENU_GROUP_DELETE, MENU_DELETE, 0, R.string.delete_event_label);
368 item.setIcon(android.R.drawable.ic_menu_delete);
370 return super.onCreateOptionsMenu(menu);
374 public boolean onPrepareOptionsMenu(Menu menu) {
375 // Cannot add reminders to a shared calendar with only free/busy
377 if (mVisibility >= Calendars.READ_ACCESS && mReminderItems.size() < MAX_REMINDERS) {
378 menu.setGroupVisible(MENU_GROUP_REMINDER, true);
379 menu.setGroupEnabled(MENU_GROUP_REMINDER, true);
381 menu.setGroupVisible(MENU_GROUP_REMINDER, false);
382 menu.setGroupEnabled(MENU_GROUP_REMINDER, false);
385 if (mVisibility >= Calendars.CONTRIBUTOR_ACCESS &&
386 mRelationship >= Attendees.RELATIONSHIP_ORGANIZER) {
387 menu.setGroupVisible(MENU_GROUP_EDIT, true);
388 menu.setGroupEnabled(MENU_GROUP_EDIT, true);
389 menu.setGroupVisible(MENU_GROUP_DELETE, true);
390 menu.setGroupEnabled(MENU_GROUP_DELETE, true);
392 menu.setGroupVisible(MENU_GROUP_EDIT, false);
393 menu.setGroupEnabled(MENU_GROUP_EDIT, false);
394 menu.setGroupVisible(MENU_GROUP_DELETE, false);
395 menu.setGroupEnabled(MENU_GROUP_DELETE, false);
398 return super.onPrepareOptionsMenu(menu);
402 public boolean onOptionsItemSelected(MenuItem item) {
403 super.onOptionsItemSelected(item);
404 switch (item.getItemId()) {
405 case MENU_ADD_REMINDER:
406 // TODO: when adding a new reminder, make it different from the
407 // last one in the list (if any).
408 if (mDefaultReminderMinutes == 0) {
409 EditEvent.addReminder(this, this, mReminderItems,
410 mReminderValues, mReminderLabels, 10 /* minutes */);
412 EditEvent.addReminder(this, this, mReminderItems,
413 mReminderValues, mReminderLabels, mDefaultReminderMinutes);
415 updateRemindersVisibility();
428 public boolean onKeyDown(int keyCode, KeyEvent event) {
429 if (keyCode == KeyEvent.KEYCODE_DEL) {
433 return super.onKeyDown(keyCode, event);
436 private void updateRemindersVisibility() {
437 if (mReminderItems.size() == 0) {
438 mRemindersContainer.setVisibility(View.GONE);
440 mRemindersContainer.setVisibility(View.VISIBLE);
445 * Saves the response to an invitation if the user changed the response.
446 * Returns true if the database was updated.
448 * @param cr the ContentResolver
449 * @return true if the database was changed
451 private boolean saveResponse(ContentResolver cr) {
452 if (mAttendeesCursor == null || mEventCursor == null) {
455 Spinner spinner = (Spinner) findViewById(R.id.response_value);
456 int position = spinner.getSelectedItemPosition() - mResponseOffset;
461 int status = ATTENDEE_VALUES[position];
463 // If the status has not changed, then don't update the database
464 if (status == mOriginalAttendeeResponse) {
468 long attendeeId = mAttendeesCursor.getInt(ATTENDEES_INDEX_ID);
470 // This is a non-repeating event
471 updateResponse(cr, mEventId, attendeeId, status);
475 // This is a repeating event
476 int whichEvents = mEditResponseHelper.getWhichEvents();
477 switch (whichEvents) {
481 createExceptionResponse(cr, mEventId, attendeeId, status);
484 updateResponse(cr, mEventId, attendeeId, status);
487 Log.e("Calendar", "Unexpected choice for updating invitation response");
493 private void updateResponse(ContentResolver cr, long eventId, long attendeeId, int status) {
494 // Update the "selfAttendeeStatus" field for the event
495 ContentValues values = new ContentValues();
497 // Will need to add email when MULTIPLE_ATTENDEES_PER_EVENT supported.
498 values.put(Attendees.ATTENDEE_STATUS, status);
499 values.put(Attendees.EVENT_ID, eventId);
501 Uri uri = ContentUris.withAppendedId(Attendees.CONTENT_URI, attendeeId);
502 cr.update(uri, values, null /* where */, null /* selection args */);
505 private void createExceptionResponse(ContentResolver cr, long eventId,
506 long attendeeId, int status) {
507 // Fetch information about the repeating event.
508 Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId);
509 Cursor cursor = cr.query(uri, EVENT_PROJECTION, null, null, null);
510 if (cursor == null) {
515 cursor.moveToFirst();
516 ContentValues values = new ContentValues();
518 String title = cursor.getString(EVENT_INDEX_TITLE);
519 String timezone = cursor.getString(EVENT_INDEX_EVENT_TIMEZONE);
520 int calendarId = cursor.getInt(EVENT_INDEX_CALENDAR_ID);
521 boolean allDay = cursor.getInt(EVENT_INDEX_ALL_DAY) != 0;
522 String syncId = cursor.getString(EVENT_INDEX_SYNC_ID);
524 values.put(Events.TITLE, title);
525 values.put(Events.EVENT_TIMEZONE, timezone);
526 values.put(Events.ALL_DAY, allDay ? 1 : 0);
527 values.put(Events.CALENDAR_ID, calendarId);
528 values.put(Events.DTSTART, mStartMillis);
529 values.put(Events.DTEND, mEndMillis);
530 values.put(Events.ORIGINAL_EVENT, syncId);
531 values.put(Events.ORIGINAL_INSTANCE_TIME, mStartMillis);
532 values.put(Events.ORIGINAL_ALL_DAY, allDay ? 1 : 0);
533 values.put(Events.STATUS, Events.STATUS_CONFIRMED);
534 values.put(Events.SELF_ATTENDEE_STATUS, status);
536 // Create a recurrence exception
537 Uri newUri = cr.insert(Events.CONTENT_URI, values);
543 private int findResponseIndexFor(int response) {
544 int size = ATTENDEE_VALUES.length;
545 for (int index = 0; index < size; index++) {
546 if (ATTENDEE_VALUES[index] == response) {
553 private void doEdit() {
554 Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
555 Intent intent = new Intent(Intent.ACTION_EDIT, uri);
556 intent.putExtra(Calendar.EVENT_BEGIN_TIME, mStartMillis);
557 intent.putExtra(Calendar.EVENT_END_TIME, mEndMillis);
558 intent.setClass(EventInfoActivity.this, EditEvent.class);
559 startActivity(intent);
563 private void doDelete() {
564 mDeleteEventHelper.delete(mStartMillis, mEndMillis, mEventCursor, -1);
567 private void updateView() {
568 if (mEventCursor == null) {
571 Resources res = getResources();
572 ContentResolver cr = getContentResolver();
574 String eventName = mEventCursor.getString(EVENT_INDEX_TITLE);
575 if (eventName == null || eventName.length() == 0) {
576 eventName = res.getString(R.string.no_title_label);
579 boolean allDay = mEventCursor.getInt(EVENT_INDEX_ALL_DAY) != 0;
580 String location = mEventCursor.getString(EVENT_INDEX_EVENT_LOCATION);
581 String description = mEventCursor.getString(EVENT_INDEX_DESCRIPTION);
582 String rRule = mEventCursor.getString(EVENT_INDEX_RRULE);
583 boolean hasAlarm = mEventCursor.getInt(EVENT_INDEX_HAS_ALARM) != 0;
584 String eventTimezone = mEventCursor.getString(EVENT_INDEX_EVENT_TIMEZONE);
585 int color = mEventCursor.getInt(EVENT_INDEX_COLOR) & 0xbbffffff;
587 View strip = (View) findViewById(R.id.strip);
588 strip.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
590 TextView title = (TextView) findViewById(R.id.title);
591 title.setTextColor(color);
593 View divider = (View) findViewById(R.id.divider);
594 divider.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
597 if (eventName != null) {
598 setTextCommon(R.id.title, eventName);
605 flags = DateUtils.FORMAT_UTC | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_DATE;
607 flags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE;
608 if (DateFormat.is24HourFormat(this)) {
609 flags |= DateUtils.FORMAT_24HOUR;
612 when = DateUtils.formatDateRange(this, mStartMillis, mEndMillis, flags);
613 setTextCommon(R.id.when, when);
615 // Show the event timezone if it is different from the local timezone
616 Time time = new Time();
617 String localTimezone = time.timezone;
619 localTimezone = Time.TIMEZONE_UTC;
621 if (eventTimezone != null && !localTimezone.equals(eventTimezone) && !allDay) {
622 setTextCommon(R.id.timezone, localTimezone);
624 setVisibilityCommon(R.id.timezone_container, View.GONE);
629 EventRecurrence eventRecurrence = new EventRecurrence();
630 eventRecurrence.parse(rRule);
631 Time date = new Time();
633 date.timezone = Time.TIMEZONE_UTC;
635 date.set(mStartMillis);
636 eventRecurrence.setStartDate(date);
637 String repeatString = eventRecurrence.getRepeatString();
638 setTextCommon(R.id.repeat, repeatString);
640 setVisibilityCommon(R.id.repeat_container, View.GONE);
644 if (location == null || location.length() == 0) {
645 setVisibilityCommon(R.id.where, View.GONE);
647 setTextCommon(R.id.where, location);
651 if (description == null || description.length() == 0) {
652 setVisibilityCommon(R.id.description, View.GONE);
654 setTextCommon(R.id.description, description);
658 if (mCalendarsCursor != null) {
659 mCalendarsCursor.moveToFirst();
660 String calendarName = mCalendarsCursor.getString(CALENDARS_INDEX_DISPLAY_NAME);
661 setTextCommon(R.id.calendar, calendarName);
663 setVisibilityCommon(R.id.calendar_container, View.GONE);
670 void updateResponse() {
671 if (mVisibility < Calendars.CONTRIBUTOR_ACCESS ||
672 mRelationship != Attendees.RELATIONSHIP_ATTENDEE) {
673 setVisibilityCommon(R.id.response_container, View.GONE);
677 setVisibilityCommon(R.id.response_container, View.VISIBLE);
679 Spinner spinner = (Spinner) findViewById(R.id.response_value);
681 mOriginalAttendeeResponse = ATTENDEE_NO_RESPONSE;
682 if (mAttendeesCursor != null) {
683 mOriginalAttendeeResponse = mAttendeesCursor.getInt(ATTENDEES_INDEX_STATUS);
687 /* If the user has previously responded to this event
688 * we should not allow them to select no response again.
689 * Switch the entries to a set of entries without the
690 * no response option.
692 if ((mOriginalAttendeeResponse != Attendees.ATTENDEE_STATUS_INVITED)
693 && (mOriginalAttendeeResponse != ATTENDEE_NO_RESPONSE)
694 && (mOriginalAttendeeResponse != Attendees.ATTENDEE_STATUS_NONE)) {
695 CharSequence[] entries;
696 entries = getResources().getTextArray(R.array.response_labels2);
697 mResponseOffset = -1;
698 ArrayAdapter<CharSequence> adapter =
699 new ArrayAdapter<CharSequence>(this,
700 android.R.layout.simple_spinner_item, entries);
701 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
702 spinner.setAdapter(adapter);
705 int index = findResponseIndexFor(mOriginalAttendeeResponse);
706 spinner.setSelection(index + mResponseOffset);
707 spinner.setOnItemSelectedListener(this);
710 private void setTextCommon(int id, CharSequence text) {
711 TextView textView = (TextView) findViewById(id);
712 if (textView == null)
714 textView.setText(text);
717 private void setVisibilityCommon(int id, int visibility) {
718 View v = findViewById(id);
720 v.setVisibility(visibility);