aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java21
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java31
-rw-r--r--src/main/res/menu/fragment_conversation.xml6
4 files changed, 37 insertions, 23 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 27512a3d1..cb3356c82 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -942,7 +942,7 @@ public class ConversationActivity extends XmppActivity
if (getSelectedConversation() == null) {
reInitLatestConversation();
} else {
- ConversationActivity.this.mConversationFragment.updateMessages();
+ ConversationActivity.this.mConversationFragment.refresh();
updateActionBarTitle();
invalidateOptionsMenu();
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 710c8d4cc..37924a0ea 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1488,7 +1488,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
this.activity.onConversationArchived(conversation);
} else {
activity.onConversationsListItemUpdated();
- updateMessages();
+ refresh();
}
});
builder.create().show();
@@ -1633,7 +1633,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
activity.onConversationsListItemUpdated();
- updateMessages();
+ refresh();
}
}
@@ -1656,7 +1656,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
activity.onConversationsListItemUpdated();
- updateMessages();
+ refresh();
return;
}
}
@@ -1701,7 +1701,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private void retryDecryption(Message message) {
message.setEncryption(Message.ENCRYPTION_PGP);
activity.onConversationsListItemUpdated();
- updateMessages();
+ refresh();
conversation.getAccount().getPgpDecryptionService().decrypt(message, false);
}
@@ -1847,7 +1847,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
activity.onBackPressed();
}
});
- updateMessages();
+ refresh();
this.conversation.messagesLoaded.set(true);
synchronized (this.messageList) {
final Message first = conversation.getFirstUnreadMessage();
@@ -1990,11 +1990,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
- public void updateMessages() {
+ @Override
+ public void refresh() {
synchronized (this.messageList) {
- if (getView() == null) {
- return;
- }
if (this.conversation != null) {
conversation.populateWithMessages(ConversationFragment.this.messageList);
updateSnackBar(conversation);
@@ -2550,11 +2548,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
- @Override
- void refresh() {
-
- }
-
public void clearPending() {
if (postponedActivityResult.pop() != null) {
Log.d(Config.LOGTAG, "cleared pending intent with unhandled result left");
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java
index 9d2f491d8..57b2e8948 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java
@@ -51,14 +51,17 @@ import de.pixart.messenger.R;
import de.pixart.messenger.databinding.ActivityConversationsBinding;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.services.EmojiService;
+import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.ui.interfaces.OnConversationArchived;
import de.pixart.messenger.ui.interfaces.OnConversationRead;
import de.pixart.messenger.ui.interfaces.OnConversationSelected;
import de.pixart.messenger.ui.interfaces.OnConversationsListItemUpdated;
+import de.pixart.messenger.xmpp.OnUpdateBlocklist;
import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS;
-public class ConversationsMainActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead {
+public class ConversationsMainActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast {
+
//secondary fragment (when holding the conversation, must be initialized before refreshing the overview fragment
private static final @IdRes
@@ -182,7 +185,6 @@ public class ConversationsMainActivity extends XmppActivity implements OnConvers
transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
}
- //TODO, do this in backendConnected so we can actually decide what to display
if (binding.secondaryFragment != null) {
transaction.replace(R.id.secondary_fragment, new ConversationFragment());
}
@@ -262,4 +264,29 @@ public class ConversationsMainActivity extends XmppActivity implements OnConvers
public void onConversationRead(Conversation conversation) {
Log.d(Config.LOGTAG, "read event for " + conversation.getName() + " received");
}
+
+ @Override
+ public void onAccountUpdate() {
+ this.refreshUi();
+ }
+
+ @Override
+ public void onConversationUpdate() {
+ this.refreshUi();
+ }
+
+ @Override
+ public void onRosterUpdate() {
+ this.refreshUi();
+ }
+
+ @Override
+ public void OnUpdateBlocklist(OnUpdateBlocklist.Status status) {
+ this.refreshUi();
+ }
+
+ @Override
+ public void onShowErrorToast(int resId) {
+ runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show());
+ }
} \ No newline at end of file
diff --git a/src/main/res/menu/fragment_conversation.xml b/src/main/res/menu/fragment_conversation.xml
index 9687e45ff..a52b48888 100644
--- a/src/main/res/menu/fragment_conversation.xml
+++ b/src/main/res/menu/fragment_conversation.xml
@@ -2,12 +2,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/action_add"
- android:icon="?attr/icon_new"
- android:orderInCategory="10"
- app:showAsAction="always"
- android:title="@string/action_add" />
- <item
android:id="@+id/action_security"
android:icon="?attr/icon_not_secure"
android:orderInCategory="20"