private void setContactPhoto(final Recipient recipient) {
    if (recipient == null) return;

    if (isBadgeEnabled()) {
      contactPhotoBadge.setImageBitmap(recipient.getContactPhoto());
      contactPhotoBadge.assignContactFromPhone(recipient.getNumber(), true);
    } else {
      contactPhotoImage.setImageBitmap(recipient.getContactPhoto());
      contactPhotoImage.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (recipient.getContactUri() != null) {
                QuickContact.showQuickContact(
                    context,
                    contactPhotoImage,
                    recipient.getContactUri(),
                    QuickContact.MODE_LARGE,
                    null);
              } else {
                Intent intent =
                    new Intent(
                        Intents.SHOW_OR_CREATE_CONTACT,
                        Uri.fromParts("tel", recipient.getNumber(), null));
                context.startActivity(intent);
              }
            }
          });
    }
  }
 private void initializeContactWidgetVisibility() {
   if (isBadgeEnabled()) {
     contactPhotoBadge.setVisibility(View.VISIBLE);
     contactPhotoImage.setVisibility(View.GONE);
   } else {
     contactPhotoBadge.setVisibility(View.GONE);
     contactPhotoImage.setVisibility(View.VISIBLE);
   }
 }
예제 #3
0
 @Override
 public void onClick(View v) {
   super.onClick(v);
   if (mExtraOnClickListener != null) {
     mExtraOnClickListener.onClick(v);
   }
 }
  public ConversationHeaderView(Context context, boolean first) {
    this(context, (Set<Long>) null);

    this.first = true;
    contactPhoto.setVisibility(View.GONE);
    this.setBackgroundColor(Color.TRANSPARENT);
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View result;
      if (convertView == null) {
        result =
            mLayoutInflater.inflate(
                mIsGroupMembershipEditable
                    ? R.layout.group_member_item
                    : R.layout.external_group_member_item,
                parent,
                false);
      } else {
        result = convertView;
      }
      final Member member = getItem(position);

      QuickContactBadge badge = (QuickContactBadge) result.findViewById(R.id.badge);
      badge.assignContactUri(member.getLookupUri());

      TextView name = (TextView) result.findViewById(R.id.name);
      name.setText(member.getDisplayName());

      View deleteButton = result.findViewById(R.id.delete_button_container);
      if (deleteButton != null) {
        deleteButton.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                removeMember(member);
              }
            });
      }
      DefaultImageRequest request =
          new DefaultImageRequest(
              member.getDisplayName(), member.getLookupKey(), true /* isCircular */);
      mPhotoManager.loadPhoto(
          badge,
          member.getPhotoUri(),
          ViewUtil.getConstantPreLayoutWidth(badge),
          false,
          true /* isCircular */,
          request);
      return result;
    }
  public void set(MessageRecord message, boolean batchMode) {
    this.recipients = message.getRecipients();
    this.threadId = message.getThreadId();
    this.fromView.setText(formatFrom(recipients, message.getCount()));

    if (message.isKeyExchange())
      this.subjectView.setText("Key exchange message...", TextView.BufferType.SPANNABLE);
    else this.subjectView.setText(message.getBody(), TextView.BufferType.SPANNABLE);

    if (message.getEmphasis())
      ((Spannable) this.subjectView.getText())
          .setSpan(
              new StyleSpan(android.graphics.Typeface.ITALIC),
              0,
              this.subjectView.getText().length(),
              Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (message.getDate() > 0)
      this.dateView.setText(
          DateUtils.getRelativeTimeSpanString(getContext(), message.getDate(), false));

    if (selectedThreads != null) this.checkbox.setChecked(selectedThreads.contains(threadId));

    clearIndicators();
    setIndicators(message.getRead(), message.isKeyExchange());

    if (!first) {
      if (batchMode) checkbox.setVisibility(View.VISIBLE);
      else checkbox.setVisibility(View.GONE);

      if (!PreferenceManager.getDefaultSharedPreferences(context)
          .getBoolean(
              ApplicationPreferencesActivity.CONVERSATION_ICONS_LIST_PREF,
              ApplicationPreferencesActivity.showIcon())) {
        contactPhoto.setVisibility(View.GONE);
      } else {
        contactPhoto.setImageBitmap(
            message.getRecipients().getPrimaryRecipient().getContactPhoto());
        contactPhoto.assignContactFromPhone(
            message.getRecipients().getPrimaryRecipient().getNumber(), false);
        contactPhoto.setVisibility(View.VISIBLE);
      }
    }
  }
  public void addThumbnail() {

    final Integer thumbnailId = fetchThumbnailId();
    if (thumbnailId != null) {
      final Bitmap thumbnail = fetchThumbnail(thumbnailId);
      if (thumbnail != null) {
        badge.setImageBitmap(thumbnail);
      }
    }
  }
예제 #8
0
  private void updateAvatarView() {
    MultiDeleteListItemData ch = mMultiDeleteThreadData;

    Drawable avatarDrawable;
    if (ch.getContacts().size() == 1) {
      Contact contact = ch.getContacts().get(0);
      avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);

      if (contact.existsInDatabase()) {
        mAvatarView.assignContactUri(contact.getUri());
      } else {
        mAvatarView.assignContactFromPhone(contact.getNumber(), true);
      }
    } else {
      // TODO get a multiple recipients asset (or do something else)
      avatarDrawable = sDefaultContactImage;
      mAvatarView.assignContactUri(null);
    }
    mAvatarView.setImageDrawable(avatarDrawable);
  }
예제 #9
0
  private void updateAvatarView() {
    Drawable avatarDrawable;
    if (mConversation.getRecipients().size() == 1) {

      Contact contact = mConversation.getRecipients().get(0);

      // to be continued
      avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);

      if (contact.existsInDatabase()) { // 010查看联系人是否存在于通讯录
        mAvatarView.assignContactUri(contact.getUri());
      } else {
        mAvatarView.assignContactFromPhone(contact.getNumber(), true);
      }
    } else {
      // TODO get a multiple recipients asset (or do something else)
      avatarDrawable = sDefaultContactImage;
      mAvatarView.assignContactUri(null);
    }
    mAvatarView.setImageDrawable(avatarDrawable);
    mAvatarView.setVisibility(View.VISIBLE);
  }
예제 #10
0
 @Override
 public void assignContactUri(Uri uri) {
   badge.assignContactUri(uri);
 }
예제 #11
0
  public void populate(final Message message, final Account account) throws MessagingException {
    final Contacts contacts = K9.showContactName() ? mContacts : null;
    final CharSequence from = Address.toFriendly(message.getFrom(), contacts);
    final CharSequence to =
        Address.toFriendly(message.getRecipients(Message.RecipientType.TO), contacts);
    final CharSequence cc =
        Address.toFriendly(message.getRecipients(Message.RecipientType.CC), contacts);

    Address[] fromAddrs = message.getFrom();
    Address[] toAddrs = message.getRecipients(Message.RecipientType.TO);
    Address[] ccAddrs = message.getRecipients(Message.RecipientType.CC);
    boolean fromMe = mMessageHelper.toMe(account, fromAddrs);

    String counterpartyAddress = null;
    if (fromMe) {
      if (toAddrs.length > 0) {
        counterpartyAddress = toAddrs[0].getAddress();
      } else if (ccAddrs.length > 0) {
        counterpartyAddress = ccAddrs[0].getAddress();
      }
    } else if (fromAddrs.length > 0) {
      counterpartyAddress = fromAddrs[0].getAddress();
    }

    /*
     * Only reset visibility of the subject if populate() was called because a new
     * message is shown. If it is the same, do not force the subject visible, because
     * this breaks the MessageTitleView in the action bar, which may hide our subject
     * if it fits in the action bar but is only called when a new message is shown
     * or the device is rotated.
     */
    if (mMessage == null || mMessage.getId() != message.getId()) {
      mSubjectView.setVisibility(VISIBLE);
    }

    mMessage = message;
    mAccount = account;

    if (K9.showContactPicture()) {
      mContactBadge.setVisibility(View.VISIBLE);
      mContactsPictureLoader = new ContactPictureLoader(mContext, R.drawable.ic_contact_picture);
    } else {
      mContactBadge.setVisibility(View.GONE);
    }

    final String subject = message.getSubject();
    if (StringUtils.isNullOrEmpty(subject)) {
      mSubjectView.setText(mContext.getText(R.string.general_no_subject));
    } else {
      mSubjectView.setText(subject);
    }
    mSubjectView.setTextColor(0xff000000 | defaultSubjectColor);

    String dateTime =
        DateUtils.formatDateTime(
            mContext,
            message.getSentDate().getTime(),
            DateUtils.FORMAT_SHOW_DATE
                | DateUtils.FORMAT_ABBREV_ALL
                | DateUtils.FORMAT_SHOW_TIME
                | DateUtils.FORMAT_SHOW_YEAR);
    mDateView.setText(dateTime);

    if (K9.showContactPicture()) {
      mContactBadge.assignContactFromEmail(counterpartyAddress, true);
      if (counterpartyAddress != null) {
        mContactsPictureLoader.loadContactPicture(counterpartyAddress, mContactBadge);
      } else {
        mContactBadge.setImageResource(R.drawable.ic_contact_picture);
      }
    }

    mFromView.setText(from);

    updateAddressField(mToView, to, mToLabel);
    updateAddressField(mCcView, cc, mCcLabel);
    mAnsweredIcon.setVisibility(message.isSet(Flag.ANSWERED) ? View.VISIBLE : View.GONE);
    mForwardedIcon.setVisibility(message.isSet(Flag.FORWARDED) ? View.VISIBLE : View.GONE);
    mFlagged.setChecked(message.isSet(Flag.FLAGGED));

    int chipColor = mAccount.getChipColor();
    int chipColorAlpha = (!message.isSet(Flag.SEEN)) ? 255 : 127;
    mChip.setBackgroundColor(chipColor);
    mChip.getBackground().setAlpha(chipColorAlpha);

    setVisibility(View.VISIBLE);

    if (mSavedState != null) {
      if (mSavedState.additionalHeadersVisible) {
        showAdditionalHeaders();
      }
      mSavedState = null;
    } else {
      hideAdditionalHeaders();
    }
  }