mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 12:42:16 -05:00
conference histories are now working. only the actually needed history is queried
This commit is contained in:
parent
962263e6e6
commit
f6a6982bd0
@ -73,7 +73,7 @@ public class Conversation extends AbstractEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRead() {
|
public boolean isRead() {
|
||||||
if (this.messages == null) return true;
|
if ((this.messages == null)||(this.messages.size() == 0)) return true;
|
||||||
return this.messages.get(this.messages.size() - 1).isRead();
|
return this.messages.get(this.messages.size() - 1).isRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,4 +128,8 @@ public class Message extends AbstractEntity {
|
|||||||
this.read = false;
|
this.read = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTime(long time) {
|
||||||
|
this.timeSent = time;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -230,6 +230,10 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mergeMessageIntoConversation(Message message) {
|
||||||
|
// select counterpart,body,(timeSent/1000)-180 as min,(timeSent/1000)+180 as max from messages where min<1392035670 and max>1392035670;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Contact> getContacts(Account account) {
|
public List<Contact> getContacts(Account account) {
|
||||||
List<Contact> list = new ArrayList<Contact>();
|
List<Contact> list = new ArrayList<Contact>();
|
||||||
SQLiteDatabase db = this.getReadableDatabase();
|
SQLiteDatabase db = this.getReadableDatabase();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package de.gultsch.chat.services;
|
package de.gultsch.chat.services;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -28,12 +31,8 @@ import de.gultsch.chat.xmpp.XmppConnection;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.CursorLoader;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Loader;
|
|
||||||
import android.content.Loader.OnLoadCompleteListener;
|
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@ -115,8 +114,7 @@ public class XmppConnectionService extends Service {
|
|||||||
String counterPart = null;
|
String counterPart = null;
|
||||||
conversation = findOrCreateConversation(account, jid, muc);
|
conversation = findOrCreateConversation(account, jid, muc);
|
||||||
if (muc) {
|
if (muc) {
|
||||||
if ((fromParts.length == 1) || (packet.hasChild("subject"))
|
if ((fromParts.length == 1) || (packet.hasChild("subject"))) {
|
||||||
|| (packet.hasChild("delay"))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
counterPart = fromParts[1];
|
counterPart = fromParts[1];
|
||||||
@ -129,6 +127,16 @@ public class XmppConnectionService extends Service {
|
|||||||
}
|
}
|
||||||
Message message = new Message(conversation, counterPart, body,
|
Message message = new Message(conversation, counterPart, body,
|
||||||
Message.ENCRYPTION_NONE, status);
|
Message.ENCRYPTION_NONE, status);
|
||||||
|
if (packet.hasChild("delay")) {
|
||||||
|
try {
|
||||||
|
String stamp = packet.findChild("delay").getAttribute("stamp");
|
||||||
|
stamp = stamp.replace("Z","+0000");
|
||||||
|
Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(stamp);
|
||||||
|
message.setTime(date.getTime());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
Log.d(LOGTAG,"error trying to parse date"+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
if(notify) {
|
if(notify) {
|
||||||
message.markUnread();
|
message.markUnread();
|
||||||
}
|
}
|
||||||
@ -550,7 +558,15 @@ public class XmppConnectionService extends Service {
|
|||||||
packet.setAttribute("to", muc + "/" + account.getUsername());
|
packet.setAttribute("to", muc + "/" + account.getUsername());
|
||||||
Element x = new Element("x");
|
Element x = new Element("x");
|
||||||
x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
|
x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
|
||||||
|
if (conversation.getMessages().size()!=0) {
|
||||||
|
Element history = new Element("history");
|
||||||
|
history.setAttribute("seconds",(System.currentTimeMillis() - conversation.getLatestMessageDate()) / 1000+"");
|
||||||
|
x.addChild(history);
|
||||||
|
} else {
|
||||||
|
Log.d(LOGTAG,"conversation had no prior messages"+conversation.getMessages().size());
|
||||||
|
}
|
||||||
packet.addChild(x);
|
packet.addChild(x);
|
||||||
|
Log.d(LOGTAG,packet.toString());
|
||||||
connections.get(conversation.getAccount()).sendPresencePacket(packet);
|
connections.get(conversation.getAccount()).sendPresencePacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user