use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatMessageAdapter method setUpAvatar.
private void setUpAvatar(MessageItem messageItem, IncomingMessage message) {
if (SettingsManager.chatsShowAvatars()) {
final AccountJid account = messageItem.getAccount();
final UserJid user = messageItem.getUser();
final Resourcepart resource = messageItem.getResource();
message.avatar.setVisibility(View.VISIBLE);
message.avatarBackground.setVisibility(View.VISIBLE);
if ((isMUC && MUCManager.getInstance().getNickname(account, user.getJid().asEntityBareJidIfPossible()).equals(resource))) {
message.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
} else {
if (isMUC) {
if (resource.equals(Resourcepart.EMPTY)) {
message.avatar.setImageDrawable(AvatarManager.getInstance().getRoomAvatar(user));
} else {
try {
message.avatar.setImageDrawable(AvatarManager.getInstance().getUserAvatar(UserJid.from(JidCreate.domainFullFrom(user.getJid().asDomainBareJid(), resource))));
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
}
} else {
message.avatar.setImageDrawable(AvatarManager.getInstance().getUserAvatar(user));
}
}
} else {
message.avatar.setVisibility(View.GONE);
message.avatarBackground.setVisibility(View.GONE);
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class AccountChooseDialogFragment method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
AccountJid account = (AccountJid) adapter.getItem(which);
OnChooseListener listener = (OnChooseListener) getActivity();
listener.onChoose(account, user, text);
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class AccountSyncDialogFragment method onPositiveClick.
private void onPositiveClick(boolean needGoToMainActivity) {
// set accounts to sync map
if (!switchSyncAll.isChecked()) {
Map<String, Boolean> syncState = new HashMap<>();
for (XMPPAccountSettings account : xmppAccounts) {
if (account.getStatus() != XMPPAccountSettings.SyncStatus.local) {
syncState.put(account.getJid(), account.isSynchronization());
} else if (account.isSynchronization() || XabberAccountManager.getInstance().getAccountSyncState(account.getJid()) != null) {
syncState.put(account.getJid(), account.isSynchronization());
}
}
XabberAccountManager.getInstance().setAccountSyncState(syncState);
}
// update timestamp in accounts if timestamp was changed in dialog
for (XMPPAccountSettings account : xmppAccounts) {
AccountJid accountJid = XabberAccountManager.getInstance().getExistingAccount(account.getJid());
if (accountJid != null)
AccountManager.getInstance().setTimestamp(accountJid, account.getTimestamp());
}
// set sync all
SettingsManager.setSyncAllAccounts(switchSyncAll.isChecked());
// callback to sync-request
((XabberAccountInfoActivity) getActivity()).onSyncClick(needGoToMainActivity);
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class EnterPassDialog method createAccount.
private void createAccount(boolean enabled) {
try {
AccountJid accountJid = AccountManager.getInstance().addAccount(jid, edtPass.getText().toString(), token, false, true, true, false, false, enabled);
AccountManager.getInstance().setColor(accountJid, ColorManager.getInstance().convertColorNameToIndex(color));
AccountManager.getInstance().setOrder(accountJid, order);
AccountManager.getInstance().setTimestamp(accountJid, timestamp);
AccountManager.getInstance().onAccountChanged(accountJid);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class AccountActionButtonsAdapter method onChange.
@Override
public void onChange() {
Collections.sort(accounts);
for (int index = 0; index < accounts.size(); index++) {
View view = linearLayout.getChildAt(index);
final CircleImageView circleImageView = (CircleImageView) view.findViewById(R.id.account_avatar);
final AccountJid account = accounts.get(index);
circleImageView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
FloatingActionButton backgroundActionButton = (FloatingActionButton) view.findViewById(R.id.fab);
final AccountPainter accountPainter = ColorManager.getInstance().getAccountPainter();
backgroundActionButton.setColorNormal(accountPainter.getAccountMainColor(account));
backgroundActionButton.setColorPressed(accountPainter.getAccountDarkColor(account));
backgroundActionButton.setColorRipple(accountPainter.getAccountRippleColor(account));
AccountJid selectedAccount = AccountManager.getInstance().getSelectedAccount();
int shadowVisibility;
if (selectedAccount == null) {
shadowVisibility = View.GONE;
} else {
shadowVisibility = View.VISIBLE;
if (selectedAccount.equals(account)) {
shadowVisibility = View.GONE;
}
}
view.findViewById(R.id.account_unselected_shadow).setVisibility(shadowVisibility);
int offlineShadowVisibility;
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
StatusMode statusMode = null;
if (accountItem != null) {
statusMode = accountItem.getDisplayStatusMode();
}
if (statusMode != null && (statusMode == StatusMode.connection || statusMode == StatusMode.unavailable)) {
offlineShadowVisibility = View.VISIBLE;
} else {
offlineShadowVisibility = View.GONE;
}
view.findViewById(R.id.account_offline_shadow).setVisibility(offlineShadowVisibility);
}
}
Aggregations