Methods Summary |
---|
public void | bind(MessageItem msgItem)
mMessageItem = msgItem;
setLongClickable(false);
switch (msgItem.mMessageType) {
case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
bindNotifInd(msgItem);
break;
default:
bindCommonMessage(msgItem);
break;
}
|
private void | bindCommonMessage(MessageItem msgItem)
if (mDownloadButton != null) {
mDownloadButton.setVisibility(View.GONE);
mDownloadingLabel.setVisibility(View.GONE);
}
// Since the message text should be concatenated with the sender's
// address(or name), I have to display it here instead of
// displaying it by the Presenter.
mBodyTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
// Get and/or lazily set the formatted message from/on the
// MessageItem. Because the MessageItem instances come from a
// cache (currently of size ~50), the hit rate on avoiding the
// expensive formatMessage() call is very high.
CharSequence formattedMessage = msgItem.getCachedFormattedMessage();
if (formattedMessage == null) {
formattedMessage = formatMessage(msgItem.mContact, msgItem.mBody,
msgItem.mSubject, msgItem.mTimestamp);
msgItem.setCachedFormattedMessage(formattedMessage);
}
mBodyTextView.setText(formattedMessage);
if (msgItem.isSms()) {
hideMmsViewIfNeeded();
} else {
Presenter presenter = PresenterFactory.getPresenter(
"MmsThumbnailPresenter", mContext,
this, msgItem.mSlideshow);
presenter.present();
if (msgItem.mAttachmentType != AttachmentEditor.TEXT_ONLY) {
inflateMmsView();
mMmsView.setVisibility(View.VISIBLE);
setOnClickListener(msgItem);
drawPlaybackButton(msgItem);
} else {
hideMmsViewIfNeeded();
}
}
drawLeftStatusIndicator(msgItem.mBoxId);
drawRightStatusIndicator(msgItem);
|
private void | bindNotifInd(MessageItem msgItem)
hideMmsViewIfNeeded();
String msgSizeText = mContext.getString(R.string.message_size_label)
+ String.valueOf((msgItem.mMessageSize + 1023) / 1024)
+ mContext.getString(R.string.kilobyte);
mBodyTextView.setText(formatMessage(msgItem.mContact, null, msgItem.mSubject,
msgSizeText + "\n" + msgItem.mTimestamp));
int state = DownloadManager.getInstance().getState(msgItem.mMessageUri);
switch (state) {
case DownloadManager.STATE_DOWNLOADING:
inflateDownloadControls();
mDownloadingLabel.setVisibility(View.VISIBLE);
mDownloadButton.setVisibility(View.GONE);
break;
case DownloadManager.STATE_UNSTARTED:
case DownloadManager.STATE_TRANSIENT_FAILURE:
case DownloadManager.STATE_PERMANENT_FAILURE:
default:
setLongClickable(true);
inflateDownloadControls();
mDownloadingLabel.setVisibility(View.GONE);
mDownloadButton.setVisibility(View.VISIBLE);
mDownloadButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mDownloadingLabel.setVisibility(View.VISIBLE);
mDownloadButton.setVisibility(View.GONE);
Intent intent = new Intent(mContext, TransactionService.class);
intent.putExtra(TransactionBundle.URI, msgItem.mMessageUri.toString());
intent.putExtra(TransactionBundle.TRANSACTION_TYPE,
Transaction.RETRIEVE_TRANSACTION);
mContext.startService(intent);
}
});
break;
}
// Hide the error indicator.
mRightStatusIndicator.setVisibility(View.GONE);
drawLeftStatusIndicator(msgItem.mBoxId);
|
private void | drawLeftStatusIndicator(int msgBoxId)
switch (msgBoxId) {
case Mms.MESSAGE_BOX_INBOX:
mMsgListItem.setBackgroundResource(R.drawable.listitem_background_lightblue);
break;
case Mms.MESSAGE_BOX_DRAFTS:
case Sms.MESSAGE_TYPE_FAILED:
case Sms.MESSAGE_TYPE_QUEUED:
case Mms.MESSAGE_BOX_OUTBOX:
mMsgListItem.setBackgroundResource(R.drawable.listitem_background);
break;
default:
mMsgListItem.setBackgroundResource(R.drawable.listitem_background);
break;
}
|
private void | drawPlaybackButton(MessageItem msgItem)
switch (msgItem.mAttachmentType) {
case AttachmentEditor.SLIDESHOW_ATTACHMENT:
case AttachmentEditor.AUDIO_ATTACHMENT:
case AttachmentEditor.VIDEO_ATTACHMENT:
// Show the 'Play' button and bind message info on it.
mSlideShowButton.setTag(msgItem);
// Set call-back for the 'Play' button.
mSlideShowButton.setOnClickListener(this);
mSlideShowButton.setVisibility(View.VISIBLE);
setLongClickable(true);
break;
default:
mSlideShowButton.setVisibility(View.GONE);
break;
}
|
private void | drawRightStatusIndicator(MessageItem msgItem)
if (msgItem.isOutgoingMessage()) {
if (isFailedMessage(msgItem)) {
mRightStatusIndicator.setImageResource(R.drawable.ic_sms_mms_not_delivered);
setErrorIndicatorClickListener(msgItem);
} else {
mRightStatusIndicator.setImageResource(R.drawable.ic_email_pending);
}
mRightStatusIndicator.setVisibility(View.VISIBLE);
} else if (msgItem.mDeliveryReport || msgItem.mReadReport) {
mRightStatusIndicator.setImageResource(R.drawable.ic_mms_message_details);
mRightStatusIndicator.setVisibility(View.VISIBLE);
} else {
mRightStatusIndicator.setVisibility(View.GONE);
}
|
private java.lang.CharSequence | formatMessage(java.lang.String contact, java.lang.String body, java.lang.String subject, java.lang.String timestamp)
SpannableStringBuilder buf = new SpannableStringBuilder(contact);
buf.append(": ");
buf.setSpan(STYLE_BOLD, 0, buf.length(),
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
boolean hasSubject = !TextUtils.isEmpty(subject);
if (hasSubject) {
buf.append(mContext.getResources().getString(R.string.inline_subject, subject));
}
if (!TextUtils.isEmpty(body)) {
if (hasSubject) {
buf.append(" - ");
}
SmileyParser parser = SmileyParser.getInstance();
buf.append(parser.addSmileySpans(body));
}
buf.append("\n");
int startOffset = buf.length();
// put a one pixel high spacer line between the message and the time stamp as requested
// by the spec.
buf.append("\n");
buf.setSpan(new AbsoluteSizeSpan(3), startOffset, buf.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startOffset = buf.length();
buf.append(timestamp);
buf.setSpan(new AbsoluteSizeSpan(12), startOffset, buf.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Make the timestamp text not as dark
int color = mContext.getResources().getColor(R.color.timestamp_color);
buf.setSpan(new ForegroundColorSpan(color), startOffset, buf.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return buf;
|
public MessageItem | getMessageItem()
return mMessageItem;
|
private void | hideMmsViewIfNeeded()
if (mMmsView != null) {
mMmsView.setVisibility(View.GONE);
}
|
private void | inflateDownloadControls()
if (mDownloadButton == null) {
//inflate the download controls
findViewById(R.id.mms_downloading_view_stub).setVisibility(VISIBLE);
mDownloadButton = (Button) findViewById(R.id.btn_download_msg);
mDownloadingLabel = (TextView) findViewById(R.id.label_downloading);
}
|
private void | inflateMmsView()
if (mMmsView == null) {
//inflate the surrounding view_stub
findViewById(R.id.mms_layout_view_stub).setVisibility(VISIBLE);
mMmsView = findViewById(R.id.mms_view);
mImageView = (ImageView) findViewById(R.id.image_view);
mSlideShowButton = (ImageButton) findViewById(R.id.play_slideshow_button);
}
|
public static boolean | isFailedMessage(MessageItem msgItem)
boolean isFailedMms = msgItem.isMms()
&& (msgItem.mErrorType >= MmsSms.ERR_TYPE_GENERIC_PERMANENT);
boolean isFailedSms = msgItem.isSms()
&& (msgItem.mBoxId == Sms.MESSAGE_TYPE_FAILED);
return isFailedMms || isFailedSms;
|
public void | onClick(android.view.View v)
MessageItem mi = (MessageItem) v.getTag();
switch (mi.mAttachmentType) {
case AttachmentEditor.VIDEO_ATTACHMENT:
case AttachmentEditor.AUDIO_ATTACHMENT:
case AttachmentEditor.SLIDESHOW_ATTACHMENT:
MessageUtils.viewMmsMessageAttachment(mContext,
mi.mMessageUri, mi.mSlideshow, null /* persister */);
break;
}
|
protected void | onFinishInflate()
super.onFinishInflate();
mMsgListItem = findViewById(R.id.msg_list_item);
mBodyTextView = (TextView) findViewById(R.id.text_view);
mRightStatusIndicator = (ImageView) findViewById(R.id.right_status_indicator);
|
public void | onMessageListItemClick()
URLSpan[] spans = mBodyTextView.getUrls();
if (spans.length == 0) {
// Do nothing.
} else if (spans.length == 1) {
Uri uri = Uri.parse(spans[0].getURL());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
mContext.startActivity(intent);
} else {
final java.util.ArrayList<String> urls = MessageUtils.extractUris(spans);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(mContext, android.R.layout.select_dialog_item, urls) {
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
try {
String url = getItem(position).toString();
TextView tv = (TextView) v;
Drawable d = mContext.getPackageManager().getActivityIcon(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
if (d != null) {
d.setBounds(0, 0, d.getIntrinsicHeight(), d.getIntrinsicHeight());
tv.setCompoundDrawablePadding(10);
tv.setCompoundDrawables(d, null, null, null);
}
final String telPrefix = "tel:";
if (url.startsWith(telPrefix)) {
url = PhoneNumberUtils.formatNumber(url.substring(telPrefix.length()));
}
tv.setText(url);
} catch (android.content.pm.PackageManager.NameNotFoundException ex) {
;
}
return v;
}
};
AlertDialog.Builder b = new AlertDialog.Builder(mContext);
DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() {
public final void onClick(DialogInterface dialog, int which) {
if (which >= 0) {
Uri uri = Uri.parse(urls.get(which));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
mContext.startActivity(intent);
}
}
};
b.setTitle(R.string.select_link_title);
b.setCancelable(true);
b.setAdapter(adapter, click);
b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public final void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
b.show();
}
|
public void | pauseAudio()
// TODO Auto-generated method stub
|
public void | pauseVideo()
// TODO Auto-generated method stub
|
public void | reset()
if (mImageView != null) {
mImageView.setVisibility(GONE);
}
|
public void | seekAudio(int seekTo)
// TODO Auto-generated method stub
|
public void | seekVideo(int seekTo)
// TODO Auto-generated method stub
|
public void | setAudio(android.net.Uri audio, java.lang.String name, java.util.Map extras)
// TODO Auto-generated method stub
|
private void | setErrorIndicatorClickListener(MessageItem msgItem)
String type = msgItem.mType;
final int what;
if (type.equals("sms")) {
what = MSG_LIST_EDIT_SMS;
} else {
what = MSG_LIST_EDIT_MMS;
}
mRightStatusIndicator.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (null != mHandler) {
Message msg = Message.obtain(mHandler, what);
msg.obj = new Long(msgItem.mMsgId);
msg.sendToTarget();
}
}
});
|
public void | setImage(java.lang.String name, android.graphics.Bitmap bitmap)
inflateMmsView();
if (null == bitmap) {
bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_missing_thumbnail_picture);
}
mImageView.setImageBitmap(bitmap);
mImageView.setVisibility(VISIBLE);
|
public void | setImageRegionFit(java.lang.String fit)
// TODO Auto-generated method stub
|
public void | setImageVisibility(boolean visible)
// TODO Auto-generated method stub
|
public void | setMsgListItemHandler(android.os.Handler handler)
mHandler = handler;
|
private void | setOnClickListener(MessageItem msgItem)
switch(msgItem.mAttachmentType) {
case AttachmentEditor.IMAGE_ATTACHMENT:
case AttachmentEditor.VIDEO_ATTACHMENT:
mImageView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
MessageUtils.viewMmsMessageAttachment(mContext,
null /* uri */, msgItem.mSlideshow, null /* persister */);
}
});
mImageView.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
return v.showContextMenu();
}
});
break;
default:
mImageView.setOnClickListener(null);
break;
}
|
public void | setText(java.lang.String name, java.lang.String text)
// TODO Auto-generated method stub
|
public void | setTextVisibility(boolean visible)
// TODO Auto-generated method stub
|
public void | setVideo(java.lang.String name, android.net.Uri video)
inflateMmsView();
Bitmap bitmap = VideoAttachmentView.createVideoThumbnail(mContext, video);
if (null == bitmap) {
bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_missing_thumbnail_video);
}
mImageView.setImageBitmap(bitmap);
mImageView.setVisibility(VISIBLE);
|
public void | setVideoVisibility(boolean visible)
// TODO Auto-generated method stub
|
public void | setVisibility(boolean visible)
// TODO Auto-generated method stub
|
public void | startAudio()
// TODO Auto-generated method stub
|
public void | startVideo()
// TODO Auto-generated method stub
|
public void | stopAudio()
// TODO Auto-generated method stub
|
public void | stopVideo()
// TODO Auto-generated method stub
|