aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-10 22:45:59 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-10 22:45:59 +0100
commitb673af2ba0b46e7444f536fbc7429f9ef74560fb (patch)
treef33e36a559d3a2b574c25962579fa161f1f968d8 /src/de/gultsch/chat/entities
parentcfc74e7c8e912c7a194ad674ec5f98ab6950640f (diff)
reworked notification a bit
Diffstat (limited to '')
-rw-r--r--src/de/gultsch/chat/entities/Account.java2
-rw-r--r--src/de/gultsch/chat/entities/Conversation.java21
-rw-r--r--src/de/gultsch/chat/entities/Message.java13
3 files changed, 32 insertions, 4 deletions
diff --git a/src/de/gultsch/chat/entities/Account.java b/src/de/gultsch/chat/entities/Account.java
index bd2e14c6..0f7bfd52 100644
--- a/src/de/gultsch/chat/entities/Account.java
+++ b/src/de/gultsch/chat/entities/Account.java
@@ -60,10 +60,8 @@ public class Account extends AbstractEntity{
public void setOption(int option, boolean value) {
if (value) {
this.options = (this.options | 1 << option);
- Log.d("xmppService","enabling option "+this.options);
} else {
this.options = (this.options & 0 << option);
- Log.d("xmppService","disabeling option "+this.options);
}
}
diff --git a/src/de/gultsch/chat/entities/Conversation.java b/src/de/gultsch/chat/entities/Conversation.java
index 8be35aa4..bddd1356 100644
--- a/src/de/gultsch/chat/entities/Conversation.java
+++ b/src/de/gultsch/chat/entities/Conversation.java
@@ -6,6 +6,7 @@ import java.util.List;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
+import android.util.Log;
public class Conversation extends AbstractEntity {
@@ -71,6 +72,20 @@ public class Conversation extends AbstractEntity {
return messages;
}
+ public boolean isRead() {
+ if (this.messages == null) return true;
+ return this.messages.get(this.messages.size() - 1).isRead();
+ }
+
+ public void markRead() {
+ Log.d("xmppService", "inside mark read method");
+ if (this.messages == null) return;
+ for(int i = this.messages.size() -1; i >= 0; --i) {
+ if (messages.get(i).isRead()) return;
+ this.messages.get(i).markRead();
+ }
+ }
+
public String getLatestMessage() {
if ((this.messages == null)||(this.messages.size()==0)) {
return null;
@@ -121,7 +136,9 @@ public class Conversation extends AbstractEntity {
public void setContact(Contact contact) {
this.contact = contact;
- this.contactUuid = contact.getUuid();
+ if (contact!=null) {
+ this.contactUuid = contact.getUuid();
+ }
}
public void setAccount(Account account) {
@@ -151,7 +168,7 @@ public class Conversation extends AbstractEntity {
ContentValues values = new ContentValues();
values.put(UUID, uuid);
values.put(NAME, name);
- values.put(CONTACT, contact.getUuid());
+ values.put(CONTACT, contactUuid);
values.put(ACCOUNT, accountUuid);
values.put(CONTACTJID, contactJid);
values.put(CREATED, created);
diff --git a/src/de/gultsch/chat/entities/Message.java b/src/de/gultsch/chat/entities/Message.java
index 4349e341..d53e93c1 100644
--- a/src/de/gultsch/chat/entities/Message.java
+++ b/src/de/gultsch/chat/entities/Message.java
@@ -30,6 +30,7 @@ public class Message extends AbstractEntity {
protected long timeSent;
protected int encryption;
protected int status;
+ protected boolean read = true;
protected transient Conversation conversation = null;
@@ -115,4 +116,16 @@ public class Message extends AbstractEntity {
this.status = status;
}
+ public boolean isRead() {
+ return this.read;
+ }
+
+ public void markRead() {
+ this.read = true;
+ }
+
+ public void markUnread() {
+ this.read = false;
+ }
+
}