diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-06-06 21:23:49 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-06 21:23:49 +0200 |
commit | 1e5c64a1f569ebe8a893cdff9a4d8957849220b3 (patch) | |
tree | 75bbcb3a1d8d40895903fb38b2a3bee008367dc7 /src/main/java/eu/siacs/conversations/entities | |
parent | 6582ac6e72a1f9bf55f2f6d8457114a6426c1062 (diff) | |
parent | b88128241eb7deb6599e946dc009fdc5dfd32974 (diff) |
Merge remote-tracking branch 'refs/remotes/siacs/master'
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Contact.java | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 8721d9c46..70878a734 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -34,7 +34,6 @@ public class Contact implements ListItem, Blockable { public static final String LAST_PRESENCE = "last_presence"; public static final String LAST_TIME = "last_time"; public static final String GROUPS = "groups"; - public Lastseen lastseen = new Lastseen(); protected String accountUuid; protected String systemName; protected String serverName; @@ -50,9 +49,14 @@ public class Contact implements ListItem, Blockable { protected Account account; protected Avatar avatar; + private boolean mActive = false; + private long mLastseen = 0; + private String mLastPresence = null; + public Contact(final String account, final String systemName, final String serverName, final Jid jid, final int subscription, final String photoUri, - final String systemAccount, final String keys, final String avatar, final Lastseen lastseen, final String groups) { + final String systemAccount, final String keys, final String avatar, final long lastseen, + final String presence, final String groups) { this.accountUuid = account; this.systemName = systemName; this.serverName = serverName; @@ -75,7 +79,8 @@ public class Contact implements ListItem, Blockable { } catch (JSONException e) { this.groups = new JSONArray(); } - this.lastseen = lastseen; + this.mLastseen = lastseen; + this.mLastPresence = presence; } public Contact(final Jid jid) { @@ -83,9 +88,6 @@ public class Contact implements ListItem, Blockable { } public static Contact fromCursor(final Cursor cursor) { - final Lastseen lastseen = new Lastseen( - cursor.getString(cursor.getColumnIndex(LAST_PRESENCE)), - cursor.getLong(cursor.getColumnIndex(LAST_TIME))); final Jid jid; try { jid = Jid.fromString(cursor.getString(cursor.getColumnIndex(JID)), true); @@ -102,7 +104,8 @@ public class Contact implements ListItem, Blockable { cursor.getString(cursor.getColumnIndex(SYSTEMACCOUNT)), cursor.getString(cursor.getColumnIndex(KEYS)), cursor.getString(cursor.getColumnIndex(AVATAR)), - lastseen, + cursor.getLong(cursor.getColumnIndex(LAST_TIME)), + cursor.getString(cursor.getColumnIndex(LAST_PRESENCE)), cursor.getString(cursor.getColumnIndex(GROUPS))); } @@ -197,8 +200,8 @@ public class Contact implements ListItem, Blockable { values.put(PHOTOURI, photoUri); values.put(KEYS, keys.toString()); values.put(AVATAR, avatar == null ? null : avatar.getFilename()); - values.put(LAST_PRESENCE, lastseen.presence); - values.put(LAST_TIME, lastseen.time); + values.put(LAST_PRESENCE, mLastPresence); + values.put(LAST_TIME, mLastseen); values.put(GROUPS, groups.toString()); return values; } @@ -517,18 +520,32 @@ public class Contact implements ListItem, Blockable { this.commonName = cn; } - public static class Lastseen { - public long time; - public String presence; + public void flagActive() { + this.mActive = true; + } - public Lastseen() { - this(null, 0); - } + public void flagInactive() { + this.mActive = false; + } - public Lastseen(final String presence, final long time) { - this.presence = presence; - this.time = time; - } + public boolean isActive() { + return this.mActive; + } + + public void setLastseen(long timestamp) { + this.mLastseen = Math.max(timestamp, mLastseen); + } + + public long getLastseen() { + return this.mLastseen; + } + + public void setLastPresence(String presence) { + this.mLastPresence = presence; + } + + public String getLastPresence() { + return this.mLastPresence; } public final class Options { |