Search in sources :

Example 1 with LetterAvatar

use of org.awesomeapp.messenger.ui.widgets.LetterAvatar in project Zom-Android by zom.

the class GroupDisplayActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setTitle("");
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.awesome_activity_group);
    mName = getIntent().getStringExtra("nickname");
    mAddress = getIntent().getStringExtra("address");
    mProviderId = getIntent().getLongExtra("provider", -1);
    mAccountId = getIntent().getLongExtra("account", -1);
    mLastChatId = getIntent().getLongExtra("chat", -1);
    Cursor cursor = getContentResolver().query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(mProviderId) }, null);
    if (cursor == null)
        // not going to work
        return;
    Imps.ProviderSettings.QueryMap providerSettings = new Imps.ProviderSettings.QueryMap(cursor, getContentResolver(), mProviderId, false, null);
    mMembers = new ArrayList<>();
    mConn = ((ImApp) getApplication()).getConnection(mProviderId, mAccountId);
    mLocalAddress = Imps.Account.getUserName(getContentResolver(), mAccountId) + '@' + providerSettings.getDomain();
    providerSettings.close();
    try {
        mSession = mConn.getChatSessionManager().getChatSession(mAddress);
        if (mSession != null) {
            mGroupOwner = mSession.getGroupChatOwner();
            if (mGroupOwner != null)
                mIsOwner = mGroupOwner.getAddress().getBareAddress().equals(mLocalAddress);
        }
    } catch (RemoteException e) {
    }
    mRecyclerView = (RecyclerView) findViewById(R.id.rvRoot);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    mRecyclerView.setAdapter(new RecyclerView.Adapter() {

        private static final int VIEW_TYPE_MEMBER = 0;

        private static final int VIEW_TYPE_HEADER = 1;

        private static final int VIEW_TYPE_FOOTER = 2;

        private int colorTextPrimary = 0xff000000;

        public RecyclerView.Adapter init() {
            TypedValue out = new TypedValue();
            getTheme().resolveAttribute(R.attr.contactTextPrimary, out, true);
            colorTextPrimary = out.data;
            return this;
        }

        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            switch(viewType) {
                case VIEW_TYPE_HEADER:
                    return new HeaderViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.awesome_activity_group_header, parent, false));
                case VIEW_TYPE_FOOTER:
                    return new FooterViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.awesome_activity_group_footer, parent, false));
            }
            return new MemberViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.group_member_view, parent, false));
        }

        @Override
        public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
            if (holder instanceof HeaderViewHolder) {
                final HeaderViewHolder h = (HeaderViewHolder) holder;
                GroupAvatar avatar = new GroupAvatar(mAddress.split("@")[0]);
                avatar.setRounded(false);
                h.avatar.setImageDrawable(avatar);
                h.qr.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        String inviteString;
                        try {
                            inviteString = OnboardingManager.generateInviteLink(GroupDisplayActivity.this, mAddress, "", mName);
                            OnboardingManager.inviteScan(GroupDisplayActivity.this, inviteString);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                });
                h.groupName.setText(mName);
                h.groupAddress.setText(mAddress);
                h.actionShare.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        try {
                            String inviteLink = OnboardingManager.generateInviteLink(GroupDisplayActivity.this, mAddress, "", mName);
                            new QrShareAsyncTask(GroupDisplayActivity.this).execute(inviteLink, mName);
                        } catch (Exception e) {
                            Log.e(ImApp.LOG_TAG, "couldn't generate QR code", e);
                        }
                    }
                });
                mActionAddFriends = h.actionAddFriends;
                showAddFriends();
                /**
                 *                    h.actionNotifications.setOnClickListener(new View.OnClickListener() {
                 *                        @Override
                 *                        public void onClick(View v) {
                 *                            setNotificationsEnabled(areNotificationsEnabled());
                 *                            h.checkNotifications.setChecked(areNotificationsEnabled());
                 *                        }
                 *                    });
                 */
                h.checkNotifications.setChecked(areNotificationsEnabled());
                h.checkNotifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        setNotificationsEnabled(isChecked);
                    }
                });
                if (Preferences.doGroupEncryption()) {
                    h.checkGroupEncryption.setChecked(isGroupEncryptionEnabled());
                    h.checkGroupEncryption.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                            setGroupEncryptionEnabled(isChecked);
                        }
                    });
                } else {
                    h.actionGroupEncryption.setVisibility(View.GONE);
                }
                if (!mIsOwner)
                    h.editGroupName.setVisibility(View.GONE);
                else {
                    h.editGroupName.setOnClickListener(new View.OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            editGroupSubject();
                        }
                    });
                }
            } else if (holder instanceof FooterViewHolder) {
                FooterViewHolder h = (FooterViewHolder) holder;
                // Tint the "leave" text and drawable(s)
                int colorAccent = ResourcesCompat.getColor(getResources(), R.color.holo_orange_light, getTheme());
                for (Drawable d : h.actionLeave.getCompoundDrawables()) {
                    if (d != null) {
                        DrawableCompat.setTint(d, colorAccent);
                    }
                }
                h.actionLeave.setTextColor(colorAccent);
                h.actionLeave.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        confirmLeaveGroup();
                    }
                });
            } else if (holder instanceof MemberViewHolder) {
                MemberViewHolder h = (MemberViewHolder) holder;
                // Reset the padding to match other views in this hierarchy
                // 
                int padding = getResources().getDimensionPixelOffset(R.dimen.detail_view_padding);
                h.itemView.setPadding(padding, h.itemView.getPaddingTop(), padding, h.itemView.getPaddingBottom());
                int idxMember = position - 1;
                final GroupMemberDisplay member = mMembers.get(idxMember);
                String nickname = member.nickname;
                if (TextUtils.isEmpty(nickname)) {
                    nickname = member.username.split("@")[0].split("\\.")[0];
                } else {
                    nickname = nickname.split("@")[0].split("\\.")[0];
                }
                h.line1.setText(nickname);
                boolean hasRoleNone = TextUtils.isEmpty(member.role) || "none".equalsIgnoreCase(member.role);
                h.line1.setTextColor(hasRoleNone ? Color.GRAY : colorTextPrimary);
                h.line2.setText(member.username);
                if (member.affiliation != null && (member.affiliation.contentEquals("owner") || member.affiliation.contentEquals("admin"))) {
                    h.avatarCrown.setVisibility(View.VISIBLE);
                } else {
                    h.avatarCrown.setVisibility(View.GONE);
                }
                // h.line2.setText(member.username);
                if (member.avatar == null) {
                    padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, getResources().getDisplayMetrics());
                    member.avatar = new LetterAvatar(holder.itemView.getContext(), nickname, padding);
                }
                h.avatar.setImageDrawable(member.avatar);
                h.avatar.setVisibility(View.VISIBLE);
                h.itemView.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        showMemberInfo(member);
                    }
                });
            }
        }

        @Override
        public int getItemCount() {
            return 2 + mMembers.size();
        }

        @Override
        public int getItemViewType(int position) {
            if (position == 0)
                return VIEW_TYPE_HEADER;
            else if (position == getItemCount() - 1)
                return VIEW_TYPE_FOOTER;
            return VIEW_TYPE_MEMBER;
        }
    }.init());
}
Also used : ChatListenerAdapter(org.awesomeapp.messenger.ui.legacy.adapter.ChatListenerAdapter) LetterAvatar(org.awesomeapp.messenger.ui.widgets.LetterAvatar) Cursor(android.database.Cursor) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) GroupAvatar(org.awesomeapp.messenger.ui.widgets.GroupAvatar) TypedValue(android.util.TypedValue) Imps(org.awesomeapp.messenger.provider.Imps) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) QrShareAsyncTask(org.awesomeapp.messenger.ui.qr.QrShareAsyncTask) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) DecoderException(org.apache.commons.codec.DecoderException) RemoteException(android.os.RemoteException) RecyclerView(android.support.v7.widget.RecyclerView) RemoteException(android.os.RemoteException) CompoundButton(android.widget.CompoundButton)

Example 2 with LetterAvatar

use of org.awesomeapp.messenger.ui.widgets.LetterAvatar in project Zom-Android by zom.

the class ContactListItem method bind.

public void bind(ContactViewHolder holder, Cursor cursor, String underLineText, boolean showChatMsg, boolean scrolling) {
    address = cursor.getString(COLUMN_CONTACT_USERNAME);
    nickname = cursor.getString(COLUMN_CONTACT_NICKNAME);
    final int type = cursor.getInt(COLUMN_CONTACT_TYPE);
    // final String lastMsg = cursor.getString(COLUMN_LAST_MESSAGE);
    // long lastMsgDate = cursor.getLong(COLUMN_LAST_MESSAGE_DATE);
    final int presence = cursor.getInt(COLUMN_CONTACT_PRESENCE_STATUS);
    final int subType = cursor.getInt(COLUMN_SUBSCRIPTION_TYPE);
    final int subStatus = cursor.getInt(COLUMN_SUBSCRIPTION_STATUS);
    String statusText = cursor.getString(COLUMN_CONTACT_CUSTOM_STATUS);
    if (TextUtils.isEmpty(nickname)) {
        nickname = address.split("@")[0].split("\\.")[0];
    } else {
        nickname = nickname.split("@")[0].split("\\.")[0];
    }
    if (!TextUtils.isEmpty(underLineText)) {
        // highlight/underline the word being searched
        String lowercase = nickname.toLowerCase();
        int start = lowercase.indexOf(underLineText.toLowerCase());
        if (start >= 0) {
            int end = start + underLineText.length();
            SpannableString str = new SpannableString(nickname);
            str.setSpan(new UnderlineSpan(), start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
            holder.mLine1.setText(str);
        } else
            holder.mLine1.setText(nickname);
    } else
        holder.mLine1.setText(nickname);
    if (holder.mAvatar != null) {
        if (Imps.Contacts.TYPE_GROUP == type) {
            holder.mAvatar.setVisibility(View.VISIBLE);
            if (AVATAR_DEFAULT_GROUP == null)
                AVATAR_DEFAULT_GROUP = new RoundedAvatarDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.group_chat));
            holder.mAvatar.setImageDrawable(AVATAR_DEFAULT_GROUP);
        } else {
            Drawable avatar = null;
            try {
                avatar = DatabaseUtils.getAvatarFromAddress(this.getContext().getContentResolver(), address, ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
            } catch (Exception e) {
                // problem decoding avatar
                Log.e(ImApp.LOG_TAG, "error decoding avatar", e);
            }
            try {
                if (avatar != null) {
                    if (avatar instanceof RoundedAvatarDrawable)
                        setAvatarBorder(presence, (RoundedAvatarDrawable) avatar);
                    holder.mAvatar.setImageDrawable(avatar);
                } else {
                    // int color = getAvatarBorder(presence);
                    int padding = 24;
                    LetterAvatar lavatar = new LetterAvatar(getContext(), nickname, padding);
                    holder.mAvatar.setImageDrawable(lavatar);
                }
                holder.mAvatar.setVisibility(View.VISIBLE);
            } catch (OutOfMemoryError ome) {
            // this seems to happen now and then even on tiny images; let's catch it and just not set an avatar
            }
        }
    }
    statusText = address;
    if (type == Imps.Contacts.TYPE_HIDDEN) {
        statusText += " | " + getContext().getString(R.string.action_archive);
    }
    if (holder.mLine2 != null)
        holder.mLine2.setText(statusText);
    if (Imps.Contacts.TYPE_NORMAL == type) {
        if (subStatus == Imps.ContactsColumns.SUBSCRIPTION_STATUS_SUBSCRIBE_PENDING) {
            if (subType == Imps.ContactsColumns.SUBSCRIPTION_TYPE_FROM) {
                if (holder.mSubBox != null) {
                    holder.mSubBox.setVisibility(View.VISIBLE);
                    holder.mButtonSubApprove.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            approveSubscription();
                            mHolder.itemView.performClick();
                        }
                    });
                    holder.mButtonSubDecline.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            declineSubscription();
                        }
                    });
                }
            } else {
                if (holder.mSubBox != null)
                    holder.mSubBox.setVisibility(View.GONE);
                if (holder.mLine2 != null)
                    holder.mLine2.setText(getContext().getString(R.string.title_pending));
            }
        } else {
            if (holder.mSubBox != null)
                holder.mSubBox.setVisibility(View.GONE);
        }
    }
    if (mShowPresence) {
        switch(presence) {
            case Presence.AVAILABLE:
                if (holder.mLine2 != null)
                    holder.mLine2.setText(getContext().getString(R.string.presence_available));
            case Presence.IDLE:
                if (holder.mLine2 != null)
                    holder.mLine2.setText(getContext().getString(R.string.presence_available));
            /**
             *                     case Presence.AWAY:
             *                     return (getResources().getColor(R.color.holo_orange_light));
             *
             *                     case Presence.DO_NOT_DISTURB:
             *                     return(getResources().getColor(R.color.holo_red_dark));
             *
             *                     case Presence.OFFLINE:
             *                     return(getResources().getColor(R.color.holo_grey_dark));
             */
            default:
        }
    }
    holder.mLine1.setVisibility(View.VISIBLE);
}
Also used : SpannableString(android.text.SpannableString) RoundedAvatarDrawable(org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable) Drawable(android.graphics.drawable.Drawable) LetterAvatar(org.awesomeapp.messenger.ui.widgets.LetterAvatar) SpannableString(android.text.SpannableString) RoundedAvatarDrawable(org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable) View(android.view.View) UnderlineSpan(android.text.style.UnderlineSpan) RemoteException(android.os.RemoteException)

Example 3 with LetterAvatar

use of org.awesomeapp.messenger.ui.widgets.LetterAvatar in project Zom-Android by zom.

the class ConversationListItem method bind.

public void bind(ConversationViewHolder holder, long contactId, long providerId, long accountId, String address, String nickname, int contactType, String message, long messageDate, String messageType, int presence, int subscription, String underLineText, boolean showChatMsg, boolean scrolling, boolean isMuted) {
    if (nickname == null) {
        nickname = address.split("@")[0].split("\\.")[0];
    } else {
        nickname = nickname.split("@")[0].split("\\.")[0];
    }
    if (isMuted) {
        nickname += " \uD83D\uDD15";
    }
    if (!TextUtils.isEmpty(underLineText)) {
        // highlight/underline the word being searched
        String lowercase = nickname.toLowerCase();
        int start = lowercase.indexOf(underLineText.toLowerCase());
        if (start >= 0) {
            int end = start + underLineText.length();
            SpannableString str = new SpannableString(nickname);
            str.setSpan(new UnderlineSpan(), start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
            holder.mLine1.setText(str);
        } else
            holder.mLine1.setText(nickname);
    } else
        holder.mLine1.setText(nickname);
    holder.mStatusIcon.setVisibility(View.GONE);
    if (holder.mAvatar != null) {
        if (Imps.Contacts.TYPE_GROUP == contactType) {
            holder.mAvatar.setVisibility(View.VISIBLE);
            try {
                String groupId = address.split("@")[0];
                Drawable avatar = new GroupAvatar(groupId);
                holder.mAvatar.setImageDrawable(avatar);
            } catch (Exception ignored) {
                if (AVATAR_DEFAULT_GROUP == null)
                    AVATAR_DEFAULT_GROUP = new RoundedAvatarDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.group_chat));
                holder.mAvatar.setImageDrawable(AVATAR_DEFAULT_GROUP);
            }
        } else // else if (cursor.getColumnIndex(Imps.Contacts.AVATAR_DATA)!=-1)
        {
            // holder.mAvatar.setVisibility(View.GONE);
            Drawable avatar = null;
            try {
                avatar = DatabaseUtils.getAvatarFromAddress(this.getContext().getContentResolver(), address, ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
            // avatar = DatabaseUtils.getAvatarFromCursor(cursor, COLUMN_AVATAR_DATA, ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
            } catch (Exception e) {
                // problem decoding avatar
                Log.e(ImApp.LOG_TAG, "error decoding avatar", e);
            }
            try {
                if (avatar != null) {
                    // if (avatar instanceof RoundedAvatarDrawable)
                    // setAvatarBorder(presence,(RoundedAvatarDrawable)avatar);
                    holder.mAvatar.setImageDrawable(avatar);
                } else {
                    // int color = getAvatarBorder(presence);
                    int padding = 24;
                    LetterAvatar lavatar = new LetterAvatar(getContext(), nickname, padding);
                    holder.mAvatar.setImageDrawable(lavatar);
                }
                holder.mAvatar.setVisibility(View.VISIBLE);
            } catch (OutOfMemoryError ome) {
            // this seems to happen now and then even on tiny images; let's catch it and just not set an avatar
            }
        }
    }
    if (showChatMsg && message != null) {
        holder.mMediaThumb.setScaleType(ImageView.ScaleType.FIT_CENTER);
        holder.mMediaThumb.setVisibility(View.GONE);
        if (holder.mLine2 != null) {
            String vPath = message.split(" ")[0];
            if (SecureMediaStore.isVfsUri(vPath) || SecureMediaStore.isContentUri(vPath)) {
                if (TextUtils.isEmpty(messageType)) {
                    holder.mMediaThumb.setVisibility(View.VISIBLE);
                    holder.mMediaThumb.setImageResource(R.drawable.ic_attach_file_black_36dp);
                    holder.mMediaThumb.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                    holder.mLine2.setText("");
                } else if (messageType.startsWith("image")) {
                    if (holder.mMediaThumb != null) {
                        holder.mMediaThumb.setVisibility(View.VISIBLE);
                        if (messageType != null && messageType.equals("image/png")) {
                            holder.mMediaThumb.setScaleType(ImageView.ScaleType.FIT_CENTER);
                        } else {
                            holder.mMediaThumb.setScaleType(ImageView.ScaleType.CENTER_CROP);
                        }
                        setThumbnail(getContext().getContentResolver(), holder, Uri.parse(vPath), true);
                        holder.mLine2.setVisibility(View.GONE);
                    }
                } else if (messageType.startsWith("audio")) {
                    mLastMediaUri = null;
                    holder.mMediaThumb.setVisibility(View.VISIBLE);
                    holder.mMediaThumb.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                    holder.mMediaThumb.setImageResource(R.drawable.ic_volume_up_black_24dp);
                    holder.mLine2.setText("");
                } else if (messageType.startsWith("video")) {
                    mLastMediaUri = null;
                    holder.mMediaThumb.setVisibility(View.VISIBLE);
                    holder.mMediaThumb.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                    holder.mMediaThumb.setImageResource(R.drawable.video256);
                    holder.mLine2.setText("");
                } else if (messageType.startsWith("application")) {
                    mLastMediaUri = null;
                    holder.mMediaThumb.setVisibility(View.VISIBLE);
                    holder.mMediaThumb.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                    holder.mMediaThumb.setImageResource(R.drawable.ic_attach_file_black_36dp);
                    holder.mLine2.setText("");
                } else {
                    mLastMediaUri = null;
                    holder.mMediaThumb.setVisibility(View.GONE);
                    holder.mLine2.setText(messageType);
                }
            } else if ((!TextUtils.isEmpty(message)) && message.startsWith("/")) {
                String cmd = message.toString().substring(1);
                if (cmd.startsWith("sticker")) {
                    String[] cmds = cmd.split(":");
                    String mimeTypeSticker = "image/png";
                    Uri mediaUri = Uri.parse("asset://" + cmds[1]);
                    mLastMediaUri = null;
                    setThumbnail(getContext().getContentResolver(), holder, mediaUri, false);
                    holder.mLine2.setVisibility(View.GONE);
                    holder.mMediaThumb.setScaleType(ImageView.ScaleType.FIT_CENTER);
                    holder.mMediaThumb.setVisibility(View.VISIBLE);
                }
            } else if ((!TextUtils.isEmpty(message)) && message.startsWith(":")) {
                String[] cmds = message.split(":");
                try {
                    String[] stickerParts = cmds[1].split("-");
                    String folder = stickerParts[0];
                    StringBuffer name = new StringBuffer();
                    for (int i = 1; i < stickerParts.length; i++) {
                        name.append(stickerParts[i]);
                        if (i + 1 < stickerParts.length)
                            name.append('-');
                    }
                    String stickerPath = "stickers/" + folder + "/" + name.toString() + ".png";
                    // make sure sticker exists
                    AssetFileDescriptor afd = getContext().getAssets().openFd(stickerPath);
                    afd.getLength();
                    afd.close();
                    // now setup the new URI for loading local sticker asset
                    Uri mediaUri = Uri.parse("asset://localhost/" + stickerPath);
                    mLastMediaUri = null;
                    setThumbnail(getContext().getContentResolver(), holder, mediaUri, false);
                    holder.mLine2.setVisibility(View.GONE);
                    holder.mMediaThumb.setScaleType(ImageView.ScaleType.FIT_CENTER);
                } catch (Exception e) {
                }
            } else {
                if (holder.mMediaThumb != null)
                    holder.mMediaThumb.setVisibility(View.GONE);
                holder.mLine2.setVisibility(View.VISIBLE);
                try {
                    holder.mLine2.setText(android.text.Html.fromHtml(message).toString());
                } catch (RuntimeException re) {
                }
            }
        }
        if (messageDate != -1) {
            Date dateLast = new Date(messageDate);
            holder.mStatusText.setText(sPrettyTime.format(dateLast));
        } else {
            holder.mStatusText.setText("");
        }
    } else if (holder.mLine2 != null) {
        holder.mLine2.setText(address);
        if (holder.mMediaThumb != null)
            holder.mMediaThumb.setVisibility(View.GONE);
    }
    holder.mLine1.setVisibility(View.VISIBLE);
    if (providerId != -1)
        getEncryptionState(providerId, accountId, address, holder);
}
Also used : AssetFileDescriptor(android.content.res.AssetFileDescriptor) RoundedAvatarDrawable(org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable) Drawable(android.graphics.drawable.Drawable) LetterAvatar(org.awesomeapp.messenger.ui.widgets.LetterAvatar) SpannableString(android.text.SpannableString) Uri(android.net.Uri) UnderlineSpan(android.text.style.UnderlineSpan) Date(java.util.Date) SpannableString(android.text.SpannableString) GroupAvatar(org.awesomeapp.messenger.ui.widgets.GroupAvatar) RoundedAvatarDrawable(org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable)

Example 4 with LetterAvatar

use of org.awesomeapp.messenger.ui.widgets.LetterAvatar in project Zom-Android by zom.

the class MessageListItem method showAvatar.

private void showAvatar(String address, String nickname, boolean isLeft, int presenceStatus) {
    if (mHolder.mAvatar == null)
        return;
    mHolder.mAvatar.setVisibility(View.GONE);
    if (address != null && isLeft) {
        RoundedAvatarDrawable avatar = null;
        try {
            avatar = (RoundedAvatarDrawable) DatabaseUtils.getAvatarFromAddress(this.getContext().getContentResolver(), XmppAddress.stripResource(address), ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
        } catch (Exception e) {
        }
        if (avatar != null) {
            mHolder.mAvatar.setVisibility(View.VISIBLE);
            mHolder.mAvatar.setImageDrawable(avatar);
        // setAvatarBorder(presenceStatus, avatar);
        } else {
            // int color = getAvatarBorder(presenceStatus);
            int padding = 24;
            if (nickname.length() > 0) {
                LetterAvatar lavatar = new LetterAvatar(getContext(), nickname, padding);
                mHolder.mAvatar.setVisibility(View.VISIBLE);
                mHolder.mAvatar.setImageDrawable(lavatar);
            }
        }
    }
}
Also used : LetterAvatar(org.awesomeapp.messenger.ui.widgets.LetterAvatar) RoundedAvatarDrawable(org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable) RemoteException(android.os.RemoteException) IOException(java.io.IOException) SuppressLint(android.annotation.SuppressLint)

Aggregations

LetterAvatar (org.awesomeapp.messenger.ui.widgets.LetterAvatar)4 Drawable (android.graphics.drawable.Drawable)3 RemoteException (android.os.RemoteException)3 RoundedAvatarDrawable (org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable)3 SpannableString (android.text.SpannableString)2 UnderlineSpan (android.text.style.UnderlineSpan)2 View (android.view.View)2 GroupAvatar (org.awesomeapp.messenger.ui.widgets.GroupAvatar)2 SuppressLint (android.annotation.SuppressLint)1 AssetFileDescriptor (android.content.res.AssetFileDescriptor)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TypedValue (android.util.TypedValue)1 ViewGroup (android.view.ViewGroup)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 IOException (java.io.IOException)1