aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2020-04-01 21:35:36 +0200
committerChristian Schneppe <christian.schneppe@pix-art.de>2020-04-01 21:35:36 +0200
commitf816abb0475b77815bce4cf850c6679715317f1f (patch)
treefc3ab065df861fe5db74d7c38624db64aa1a308f /src
parentfb56abb00f3c94e81ac009d07d2e570d32aa807e (diff)
display toast when trying to join channel with no enabled accounts
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java3
-rw-r--r--src/main/res/values/strings.xml1
3 files changed, 8 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);
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 7fa728f54..15a0ff7ac 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -1005,4 +1005,5 @@
<string name="show_avatar">Show avatar</string>
<string name="action_delete">Delete</string>
<string name="attach_choose_video">Choose video</string>
+ <string name="please_enable_an_account">Please enable an account</string>
</resources>