首页 > 代码库 > Mms编辑短信时候联系人重复或者无效则删除解决方案

Mms编辑短信时候联系人重复或者无效则删除解决方案

路径

packages\apps\Mms\src\com\android\mms\ui\ComposeMessageActivity.java

修改

private void updateTitle(ContactList list)
if (mConversation.isGroupChat()) {
    GroupChatModel groupChat = mConversation.getGroupChat();
    if (groupChat != null) {
        title = RcsUtils.getDisplayName(groupChat);
    } else if (!mSentMessage) {
        title = getString(R.string.new_group_chat);
    } else {
        title = getString(R.string.group_chat);
    }
    subTitle = getString(R.string.group_chat) + mConversation.getGroupChatStatusText();
} else {
    //modify start
    if(mRecipientsEditor != null && list != null && list.size() > 0) {
        int size = list.size();
        
        Contact lastContact = list.get(size - 1);  //Find the last contact
        String name = lastContact.getName();
        String number = lastContact.getNumber();
        if (!(Mms.isEmailAddress(number) || Telephony.Mms.isPhoneNumber(number))) {  //Add contact error
            list.remove(size - 1);
            mRecipientsEditor.populate(list);
            
            String title2 = getResourcesString(R.string.has_invalid_recipient, name);
            Toast.makeText(ComposeMessageActivity.this, title2, Toast.LENGTH_SHORT).show();
            return;
        }
        if(size > 1){
            for(int i = 0; i < size - 1; i++) {
                if(number.equals(list.get(i).getNumber())){  //Repeat the contact
                    list.remove(size - 1);
                    mRecipientsEditor.populate(list);
                    String title2 = getResourcesString(R.string.has_invalid_recipient, name);
                    Toast.makeText(ComposeMessageActivity.this, title2, Toast.LENGTH_SHORT).show();
                    return;
                }
            }
        }
        
    }
    //modify end

  

Mms编辑短信时候联系人重复或者无效则删除解决方案