2 * Copyright (C) 2008 Esmertec AG.
3 * Copyright (C) 2008 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package com.android.mms.ui;
20 import android.content.Context;
22 import com.android.mms.data.ContactList;
23 import com.android.mms.data.Conversation;
26 * A holder class for a conversation header.
28 public class ConversationListItemData {
29 private Conversation mConversation;
30 private long mThreadId;
31 private String mSubject;
33 private boolean mHasAttachment;
34 private boolean mIsRead;
35 private boolean mHasError;
36 private boolean mHasDraft;
37 private int mMessageCount;
39 // The recipients in this conversation
40 private ContactList mRecipients;
41 private String mRecipientString;
43 // the presence icon resource id displayed for the conversation thread.
44 private int mPresenceResId;
46 public ConversationListItemData(Context context, Conversation conv) {
48 mThreadId = conv.getThreadId();
50 mSubject = conv.getSnippet();
51 mDate = MessageUtils.formatTimeStampString(context, conv.getDate());
52 mIsRead = !conv.hasUnreadMessages();
53 mHasError = conv.hasError();
54 mHasDraft = conv.hasDraft();
55 mMessageCount = conv.getMessageCount();
56 mHasAttachment = conv.hasAttachment();
60 public void updateRecipients() {
61 mRecipients = mConversation.getRecipients();
62 mRecipientString = mRecipients.formatNames(", ");
66 * @return Returns the ID of the thread.
68 public long getThreadId() {
73 * @return Returns the date.
75 public String getDate() {
80 * @return Returns the from. (formatted for display)
82 public String getFrom() {
83 return mRecipientString;
86 public ContactList getContacts() {
90 public int getPresenceResourceId() {
91 return mPresenceResId;
95 * @return Returns the subject.
97 public String getSubject() {
102 * @return Returns the hasAttachment.
104 public boolean hasAttachment() {
105 return mHasAttachment;
109 * @return Returns the isRead.
111 public boolean isRead() {
116 * @return Whether the thread has a transmission error.
118 public boolean hasError() {
123 * @return Whether the thread has a draft.
125 public boolean hasDraft() {
130 * @return message count of the thread.
132 public int getMessageCount() {
133 return mMessageCount;
138 * @see java.lang.Object#toString()
141 public String toString() {
142 return "[ConversationHeader from:" + getFrom() + " subject:" + getSubject()