Search in sources :

Example 6 with MucOptions

use of eu.siacs.conversations.entities.MucOptions in project Conversations by siacs.

the class ConferenceDetailsActivity method updateView.

private void updateView() {
    invalidateOptionsMenu();
    final MucOptions mucOptions = mConversation.getMucOptions();
    final User self = mucOptions.getSelf();
    String account;
    if (Config.DOMAIN_LOCK != null) {
        account = mConversation.getAccount().getJid().getLocalpart();
    } else {
        account = mConversation.getAccount().getJid().toBareJid().toString();
    }
    mAccountJid.setText(getString(R.string.using_account, account));
    mYourPhoto.setImageBitmap(avatarService().get(mConversation.getAccount(), getPixel(48)));
    setTitle(mConversation.getName());
    mFullJid.setText(mConversation.getJid().toBareJid().toString());
    mYourNick.setText(mucOptions.getActualNick());
    mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
    if (mucOptions.online()) {
        mMoreDetails.setVisibility(View.VISIBLE);
        final String status = getStatus(self);
        if (status != null) {
            mRoleAffiliaton.setVisibility(View.VISIBLE);
            mRoleAffiliaton.setText(status);
        } else {
            mRoleAffiliaton.setVisibility(View.GONE);
        }
        if (mucOptions.membersOnly()) {
            mConferenceType.setText(R.string.private_conference);
        } else {
            mConferenceType.setText(R.string.public_conference);
        }
        if (mucOptions.mamSupport()) {
            mConferenceInfoMam.setText(R.string.server_info_available);
        } else {
            mConferenceInfoMam.setText(R.string.server_info_unavailable);
        }
        if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
            mChangeConferenceSettingsButton.setVisibility(View.VISIBLE);
        } else {
            mChangeConferenceSettingsButton.setVisibility(View.GONE);
        }
    }
    int ic_notifications = getThemeResource(R.attr.icon_notifications, R.drawable.ic_notifications_black54_24dp);
    int ic_notifications_off = getThemeResource(R.attr.icon_notifications_off, R.drawable.ic_notifications_off_black54_24dp);
    int ic_notifications_paused = getThemeResource(R.attr.icon_notifications_paused, R.drawable.ic_notifications_paused_black54_24dp);
    int ic_notifications_none = getThemeResource(R.attr.icon_notifications_none, R.drawable.ic_notifications_none_black54_24dp);
    long mutedTill = mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0);
    if (mutedTill == Long.MAX_VALUE) {
        mNotifyStatusText.setText(R.string.notify_never);
        mNotifyStatusButton.setImageResource(ic_notifications_off);
    } else if (System.currentTimeMillis() < mutedTill) {
        mNotifyStatusText.setText(R.string.notify_paused);
        mNotifyStatusButton.setImageResource(ic_notifications_paused);
    } else if (mConversation.alwaysNotify()) {
        mNotifyStatusButton.setImageResource(ic_notifications);
        mNotifyStatusText.setText(R.string.notify_on_all_messages);
    } else {
        mNotifyStatusButton.setImageResource(ic_notifications_none);
        mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
    }
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    membersView.removeAllViews();
    final ArrayList<User> users = mucOptions.getUsers();
    Collections.sort(users);
    for (final User user : users) {
        View view = inflater.inflate(R.layout.contact, membersView, false);
        this.setListItemBackgroundOnView(view);
        view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                highlightInMuc(mConversation, user.getName());
            }
        });
        registerForContextMenu(view);
        view.setTag(user);
        TextView tvDisplayName = (TextView) view.findViewById(R.id.contact_display_name);
        TextView tvKey = (TextView) view.findViewById(R.id.key);
        TextView tvStatus = (TextView) view.findViewById(R.id.contact_jid);
        if (mAdvancedMode && user.getPgpKeyId() != 0) {
            tvKey.setVisibility(View.VISIBLE);
            tvKey.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    viewPgpKey(user);
                }
            });
            tvKey.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId()));
        }
        Contact contact = user.getContact();
        String name = user.getName();
        if (contact != null) {
            tvDisplayName.setText(contact.getDisplayName());
            tvStatus.setText((name != null ? name + " • " : "") + getStatus(user));
        } else {
            tvDisplayName.setText(name == null ? "" : name);
            tvStatus.setText(getStatus(user));
        }
        ImageView iv = (ImageView) view.findViewById(R.id.contact_photo);
        iv.setImageBitmap(avatarService().get(user, getPixel(48), false));
        if (user.getRole() == MucOptions.Role.NONE) {
            tvDisplayName.setAlpha(INACTIVE_ALPHA);
            tvKey.setAlpha(INACTIVE_ALPHA);
            tvStatus.setAlpha(INACTIVE_ALPHA);
            iv.setAlpha(INACTIVE_ALPHA);
        }
        membersView.addView(view);
        if (mConversation.getMucOptions().canInvite()) {
            mInviteButton.setVisibility(View.VISIBLE);
        } else {
            mInviteButton.setVisibility(View.GONE);
        }
    }
}
Also used : User(eu.siacs.conversations.entities.MucOptions.User) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Contact(eu.siacs.conversations.entities.Contact) MucOptions(eu.siacs.conversations.entities.MucOptions) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Aggregations

MucOptions (eu.siacs.conversations.entities.MucOptions)6 Jid (eu.siacs.conversations.xmpp.jid.Jid)3 Account (eu.siacs.conversations.entities.Account)2 Conversation (eu.siacs.conversations.entities.Conversation)2 Element (eu.siacs.conversations.xml.Element)2 PresencePacket (eu.siacs.conversations.xmpp.stanzas.PresencePacket)2 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Bookmark (eu.siacs.conversations.entities.Bookmark)1 Contact (eu.siacs.conversations.entities.Contact)1 OnRenameListener (eu.siacs.conversations.entities.MucOptions.OnRenameListener)1 User (eu.siacs.conversations.entities.MucOptions.User)1 Avatar (eu.siacs.conversations.xmpp.pep.Avatar)1 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)1