私聊违规提示优化
This commit is contained in:
@@ -13,6 +13,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -77,33 +78,30 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
|
||||
public static final String IS_BY_MATCH = "isByMatch";
|
||||
private static final String TAG = "NimP2PMessageActivity";
|
||||
OnlineStateChangeObserver onlineStateChangeObserver = new OnlineStateChangeObserver() {
|
||||
@Override
|
||||
public void onlineStateChange(Set<String> accounts) {
|
||||
// 更新 toolbar
|
||||
if (accounts.contains(sessionId)) {
|
||||
// 按照交互来展示
|
||||
displayOnlineState();
|
||||
}
|
||||
private final OnlineStateChangeObserver onlineStateChangeObserver = accounts -> {
|
||||
// 更新 toolbar
|
||||
if (accounts.contains(sessionId)) {
|
||||
// 按照交互来展示
|
||||
displayOnlineState();
|
||||
}
|
||||
};
|
||||
private boolean isResume = false;
|
||||
/**
|
||||
* 命令消息接收观察者
|
||||
*/
|
||||
Observer<CustomNotification> commandObserver = new Observer<CustomNotification>() {
|
||||
@Override
|
||||
public void onEvent(CustomNotification message) {
|
||||
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
||||
return;
|
||||
}
|
||||
showCommandMessage(message);
|
||||
private final Observer<CustomNotification> commandObserver = message -> {
|
||||
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
||||
return;
|
||||
}
|
||||
showCommandMessage(message);
|
||||
};
|
||||
private TextView ivAddBlackList;
|
||||
private TextView tvTips;
|
||||
private View tipsLayout;
|
||||
private ImageView closeIcon;
|
||||
ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
||||
@Nullable
|
||||
private UserInfo buddyUserInfo;
|
||||
private final ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
||||
@Override
|
||||
public void onAddedOrUpdatedFriends(List<String> accounts) {
|
||||
displayAntiFraudTips();
|
||||
@@ -156,7 +154,6 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
intent.putExtra(Extras.EXTRA_CUSTOMIZATION, NimUIKitImpl.commonP2PSessionCustomization);
|
||||
intent.setClass(context, NimP2PMessageActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
@@ -164,6 +161,13 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
tipsLayout = findViewById(R.id.rl_tips);
|
||||
closeIcon = findViewById(R.id.iv_close_tips);
|
||||
tvTips = findViewById(R.id.tv_tips);
|
||||
closeIcon.setOnClickListener(view -> {
|
||||
IMFriendModel.get().addCloseTipsAccount(sessionId);
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
});
|
||||
// 单聊特例话数据,包括个人信息,黑名单
|
||||
addBlackList();
|
||||
requestBuddyInfo();
|
||||
@@ -182,6 +186,7 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
//如果sessionId与之前的sessionId不是同一个,刷新数据
|
||||
if (!TextUtils.isEmpty(this.sessionId) && !this.sessionId.equals(sessionId)) {
|
||||
this.sessionId = sessionId;
|
||||
buddyUserInfo = null;
|
||||
requestBuddyInfo();
|
||||
displayOnlineState();
|
||||
displayAntiFraudTips();
|
||||
@@ -190,14 +195,12 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
}
|
||||
|
||||
private void displayAntiFraudTips() {
|
||||
tipsLayout = findViewById(R.id.rl_tips);
|
||||
closeIcon = findViewById(R.id.iv_close_tips);
|
||||
if (shouldDisplayAntiFraudTips()) {
|
||||
if (buddyUserInfo != null && buddyUserInfo.isBanAccount()) {
|
||||
tipsLayout.setVisibility(View.VISIBLE);
|
||||
closeIcon.setOnClickListener(view -> {
|
||||
IMFriendModel.get().addCloseTipsAccount(sessionId);
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
});
|
||||
tvTips.setText("温馨提醒:当前对方账号存在异常,请谨慎来往!");
|
||||
} else if (shouldDisplayAntiFraudTips()) {
|
||||
tipsLayout.setVisibility(View.VISIBLE);
|
||||
tvTips.setText("温馨提示:对方和您非好友关系,请注意隐私安全!");
|
||||
} else {
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -280,6 +283,8 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
if (AuthModel.get().getCurrentUid() != userInfo.getUid()) {
|
||||
PraiseModel.get().isPraised(AuthModel.get().getCurrentUid(), userInfo.getUid()).subscribe();
|
||||
}
|
||||
buddyUserInfo = userInfo;
|
||||
displayAntiFraudTips();
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -1,10 +1,21 @@
|
||||
package com.yizhuan.erban.ui.im.chat;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.yizhuan.erban.ui.webview.SimpleWebViewActivity;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
|
||||
|
||||
public class MsgViewHolderChatHint extends MsgViewHolderBase {
|
||||
@@ -44,7 +55,30 @@ public class MsgViewHolderChatHint extends MsgViewHolderBase {
|
||||
protected void bindContentView() {
|
||||
ChatHintAttachment attachment = (ChatHintAttachment) message.getAttachment();
|
||||
if (attachment != null) {
|
||||
tvContent.setText(attachment.getContent());
|
||||
String content = attachment.getContent();
|
||||
String restoreTitle = "《整治网络直播乱象》";
|
||||
if (TextUtils.isEmpty(content) || !content.contains(restoreTitle)) {
|
||||
tvContent.setText(content);
|
||||
} else {
|
||||
SpannableString ss = new SpannableString(content);
|
||||
int restoreTitleIndex = content.indexOf(restoreTitle);
|
||||
ss.setSpan(
|
||||
new ForegroundColorSpan(Color.parseColor("#FB486A")),
|
||||
restoreTitleIndex,
|
||||
restoreTitleIndex + restoreTitle.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
SimpleWebViewActivity.start(context, UriProvider.getLiveAgreement());
|
||||
}
|
||||
},
|
||||
restoreTitleIndex,
|
||||
restoreTitleIndex + restoreTitle.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
tvContent.setText(ss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -105,6 +105,7 @@
|
||||
android:background="@color/color_FEE4E4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
|
@@ -18,4 +18,5 @@
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="13sp"
|
||||
tools:text="您发送的消息中可能包含了您发送的消息中可能包含了您发送的消息中可能包含了您发送的消息中可能包含了" />
|
||||
|
||||
</FrameLayout>
|
@@ -478,4 +478,14 @@ public class UriProvider {
|
||||
public static String getLuckyGiftRule(int giftID) {
|
||||
return JAVA_WEB_URL.concat("/yinyou/modules/rule/luckyGiftRule.html?giftID=" + giftID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播乱象
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getLiveAgreement() {
|
||||
return JAVA_WEB_URL.concat("/yinyou/activity/activemodel/index.html?code=ZBGG");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -280,6 +280,10 @@ public class UserInfo implements Serializable {
|
||||
@Setter
|
||||
private long limitChargeEndTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean banAccount;
|
||||
|
||||
public UserInfo() {
|
||||
|
||||
}
|
||||
|
BIN
nim_uikit/res/drawable-xhdpi/nim_ic_failed.png
Normal file
BIN
nim_uikit/res/drawable-xhdpi/nim_ic_failed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 828 B |
@@ -104,8 +104,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/message_item_alert"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
|
@@ -2,6 +2,7 @@ package com.netease.nim.uikit.business.session.viewholder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -35,11 +36,7 @@ import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
*/
|
||||
public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItemFetchLoadAdapter, BaseViewHolder, IMMessage> {
|
||||
|
||||
public MsgViewHolderBase(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
public ImageView nameIconView;
|
||||
// basic
|
||||
protected View view;
|
||||
protected Context context;
|
||||
@@ -56,15 +53,16 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem
|
||||
protected FrameLayout contentContainer;
|
||||
protected LinearLayout nameContainer;
|
||||
protected TextView readReceiptTextView;
|
||||
|
||||
private HeadImageView avatarLeft;
|
||||
private HeadImageView avatarRight;
|
||||
|
||||
public ImageView nameIconView;
|
||||
|
||||
// contentContainerView的默认长按事件。如果子类需要不同的处理,可覆盖onItemLongClick方法
|
||||
// 但如果某些子控件会拦截触摸消息,导致contentContainer收不到长按事件,子控件也可在inflate时重新设置
|
||||
protected View.OnLongClickListener longClickListener;
|
||||
private HeadImageView avatarLeft;
|
||||
private HeadImageView avatarRight;
|
||||
|
||||
public MsgViewHolderBase(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
/// -- 以下接口可由子类覆盖或实现
|
||||
// 返回具体消息类型内容展示区域的layout res id
|
||||
@@ -233,6 +231,9 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem
|
||||
* 设置消息发送状态
|
||||
*/
|
||||
private void setStatus() {
|
||||
String AntiSpamRes = message.getYidunAntiSpamRes();
|
||||
//todo 要升级安全通道新版才有数据
|
||||
Log.d("setStatus", "AntiSpamRes=" + AntiSpamRes);
|
||||
MsgStatusEnum status = message.getStatus();
|
||||
switch (status) {
|
||||
case fail:
|
||||
|
Reference in New Issue
Block a user