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();
}
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);
}
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();
}
}
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);
}
}
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);
}
Aggregations