android:layout_width="fill_parent"
android:paddingLeft="0dip"
android:paddingRight="9dip"
- android:paddingBottom="4dip"
android:minHeight="48dip">
- <ImageView
- android:id="@+id/avatar"
- android:scaleType="centerInside"
- android:paddingLeft="4dip"
- android:paddingRight="4dip"
- android:paddingTop="4dip"
- android:paddingBottom="9dip"
- android:layout_width="35dip"
- android:layout_height="40dip"
+ <FasttrackBadgeWidget
+ android:id="@+id/badge"
+ android:paddingLeft="3dip"
+ android:paddingRight="3dip"
+ android:paddingTop="3dip"
+ android:paddingBottom="6dip"
+ android:layout_above="@+id/separator"
android:layout_marginLeft="2dip"
android:layout_marginRight="14dip"
- android:layout_marginTop="3dip"
+ android:layout_marginTop="4dip"
android:layout_marginBottom="3dip"
android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:focusable="true"
+ android:layout_alignParentTop="true"
android:src="@drawable/ic_contact_picture"
- android:background="@drawable/fasttrack_badge" />
+ style="@*android:style/Widget.FasttrackBadgeWidgetSmall.WindowSmall" />
<TextView
android:id="@+id/name"
android:inputType="none"
android:paddingLeft="2dip"
android:layout_centerVertical="true"
- android:layout_toRightOf="@id/avatar"
+ android:layout_toRightOf="@id/badge"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
+import android.widget.FasttrackBadgeWidget;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
Events.ACCESS_LEVEL, // 11
Events.COLOR, // 12
Events.GUESTS_CAN_MODIFY, // 13
- // TODO Events.CAN_INVITE_OTHERS is broken. Investigate
+ // TODO Events.GUESTS_CAN_INVITE_OTHERS has not been implemented in calendar provider
Events.GUESTS_CAN_INVITE_OTHERS, // 14
Events.ORGANIZER, // 15
};
// TODO This can be removed when the contacts content provider doesn't return duplicates
private int mUpdateCounts;
private static class ViewHolder {
- ImageView avatar;
+ FasttrackBadgeWidget badge;
ImageView presence;
int updateCounts;
}
ArrayList<Attendee> mAcceptedAttendees = new ArrayList<Attendee>();
ArrayList<Attendee> mDeclinedAttendees = new ArrayList<Attendee>();
ArrayList<Attendee> mTentativeAttendees = new ArrayList<Attendee>();
- private OnClickListener contactOnClickListener = new OnClickListener() {
- private Rect getTargetRect(View anchor) {
- final int[] location = new int[2];
- anchor.getLocationOnScreen(location);
-
- final Rect rect = new Rect();
- rect.left = location[0];
- rect.top = location[1];
- rect.right = rect.left + anchor.getWidth();
- rect.bottom = rect.top + anchor.getHeight();
- return rect;
- }
-
- public void onClick(View avatar) {
- final Rect target = getTargetRect(avatar);
- View attendeeItem = (View) avatar.getParent();
- showContactInfo((Attendee) attendeeItem.getTag(), target);
- }
- };
private int mColor;
// This is called when one of the "remove reminder" buttons is selected.
}
setContentView(R.layout.event_info_activity);
-
- // Attendees cursor
- Uri uri = Attendees.CONTENT_URI;
- String where = String.format(ATTENDEES_WHERE, mEventId);
- mAttendeesCursor = managedQuery(uri, ATTENDEES_PROJECTION, where, ATTENDEES_SORT_ORDER);
+ mPresenceQueryHandler = new PresenceQueryHandler(this, cr);
+ mLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mRemindersContainer = (LinearLayout) findViewById(R.id.reminders_container);
+ mOrganizerContainer = (LinearLayout) findViewById(R.id.organizer_container);
+ mOrganizerView = (TextView) findViewById(R.id.organizer);
// Calendars cursor
- uri = Calendars.CONTENT_URI;
- where = String.format(CALENDARS_WHERE, mEventCursor.getLong(EVENT_INDEX_CALENDAR_ID));
+ Uri uri = Calendars.CONTENT_URI;
+ String where = String.format(CALENDARS_WHERE, mEventCursor.getLong(EVENT_INDEX_CALENDAR_ID));
mCalendarsCursor = managedQuery(uri, CALENDARS_PROJECTION, where, null);
mCalendarOwnerAccount = "";
if (mCalendarsCursor != null) {
mCalendarOwnerAccount = mCalendarsCursor.getString(CALENDARS_INDEX_OWNER_ACCOUNT);
}
+ updateView();
+
+ // Attendees cursor
+ uri = Attendees.CONTENT_URI;
+ where = String.format(ATTENDEES_WHERE, mEventId);
+ mAttendeesCursor = managedQuery(uri, ATTENDEES_PROJECTION, where, ATTENDEES_SORT_ORDER);
+ initAttendeesCursor();
+
String eventOrganizer = mEventCursor.getString(EVENT_INDEX_ORGANIZER);
mOrganizer = eventOrganizer;
mCanModifyCalendar =
prefs.getString(CalendarPreferenceActivity.KEY_DEFAULT_REMINDER, "0");
mDefaultReminderMinutes = Integer.parseInt(durationString);
- 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;
if (hasAlarm) {
}
}
- updateView();
-
// Setup the + Add Reminder Button
View.OnClickListener addReminderOnClickListener = new View.OnClickListener() {
public void onClick(View v) {
mDeleteEventHelper = new DeleteEventHelper(this, true /* exit when done */);
mEditResponseHelper = new EditResponseHelper(this);
-
- mPresenceQueryHandler = new PresenceQueryHandler(this, cr);
- mLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
finish();
return;
}
- initAttendeesCursor();
initCalendarsCursor();
updateResponse();
updateTitle();
if (mCalendarOwnerAttendeeId == -1 && mCalendarOwnerAccount.equals(email)) {
mCalendarOwnerAttendeeId = mAttendeesCursor.getInt(ATTENDEES_INDEX_ID);
mOriginalAttendeeResponse = mAttendeesCursor.getInt(ATTENDEES_INDEX_STATUS);
- }
-
- switch(status) {
- case Attendees.ATTENDEE_STATUS_ACCEPTED:
- mAcceptedAttendees.add(new Attendee(name, email));
- break;
- case Attendees.ATTENDEE_STATUS_DECLINED:
- mDeclinedAttendees.add(new Attendee(name, email));
- break;
- default:
- mTentativeAttendees.add(new Attendee(name, email));
+ } else {
+ // Don't show your own status in the list because:
+ // 1) it doesn't make sense for event without other guests.
+ // 2) there's a spinner for that for events with guests.
+ switch(status) {
+ case Attendees.ATTENDEE_STATUS_ACCEPTED:
+ mAcceptedAttendees.add(new Attendee(name, email));
+ break;
+ case Attendees.ATTENDEE_STATUS_DECLINED:
+ mDeclinedAttendees.add(new Attendee(name, email));
+ break;
+ default:
+ mTentativeAttendees.add(new Attendee(name, email));
+ }
}
} while (mAttendeesCursor.moveToNext());
mAttendeesCursor.moveToFirst();
updateResponse(cr, mEventId, mCalendarOwnerAttendeeId, status);
return true;
default:
- Log.e("Calendar", "Unexpected choice for updating invitation response");
+ Log.e(TAG, "Unexpected choice for updating invitation response");
break;
}
return false;
if (mEventCursor == null) {
return;
}
- Resources res = getResources();
String eventName = mEventCursor.getString(EVENT_INDEX_TITLE);
if (eventName == null || eventName.length() == 0) {
+ Resources res = getResources();
eventName = res.getString(R.string.no_title_label);
}
ContentResolver cr = getContentResolver();
// Yes/No/Maybe Title
View titleView = mLayoutInflater.inflate(R.layout.contact_item, null);
- titleView.findViewById(R.id.avatar).setVisibility(View.GONE);
+ titleView.findViewById(R.id.badge).setVisibility(View.GONE);
View divider = titleView.findViewById(R.id.separator);
divider.getBackground().setColorFilter(mColor, PorterDuff.Mode.SRC_IN);
tv.setText(name);
ViewHolder vh = new ViewHolder();
- vh.avatar = (ImageView) v.findViewById(R.id.avatar);
- vh.avatar.setOnClickListener(contactOnClickListener);
+ vh.badge = (FasttrackBadgeWidget) v.findViewById(R.id.badge);
+ vh.badge.assignContactFromEmail(attendee.mEmail, true);
vh.presence = (ImageView) v.findViewById(R.id.presence);
mViewHolders.put(attendee.mEmail, vh);
}
try {
-
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
String email = cursor.getString(PRESENCE_PROJECTION_EMAIL_INDEX);
if (photoId > 0 && vh.updateCounts < queryIndex) {
vh.updateCounts = queryIndex;
Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
- ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, vh.avatar,
+ ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, vh.badge,
personUri, R.drawable.ic_contact_picture);
}
}