Search in sources :

Example 26 with AccountJid

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;
}
Also used : HashMap(java.util.HashMap) AbstractChat(com.xabber.android.data.message.AbstractChat) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid)

Example 27 with AccountJid

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;
}
Also used : AbstractChat(com.xabber.android.data.message.AbstractChat) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) NotificationState(com.xabber.android.data.message.NotificationState)

Example 28 with AccountJid

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();
            }
        }
    }
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid)

Example 29 with AccountJid

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;
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid)

Example 30 with AccountJid

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;
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) AccountManager(com.xabber.android.data.account.AccountManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

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