diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-12-17 21:05:47 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-12-17 21:05:47 +0100 |
commit | f00e168752e0b59de8eb667ce99bf6d10bd1361f (patch) | |
tree | 515ac38ac45e4306fc75058baa6b9aaea1395ddc | |
parent | de952cc9590b4e4f38698e5cdb42f378169f663b (diff) |
clean up conversation history after swtiching to a different conversation
Diffstat (limited to '')
3 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 90e4a899..6fe13d93 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -19,6 +19,7 @@ public final class Config { public static final int MESSAGE_MERGE_WINDOW = 20; public static final int PAGE_SIZE = 50; + public static final int MAX_NUM_PAGES = 3; public static final int PROGRESS_UI_UPDATE_INTERVAL = 750; diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index ac1343a8..e8482a96 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -129,6 +129,16 @@ public class Conversation extends AbstractEntity { } } + public void trim() { + synchronized (this.messages) { + final int size = messages.size(); + final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES; + if (size > maxsize) { + this.messages.subList(0, size - maxsize).clear(); + } + } + } + public void findUnsentMessagesWithOtrEncryption(OnMessageFound onMessageFound) { synchronized (this.messages) { for (Message message : this.messages) { @@ -265,10 +275,6 @@ public class Conversation extends AbstractEntity { } } - public String getProfilePhotoString() { - return this.getContact().getProfilePhoto(); - } - public String getAccountUuid() { return this.accountUuid; } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 418d9bbf..b46fd0a3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -554,6 +554,7 @@ public class ConversationFragment extends Fragment { } if (this.conversation != null) { this.conversation.setNextMessage(mEditMessage.getText().toString()); + this.conversation.trim(); } this.activity = (ConversationActivity) getActivity(); this.conversation = conversation; |