aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-17 21:05:47 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-17 21:05:47 +0100
commitf00e168752e0b59de8eb667ce99bf6d10bd1361f (patch)
tree515ac38ac45e4306fc75058baa6b9aaea1395ddc /src/main/java/eu/siacs/conversations
parentde952cc9590b4e4f38698e5cdb42f378169f663b (diff)
clean up conversation history after swtiching to a different conversation
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java1
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java14
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java1
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 90e4a8991..6fe13d932 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 ac1343a8f..e8482a962 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 418d9bbfb..b46fd0a3e 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;