Commit 9d3afd55 authored by Grigory Fedorov's avatar Grigory Fedorov

Last outgoing message and time are displayed in active chats.

parent 1787ea35
......@@ -451,8 +451,9 @@ public abstract class AbstractChat extends BaseEntity {
for (int index = messages.size() - 1; index >= 0; index--) {
MessageItem messageItem = messages.get(index);
if (messageItem.getAction() == null) {
lastText = messageItem.isIncoming() ? messageItem.getText()
: "";
String lastMessage = messageItem.getText();
lastText = messageItem.isIncoming() ? "< " + lastMessage : "> " + lastMessage;
lastTime = messageItem.getTimestamp();
return;
}
......@@ -467,8 +468,7 @@ public abstract class AbstractChat extends BaseEntity {
Application.getInstance().runInBackground(new Runnable() {
@Override
public void run() {
MessageTable.getInstance().removeMessages(
MessageManager.getMessageIds(messageItems, true));
MessageTable.getInstance().removeMessages(MessageManager.getMessageIds(messageItems, true));
}
});
}
......@@ -482,8 +482,7 @@ public abstract class AbstractChat extends BaseEntity {
Application.getInstance().runInBackground(new Runnable() {
@Override
public void run() {
MessageTable.getInstance().removeMessages(
MessageManager.getMessageIds(messageItems, true));
MessageTable.getInstance().removeMessages(MessageManager.getMessageIds(messageItems, true));
MessageTable.getInstance().removeMessages(historyIds);
historyIds.clear();
}
......
......@@ -15,8 +15,11 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.ui.ContactEditor;
import com.xabber.android.ui.ContactViewer;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import java.util.Date;
public class ContactItemInflater {
static class ContactViewHolder {
......@@ -78,13 +81,7 @@ public class ContactItemInflater {
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (MUCManager.getInstance().hasRoom(abstractContact.getAccount(), abstractContact.getUser())) {
context.startActivity(ContactViewer.createIntent(context,
abstractContact.getAccount(), abstractContact.getUser()));
} else {
context.startActivity(ContactEditor.createIntent(context,
abstractContact.getAccount(), abstractContact.getUser()));
}
onAvatarClick(abstractContact);
}
});
......@@ -93,8 +90,12 @@ public class ContactItemInflater {
if (MessageManager.getInstance()
.hasActiveChat(abstractContact.getAccount(), abstractContact.getUser())) {
statusText = MessageManager.getInstance()
String lastMessage = MessageManager.getInstance()
.getLastText(abstractContact.getAccount(), abstractContact.getUser());
Date lastTime = MessageManager.getInstance()
.getLastTime(abstractContact.getAccount(), abstractContact.getUser());
statusText = StringUtils.getSmartTimeText(context, lastTime) + " " + lastMessage;
} else {
statusText = abstractContact.getStatusText();
}
......@@ -126,4 +127,14 @@ public class ContactItemInflater {
return view;
}
private void onAvatarClick(AbstractContact contact) {
if (MUCManager.getInstance().hasRoom(contact.getAccount(), contact.getUser())) {
context.startActivity(ContactViewer.createIntent(context,
contact.getAccount(), contact.getUser()));
} else {
context.startActivity(ContactEditor.createIntent(context,
contact.getAccount(), contact.getUser()));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment