display toast when trying to join channel with no enabled accounts

This commit is contained in:
Christian Schneppe 2020-04-01 21:35:36 +02:00
parent fb56abb00f
commit f816abb047
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E
3 changed files with 8 additions and 3 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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>