From ff18ea452df97d0ee87200bc7179dae39e511f19 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 31 Mar 2020 19:46:05 +0200 Subject: [PATCH] display toast when trying to join channel with no enabled accounts --- .../siacs/conversations/ui/ChannelDiscoveryActivity.java | 7 +++++-- .../eu/siacs/conversations/ui/EditAccountActivity.java | 3 ++- src/main/res/values/strings.xml | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java index 567a2f3d6..cb1baa39b 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java @@ -18,6 +18,7 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.TextView; +import android.widget.Toast; import java.util.Collections; import java.util.List; @@ -224,10 +225,12 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O @Override public void onChannelSearchResult(final Room result) { - List accounts = AccountUtils.getEnabledAccounts(xmppConnectionService); + final List accounts = AccountUtils.getEnabledAccounts(xmppConnectionService); if (accounts.size() == 1) { joinChannelSearchResult(accounts.get(0), result); - } else if (accounts.size() > 0) { + } else if (accounts.size() == 0) { + Toast.makeText(this, R.string.please_enable_your_account_first, Toast.LENGTH_LONG).show(); + } else { final AtomicReference account = new AtomicReference<>(accounts.get(0)); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.choose_account); diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index c2bdd05de..cc3b22be0 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -420,7 +420,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } - if (xmppConnectionService.getAccounts().size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { + final List accounts = xmppConnectionService == null ? null : xmppConnectionService.getAccounts(); + if (accounts != null && accounts.size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { Intent intent = SignupUtils.getSignUpIntent(this, mForceRegister != null && mForceRegister); StartConversationActivity.addInviteUri(intent, getIntent()); startActivity(intent); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a6c61e8d8..4601600dd 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -883,6 +883,7 @@ Channel discovery method Backup About + Please enable your account first View %1$d Participant View %1$d Participants