11111
This commit is contained in:
parent
62d38d4275
commit
b6c80f095d
@ -155,6 +155,8 @@ dependencies {
|
||||
//此处以集成 5.1.2 版本为例
|
||||
api 'cn.rongcloud.sdk:im_lib:5.1.3.10' // 即时通讯基础能力库
|
||||
api 'cn.rongcloud.sdk:im_kit:5.1.3.10' // 即时通讯 UI 基础组件
|
||||
//融云小视频模块
|
||||
api 'cn.rongcloud.sdk:sight:5.1.2'
|
||||
api 'com.facebook.android:facebook-login:8.2.0'
|
||||
api 'com.facebook.android:facebook-android-sdk:[5,6)'
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.yunbao.live.dialog;
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.common.R;
|
||||
|
||||
/**
|
||||
* 消息長按彈窗
|
||||
@ -14,6 +15,7 @@ public class MessageLongClickPopuwindow {
|
||||
private Activity mContext;
|
||||
private View popupView;
|
||||
private PopupWindow popupWindow;
|
||||
private LinearLayout copyLinear;
|
||||
|
||||
public MessageLongClickPopuwindow(Activity context) {
|
||||
this.mContext = context;
|
@ -226,7 +226,6 @@ public class MessageIMManager {
|
||||
*/
|
||||
@Override
|
||||
public boolean onMessageLongClick(Context context, View view, Message message) {
|
||||
|
||||
ToastUtil.show(message.getContent().toString());
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.media.MediaMetadataRetriever;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@ -29,4 +31,45 @@ public class FileUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 视频 或 音频 时长
|
||||
* @param path 视频 或 音频 文件路径
|
||||
* @return 时长 毫秒值
|
||||
*/
|
||||
public static long getDuration(String path){
|
||||
android.media.MediaMetadataRetriever mmr = new android.media.MediaMetadataRetriever();
|
||||
long duration=0;
|
||||
try {
|
||||
if (path!= null) {
|
||||
mmr.setDataSource(path);
|
||||
}
|
||||
String time = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
||||
duration= Long.parseLong(time);
|
||||
} catch (Exception ex) {
|
||||
} finally {
|
||||
mmr.release();
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
/**
|
||||
* Android 音乐播放器应用里,读出的音乐时长为 long 类型以毫秒数为单位,例如:将 234736 转化为分钟和秒应为 03:55 (包含四舍五入)
|
||||
* @param duration 音乐时长
|
||||
* @return
|
||||
*/
|
||||
public static String timeParse(long duration) {
|
||||
String time = "" ;
|
||||
long minute = duration / 60000 ;
|
||||
long seconds = duration % 60000 ;
|
||||
long second = Math.round((float)seconds/1000) ;
|
||||
if( minute < 10 ){
|
||||
time += "0" ;
|
||||
}
|
||||
time += minute+":" ;
|
||||
if( second < 10 ){
|
||||
time += "0" ;
|
||||
}
|
||||
time += second ;
|
||||
return time ;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:cardBackgroundColor="#474747"
|
||||
@ -10,13 +10,18 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/copy_linear"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
@ -31,9 +36,12 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/withdraw_linear"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
@ -48,9 +56,11 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
Before Width: | Height: | Size: 470 B After Width: | Height: | Size: 470 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@ -31,19 +31,22 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
|
||||
Message.MessageDirection messageDirection = mDataList.get(position).getMessage().getMessageDirection();
|
||||
ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt);
|
||||
ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new);
|
||||
if (messageDirection==Message.MessageDirection.SEND){
|
||||
readReceiptNew.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
readReceiptNew.setVisibility(View.GONE);
|
||||
}
|
||||
if (readReceiptNew!=null){
|
||||
if (messageDirection==Message.MessageDirection.SEND){
|
||||
readReceiptNew.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
readReceiptNew.setVisibility(View.GONE);
|
||||
}
|
||||
if (readReceipt.getVisibility()==View.VISIBLE) {
|
||||
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read);
|
||||
} else {
|
||||
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread);
|
||||
}
|
||||
if (readReceipt!=null){
|
||||
readReceipt.setVisibility(View.GONE);
|
||||
if (readReceipt!=null){
|
||||
readReceipt.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
holder.getConvertView().setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
@ -6,6 +6,7 @@ import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
@ -15,6 +16,7 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.yunbao.common.utils.FileUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.utils.FileSizeUtil;
|
||||
@ -26,6 +28,7 @@ import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.FileMessage;
|
||||
import io.rong.message.ImageMessage;
|
||||
import io.rong.message.SightMessage;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
@ -237,8 +240,70 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
|
||||
if (pluginList.getVisibility() == VISIBLE) {
|
||||
pluginList.setVisibility(GONE);
|
||||
}
|
||||
Message message;
|
||||
long duration = FileUtil.getDuration(filePath);
|
||||
double fileSize = FileSizeUtil.getFileOrFilesSize(filePath, FileSizeUtil.SIZETYPE_MB);
|
||||
//将视频获取的毫秒时长转成分总
|
||||
long minute = duration / 60000;
|
||||
//大于两分钟走发送文件,否则走发送小视频
|
||||
if (minute > 2) {
|
||||
sendFile(filePath);
|
||||
} else {
|
||||
sendSightExtension(filePath, duration);
|
||||
}
|
||||
Log.e("InputPanelViewHolder", "时长" + duration + "文件大小");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送小视频消息
|
||||
*
|
||||
* @param filePath 文件路径
|
||||
* @param duration 视频时长
|
||||
*/
|
||||
private void sendSightExtension(String filePath, long duration) {
|
||||
long seconds = duration % 60000 ;
|
||||
long second = Math.round((float)seconds/1000) ;
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
Uri localUri = Uri.parse("file://" + filePath);
|
||||
SightMessage sightMessage = SightMessage.obtain(localUri, (int) second);
|
||||
Message message = Message.obtain(targetId, conversationType, sightMessage);
|
||||
IMCenter.getInstance().sendMediaMessage(message, null, null, new IRongCallback.ISendMediaMessageCallback() {
|
||||
@Override
|
||||
public void onProgress(Message message, int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(final Message message, final RongIMClient.ErrorCode errorCode) {
|
||||
ToastUtil.show(errorCode.msg);
|
||||
}
|
||||
});//
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送文件消息
|
||||
*
|
||||
* @param filePath 文件路径
|
||||
*/
|
||||
private void sendFile(String filePath) {
|
||||
Message message;
|
||||
|
||||
Uri localUri = Uri.parse("file://" + filePath);
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
|
||||
@ -273,10 +338,8 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
|
||||
ToastUtil.show(errorCode.msg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 多媒体信息
|
||||
*/
|
||||
|
@ -59,6 +59,7 @@
|
||||
android:id="@+id/rc_conversation_read_receipt"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
@ -76,7 +77,7 @@
|
||||
android:singleLine="true"
|
||||
android:text="你好,朋友!"
|
||||
android:textColor="@color/rc_secondary_color"
|
||||
android:textSize="@dimen/rc_font_text_third_size" />
|
||||
android:textSize="15dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rc_conversation_unread"
|
||||
|
@ -25,6 +25,7 @@ import com.yunbao.main.utils.PDLiveMessageProcessor;
|
||||
import io.rong.imkit.RongIM;
|
||||
import io.rong.imkit.config.ConversationListBehaviorListener;
|
||||
import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imkit.conversation.extension.RongExtensionManager;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.provider.PrivateConversationProvider;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
@ -32,6 +33,7 @@ import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.adapter.ProviderManager;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
import io.rong.sight.SightExtensionModule;
|
||||
|
||||
/**
|
||||
* 会话列表管理
|
||||
@ -52,6 +54,8 @@ public class ConversationIMListManager {
|
||||
ProviderManager<BaseUiConversation> providerManager = RongConfigCenter.conversationListConfig().getProviderManager();
|
||||
//用自定义模板替换 SDK 原有模板
|
||||
providerManager.replaceProvider(PrivateConversationProvider.class, new PDLiveCustomConversationProvider());
|
||||
//注册小视频模块
|
||||
RongExtensionManager.getInstance().registerExtensionModule(new SightExtensionModule());
|
||||
//会话列表监听事件
|
||||
RongIM.setConversationListBehaviorListener(listener);
|
||||
}
|
||||
|
89
main/src/main/res/values/rc_config.xml
Normal file
89
main/src/main/res/values/rc_config.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- 设置聊天室一次拉取消息数目 设置0默认拉取10条,设置-1默认不拉取,其他值为拉取自定义条数 -->
|
||||
<integer name="rc_chatroom_first_pull_message_count">10</integer>
|
||||
|
||||
<!-- 设置在会话列表或会话页面是否显示“连接状态”的提示 -->
|
||||
<bool name="rc_is_show_warning_notification">true</bool>
|
||||
|
||||
<!-- 设置未听的语音消息,是否连续播放 -->
|
||||
<bool name="rc_play_audio_continuous">true</bool>
|
||||
|
||||
<!-- 进入客服会话,弹出评价菜单超时时间(单位:秒)-->
|
||||
<!-- 设置为 0 时,任何时候离开客服会话时,都会弹出评价菜单-->
|
||||
<!-- <integer name="rc_custom_service_evaluation_interval">60</integer>-->
|
||||
|
||||
<!-- 退出客服页面是否关闭客服 -->
|
||||
<!-- <bool name="rc_stop_custom_service_when_quit">true</bool>-->
|
||||
|
||||
<!-- 默认图片保存路径,在会话界面查看大图,长按时选择保存,会使用这个配置-->
|
||||
<string name="rc_image_default_saved_path">/RongCloud/Image/</string>
|
||||
|
||||
<!-- 默认视频保存路径,在会话界面查看,长按时选择保存,会使用这个配置-->
|
||||
<string name="rc_video_default_saved_path">/RongCloud/Video/</string>
|
||||
|
||||
<!-- 默认文件保存路径,在会话界面查看,长按时选择保存,会使用这个配置-->
|
||||
<string name="rc_file_default_saved_path">/RongCloud/File/</string>
|
||||
|
||||
<!-- 设置是否支持消息撤回-->
|
||||
<bool name="rc_enable_message_recall">true</bool>
|
||||
<!-- 消息撤回有效时间(单位:秒)-->
|
||||
<integer name="rc_message_recall_interval">120</integer>
|
||||
<!-- 消息撤回重新编辑有效时间(单位:秒)-->
|
||||
<integer name="rc_message_recall_edit_interval">300</integer>
|
||||
|
||||
<!-- 是否打开 @ 功能-->
|
||||
<bool name="rc_enable_mentioned_message">true</bool>
|
||||
|
||||
<!-- 设置已读回执,目前仅支持单聊、群聊、讨论组 -->
|
||||
<bool name="rc_read_receipt">true</bool>
|
||||
|
||||
<!-- 设置已读回执有效时间(单位:秒)-->
|
||||
<integer name="rc_read_receipt_request_interval">120</integer>
|
||||
|
||||
<!-- 开启之后,用户在其他端上阅读过的消息,当前客户端会清掉该消息的未读数。目前仅支持单聊、群聊、讨论组。-->
|
||||
<bool name="rc_enable_sync_read_status">true</bool>
|
||||
|
||||
<!--WebView 是否忽略 SSL 证书错误检测-->
|
||||
<!-- <bool name="rc_open_https_certificate">false</bool>-->
|
||||
|
||||
<bool name="rc_location_2D">false</bool>
|
||||
|
||||
<!--PictureSelectorActivity 选择媒体资源时,是否包含视频文件 -->
|
||||
<bool name="rc_media_selector_contain_video">true</bool>
|
||||
|
||||
<!--进入会话或会话列表界面,是否清除通知栏通知-->
|
||||
<bool name="rc_wipe_out_notification_message">true</bool>
|
||||
|
||||
|
||||
<!--是否允许 WebView 加载 JavaScript-->
|
||||
<bool name="rc_set_java_script_enabled">true</bool>
|
||||
|
||||
<!--在线时是否自动下载高质量语音消息-->
|
||||
<bool name="rc_enable_automatic_download_voice_msg">true</bool>
|
||||
|
||||
<!--gif 自动下载的最大值, 超过就需点击手动下载(单位 KB)-->
|
||||
<integer name="rc_gifmsg_auto_download_size">1024</integer>
|
||||
|
||||
<!--是否启用阅后即焚插件-->
|
||||
<bool name="rc_open_destruct_plugin">false</bool>
|
||||
|
||||
<!--多选时,最大多选消息数 -->
|
||||
<integer name="rc_max_message_selected_count">100</integer>
|
||||
|
||||
<!--是否开启合并转发功能,默认关闭 -->
|
||||
<bool name="rc_enable_send_combine_message">false</bool>
|
||||
|
||||
<!--在前台非会话页面时,接收到新消息是否响铃 -->
|
||||
<bool name="rc_sound_in_foreground">true</bool>
|
||||
|
||||
<!--会话页面右上角的未读 @ 消息数提示,当收到的消息中有 @ 消息时,进入会话之后,是否在右上角提示未读 @ 消息数-->
|
||||
<bool name="rc_enable_unread_mention">true</bool>
|
||||
|
||||
<!-- 进入会话界面,默认拉取历史消息数量 -->
|
||||
<integer name="rc_conversation_history_message_count">10</integer>
|
||||
<!-- 进入会话界面,默认拉取远端历史消息数量 -->
|
||||
<integer name="rc_conversation_remote_message_count">10</integer>
|
||||
<!-- 进入会话界面,默认显示未读消息数量 -->
|
||||
<integer name="rc_conversation_show_unread_message_count">10</integer>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user