use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatContactSettingsFragment method getValues.
@Override
protected Map<String, Object> getValues() {
Map<String, Object> map = new HashMap<>();
AccountJid account = mListener.getAccount();
UserJid user = mListener.getUser();
boolean isMUC = false;
if (MUCManager.getInstance().hasRoom(account, user.getJid().asEntityBareJidIfPossible())) {
isMUC = true;
}
// custom notification
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat != null) {
putValue(map, R.string.chat_notification_settings_key, chat.notifyAboutMessage());
}
putValue(map, R.string.chat_save_history_key, ChatManager.getInstance().isSaveMessages(account, user));
putValue(map, R.string.chat_events_visible_chat_key, ChatManager.getInstance().isNotifyVisible(account, user));
putValue(map, R.string.chat_events_show_text_key, ChatManager.getInstance().getShowText(account, user).ordinal());
putValue(map, R.string.chat_events_vibro_key, ChatManager.getInstance().isMakeVibro(account, user));
putValue(map, R.string.chat_events_sound_key, ChatManager.getInstance().getSound(account, user, isMUC));
putValue(map, R.string.chat_events_suppress_100_key, ChatManager.getInstance().isSuppress100(account, user));
return map;
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatContactSettingsFragment method setValues.
@Override
protected boolean setValues(Map<String, Object> source, Map<String, Object> result) {
AccountJid account = mListener.getAccount();
UserJid user = mListener.getUser();
// custom notification
if (hasChanges(source, result, R.string.chat_notification_settings_key)) {
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat != null) {
boolean newValue = getBoolean(result, R.string.chat_notification_settings_key);
if (chat.getNotificationState().getMode().equals(NotificationState.NotificationMode.bydefault)) {
NotificationState.NotificationMode mode = newValue ? NotificationState.NotificationMode.enabled : NotificationState.NotificationMode.disabled;
chat.setNotificationState(new NotificationState(mode, 0), true);
} else {
boolean defValue;
if (MUCManager.getInstance().hasRoom(account, user.getJid().asEntityBareJidIfPossible()))
defValue = SettingsManager.eventsOnMuc();
else
defValue = SettingsManager.eventsOnChat();
if (!defValue && chat.getNotificationState().getMode().equals(NotificationState.NotificationMode.disabled)) {
chat.setNotificationState(new NotificationState(NotificationState.NotificationMode.enabled, 0), true);
} else if (defValue && chat.getNotificationState().getMode().equals(NotificationState.NotificationMode.enabled)) {
chat.setNotificationState(new NotificationState(NotificationState.NotificationMode.disabled, 0), true);
} else
chat.setNotificationState(new NotificationState(NotificationState.NotificationMode.bydefault, 0), true);
}
}
}
if (hasChanges(source, result, R.string.chat_save_history_key))
ChatManager.getInstance().setSaveMessages(account, user, getBoolean(result, R.string.chat_save_history_key));
if (hasChanges(source, result, R.string.chat_events_visible_chat_key))
ChatManager.getInstance().setNotifyVisible(account, user, getBoolean(result, R.string.chat_events_visible_chat_key));
if (hasChanges(source, result, R.string.chat_events_show_text_key)) {
ChatManager.getInstance().setShowText(account, user, ShowMessageTextInNotification.fromInteger(getInt(result, R.string.chat_events_show_text_key)));
}
if (hasChanges(source, result, R.string.chat_events_vibro_key))
ChatManager.getInstance().setMakeVibro(account, user, getBoolean(result, R.string.chat_events_vibro_key));
if (hasChanges(source, result, R.string.chat_events_sound_key))
ChatManager.getInstance().setSound(account, user, getUri(result, R.string.chat_events_sound_key));
if (hasChanges(source, result, R.string.chat_events_suppress_100_key))
ChatManager.getInstance().setSuppress100(account, user, getBoolean(result, R.string.chat_events_suppress_100_key));
return true;
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class SecuritySettingsFragment method onSharedPreferenceChanged.
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(getString(R.string.security_check_certificate_key))) {
boolean checkCertificate = sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.security_check_certificate_default));
LogManager.i(LOG_TAG, "Check certificate preference changed. new value " + checkCertificate);
// reconnect all enabled account to apply and check changes
Collection<AccountJid> enabledAccounts = AccountManager.getInstance().getAllAccounts();
for (AccountJid accountJid : enabledAccounts) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem != null) {
accountItem.recreateConnection();
}
}
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class BottomMenu method onClick.
@Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.btnRecent:
listener.onRecentClick();
break;
case R.id.btnSearch:
listener.onSearchClick();
openSearch();
break;
case R.id.btnMenu:
listener.onMenuClick();
break;
case R.id.searchLayout:
listener.onSearchClick();
openSearch();
break;
case R.id.avatarView:
int position = accountList.getChildLayoutPosition(view);
AccountJid accountJid = items.get(position).getAccountJid();
listener.onAccountShortcutClick(accountJid);
break;
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class AccountChooseAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View view;
final AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) {
view = activity.getLayoutInflater().inflate(R.layout.item_account_choose, parent, false);
} else {
view = convertView;
}
final AccountJid account = (AccountJid) getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
return view;
}
Aggregations