aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-01-29 20:06:28 +0100
committerChristian Schneppe <christian@pix-art.de>2017-01-29 20:06:28 +0100
commit475e29b622ef5c87e3a3b3a36020bf99958467cd (patch)
tree75a7df26cb66eaf5fd16ef4aab3eb50080975291 /src/main/java/de/pixart/messenger/ui
parent91e6a152c066d1bcff15a9585d6830feb1a53288 (diff)
configurable local message retention period.
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java11
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java11
4 files changed, 13 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index bc9c7ea1b..0dfd7bc14 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -2137,11 +2137,4 @@ public class ConversationActivity extends XmppActivity
startActivity(intent);
}
}
-
- public void setMessagesLoaded() {
- if (mConversationFragment != null) {
- mConversationFragment.setMessagesLoaded();
- mConversationFragment.updateMessages();
- }
- }
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index c515aeb29..5b17e7179 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -118,7 +118,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
private RelativeLayout snackbar;
private TextView snackbarMessage;
private TextView snackbarAction;
- private boolean messagesLoaded = true;
private Toast messageLoaderToast;
private OnScrollListener mOnScrollListener = new OnScrollListener() {
@@ -133,14 +132,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
synchronized (ConversationFragment.this.messageList) {
- if (firstVisibleItem < 5 && messagesLoaded && messageList.size() > 0) {
+ if (firstVisibleItem < 5 && conversation != null && conversation.messagesLoaded.compareAndSet(true,false) && messageList.size() > 0) {
long timestamp;
if (messageList.get(0).getType() == Message.TYPE_STATUS && messageList.size() >= 2) {
timestamp = messageList.get(1).getTimeSent();
} else {
timestamp = messageList.get(0).getTimeSent();
}
- messagesLoaded = false;
activity.xmppConnectionService.loadMoreMessages(conversation, timestamp, new XmppConnectionService.OnMoreMessagesLoaded() {
@Override
public void onMoreMessagesLoaded(final int c, Conversation conversation) {
@@ -169,7 +167,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
messageListAdapter.notifyDataSetChanged();
int pos = Math.max(getIndexOf(uuid, messageList), 0);
messagesView.setSelectionFromTop(pos, pxOffset);
- messagesLoaded = true;
if (messageLoaderToast != null) {
messageLoaderToast.cancel();
}
@@ -387,10 +384,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
private ConversationActivity activity;
private Message selectedMessage;
- public void setMessagesLoaded() {
- this.messagesLoaded = true;
- }
-
private void sendMessage() {
final String body = mEditMessage.getText().toString();
if (body.length() == 0 || this.conversation == null) {
@@ -937,7 +930,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
messageListAdapter.updatePreferences();
this.messagesView.setAdapter(messageListAdapter);
updateMessages();
- this.messagesLoaded = true;
+ this.conversation.messagesLoaded.set(true);
synchronized (this.messageList) {
final Message first = conversation.getFirstUnreadMessage();
final int bottom = Math.max(0, this.messageList.size() - 1);
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
index 7c3131a0f..6624266f7 100644
--- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
@@ -40,6 +40,7 @@ public class SettingsActivity extends XmppActivity implements
public static final String TREAT_VIBRATE_AS_SILENT = "treat_vibrate_as_silent";
public static final String MANUALLY_CHANGE_PRESENCE = "manually_change_presence";
public static final String BLIND_TRUST_BEFORE_VERIFICATION = "btbv";
+ public static final String AUTOMATIC_MESSAGE_DELETION = "automatic_message_deletion";
public static final int REQUEST_WRITE_LOGS = 0xbf8701;
private SettingsFragment mSettingsFragment;
@@ -263,6 +264,8 @@ public class SettingsActivity extends XmppActivity implements
reconnectAccounts();
} else if (name.equals("use_tor")) {
reconnectAccounts();
+ } else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) {
+ xmppConnectionService.expireOldMessages(true);
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index 2f99b6b99..385fa184b 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -62,6 +62,7 @@ import de.pixart.messenger.entities.Message;
import de.pixart.messenger.entities.Message.FileParams;
import de.pixart.messenger.entities.Transferable;
import de.pixart.messenger.persistance.FileBackend;
+import de.pixart.messenger.services.MessageArchiveService;
import de.pixart.messenger.services.NotificationService;
import de.pixart.messenger.ui.ConversationActivity;
import de.pixart.messenger.ui.ShowFullscreenMessageActivity;
@@ -679,9 +680,13 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (timestamp == 0) {
timestamp = System.currentTimeMillis();
}
- activity.setMessagesLoaded();
- activity.xmppConnectionService.getMessageArchiveService().query(conversation, 0, timestamp);
- Toast.makeText(activity, R.string.fetching_history_from_server, Toast.LENGTH_LONG).show();
+ conversation.messagesLoaded.set(true);
+ MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(conversation, 0, timestamp);
+ if (query != null) {
+ Toast.makeText(activity, R.string.fetching_history_from_server, Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(activity, R.string.not_fetching_history_retention_period, Toast.LENGTH_SHORT).show();
+ }
}
@Override