Compare commits
7 Commits
release1.5
...
release_1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0e30b8e303 | ||
![]() |
3325ccaee9 | ||
![]() |
277c1a637e | ||
![]() |
8660f0e826 | ||
![]() |
dc46c16f3e | ||
![]() |
1dfa9e9d25 | ||
![]() |
5376774ab6 |
@@ -389,6 +389,7 @@ public class XChatApplication extends BaseApp {
|
||||
options.messageNotifierCustomization = messageNotifierCustomization;
|
||||
|
||||
options.appKey = Constants.nimAppKey;
|
||||
options.shouldConsiderRevokedMessageUnreadCount = true;
|
||||
|
||||
// 配置保存图片,文件,log 等数据的目录
|
||||
// 如果 options 中没有设置这个值,SDK 会使用下面代码示例中的位置作为 SDK 的数据目录。
|
||||
|
@@ -402,10 +402,10 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
}
|
||||
ImageView ivAvatar = contentView.findViewById(R.id.iv_avatar);
|
||||
TextView tvNickname = contentView.findViewById(R.id.tv_nickname);
|
||||
TextView tvContent = contentView.findViewById(R.id.tv_content);
|
||||
// TextView tvContent = contentView.findViewById(R.id.tv_content);
|
||||
ImageLoadUtils.loadAvatar(userInfo.getAvatar(), ivAvatar);
|
||||
tvNickname.setText(StringExtensionKt.subAndReplaceDot(userInfo.getName(), 4));
|
||||
tvContent.setText(ImHelperUtils.getMsgDigest(recentContact));
|
||||
// tvContent.setText(ImHelperUtils.getMsgDigest(recentContact));
|
||||
|
||||
contentView.setOnClickListener(v -> RoomMsgActivity.startForPrivateChat(getContext(), recentContact.getFromAccount()));
|
||||
int[] vLoc = new int[2];
|
||||
|
@@ -73,12 +73,27 @@ object LevelIconHelper : ILog {
|
||||
return null
|
||||
}
|
||||
// https://image.nnbc123.cn/charm_20.png
|
||||
val dotIndex = levelIconUrl.lastIndexOf('.')
|
||||
val separatorIndex = levelIconUrl.lastIndexOf('_') + 1
|
||||
if (dotIndex > 0 && separatorIndex > 0 && dotIndex > separatorIndex) {
|
||||
return levelIconUrl.substring(separatorIndex, dotIndex).toIntOrNull()
|
||||
// https://image.nnbc123.cn/charm_20_1.png
|
||||
val separatorIndex = levelIconUrl.lastIndexOf('/')
|
||||
if (separatorIndex == -1) {
|
||||
return null
|
||||
}
|
||||
return null
|
||||
var numberStart = levelIconUrl.indexOf('_', startIndex = separatorIndex)
|
||||
if (numberStart == -1) {
|
||||
return null
|
||||
}
|
||||
numberStart++
|
||||
if (numberStart >= levelIconUrl.length) {
|
||||
return null
|
||||
}
|
||||
var numberEnd = levelIconUrl.indexOf('_', startIndex = numberStart)
|
||||
if (numberEnd == -1) {
|
||||
numberEnd = levelIconUrl.indexOf('.', startIndex = numberStart)
|
||||
}
|
||||
if (numberEnd == -1) {
|
||||
return null
|
||||
}
|
||||
return levelIconUrl.substring(numberStart, numberEnd).toIntOrNull()
|
||||
}
|
||||
|
||||
private fun getLevelName(level: Int?): String? {
|
||||
|
@@ -830,17 +830,14 @@ public class MessageListPanelEx {
|
||||
if (messages == null) {
|
||||
return;
|
||||
}
|
||||
boolean isEmptyTextMessage = true;
|
||||
boolean textMessageIsEmpty = true;
|
||||
for (IMMessage message : messages) {
|
||||
if (message.getMsgType() == MsgTypeEnum.text) {
|
||||
String messageContext = message.getContent();
|
||||
if (!messageContext.equals("我对你很感兴趣并关注了你~快来和我成为好友一起玩吧")) {
|
||||
isEmptyTextMessage = false;
|
||||
break;
|
||||
}
|
||||
if (isValidMessageForChatLimit(message)) {
|
||||
textMessageIsEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
EventBus.getDefault().post(new MessageSizeEvent(isEmptyTextMessage));
|
||||
EventBus.getDefault().post(new MessageSizeEvent(textMessageIsEmpty));
|
||||
if (onMessageFilterListener != null) {
|
||||
messages = onMessageFilterListener.filterLoadedMessage(messages);
|
||||
}
|
||||
@@ -1294,4 +1291,29 @@ public class MessageListPanelEx {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 会话是空的?(仅为了聊天限制功能的判断)
|
||||
* @return
|
||||
*/
|
||||
public boolean isEmptySessionForChatLimit() {
|
||||
if (items == null) {
|
||||
return true;
|
||||
}
|
||||
for (IMMessage message : items) {
|
||||
if (isValidMessageForChatLimit(message)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isValidMessageForChatLimit(IMMessage message) {
|
||||
if (message == null) {
|
||||
return false;
|
||||
}
|
||||
if (message.getMsgType() == MsgTypeEnum.text) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@ import com.nnbc123.app.ui.webview.CommonWebViewActivity;
|
||||
import com.nnbc123.app.utils.PushMessageHandler;
|
||||
import com.nnbc123.core.UriProvider;
|
||||
import com.nnbc123.core.auth.AuthModel;
|
||||
import com.nnbc123.core.bean.PrivateChatLimitInfo;
|
||||
import com.nnbc123.core.im.chatterbox.ChatterBoxHelper;
|
||||
import com.nnbc123.core.im.chatterbox.HideInputEvent;
|
||||
import com.nnbc123.core.im.custom.bean.CustomAttachment;
|
||||
@@ -591,12 +592,7 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onReloadInputPanel(MessageSizeEvent event) {
|
||||
if (inputPanel != null) {
|
||||
if (!event.textMessageIsEmpty) {
|
||||
tvChatLimit.setVisibility(View.GONE);
|
||||
inputPanel.setLimitLevel(true, "");
|
||||
} else {
|
||||
loadChatLimit();
|
||||
}
|
||||
loadChatLimit(event.textMessageIsEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,61 +646,80 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
if (inputPanel == null) {
|
||||
return;
|
||||
}
|
||||
if (!inputPanel.getLimitLevel()) {
|
||||
loadChatLimit();
|
||||
if (messageListPanel == null) {
|
||||
return;
|
||||
}
|
||||
loadChatLimit(messageListPanel.isEmptySessionForChatLimit());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void loadChatLimit(){
|
||||
private void loadChatLimit(boolean sessionIsEmpty) {
|
||||
IMCustomModel.get().getPrivateChatLimit(sessionId).subscribe(((privateChatLimitInfo, throwable) -> {
|
||||
if (isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace();
|
||||
} else {
|
||||
isChat = privateChatLimitInfo.isChat();
|
||||
int model = privateChatLimitInfo.getModel();
|
||||
if (model == 2) {
|
||||
hintText = "互相关注成为好友可发起聊天";
|
||||
inputPanel.setLimitLevel(privateChatLimitInfo.isChat(), hintText);
|
||||
tvChatLimit.setText(hintText);
|
||||
tvChatLimit.setVisibility(isChat ? View.GONE : View.VISIBLE);
|
||||
} else {
|
||||
hintText = "暂未达到可发起私聊等级";
|
||||
inputPanel.setLimitLevel(privateChatLimitInfo.isChat(), hintText);
|
||||
String experLevel = "财富等级≥" + privateChatLimitInfo.getWealthLevel();
|
||||
String charmLevel = "魅力等级≥" + privateChatLimitInfo.getCharmLevel();
|
||||
String privacyAgreementDescTip = getContext().getString(R.string.text_chat_limit, experLevel, charmLevel);
|
||||
SpannableString ss = new SpannableString(privacyAgreementDescTip);
|
||||
int experLevelIndex = privacyAgreementDescTip.indexOf(experLevel);
|
||||
int charmLevelIndex = privacyAgreementDescTip.indexOf(charmLevel);
|
||||
|
||||
ss.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.appColor)), experLevelIndex, experLevelIndex + experLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new OriginalDrawStatusClickSpan(ContextCompat.getColor(getContext(), R.color.appColor)) {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (widget instanceof TextView)
|
||||
((TextView) widget).setHighlightColor(getResources().getColor(android.R.color.transparent));
|
||||
|
||||
CommonWebViewActivity.start(getContext(), UriProvider.getUserLevelUrl());
|
||||
}
|
||||
}, experLevelIndex, experLevelIndex + experLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.appColor)), charmLevelIndex, charmLevelIndex + charmLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new OriginalDrawStatusClickSpan(ContextCompat.getColor(getContext(), R.color.appColor)) {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (widget instanceof TextView)
|
||||
((TextView) widget).setHighlightColor(getResources().getColor(android.R.color.transparent));
|
||||
|
||||
CommonWebViewActivity.start(getContext(), UriProvider.getUserLevelUrl());
|
||||
}
|
||||
}, charmLevelIndex, charmLevelIndex + experLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
tvChatLimit.setText(ss);
|
||||
tvChatLimit.setHighlightColor(Color.TRANSPARENT);
|
||||
tvChatLimit.setMovementMethod(new LinkMovementMethod());
|
||||
tvChatLimit.setVisibility(isChat ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
} else if (privateChatLimitInfo != null) {
|
||||
loadChatLimit(privateChatLimitInfo, sessionIsEmpty);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void loadChatLimit(PrivateChatLimitInfo limitInfo, boolean sessionIsEmpty) {
|
||||
if (limitInfo == null) {
|
||||
return;
|
||||
}
|
||||
int model = limitInfo.getModel();
|
||||
if (model == 2) {
|
||||
isChat = limitInfo.isChat();
|
||||
hintText = "互相关注成为好友可发起聊天";
|
||||
inputPanel.setLimitLevel(isChat, hintText);
|
||||
tvChatLimit.setText(hintText);
|
||||
tvChatLimit.setVisibility(isChat ? View.GONE : View.VISIBLE);
|
||||
} else {
|
||||
if (!sessionIsEmpty || limitInfo.isChat()) {
|
||||
isChat = true;
|
||||
} else {
|
||||
isChat = false;
|
||||
}
|
||||
hintText = "暂未达到可发起私聊等级";
|
||||
inputPanel.setLimitLevel(isChat, hintText);
|
||||
tvChatLimit.setVisibility(isChat ? View.GONE : View.VISIBLE);
|
||||
if (!isChat) {
|
||||
String experLevel = "财富等级≥" + limitInfo.getWealthLevel();
|
||||
String charmLevel = "魅力等级≥" + limitInfo.getCharmLevel();
|
||||
String privacyAgreementDescTip = getContext().getString(R.string.text_chat_limit, experLevel, charmLevel);
|
||||
SpannableString ss = new SpannableString(privacyAgreementDescTip);
|
||||
int experLevelIndex = privacyAgreementDescTip.indexOf(experLevel);
|
||||
int charmLevelIndex = privacyAgreementDescTip.indexOf(charmLevel);
|
||||
|
||||
ss.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.appColor)), experLevelIndex, experLevelIndex + experLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new OriginalDrawStatusClickSpan(ContextCompat.getColor(getContext(), R.color.appColor)) {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (widget instanceof TextView)
|
||||
((TextView) widget).setHighlightColor(getResources().getColor(android.R.color.transparent));
|
||||
|
||||
CommonWebViewActivity.start(getContext(), UriProvider.getUserLevelUrl());
|
||||
}
|
||||
}, experLevelIndex, experLevelIndex + experLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.appColor)), charmLevelIndex, charmLevelIndex + charmLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new OriginalDrawStatusClickSpan(ContextCompat.getColor(getContext(), R.color.appColor)) {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (widget instanceof TextView)
|
||||
((TextView) widget).setHighlightColor(getResources().getColor(android.R.color.transparent));
|
||||
|
||||
CommonWebViewActivity.start(getContext(), UriProvider.getUserLevelUrl());
|
||||
}
|
||||
}, charmLevelIndex, charmLevelIndex + experLevel.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
tvChatLimit.setText(ss);
|
||||
tvChatLimit.setHighlightColor(Color.TRANSPARENT);
|
||||
tvChatLimit.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -44,6 +44,6 @@
|
||||
android:lines="1"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="10dp"
|
||||
tools:text="一二三四五六七八" />
|
||||
android:text="收到一条新消息"/>
|
||||
|
||||
</LinearLayout>
|
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/messageActivityLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -19,8 +20,9 @@
|
||||
android:paddingTop="@dimen/dp_2"
|
||||
android:paddingEnd="@dimen/dp_10"
|
||||
android:paddingBottom="@dimen/dp_2"
|
||||
android:text="哈哈哈哈哈"
|
||||
android:visibility="visible" />
|
||||
android:visibility="gone"
|
||||
tools:text="AAAAA"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -56,7 +56,7 @@ public class XChatConstants {
|
||||
/**
|
||||
* 网易易盾 业务 ID 注册
|
||||
*/
|
||||
public static final String QUICK_PASS_BUSINESS_ID = "3a94ceb70b144963a03bf98cb55b812a";
|
||||
public static final String QUICK_PASS_BUSINESS_ID = "200c83103d4a413591c7969dd8d4d6e2";
|
||||
|
||||
/**
|
||||
* 声网 key
|
||||
|
@@ -27,6 +27,7 @@ import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
import com.netease.nimlib.sdk.msg.model.RevokeMsgNotification;
|
||||
import com.nnbc123.core.activity.event.ActivityEvent;
|
||||
import com.nnbc123.core.auth.AuthModel;
|
||||
import com.nnbc123.core.event.RoomInviteEvent;
|
||||
@@ -80,6 +81,7 @@ public class IMMessageManager {
|
||||
|
||||
registerMsgStatusObserver();
|
||||
|
||||
registerRevokeMessageObserver();
|
||||
// pullMessageHistory();
|
||||
}
|
||||
|
||||
@@ -96,6 +98,20 @@ public class IMMessageManager {
|
||||
msgStatusObserver, true);
|
||||
}
|
||||
|
||||
private void registerRevokeMessageObserver() {
|
||||
Observer<RevokeMsgNotification> revokeMessageObserver = new Observer<RevokeMsgNotification>() {
|
||||
@Override
|
||||
public void onEvent(RevokeMsgNotification notification) {
|
||||
if (notification == null || notification.getMessage() == null) {
|
||||
return;
|
||||
}
|
||||
IMMessage message = notification.getMessage();
|
||||
NIMClient.getService(MsgService.class).deleteRecentContact2(message.getSessionId(), message.getSessionType());
|
||||
}
|
||||
};
|
||||
NIMClient.getService(MsgServiceObserve.class).observeRevokeMessage(revokeMessageObserver, true);
|
||||
}
|
||||
|
||||
private void registerRecentContactObserver() {
|
||||
//会话改变监听
|
||||
Observer<List<RecentContact>> recentContactObserver = (Observer<List<RecentContact>>) recentContacts -> {
|
||||
|
Reference in New Issue
Block a user