diff --git a/common/src/main/java/com/yunbao/common/bean/ImUserInfoModel.java b/common/src/main/java/com/yunbao/common/bean/ImUserInfoModel.java new file mode 100644 index 000000000..daf6510d2 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/ImUserInfoModel.java @@ -0,0 +1,141 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +/** + * r融雲發送的系統消息通知 + */ +public class ImUserInfoModel extends BaseModel { + @SerializedName("title") + String title;// + @SerializedName("image") + String image;//头像 + @SerializedName("content") + String content;//最新一条内容 + @SerializedName("addtime") + String addtime;//最后时间 + @SerializedName("num") + String num;//未读消息数 + @SerializedName("link") + String link;//跳转连接 + @SerializedName("type") + String type;// + @SerializedName("userId") + String userId;//单聊的id + @SerializedName("remarks") + String remarks;//备注的信息 + @SerializedName("is_admin") + String isAdmin; + @SerializedName("isDelet") + String isDelet; + @SerializedName("_method_") + String method="";//融雲消息類型 + + public String getTitle() { + return title; + } + + public ImUserInfoModel setTitle(String title) { + this.title = title; + return this; + } + + public String getImage() { + return image; + } + + public ImUserInfoModel setImage(String image) { + this.image = image; + return this; + } + + public String getContent() { + return content; + } + + public ImUserInfoModel setContent(String content) { + this.content = content; + return this; + } + + public String getAddtime() { + return addtime; + } + + public ImUserInfoModel setAddtime(String addtime) { + this.addtime = addtime; + return this; + } + + public String getNum() { + return num; + } + + public ImUserInfoModel setNum(String num) { + this.num = num; + return this; + } + + public String getLink() { + return link; + } + + public ImUserInfoModel setLink(String link) { + this.link = link; + return this; + } + + public String getType() { + return type; + } + + public ImUserInfoModel setType(String type) { + this.type = type; + return this; + } + + public String getUserId() { + return userId; + } + + public ImUserInfoModel setUserId(String userId) { + this.userId = userId; + return this; + } + + public String getRemarks() { + return remarks; + } + + public ImUserInfoModel setRemarks(String remarks) { + this.remarks = remarks; + return this; + } + + public String getIsAdmin() { + return isAdmin; + } + + public ImUserInfoModel setIsAdmin(String isAdmin) { + this.isAdmin = isAdmin; + return this; + } + + public String getIsDelet() { + return isDelet; + } + + public ImUserInfoModel setIsDelet(String isDelet) { + this.isDelet = isDelet; + return this; + } + + public String getMethod() { + return method; + } + + public ImUserInfoModel setMethod(String method) { + this.method = method; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java index dd1f125b9..1c2484c15 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java @@ -3,21 +3,30 @@ package com.yunbao.common.manager.imrongcloud; import android.content.Context; import android.os.Handler; import android.text.TextUtils; +import android.view.View; import com.alibaba.fastjson.JSON; +import com.google.gson.Gson; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.ImUserInfoModel; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.ToastUtil; import org.greenrobot.eventbus.EventBus; import java.util.Arrays; import java.util.List; +import io.rong.imkit.IMCenter; +import io.rong.imkit.config.ConversationClickListener; import io.rong.imkit.manager.UnReadMessageManager; import io.rong.imlib.model.Conversation; +import io.rong.imlib.model.Message; +import io.rong.imlib.model.UserInfo; +import io.rong.message.TextMessage; /** * 消息的监听管理 @@ -85,7 +94,7 @@ public class MessageIMManager { List listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class); if (listUserBean != null && listUserBean.size() >= 2) { //目前就三条消息,需求判断前两条消息是否有未读消息 - for (int i = 0; i < listUserBean.size() - 2; i++) { + for (int i = 0; i < listUserBean.size(); i++) { //消息对象 IMLoginModel userBean = listUserBean.get(i); //未读消息数 @@ -94,7 +103,7 @@ public class MessageIMManager { try { if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) { systemNumber = Integer.parseInt(number); - }else { + } else { systemNumber = 0; } } catch (NumberFormatException e) { @@ -109,6 +118,30 @@ public class MessageIMManager { }); } + /** + * 融雲發送的系統消息 + * + * @param message + */ + public void getSystemForRongcloud(Message message) { + ImUserInfoModel model = null; + if ((message.getConversationType() == Conversation.ConversationType.SYSTEM) && (message.getContent() instanceof TextMessage)) { + TextMessage content = (TextMessage) message.getContent(); + String json = content.getContent(); + model = new Gson().fromJson(json, ImUserInfoModel.class); + } + if (message.getConversationType() == Conversation.ConversationType.SYSTEM && model != null && TextUtils.equals(model.getMethod(), "LivePK_UnreadCount")) { + //发送通知 + EventBus.getDefault().post(model); + try { + systemNumber = systemNumber + 1; + unreadMessagesHandler.post(essagesRunnable); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + } + } + /** * 获取系统消息(有未读数展示红点) */ @@ -127,7 +160,7 @@ public class MessageIMManager { List listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class); if (listUserBean != null && listUserBean.size() >= 2) { //目前就三条消息,需求判断前两条消息是否有未读消息 - for (int i = 0; i < listUserBean.size() - 2; i++) { + for (int i = 0; i < listUserBean.size(); i++) { //消息对象 IMLoginModel userBean = listUserBean.get(i); //未读消息数 @@ -136,7 +169,7 @@ public class MessageIMManager { try { if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) { systemNumber = Integer.parseInt(number); - }else { + } else { systemNumber = 0; } } catch (NumberFormatException e) { @@ -164,4 +197,50 @@ public class MessageIMManager { EventBus.getDefault().post(new MessageIMEvent().setNumber(number)); }; + /** + * 设置会话界面操作监听器 + */ + public void addConversationClickListener() { + IMCenter.setConversationClickListener(listener); + } + + /** + * 会话界面操作监听器 + */ + private ConversationClickListener listener = new ConversationClickListener() { + @Override + public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String s) { + return false; + } + + @Override + public boolean onUserPortraitLongClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String s) { + return false; + } + + @Override + public boolean onMessageClick(Context context, View view, Message message) { + return false; + } + + /** + * 长按消息时。 + */ + @Override + public boolean onMessageLongClick(Context context, View view, Message message) { + + ToastUtil.show(message.getContent().toString()); + return true; + } + + @Override + public boolean onMessageLinkClick(Context context, String s, Message message) { + return false; + } + + @Override + public boolean onReadReceiptStateClick(Context context, Message message) { + return false; + } + }; } diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 11b0d5d05..da56ec69f 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -827,4 +827,5 @@ 前往「個人中心」-「我的包裹」中,即可使用熱度卡。 熱度卡生效多久? 對指定主播使用熱度卡後,將會立即生效,效果時長為24小時,不管主播是否在線,熱度時長都將會持續減少 + 引用 diff --git a/config.gradle b/config.gradle index eddca7244..53e2161f5 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式 - serverHost : "https://napi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", //測試 -// serverHost : "https://ceshi.yaoulive.com", + serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml index 4c61ad7ce..263ecc166 100644 --- a/live/src/main/AndroidManifest.xml +++ b/live/src/main/AndroidManifest.xml @@ -76,21 +76,20 @@ + + - + android:windowSoftInputMode="stateAlwaysHidden|adjustResize"/> - + android:theme="@style/DialogActivity"/> diff --git a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java index fbe802527..eaf92435d 100644 --- a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java @@ -23,9 +23,12 @@ import com.yunbao.common.activity.SelectImageActivity; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.ImageEntity; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.live.R; import com.yunbao.live.bean.SearchUserBean; import com.yunbao.live.dialog.MenuPopuwWindow; +import com.yunbao.live.event.InputPanelViewHolderEvent; +import com.yunbao.live.utils.WindowSoftModeAdjustResizeExecutor; import com.yunbao.live.views.InputPanelViewHolder; import com.yunbao.live.views.PDLiveConversationFragment; @@ -65,9 +68,12 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl super.main(); EventBus.getDefault().register(this); mContext = this; -// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); initView(); initData(); + WindowSoftModeAdjustResizeExecutor.assistActivity(this); + //设置会话界面操作监听器 + MessageIMManager.get(this).addConversationClickListener(); } /** @@ -79,20 +85,26 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl inputPanel.setTargetId(targetId); //获取用户信息 UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId); - titleView.setText(userInfo.getName()); - if (!TextUtils.isEmpty(userInfo.getExtra())) { - SearchUserBean userBean = GsonUtils.fromJson(userInfo.getExtra(), SearchUserBean.class); - //新手指导员 - if (!TextUtils.isEmpty(userBean.getIs_admin()) && TextUtils.equals(userBean.getIs_admin(), "1")) { - isAdmin = true; - imgMore.setVisibility(View.GONE); - } else {//非指导员 - isAdmin = false; - imgMore.setVisibility(View.VISIBLE); + if (null!=userInfo){ + titleView.setText(userInfo.getName()); + if (!TextUtils.isEmpty(userInfo.getExtra())) { + SearchUserBean userBean = GsonUtils.fromJson(userInfo.getExtra(), SearchUserBean.class); + //新手指导员 + if (!TextUtils.isEmpty(userBean.getIs_admin()) && TextUtils.equals(userBean.getIs_admin(), "1")) { + isAdmin = true; + imgMore.setVisibility(View.GONE); + } else {//非指导员 + isAdmin = false; + imgMore.setVisibility(View.VISIBLE); + } + Log.e("PDLiveConversation", userInfo.getExtra()); } - Log.e("PDLiveConversation", userInfo.getExtra()); + }else { + titleView.setText("系統消息"); + inputPanel.setVisibility(View.GONE); } + } /** @@ -204,4 +216,13 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl titleView.setText(event); } } + + //消息中心 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onInputPanelViewHolderEvent(InputPanelViewHolderEvent event) { + ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); + inputPanel.hidePluginList(); + } + + } diff --git a/live/src/main/java/com/yunbao/live/bean/ImUserBean.java b/live/src/main/java/com/yunbao/live/bean/ImUserBean.java index 7b5e56890..4877313c1 100644 --- a/live/src/main/java/com/yunbao/live/bean/ImUserBean.java +++ b/live/src/main/java/com/yunbao/live/bean/ImUserBean.java @@ -1,11 +1,8 @@ package com.yunbao.live.bean; -import android.os.Parcel; -import android.os.Parcelable; import android.text.TextUtils; -import com.alibaba.fastjson.annotation.JSONField; -import com.yunbao.common.bean.UserBean; +import com.yunbao.common.bean.BaseModel; import java.text.SimpleDateFormat; import java.util.Date; @@ -15,7 +12,8 @@ import java.util.Date; * IM 聊天用户 实体类 */ -public class ImUserBean { +public class ImUserBean extends BaseModel { + String title;// String image;//头像 @@ -28,100 +26,121 @@ public class ImUserBean { String remarks;//备注的信息 String is_admin; String isDelet; - - public String getIsDelet() { - return isDelet; - } - - public void setIsDelet(String isDelet) { - this.isDelet = isDelet; - } - - public String getIs_admin() { - return is_admin; - } - - public void setIs_admin(String is_admin) { - this.is_admin = is_admin; - } - - public String getRemarks() { - return remarks; - } - - public void setRemarks(String remarks) { - this.remarks = remarks; - } + String _method_ = "";//融雲消息類型 public String getTitle() { return title; } - public void setTitle(String title) { + public ImUserBean setTitle(String title) { this.title = title; + return this; } public String getImage() { return image; } - public void setImage(String image) { + public ImUserBean setImage(String image) { this.image = image; + return this; } public String getContent() { return content; } - public void setContent(String content) { + public ImUserBean setContent(String content) { this.content = content; + return this; } public String getAddtime() { return addtime; } - public void setAddtime(String addtime) { + public ImUserBean setAddtime(String addtime) { this.addtime = addtime; + return this; } public String getNum() { return num; } - public void setNum(String num) { + public ImUserBean setNum(String num) { this.num = num; + return this; } public String getLink() { return link; } - public void setLink(String link) { + public ImUserBean setLink(String link) { this.link = link; + return this; } public String getType() { return type; } - public void setType(String type) { + public ImUserBean setType(String type) { this.type = type; + return this; } public String getUserId() { return userId; } - public void setUserId(String userId) { + public ImUserBean setUserId(String userId) { this.userId = userId; + return this; + } + + public String getRemarks() { + return remarks; + } + + public ImUserBean setRemarks(String remarks) { + this.remarks = remarks; + return this; + } + + public String getIs_admin() { + return is_admin; + } + + public ImUserBean setIs_admin(String is_admin) { + this.is_admin = is_admin; + return this; + } + + public String getIsDelet() { + return isDelet; + } + + public ImUserBean setIsDelet(String isDelet) { + this.isDelet = isDelet; + return this; + } + + public String get_method_() { + return _method_; + } + + public ImUserBean set_method_(String _method_) { + this._method_ = _method_; + return this; } /** * 会话列表展示时间 */ public String getLastDate() { - if (!TextUtils.isEmpty(addtime)&&!TextUtils.equals(addtime,"0")) { + if (!TextUtils.isEmpty(addtime) && !TextUtils.equals(addtime, "0")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date currenTimeZone; if (TextUtils.equals(type, "-1")) { @@ -135,4 +154,18 @@ public class ImUserBean { } } + + public String addNumber(int index) { + String number; + if (TextUtils.isEmpty(num)) { + number = String.valueOf(index); + } else { + try { + number = String.valueOf(Integer.parseInt(num) + index); + } catch (NumberFormatException e) { + number = String.valueOf(index); + } + } + return number; + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/MessageLongClickPopuwindow.java b/live/src/main/java/com/yunbao/live/dialog/MessageLongClickPopuwindow.java new file mode 100644 index 000000000..6a8d0c685 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/MessageLongClickPopuwindow.java @@ -0,0 +1,26 @@ +package com.yunbao.live.dialog; + +import android.app.Activity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.PopupWindow; + +import com.yunbao.live.R; + +/** + * 消息長按彈窗 + */ +public class MessageLongClickPopuwindow { + private Activity mContext; + private View popupView; + private PopupWindow popupWindow; + + public MessageLongClickPopuwindow(Activity context) { + this.mContext = context; + popupView = LayoutInflater.from(mContext).inflate(R.layout.view_message_long_click, null); + initView(); + } + + private void initView() { + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java index b2585f07b..e6bf05489 100644 --- a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java +++ b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java @@ -1,11 +1,15 @@ package com.yunbao.live.dialog; +import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import androidx.annotation.NonNull; import com.yunbao.live.R; +import com.yunbao.live.event.InputPanelViewHolderEvent; + +import org.greenrobot.eventbus.EventBus; import io.rong.imkit.conversation.MessageListAdapter; import io.rong.imkit.model.UiMessage; @@ -28,15 +32,22 @@ public class PDLiveMessageListAdapter extends MessageListAdapter { Message.SentStatus sentStatus = mDataList.get(position).getMessage().getSentStatus(); ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt); ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new); - if (readReceipt!=null&&readReceiptNew!=null){ + if (readReceipt != null && readReceiptNew != null) { if (readReceipt.getVisibility() == View.VISIBLE) { readReceipt.setVisibility(View.GONE); readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read); } else { - if (messageDirection.equals(Message.MessageDirection.SEND)&&sentStatus.equals(Message.SentStatus.SENT)) + if (messageDirection.equals(Message.MessageDirection.SEND) && sentStatus.equals(Message.SentStatus.SENT)) readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread); } } - + holder.getConvertView().setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //消費掉軟件盤和插件頁面 + EventBus.getDefault().post(new InputPanelViewHolderEvent()); + return true; + } + }); } } diff --git a/live/src/main/java/com/yunbao/live/event/InputPanelViewHolderEvent.java b/live/src/main/java/com/yunbao/live/event/InputPanelViewHolderEvent.java new file mode 100644 index 000000000..6e2a87c59 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/event/InputPanelViewHolderEvent.java @@ -0,0 +1,9 @@ +package com.yunbao.live.event; + +import com.yunbao.common.bean.BaseModel; + +/** + * 點擊聊天列表的消費 + */ +public class InputPanelViewHolderEvent extends BaseModel { +} diff --git a/live/src/main/java/com/yunbao/live/utils/WindowSoftModeAdjustResizeExecutor.java b/live/src/main/java/com/yunbao/live/utils/WindowSoftModeAdjustResizeExecutor.java new file mode 100644 index 000000000..4136bdeb9 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/utils/WindowSoftModeAdjustResizeExecutor.java @@ -0,0 +1,48 @@ +package com.yunbao.live.utils; + +import android.app.Activity; +import android.graphics.Rect; +import android.os.Build; +import android.view.View; +import android.widget.FrameLayout; + +public class WindowSoftModeAdjustResizeExecutor { + // For more information, see https://code.google.com/p/android/issues/detail?id=5497 + // To use this class, simply invoke assistActivity() on an Activity that already has its content view set. + // CREDIT TO Joseph Johnson (http://stackoverflow.com/users/341631/joseph-johnson) for publishing the original Android solution on stackoverflow.com + public static void assistActivity(Activity activity) { + new WindowSoftModeAdjustResizeExecutor(activity); + } + + private View mChildOfContent; + private int usableHeightPrevious; + private FrameLayout.LayoutParams frameLayoutParams; + + private WindowSoftModeAdjustResizeExecutor(Activity activity) { + FrameLayout content = activity.findViewById(android.R.id.content); + mChildOfContent = content.getChildAt(0); + mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(() -> WindowSoftModeAdjustResizeExecutor.this.possiblyResizeChildOfContent()); + frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams(); + } + + private void possiblyResizeChildOfContent() { + int usableHeightNow = computeUsableHeight(); + if (usableHeightNow != usableHeightPrevious) { + int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight(); + int heightDifference = usableHeightSansKeyboard - usableHeightNow; + frameLayoutParams.height = usableHeightSansKeyboard - heightDifference; + mChildOfContent.requestLayout(); + usableHeightPrevious = usableHeightNow; + } + } + + private int computeUsableHeight() { + Rect r = new Rect(); + mChildOfContent.getWindowVisibleDisplayFrame(r); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + return (r.bottom - r.top); + } + return r.bottom; + } + +} diff --git a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java index b054f9bb4..10c5036bb 100644 --- a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java @@ -78,21 +78,23 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi inputPanelView.findViewById(R.id.lt_photo_button).setOnClickListener(this); inputPanelView.findViewById(R.id.lt_choospic_button).setOnClickListener(this); inputPanelView.findViewById(R.id.lt_video_button).setOnClickListener(this); - editBtn.setOnFocusChangeListener(focusChangeListener); +// editBtn.setOnFocusChangeListener(focusChangeListener); } - //输入框焦点监听事件 - View.OnFocusChangeListener focusChangeListener = new OnFocusChangeListener() { - @Override - public void onFocusChange(View v, boolean hasFocus) { - if (!hasFocus) { - //失去焦点 - InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(editBtn, InputMethodManager.SHOW_FORCED); - imm.hideSoftInputFromWindow(editBtn.getWindowToken(), 0); //强制隐藏键盘 - } - } - }; +// //输入框焦点监听事件 +// View.OnFocusChangeListener focusChangeListener = new OnFocusChangeListener() { +// @Override +// public void onFocusChange(View v, boolean hasFocus) { +// if (!hasFocus&& pluginList.getVisibility()==GONE) { +// //失去焦点 +// InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); +// imm.showSoftInput(editBtn, InputMethodManager.SHOW_FORCED); +// imm.hideSoftInputFromWindow(editBtn.getWindowToken(), 0); //强制隐藏键盘 +// } else { +// pluginList.setVisibility(GONE); +// } +// } +// }; @Override public void onClick(View v) { @@ -106,6 +108,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi } else if (id == R.id.edit_btn) { if (pluginList.getVisibility() == VISIBLE) { pluginList.setVisibility(GONE); + editBtn.setFocusable(true); } } else if (id == R.id.lt_photo_button) { if (messageCallback != null) { @@ -129,11 +132,11 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi if (pluginList.getVisibility() == VISIBLE) { pluginList.setVisibility(GONE); } else { + pluginList.setVisibility(VISIBLE); + //失去焦点 InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editBtn, InputMethodManager.SHOW_FORCED); - imm.hideSoftInputFromWindow(editBtn.getWindowToken(), 0); //强制隐藏键盘 - pluginList.setVisibility(VISIBLE); } } @@ -205,7 +208,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi }; /** - * 发送媒体消息 + * 发送媒体消息 隱藏 * * @param imagePath */ @@ -303,4 +306,11 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi messageCallback = callback; } + /** + * 隱藏插件列表 + */ + public void hidePluginList() { + pluginList.setVisibility(GONE); + } + } diff --git a/live/src/main/res/layout/rc_conversationlist_item.xml b/live/src/main/res/layout/rc_conversationlist_item.xml index 8a781ed44..462eac0b1 100644 --- a/live/src/main/res/layout/rc_conversationlist_item.xml +++ b/live/src/main/res/layout/rc_conversationlist_item.xml @@ -74,13 +74,14 @@ android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" + android:gravity="center_vertical" app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl" app:layout_constraintTop_toBottomOf="@+id/rc_conversation_title"> diff --git a/live/src/main/res/layout/view_message_long_click.xml b/live/src/main/res/layout/view_message_long_click.xml new file mode 100644 index 000000000..8f8a5c0c7 --- /dev/null +++ b/live/src/main/res/layout/view_message_long_click.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/mipmap-xhdpi/icon_message_copy.png b/live/src/main/res/mipmap-xhdpi/icon_message_copy.png new file mode 100644 index 000000000..a3891be1d Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/icon_message_copy.png differ diff --git a/live/src/main/res/mipmap-xhdpi/icon_message_quote.png b/live/src/main/res/mipmap-xhdpi/icon_message_quote.png new file mode 100644 index 000000000..adf9ecd48 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/icon_message_quote.png differ diff --git a/live/src/main/res/mipmap-xhdpi/icon_messagelist_read.png b/live/src/main/res/mipmap-xhdpi/icon_messagelist_read.png new file mode 100644 index 000000000..0526042c8 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/icon_messagelist_read.png differ diff --git a/live/src/main/res/mipmap-xhdpi/icon_messagelist_unread.png b/live/src/main/res/mipmap-xhdpi/icon_messagelist_unread.png new file mode 100644 index 000000000..012b901b9 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/icon_messagelist_unread.png differ diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index dfcec733e..9d0d93f76 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -37,12 +37,10 @@ import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSDKConfig; import com.tencent.imsdk.v2.V2TIMSDKListener; import com.tencent.imsdk.v2.V2TIMUserFullInfo; - import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.adapter.ViewPagerAdapter; -import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.ChatRemarksBean; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.LiveSvgGiftBean; @@ -56,6 +54,7 @@ import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; @@ -72,7 +71,6 @@ import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.live.LiveConfig; import com.yunbao.live.activity.LiveAnchorActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; -import com.yunbao.live.activity.PDLIiveChatActivity; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.http.LiveHttpConsts; @@ -115,10 +113,8 @@ import java.util.Map; import cn.rongcloud.rtc.api.RCRTCConfig; import cn.rongcloud.rtc.api.RCRTCEngine; import io.rong.imlib.RongIMClient; -import io.rong.imlib.model.Conversation; import io.rong.message.TextMessage; -import static com.yunbao.common.CommonAppContext.Ingroup; import static com.yunbao.common.CommonAppContext.isReady; public class MainActivity extends AbsActivity implements MainAppBarLayoutListener { @@ -365,6 +361,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Override public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) { Log.e("wewe", message.getConversationType() + "112121"); + MessageIMManager.get(mContext).getSystemForRongcloud(message); //融云直播间聊天 Message msg = Message.obtain(); msg.what = Constants.SOCKET_WHAT_BROADCAST; @@ -1074,8 +1071,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene public void onMessageIMEvent(MessageIMEvent event) { messageNumber = event.getNumber(); if (event.getNumber() > 0) { + if (event.getNumber() > 99) { + v_table_redpoint.setText("99+"); + } else { + v_table_redpoint.setText(event.getNumber() + ""); + } v_table_redpoint.setVisibility(View.VISIBLE); - v_table_redpoint.setText(event.getNumber() + ""); + } else { v_table_redpoint.setVisibility(View.GONE); v_table_redpoint.setText(""); diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java index 7e67796f9..b515ac572 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java @@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.alibaba.fastjson.JSON; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.ImUserInfoModel; import com.yunbao.common.custom.TabButtonGroup; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.UpdateTablePointMe; @@ -51,6 +52,7 @@ public class PDLiveConversationListActivity extends AbsActivity { private long mLastClickBackTime;//上次点击back键的时间 private TextView redPoint; private View redpointMe; + private SystemMessageAdapter messageAdapter; @Override protected int getLayoutId() { @@ -143,7 +145,7 @@ public class PDLiveConversationListActivity extends AbsActivity { //初始化系统消息界面 View rootView = LayoutInflater.from(mContext).inflate(R.layout.view_system_message, null, true); RecyclerView systemMessageList = rootView.findViewById(R.id.system_message_list); - SystemMessageAdapter messageAdapter = new SystemMessageAdapter(mContext); + messageAdapter = new SystemMessageAdapter(mContext); messageAdapter.addDataAll(listUserBean); systemMessageList.setHasFixedSize(false); systemMessageList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true)); @@ -201,8 +203,13 @@ public class PDLiveConversationListActivity extends AbsActivity { public void onMessageIMEvent(MessageIMEvent event) { if (redPoint == null) return; if (event.getNumber() > 0) { + if (event.getNumber() > 99) { + redPoint.setText(String.valueOf("99+")); + } else { + redPoint.setText(String.valueOf(event.getNumber())); + } redPoint.setVisibility(View.VISIBLE); - redPoint.setText(String.valueOf(event.getNumber())); + } else { redPoint.setVisibility(View.GONE); redPoint.setText(""); @@ -219,4 +226,10 @@ public class PDLiveConversationListActivity extends AbsActivity { redpointMe.setVisibility(View.GONE); } } + + //更新系統消息 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onImUserInfoModel(ImUserInfoModel model) { + messageAdapter.upDataMessage(model); + } } diff --git a/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java index cb61b2266..4dbf42d3f 100644 --- a/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java @@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSON; import com.facebook.appevents.AppEventsLogger; import com.google.firebase.analytics.FirebaseAnalytics; import com.yunbao.common.activity.WebViewActivity; +import com.yunbao.common.bean.ImUserInfoModel; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.live.activity.SystemMessageActivity; @@ -55,7 +56,7 @@ public class SystemMessageAdapter extends RecyclerView.Adapter { SystemMessageViewHolder messageViewHolder = (SystemMessageViewHolder) holder; ImgLoader.displayWithError(mContext, model.getImage(), messageViewHolder.avatarImage, com.yunbao.live.R.mipmap.chat_head_mo); if (position == 2) { - messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getLink()) ? mContext.getResources().getString(R.string.chat_like) : model.getLink()); + messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getContent()) ? mContext.getResources().getString(R.string.chat_like) : model.getContent()); } else { if (position == 1) { messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getContent()) ? mContext.getResources().getString(R.string.chat_action_no) : model.getContent()); @@ -68,8 +69,15 @@ public class SystemMessageAdapter extends RecyclerView.Adapter { String number = model.getNum(); if (!TextUtils.isEmpty(number) && !TextUtils.equals(number, "0")) { + int index = Integer.parseInt(number); + if (index > 99) { + + messageViewHolder.redPoint.setText("99+"); + } else { + messageViewHolder.redPoint.setText(number); + } messageViewHolder.redPoint.setVisibility(View.VISIBLE); - messageViewHolder.redPoint.setText(number); + } else { messageViewHolder.redPoint.setVisibility(View.GONE); } @@ -79,7 +87,7 @@ public class SystemMessageAdapter extends RecyclerView.Adapter { MessageIMManager.get(mContext).getSystemMessages(new MessageIMManager.SystemMessagesHttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - if (code==0){ + if (code == 0) { List listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class); addSystemMessagesView(listUserBean); } @@ -145,6 +153,28 @@ public class SystemMessageAdapter extends RecyclerView.Adapter { listUserBean.clear(); listUserBean.addAll(mlistUserBean); notifyDataSetChanged(); + } + /** + * 更新系統數據 + */ + public void upDataMessage(ImUserInfoModel model) { + for (ImUserBean imUserBean : listUserBean) { + if (TextUtils.equals(imUserBean.getType(), model.getType())) { + imUserBean.setContent(model.getContent()) + .setIsDelet(model.getIsDelet()) + .setRemarks(model.getRemarks()) + .setIs_admin(model.getIsAdmin()) + .set_method_(model.getMethod()) + .setAddtime(model.getAddtime()) + .setImage(model.getImage()) + .setLink(model.getLink()) + .setNum(imUserBean.addNumber(1)) + .setTitle(model.getTitle()) + .setType(model.getType()) + .setUserId(model.getUserId()); + } + } + notifyDataSetChanged(); } } diff --git a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java index 36d5c7d98..8f2f869cc 100644 --- a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java +++ b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java @@ -124,7 +124,7 @@ public class ConversationIMListManager { CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { + if (code == 0 && info.length > 0&&!TextUtils.equals("__system__",userId)) { JSONObject obj = JSON.parseObject(info[0]); SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class); String userNiceName = ""; diff --git a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java index 829a01ded..74d3ec39d 100644 --- a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java +++ b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java @@ -1,8 +1,6 @@ package com.yunbao.main.utils; import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -10,12 +8,10 @@ import java.util.List; import io.rong.imkit.conversationlist.model.BaseUiConversation; import io.rong.imkit.conversationlist.provider.BaseConversationProvider; -import io.rong.imkit.utils.RouteUtils; import io.rong.imkit.widget.adapter.IViewProviderListener; import io.rong.imkit.widget.adapter.ViewHolder; import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Message; -import io.rong.imlib.model.UserInfo; /** * pdlive自定义会话模板 @@ -31,7 +27,7 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider { @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { //根据业务需要,自定义处理 - Log.e("PDLiveCustomConversat","------------------------------------------"+viewType); + Log.e("PDLiveCustomConversat", "------------------------------------------" + viewType); return super.onCreateViewHolder(parent, viewType); } @@ -41,14 +37,17 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider { //根据业务需要,自定义处理 super.bindViewHolder(holder, uiConversation, position, list, listener); - if ( list.size()>0){ + + if (list.size() > 0) { Message.ReceivedStatus receivedStatus = list.get(position).mCore.getReceivedStatus(); ImageView readReceipt = holder.itemView.findViewById(com.yunbao.live.R.id.rc_read_receipt_new); if (receivedStatus.isRead()) { - readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_unread); - }else { - readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_read); + readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_read); + } else { + readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_unread); } } + + } } diff --git a/main/src/main/res/layout/activity_conversation_list.xml b/main/src/main/res/layout/activity_conversation_list.xml index 6696e64ed..110a24518 100644 --- a/main/src/main/res/layout/activity_conversation_list.xml +++ b/main/src/main/res/layout/activity_conversation_list.xml @@ -129,10 +129,10 @@ diff --git a/main/src/main/res/layout/view_homemain.xml b/main/src/main/res/layout/view_homemain.xml index 554e7409d..9609f669e 100644 --- a/main/src/main/res/layout/view_homemain.xml +++ b/main/src/main/res/layout/view_homemain.xml @@ -107,12 +107,12 @@ diff --git a/main/src/main/res/layout/view_system_message_item.xml b/main/src/main/res/layout/view_system_message_item.xml index 0d14049b3..dfc6855ff 100644 --- a/main/src/main/res/layout/view_system_message_item.xml +++ b/main/src/main/res/layout/view_system_message_item.xml @@ -54,8 +54,8 @@