linphone-去掉ChatListFragment聊天界面

来源:互联网 发布:c语言编程书籍推荐 编辑:程序博客网 时间:2024/05/15 01:05

说明

linphone有一个聊天界面。
1. 显示所有的聊天界面。
2. 向固定的帐号发送聊天信息。
3. 向固定的帐号发送附件信息。这个需要跳转到其他的应用。
4. 怎样显示聊天列表,有没有优化这个。
5. 当编辑的时候,对端显示remote is writing.

图片

显示对话列表
显示对话列表

新增加对话框列表
新增加对话框列表

对话聊天界面
对话聊天界面

具体逻辑分析

调用系统的应用

#ChatFragment.java//File transferprivate void pickImage() {    List<Intent> cameraIntents = new ArrayList<Intent>();    Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);    File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())));    imageToUploadUri = Uri.fromFile(file);    captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);    cameraIntents.add(captureIntent);    Intent galleryIntent = new Intent();    galleryIntent.setType("image/*");    galleryIntent.setAction(Intent.ACTION_PICK);    Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));    startActivityForResult(chooserIntent, ADD_PHOTO);}
@Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) {    if (requestCode == ADD_PHOTO && resultCode == Activity.RESULT_OK) {        String fileToUploadPath = null;        if (data != null && data.getData() != null) {            fileToUploadPath = getRealPathFromURI(data.getData());        } else if (imageToUploadUri != null) {            fileToUploadPath = imageToUploadUri.getPath();        }        if (fileToUploadPath != null) {                //showPopupMenuAskingImageSize(fileToUploadPath);            sendImageMessage(fileToUploadPath, 0);        }    } else {        super.onActivityResult(requestCode, resultCode, data);    }}
private void sendImageMessage(String path, int imageSize) {    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();    boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();    if (newChatConversation && chatRoom == null) {        String address = searchContactField.getText().toString();        if (address != null && !address.equals("")) {            initChatRoom(address);        }    }    if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {       try {            Bitmap bm = BitmapFactory.decodeFile(path);            if (bm != null) {                FileUploadPrepareTask task = new FileUploadPrepareTask(getActivity(), path, imageSize);                task.execute(bm);            } else {                Log.e("Error, bitmap factory can't read " + path);            }        } catch (RuntimeException e) {            Log.e("Error, not enough memory to create the bitmap");        }    } else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {            LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);        }    }
0 0
原创粉丝点击