diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-04-01 21:35:36 +0200 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-04-01 21:35:36 +0200 |
commit | f816abb0475b77815bce4cf850c6679715317f1f (patch) | |
tree | fc3ab065df861fe5db74d7c38624db64aa1a308f /src/main/java | |
parent | fb56abb00f3c94e81ac009d07d2e570d32aa807e (diff) |
display toast when trying to join channel with no enabled accounts
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java | 7 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/EditAccountActivity.java | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java index 6c2a5c562..ba572e837 100644 --- a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java @@ -36,6 +36,7 @@ import de.pixart.messenger.ui.adapter.ChannelSearchResultAdapter; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.ui.util.SoftKeyboardUtils; import de.pixart.messenger.utils.AccountUtils; +import me.drakeet.support.toast.ToastCompat; import rocks.xmpp.addr.Jid; public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.OnActionExpandListener, TextView.OnEditorActionListener, ChannelDiscoveryService.OnChannelSearchResultsFound, ChannelSearchResultAdapter.OnChannelSearchResultSelected { @@ -219,10 +220,12 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O @Override public void onChannelSearchResult(final Room result) { - List<String> accounts = AccountUtils.getEnabledAccounts(xmppConnectionService); + final List<String> accounts = AccountUtils.getEnabledAccounts(xmppConnectionService); if (accounts.size() == 1) { joinChannelSearchResult(accounts.get(0), result); - } else if (accounts.size() > 0) { + } else if (accounts.size() == 0) { + ToastCompat.makeText(this, R.string.please_enable_an_account, ToastCompat.LENGTH_LONG).show(); + } else { final AtomicReference<String> account = new AtomicReference<>(accounts.get(0)); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.choose_account); diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 3afcf83bb..a6ab04be2 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -364,7 +364,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat return; } - if (xmppConnectionService.getAccounts().size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { + final List<Account> 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); |