Commit 8d31a7ce by 霍志良

feat:消息免打扰状态

parent a4ded454
...@@ -3,12 +3,11 @@ package com.yidianling.im.ui.page.fragment.view ...@@ -3,12 +3,11 @@ package com.yidianling.im.ui.page.fragment.view
import android.content.Context import android.content.Context
import android.text.Html import android.text.Html
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.RelativeLayout import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.team.TeamService
import com.ydl.ydl_image.module.GlideApp import com.ydl.ydl_image.module.GlideApp
import com.yidianling.im.R import com.yidianling.im.R
import com.yidianling.im.helper.MsgReceiveHelper
import com.yidianling.im.preference.ImTempData import com.yidianling.im.preference.ImTempData
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import kotlinx.android.synthetic.main.im_chat_item_view.view.* import kotlinx.android.synthetic.main.im_chat_item_view.view.*
...@@ -80,21 +79,50 @@ class ChatItemView(mContext: Context) : LinearLayout(mContext) { ...@@ -80,21 +79,50 @@ class ChatItemView(mContext: Context) : LinearLayout(mContext) {
chat_message_content.text = bean.content chat_message_content.text = bean.content
} }
if (bean.unReadNum > 99) {
chat_message_unread_num.visibility = View.VISIBLE
chat_message_unread_num.text = "99+"
} else if (bean.unReadNum > 0) {
chat_message_unread_num.visibility = View.VISIBLE
chat_message_unread_num.text = "${bean.unReadNum}"
} else {
chat_message_unread_num.visibility = View.GONE
}
if (bean.is_top == 1) { if (bean.is_top == 1) {
chat_global_ll.setBackgroundResource(R.drawable.im_chat_is_top_bg) chat_global_ll.setBackgroundResource(R.drawable.im_chat_is_top_bg)
} else { } else {
chat_global_ll.setBackgroundResource(0) chat_global_ll.setBackgroundResource(0)
} }
//如果是群聊 根据免打扰状态判断逻辑
if (bean.chat_type==2){
val notifyType = NIMClient.getService(TeamService::class.java)
.queryTeamBlock(bean.toUid.toString()).messageNotifyType.value // 群消息提醒
if (notifyType==0){
//有消息提醒
not_disturb.visibility=View.GONE
if (bean.unReadNum > 99) {
chat_message_unread_num.visibility = View.VISIBLE
chat_message_unread_num.text = "99+"
} else if (bean.unReadNum > 0) {
chat_message_unread_num.visibility = View.VISIBLE
chat_message_unread_num.text = "${bean.unReadNum}"
} else {
chat_message_unread_num.visibility = View.GONE
}
}else{
not_disturb.visibility=View.VISIBLE
if (bean.unReadNum > 0){
chat_message_unread_num.visibility=View.VISIBLE
chat_message_unread_num.text=""
}else{
chat_message_unread_num.visibility = View.GONE
}
}
}else{
if (bean.unReadNum > 99) {
chat_message_unread_num.visibility = View.VISIBLE
chat_message_unread_num.text = "99+"
} else if (bean.unReadNum > 0) {
chat_message_unread_num.visibility = View.VISIBLE
chat_message_unread_num.text = "${bean.unReadNum}"
} else {
chat_message_unread_num.visibility = View.GONE
}
not_disturb.visibility=View.GONE
}
} }
} }
......
...@@ -10,11 +10,13 @@ import androidx.annotation.Nullable; ...@@ -10,11 +10,13 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService; import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum; import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage; import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.netease.nimlib.sdk.team.TeamService; import com.netease.nimlib.sdk.team.TeamService;
import com.netease.nimlib.sdk.team.constant.TeamMemberType; import com.netease.nimlib.sdk.team.constant.TeamMemberType;
import com.netease.nimlib.sdk.team.constant.TeamMessageNotifyTypeEnum;
import com.netease.nimlib.sdk.team.model.Team; import com.netease.nimlib.sdk.team.model.Team;
import com.netease.nimlib.sdk.team.model.TeamMember; import com.netease.nimlib.sdk.team.model.TeamMember;
import com.ydl.ydlcommon.data.http.RxUtils; import com.ydl.ydlcommon.data.http.RxUtils;
...@@ -95,10 +97,17 @@ public class YDLTeamMessageFragment extends YDLMessageFragment { ...@@ -95,10 +97,17 @@ public class YDLTeamMessageFragment extends YDLMessageFragment {
public void onClick(View view, boolean isActive) { public void onClick(View view, boolean isActive) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
int notifyType = NIMClient.getService(TeamService.class).queryTeamBlock(sessionId).getMessageNotifyType().getValue(); // 群消息提醒
// if (ImConstants.KEFUXIAOYI.equals(toChatUsername) || "4108805".equals(toChatUsername)) { // if (ImConstants.KEFUXIAOYI.equals(toChatUsername) || "4108805".equals(toChatUsername)) {
// list.add("历史聊天记录"); // list.add("历史聊天记录");
// list.add("客服热线"); // list.add("客服热线");
// } else { // } else {
if (notifyType==0){
list.add("关闭群消息提醒");
}else{
list.add("开启群消息提醒");
}
list.add("投诉反馈"); list.add("投诉反馈");
// //
// list.add("历史聊天记录"); // list.add("历史聊天记录");
...@@ -115,6 +124,10 @@ public class YDLTeamMessageFragment extends YDLMessageFragment { ...@@ -115,6 +124,10 @@ public class YDLTeamMessageFragment extends YDLMessageFragment {
public void onItemClick(Dialog dialog, View view, int position) { public void onItemClick(Dialog dialog, View view, int position) {
LogHelper.Companion.getInstance().writeLogSync(String.format("聊天界面:%s", list.get(position))); LogHelper.Companion.getInstance().writeLogSync(String.format("聊天界面:%s", list.get(position)));
switch (list.get(position)) { switch (list.get(position)) {
case "开启群消息提醒":
case "关闭群消息提醒":
OpenCloseTeamMute(notifyType);
break;
case "投诉反馈": case "投诉反馈":
ImIn.INSTANCE.feedBackIntent((Activity) getContext()); ImIn.INSTANCE.feedBackIntent((Activity) getContext());
break; break;
...@@ -149,6 +162,31 @@ public class YDLTeamMessageFragment extends YDLMessageFragment { ...@@ -149,6 +162,31 @@ public class YDLTeamMessageFragment extends YDLMessageFragment {
}); });
} }
private void OpenCloseTeamMute(int notifyType) {
TeamMessageNotifyTypeEnum type = TeamMessageNotifyTypeEnum.All;
if (notifyType ==0){
type = TeamMessageNotifyTypeEnum.Mute;
}
NIMClient.getService(TeamService.class).muteTeam(team.getId(), type).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
ToastUtil.toastShort("成功");
// 设置成功
}
@Override
public void onFailed(int code) {
ToastUtil.toastShort(code+"");
// 设置失败
}
@Override
public void onException(Throwable exception) {
// 错误
}
});
}
public void onEventMainThread(ChatGroupStatusEvent event){ public void onEventMainThread(ChatGroupStatusEvent event){
getChatGroupMute(); getChatGroupMute();
} }
......
...@@ -112,19 +112,42 @@ ...@@ -112,19 +112,42 @@
android:textColor="#999999" android:textColor="#999999"
android:textSize="11dp" /> android:textSize="11dp" />
</LinearLayout> </LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
<TextView android:layout_width="match_parent"
android:id="@+id/chat_message_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="18dp" android:orientation="horizontal"
android:layout_marginRight="35dp" android:gravity="center"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:ellipsize="end" >
android:maxLines="1" <TextView
android:text="你好,请问你遇到了什么烦恼?我可你好,请问你遇到了什么烦恼?我可以帮…" android:id="@+id/chat_message_content"
android:textColor="#999999" android:layout_width="0dp"
android:textSize="14dp" /> android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/not_disturb"
android:layout_marginEnd="@dimen/platform_dp_10"
android:layout_marginBottom="18dp"
android:ellipsize="end"
android:includeFontPadding="false"
android:layout_toLeftOf="@id/not_disturb"
android:maxLines="1"
android:text="你好,请问你遇到了什么烦恼?我可你好,请问你遇到了什么烦恼?我可以帮…"
android:textColor="#999999"
android:textSize="14dp" />
<ImageView
android:layout_width="@dimen/platform_dp_15"
android:layout_height="@dimen/platform_dp_15"
android:src="@drawable/team_not_disturb"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/chat_message_content"
app:layout_constraintBottom_toBottomOf="@id/chat_message_content"
android:id="@+id/not_disturb"
android:visibility="gone"
>
</ImageView>
</androidx.constraintlayout.widget.ConstraintLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -102,11 +102,13 @@ public class DefaultFormatPrinter { ...@@ -102,11 +102,13 @@ public class DefaultFormatPrinter {
final String responseBody = LINE_SEPARATOR + BODY_TAG + LINE_SEPARATOR + bodyString; final String responseBody = LINE_SEPARATOR + BODY_TAG + LINE_SEPARATOR + bodyString;
final String tag = getTag(false); final String tag = getTag(false);
final String[] urlLine = {URL_TAG + responseUrl, N}; final String[] urlLine = {URL_TAG + responseUrl, N};
NetLogUtils.debugInfo(tag, RESPONSE_UP_LINE); if (!responseUrl.contains("writeMaiDianData")){
logLines(tag, urlLine, true); NetLogUtils.debugInfo(tag, RESPONSE_UP_LINE);
logLines(tag, getResponse(headers, chainMs, code, isSuccessful, segments, message), true); logLines(tag, urlLine, true);
logLines(tag, responseBody.split(LINE_SEPARATOR), true); logLines(tag, getResponse(headers, chainMs, code, isSuccessful, segments, message), true);
NetLogUtils.debugInfo(tag, END_LINE); logLines(tag, responseBody.split(LINE_SEPARATOR), true);
NetLogUtils.debugInfo(tag, END_LINE);
}
} }
/** /**
...@@ -125,12 +127,13 @@ public class DefaultFormatPrinter { ...@@ -125,12 +127,13 @@ public class DefaultFormatPrinter {
@NonNull List<String> segments, @NonNull String message, @NonNull final String responseUrl) { @NonNull List<String> segments, @NonNull String message, @NonNull final String responseUrl) {
final String tag = getTag(false); final String tag = getTag(false);
final String[] urlLine = {URL_TAG + responseUrl, N}; final String[] urlLine = {URL_TAG + responseUrl, N};
NetLogUtils.debugInfo(tag, RESPONSE_UP_LINE); if (!responseUrl.contains("writeMaiDianData")){
logLines(tag, urlLine, true); NetLogUtils.debugInfo(tag, RESPONSE_UP_LINE);
logLines(tag, getResponse(headers, chainMs, code, isSuccessful, segments, message), true); logLines(tag, urlLine, true);
logLines(tag, OMITTED_RESPONSE, true); logLines(tag, getResponse(headers, chainMs, code, isSuccessful, segments, message), true);
NetLogUtils.debugInfo(tag, END_LINE); logLines(tag, OMITTED_RESPONSE, true);
NetLogUtils.debugInfo(tag, END_LINE);
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment