android:autoLink="all"
style="?android:attr/textAppearanceSmall"
/>
+
+ <!-- Organizer -->
+ <LinearLayout android:id="@+id/organizer_container"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="5dip"
+ >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="5dip"
+ android:text="@string/view_event_organizer_label"
+ style="?android:attr/textAppearanceSmall"
+ />
+ <TextView android:id="@+id/organizer"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ style="?android:attr/textAppearanceSmall"
+ />
+ </LinearLayout>
+
<!-- DESCRIPTION -->
<TextView android:id="@+id/description"
android:layout_width="fill_parent"
</LinearLayout>
</LinearLayout>
- <!-- GUEST LIST -->
- <LinearLayout
- android:id="@+id/attendee_list"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="8dip"
- android:orientation="vertical" />
-
<!-- RESPONSE -->
<LinearLayout android:id="@+id/response_container"
android:orientation="vertical"
android:entries="@array/response_labels1"/>
</LinearLayout>
+ <!-- GUEST LIST -->
+ <LinearLayout
+ android:id="@+id/attendee_list"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="8dip"
+ android:orientation="vertical" />
+
<!-- REMINDERS -->
<LinearLayout android:id="@+id/reminders_container"
android:orientation="vertical"
android:paddingLeft="8dip"
android:paddingRight="7dip"
android:paddingTop="5dip"
- android:paddingBottom="1dip">
+ android:paddingBottom="5dip">
<TextView android:id="@+id/reminders_label"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
- </LinearLayout>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical|right"
- android:paddingRight="5dip"
- android:paddingBottom="5dip">
-
- <TextView
- android:layout_width="wrap_content"
+ <LinearLayout android:id="@+id/reminder_adder"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginRight="7dip"
- android:text="@string/add_new_reminder"/>
+ android:gravity="center_vertical|right">
- <ImageButton android:id="@+id/reminder_add"
- style="@style/PlusButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="2dip"
- />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="7dip"
+ android:text="@string/add_new_reminder"/>
+
+ <ImageButton android:id="@+id/reminder_add"
+ style="@style/PlusButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ />
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
public class EventInfoActivity extends Activity implements View.OnClickListener,
AdapterView.OnItemSelectedListener {
+ public static final boolean DEBUG = false;
+
+ public static final String TAG = "EventInfoActivity";
+
private static final int MAX_REMINDERS = 5;
/**
Events.ACCESS_LEVEL, // 11
Events.COLOR, // 12
Events.GUESTS_CAN_MODIFY, // 13
- Events.ORGANIZER, // 14
+ // TODO Events.CAN_INVITE_OTHERS is broken. Investigate
+ Events.GUESTS_CAN_INVITE_OTHERS, // 14
+ Events.ORGANIZER, // 15
};
private static final int EVENT_INDEX_ID = 0;
private static final int EVENT_INDEX_TITLE = 1;
private static final int EVENT_INDEX_ACCESS_LEVEL = 11;
private static final int EVENT_INDEX_COLOR = 12;
private static final int EVENT_INDEX_GUESTS_CAN_MODIFY = 13;
- private static final int EVENT_INDEX_ORGANIZER = 14;
+ private static final int EVENT_INDEX_CAN_INVITE_OTHERS = 14;
+ private static final int EVENT_INDEX_ORGANIZER = 15;
private static final String[] ATTENDEES_PROJECTION = new String[] {
Attendees._ID, // 0
};
private LinearLayout mRemindersContainer;
+ private LinearLayout mOrganizerContainer;
+ private TextView mOrganizerView;
private Uri mUri;
private long mEventId;
private long mCalendarOwnerAttendeeId = -1;
private String mCalendarOwnerAccount;
private boolean mCanModifyCalendar;
+ private boolean mIsBusyFreeCalendar;
private boolean mCanModifyEvent;
- private boolean mIsAttendee;
+ private int mNumOfAttendees;
private String mOrganizer;
private ArrayList<Integer> mOriginalMinutes = new ArrayList<Integer>();
private Pattern mWildcardPattern = Pattern.compile("^.*$");
private LayoutInflater mLayoutInflater;
+ private LinearLayout mReminderAdder;
// TODO This can be removed when the contacts content provider doesn't return duplicates
private int mUpdateCounts;
Contacts.PHOTO_ID, // 3
};
- public static final boolean DEBUG = false;
-
- public static final String TAG = "EventInfoActivity";
-
ArrayList<Attendee> mAcceptedAttendees = new ArrayList<Attendee>();
ArrayList<Attendee> mDeclinedAttendees = new ArrayList<Attendee>();
ArrayList<Attendee> mTentativeAttendees = new ArrayList<Attendee>();
mCalendarOwnerAccount = mCalendarsCursor.getString(CALENDARS_INDEX_OWNER_ACCOUNT);
}
+ String eventOrganizer = mEventCursor.getString(EVENT_INDEX_ORGANIZER);
+ mOrganizer = eventOrganizer;
mCanModifyCalendar =
mEventCursor.getInt(EVENT_INDEX_ACCESS_LEVEL) >= Calendars.CONTRIBUTOR_ACCESS;
+ mIsBusyFreeCalendar =
+ mEventCursor.getInt(EVENT_INDEX_ACCESS_LEVEL) == Calendars.FREEBUSY_ACCESS;
mCanModifyEvent = mCanModifyCalendar
- && (mEventCursor.getInt(EVENT_INDEX_GUESTS_CAN_MODIFY) != 0);
- mOrganizer = mEventCursor.getString(EVENT_INDEX_ORGANIZER);
+ && (mCalendarOwnerAccount.equals(eventOrganizer)
+ || mEventCursor.getInt(EVENT_INDEX_GUESTS_CAN_MODIFY) != 0);
// Initialize the reminder values array.
Resources r = getResources();
prefs.getString(CalendarPreferenceActivity.KEY_DEFAULT_REMINDER, "0");
mDefaultReminderMinutes = Integer.parseInt(durationString);
- mRemindersContainer = (LinearLayout) findViewById(R.id.reminder_items_container);
+ mRemindersContainer = (LinearLayout) findViewById(R.id.reminders_container);
+ mOrganizerContainer = (LinearLayout) findViewById(R.id.organizer_container);
+ mOrganizerView = (TextView) findViewById(R.id.organizer);
// Reminders cursor
boolean hasAlarm = mEventCursor.getInt(EVENT_INDEX_HAS_ALARM) != 0;
}
updateView();
- updateRemindersVisibility();
// Setup the + Add Reminder Button
View.OnClickListener addReminderOnClickListener = new View.OnClickListener() {
addReminder();
}
};
- ImageButton reminderRemoveButton = (ImageButton) findViewById(R.id.reminder_add);
- reminderRemoveButton.setOnClickListener(addReminderOnClickListener);
+ ImageButton reminderAddButton = (ImageButton) findViewById(R.id.reminder_add);
+ reminderAddButton.setOnClickListener(addReminderOnClickListener);
+
+ mReminderAdder = (LinearLayout) findViewById(R.id.reminder_adder);
+ updateRemindersVisibility();
mDeleteEventHelper = new DeleteEventHelper(this, true /* exit when done */);
mEditResponseHelper = new EditResponseHelper(this);
private void updateTitle() {
Resources res = getResources();
- if (mCanModifyCalendar && mIsAttendee) {
+ if (mCanModifyCalendar && mNumOfAttendees > 1) {
setTitle(res.getString(R.string.event_info_title_invite));
} else {
setTitle(res.getString(R.string.event_info_title));
private void initAttendeesCursor() {
mOriginalAttendeeResponse = ATTENDEE_NO_RESPONSE;
mCalendarOwnerAttendeeId = -1;
+ mNumOfAttendees = 0;
if (mAttendeesCursor != null) {
+ mNumOfAttendees = mAttendeesCursor.getCount();
if (mAttendeesCursor.moveToFirst()) {
mAcceptedAttendees.clear();
mDeclinedAttendees.clear();
String name = mAttendeesCursor.getString(ATTENDEES_INDEX_NAME);
String email = mAttendeesCursor.getString(ATTENDEES_INDEX_EMAIL);
+ if (mAttendeesCursor.getInt(ATTENDEES_INDEX_RELATIONSHIP) ==
+ Attendees.RELATIONSHIP_ORGANIZER) {
+ // Overwrites the one from Event table if available
+ if (name != null && name.length() > 0) {
+ mOrganizer = name;
+ } else if (email != null && email.length() > 0) {
+ mOrganizer = email;
+ }
+ }
+
if (mCalendarOwnerAttendeeId == -1 && mCalendarOwnerAccount.equals(email)) {
- mIsAttendee = true;
mCalendarOwnerAttendeeId = mAttendeesCursor.getInt(ATTENDEES_INDEX_ID);
mOriginalAttendeeResponse = mAttendeesCursor.getInt(ATTENDEES_INDEX_STATUS);
}
updateAttendees();
}
}
+ if (mNumOfAttendees > 1) {
+ mOrganizerContainer.setVisibility(View.VISIBLE);
+ mOrganizerView.setText(mOrganizer);
+ } else {
+ mOrganizerContainer.setVisibility(View.GONE);
+ }
}
private void initCalendarsCursor() {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- // Cannot add reminders to a shared calendar with only free/busy
- // permissions
- boolean canAddReminders = mCanModifyCalendar && mReminderItems.size() < MAX_REMINDERS;
+ boolean canAddReminders = canAddReminders();
menu.setGroupVisible(MENU_GROUP_REMINDER, canAddReminders);
menu.setGroupEnabled(MENU_GROUP_REMINDER, canAddReminders);
return super.onPrepareOptionsMenu(menu);
}
+ private boolean canAddReminders() {
+ return !mIsBusyFreeCalendar && mReminderItems.size() < MAX_REMINDERS;
+ }
+
private void addReminder() {
// TODO: when adding a new reminder, make it different from the
// last one in the list (if any).
}
private void updateRemindersVisibility() {
- if (mReminderItems.size() == 0) {
+ if (mIsBusyFreeCalendar) {
mRemindersContainer.setVisibility(View.GONE);
} else {
mRemindersContainer.setVisibility(View.VISIBLE);
+ mReminderAdder.setVisibility(canAddReminders() ? View.VISIBLE : View.GONE);
}
}
}
void updateResponse() {
- if (!mCanModifyCalendar || !mIsAttendee) {
+ if (!mCanModifyCalendar || mNumOfAttendees <= 1) {
setVisibilityCommon(R.id.response_container, View.GONE);
return;
}