linphone-去掉ChatListFragment聊天界面

说明

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

图片

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

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

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

具体逻辑分析

调用系统的应用

#ChatFragment.java
//File transfer
private 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);
}
@Override
public 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);
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赵健zj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值