Search in sources :

Example 11 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class ChatActivity method handleOtrIntent.

private void handleOtrIntent(Intent intent) {
    String account = intent.getStringExtra(KEY_ACCOUNT);
    String user = intent.getStringExtra(KEY_USER);
    String question = intent.getStringExtra(KEY_QUESTION);
    if (account != null && user != null) {
        try {
            AccountJid accountJid = AccountJid.from(account);
            UserJid userJid = UserJid.from(user);
            AbstractChat chat = MessageManager.getInstance().getOrCreateChat(accountJid, userJid);
            if (chat != null && chat instanceof RegularChat) {
                if (intent.getBooleanExtra(EXTRA_OTR_PROGRESS, false)) {
                    ((RegularChat) chat).setIntent(QuestionActivity.createCancelIntent(Application.getInstance(), accountJid, userJid));
                } else {
                    ((RegularChat) chat).setIntent(QuestionActivity.createIntent(Application.getInstance(), accountJid, userJid, question != null, true, question));
                }
            }
        } catch (UserJid.UserJidCreateException | XmppStringprepException e) {
            e.printStackTrace();
        }
    }
    getIntent().removeExtra(EXTRA_OTR_REQUEST);
    getIntent().removeExtra(EXTRA_OTR_PROGRESS);
}
Also used : AbstractChat(com.xabber.android.data.message.AbstractChat) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException) RegularChat(com.xabber.android.data.message.RegularChat)

Example 12 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class ContactListActivity method showMucPrivateChatDialog.

private void showMucPrivateChatDialog() {
    Intent intent = getIntent();
    AccountJid account = getRoomInviteAccount(intent);
    UserJid user = getRoomInviteUser(intent);
    if (account != null && user != null) {
        MucPrivateChatInvitationDialog.newInstance(account, user).show(getFragmentManager(), MucPrivateChatInvitationDialog.class.getName());
    }
}
Also used : MucPrivateChatInvitationDialog(com.xabber.android.ui.dialog.MucPrivateChatInvitationDialog) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) Intent(android.content.Intent)

Example 13 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class ContactListActivity method showPassDialogs.

public void showPassDialogs() {
    List<XMPPAccountSettings> items = XabberAccountManager.getInstance().getXmppAccountsForCreate();
    if (items != null && items.size() > 0) {
        for (XMPPAccountSettings item : items) {
            if (XabberAccountManager.getInstance().isAccountSynchronize(item.getJid()) || SettingsManager.isSyncAllAccounts()) {
                if (!item.isDeleted() && XabberAccountManager.getInstance().getExistingAccount(item.getJid()) == null) {
                    if (item.getToken() != null && !item.getToken().isEmpty()) {
                        // create account if exist token
                        try {
                            AccountJid accountJid = AccountManager.getInstance().addAccount(item.getJid(), "", item.getToken(), false, true, true, false, false, true);
                            AccountManager.getInstance().setColor(accountJid, ColorManager.getInstance().convertColorNameToIndex(item.getColor()));
                            AccountManager.getInstance().setOrder(accountJid, item.getOrder());
                            AccountManager.getInstance().setTimestamp(accountJid, item.getTimestamp());
                            AccountManager.getInstance().onAccountChanged(accountJid);
                        } catch (NetworkException e) {
                            Application.getInstance().onError(e);
                        }
                    // require pass if token not exist
                    } else
                        EnterPassDialog.newInstance(item).show(getFragmentManager(), EnterPassDialog.class.getName());
                }
            }
        }
        XabberAccountManager.getInstance().clearXmppAccountsForCreate();
    }
}
Also used : XMPPAccountSettings(com.xabber.android.data.xaccount.XMPPAccountSettings) AccountJid(com.xabber.android.data.entity.AccountJid) NetworkException(com.xabber.android.data.NetworkException)

Example 14 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class ServerInfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_server_info);
    final Intent intent = getIntent();
    AccountJid account = getAccount(intent);
    if (account == null) {
        finish();
        return;
    }
    accountItem = AccountManager.getInstance().getAccount(account);
    if (accountItem == null) {
        Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
        finish();
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    toolbar.setTitle(accountItem.getConnection().getXMPPServiceDomain());
    BarPainter barPainter = new BarPainter(this, toolbar);
    barPainter.updateWithAccountName(account);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.server_info_recycler_view);
    serverInfoAdapter = new ServerInfoAdapter();
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(serverInfoAdapter);
    progressBar = findViewById(R.id.server_info_progress_bar);
    requestServerInfo();
}
Also used : ServerInfoAdapter(com.xabber.android.ui.adapter.ServerInfoAdapter) AccountJid(com.xabber.android.data.entity.AccountJid) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar) BarPainter(com.xabber.android.ui.color.BarPainter)

Example 15 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class AttentionManager method onSettingsChanged.

public void onSettingsChanged() {
    synchronized (enabledLock) {
        for (AccountJid account : AccountManager.getInstance().getEnabledAccounts()) {
            AccountItem accountItem = AccountManager.getInstance().getAccount(account);
            if (accountItem == null) {
                continue;
            }
            ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(accountItem.getConnection());
            if (manager == null) {
                continue;
            }
            boolean contains = false;
            for (String feature : manager.getFeatures()) {
                if (AttentionExtension.NAMESPACE.equals(feature)) {
                    contains = true;
                }
            }
            if (SettingsManager.chatsAttention() == contains) {
                continue;
            }
            if (SettingsManager.chatsAttention()) {
                manager.addFeature(AttentionExtension.NAMESPACE);
            } else {
                manager.removeFeature(AttentionExtension.NAMESPACE);
            }
        }
        AccountManager.getInstance().resendPresence();
    }
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid) ServiceDiscoveryManager(org.jivesoftware.smackx.disco.ServiceDiscoveryManager)

Aggregations

AccountJid (com.xabber.android.data.entity.AccountJid)74 UserJid (com.xabber.android.data.entity.UserJid)38 AccountItem (com.xabber.android.data.account.AccountItem)21 Jid (org.jxmpp.jid.Jid)13 Intent (android.content.Intent)11 ArrayList (java.util.ArrayList)11 View (android.view.View)10 NetworkException (com.xabber.android.data.NetworkException)9 AbstractChat (com.xabber.android.data.message.AbstractChat)7 Message (org.jivesoftware.smack.packet.Message)7 Presence (org.jivesoftware.smack.packet.Presence)7 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)6 TextView (android.widget.TextView)5 StatusMode (com.xabber.android.data.account.StatusMode)5 Resourcepart (org.jxmpp.jid.parts.Resourcepart)5 ImageView (android.widget.ImageView)4 AccountManager (com.xabber.android.data.account.AccountManager)4 RosterContact (com.xabber.android.data.roster.RosterContact)4 ContactVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO)4 BarPainter (com.xabber.android.ui.color.BarPainter)4