From d1490673bb64efc45aea932280152602a11a38cc Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 11 Dec 2020 11:29:23 +0100 Subject: [PATCH] work around race condition after opening easy invite dialog --- .../siacs/conversations/services/MessageArchiveService.java | 3 +++ .../conversations/ui/ConversationsOverviewFragment.java | 6 +++++- src/main/res/values/strings.xml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 89ddec12b..47d4a240b 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -2,6 +2,8 @@ package eu.siacs.conversations.services; import android.util.Log; +import org.jetbrains.annotations.NotNull; + import java.math.BigInteger; import java.util.ArrayList; import java.util.HashSet; @@ -615,6 +617,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } } + @NotNull @Override public String toString() { StringBuilder builder = new StringBuilder(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java index ae81874e1..3c3c53f63 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java @@ -48,6 +48,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import com.google.common.collect.Collections2; @@ -371,7 +372,10 @@ public class ConversationsOverviewFragment extends XmppFragment { private void selectAccountToStartEasyInvite() { final List accounts = EasyOnboardingInvite.getSupportingAccounts(activity.xmppConnectionService); - if (accounts.size() == 1) { + if (accounts.size() == 0) { + //This can technically happen if opening the menu item races with accounts reconnecting or something + Toast.makeText(getActivity(),R.string.no_active_accounts_support_this, Toast.LENGTH_LONG).show(); + } else if (accounts.size() == 1) { openEasyInviteScreen(accounts.get(0)); } else { final AtomicReference selectedAccount = new AtomicReference<>(accounts.get(0)); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a9670533f..5aba03dfd 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -953,4 +953,5 @@ Invite to Conversations Unable to parse invite Server does not support generating invites + No active accounts support this feature