Search in sources :

Example 1 with XMPPAccountSettings

use of com.xabber.android.data.xaccount.XMPPAccountSettings in project xabber-android by redsolution.

the class AccountSyncActivity method handleSuccessDelete.

private void handleSuccessDelete(List<XMPPAccountSettings> settings, boolean deleteAccount) {
    if (!deleteAccount) {
        for (XMPPAccountSettings set : settings) {
            if (set.getJid().equals(jid))
                AccountManager.getInstance().setTimestamp(accountItem.getAccount(), set.getTimestamp() + 1);
        }
    }
    hideProgress();
    Toast.makeText(this, R.string.settings_delete_success, Toast.LENGTH_SHORT).show();
    getSyncStatus();
    updateSyncSwitchButton();
}
Also used : XMPPAccountSettings(com.xabber.android.data.xaccount.XMPPAccountSettings)

Example 2 with XMPPAccountSettings

use of com.xabber.android.data.xaccount.XMPPAccountSettings in project xabber-android by redsolution.

the class AccountSyncActivity method handleSuccessGetSettings.

private void handleSuccessGetSettings(List<XMPPAccountSettings> list) {
    XMPPAccountSettings.SyncStatus status = XMPPAccountSettings.SyncStatus.local;
    for (XMPPAccountSettings item : list) {
        if (jid.equals(item.getJid())) {
            if (item.isDeleted()) {
                status = XMPPAccountSettings.SyncStatus.deleted;
                break;
            }
            if (item.getTimestamp() == accountItem.getTimestamp())
                status = XMPPAccountSettings.SyncStatus.localEqualsRemote;
            else if (item.getTimestamp() > accountItem.getTimestamp())
                status = XMPPAccountSettings.SyncStatus.remoteNewer;
            else {
                status = XMPPAccountSettings.SyncStatus.localNewer;
            }
            break;
        }
    }
    setSyncStatus(status);
}
Also used : XMPPAccountSettings(com.xabber.android.data.xaccount.XMPPAccountSettings)

Example 3 with XMPPAccountSettings

use of com.xabber.android.data.xaccount.XMPPAccountSettings 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 4 with XMPPAccountSettings

use of com.xabber.android.data.xaccount.XMPPAccountSettings in project xabber-android by redsolution.

the class PreferenceEditor method onDeleteAccountSettings.

public void onDeleteAccountSettings(String jid) {
    showProgress(getResources().getString(R.string.progress_title_delete_settings));
    if (XabberAccountManager.getInstance().getAccountSyncState(jid) != null) {
        Subscription deleteSubscription = AuthManager.deleteClientSettings(jid).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<XMPPAccountSettings>>() {

            @Override
            public void call(List<XMPPAccountSettings> settings) {
                handleSuccessDelete(settings);
            }
        }, new Action1<Throwable>() {

            @Override
            public void call(Throwable throwable) {
                handleErrorDelete(throwable);
            }
        });
        compositeSubscription.add(deleteSubscription);
    }
}
Also used : XMPPAccountSettings(com.xabber.android.data.xaccount.XMPPAccountSettings) List(java.util.List) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 5 with XMPPAccountSettings

use of com.xabber.android.data.xaccount.XMPPAccountSettings in project xabber-android by redsolution.

the class XabberAccountInfoActivity method getSettings.

private void getSettings() {
    Subscription getSettingsSubscription = AuthManager.getClientSettings().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<XMPPAccountSettings>>() {

        @Override
        public void call(List<XMPPAccountSettings> settings) {
            Log.d(LOG_TAG, "XMPP accounts loading from net: successfully");
            XabberAccountManager.getInstance().setXmppAccountsForCreate(settings);
            hideProgress();
            // update last synchronization time
            SettingsManager.setLastSyncDate(XabberAccountManager.getCurrentTimeString());
            Toast.makeText(XabberAccountInfoActivity.this, R.string.sync_success, Toast.LENGTH_SHORT).show();
            goToMainActivity();
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
            Log.d(LOG_TAG, "XMPP accounts loading from net: error: " + throwable.toString());
            hideProgress();
        }
    });
    compositeSubscription.add(getSettingsSubscription);
}
Also used : XMPPAccountSettings(com.xabber.android.data.xaccount.XMPPAccountSettings) List(java.util.List) Subscription(rx.Subscription)

Aggregations

XMPPAccountSettings (com.xabber.android.data.xaccount.XMPPAccountSettings)14 List (java.util.List)8 Subscription (rx.Subscription)8 CompositeSubscription (rx.subscriptions.CompositeSubscription)5 AccountJid (com.xabber.android.data.entity.AccountJid)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NetworkException (com.xabber.android.data.NetworkException)1 AccountItem (com.xabber.android.data.account.AccountItem)1 XabberAccountInfoActivity (com.xabber.android.ui.activity.XabberAccountInfoActivity)1 HashMap (java.util.HashMap)1