display toast when trying to join channel with no enabled accounts
This commit is contained in:
parent
fb56abb00f
commit
f816abb047
3 changed files with 8 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Reference in a new issue