linphone-去掉ChatListFragment聊天介面
阿新 • • 發佈:2018-12-07
說明
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);
}
}