码迷,mamicode.com
首页 > 其他好文 > 详细

解决:People下面选择分享可见联系人,选择多个联系人后通过短信分享,短信中只显示一个联系人

时间:2014-06-08 05:49:12      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:des   android   c   style   code   a   

问题描述:

【操作步骤】:People下导入导出中选择分享可见联系人,选择多个联系人后通过短信分享

【测试结果】:短信中只能显示一个联系人

【预期结果】:可以显示多个联系人


经过代码分析,从compose_message_activitu.xml中的ViewStub进行定位到现实联系人名片的视图:                 

<ViewStub android:id="@+id/vcard_attachment_view_stub"
                      android:layout="@layout/vcard_attachment_view"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"/>

经过上述代码,找到vcard_attachment_view的布局,并定位到现实联系人名片的预览视图:


<com.android.mms.ui.VcardAttachmentView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/vcard_attachment_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:paddingRight="5dip"
    android:background="@drawable/attachment_editor_bg">


根据ID我们定位到AttachmentEditor类的createView()方法,代码如下:

private SlideViewInterface createView() {
        boolean inPortrait = inPortraitMode();
        if (mSlideshow.size() > 1) {
            return createSlideshowView(inPortrait);
        }

        SlideModel slide = mSlideshow.get(0);
        if (slide.hasImage()) {
            return createMediaView(
                    R.id.image_attachment_view_stub,
                    R.id.image_attachment_view,
                    R.id.view_image_button, R.id.replace_image_button, R.id.remove_image_button,
                    MSG_VIEW_IMAGE, MSG_REPLACE_IMAGE, MSG_REMOVE_ATTACHMENT);
        } else if (slide.hasVideo()) {
            return createMediaView(
                    R.id.video_attachment_view_stub,
                    R.id.video_attachment_view,
                    R.id.view_video_button, R.id.replace_video_button, R.id.remove_video_button,
                    MSG_PLAY_VIDEO, MSG_REPLACE_VIDEO, MSG_REMOVE_ATTACHMENT);
        } else if (slide.hasAudio()) {
            return createMediaView(
                    R.id.audio_attachment_view_stub,
                    R.id.audio_attachment_view,
                    R.id.play_audio_button, R.id.replace_audio_button, R.id.remove_audio_button,
                    MSG_PLAY_AUDIO, MSG_REPLACE_AUDIO, MSG_REMOVE_ATTACHMENT);
        } else if (slide.hasVcard()) {
            return createMediaView(R.id.vcard_attachment_view_stub,
                    R.id.vcard_attachment_view,
                    R.id.view_vcard_button,
                    R.id.replace_vcard_button,
                    R.id.remove_vcard_button,
                    MSG_VIEW_VCARD, MSG_REPLACE_VCARD, MSG_REMOVE_ATTACHMENT);
        } else if (slide.hasUnsupport()) {

            return createMediaView(R.id.unsupport_attachment_view_stub,
                    R.id.unsupport_attachment_view,
                    R.id.view_unsupport_button,
                    R.id.replace_unsupport_button,
                    R.id.remove_unsupport_button,
                    MSG_VIEW_VCARD, MSG_REPLACE_VCARD, MSG_REMOVE_ATTACHMENT);
        } else {
            throw new IllegalArgumentException();
        }
    }

经过分析,我们发现,通过调用createMediaView()方法,并在该方法中绑定点击时间的监听 viewButton.setOnClickListener(new MessageOnClick(view_message));通过点击发送消息给Handler,而setHandler的操作放在了ComposeMessageActivity类中。我们接着分析ComposeMessageActivity类中的Handler对象的handleMessage()方法:<TAG 1-1>


 private final Handler mAttachmentEditorHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case AttachmentEditor.MSG_EDIT_SLIDESHOW: {
                    editSlideshow();
                    break;
                }
                case AttachmentEditor.MSG_SEND_SLIDESHOW: {
                    if (isPreparedForSending()) {
                        ComposeMessageActivity.this.confirmSendMessageIfNeeded();
                    }
                    break;
                }
                case AttachmentEditor.MSG_VIEW_IMAGE:
                case AttachmentEditor.MSG_PLAY_VIDEO:
                case AttachmentEditor.MSG_PLAY_AUDIO:
                case AttachmentEditor.MSG_PLAY_SLIDESHOW:
                case AttachmentEditor.MSG_VIEW_VCARD:
                    if (mWorkingMessage.getSlideshow() != null) {
                         viewMmsMessageAttachment(msg.what);
                    }
                    break;


                case AttachmentEditor.MSG_REPLACE_IMAGE:
                case AttachmentEditor.MSG_REPLACE_VIDEO:
                case AttachmentEditor.MSG_REPLACE_AUDIO:
                    showAddAttachmentDialog(true);
                    break;

                //AddBy:yabin.huang BugID:SWBUG00029664 Date:20140528
                case AttachmentEditor.MSG_REPLACE_VCARD:
                    pickContacts(MultiPickContactsActivity.MODE_VCARD,REQUEST_CODE_ATTACH_ADD_CONTACT_VCARD);
                    break;

                case AttachmentEditor.MSG_REMOVE_ATTACHMENT:
                    mWorkingMessage.removeAttachment(true);
                    mAttachFileUri = null;
                    mIsSendMultiple = false;
                    break;

                default:
                    break;
            }
        }
    };

上述代码中<TAG 1-1>,调用viewMmsMessageAttachment()方法:

 public static void viewSimpleSlideshow(Context context, SlideshowModel slideshow) {
        if (!slideshow.isSimple()) {
            throw new IllegalArgumentException(
                    "viewSimpleSlideshow() called on a non-simple slideshow");
        }
        SlideModel slide = slideshow.get(0);
        MediaModel mm = null;
        if (slide.hasImage()) {
            mm = slide.getImage();
        } else if (slide.hasVideo()) {
            mm = slide.getVideo();
        } else if (slide.hasVcard()) {
            mm = slide.getVcard();
            String lookupUri = ((VcardModel) mm).getLookupUri();

            Intent intent = new Intent(Intent.ACTION_VIEW);
            if (!TextUtils.isEmpty(lookupUri) && lookupUri.contains("contacts")) {
                // if the uri is from the contact, we suggest to view the contact.
                intent.setData(Uri.parse(lookupUri));
            } else {

                // we need open the saved part.
                intent.setDataAndType(mm.getUri(), ContentType.TEXT_VCARD.toLowerCase());
                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }
            // distinguish view vcard from mms or contacts.
            intent.putExtra(VIEW_VCARD, true);
            context.startActivity(intent);
            return;
        }
上述加粗标红代码进行注释,则问题解决。这么处理的原因,无论当前lookruUri中包含几个联系人或者无论从那里跳转查看名片附件的内容都跳转到mm.getUri()所表示的uri去。当然这样的处理还有待改善,由于时间问题这里暂作处理,以后如果有时间进行完善。








解决:People下面选择分享可见联系人,选择多个联系人后通过短信分享,短信中只显示一个联系人,布布扣,bubuko.com

解决:People下面选择分享可见联系人,选择多个联系人后通过短信分享,短信中只显示一个联系人

标签:des   android   c   style   code   a   

原文地址:http://blog.csdn.net/huangyabin001/article/details/28886097

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!