添加项目
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,50 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
res.srcDirs += "src/main/res-light"
|
||||
res.srcDirs += "src/main/res-lively"
|
||||
res.srcDirs += "src/main/res-serious"
|
||||
res.srcDirs += "src/main/res-minimalist"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
afterEvaluate{
|
||||
generateReleaseBuildConfig.enabled =false
|
||||
generateDebugBuildConfig.enabled =false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.8.7'
|
||||
api project(':system:tuicore')
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.tencent.qcloud.tuikit.tuicontact">
|
||||
<application>
|
||||
<provider
|
||||
android:name=".TUIContactService"
|
||||
android:authorities="${applicationId}.TUIContact.Init"
|
||||
android:enabled="true"
|
||||
android:exported="false"/>
|
||||
|
||||
|
||||
|
||||
<!-- **************** Classic UI Activity Start **************** -->
|
||||
<activity
|
||||
android:name=".classicui.pages.AddMoreActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".classicui.pages.FriendProfileActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".classicui.pages.NewFriendActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".classicui.pages.BlackListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".classicui.pages.GroupListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".classicui.pages.StartC2CChatActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".classicui.pages.StartGroupChatActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name=".classicui.pages.ForwardSelectGroupActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".classicui.pages.StartGroupMemberSelectActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".classicui.pages.CreateGroupActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".classicui.pages.GroupTypeSelectActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<!-- **************** Classic UI Activity End **************** -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- **************** Minimalist UI Activity Start **************** -->
|
||||
<activity
|
||||
android:name=".minimalistui.pages.AddMoreMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".minimalistui.pages.FriendProfileMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".minimalistui.pages.NewFriendMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".minimalistui.pages.BlackListMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".minimalistui.pages.GroupListMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".minimalistui.pages.StartC2CChatMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".minimalistui.pages.StartGroupChatMinimalistActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name=".minimalistui.pages.ForwardSelectGroupMinimalistActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".minimalistui.pages.StartGroupMemberSelectMinimalistActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".minimalistui.pages.CreateGroupMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".minimalistui.pages.GroupTypeSelectMinimalistActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<!-- **************** Minimalist UI Activity End **************** -->
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact;
|
||||
|
||||
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUIService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ITUIContactService extends ITUIService, ITUINotification {
|
||||
@Override
|
||||
Object onCall(String method, Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 接收好友备注修改通知
|
||||
* @param key TUIConstants.TUIContact.EVENT_FRIEND_INFO_CHANGED
|
||||
* @param subKey TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_REMARK_CHANGED
|
||||
* @param param {TUIConstants.TUIContact.FRIEND_ID : String, TUIConstants.TUIContact.FRIEND_REMARK : String}
|
||||
*
|
||||
*
|
||||
* Receive notification of friend's note modification
|
||||
* @param key TUIConstants.TUIContact.EVENT_FRIEND_INFO_CHANGED
|
||||
* @param subKey TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_REMARK_CHANGED
|
||||
* @param param {TUIConstants.TUIContact.FRIEND_ID : String, TUIConstants.TUIContact.FRIEND_REMARK : String}
|
||||
*/
|
||||
@Override
|
||||
void onNotifyEvent(String key, String subKey, Map<String, Object> param);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact;
|
||||
|
||||
import com.tencent.imsdk.BaseConstants;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupAtInfo;
|
||||
|
||||
public class TUIContactConstants {
|
||||
|
||||
public static final String FORWARD_SELECT_CONVERSATION_KEY = "forward_select_conversation_key";
|
||||
public static final int FORWARD_SELECT_MEMBERS_CODE = 102;
|
||||
public static final int FORWARD_CREATE_GROUP_CODE = 103;
|
||||
|
||||
public static final String FORWARD_CREATE_NEW_CHAT = "forward_create_new_chat";
|
||||
public static final String IM_PRODUCT_DOC_URL = "https://cloud.tencent.com/product/im";
|
||||
public static final String IM_PRODUCT_DOC_URL_EN = "https://www.tencentcloud.com/products/im?lang=en&pg=";
|
||||
/**
|
||||
* 1: 仅仅是一个带链接的文本消息
|
||||
* 2: iOS支持的视频通话版本,后续已经不兼容
|
||||
* 3: 未发布版本
|
||||
* 4: Android/iOS/Web互通的视频通话版本
|
||||
*
|
||||
* 1: Just a text message with a link
|
||||
* 2: The video calling version supported by iOS is no longer compatible
|
||||
* 3: unreleased version
|
||||
* 4: Android/iOS/Web interoperable version for video call
|
||||
*/
|
||||
public static final int JSON_VERSION_UNKNOWN = 0;
|
||||
public static final int JSON_VERSION_1 = 1;
|
||||
public static final int JSON_VERSION_4 = 4;
|
||||
public static int version = JSON_VERSION_4;
|
||||
|
||||
public static final class Group {
|
||||
|
||||
public static final String GROUP_ID = "group_id";
|
||||
}
|
||||
|
||||
public static class Selection {
|
||||
public static final String SELECT_ALL = V2TIMGroupAtInfo.AT_ALL_TAG;
|
||||
public static final String SELECT_FRIENDS = "select_friends";
|
||||
public static final String SELECT_FOR_CALL = "isSelectForCall";
|
||||
public static final String CONTENT = "content";
|
||||
public static final String TYPE = "type";
|
||||
public static final String TITLE = "title";
|
||||
public static final String INIT_CONTENT = "init_content";
|
||||
public static final String DEFAULT_SELECT_ITEM_INDEX = "default_select_item_index";
|
||||
public static final String LIST = "list";
|
||||
public static final String LIMIT = "limit";
|
||||
public static final String SELECTED_LIST = "selectedList";
|
||||
|
||||
public static final int TYPE_TEXT = 1;
|
||||
public static final int TYPE_LIST = 2;
|
||||
|
||||
public static final String USER_ID_SELECT = "user_id_select";
|
||||
public static final String USER_NAMECARD_SELECT = "user_namecard_select";
|
||||
}
|
||||
|
||||
public static class ProfileType {
|
||||
public static final String CONTENT = "content";
|
||||
}
|
||||
|
||||
public static class GroupType {
|
||||
public static final String TYPE = "type";
|
||||
public static final String GROUP = "isGroup";
|
||||
public static final int PRIVATE = 0;
|
||||
public static final int PUBLIC = 1;
|
||||
public static final int CHAT_ROOM = 2;
|
||||
public static final int COMMUNITY = 3;
|
||||
|
||||
public static final String TYPE_PUBLIC = "Public";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMFriendApplication;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendshipListener;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSDKListener;
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.qcloud.tuicore.ServiceInitializer;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.ContactEventListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TUIContactService extends ServiceInitializer implements ITUIContactService {
|
||||
public static final String TAG = TUIContactService.class.getSimpleName();
|
||||
|
||||
private static TUIContactService instance;
|
||||
|
||||
public static TUIContactService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<WeakReference<ContactEventListener>> contactEventListenerList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
instance = this;
|
||||
initService();
|
||||
initEvent();
|
||||
initIMListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object onCall(String method, Map<String, Object> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void initService() {
|
||||
TUICore.registerService(TUIConstants.TUIContact.SERVICE_NAME, this);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
TUICore.registerEvent(TUIConstants.TUIContact.EVENT_FRIEND_INFO_CHANGED, TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_REMARK_CHANGED, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
if (key.equals(TUIConstants.TUIContact.EVENT_FRIEND_INFO_CHANGED)) {
|
||||
if (subKey.equals(TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_REMARK_CHANGED)) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
if (param == null || param.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String id = (String) param.get(TUIConstants.TUIContact.FRIEND_ID);
|
||||
String remark = (String) param.get(TUIConstants.TUIContact.FRIEND_REMARK);
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendRemarkChanged(id ,remark);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initIMListener() {
|
||||
V2TIMManager.getFriendshipManager().addFriendListener(new V2TIMFriendshipListener() {
|
||||
@Override
|
||||
public void onFriendApplicationListAdded(List<V2TIMFriendApplication> applicationList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
List<FriendApplicationBean> friendApplicationBeanList = new ArrayList<>();
|
||||
for(V2TIMFriendApplication v2TIMFriendApplication : applicationList) {
|
||||
FriendApplicationBean friendApplicationBean = new FriendApplicationBean();
|
||||
friendApplicationBean.convertFromTimFriendApplication(v2TIMFriendApplication);
|
||||
friendApplicationBeanList.add(friendApplicationBean);
|
||||
}
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendApplicationListAdded(friendApplicationBeanList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationListDeleted(List<String> userIDList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendApplicationListDeleted(userIDList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationListRead() {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendApplicationListRead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendListAdded(List<V2TIMFriendInfo> users) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
for(V2TIMFriendInfo v2TIMFriendInfo : users) {
|
||||
ContactItemBean contactItemBean = new ContactItemBean();
|
||||
contactItemBean.setFriend(true);
|
||||
contactItemBean.covertTIMFriend(v2TIMFriendInfo);
|
||||
contactItemBeanList.add(contactItemBean);
|
||||
}
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendListAdded(contactItemBeanList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendListDeleted(List<String> userList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendListDeleted(userList);
|
||||
}
|
||||
HashMap<String, Object> bundle = new HashMap<>();
|
||||
bundle.put(TUIConstants.TUIContact.FRIEND_ID_LIST, new ArrayList<>(userList));
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_FRIEND_STATE_CHANGED,
|
||||
TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_DELETE, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlackListAdd(List<V2TIMFriendInfo> infoList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
for(V2TIMFriendInfo v2TIMFriendInfo : infoList) {
|
||||
ContactItemBean contactItemBean = new ContactItemBean();
|
||||
contactItemBean.covertTIMFriend(v2TIMFriendInfo);
|
||||
contactItemBeanList.add(contactItemBean);
|
||||
}
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onBlackListAdd(contactItemBeanList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlackListDeleted(List<String> userList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onBlackListDeleted(userList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendInfoChanged(List<V2TIMFriendInfo> infoList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
for(V2TIMFriendInfo v2TIMFriendInfo : infoList) {
|
||||
ContactItemBean contactItemBean = new ContactItemBean();
|
||||
contactItemBean.setFriend(true);
|
||||
contactItemBean.covertTIMFriend(v2TIMFriendInfo);
|
||||
contactItemBeanList.add(contactItemBean);
|
||||
}
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onFriendInfoChanged(contactItemBeanList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
V2TIMSDKListener v2TIMSDKListener = new V2TIMSDKListener() {
|
||||
@Override
|
||||
public void onUserStatusChanged(List<V2TIMUserStatus> userStatusList) {
|
||||
List<ContactEventListener> contactEventListenerList = getInstance().getContactEventListenerList();
|
||||
for (ContactEventListener contactEventListener : contactEventListenerList) {
|
||||
contactEventListener.onUserStatusChanged(userStatusList);
|
||||
}
|
||||
}
|
||||
};
|
||||
V2TIMManager.getInstance().addIMSDKListener(v2TIMSDKListener);
|
||||
}
|
||||
|
||||
public List<ContactEventListener> getContactEventListenerList() {
|
||||
List<ContactEventListener> contactEventListeners = new ArrayList<>();
|
||||
Iterator<WeakReference<ContactEventListener>> iterator = contactEventListenerList.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
WeakReference<ContactEventListener> weakReference = iterator.next();
|
||||
if (weakReference.get() == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
contactEventListeners.add(weakReference.get());
|
||||
}
|
||||
return contactEventListeners;
|
||||
}
|
||||
|
||||
public void addContactEventListener(ContactEventListener contactEventListener) {
|
||||
WeakReference<ContactEventListener> reference = new WeakReference<>(contactEventListener);
|
||||
Iterator<WeakReference<ContactEventListener>> iterator = contactEventListenerList.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
WeakReference<ContactEventListener> weakReference = iterator.next();
|
||||
if (weakReference.get() == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (weakReference.get() == contactEventListener) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
contactEventListenerList.add(reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightThemeResId() {
|
||||
return R.style.TUIContactLightTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLivelyThemeResId() {
|
||||
return R.style.TUIContactLivelyTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSeriousThemeResId() {
|
||||
return R.style.TUIContactSeriousTheme;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupAtInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class ChatInfo implements Serializable {
|
||||
|
||||
public static final int TYPE_C2C = V2TIMConversation.V2TIM_C2C;
|
||||
public static final int TYPE_GROUP = V2TIMConversation.V2TIM_GROUP;
|
||||
public static final int TYPE_INVALID = V2TIMConversation.CONVERSATION_TYPE_INVALID;
|
||||
|
||||
private static List<V2TIMGroupAtInfo> atInfoList;
|
||||
|
||||
private String chatName;
|
||||
private int type = V2TIMConversation.V2TIM_C2C;
|
||||
private String id;
|
||||
private String groupType;
|
||||
private boolean isTopChat;
|
||||
|
||||
|
||||
public ChatInfo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天的标题,单聊一般为对方名称,群聊为群名字
|
||||
*
|
||||
* Get the title of the chat, usually the name of the other party for a single chat, and the group name for a group chat
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getChatName() {
|
||||
return chatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置聊天的标题,单聊一般为对方名称,群聊为群名字
|
||||
*
|
||||
* Set the title of the chat, usually the name of the other party for a single chat, and the group name for a group chat
|
||||
*
|
||||
* @param chatName
|
||||
*/
|
||||
public void setChatName(String chatName) {
|
||||
this.chatName = chatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天类型,C2C为单聊,Group为群聊
|
||||
*
|
||||
* Get the chat type, C2C is a single chat, Group is a group chat
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置聊天类型,C2C为单聊,Group为群聊
|
||||
*
|
||||
* Set the chat type, C2C is a single chat, Group is a group chat
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天唯一标识
|
||||
*
|
||||
* Get chat unique ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置聊天唯一标识
|
||||
*
|
||||
* Set chat unique ID
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群组类型
|
||||
*
|
||||
* Get the group type
|
||||
*/
|
||||
public String getGroupType() {
|
||||
return groupType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群组类型
|
||||
*
|
||||
* Set the group type
|
||||
*/
|
||||
public void setGroupType(String groupType) {
|
||||
this.groupType = groupType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为置顶的会话
|
||||
*
|
||||
* Is it a pinned conversation
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isTopChat() {
|
||||
return isTopChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置会话是否置顶
|
||||
*
|
||||
* Set as a pinned conversation
|
||||
*
|
||||
* @param topChat
|
||||
*/
|
||||
public void setTopChat(boolean topChat) {
|
||||
isTopChat = topChat;
|
||||
}
|
||||
|
||||
public List<V2TIMGroupAtInfo> getAtInfoList() {
|
||||
return atInfoList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupApplication;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ContactGroupApplyInfo implements Serializable {
|
||||
|
||||
private String fromUser;
|
||||
private String fromUserNickName;
|
||||
private String requestMsg;
|
||||
private V2TIMGroupApplication timGroupApplication;
|
||||
|
||||
public String getFromUser() {
|
||||
return fromUser;
|
||||
}
|
||||
|
||||
public void setFromUser(String fromUser) {
|
||||
this.fromUser = fromUser;
|
||||
}
|
||||
|
||||
public String getFromUserNickName() {
|
||||
return fromUserNickName;
|
||||
}
|
||||
|
||||
public void setFromUserNickName(String fromUserNickName) {
|
||||
this.fromUserNickName = fromUserNickName;
|
||||
}
|
||||
|
||||
public String getRequestMsg() {
|
||||
return requestMsg;
|
||||
}
|
||||
|
||||
public void setRequestMsg(String requestMsg) {
|
||||
this.requestMsg = requestMsg;
|
||||
}
|
||||
|
||||
public void setTimGroupApplication(V2TIMGroupApplication timGroupApplication) {
|
||||
this.timGroupApplication = timGroupApplication;
|
||||
}
|
||||
|
||||
public V2TIMGroupApplication getTimGroupApplication() {
|
||||
return timGroupApplication;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.bean.BaseIndexPinyinBean;
|
||||
|
||||
public class ContactItemBean extends BaseIndexPinyinBean {
|
||||
public static final int TYPE_C2C = V2TIMConversation.V2TIM_C2C;
|
||||
public static final int TYPE_GROUP = V2TIMConversation.V2TIM_GROUP;
|
||||
public static final int TYPE_INVALID = V2TIMConversation.CONVERSATION_TYPE_INVALID;
|
||||
|
||||
public static final String INDEX_STRING_TOP = "↑";
|
||||
private String id;
|
||||
private boolean isTop;
|
||||
private boolean isSelected;
|
||||
private boolean isBlackList;
|
||||
private String remark;
|
||||
private String nickName;
|
||||
private String avatarUrl;
|
||||
private String signature;
|
||||
private boolean isGroup;
|
||||
private String groupType;
|
||||
private boolean isFriend = false;
|
||||
private boolean isEnable = true;
|
||||
private int role;
|
||||
private int statusType = V2TIMUserStatus.V2TIM_USER_STATUS_UNKNOWN;
|
||||
|
||||
public ContactItemBean() {
|
||||
}
|
||||
|
||||
public ContactItemBean(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ContactItemBean setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isTop() {
|
||||
return isTop;
|
||||
}
|
||||
|
||||
public ContactItemBean setTop(boolean top) {
|
||||
isTop = top;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTarget() {
|
||||
if (!TextUtils.isEmpty(remark)) {
|
||||
return remark;
|
||||
}
|
||||
if (!TextUtils.isEmpty(nickName)) {
|
||||
return nickName;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNeedToPinyin() {
|
||||
return !isTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowSuspension() {
|
||||
return !isTop;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
public void setEnable(boolean enable) {
|
||||
isEnable = enable;
|
||||
}
|
||||
|
||||
public boolean isBlackList() {
|
||||
return isBlackList;
|
||||
}
|
||||
|
||||
public void setBlackList(boolean blacklist) {
|
||||
isBlackList = blacklist;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public ContactItemBean covertTIMFriend(V2TIMFriendInfo friendInfo) {
|
||||
if (friendInfo == null) {
|
||||
return this;
|
||||
}
|
||||
setId(friendInfo.getUserID());
|
||||
setNickName(friendInfo.getUserProfile().getNickName());
|
||||
setAvatarUrl(friendInfo.getUserProfile().getFaceUrl());
|
||||
setSignature(friendInfo.getUserProfile().getSelfSignature());
|
||||
setRemark(friendInfo.getFriendRemark());
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public boolean isGroup() {
|
||||
return isGroup;
|
||||
}
|
||||
|
||||
public void setGroup(boolean group) {
|
||||
isGroup = group;
|
||||
}
|
||||
|
||||
public String getGroupType() {
|
||||
return groupType;
|
||||
}
|
||||
|
||||
public void setGroupType(String groupType) {
|
||||
this.groupType = groupType;
|
||||
}
|
||||
|
||||
public boolean isFriend() {
|
||||
return isFriend;
|
||||
}
|
||||
|
||||
public void setFriend(boolean friend) {
|
||||
isFriend = friend;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public int getStatusType() {
|
||||
return statusType;
|
||||
}
|
||||
|
||||
public void setStatusType(int statusType) {
|
||||
this.statusType = statusType;
|
||||
}
|
||||
|
||||
public int getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(int role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public ContactItemBean covertTIMGroupBaseInfo(V2TIMGroupInfo group) {
|
||||
if (group == null) {
|
||||
return this;
|
||||
}
|
||||
setId(group.getGroupID());
|
||||
setRemark(group.getGroupName());
|
||||
setAvatarUrl(group.getFaceUrl());
|
||||
setGroup(true);
|
||||
setGroupType(group.getGroupType());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContactItemBean covertTIMGroupMemberFullInfo(V2TIMGroupMemberFullInfo member) {
|
||||
if (member == null) {
|
||||
return this;
|
||||
}
|
||||
setId(member.getUserID());
|
||||
setRole(member.getRole());
|
||||
if(TextUtils.isEmpty(member.getNickName())){
|
||||
setRemark(member.getNameCard());
|
||||
setNickName(member.getNameCard());
|
||||
}else{
|
||||
setRemark(member.getNickName());
|
||||
setNickName(member.getNickName());
|
||||
}
|
||||
setAvatarUrl(member.getFaceUrl());
|
||||
setGroup(false);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class ConversationBean implements Parcelable {
|
||||
private String conversationID;
|
||||
private int isGroup;
|
||||
private String title;
|
||||
|
||||
public ConversationBean()
|
||||
{}
|
||||
|
||||
public ConversationBean(String conversationID, int isGroup, String title)
|
||||
{
|
||||
this.conversationID = conversationID;
|
||||
this.isGroup = isGroup;
|
||||
this.title = title;
|
||||
}
|
||||
public String getConversationID()
|
||||
{
|
||||
return this.conversationID;
|
||||
}
|
||||
|
||||
public void setConversationID(String conversationID)
|
||||
{
|
||||
this.conversationID = conversationID;
|
||||
}
|
||||
|
||||
public int getIsGroup()
|
||||
{
|
||||
return this.isGroup;
|
||||
}
|
||||
|
||||
public void setIsGroup(int isGroup)
|
||||
{
|
||||
this.isGroup = isGroup;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override public int describeContents() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(conversationID);
|
||||
dest.writeInt(isGroup);
|
||||
dest.writeString(title);
|
||||
}
|
||||
|
||||
public static final Creator<ConversationBean> CREATOR = new Creator<ConversationBean>() {
|
||||
@Override
|
||||
public ConversationBean createFromParcel(Parcel source) {
|
||||
return new ConversationBean(source.readString(), source.readInt(),source.readString());
|
||||
}
|
||||
@Override
|
||||
public ConversationBean[] newArray(int size) {
|
||||
|
||||
return new ConversationBean[size];
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConversationInfo implements Serializable, Comparable<ConversationInfo> {
|
||||
|
||||
public static final int TYPE_COMMON = 1;
|
||||
public static final int TYPE_CUSTOM = 2;
|
||||
|
||||
public static final int TYPE_FORWAR_SELECT = 3;
|
||||
public static final int TYPE_RECENT_LABEL = 4;
|
||||
/**
|
||||
* 会话类型,自定义会话or普通会话
|
||||
*
|
||||
* conversation type
|
||||
*/
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 消息未读数
|
||||
*
|
||||
* unread message number
|
||||
*/
|
||||
private int unRead;
|
||||
/**
|
||||
* 会话ID
|
||||
*
|
||||
* conversation ID
|
||||
*/
|
||||
private String conversationId;
|
||||
/**
|
||||
* 会话标识,C2C为对方用户ID,群聊为群组ID
|
||||
*
|
||||
* ID, C2C is UserID, Group is group ID
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 会话头像url
|
||||
*
|
||||
* conversation avatar url
|
||||
*/
|
||||
private List<Object> iconUrlList = new ArrayList<>();
|
||||
|
||||
public List<Object> getIconUrlList() {
|
||||
return iconUrlList;
|
||||
}
|
||||
|
||||
public void setIconUrlList(List<Object> iconUrlList) {
|
||||
this.iconUrlList = iconUrlList;
|
||||
}
|
||||
|
||||
private String title;
|
||||
private String iconPath;
|
||||
private boolean isGroup;
|
||||
private boolean top;
|
||||
private long lastMessageTime;
|
||||
|
||||
|
||||
/**
|
||||
* 会话界面显示的@提示消息
|
||||
*
|
||||
* "@" message in group
|
||||
*/
|
||||
private String atInfoText;
|
||||
|
||||
/**
|
||||
* 会话界面显示消息免打扰图标
|
||||
*
|
||||
* the conversation item displays the icon of Do Not Disturb
|
||||
*/
|
||||
private boolean showDisturbIcon;
|
||||
|
||||
private String groupType;
|
||||
|
||||
/**
|
||||
* 会话排序键值
|
||||
*
|
||||
* conversation sort key
|
||||
*/
|
||||
private long orderKey;
|
||||
|
||||
public ConversationInfo() {
|
||||
|
||||
}
|
||||
|
||||
public String getConversationId() {
|
||||
return conversationId;
|
||||
}
|
||||
|
||||
public void setConversationId(String conversationId) {
|
||||
this.conversationId = conversationId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getUnRead() {
|
||||
return unRead;
|
||||
}
|
||||
|
||||
public void setUnRead(int unRead) {
|
||||
this.unRead = unRead;
|
||||
}
|
||||
|
||||
public boolean isGroup() {
|
||||
return isGroup;
|
||||
}
|
||||
|
||||
public void setGroup(boolean group) {
|
||||
isGroup = group;
|
||||
}
|
||||
|
||||
public boolean isTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(boolean top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得最后一条消息的时间,单位是秒
|
||||
*
|
||||
* Get the time of the last message, in seconds
|
||||
*/
|
||||
public long getLastMessageTime() {
|
||||
return lastMessageTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最后一条消息的时间,单位是秒
|
||||
*
|
||||
* Set the time to the last message, in seconds
|
||||
*
|
||||
* @param lastMessageTime
|
||||
*/
|
||||
public void setLastMessageTime(long lastMessageTime) {
|
||||
this.lastMessageTime = lastMessageTime;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setAtInfoText(String atInfoText) {
|
||||
this.atInfoText = atInfoText;
|
||||
}
|
||||
|
||||
public String getAtInfoText() {
|
||||
return atInfoText;
|
||||
}
|
||||
|
||||
public boolean isShowDisturbIcon() {
|
||||
return showDisturbIcon;
|
||||
}
|
||||
|
||||
public void setShowDisturbIcon(boolean showDisturbIcon) {
|
||||
this.showDisturbIcon = showDisturbIcon;
|
||||
}
|
||||
|
||||
public String getGroupType() {
|
||||
return groupType;
|
||||
}
|
||||
|
||||
public void setGroupType(String groupType) {
|
||||
this.groupType = groupType;
|
||||
}
|
||||
|
||||
public String getIconPath() {
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
public void setIconPath(String iconPath) {
|
||||
this.iconPath = iconPath;
|
||||
}
|
||||
|
||||
public void setOrderKey(long orderKey) {
|
||||
this.orderKey = orderKey;
|
||||
}
|
||||
|
||||
public long getOrderKey() {
|
||||
return orderKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull ConversationInfo other) {
|
||||
long thisOrderKey = this.orderKey;
|
||||
long otherOrderKey = other.orderKey;
|
||||
if (thisOrderKey > otherOrderKey) {
|
||||
return -1;
|
||||
} else if (thisOrderKey == otherOrderKey) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConversationInfo{" +
|
||||
"type=" + type +
|
||||
", unRead=" + unRead +
|
||||
", conversationId='" + conversationId + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", iconUrl='" + iconUrlList.size() + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", iconPath=" + iconPath +
|
||||
", isGroup=" + isGroup +
|
||||
", top=" + top +
|
||||
", lastMessageTime=" + lastMessageTime +
|
||||
", groupType=" + groupType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import com.tencent.imsdk.BaseConstants;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendApplication;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FriendApplicationBean implements Serializable {
|
||||
/**
|
||||
* ## 别人发给我的加好友请求
|
||||
*
|
||||
* ## Friend request received by me
|
||||
*/
|
||||
public static final int FRIEND_APPLICATION_COME_IN = V2TIMFriendApplication.V2TIM_FRIEND_APPLICATION_COME_IN;
|
||||
|
||||
/**
|
||||
* ## 我发给别人的加好友请求
|
||||
*
|
||||
* ## Friend request sent by me
|
||||
*/
|
||||
public static final int FRIEND_APPLICATION_SEND_OUT = V2TIMFriendApplication.V2TIM_FRIEND_APPLICATION_SEND_OUT;
|
||||
|
||||
/**
|
||||
* ## 别人发给我的和我发给别人的加好友请求。仅在拉取时有效。
|
||||
*
|
||||
* ## Friend requests received and sent by me. Valid only during pulling
|
||||
*/
|
||||
public static final int FRIEND_APPLICATION_BOTH = V2TIMFriendApplication.V2TIM_FRIEND_APPLICATION_BOTH;
|
||||
|
||||
/**
|
||||
* ## 同意加好友(建立单向好友)
|
||||
*
|
||||
* ## Accept the friend request (build a one-way friend relationship)
|
||||
*/
|
||||
public static final int FRIEND_ACCEPT_AGREE = V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE;
|
||||
|
||||
/**
|
||||
* ## 同意加好友并加对方为好友(建立双向好友)
|
||||
*
|
||||
* ## Accept the friend request and add the peer party as a friend (build a two-way friend relationship)
|
||||
*/
|
||||
public static final int FRIEND_ACCEPT_AGREE_AND_ADD = V2TIMFriendApplication.V2TIM_FRIEND_ACCEPT_AGREE_AND_ADD;
|
||||
|
||||
public static final int ERR_SUCC = BaseConstants.ERR_SUCC;
|
||||
public static final int ERR_SVR_FRIENDSHIP_INVALID_PARAMETERS = BaseConstants.ERR_SVR_FRIENDSHIP_INVALID_PARAMETERS;
|
||||
public static final int ERR_SVR_FRIENDSHIP_COUNT_LIMIT = BaseConstants.ERR_SVR_FRIENDSHIP_COUNT_LIMIT;
|
||||
public static final int ERR_SVR_FRIENDSHIP_PEER_FRIEND_LIMIT = BaseConstants.ERR_SVR_FRIENDSHIP_PEER_FRIEND_LIMIT;
|
||||
public static final int ERR_SVR_FRIENDSHIP_IN_SELF_BLACKLIST = BaseConstants.ERR_SVR_FRIENDSHIP_IN_SELF_BLACKLIST;
|
||||
public static final int ERR_SVR_FRIENDSHIP_ALLOW_TYPE_DENY_ANY = BaseConstants.ERR_SVR_FRIENDSHIP_ALLOW_TYPE_DENY_ANY;
|
||||
public static final int ERR_SVR_FRIENDSHIP_IN_PEER_BLACKLIST = BaseConstants.ERR_SVR_FRIENDSHIP_IN_PEER_BLACKLIST;
|
||||
public static final int ERR_SVR_FRIENDSHIP_ALLOW_TYPE_NEED_CONFIRM = BaseConstants.ERR_SVR_FRIENDSHIP_ALLOW_TYPE_NEED_CONFIRM;
|
||||
|
||||
private String userId;
|
||||
private String nickName;
|
||||
private String addWording;
|
||||
private int addType;
|
||||
private String faceUrl;
|
||||
private V2TIMFriendApplication friendApplication;
|
||||
private boolean isAccept = false;
|
||||
public FriendApplicationBean() {}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getAddWording() {
|
||||
return addWording;
|
||||
}
|
||||
|
||||
public void setAddWording(String addWording) {
|
||||
this.addWording = addWording;
|
||||
}
|
||||
|
||||
public int getAddType() {
|
||||
return addType;
|
||||
}
|
||||
|
||||
public void setAddType(int addType) {
|
||||
this.addType = addType;
|
||||
}
|
||||
|
||||
public void setAccept(boolean accept) {
|
||||
isAccept = accept;
|
||||
}
|
||||
|
||||
public boolean isAccept() {
|
||||
return isAccept;
|
||||
}
|
||||
|
||||
public void setFriendApplication(V2TIMFriendApplication friendApplication) {
|
||||
this.friendApplication = friendApplication;
|
||||
}
|
||||
|
||||
public void setFaceUrl(String faceUrl) {
|
||||
this.faceUrl = faceUrl;
|
||||
}
|
||||
|
||||
public String getFaceUrl() {
|
||||
return faceUrl;
|
||||
}
|
||||
|
||||
public V2TIMFriendApplication getFriendApplication() {
|
||||
return friendApplication;
|
||||
}
|
||||
|
||||
public FriendApplicationBean convertFromTimFriendApplication(V2TIMFriendApplication v2TIMFriendApplication) {
|
||||
if (v2TIMFriendApplication == null) {
|
||||
return this;
|
||||
}
|
||||
setAddType(v2TIMFriendApplication.getType());
|
||||
setNickName(v2TIMFriendApplication.getNickname());
|
||||
setAddWording(v2TIMFriendApplication.getAddWording());
|
||||
setUserId(v2TIMFriendApplication.getUserID());
|
||||
setFriendApplication(v2TIMFriendApplication);
|
||||
setFaceUrl(v2TIMFriendApplication.getFaceUrl());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import com.tencent.imsdk.BaseConstants;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class GroupInfo extends ChatInfo {
|
||||
|
||||
public static final int ERR_SVR_GROUP_ALLREADY_MEMBER = BaseConstants.ERR_SVR_GROUP_ALLREADY_MEMBER;
|
||||
public static final int ERR_SVR_GROUP_PERMISSION_DENY = BaseConstants.ERR_SVR_GROUP_PERMISSION_DENY;
|
||||
public static final int ERR_SVR_GROUP_NOT_FOUND = BaseConstants.ERR_SVR_GROUP_NOT_FOUND; // 群组不存在
|
||||
public static final int ERR_SVR_GROUP_FULL_MEMBER_COUNT = BaseConstants.ERR_SVR_GROUP_FULL_MEMBER_COUNT;
|
||||
|
||||
private String groupType;
|
||||
private int memberCount;
|
||||
private String groupName;
|
||||
private String notice;
|
||||
private List<GroupMemberInfo> memberDetails = new ArrayList<>();
|
||||
private int joinType;
|
||||
private String owner;
|
||||
private boolean messageReceiveOption;
|
||||
private String faceUrl;
|
||||
private boolean communitySupportTopic = false;
|
||||
|
||||
public GroupInfo() {
|
||||
setType(V2TIMConversation.V2TIM_GROUP);
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群公告
|
||||
*
|
||||
* Get group announcements
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getNotice() {
|
||||
return notice;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群公告
|
||||
*
|
||||
* Set group announcements
|
||||
*
|
||||
* @param signature
|
||||
*/
|
||||
public void setNotice(String signature) {
|
||||
this.notice = signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取加群验证方式
|
||||
*
|
||||
* Get the group verification method
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getJoinType() {
|
||||
return joinType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置加群验证方式
|
||||
*
|
||||
* Set the group verification method
|
||||
*
|
||||
* @param joinType
|
||||
*/
|
||||
public void setJoinType(int joinType) {
|
||||
this.joinType = joinType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群类型,Public/Private/ChatRoom
|
||||
*
|
||||
* Get the group type, Public/Private/ChatRoom
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getGroupType() {
|
||||
return groupType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群类型
|
||||
*
|
||||
* Set the group type
|
||||
*
|
||||
* @param groupType
|
||||
*/
|
||||
public void setGroupType(String groupType) {
|
||||
this.groupType = groupType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员详细信息
|
||||
*
|
||||
* Get member details
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<GroupMemberInfo> getMemberDetails() {
|
||||
return memberDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置成员详细信息
|
||||
*
|
||||
* Set member details
|
||||
*
|
||||
* @param memberDetails
|
||||
*/
|
||||
public void setMemberDetails(List<GroupMemberInfo> memberDetails) {
|
||||
this.memberDetails = memberDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群成员数量
|
||||
*
|
||||
* Get the number of members that have joined the group
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getMemberCount() {
|
||||
if (memberDetails != null) {
|
||||
return memberDetails.size();
|
||||
}
|
||||
return memberCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置群成员数量
|
||||
*
|
||||
* Set the number of members that have joined the group
|
||||
*
|
||||
* @param memberCount
|
||||
*/
|
||||
public void setMemberCount(int memberCount) {
|
||||
this.memberCount = memberCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回是否是群主
|
||||
*
|
||||
* Returns whether it is the owner of the group
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOwner() {
|
||||
return V2TIMManager.getInstance().getLoginUser().equals(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否是群主
|
||||
*
|
||||
* Set whether it is the owner of the group
|
||||
*
|
||||
* @param owner
|
||||
*/
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息接收选项
|
||||
*
|
||||
* Get the current user's message receiving option in the group. To modify the group message receiving option, please call the setReceiveMessageOpt API.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getMessageReceiveOption() {
|
||||
return messageReceiveOption;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息接收选项
|
||||
* @param messageReceiveOption, true,免打扰; false,接收消息
|
||||
*
|
||||
*
|
||||
* Set the current user's message receiving option in the group.
|
||||
* @param messageReceiveOption, true,no message will be received; false,messages will be received.
|
||||
*/
|
||||
public void setMessageReceiveOption(boolean messageReceiveOption) {
|
||||
this.messageReceiveOption = messageReceiveOption;
|
||||
}
|
||||
|
||||
public String getFaceUrl() {
|
||||
return faceUrl;
|
||||
}
|
||||
|
||||
public void setFaceUrl(String faceUrl) {
|
||||
this.faceUrl = faceUrl;
|
||||
}
|
||||
|
||||
public boolean isCommunitySupportTopic() {
|
||||
return communitySupportTopic;
|
||||
}
|
||||
|
||||
public void setCommunitySupportTopic(boolean communitySupportTopic) {
|
||||
this.communitySupportTopic = communitySupportTopic;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从SDK转化为TUIKit的群信息bean
|
||||
*
|
||||
* @param infoResult
|
||||
* @return
|
||||
*/
|
||||
public GroupInfo covertTIMGroupDetailInfo(V2TIMGroupInfoResult infoResult) {
|
||||
if (infoResult.getResultCode() != 0) {
|
||||
return this;
|
||||
}
|
||||
setChatName(infoResult.getGroupInfo().getGroupName());
|
||||
setGroupName(infoResult.getGroupInfo().getGroupName());
|
||||
setId(infoResult.getGroupInfo().getGroupID());
|
||||
setNotice(infoResult.getGroupInfo().getNotification());
|
||||
setMemberCount(infoResult.getGroupInfo().getMemberCount());
|
||||
setGroupType(infoResult.getGroupInfo().getGroupType());
|
||||
setOwner(infoResult.getGroupInfo().getOwner());
|
||||
setJoinType(infoResult.getGroupInfo().getGroupAddOpt());
|
||||
setMessageReceiveOption(infoResult.getGroupInfo().getRecvOpt() == V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE ? true : false);
|
||||
setCommunitySupportTopic(infoResult.getGroupInfo().isSupportTopic());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GroupMemberInfo implements Serializable {
|
||||
|
||||
private String iconUrl;
|
||||
private String account;
|
||||
private String signature;
|
||||
private String location;
|
||||
private String birthday;
|
||||
private String nameCard;
|
||||
private String nickName;
|
||||
private boolean isTopChat;
|
||||
private boolean isFriend;
|
||||
private long joinTime;
|
||||
private long tinyId;
|
||||
private int memberType;
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public void setNameCard(String nameCard) {
|
||||
this.nameCard = nameCard;
|
||||
}
|
||||
|
||||
public String getNameCard() {
|
||||
return nameCard;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return this.nickName;
|
||||
}
|
||||
|
||||
public boolean isTopChat() {
|
||||
return isTopChat;
|
||||
}
|
||||
|
||||
public void setTopChat(boolean topChat) {
|
||||
isTopChat = topChat;
|
||||
}
|
||||
|
||||
public boolean isFriend() {
|
||||
return isFriend;
|
||||
}
|
||||
|
||||
public void setFriend(boolean friend) {
|
||||
isFriend = friend;
|
||||
}
|
||||
|
||||
public long getJoinTime() {
|
||||
return joinTime;
|
||||
}
|
||||
|
||||
public void setJoinTime(long joinTime) {
|
||||
this.joinTime = joinTime;
|
||||
}
|
||||
|
||||
public long getTinyId() {
|
||||
return tinyId;
|
||||
}
|
||||
|
||||
public void setTinyId(long tinyId) {
|
||||
this.tinyId = tinyId;
|
||||
}
|
||||
|
||||
public int getMemberType() {
|
||||
return memberType;
|
||||
}
|
||||
|
||||
public void setMemberType(int memberType) {
|
||||
this.memberType = memberType;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
String displayName = account;
|
||||
if (!TextUtils.isEmpty(nameCard)) {
|
||||
displayName = nameCard;
|
||||
} else if (!TextUtils.isEmpty(nickName)) {
|
||||
displayName = nickName;
|
||||
}
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public GroupMemberInfo covertTIMGroupMemberInfo(V2TIMGroupMemberInfo info) {
|
||||
if (info instanceof V2TIMGroupMemberFullInfo) {
|
||||
V2TIMGroupMemberFullInfo v2TIMGroupMemberFullInfo = (V2TIMGroupMemberFullInfo)info;
|
||||
setJoinTime(v2TIMGroupMemberFullInfo.getJoinTime());
|
||||
setMemberType(v2TIMGroupMemberFullInfo.getRole());
|
||||
}
|
||||
setAccount(info.getUserID());
|
||||
setNameCard(info.getNameCard());
|
||||
setIconUrl(info.getFaceUrl());
|
||||
setNickName(info.getNickName());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.bean;
|
||||
|
||||
public class MessageCustom {
|
||||
public static final String BUSINESS_ID_GROUP_CREATE = "group_create";
|
||||
|
||||
public int version = 0;
|
||||
public String businessID;
|
||||
public String opUser;
|
||||
public String content;
|
||||
public String data;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ILayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
|
||||
public interface IContactLayout extends ILayout {
|
||||
|
||||
ContactListView getContactListView();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IAddMoreActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.AddMorePresenter;
|
||||
|
||||
public class AddMoreActivity extends BaseLightActivity implements IAddMoreActivity {
|
||||
|
||||
private static final String TAG = AddMoreActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private EditText searchEdit;
|
||||
private TextView idLabel;
|
||||
private TextView notFoundTip;
|
||||
private TextView searchBtn;
|
||||
private View detailArea;
|
||||
|
||||
private ImageView faceImgView;
|
||||
private TextView idTextView;
|
||||
private TextView groupTypeView;
|
||||
private TextView groupTypeTagView;
|
||||
private TextView nickNameView;
|
||||
|
||||
private boolean mIsGroup;
|
||||
|
||||
private AddMorePresenter presenter;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.contact_add_activity);
|
||||
if (getIntent() != null) {
|
||||
mIsGroup = getIntent().getExtras().getBoolean(TUIContactConstants.GroupType.GROUP);
|
||||
}
|
||||
|
||||
presenter = new AddMorePresenter();
|
||||
presenter.setAddMoreActivity(this);
|
||||
|
||||
faceImgView = findViewById(R.id.friend_icon);
|
||||
idTextView = findViewById(R.id.friend_account);
|
||||
groupTypeView = findViewById(R.id.group_type);
|
||||
nickNameView = findViewById(R.id.friend_nick_name);
|
||||
groupTypeTagView = findViewById(R.id.group_type_tag);
|
||||
|
||||
mTitleBar = findViewById(R.id.add_friend_titlebar);
|
||||
mTitleBar.setTitle(mIsGroup ? getResources().getString(R.string.add_group) : getResources().getString(R.string.add_friend), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
|
||||
searchEdit = findViewById(R.id.search_edit);
|
||||
if (mIsGroup) {
|
||||
searchEdit.setHint(R.string.hint_search_group_id);
|
||||
}
|
||||
|
||||
idLabel = findViewById(R.id.id_label);
|
||||
notFoundTip = findViewById(R.id.not_found_tip);
|
||||
searchBtn = findViewById(R.id.search_button);
|
||||
detailArea = findViewById(R.id.friend_detail_area);
|
||||
searchBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
notFoundTip.setVisibility(View.GONE);
|
||||
String id = searchEdit.getText().toString();
|
||||
|
||||
if (mIsGroup) {
|
||||
presenter.getGroupInfo(id, new IUIKitCallback<GroupInfo>() {
|
||||
@Override
|
||||
public void onSuccess(GroupInfo data) {
|
||||
setGroupDetail(data);
|
||||
detailArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), FriendProfileActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, data);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
setNotFound(true);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
presenter.getUserInfo(id, new IUIKitCallback<ContactItemBean>() {
|
||||
@Override
|
||||
public void onSuccess(ContactItemBean data) {
|
||||
setFriendDetail(data.getAvatarUrl(), data.getId(), data.getNickName());
|
||||
detailArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), FriendProfileActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, data);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
setNotFound(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!mIsGroup) {
|
||||
idLabel.setText(getString(R.string.contact_my_user_id, TUILogin.getLoginUser()));
|
||||
}
|
||||
|
||||
searchEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
idLabel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
searchEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (TextUtils.isEmpty(searchEdit.getText())) {
|
||||
detailArea.setVisibility(View.GONE);
|
||||
notFoundTip.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setGroupDetail(GroupInfo groupInfo) {
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(faceImgView, groupInfo.getFaceUrl(),
|
||||
TUIUtil.getDefaultGroupIconResIDByGroupType(this, groupInfo.getGroupType()), radius);
|
||||
idTextView.setText(groupInfo.getId());
|
||||
nickNameView.setText(groupInfo.getGroupName());
|
||||
groupTypeTagView.setVisibility(View.VISIBLE);
|
||||
groupTypeView.setVisibility(View.VISIBLE);
|
||||
groupTypeView.setText(groupInfo.getGroupType());
|
||||
detailArea.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setFriendDetail(String faceUrl, String id, String nickName) {
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(faceImgView, faceUrl, radius);
|
||||
idTextView.setText(id);
|
||||
if (TextUtils.isEmpty(nickName)) {
|
||||
nickNameView.setText(id);
|
||||
} else {
|
||||
nickNameView.setText(nickName);
|
||||
}
|
||||
groupTypeTagView.setVisibility(View.GONE);
|
||||
groupTypeView.setVisibility(View.GONE);
|
||||
detailArea.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setNotFound(boolean isGroup) {
|
||||
detailArea.setVisibility(View.GONE);
|
||||
if (isGroup) {
|
||||
notFoundTip.setText(getString(R.string.contact_no_such_group));
|
||||
} else {
|
||||
notFoundTip.setText(getString(R.string.contact_no_such_user));
|
||||
}
|
||||
notFoundTip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
|
||||
public class BlackListActivity extends BaseLightActivity {
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mListView;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.contact_blacklist_activity);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mTitleBar = findViewById(R.id.black_list_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.blacklist), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
|
||||
mListView = findViewById(R.id.black_list);
|
||||
mListView.setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
Intent intent = new Intent(BlackListActivity.this, FriendProfileActivity.class);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, contact);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
loadDataSource();
|
||||
}
|
||||
|
||||
public void loadDataSource() {
|
||||
presenter = new ContactPresenter();
|
||||
mListView.setPresenter(presenter);
|
||||
mListView.setNotFoundTip(getString(R.string.contact_no_block_list));
|
||||
presenter.setContactListView(mListView);
|
||||
presenter.setBlackListListener();
|
||||
mListView.loadDataSource(ContactListView.DataSource.BLACK_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.ImageSelectActivity;
|
||||
import com.tencent.qcloud.tuicore.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuicore.component.gatherimage.SynthesizedImageView;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.component.popupcard.PopupInputCard;
|
||||
import com.tencent.qcloud.tuicore.util.ImageUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ChatInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateGroupActivity extends BaseLightActivity implements View.OnClickListener {
|
||||
private static final String TAG = CreateGroupActivity.class.getSimpleName();
|
||||
|
||||
private static final int CHOOSE_AVATAR_REQUEST_CODE = 1;
|
||||
private static final int CHOOSE_GROUP_TYPE_REQUEST_CODE = 2;
|
||||
private TitleBarLayout titleBarLayout;
|
||||
private SynthesizedImageView groupAvatar;
|
||||
private LineControllerView groupNameLv;
|
||||
private LineControllerView groupIdLv;
|
||||
private LineControllerView groupTypeLv;
|
||||
private View groupAvatarLayout;
|
||||
private TextView confirmButton;
|
||||
private TextView groupTypeContentView, groupTypeContentUrlView;
|
||||
|
||||
private String groupName;
|
||||
private String groupId;
|
||||
private String groupType = V2TIMManager.GROUP_TYPE_WORK;
|
||||
private String groupAvatarUrl;
|
||||
private List<Object> groupAvatarUrlList;
|
||||
private int joinTypeIndex;
|
||||
private String groupAvatarImageId = "";
|
||||
|
||||
private ArrayList<GroupMemberInfo> mGroupMembers = new ArrayList<>();
|
||||
private boolean mCreating;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.create_group_layout);
|
||||
|
||||
titleBarLayout = findViewById(R.id.create_group_bar);
|
||||
groupNameLv = findViewById(R.id.group_name_layout);
|
||||
groupIdLv = findViewById(R.id.group_id_layout);
|
||||
groupTypeLv = findViewById(R.id.group_type_layout);
|
||||
groupAvatarLayout = findViewById(R.id.group_avatar_layout);
|
||||
groupAvatar = findViewById(R.id.group_avatar);
|
||||
confirmButton = findViewById(R.id.confirm_button);
|
||||
groupTypeContentView = findViewById(R.id.group_type_text);
|
||||
groupTypeContentUrlView = findViewById(R.id.group_type_text_url);
|
||||
|
||||
initData();
|
||||
setupViews();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
TUIContactLog.e(TAG, "intent is null");
|
||||
return;
|
||||
}
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) {
|
||||
TUIContactLog.e(TAG, "bundle is null");
|
||||
return;
|
||||
}
|
||||
|
||||
mGroupMembers = (ArrayList<GroupMemberInfo>) bundle.getSerializable(TUIConstants.TUIGroup.GROUP_MEMBER_ID_LIST);
|
||||
|
||||
if (mGroupMembers == null || mGroupMembers.size() <= 1) {
|
||||
TUIContactLog.e(TAG, "mGroupMemberIcons <= 1");
|
||||
}
|
||||
|
||||
int num = mGroupMembers.size();
|
||||
if (num > 9) {
|
||||
num = 9;
|
||||
}
|
||||
for (int i = 0; i < num; i++) {
|
||||
groupAvatarImageId += mGroupMembers.get(i).getAccount();
|
||||
}
|
||||
|
||||
groupName = bundle.getString(TUIConstants.TUIGroup.GROUP_NAME);
|
||||
groupNameLv.setContent(groupName);
|
||||
|
||||
groupTypeLv.setContent(groupType);
|
||||
|
||||
if (TUIConfig.isEnableGroupGridAvatar()) {
|
||||
groupAvatarUrlList = fillGroupGridAvatar();
|
||||
groupAvatar.setImageId(groupAvatarImageId);
|
||||
groupAvatar.displayImage(groupAvatarUrlList).load(groupAvatarImageId);
|
||||
groupAvatarUrl = null;
|
||||
}
|
||||
|
||||
joinTypeIndex = bundle.getInt(TUIConstants.TUIGroup.JOIN_TYPE_INDEX, 2);
|
||||
}
|
||||
|
||||
private void setupViews() {
|
||||
titleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
titleBarLayout.setTitle(getString(R.string.create_group_chat), ITitleBarLayout.Position.MIDDLE);
|
||||
titleBarLayout.setOnLeftClickListener(this);
|
||||
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
groupAvatar.setRadius(radius);
|
||||
groupAvatar.setOnClickListener(this);
|
||||
groupAvatarLayout.setOnClickListener(this);
|
||||
groupNameLv.setOnClickListener(this);
|
||||
groupIdLv.setOnClickListener(this);
|
||||
groupTypeLv.setOnClickListener(this);
|
||||
groupAvatarLayout.setOnClickListener(this);
|
||||
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createGroupChat();
|
||||
}
|
||||
});
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
initGroupTypeContentView();
|
||||
}
|
||||
|
||||
private void initGroupTypeContentView() {
|
||||
switch(groupType) {
|
||||
case V2TIMManager.GROUP_TYPE_WORK:
|
||||
groupTypeContentView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_PUBLIC:
|
||||
groupTypeContentView.setText(getString(R.string.group_public_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_MEETING:
|
||||
groupTypeContentView.setText(getString(R.string.group_meeting_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_COMMUNITY:
|
||||
groupTypeContentView.setText(getString(R.string.group_commnity_des));
|
||||
break;
|
||||
default:
|
||||
groupTypeContentView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
}
|
||||
|
||||
String groupTypeContent = getResources().getString(R.string.group_type_content_title);
|
||||
String urlContent = getResources().getString(R.string.group_type_content_url);
|
||||
int urlContentIndex = groupTypeContent.lastIndexOf(urlContent);
|
||||
|
||||
final int foregroundColor;
|
||||
int currentTheme = TUIThemeManager.getInstance().getCurrentTheme();
|
||||
if (currentTheme == TUIThemeManager.THEME_LIVELY) {
|
||||
foregroundColor = getResources().getColor(com.tencent.qcloud.tuicore.R.color.core_primary_color_lively);
|
||||
} else if (currentTheme == TUIThemeManager.THEME_SERIOUS) {
|
||||
foregroundColor = getResources().getColor(com.tencent.qcloud.tuicore.R.color.core_primary_color_serious);
|
||||
} else {
|
||||
foregroundColor = getResources().getColor(com.tencent.qcloud.tuicore.R.color.core_primary_color_light);
|
||||
}
|
||||
|
||||
SpannableString spannedString = new SpannableString(groupTypeContent);
|
||||
ForegroundColorSpan colorSpan = new ForegroundColorSpan(foregroundColor);
|
||||
spannedString.setSpan(colorSpan, urlContentIndex, urlContentIndex + urlContent.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
openWebUrl(TUIContactConstants.IM_PRODUCT_DOC_URL);
|
||||
} else {
|
||||
openWebUrl(TUIContactConstants.IM_PRODUCT_DOC_URL_EN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
};
|
||||
spannedString.setSpan(clickableSpan, urlContentIndex, urlContentIndex + urlContent.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
groupTypeContentUrlView.setText(spannedString);
|
||||
groupTypeContentUrlView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == groupAvatar || v == groupAvatarLayout) {
|
||||
ArrayList<ImageSelectActivity.ImageBean> faceList = new ArrayList<>();
|
||||
if (TUIConfig.isEnableGroupGridAvatar()) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setGroupGridAvatar(fillGroupGridAvatar());
|
||||
imageBean.setImageId(groupAvatarImageId);
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
for (int i = 0; i < TUIConstants.TUIContact.GROUP_FACE_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setThumbnailUri(String.format(TUIConstants.TUIContact.GROUP_FACE_URL, (i + 1) + ""));
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CreateGroupActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getString(R.string.group_choose_avatar));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 4);
|
||||
intent.putExtra(ImageSelectActivity.PLACEHOLDER, com.tencent.qcloud.tuicore.R.drawable.core_default_user_icon_light);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_WIDTH, ScreenUtil.dip2px(77));
|
||||
intent.putExtra(ImageSelectActivity.ITEM_HEIGHT, ScreenUtil.dip2px(77));
|
||||
intent.putExtra(ImageSelectActivity.DATA, faceList);
|
||||
intent.putExtra(ImageSelectActivity.SELECTED, faceList.get(0));
|
||||
startActivityForResult(intent, CHOOSE_AVATAR_REQUEST_CODE);
|
||||
} else if (v == groupNameLv) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(this);
|
||||
popupInputCard.setContent(groupNameLv.getContent().toString());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.modify_group_name));
|
||||
popupInputCard.setMaxLimit(30);
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
groupName = result;
|
||||
groupNameLv.setContent(groupName);
|
||||
|
||||
} else {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_name_edit_null_tips));
|
||||
}
|
||||
}
|
||||
});
|
||||
popupInputCard.setTextExceedListener(new PopupInputCard.OnTextExceedListener() {
|
||||
@Override
|
||||
public void onTextExceedMax() {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_name_edit_exceed_tips));
|
||||
}
|
||||
});
|
||||
popupInputCard.show(groupNameLv, Gravity.BOTTOM);
|
||||
} else if (v == groupIdLv) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(this);
|
||||
popupInputCard.setContent(groupIdLv.getContent().toString());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.modify_group_id));
|
||||
popupInputCard.setMaxLimit(48);
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
if (!TextUtils.isEmpty(result) && result.startsWith("@TGS#")) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_id_edit_format_tips));
|
||||
groupIdLv.setContent("");
|
||||
groupId = "";
|
||||
return;
|
||||
}
|
||||
|
||||
groupIdLv.setContent(result);
|
||||
groupId = result;
|
||||
}
|
||||
});
|
||||
popupInputCard.setTextExceedListener(new PopupInputCard.OnTextExceedListener() {
|
||||
@Override
|
||||
public void onTextExceedMax(){
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_id_edit_exceed_tips));
|
||||
}
|
||||
});
|
||||
popupInputCard.show(groupIdLv, Gravity.BOTTOM);
|
||||
} else if (v == groupTypeLv) {
|
||||
Intent intent = new Intent(this, GroupTypeSelectActivity.class);
|
||||
startActivityForResult(intent, CHOOSE_GROUP_TYPE_REQUEST_CODE);
|
||||
} else if (v == titleBarLayout.getLeftGroup()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> fillGroupGridAvatar() {
|
||||
final List<Object> urlList = new ArrayList<>();
|
||||
String savedIcon = ImageUtil.getGroupConversationAvatar(groupAvatarImageId);
|
||||
if (TextUtils.isEmpty(savedIcon)) {
|
||||
int faceSize = Math.min(mGroupMembers.size(), 9);
|
||||
for (int i = 0; i < faceSize; i++) {
|
||||
String iconUrl = mGroupMembers.get(i).getIconUrl();
|
||||
urlList.add(TextUtils.isEmpty(iconUrl) ? TUIConfig.getDefaultAvatarImage() : iconUrl);
|
||||
}
|
||||
} else {
|
||||
urlList.add(savedIcon);
|
||||
}
|
||||
|
||||
return urlList;
|
||||
}
|
||||
|
||||
private void createGroupChat() {
|
||||
if (mCreating) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GroupInfo groupInfo = new GroupInfo();
|
||||
groupInfo.setChatName(groupName);
|
||||
groupInfo.setGroupName(groupName);
|
||||
groupInfo.setMemberDetails(mGroupMembers);
|
||||
groupInfo.setGroupType(groupType);
|
||||
groupInfo.setJoinType(joinTypeIndex);
|
||||
groupInfo.setCommunitySupportTopic(false);
|
||||
groupInfo.setFaceUrl(groupAvatarUrl);
|
||||
groupInfo.setId(groupId);
|
||||
|
||||
mCreating = true;
|
||||
|
||||
presenter.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ContactStartChatUtils.startChatActivity(data, ChatInfo.TYPE_GROUP, groupInfo.getGroupName(), groupInfo.getGroupType());
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mCreating = false;
|
||||
//mGroupMembers.remove(selfInfo);
|
||||
if (errCode == TUIConstants.BuyingFeature.ERR_SDK_INTERFACE_NOT_SUPPORT || errCode == 11000) {
|
||||
showNotSupportDialog();
|
||||
}
|
||||
ToastUtil.toastLongMessage("createGroupChat fail:" + errCode + "=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showNotSupportDialog() {
|
||||
String string = getResources().getString(R.string.contact_im_flagship_edition_update_tip, getString(R.string.contact_community));
|
||||
String buyingGuidelines = getResources().getString(R.string.contact_buying_guidelines);
|
||||
int buyingGuidelinesIndex = string.lastIndexOf(buyingGuidelines);
|
||||
final int foregroundColor = getResources().getColor(TUIThemeManager.getAttrResId(this, com.tencent.qcloud.tuicore.R.attr.core_primary_color));
|
||||
SpannableString spannedString = new SpannableString(string);
|
||||
ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(foregroundColor);
|
||||
spannedString.setSpan(colorSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
ClickableSpan clickableSpan2 = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC);
|
||||
} else {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC_EN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
};
|
||||
spannedString.setSpan(clickableSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance()
|
||||
.createDialog(this)
|
||||
.setMovementMethod(LinkMovementMethod.getInstance())
|
||||
.setShowOnlyDebug(true)
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(spannedString)
|
||||
.setDialogWidth(0.75f)
|
||||
.setDialogFeatureName(TUIConstants.BuyingFeature.BUYING_FEATURE_COMMUNITY)
|
||||
.setPositiveButton(getString(R.string.contact_no_more_reminders), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().setNeverShow(true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.contact_i_know), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void openWebUrl(String url) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == CHOOSE_AVATAR_REQUEST_CODE && resultCode == ImageSelectActivity.RESULT_CODE_SUCCESS) {
|
||||
if (data != null) {
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Object> faceUrl = imageBean.getGroupGridAvatar();
|
||||
if (faceUrl != null && !faceUrl.isEmpty()) {
|
||||
groupAvatar.setImageId(groupAvatarImageId);
|
||||
groupAvatar.displayImage(faceUrl).load(groupAvatarImageId);
|
||||
groupAvatarUrlList = faceUrl;
|
||||
groupAvatarUrl = null;
|
||||
} else {
|
||||
groupAvatarUrl = imageBean.getThumbnailUri();
|
||||
GlideEngine.loadImage(groupAvatar, groupAvatarUrl);
|
||||
}
|
||||
}
|
||||
} else if (requestCode == CHOOSE_GROUP_TYPE_REQUEST_CODE) {
|
||||
if (data != null) {
|
||||
String type = data.getStringExtra(TUIContactConstants.Selection.TYPE);
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
TUIContactLog.e(TAG, "onActivityResult type is null");
|
||||
return;
|
||||
}
|
||||
|
||||
groupType = type;
|
||||
groupTypeLv.setContent(type);
|
||||
initGroupTypeContentView();
|
||||
if (TextUtils.equals(groupType, V2TIMManager.GROUP_TYPE_COMMUNITY)) {
|
||||
groupIdLv.setOnClickListener(null);
|
||||
groupIdLv.setClickable(false);
|
||||
} else {
|
||||
groupIdLv.setClickable(true);
|
||||
groupIdLv.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.CustomLinearLayoutManager;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.SelectionActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ConversationInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ForwardContactSelectorAdapter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ForwardSelectGroupActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = ForwardSelectGroupActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private LineControllerView mJoinType;
|
||||
private ArrayList<GroupMemberInfo> mMembers = new ArrayList<>();
|
||||
private int mGroupType = -1;
|
||||
private int mJoinTypeIndex = 2;
|
||||
private ArrayList<String> mJoinTypes = new ArrayList<>();
|
||||
private ArrayList<String> mGroupTypeValue = new ArrayList<>();
|
||||
private boolean mCreating;
|
||||
private boolean isCreateNewChat = true;
|
||||
|
||||
private RecyclerView mForwardSelectlistView;
|
||||
private ForwardContactSelectorAdapter mAdapter;
|
||||
private List<String> mSelectConversationIcons = new ArrayList<>();
|
||||
private RelativeLayout mForwardSelectlistViewLayout;
|
||||
private TextView mSureView;
|
||||
|
||||
private List<ConversationInfo> mContactDataSource = new ArrayList<>();
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.forward_select_group_contact);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private String getMembersUserId(){
|
||||
if (mMembers.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String userIdString = "";
|
||||
for(int i = 0; i < mMembers.size(); i++){
|
||||
userIdString += mMembers.get(i).getAccount();
|
||||
userIdString += " ";
|
||||
}
|
||||
return userIdString;
|
||||
}
|
||||
|
||||
private void refreshMembers(){
|
||||
if (mContactDataSource == null || mContactDataSource.size() ==0){
|
||||
mMembers.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0;i<mContactDataSource.size();i++){
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(mContactDataSource.get(i).getId());
|
||||
memberInfo.setIconUrl((String)mContactDataSource.get(i).getIconUrlList().get(0));
|
||||
mMembers.add(memberInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null){
|
||||
isCreateNewChat = intent.getBooleanExtra(TUIContactConstants.FORWARD_CREATE_NEW_CHAT, false);
|
||||
}
|
||||
|
||||
mTitleBar = findViewById(R.id.group_create_title_bar);
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mJoinType = findViewById(R.id.group_type_join);
|
||||
mJoinType.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showJoinTypePickerView();
|
||||
}
|
||||
});
|
||||
mJoinType.setCanNav(true);
|
||||
mJoinType.setContent("Public");
|
||||
mJoinType.setVisibility(View.GONE);
|
||||
|
||||
mContactListView = findViewById(R.id.group_create_member_list);
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setFriendListListener();
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(contact.getId());
|
||||
memberInfo.setIconUrl(contact.getAvatarUrl());
|
||||
mMembers.add(memberInfo);
|
||||
} else {
|
||||
for (int i = mMembers.size() - 1; i >= 0; i--) {
|
||||
if (mMembers.get(i).getAccount().equals(contact.getId())) {
|
||||
mMembers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshSelectConversations();
|
||||
}
|
||||
});
|
||||
|
||||
setGroupType(TUIContactConstants.GroupType.PUBLIC);
|
||||
|
||||
mForwardSelectlistViewLayout = findViewById(R.id.forward_contact_select_list_layout);
|
||||
mForwardSelectlistViewLayout.setVisibility(View.VISIBLE);
|
||||
mForwardSelectlistView = findViewById(R.id.forward_contact_select_list);
|
||||
mForwardSelectlistView.setLayoutManager(new CustomLinearLayoutManager(this, CustomLinearLayoutManager.HORIZONTAL, false));
|
||||
mAdapter = new ForwardContactSelectorAdapter(this);
|
||||
mForwardSelectlistView.setAdapter(mAdapter);
|
||||
|
||||
mSureView = findViewById(R.id.btn_msg_ok);
|
||||
mSureView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isCreateNewChat){
|
||||
createGroupChat();
|
||||
} else {
|
||||
Intent intent = new Intent();
|
||||
HashMap<String, String> conversationMap = new HashMap<>();
|
||||
if (mMembers != null && mMembers.size() != 0){
|
||||
for (int i=0;i<mMembers.size();i++){
|
||||
conversationMap.put(mMembers.get(i).getAccount(), mMembers.get(i).getIconUrl());
|
||||
}
|
||||
}
|
||||
|
||||
intent.putExtra(TUIContactConstants.FORWARD_SELECT_CONVERSATION_KEY, conversationMap);
|
||||
setResult(TUIContactConstants.FORWARD_SELECT_MEMBERS_CODE, intent);
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
refreshSelectConversations();
|
||||
}
|
||||
|
||||
private void refreshSelectConversations(){
|
||||
mSelectConversationIcons.clear();
|
||||
if (mMembers != null && mMembers.size() != 0){
|
||||
for (int i=0;i<mMembers.size();i++){
|
||||
mSelectConversationIcons.add(mMembers.get(i).getIconUrl());
|
||||
}
|
||||
}
|
||||
mAdapter.setDataSource(mSelectConversationIcons);
|
||||
|
||||
if (mSelectConversationIcons == null || mSelectConversationIcons.size() == 0){
|
||||
mSureView.setText(getString(com.tencent.qcloud.tuicore.R.string.sure));
|
||||
mSureView.setVisibility(View.GONE);
|
||||
mForwardSelectlistViewLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
mForwardSelectlistViewLayout.setVisibility(View.VISIBLE);
|
||||
mSureView.setVisibility(View.VISIBLE);
|
||||
mSureView.setText(getString(com.tencent.qcloud.tuicore.R.string.sure) + "(" + mSelectConversationIcons.size() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public void setGroupType(int type) {
|
||||
mGroupType = type;
|
||||
mTitleBar.setTitle(getResources().getString(R.string.contact_title), ITitleBarLayout.Position.MIDDLE);
|
||||
mJoinType.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showJoinTypePickerView() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SelectionActivity.Selection.TITLE, getResources().getString(R.string.group_join_type));
|
||||
bundle.putStringArrayList(SelectionActivity.Selection.LIST, mJoinTypes);
|
||||
bundle.putInt(SelectionActivity.Selection.DEFAULT_SELECT_ITEM_INDEX, mJoinTypeIndex);
|
||||
SelectionActivity.startListSelection(this, bundle, new SelectionActivity.OnResultReturnListener() {
|
||||
@Override
|
||||
public void onReturn(Object text) {
|
||||
mJoinType.setContent(mJoinTypes.get((Integer) text));
|
||||
mJoinTypeIndex = (Integer) text;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createGroupChat() {
|
||||
if (mCreating || mMembers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMembers.size() == 1){
|
||||
Intent intent = new Intent();
|
||||
HashMap<String, Boolean> conversationMap = new HashMap<>();
|
||||
conversationMap.put(mMembers.get(0).getAccount(), false);
|
||||
intent.putExtra(TUIContactConstants.FORWARD_SELECT_CONVERSATION_KEY, conversationMap);
|
||||
setResult(TUIContactConstants.FORWARD_CREATE_GROUP_CODE, intent);
|
||||
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(ContactUtils.getLoginUser());
|
||||
mMembers.add(memberInfo);
|
||||
|
||||
final GroupInfo groupInfo = new GroupInfo();
|
||||
String groupName = ContactUtils.getLoginUser();
|
||||
for (int i = 1; i < mMembers.size(); i++) {
|
||||
groupName = groupName + "、" + mMembers.get(i).getAccount();
|
||||
}
|
||||
if (groupName.length() > 20) {
|
||||
groupName = groupName.substring(0, 17) + "...";
|
||||
}
|
||||
groupInfo.setChatName(groupName);
|
||||
groupInfo.setGroupName(groupName);
|
||||
groupInfo.setMemberDetails(mMembers);
|
||||
groupInfo.setGroupType(TUIContactConstants.GroupType.TYPE_PUBLIC);
|
||||
groupInfo.setJoinType(0);
|
||||
|
||||
mCreating = true;
|
||||
|
||||
presenter.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
Intent intent = new Intent();
|
||||
HashMap<String, Boolean> conversationMap = new HashMap<>();
|
||||
conversationMap.put(data, true);
|
||||
|
||||
intent.putExtra(TUIContactConstants.FORWARD_SELECT_CONVERSATION_KEY, conversationMap);
|
||||
setResult(TUIContactConstants.FORWARD_CREATE_GROUP_CODE, intent);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mCreating = false;
|
||||
ToastUtil.toastLongMessage("createGroupChat fail:" + errCode + "=" + errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupApplication;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.ImageSelectActivity;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactGroupApplyInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.FriendProfileLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.FriendProfilePresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class FriendProfileActivity extends BaseLightActivity {
|
||||
|
||||
private FriendProfilePresenter presenter;
|
||||
private FriendProfileLayout layout;
|
||||
private String mChatId;
|
||||
private String mChatBackgroundThumbnailUrl;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.contact_friend_profile_activity);
|
||||
layout = findViewById(R.id.friend_profile);
|
||||
System.out.println("聊天界面");
|
||||
presenter = new FriendProfilePresenter();
|
||||
layout.setPresenter(presenter);
|
||||
presenter.setFriendProfileLayout(layout);
|
||||
Intent intent = getIntent();
|
||||
mChatId = intent.getStringExtra(TUIConstants.TUIChat.CHAT_ID);
|
||||
mChatBackgroundThumbnailUrl = intent.getStringExtra(TUIConstants.TUIChat.CHAT_BACKGROUND_URI);
|
||||
String fromUser = intent.getStringExtra("fromUser");
|
||||
String fromUserNickName = intent.getStringExtra("fromUserNickName");
|
||||
String requestMsg = intent.getStringExtra("requestMsg");
|
||||
V2TIMGroupApplication application = (V2TIMGroupApplication) intent.getSerializableExtra("groupApplication");
|
||||
|
||||
if (!TextUtils.isEmpty(mChatId)) {
|
||||
layout.initData(mChatId);
|
||||
} else if (!TextUtils.isEmpty(fromUser)) {
|
||||
ContactGroupApplyInfo contactGroupApplyInfo = new ContactGroupApplyInfo();
|
||||
contactGroupApplyInfo.setFromUser(fromUser);
|
||||
contactGroupApplyInfo.setFromUserNickName(fromUserNickName);
|
||||
contactGroupApplyInfo.setRequestMsg(requestMsg);
|
||||
contactGroupApplyInfo.setTimGroupApplication(application);
|
||||
layout.initData(contactGroupApplyInfo);
|
||||
} else {
|
||||
layout.initData(intent.getSerializableExtra(TUIContactConstants.ProfileType.CONTENT));
|
||||
}
|
||||
layout.setOnButtonClickListener(new FriendProfileLayout.OnButtonClickListener() {
|
||||
@Override
|
||||
public void onStartConversationClick(ContactItemBean info) {
|
||||
String chatName = info.getId();
|
||||
if (!TextUtils.isEmpty(info.getRemark())) {
|
||||
chatName = info.getRemark();
|
||||
} else if (!TextUtils.isEmpty(info.getNickName())) {
|
||||
chatName = info.getNickName();
|
||||
}
|
||||
ContactStartChatUtils.startChatActivity(info.getId(), ContactItemBean.TYPE_C2C, chatName, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteFriendClick(String id) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetChatBackground() {
|
||||
ArrayList<ImageSelectActivity.ImageBean> faceList = new ArrayList<>();
|
||||
ImageSelectActivity.ImageBean defaultFace = new ImageSelectActivity.ImageBean();
|
||||
defaultFace.setDefault(true);
|
||||
faceList.add(defaultFace);
|
||||
for (int i = 0; i < TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setImageUri(String.format(TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_URL, (i + 1) + ""));
|
||||
imageBean.setThumbnailUri(String.format(TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_THUMBNAIL_URL, (i + 1) + ""));
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(FriendProfileActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getResources().getString(R.string.chat_background_title));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 2);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_WIDTH, ScreenUtil.dip2px(186));
|
||||
intent.putExtra(ImageSelectActivity.ITEM_HEIGHT, ScreenUtil.dip2px(124));
|
||||
intent.putExtra(ImageSelectActivity.DATA, faceList);
|
||||
if (TextUtils.isEmpty(mChatBackgroundThumbnailUrl) || TextUtils.equals(TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_DEFAULT_URL, mChatBackgroundThumbnailUrl)) {
|
||||
intent.putExtra(ImageSelectActivity.SELECTED, defaultFace);
|
||||
} else {
|
||||
intent.putExtra(ImageSelectActivity.SELECTED, new ImageSelectActivity.ImageBean(mChatBackgroundThumbnailUrl, "", false));
|
||||
}
|
||||
intent.putExtra(ImageSelectActivity.NEED_DOWLOAD_LOCAL, true);
|
||||
startActivityForResult(intent, TUIConstants.TUIChat.CHAT_REQUEST_BACKGROUND_CODE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == TUIConstants.TUIChat.CHAT_REQUEST_BACKGROUND_CODE) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
TUIContactLog.e("FriendProfileActivity", "onActivityResult imageBean is null");
|
||||
return;
|
||||
}
|
||||
|
||||
String backgroundUri = imageBean.getLocalPath();
|
||||
String thumbnailUri = imageBean.getThumbnailUri();
|
||||
String dataUri = thumbnailUri + "," + backgroundUri;
|
||||
TUIContactLog.d("FriendProfileActivity", "onActivityResult backgroundUri = " + backgroundUri);
|
||||
mChatBackgroundThumbnailUrl = thumbnailUri;
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIChat.CHAT_ID, mChatId);
|
||||
param.put(TUIConstants.TUIChat.CHAT_BACKGROUND_URI, dataUri);
|
||||
TUICore.callService(TUIConstants.TUIChat.SERVICE_NAME, TUIConstants.TUIChat.METHOD_UPDATE_DATA_STORE_CHAT_URI, param);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
public class GroupListActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = GroupListActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mListView;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.group_list_activity);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
loadDataSource();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mTitleBar = findViewById(R.id.group_list_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.group), ITitleBarLayout.Position.LEFT);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.setTitle(getResources().getString(R.string.add_group), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(GroupListActivity.this, AddMoreActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("isGroup", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
mListView = findViewById(R.id.group_list);
|
||||
mListView.setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
String chatName = contact.getId();
|
||||
if (!TextUtils.isEmpty(contact.getRemark())) {
|
||||
chatName = contact.getRemark();
|
||||
} else if (!TextUtils.isEmpty(contact.getNickName())) {
|
||||
chatName = contact.getNickName();
|
||||
}
|
||||
ContactStartChatUtils.startChatActivity(contact.getId(), ContactItemBean.TYPE_GROUP, chatName, contact.getGroupType());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadDataSource() {
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mListView.setIsGroupList(true);
|
||||
mListView.setPresenter(presenter);
|
||||
mListView.setNotFoundTip(getString(R.string.contact_no_group));
|
||||
presenter.setContactListView(mListView);
|
||||
mListView.loadDataSource(ContactListView.DataSource.GROUP_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupTypeSelectActivity extends BaseLightActivity implements View.OnClickListener {
|
||||
private static final String TAG = GroupTypeSelectActivity.class.getSimpleName();
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private RecyclerView.LayoutManager mLayoutManager;
|
||||
private RecyclerView.Adapter mAdapter;
|
||||
private List<String> mDatas = new ArrayList<>();
|
||||
private TitleBarLayout titleBarLayout;
|
||||
private TextView groupTypeTextView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.group_type_select_layout);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
||||
mAdapter = new MyAdapter(mDatas);
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
titleBarLayout = findViewById(R.id.create_group_bar);
|
||||
titleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
titleBarLayout.setTitle(getString(R.string.group_type_select_text), ITitleBarLayout.Position.MIDDLE);
|
||||
titleBarLayout.setOnLeftClickListener(this);
|
||||
groupTypeTextView = findViewById(R.id.group_type_text);
|
||||
groupTypeTextView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String url = "";
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
url = TUIContactConstants.IM_PRODUCT_DOC_URL;
|
||||
} else {
|
||||
url = TUIContactConstants.IM_PRODUCT_DOC_URL_EN;
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
String[] array = getResources().getStringArray(R.array.group_type);
|
||||
mDatas.addAll(Arrays.asList(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view == titleBarLayout.getLeftGroup()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>{
|
||||
private List<String> mDatas;
|
||||
|
||||
public MyAdapter(List<String> datas) {
|
||||
this.mDatas = datas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.group_type_item, parent, false);
|
||||
ViewHolder viewHolder = new ViewHolder(v);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
String type = this.mDatas.get(position);
|
||||
holder.imageView.setImageResource(TUIUtil.getDefaultGroupIconResIDByGroupType(getApplicationContext(), type));
|
||||
switch(type) {
|
||||
case V2TIMManager.GROUP_TYPE_WORK:
|
||||
holder.textView.setText(getString(R.string.group_work_type));
|
||||
holder.subTextView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_PUBLIC:
|
||||
holder.textView.setText(getString(R.string.group_public_type));
|
||||
holder.subTextView.setText(getString(R.string.group_public_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_MEETING:
|
||||
holder.textView.setText(getString(R.string.group_meeting_type));
|
||||
holder.subTextView.setText(getString(R.string.group_meeting_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_COMMUNITY:
|
||||
holder.textView.setText(getString(R.string.group_commnity_type));
|
||||
holder.subTextView.setText(getString(R.string.group_commnity_des));
|
||||
break;
|
||||
default:
|
||||
holder.textView.setText(getString(R.string.group_work_type));
|
||||
holder.subTextView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
}
|
||||
|
||||
holder.rootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(TUIContactConstants.Selection.TYPE, type);
|
||||
setResult(0, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.mDatas == null ? 0 : this.mDatas.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
View rootView;
|
||||
RelativeLayout itemLayout;
|
||||
ImageView imageView;
|
||||
TextView textView, subTextView;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
rootView = itemView;
|
||||
itemLayout = (RelativeLayout) itemView.findViewById(R.id.item_layout);
|
||||
imageView = (ImageView) itemView.findViewById(R.id.group_type_icon);
|
||||
textView = (TextView) itemView.findViewById(R.id.group_type_text);
|
||||
subTextView = (TextView) itemView.findViewById(R.id.group_type_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.NewFriendListAdapter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.INewFriendActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.NewFriendPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NewFriendActivity extends BaseLightActivity implements INewFriendActivity {
|
||||
|
||||
private static final String TAG = NewFriendActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ListView mNewFriendLv;
|
||||
private NewFriendListAdapter mAdapter;
|
||||
private TextView notFoundTip;
|
||||
|
||||
private NewFriendPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.contact_new_friend_activity);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
initPendency();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mTitleBar = findViewById(R.id.new_friend_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.new_friend), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
presenter = new NewFriendPresenter();
|
||||
presenter.setFriendActivity(this);
|
||||
presenter.setFriendApplicationListAllRead(new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
mNewFriendLv = findViewById(R.id.new_friend_list);
|
||||
notFoundTip = findViewById(R.id.not_found_tip);
|
||||
}
|
||||
|
||||
private void initPendency() {
|
||||
presenter.loadFriendApplicationList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSourceChanged(List<FriendApplicationBean> dataSource) {
|
||||
TUIContactLog.i(TAG, "getFriendApplicationList success");
|
||||
if (dataSource == null || dataSource.isEmpty()) {
|
||||
notFoundTip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
notFoundTip.setVisibility(View.GONE);
|
||||
}
|
||||
mNewFriendLv.setVisibility(View.VISIBLE);
|
||||
mAdapter = new NewFriendListAdapter(NewFriendActivity.this, R.layout.contact_new_friend_item, dataSource);
|
||||
mAdapter.setPresenter(presenter);
|
||||
mNewFriendLv.setAdapter(mAdapter);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StartC2CChatActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = StartC2CChatActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private ContactItemBean mSelectedItem;
|
||||
private List<ContactItemBean> mContacts = new ArrayList<>();
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.popup_start_c2c_chat_activity);
|
||||
|
||||
mTitleBar = findViewById(R.id.start_c2c_chat_title);
|
||||
mTitleBar.setTitle(getResources().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startConversation();
|
||||
}
|
||||
});
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mContactListView = findViewById(R.id.contact_list_view);
|
||||
mContactListView.setSingleSelectMode(true);
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
if (mSelectedItem == contact) {
|
||||
|
||||
} else {
|
||||
if (mSelectedItem != null) {
|
||||
mSelectedItem.setSelected(false);
|
||||
}
|
||||
mSelectedItem = contact;
|
||||
}
|
||||
} else {
|
||||
if (mSelectedItem == contact) {
|
||||
mSelectedItem.setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void startConversation() {
|
||||
if (mSelectedItem == null || !mSelectedItem.isSelected()) {
|
||||
ToastUtil.toastLongMessage(getString(R.string.select_chat));
|
||||
return;
|
||||
}
|
||||
String chatName = mSelectedItem.getId();
|
||||
if (!TextUtils.isEmpty(mSelectedItem.getRemark())) {
|
||||
chatName = mSelectedItem.getRemark();
|
||||
} else if (!TextUtils.isEmpty(mSelectedItem.getNickName())) {
|
||||
chatName = mSelectedItem.getNickName();
|
||||
}
|
||||
|
||||
ContactStartChatUtils.startChatActivity(mSelectedItem.getId(), ContactItemBean.TYPE_C2C, chatName, "");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.SelectionActivity;
|
||||
import com.tencent.qcloud.tuicore.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ChatInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StartGroupChatActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = StartGroupChatActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private LineControllerView mJoinType;
|
||||
private ArrayList<GroupMemberInfo> mMembers = new ArrayList<>();
|
||||
private int mGroupType = -1;
|
||||
private boolean communitySupportTopic = false;
|
||||
private int mJoinTypeIndex = 2;
|
||||
private ArrayList<String> mJoinTypes = new ArrayList<>();
|
||||
private ArrayList<String> mGroupTypeValue = new ArrayList<>();
|
||||
private boolean mCreating;
|
||||
private RecyclerView selectedList;
|
||||
private StartGroupMemberSelectActivity.SelectedAdapter selectedListAdapter;
|
||||
private TextView confirmButton;
|
||||
private ContactPresenter presenter;
|
||||
private GroupMemberInfo selfInfo;
|
||||
private int limit;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.popup_start_group_chat_activity);
|
||||
selfInfo = new GroupMemberInfo();
|
||||
selfInfo.setAccount(ContactUtils.getLoginUser());
|
||||
selfInfo.setNickName(TUIConfig.getSelfNickName());
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
limit = getIntent().getIntExtra(TUIContactConstants.Selection.LIMIT, Integer.MAX_VALUE);
|
||||
String[] array = getResources().getStringArray(R.array.group_type);
|
||||
mGroupTypeValue.addAll(Arrays.asList(array));
|
||||
array = getResources().getStringArray(R.array.group_join_type);
|
||||
mJoinTypes.addAll(Arrays.asList(array));
|
||||
|
||||
mTitleBar = findViewById(R.id.group_create_title_bar);
|
||||
mTitleBar.setTitle(getResources().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toCreateGroupChat();
|
||||
}
|
||||
});
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mJoinType = findViewById(R.id.group_type_join);
|
||||
mJoinType.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showJoinTypePickerView();
|
||||
}
|
||||
});
|
||||
mJoinType.setCanNav(true);
|
||||
mJoinType.setContent(mJoinTypes.get(2));
|
||||
|
||||
mContactListView = findViewById(R.id.group_create_member_list);
|
||||
confirmButton = findViewById(R.id.confirm_button);
|
||||
selectedList = findViewById(R.id.selected_list);
|
||||
selectedListAdapter = new StartGroupMemberSelectActivity.SelectedAdapter();
|
||||
selectedList.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
|
||||
selectedList.setAdapter(selectedListAdapter);
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
ArrayList<String> alreadySelectedList = new ArrayList<>();
|
||||
alreadySelectedList.add(TUILogin.getLoginUser());
|
||||
mContactListView.setAlreadySelectedList(alreadySelectedList);
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(contact.getId());
|
||||
memberInfo.setNickName(contact.getNickName());
|
||||
memberInfo.setIconUrl(contact.getAvatarUrl());
|
||||
mMembers.add(memberInfo);
|
||||
} else {
|
||||
for (int i = mMembers.size() - 1; i >= 0; i--) {
|
||||
if (mMembers.get(i).getAccount().equals(contact.getId())) {
|
||||
mMembers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedListAdapter.setMembers(mMembers);
|
||||
selectedListAdapter.notifyDataSetChanged();
|
||||
if (mMembers.size() > 0) {
|
||||
confirmButton.setAlpha(1f);
|
||||
confirmButton.setEnabled(true);
|
||||
} else {
|
||||
confirmButton.setAlpha(0.5f);
|
||||
confirmButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toCreateGroupChat();
|
||||
}
|
||||
});
|
||||
confirmButton.setAlpha(0.5f);
|
||||
confirmButton.setEnabled(false);
|
||||
Intent intent = getIntent();
|
||||
communitySupportTopic = intent.getBooleanExtra(TUIConstants.TUIContact.COMMUNITY_SUPPORT_TOPIC_KEY, false);
|
||||
setGroupType(intent.getIntExtra(TUIConstants.TUIContact.GROUP_TYPE_KEY, TUIContactConstants.GroupType.PRIVATE));
|
||||
}
|
||||
|
||||
public void setGroupType(int type) {
|
||||
mGroupType = type;
|
||||
switch (type) {
|
||||
case TUIContactConstants.GroupType.PUBLIC:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_group_chat), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
case TUIContactConstants.GroupType.CHAT_ROOM:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_chat_room), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
case TUIContactConstants.GroupType.COMMUNITY:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_community), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
case TUIContactConstants.GroupType.PRIVATE:
|
||||
default:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_private_group), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showJoinTypePickerView() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SelectionActivity.Selection.TITLE, getResources().getString(R.string.group_join_type));
|
||||
bundle.putStringArrayList(SelectionActivity.Selection.LIST, mJoinTypes);
|
||||
bundle.putInt(SelectionActivity.Selection.DEFAULT_SELECT_ITEM_INDEX, mJoinTypeIndex);
|
||||
SelectionActivity.startListSelection(this, bundle, new SelectionActivity.OnResultReturnListener() {
|
||||
@Override
|
||||
public void onReturn(Object text) {
|
||||
mJoinType.setContent(mJoinTypes.get((Integer) text));
|
||||
mJoinTypeIndex = (Integer) text;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toCreateGroupChat() {
|
||||
mMembers.add(0, selfInfo);
|
||||
if (mMembers.size() == 1) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.tips_empty_group_member));
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = selfInfo.getDisplayName();
|
||||
for (int i = 1; i < mMembers.size(); i++) {
|
||||
groupName = groupName + "、" + mMembers.get(i).getDisplayName();
|
||||
}
|
||||
if (groupName.length() >= 10) {
|
||||
groupName = groupName.substring(0, 7) + "..";
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TUIGroup.GROUP_NAME, groupName);
|
||||
bundle.putInt(TUIConstants.TUIGroup.JOIN_TYPE_INDEX, mJoinTypeIndex);
|
||||
bundle.putSerializable(TUIConstants.TUIGroup.GROUP_MEMBER_ID_LIST, mMembers);
|
||||
TUICore.startActivity("CreateGroupActivity", bundle);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void createGroupChat() {
|
||||
if (mCreating) {
|
||||
return;
|
||||
}
|
||||
mMembers.add(0, selfInfo);
|
||||
if (mGroupType < 3 && mMembers.size() == 1) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.tips_empty_group_member));
|
||||
return;
|
||||
}
|
||||
if (mGroupType > 0 && mJoinTypeIndex == -1) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.tips_empty_group_type));
|
||||
return;
|
||||
}
|
||||
if (mGroupType == 0) {
|
||||
mJoinTypeIndex = -1;
|
||||
}
|
||||
final GroupInfo groupInfo = new GroupInfo();
|
||||
String groupName = selfInfo.getDisplayName();
|
||||
for (int i = 1; i < mMembers.size(); i++) {
|
||||
groupName = groupName + "、" + mMembers.get(i).getDisplayName();
|
||||
}
|
||||
if (groupName.length() >= 10) {
|
||||
groupName = groupName.substring(0, 7) + "..";
|
||||
}
|
||||
groupInfo.setChatName(groupName);
|
||||
groupInfo.setGroupName(groupName);
|
||||
groupInfo.setMemberDetails(mMembers);
|
||||
groupInfo.setGroupType(mGroupTypeValue.get(mGroupType));
|
||||
groupInfo.setJoinType(mJoinTypeIndex);
|
||||
groupInfo.setCommunitySupportTopic(communitySupportTopic);
|
||||
|
||||
mCreating = true;
|
||||
|
||||
presenter.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
if (!communitySupportTopic) {
|
||||
ContactStartChatUtils.startChatActivity(data, ChatInfo.TYPE_GROUP, groupInfo.getGroupName(), groupInfo.getGroupType());
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mCreating = false;
|
||||
mMembers.remove(selfInfo);
|
||||
if (errCode == TUIConstants.BuyingFeature.ERR_SDK_INTERFACE_NOT_SUPPORT || errCode == 11000) {
|
||||
showNotSupportDialog();
|
||||
}
|
||||
ToastUtil.toastLongMessage("createGroupChat fail:" + errCode + "=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showNotSupportDialog() {
|
||||
String string = getResources().getString(R.string.contact_im_flagship_edition_update_tip, getString(R.string.contact_community));
|
||||
String buyingGuidelines = getResources().getString(R.string.contact_buying_guidelines);
|
||||
int buyingGuidelinesIndex = string.lastIndexOf(buyingGuidelines);
|
||||
final int foregroundColor = getResources().getColor(TUIThemeManager.getAttrResId(this, com.tencent.qcloud.tuicore.R.attr.core_primary_color));
|
||||
SpannableString spannedString = new SpannableString(string);
|
||||
ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(foregroundColor);
|
||||
spannedString.setSpan(colorSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
ClickableSpan clickableSpan2 = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC);
|
||||
} else {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC_EN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
};
|
||||
spannedString.setSpan(clickableSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance()
|
||||
.createDialog(this)
|
||||
.setMovementMethod(LinkMovementMethod.getInstance())
|
||||
.setShowOnlyDebug(true)
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(spannedString)
|
||||
.setDialogWidth(0.75f)
|
||||
.setDialogFeatureName(TUIConstants.BuyingFeature.BUYING_FEATURE_COMMUNITY)
|
||||
.setPositiveButton(getString(R.string.contact_no_more_reminders), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().setNeverShow(true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.contact_i_know), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void openWebUrl(String url) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StartGroupMemberSelectActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = StartGroupMemberSelectActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private ArrayList<GroupMemberInfo> mMembers = new ArrayList<>();
|
||||
private ArrayList<String> alreadySelectedList;
|
||||
private RecyclerView selectedList;
|
||||
private SelectedAdapter selectedListAdapter;
|
||||
private TextView confirmButton;
|
||||
private ContactPresenter presenter;
|
||||
private int limit;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.popup_start_group_select_activity);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private ArrayList<String> getMembersNameCard(){
|
||||
if (mMembers.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ArrayList<String> nameCards = new ArrayList<>();
|
||||
for(int i = 0; i < mMembers.size(); i++){
|
||||
nameCards.add(mMembers.get(i).getNameCard());
|
||||
}
|
||||
return nameCards;
|
||||
}
|
||||
|
||||
private ArrayList<String> getMembersUserId(){
|
||||
if (mMembers.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ArrayList<String> userIds = new ArrayList<>();
|
||||
for(int i = 0; i < mMembers.size(); i++){
|
||||
userIds.add(mMembers.get(i).getAccount());
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMembers.clear();
|
||||
|
||||
String groupId = getIntent().getStringExtra(TUIContactConstants.Group.GROUP_ID);
|
||||
boolean isSelectFriends = getIntent().getBooleanExtra(TUIContactConstants.Selection.SELECT_FRIENDS, false);
|
||||
boolean isSelectForCall = getIntent().getBooleanExtra(TUIContactConstants.Selection.SELECT_FOR_CALL, true);
|
||||
limit = getIntent().getIntExtra(TUIContactConstants.Selection.LIMIT, Integer.MAX_VALUE);
|
||||
alreadySelectedList = getIntent().getStringArrayListExtra(TUIContactConstants.Selection.SELECTED_LIST);
|
||||
mTitleBar = findViewById(R.id.group_create_title_bar);
|
||||
mTitleBar.setTitle(getResources().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmAndFinish();
|
||||
}
|
||||
});
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
confirmButton = findViewById(R.id.confirm_button);
|
||||
selectedList = findViewById(R.id.selected_list);
|
||||
selectedListAdapter = new SelectedAdapter();
|
||||
selectedList.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
|
||||
selectedList.setAdapter(selectedListAdapter);
|
||||
mContactListView = findViewById(R.id.group_create_member_list);
|
||||
mContactListView.setAlreadySelectedList(alreadySelectedList);
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
presenter.setIsForCall(isSelectForCall);
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
mContactListView.setGroupId(groupId);
|
||||
if (isSelectFriends) {
|
||||
mTitleBar.setTitle(getString(R.string.add_group_member), TitleBarLayout.Position.MIDDLE);
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
} else {
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.GROUP_MEMBER_LIST);
|
||||
}
|
||||
|
||||
if (!isSelectForCall && !isSelectFriends) {
|
||||
mContactListView.setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
if (position == 0) {
|
||||
mMembers.clear();
|
||||
|
||||
Intent i = new Intent();
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_NAMECARD_SELECT, new ArrayList<String>(Arrays.asList(getString(R.string.at_all))));
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_ID_SELECT, new ArrayList<String>(Arrays.asList(TUIContactConstants.Selection.SELECT_ALL)));
|
||||
setResult(3, i);
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(contact.getId());
|
||||
memberInfo.setIconUrl(contact.getAvatarUrl());
|
||||
memberInfo.setNameCard(TextUtils.isEmpty(contact.getNickName()) ? contact.getId() : contact.getNickName());
|
||||
mMembers.add(memberInfo);
|
||||
} else {
|
||||
for (int i = mMembers.size() - 1; i >= 0; i--) {
|
||||
if (mMembers.get(i).getAccount().equals(contact.getId())) {
|
||||
mMembers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedListAdapter.setMembers(mMembers);
|
||||
selectedListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmAndFinish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void confirmAndFinish() {
|
||||
if (mMembers.size() > limit) {
|
||||
String overLimitTip = getString(R.string.contact_over_limit_tip, limit);
|
||||
ToastUtil.toastShortMessage(overLimitTip);
|
||||
return;
|
||||
}
|
||||
Intent i = new Intent();
|
||||
List<String> friendIdList = new ArrayList<>();
|
||||
for (GroupMemberInfo memberInfo : mMembers) {
|
||||
friendIdList.add(memberInfo.getAccount());
|
||||
}
|
||||
i.putExtra(TUIContactConstants.Selection.LIST, (Serializable) friendIdList);
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_NAMECARD_SELECT, getMembersNameCard());
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_ID_SELECT, getMembersUserId());
|
||||
i.putExtras(getIntent());
|
||||
setResult(3, i);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class SelectedAdapter extends RecyclerView.Adapter<SelectedAdapter.SelectedViewHolder> {
|
||||
private List<GroupMemberInfo> mMembers;
|
||||
|
||||
public void setMembers(List<GroupMemberInfo> mMembers) {
|
||||
this.mMembers = mMembers;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SelectedViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new SelectedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.forward_contact_selector_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull StartGroupMemberSelectActivity.SelectedAdapter.SelectedViewHolder holder, int position) {
|
||||
GlideEngine.loadImage(holder.userIconView, mMembers.get(position).getIconUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mMembers == null) {
|
||||
return 0;
|
||||
}
|
||||
return mMembers.size();
|
||||
}
|
||||
|
||||
public class SelectedViewHolder extends RecyclerView.ViewHolder {
|
||||
public ImageView userIconView;
|
||||
public SelectedViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
userIconView = (ImageView) itemView.findViewById(R.id.ivAvatar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.fragments.BaseFragment;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
public class TUIContactFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = TUIContactFragment.class.getSimpleName();
|
||||
private ContactLayout mContactLayout;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||
View baseView = inflater.inflate(R.layout.contact_fragment, container, false);
|
||||
initViews(baseView);
|
||||
|
||||
return baseView;
|
||||
}
|
||||
|
||||
private void initViews(View view) {
|
||||
mContactLayout = view.findViewById(R.id.contact_layout);
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mContactLayout.setPresenter(presenter);
|
||||
mContactLayout.initDefault();
|
||||
|
||||
mContactLayout.getContactListView().setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
if (position == 0) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), NewFriendActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
} else if (position == 1) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), GroupListActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
} else if (position == 2) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), BlackListActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), FriendProfileActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, contact);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
TUIContactLog.i(TAG, "onResume");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.util;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
|
||||
public class ContactStartChatUtils {
|
||||
public static boolean isC2CChat(int chatType) {
|
||||
return chatType == V2TIMConversation.V2TIM_C2C;
|
||||
}
|
||||
|
||||
public static boolean isGroupChat(int chatType) {
|
||||
return chatType == V2TIMConversation.V2TIM_GROUP;
|
||||
}
|
||||
|
||||
public static void startChatActivity(String chatId, int chatType, String chatName, String groupType) {
|
||||
if (TextUtils.isEmpty(chatId)) {
|
||||
return;
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_ID, chatId);
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_NAME, chatName);
|
||||
bundle.putInt(TUIConstants.TUIChat.CHAT_TYPE, chatType);
|
||||
if (isC2CChat(chatType)) {
|
||||
TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, bundle);
|
||||
} else if (isGroupChat(chatType)) {
|
||||
bundle.putString(TUIConstants.TUIChat.GROUP_TYPE, groupType);
|
||||
TUICore.startActivity(TUIConstants.TUIChat.GROUP_CHAT_ACTIVITY_NAME, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLoginUser() {
|
||||
return V2TIMManager.getInstance().getLoginUser();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.config.TUIContactConfig;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ViewHolder> {
|
||||
|
||||
protected List<ContactItemBean> mData;
|
||||
private ContactListView.OnSelectChangedListener mOnSelectChangedListener;
|
||||
private ContactListView.OnItemClickListener mOnClickListener;
|
||||
|
||||
private int mPreSelectedPosition;
|
||||
private boolean isSingleSelectMode;
|
||||
private ContactPresenter presenter;
|
||||
private boolean isGroupList = false;
|
||||
private int dataSourceType = ContactListView.DataSource.UNKNOWN;
|
||||
private ArrayList<String> alreadySelectedList;
|
||||
|
||||
public ContactAdapter(List<ContactItemBean> data) {
|
||||
this.mData = data;
|
||||
}
|
||||
|
||||
public void setPresenter(ContactPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
public void setIsGroupList(boolean groupList) {
|
||||
isGroupList = groupList;
|
||||
}
|
||||
|
||||
public void setAlreadySelectedList(ArrayList<String> alreadySelectedList) {
|
||||
this.alreadySelectedList = alreadySelectedList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ContactAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_selecable_adapter_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ContactAdapter.ViewHolder holder, final int position) {
|
||||
final ContactItemBean contactBean = mData.get(position);
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)holder.line.getLayoutParams();
|
||||
if (position < mData.size() - 1) {
|
||||
String tag1 = contactBean.getSuspensionTag();
|
||||
String tag2 = mData.get(position + 1).getSuspensionTag();
|
||||
|
||||
if (TextUtils.equals(tag1, tag2)) {
|
||||
params.leftMargin = holder.tvName.getLeft();
|
||||
} else {
|
||||
params.leftMargin = 0;
|
||||
}
|
||||
} else {
|
||||
params.leftMargin = 0;
|
||||
}
|
||||
holder.line.setLayoutParams(params);
|
||||
if (!TextUtils.isEmpty(contactBean.getRemark())) {
|
||||
holder.tvName.setText(contactBean.getRemark());
|
||||
} else if (!TextUtils.isEmpty(contactBean.getNickName())) {
|
||||
holder.tvName.setText(contactBean.getNickName());
|
||||
} else {
|
||||
holder.tvName.setText(contactBean.getId());
|
||||
}
|
||||
if (mOnSelectChangedListener != null) {
|
||||
holder.ccSelect.setVisibility(View.VISIBLE);
|
||||
holder.ccSelect.setChecked(contactBean.isSelected());
|
||||
}
|
||||
|
||||
holder.content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!contactBean.isEnable()) {
|
||||
return;
|
||||
}
|
||||
holder.ccSelect.setChecked(!holder.ccSelect.isChecked());
|
||||
if (mOnSelectChangedListener != null) {
|
||||
mOnSelectChangedListener.onSelectChanged(getItem(position), holder.ccSelect.isChecked());
|
||||
}
|
||||
contactBean.setSelected(holder.ccSelect.isChecked());
|
||||
if (mOnClickListener != null) {
|
||||
mOnClickListener.onItemClick(position, contactBean);
|
||||
}
|
||||
if (isSingleSelectMode && position != mPreSelectedPosition && contactBean.isSelected()) {
|
||||
mData.get(mPreSelectedPosition).setSelected(false);
|
||||
notifyItemChanged(mPreSelectedPosition);
|
||||
}
|
||||
mPreSelectedPosition = position;
|
||||
}
|
||||
});
|
||||
holder.unreadText.setVisibility(View.GONE);
|
||||
holder.userStatusView.setVisibility(View.GONE);
|
||||
if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.new_friend), contactBean.getId())) {
|
||||
holder.avatar.setImageResource(TUIThemeManager.getAttrResId(holder.itemView.getContext(), R.attr.contact_new_friend_icon));
|
||||
|
||||
presenter.getFriendApplicationUnreadCount(new IUIKitCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer data) {
|
||||
if (data == 0) {
|
||||
holder.unreadText.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.unreadText.setVisibility(View.VISIBLE);
|
||||
holder.unreadText.setText("" + data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.group), contactBean.getId())) {
|
||||
holder.avatar.setImageResource(TUIThemeManager.getAttrResId(holder.itemView.getContext(), R.attr.contact_group_list_icon));
|
||||
} else if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.blacklist), contactBean.getId())) {
|
||||
holder.avatar.setImageResource(TUIThemeManager.getAttrResId(holder.itemView.getContext(), R.attr.contact_black_list_icon));
|
||||
} else {
|
||||
int radius = holder.itemView.getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
if (isGroupList) {
|
||||
int defaultIconResId = TUIUtil.getDefaultGroupIconResIDByGroupType(holder.itemView.getContext(), contactBean.getGroupType());
|
||||
GlideEngine.loadUserIcon(holder.avatar, contactBean.getAvatarUrl(), defaultIconResId, radius);
|
||||
} else {
|
||||
GlideEngine.loadUserIcon(holder.avatar, contactBean.getAvatarUrl(), radius);
|
||||
}
|
||||
if (dataSourceType == ContactListView.DataSource.CONTACT_LIST && TUIContactConfig.getInstance().isShowUserStatus()) {
|
||||
holder.userStatusView.setVisibility(View.VISIBLE);
|
||||
if (contactBean.getStatusType() == V2TIMUserStatus.V2TIM_USER_STATUS_ONLINE) {
|
||||
holder.userStatusView.setBackgroundResource(TUIThemeManager.getAttrResId(TUIContactService.getAppContext(), com.tencent.qcloud.tuicore.R.attr.user_status_online));
|
||||
} else {
|
||||
holder.userStatusView.setBackgroundResource(TUIThemeManager.getAttrResId(TUIContactService.getAppContext(), com.tencent.qcloud.tuicore.R.attr.user_status_offline));
|
||||
}
|
||||
} else {
|
||||
holder.userStatusView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
setAlreadySelected(holder, contactBean);
|
||||
}
|
||||
|
||||
private void setAlreadySelected(ContactAdapter.ViewHolder holder, ContactItemBean contactItemBean) {
|
||||
if (alreadySelectedList != null && alreadySelectedList.contains(contactItemBean.getId())) {
|
||||
holder.ccSelect.setChecked(true);
|
||||
holder.itemView.setEnabled(false);
|
||||
holder.ccSelect.setEnabled(false);
|
||||
} else {
|
||||
holder.itemView.setEnabled(true);
|
||||
holder.ccSelect.setEnabled(true);
|
||||
holder.ccSelect.setSelected(contactItemBean.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(ContactAdapter.ViewHolder holder) {
|
||||
if (holder != null) {
|
||||
GlideEngine.clear(holder.avatar);
|
||||
holder.avatar.setImageResource(0);
|
||||
|
||||
}
|
||||
super.onViewRecycled(holder);
|
||||
}
|
||||
|
||||
private ContactItemBean getItem(int position) {
|
||||
if (position < mData.size()) {
|
||||
return mData.get(position);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData != null ? mData.size() : 0;
|
||||
}
|
||||
|
||||
public void setDataSource(List<ContactItemBean> datas) {
|
||||
this.mData = datas;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setSingleSelectMode(boolean mode) {
|
||||
isSingleSelectMode = mode;
|
||||
}
|
||||
|
||||
public void setOnSelectChangedListener(ContactListView.OnSelectChangedListener selectListener) {
|
||||
mOnSelectChangedListener = selectListener;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(ContactListView.OnItemClickListener listener) {
|
||||
mOnClickListener = listener;
|
||||
}
|
||||
|
||||
public void setDataSourceType(int dataSourceType) {
|
||||
this.dataSourceType = dataSourceType;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvName;
|
||||
TextView unreadText;
|
||||
ImageView avatar;
|
||||
CheckBox ccSelect;
|
||||
View content;
|
||||
View line;
|
||||
View userStatusView;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvName = itemView.findViewById(R.id.tvCity);
|
||||
unreadText = itemView.findViewById(R.id.conversation_unread);
|
||||
unreadText.setVisibility(View.GONE);
|
||||
avatar = itemView.findViewById(R.id.ivAvatar);
|
||||
ccSelect = itemView.findViewById(R.id.contact_check_box);
|
||||
content = itemView.findViewById(R.id.selectable_contact_item);
|
||||
line = itemView.findViewById(R.id.view_line);
|
||||
userStatusView = itemView.findViewById(R.id.user_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.classicui.interfaces.IContactLayout;
|
||||
|
||||
|
||||
public class ContactLayout extends LinearLayout implements IContactLayout {
|
||||
|
||||
private static final String TAG = ContactLayout.class.getSimpleName();
|
||||
|
||||
private ContactListView mContactListView;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
|
||||
public ContactLayout(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactLayout(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setPresenter(ContactPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.contact_layout, this);
|
||||
mContactListView = findViewById(R.id.contact_listview);
|
||||
}
|
||||
|
||||
public void initDefault() {
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.CONTACT_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactListView getContactListView() {
|
||||
return mContactListView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TitleBarLayout getTitleBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentLayout(Object parent) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.CustomLinearLayoutManager;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.widget.IndexBar;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.suspension.SuspensionDecoration;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ContactListView extends LinearLayout implements IContactListView {
|
||||
|
||||
private static final String TAG = ContactListView.class.getSimpleName();
|
||||
|
||||
private RecyclerView mRv;
|
||||
private ContactAdapter mAdapter;
|
||||
private CustomLinearLayoutManager mManager;
|
||||
private List<ContactItemBean> mData = new ArrayList<>();
|
||||
private SuspensionDecoration mDecoration;
|
||||
private ProgressBar mContactLoadingBar;
|
||||
private String groupId;
|
||||
private boolean isGroupList = false;
|
||||
|
||||
private TextView notFoundTip;
|
||||
/**
|
||||
* 右侧边栏导航区域
|
||||
*/
|
||||
private IndexBar mIndexBar;
|
||||
|
||||
private TextView mTvSideBarHint;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
|
||||
private int dataSourceType = DataSource.UNKNOWN;
|
||||
private ArrayList<String> alreadySelectedList;
|
||||
|
||||
public ContactListView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactListView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactListView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setPresenter(ContactPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setPresenter(presenter);
|
||||
mAdapter.setIsGroupList(isGroupList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsGroupList(boolean isGroupList) {
|
||||
this.isGroupList = isGroupList;
|
||||
}
|
||||
|
||||
public void setAlreadySelectedList(ArrayList<String> alreadySelectedList) {
|
||||
this.alreadySelectedList = alreadySelectedList;
|
||||
mAdapter.setAlreadySelectedList(alreadySelectedList);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.contact_list, this);
|
||||
mRv = findViewById(R.id.contact_member_list);
|
||||
notFoundTip = findViewById(R.id.not_found_tip);
|
||||
mManager = new CustomLinearLayoutManager(getContext());
|
||||
mRv.setLayoutManager(mManager);
|
||||
|
||||
mAdapter = new ContactAdapter(mData);
|
||||
mRv.setAdapter(mAdapter);
|
||||
mRv.addItemDecoration(mDecoration = new SuspensionDecoration(getContext(), mData));
|
||||
mRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
int lastCompletelyVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
|
||||
if(lastCompletelyVisibleItemPosition==layoutManager.getItemCount()-1) {
|
||||
if (presenter.getNextSeq() > 0) {
|
||||
presenter.loadGroupMemberList(groupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
mTvSideBarHint = findViewById(R.id.contact_tvSideBarHint);
|
||||
mIndexBar = findViewById(R.id.contact_indexBar);
|
||||
mIndexBar.setPressedShowTextView(mTvSideBarHint)
|
||||
.setNeedRealIndex(false)
|
||||
.setLayoutManager(mManager);
|
||||
mContactLoadingBar = findViewById(R.id.contact_loading_bar);
|
||||
}
|
||||
|
||||
public ContactAdapter getAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
public void setNotFoundTip(String text) {
|
||||
notFoundTip.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSourceChanged(List<ContactItemBean> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
if (!TextUtils.isEmpty(notFoundTip.getText())) {
|
||||
notFoundTip.setVisibility(VISIBLE);
|
||||
}
|
||||
} else {
|
||||
notFoundTip.setVisibility(GONE);
|
||||
}
|
||||
mContactLoadingBar.setVisibility(GONE);
|
||||
this.mData = data;
|
||||
mAdapter.setDataSource(mData);
|
||||
mIndexBar.setSourceDatas(mData).invalidate();
|
||||
mDecoration.setDatas(mData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationChanged() {
|
||||
if (dataSourceType == DataSource.CONTACT_LIST) {
|
||||
mAdapter.notifyItemChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSingleSelectMode(boolean mode) {
|
||||
mAdapter.setSingleSelectMode(mode);
|
||||
}
|
||||
|
||||
public void setOnSelectChangeListener(OnSelectChangedListener selectChangeListener) {
|
||||
mAdapter.setOnSelectChangedListener(selectChangeListener);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
mAdapter.setOnItemClickListener(listener);
|
||||
}
|
||||
|
||||
public void loadDataSource(int dataSource) {
|
||||
this.dataSourceType = dataSource;
|
||||
if (presenter == null) {
|
||||
return;
|
||||
}
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setDataSourceType(dataSource);
|
||||
}
|
||||
mContactLoadingBar.setVisibility(VISIBLE);
|
||||
if (dataSource == ContactListView.DataSource.GROUP_MEMBER_LIST) {
|
||||
presenter.loadGroupMemberList(groupId);
|
||||
} else {
|
||||
presenter.loadDataSource(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public interface OnSelectChangedListener {
|
||||
void onSelectChanged(ContactItemBean contact, boolean selected);
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int position, ContactItemBean contact);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ForwardContactSelectorAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
private Context context;
|
||||
private List<String> list;
|
||||
private RecyclerView mRecycleView;
|
||||
|
||||
public ForwardContactSelectorAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
mRecycleView = (RecyclerView) recyclerView;
|
||||
//mRecycleView.setItemViewCacheSize(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ContactViewHolder(LayoutInflater.from(context).inflate(R.layout.forward_contact_selector_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ContactViewHolder viewHolder = (ContactViewHolder) holder;
|
||||
if (viewHolder != null){
|
||||
if (!TextUtils.isEmpty(list.get(position))) {
|
||||
GlideEngine.loadImage(viewHolder.userIconView, list.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setDataSource(List<String> provider) {
|
||||
if (provider == null) {
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
}
|
||||
} else {
|
||||
list = provider;
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
}
|
||||
|
||||
class ContactViewHolder extends RecyclerView.ViewHolder {
|
||||
public ImageView userIconView;
|
||||
public ContactViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
userIconView = (ImageView) itemView.findViewById(R.id.ivAvatar);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,660 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.widget;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.component.popupcard.PopupInputCard;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ChatInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactGroupApplyInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IFriendProfileLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.FriendProfilePresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FriendProfileLayout extends LinearLayout implements View.OnClickListener, IFriendProfileLayout {
|
||||
|
||||
private static final String TAG = FriendProfileLayout.class.getSimpleName();
|
||||
|
||||
private final int CHANGE_REMARK_CODE = 200;
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ImageView mHeadImageView;
|
||||
private TextView mNickNameView;
|
||||
private TextView mIDView;
|
||||
private TextView mSignatureView;
|
||||
private TextView mSignatureTagView;
|
||||
private TextView remarkAndGroupTip;
|
||||
private LineControllerView mRemarkView;
|
||||
private LineControllerView mAddBlackView;
|
||||
private LineControllerView mChatTopView;
|
||||
private LineControllerView mMessageOptionView;
|
||||
private LineControllerView addFriendRemarkLv;
|
||||
private LineControllerView addFriendGroupLv;
|
||||
private LineControllerView mChatBackground;
|
||||
private Button deleteFriendBtn;
|
||||
private Button clearMessageBtn;
|
||||
private Button chatBtn;
|
||||
private Button audioCallBtn;
|
||||
private Button videoCallBtn;
|
||||
private Button addFriendSendBtn;
|
||||
private Button acceptFriendBtn;
|
||||
private Button refuseFriendBtn;
|
||||
private View addFriendArea;
|
||||
private EditText addWordingEditText;
|
||||
private View friendApplicationVerifyArea;
|
||||
private TextView friendApplicationAddWording;
|
||||
|
||||
private ContactItemBean mContactInfo;
|
||||
private FriendApplicationBean friendApplicationBean;
|
||||
private OnButtonClickListener mListener;
|
||||
private String mId;
|
||||
private String mNickname;
|
||||
private String mRemark;
|
||||
private String mAddWords;
|
||||
private boolean isFriend;
|
||||
private boolean isGroup = false;
|
||||
|
||||
private FriendProfilePresenter presenter;
|
||||
|
||||
public FriendProfileLayout(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public FriendProfileLayout(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public FriendProfileLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setPresenter(FriendProfilePresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.contact_friend_profile_layout, this);
|
||||
|
||||
mHeadImageView = findViewById(R.id.friend_icon);
|
||||
mNickNameView = findViewById(R.id.friend_nick_name);
|
||||
mIDView = findViewById(R.id.friend_account);
|
||||
mRemarkView = findViewById(R.id.remark);
|
||||
mRemarkView.setOnClickListener(this);
|
||||
mSignatureTagView = findViewById(R.id.friend_signature_tag);
|
||||
mSignatureView = findViewById(R.id.friend_signature);
|
||||
mMessageOptionView = findViewById(R.id.msg_rev_opt);
|
||||
mMessageOptionView.setOnClickListener(this);
|
||||
mChatTopView = findViewById(R.id.chat_to_top);
|
||||
mAddBlackView = findViewById(R.id.blackList);
|
||||
deleteFriendBtn = findViewById(R.id.btn_delete);
|
||||
deleteFriendBtn.setOnClickListener(this);
|
||||
clearMessageBtn = findViewById(R.id.btn_clear_chat_history);
|
||||
clearMessageBtn.setOnClickListener(this);
|
||||
chatBtn = findViewById(R.id.btn_chat);
|
||||
chatBtn.setOnClickListener(this);
|
||||
mChatBackground = findViewById(R.id.chat_background);
|
||||
mChatBackground.setOnClickListener(this);
|
||||
|
||||
audioCallBtn = findViewById(R.id.btn_voice);
|
||||
audioCallBtn.setOnClickListener(this);
|
||||
videoCallBtn = findViewById(R.id.btn_video);
|
||||
videoCallBtn.setOnClickListener(this);
|
||||
|
||||
addFriendSendBtn = findViewById(R.id.add_friend_send_btn);
|
||||
addFriendSendBtn.setOnClickListener(this);
|
||||
|
||||
acceptFriendBtn = findViewById(R.id.accept_friend_send_btn);
|
||||
refuseFriendBtn = findViewById(R.id.refuse_friend_send_btn);
|
||||
|
||||
addFriendArea = findViewById(R.id.add_friend_verify_area);
|
||||
addWordingEditText = findViewById(R.id.add_wording_edit);
|
||||
|
||||
friendApplicationVerifyArea = findViewById(R.id.friend_application_verify_area);
|
||||
friendApplicationAddWording = findViewById(R.id.friend_application_add_wording);
|
||||
|
||||
addFriendRemarkLv = findViewById(R.id.friend_remark_lv);
|
||||
addFriendRemarkLv.setOnClickListener(this);
|
||||
addFriendGroupLv = findViewById(R.id.friend_group_lv);
|
||||
addFriendGroupLv.setContent(getContext().getString(R.string.contact_my_friend));
|
||||
|
||||
remarkAndGroupTip = findViewById(R.id.remark_and_group_tip);
|
||||
|
||||
mTitleBar = findViewById(R.id.friend_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.profile_detail), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupCall() {
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIChat.CHAT_ID, mId);
|
||||
param.put(TUIConstants.TUIChat.CHAT_NAME, mNickname);
|
||||
param.put(TUIConstants.TUIChat.CHAT_TYPE, ChatInfo.TYPE_C2C);
|
||||
param.put(TUIConstants.TUIChat.CONTEXT, getContext());
|
||||
Map<String, Object> videoCallExtension = TUICore.getExtensionInfo(TUIConstants.TUIChat.EXTENSION_INPUT_MORE_VIDEO_CALL, param);
|
||||
if (videoCallExtension == null) {
|
||||
videoCallBtn.setVisibility(GONE);
|
||||
}
|
||||
|
||||
Map<String, Object> audioCallExtension = TUICore.getExtensionInfo(TUIConstants.TUIChat.EXTENSION_INPUT_MORE_AUDIO_CALL, param);
|
||||
if (audioCallExtension == null) {
|
||||
audioCallBtn.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
mChatTopView.setCheckListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
|
||||
if (presenter != null) {
|
||||
presenter.setConversationTop(mId, isChecked);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mAddBlackView.setCheckListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
addBlack();
|
||||
} else {
|
||||
deleteBlack();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
refuseFriendBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
refuse();
|
||||
}
|
||||
});
|
||||
|
||||
acceptFriendBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
accept();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initData(Object data) {
|
||||
initEvent();
|
||||
|
||||
if (data instanceof String) {
|
||||
mId = (String) data;
|
||||
loadUserProfile(mId);
|
||||
} else if (data instanceof ContactItemBean) {
|
||||
setViewContentFromItemBean((ContactItemBean) data);
|
||||
} else if (data instanceof FriendApplicationBean) {
|
||||
setViewContentFromFriendApplicationBean((FriendApplicationBean) data);
|
||||
} else if (data instanceof ContactGroupApplyInfo) {
|
||||
setViewContentFromContactGroupApplyInfo((ContactGroupApplyInfo) data);
|
||||
} else if (data instanceof GroupInfo) {
|
||||
setViewContentFromGroupInfo((GroupInfo) data);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mNickname)) {
|
||||
mNickNameView.setText(mNickname);
|
||||
} else {
|
||||
mNickNameView.setText(mId);
|
||||
}
|
||||
mIDView.setText(mId);
|
||||
|
||||
setupCall();
|
||||
}
|
||||
|
||||
private void setViewContentFromContactGroupApplyInfo(ContactGroupApplyInfo data) {
|
||||
final ContactGroupApplyInfo info = data;
|
||||
mId = info.getFromUser();
|
||||
mNickname = info.getFromUserNickName();
|
||||
mRemarkView.setVisibility(GONE);
|
||||
mAddBlackView.setVisibility(GONE);
|
||||
mMessageOptionView.setVisibility(GONE);
|
||||
mChatBackground.setVisibility(GONE);
|
||||
deleteFriendBtn.setText(R.string.refuse);
|
||||
deleteFriendBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
refuseJoinGroupApply(info);
|
||||
}
|
||||
});
|
||||
chatBtn.setText(R.string.accept);
|
||||
chatBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
acceptJoinGroupApply(info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setViewContentFromGroupInfo(GroupInfo groupInfo) {
|
||||
mTitleBar.setTitle(getResources().getString(R.string.add_group), ITitleBarLayout.Position.MIDDLE);
|
||||
isGroup = true;
|
||||
mId = groupInfo.getId();
|
||||
mNickname = groupInfo.getGroupName();
|
||||
mSignatureTagView.setText(getResources().getString(R.string.contact_group_type_tag));
|
||||
mSignatureView.setText(groupInfo.getGroupType());
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, groupInfo.getFaceUrl(), TUIUtil.getDefaultGroupIconResIDByGroupType(getContext(), groupInfo.getGroupType()), radius);
|
||||
addFriendSendBtn.setVisibility(VISIBLE);
|
||||
addFriendArea.setVisibility(VISIBLE);
|
||||
remarkAndGroupTip.setVisibility(GONE);
|
||||
addFriendRemarkLv.setVisibility(GONE);
|
||||
addFriendGroupLv.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void setViewContentFromFriendApplicationBean(FriendApplicationBean data) {
|
||||
friendApplicationBean = data;
|
||||
mId = friendApplicationBean.getUserId();
|
||||
mNickname = friendApplicationBean.getNickName();
|
||||
mSignatureTagView.setVisibility(GONE);
|
||||
mSignatureView.setVisibility(GONE);
|
||||
mRemarkView.setVisibility(GONE);
|
||||
mAddBlackView.setVisibility(GONE);
|
||||
mMessageOptionView.setVisibility(GONE);
|
||||
mChatBackground.setVisibility(GONE);
|
||||
|
||||
friendApplicationVerifyArea.setVisibility(VISIBLE);
|
||||
friendApplicationAddWording.setText(friendApplicationBean.getAddWording());
|
||||
|
||||
refuseFriendBtn.setVisibility(VISIBLE);
|
||||
acceptFriendBtn.setVisibility(VISIBLE);
|
||||
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, friendApplicationBean.getFaceUrl(), radius);
|
||||
}
|
||||
|
||||
private void setViewContentFromItemBean(ContactItemBean data) {
|
||||
mContactInfo = data;
|
||||
isFriend = mContactInfo.isFriend();
|
||||
mId = mContactInfo.getId();
|
||||
mNickname = mContactInfo.getNickName();
|
||||
mSignatureView.setText(mContactInfo.getSignature());
|
||||
if (TextUtils.isEmpty(mContactInfo.getSignature())) {
|
||||
mSignatureTagView.setText(getResources().getString(R.string.contact_no_status));
|
||||
} else {
|
||||
mSignatureTagView.setText(getResources().getString(R.string.contact_signature_tag));
|
||||
}
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, mContactInfo.getAvatarUrl(), radius);
|
||||
mChatTopView.setChecked(presenter.isTopConversation(mId));
|
||||
mAddBlackView.setChecked(mContactInfo.isBlackList());
|
||||
mRemarkView.setContent(mContactInfo.getRemark());
|
||||
|
||||
if (TextUtils.equals(mContactInfo.getId(), TUILogin.getLoginUser())) {
|
||||
if (isFriend) {
|
||||
mRemarkView.setVisibility(VISIBLE);
|
||||
chatBtn.setVisibility(VISIBLE);
|
||||
audioCallBtn.setVisibility(VISIBLE);
|
||||
videoCallBtn.setVisibility(VISIBLE);
|
||||
deleteFriendBtn.setVisibility(VISIBLE);
|
||||
mAddBlackView.setVisibility(VISIBLE);
|
||||
mChatTopView.setVisibility(View.VISIBLE);
|
||||
mChatBackground.setVisibility(VISIBLE);
|
||||
updateMessageOptionView();
|
||||
} else {
|
||||
// DO NOTHING
|
||||
}
|
||||
} else {
|
||||
if (mContactInfo.isBlackList()) {
|
||||
deleteFriendBtn.setVisibility(VISIBLE);
|
||||
chatBtn.setVisibility(VISIBLE);
|
||||
audioCallBtn.setVisibility(VISIBLE);
|
||||
videoCallBtn.setVisibility(VISIBLE);
|
||||
mRemarkView.setVisibility(VISIBLE);
|
||||
mAddBlackView.setVisibility(VISIBLE);
|
||||
mMessageOptionView.setVisibility(VISIBLE);
|
||||
mChatTopView.setVisibility(VISIBLE);
|
||||
mChatBackground.setVisibility(VISIBLE);
|
||||
} else {
|
||||
if (!isFriend) {
|
||||
if (isGroup) {
|
||||
addFriendRemarkLv.setVisibility(GONE);
|
||||
addFriendGroupLv.setVisibility(GONE);
|
||||
}
|
||||
mTitleBar.setTitle(getResources().getString(R.string.add_friend), ITitleBarLayout.Position.MIDDLE);
|
||||
addFriendSendBtn.setVisibility(VISIBLE);
|
||||
addFriendArea.setVisibility(VISIBLE);
|
||||
} else {
|
||||
mRemarkView.setVisibility(VISIBLE);
|
||||
chatBtn.setVisibility(VISIBLE);
|
||||
audioCallBtn.setVisibility(VISIBLE);
|
||||
videoCallBtn.setVisibility(VISIBLE);
|
||||
deleteFriendBtn.setVisibility(VISIBLE);
|
||||
mAddBlackView.setVisibility(VISIBLE);
|
||||
mChatTopView.setVisibility(View.VISIBLE);
|
||||
mChatBackground.setVisibility(VISIBLE);
|
||||
updateMessageOptionView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateMessageOptionView() {
|
||||
mMessageOptionView.setVisibility(VISIBLE);
|
||||
//get
|
||||
final ArrayList<String> userIdList = new ArrayList<>();
|
||||
userIdList.add(mId);
|
||||
|
||||
presenter.getC2CReceiveMessageOpt(userIdList, new IUIKitCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
mMessageOptionView.setChecked(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mMessageOptionView.setChecked(false);
|
||||
}
|
||||
});
|
||||
|
||||
//set
|
||||
mMessageOptionView.setCheckListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
presenter.setC2CReceiveMessageOpt(userIdList, isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSourceChanged(ContactItemBean bean) {
|
||||
setViewContentFromItemBean(bean);
|
||||
setupCall();
|
||||
if (bean.isFriend()) {
|
||||
updateMessageOptionView();
|
||||
clearMessageBtn.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mNickname)) {
|
||||
mNickNameView.setText(mNickname);
|
||||
} else {
|
||||
mNickNameView.setText(mId);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(bean.getAvatarUrl())) {
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, bean.getAvatarUrl(), radius);
|
||||
}
|
||||
mIDView.setText(mId);
|
||||
}
|
||||
|
||||
private void loadUserProfile(String id) {
|
||||
final ContactItemBean bean = new ContactItemBean();
|
||||
presenter.getUsersInfo(id, bean);
|
||||
}
|
||||
|
||||
private void accept() {
|
||||
presenter.acceptFriendApplication(friendApplicationBean, FriendApplicationBean.FRIEND_ACCEPT_AGREE_AND_ADD, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
chatBtn.setText(R.string.accepted);
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("accept Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refuse() {
|
||||
presenter.refuseFriendApplication(friendApplicationBean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
deleteFriendBtn.setText(R.string.refused);
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("refuse Error code = " + errCode + ", desc = " + errMsg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void acceptJoinGroupApply(final ContactGroupApplyInfo item) {
|
||||
presenter.acceptJoinGroupApply(item, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastLongMessage(errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refuseJoinGroupApply(final ContactGroupApplyInfo item) {
|
||||
presenter.refuseJoinGroupApply(item, "", new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastLongMessage(errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void delete() {
|
||||
List<String> identifiers = new ArrayList<>();
|
||||
identifiers.add(mId);
|
||||
|
||||
presenter.deleteFriend(identifiers, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
if (mListener != null) {
|
||||
mListener.onDeleteFriendClick(mId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("deleteFriend Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void chat() {
|
||||
if (mListener != null || mContactInfo != null) {
|
||||
mListener.onStartConversationClick(mContactInfo);
|
||||
}
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == chatBtn) {
|
||||
chat();
|
||||
} else if (v == deleteFriendBtn) {
|
||||
delete();
|
||||
}else if (v == clearMessageBtn) {
|
||||
new TUIKitDialog(getContext())
|
||||
.builder()
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(getContext().getString(R.string.clear_msg_tip))
|
||||
.setDialogWidth(0.75f)
|
||||
.setPositiveButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.sure), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Map<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put(TUIConstants.TUIContact.FRIEND_ID, mId);
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_USER,
|
||||
TUIConstants.TUIContact.EVENT_SUB_KEY_CLEAR_MESSAGE, hashMap);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.cancel), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
})
|
||||
.show();
|
||||
} else if (v == videoCallBtn) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_USERIDS, new String[]{mId});
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_TYPE, TUIConstants.TUICalling.TYPE_VIDEO);
|
||||
TUICore.callService(TUIConstants.TUICalling.SERVICE_NAME, TUIConstants.TUICalling.METHOD_NAME_CALL, map);
|
||||
} else if (v == audioCallBtn) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_USERIDS, new String[]{mId});
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_TYPE, TUIConstants.TUICalling.TYPE_AUDIO);
|
||||
TUICore.callService(TUIConstants.TUICalling.SERVICE_NAME, TUIConstants.TUICalling.METHOD_NAME_CALL, map);
|
||||
} else if (v == addFriendSendBtn) {
|
||||
String addWording = addWordingEditText.getText().toString();
|
||||
String friendGroup = "";
|
||||
String remark = addFriendRemarkLv.getContent();
|
||||
|
||||
if (isGroup) {
|
||||
presenter.joinGroup(mId, addWording, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ToastUtil.toastShortMessage(getContext().getString(R.string.success));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(getContext().getString(R.string.contact_add_failed) + " " + errMsg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
presenter.addFriend(mId, addWording, friendGroup, remark, new IUIKitCallback<Pair<Integer, String>>() {
|
||||
@Override
|
||||
public void onSuccess(Pair<Integer, String> data) {
|
||||
ToastUtil.toastShortMessage(data.second);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(getContext().getString(R.string.contact_add_failed));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (v == addFriendRemarkLv) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard((Activity) getContext());
|
||||
popupInputCard.setContent(addFriendRemarkLv.getContent());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.contact_friend_remark));
|
||||
popupInputCard.setOnPositive((result -> {
|
||||
addFriendRemarkLv.setContent(result);
|
||||
if (TextUtils.isEmpty(result)) {
|
||||
result = "";
|
||||
}
|
||||
modifyRemark(result);
|
||||
}));
|
||||
popupInputCard.show(addFriendRemarkLv, Gravity.BOTTOM);
|
||||
} else if (v == mRemarkView) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard((Activity) getContext());
|
||||
popupInputCard.setContent(mRemarkView.getContent());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.profile_remark_edit));
|
||||
String description = getResources().getString(R.string.contact_modify_remark_rule);
|
||||
popupInputCard.setRule("^[a-zA-Z0-9_\u4e00-\u9fa5]*$");
|
||||
popupInputCard.setDescription(description);
|
||||
popupInputCard.setOnPositive((result -> {
|
||||
mRemarkView.setContent(result);
|
||||
if (TextUtils.isEmpty(result)) {
|
||||
result = "";
|
||||
}
|
||||
modifyRemark(result);
|
||||
}));
|
||||
popupInputCard.show(mRemarkView, Gravity.BOTTOM);
|
||||
|
||||
} else if (v == mChatBackground) {
|
||||
if (mListener != null) {
|
||||
mListener.onSetChatBackground();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void modifyRemark(final String txt) {
|
||||
presenter.modifyRemark(mId, txt, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
mContactInfo.setRemark(txt);
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIContact.FRIEND_ID, mId);
|
||||
param.put(TUIConstants.TUIContact.FRIEND_REMARK, txt);
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_FRIEND_INFO_CHANGED, TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_REMARK_CHANGED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBlack() {
|
||||
String[] idStringList = mId.split(",");
|
||||
List<String> idList = new ArrayList<>(Arrays.asList(idStringList));
|
||||
presenter.addToBlackList(idList);
|
||||
}
|
||||
|
||||
private void deleteBlack() {
|
||||
String[] idStringList = mId.split(",");
|
||||
List<String> idList = new ArrayList<>(Arrays.asList(idStringList));
|
||||
presenter.deleteFromBlackList(idList);
|
||||
}
|
||||
|
||||
public void setOnButtonClickListener(OnButtonClickListener l) {
|
||||
mListener = l;
|
||||
}
|
||||
|
||||
public interface OnButtonClickListener {
|
||||
void onStartConversationClick(ContactItemBean info);
|
||||
|
||||
void onDeleteFriendClick(String id);
|
||||
|
||||
default void onSetChatBackground() {};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.classicui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.NewFriendPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NewFriendListAdapter extends ArrayAdapter<FriendApplicationBean> {
|
||||
|
||||
private static final String TAG = NewFriendListAdapter.class.getSimpleName();
|
||||
|
||||
private int mResourceId;
|
||||
private View mView;
|
||||
private ViewHolder mViewHolder;
|
||||
|
||||
private NewFriendPresenter presenter;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param context The current context.
|
||||
* @param resource The resource ID for a layout ic_chat_input_file containing a TextView to use when
|
||||
* instantiating views.
|
||||
* @param objects The objects to represent in the ListView.
|
||||
*/
|
||||
public NewFriendListAdapter(Context context, int resource, List<FriendApplicationBean> objects) {
|
||||
super(context, resource, objects);
|
||||
mResourceId = resource;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final FriendApplicationBean data = getItem(position);
|
||||
if (convertView != null) {
|
||||
mView = convertView;
|
||||
mViewHolder = (ViewHolder) mView.getTag();
|
||||
} else {
|
||||
mView = LayoutInflater.from(getContext()).inflate(mResourceId, null);
|
||||
mView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(TUIContactConstants.ProfileType.CONTENT, data);
|
||||
TUICore.startActivity("FriendProfileActivity", bundle);
|
||||
}
|
||||
});
|
||||
mViewHolder = new ViewHolder();
|
||||
mViewHolder.avatar = mView.findViewById(R.id.avatar);
|
||||
mViewHolder.name = mView.findViewById(R.id.name);
|
||||
mViewHolder.des = mView.findViewById(R.id.description);
|
||||
mViewHolder.agree = mView.findViewById(R.id.agree);
|
||||
mViewHolder.reject = mView.findViewById(R.id.reject);
|
||||
mViewHolder.result = mView.findViewById(R.id.result_tv);
|
||||
mView.setTag(mViewHolder);
|
||||
}
|
||||
Resources res = getContext().getResources();
|
||||
int radius = mView.getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mViewHolder.avatar, data.getFaceUrl(), radius);
|
||||
mViewHolder.name.setText(TextUtils.isEmpty(data.getNickName()) ? data.getUserId() : data.getNickName());
|
||||
mViewHolder.des.setText(data.getAddWording());
|
||||
switch (data.getAddType()) {
|
||||
case FriendApplicationBean.FRIEND_APPLICATION_COME_IN:
|
||||
mViewHolder.agree.setText(res.getString(R.string.request_agree));
|
||||
mViewHolder.agree.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
doResponse(data, true);
|
||||
}
|
||||
});
|
||||
mViewHolder.reject.setText(res.getString(R.string.refuse));
|
||||
mViewHolder.reject.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
doResponse(data, false);
|
||||
}
|
||||
});
|
||||
if (data.isAccept()) {
|
||||
mViewHolder.agree.setVisibility(View.GONE);
|
||||
mViewHolder.reject.setVisibility(View.GONE);
|
||||
mViewHolder.result.setVisibility(View.VISIBLE);
|
||||
}
|
||||
break;
|
||||
case FriendApplicationBean.FRIEND_APPLICATION_BOTH:
|
||||
mViewHolder.agree.setText(res.getString(R.string.request_accepted));
|
||||
break;
|
||||
}
|
||||
return mView;
|
||||
}
|
||||
|
||||
private void doResponse(FriendApplicationBean bean, boolean isAccept) {
|
||||
if (presenter != null) {
|
||||
if (isAccept) {
|
||||
presenter.acceptFriendApplication(bean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
bean.setAccept(true);
|
||||
refreshList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
presenter.refuseFriendApplication(bean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshList() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setPresenter(NewFriendPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
public class ViewHolder {
|
||||
ImageView avatar;
|
||||
TextView name;
|
||||
TextView des;
|
||||
TextView agree;
|
||||
TextView reject;
|
||||
TextView result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.suspension.ISuspensionInterface;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public abstract class BaseIndexBean implements ISuspensionInterface, Serializable {
|
||||
|
||||
private String baseIndexTag;//所属的分类(名字的汉语拼音首字母) // The category to which it belongs (the first letter of the Chinese pinyin of the name)
|
||||
|
||||
public String getBaseIndexTag() {
|
||||
return baseIndexTag;
|
||||
}
|
||||
|
||||
public BaseIndexBean setBaseIndexTag(String baseIndexTag) {
|
||||
this.baseIndexTag = baseIndexTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuspensionTag() {
|
||||
if (TextUtils.isEmpty(baseIndexTag)) {
|
||||
return "";
|
||||
}
|
||||
return baseIndexTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowSuspension() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.bean;
|
||||
|
||||
|
||||
public abstract class BaseIndexPinyinBean extends BaseIndexBean {
|
||||
|
||||
private String baseIndexPinyin;
|
||||
|
||||
public String getBaseIndexPinyin() {
|
||||
return baseIndexPinyin;
|
||||
}
|
||||
|
||||
public BaseIndexPinyinBean setBaseIndexPinyin(String baseIndexPinyin) {
|
||||
this.baseIndexPinyin = baseIndexPinyin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNeedToPinyin() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract String getTarget();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.helper;
|
||||
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.bean.BaseIndexPinyinBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 介绍:IndexBar 的 数据相关帮助类
|
||||
* 1 将汉语转成拼音
|
||||
* 2 填充indexTag
|
||||
* 3 排序源数据源
|
||||
* 4 根据排序后的源数据源->indexBar的数据源
|
||||
*
|
||||
*
|
||||
* Introduction: Data-related helper classes for IndexBar
|
||||
* 1 Convert Chinese to Pinyin
|
||||
* 2 filling indexTag
|
||||
* 3 Sort source data
|
||||
* 4 According to the sorted source data -> source data of indexBar
|
||||
*/
|
||||
|
||||
public interface IIndexBarDataHelper {
|
||||
// 汉语-》拼音
|
||||
// Chinese to Pinyin
|
||||
IIndexBarDataHelper convert(List<? extends BaseIndexPinyinBean> data);
|
||||
|
||||
// 拼音->tag
|
||||
// Pinyin to tag
|
||||
IIndexBarDataHelper fillInexTag(List<? extends BaseIndexPinyinBean> data);
|
||||
|
||||
// 对源数据进行排序(RecyclerView)
|
||||
// Sort source data
|
||||
IIndexBarDataHelper sortSourceDatas(List<? extends BaseIndexPinyinBean> datas);
|
||||
|
||||
// 对IndexBar的数据源进行排序(右侧栏),在 sortSourceDatas 方法后调用
|
||||
// sort source data of indexBar, call after the method of sortSourceDatas
|
||||
IIndexBarDataHelper getSortedIndexDatas(List<? extends BaseIndexPinyinBean> sourceDatas, List<String> datas);
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.helper;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.promeg.pinyinhelper.Pinyin;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.bean.BaseIndexPinyinBean;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class IndexBarDataHelperImpl implements IIndexBarDataHelper {
|
||||
@Override
|
||||
public IIndexBarDataHelper convert(List<? extends BaseIndexPinyinBean> datas) {
|
||||
if (null == datas || datas.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
int size = datas.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
BaseIndexPinyinBean indexPinyinBean = datas.get(i);
|
||||
StringBuilder pySb = new StringBuilder();
|
||||
if (indexPinyinBean.isNeedToPinyin()) {
|
||||
String target = indexPinyinBean.getTarget();
|
||||
// 遍历target的每个char得到它的全拼音
|
||||
// Traverse each char of target to get its full pinyin
|
||||
if (target == null) {
|
||||
continue;
|
||||
}
|
||||
for (int i1 = 0; i1 < target.length(); i1++) {
|
||||
//利用TinyPinyin将char转成拼音
|
||||
//查看源码,方法内 如果char为汉字,则返回大写拼音
|
||||
//如果c不是汉字,则返回String.valueOf(c)
|
||||
// Convert char to Pinyin using TinyPinyin
|
||||
// If char is Chinese characters, return uppercase pinyin. If c is not a Chinese character, return String.valueOf(c)
|
||||
pySb.append(Pinyin.toPinyin(target.charAt(i1)).toUpperCase());
|
||||
}
|
||||
indexPinyinBean.setBaseIndexPinyin(pySb.toString());
|
||||
} else {
|
||||
//pySb.append(indexPinyinBean.getBaseIndexPinyin());
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexBarDataHelper fillInexTag(List<? extends BaseIndexPinyinBean> datas) {
|
||||
if (null == datas || datas.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
int size = datas.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
BaseIndexPinyinBean indexPinyinBean = datas.get(i);
|
||||
if (indexPinyinBean.isNeedToPinyin()) {
|
||||
if (TextUtils.isEmpty(indexPinyinBean.getBaseIndexPinyin())) {
|
||||
indexPinyinBean.setBaseIndexTag("#");
|
||||
continue;
|
||||
}
|
||||
String tagString = indexPinyinBean.getBaseIndexPinyin().substring(0, 1);
|
||||
if (tagString.matches("[A-Z]")) {
|
||||
indexPinyinBean.setBaseIndexTag(tagString);
|
||||
} else {
|
||||
indexPinyinBean.setBaseIndexTag("#");
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexBarDataHelper sortSourceDatas(List<? extends BaseIndexPinyinBean> datas) {
|
||||
if (null == datas || datas.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
convert(datas);
|
||||
fillInexTag(datas);
|
||||
|
||||
Collections.sort(datas, new Comparator<BaseIndexPinyinBean>() {
|
||||
@Override
|
||||
public int compare(BaseIndexPinyinBean lhs, BaseIndexPinyinBean rhs) {
|
||||
if (lhs.getBaseIndexPinyin() == null && rhs.getBaseIndexPinyin() == null) {
|
||||
return 0;
|
||||
} else if (lhs.getBaseIndexPinyin() == null && rhs.getBaseIndexPinyin() != null) {
|
||||
return -1;
|
||||
} else if (lhs.getBaseIndexPinyin() != null && rhs.getBaseIndexPinyin() == null) {
|
||||
return 1;
|
||||
}
|
||||
if (!lhs.isNeedToPinyin()) {
|
||||
return 0;
|
||||
} else if (!rhs.isNeedToPinyin()) {
|
||||
return 0;
|
||||
} else if (lhs.getBaseIndexTag().equals("#") && !rhs.getBaseIndexTag().equals("#")) {
|
||||
return 1;
|
||||
} else if (!lhs.getBaseIndexTag().equals("#") && rhs.getBaseIndexTag().equals("#")) {
|
||||
return -1;
|
||||
} else {
|
||||
return lhs.getBaseIndexPinyin().compareTo(rhs.getBaseIndexPinyin());
|
||||
}
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexBarDataHelper getSortedIndexDatas(List<? extends BaseIndexPinyinBean> sourceDatas, List<String> indexDatas) {
|
||||
if (null == sourceDatas || sourceDatas.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
int size = sourceDatas.size();
|
||||
String baseIndexTag;
|
||||
for (int i = 0; i < size; i++) {
|
||||
baseIndexTag = sourceDatas.get(i).getBaseIndexTag();
|
||||
if (!indexDatas.contains(baseIndexTag)) {
|
||||
indexDatas.add(baseIndexTag);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.R;
|
||||
import com.tencent.qcloud.tuicore.component.CustomLinearLayoutManager;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.bean.BaseIndexPinyinBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.helper.IIndexBarDataHelper;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.helper.IndexBarDataHelperImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class IndexBar extends View {
|
||||
private static final String TAG = IndexBar.class.getSimpleName();
|
||||
|
||||
public static String[] INDEX_STRING = {"A", "B", "C", "D", "E", "F", "G", "H", "I",
|
||||
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
|
||||
"W", "X", "Y", "Z", "#"};
|
||||
// 是否需要根据实际的数据来生成索引数据源(例如 只有 A B C 三种tag,那么索引栏就 A B C 三项)
|
||||
// Whether the index data source needs to be generated based on the actual data
|
||||
private boolean isNeedRealIndex;
|
||||
|
||||
private List<String> mIndexDatas;
|
||||
|
||||
private int mWidth, mHeight;
|
||||
|
||||
private int mGapHeight;
|
||||
|
||||
private Paint mPaint;
|
||||
|
||||
// 手指按下时的背景色
|
||||
// background color when finger is pressed
|
||||
private int mPressedBackground;
|
||||
|
||||
private IIndexBarDataHelper mDataHelper;
|
||||
|
||||
//以下边变量是外部set进来的 // The following side variables are imported from external set
|
||||
private TextView mPressedShowTextView;// 用于特写显示正在被触摸的index值 // Used to close-up display the index value that is being touched
|
||||
private boolean isSourceDatasAlreadySorted;
|
||||
private List<? extends BaseIndexPinyinBean> mSourceDatas;
|
||||
private CustomLinearLayoutManager mLayoutManager;
|
||||
private int mHeaderViewCount = 0;
|
||||
private onIndexPressedListener mOnIndexPressedListener;
|
||||
|
||||
public IndexBar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public IndexBar(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public IndexBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public int getHeaderViewCount() {
|
||||
return mHeaderViewCount;
|
||||
}
|
||||
|
||||
public IndexBar setHeaderViewCount(int headerViewCount) {
|
||||
mHeaderViewCount = headerViewCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSourceDatasAlreadySorted() {
|
||||
return isSourceDatasAlreadySorted;
|
||||
}
|
||||
|
||||
public IndexBar setSourceDatasAlreadySorted(boolean sourceDatasAlreadySorted) {
|
||||
isSourceDatasAlreadySorted = sourceDatasAlreadySorted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IIndexBarDataHelper getDataHelper() {
|
||||
return mDataHelper;
|
||||
}
|
||||
|
||||
public IndexBar setDataHelper(IIndexBarDataHelper dataHelper) {
|
||||
mDataHelper = dataHelper;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
int textSize = (int) TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics());
|
||||
mPressedBackground = Color.BLACK;
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.IndexBar, defStyleAttr, 0);
|
||||
int n = typedArray.getIndexCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
int attr = typedArray.getIndex(i);
|
||||
if (attr == R.styleable.IndexBar_indexBarTextSize) {
|
||||
textSize = typedArray.getDimensionPixelSize(attr, textSize);
|
||||
} else if (attr == R.styleable.IndexBar_indexBarPressBackground) {
|
||||
mPressedBackground = typedArray.getColor(attr, mPressedBackground);
|
||||
}
|
||||
}
|
||||
typedArray.recycle();
|
||||
|
||||
initIndexDatas();
|
||||
|
||||
|
||||
mPaint = new Paint();
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setTextSize(textSize);
|
||||
mPaint.setColor(0xff888888);
|
||||
|
||||
setOnIndexPressedListener(new onIndexPressedListener() {
|
||||
@Override
|
||||
public void onIndexPressed(int index, String text) {
|
||||
if (mPressedShowTextView != null) {
|
||||
mPressedShowTextView.setVisibility(View.VISIBLE);
|
||||
mPressedShowTextView.setText(text);
|
||||
}
|
||||
|
||||
if (mLayoutManager != null) {
|
||||
int position = getPosByTag(text);
|
||||
if (position != -1) {
|
||||
mLayoutManager.scrollToPositionWithOffset(position, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMotionEventEnd() {
|
||||
if (mPressedShowTextView != null) {
|
||||
mPressedShowTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mDataHelper = new IndexBarDataHelperImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int wMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
int wSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int hMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
int hSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
int measureWidth = 0, measureHeight = 0;
|
||||
|
||||
Rect indexBounds = new Rect();// 存放每个绘制的index的Rect区域 // The Rect area that stores each drawn index
|
||||
String index;// 每个要绘制的index内容 // Each index content to be drawn
|
||||
for (int i = 0; i < mIndexDatas.size(); i++) {
|
||||
index = mIndexDatas.get(i);
|
||||
mPaint.getTextBounds(index, 0, index.length(), indexBounds);
|
||||
measureWidth = Math.max(indexBounds.width(), measureWidth);
|
||||
measureHeight = Math.max(indexBounds.height(), measureHeight);
|
||||
}
|
||||
measureHeight *= mIndexDatas.size();
|
||||
switch (wMode) {
|
||||
case MeasureSpec.EXACTLY:
|
||||
measureWidth = wSize;
|
||||
break;
|
||||
case MeasureSpec.AT_MOST:
|
||||
measureWidth = Math.min(measureWidth, wSize);
|
||||
break;
|
||||
case MeasureSpec.UNSPECIFIED:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (hMode) {
|
||||
case MeasureSpec.EXACTLY:
|
||||
measureHeight = hSize;
|
||||
break;
|
||||
case MeasureSpec.AT_MOST:
|
||||
measureHeight = Math.min(measureHeight, hSize);
|
||||
break;
|
||||
case MeasureSpec.UNSPECIFIED:
|
||||
break;
|
||||
}
|
||||
|
||||
setMeasuredDimension(measureWidth, measureHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
int t = getPaddingTop();
|
||||
String index;
|
||||
for (int i = 0; i < mIndexDatas.size(); i++) {
|
||||
index = mIndexDatas.get(i);
|
||||
// 获得画笔的FontMetrics,用来计算baseLine。因为drawText的y坐标,代表的是绘制的文字的baseLine的位置
|
||||
// Get the FontMetrics of the brush, used to calculate the baseLine. Because the y coordinate of drawText represents the position of the baseLine of the drawn text
|
||||
Paint.FontMetrics fontMetrics = mPaint.getFontMetrics();
|
||||
// 计算出在每格index区域,竖直居中的baseLine值
|
||||
// Calculate the baseLine value centered vertically in the index area of each grid
|
||||
int baseline = (int) ((mGapHeight - fontMetrics.bottom - fontMetrics.top) / 2);
|
||||
// 调用drawText,居中显示绘制index
|
||||
// Call drawText to center the drawing index
|
||||
canvas.drawText(index, mWidth / 2 - mPaint.measureText(index) / 2, t + mGapHeight * i + baseline, mPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
setBackgroundColor(mPressedBackground);
|
||||
// 注意这里没有break,因为down时,也要计算落点 回调监听器
|
||||
// Note that there is no break here, because when down, the drop point is also calculated. Callback listener
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
float y = event.getY();
|
||||
// 通过计算判断落点在哪个区域:
|
||||
// Determine which area the landing point is in by calculating:
|
||||
int pressI = (int) ((y - getPaddingTop()) / mGapHeight);
|
||||
// 边界处理(在手指move时,有可能已经移出边界,防止越界)
|
||||
// Boundary processing (when the finger moves, it may have moved out of the boundary to prevent crossing the boundary)
|
||||
if (pressI < 0) {
|
||||
pressI = 0;
|
||||
} else if (pressI >= mIndexDatas.size()) {
|
||||
pressI = mIndexDatas.size() - 1;
|
||||
}
|
||||
|
||||
if (null != mOnIndexPressedListener && pressI > -1 && pressI < mIndexDatas.size()) {
|
||||
mOnIndexPressedListener.onIndexPressed(pressI, mIndexDatas.get(pressI));
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
default:
|
||||
setBackgroundResource(android.R.color.transparent);
|
||||
|
||||
if (null != mOnIndexPressedListener) {
|
||||
mOnIndexPressedListener.onMotionEventEnd();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
mWidth = w;
|
||||
mHeight = h;
|
||||
|
||||
if (null == mIndexDatas || mIndexDatas.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
computeGapHeight();
|
||||
}
|
||||
|
||||
public onIndexPressedListener getOnIndexPressedListener() {
|
||||
return mOnIndexPressedListener;
|
||||
}
|
||||
|
||||
public void setOnIndexPressedListener(onIndexPressedListener mOnIndexPressedListener) {
|
||||
this.mOnIndexPressedListener = mOnIndexPressedListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示当前被按下的index的TextView
|
||||
*
|
||||
* Displays the TextView of the currently pressed index
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IndexBar setPressedShowTextView(TextView mPressedShowTextView) {
|
||||
this.mPressedShowTextView = mPressedShowTextView;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IndexBar setLayoutManager(CustomLinearLayoutManager mLayoutManager) {
|
||||
this.mLayoutManager = mLayoutManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一定要在设置数据源{@link #setSourceDatas(List)}之前调用
|
||||
*
|
||||
* Be sure to call before setting the data source {@link #setSourceDatas(List)}
|
||||
*
|
||||
* @param needRealIndex
|
||||
* @return
|
||||
*/
|
||||
public IndexBar setNeedRealIndex(boolean needRealIndex) {
|
||||
isNeedRealIndex = needRealIndex;
|
||||
initIndexDatas();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void initIndexDatas() {
|
||||
if (isNeedRealIndex) {
|
||||
mIndexDatas = new ArrayList<>();
|
||||
} else {
|
||||
mIndexDatas = Arrays.asList(INDEX_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
public IndexBar setSourceDatas(List<? extends BaseIndexPinyinBean> mSourceDatas) {
|
||||
this.mSourceDatas = mSourceDatas;
|
||||
initSourceDatas();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化原始数据源,并取出索引数据源
|
||||
*
|
||||
* Initialize the original data source and take out the index data source
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void initSourceDatas() {
|
||||
if (null == mSourceDatas || mSourceDatas.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!isSourceDatasAlreadySorted) {
|
||||
mDataHelper.sortSourceDatas(mSourceDatas);
|
||||
} else {
|
||||
mDataHelper.convert(mSourceDatas);
|
||||
mDataHelper.fillInexTag(mSourceDatas);
|
||||
}
|
||||
if (isNeedRealIndex) {
|
||||
mDataHelper.getSortedIndexDatas(mSourceDatas, mIndexDatas);
|
||||
computeGapHeight();
|
||||
}
|
||||
//sortData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 以下情况调用:
|
||||
* 1 在数据源改变
|
||||
* 2 控件size改变时
|
||||
* 计算gapHeight
|
||||
*
|
||||
*
|
||||
* Called when:
|
||||
* 1 change in data source
|
||||
* 2 When the control size changes
|
||||
* Calculate gapHeight
|
||||
*/
|
||||
private void computeGapHeight() {
|
||||
mGapHeight = (mHeight - getPaddingTop() - getPaddingBottom()) / mIndexDatas.size();
|
||||
}
|
||||
|
||||
|
||||
private void sortData() {
|
||||
|
||||
}
|
||||
|
||||
private int getPosByTag(String tag) {
|
||||
if (null == mSourceDatas || mSourceDatas.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < mSourceDatas.size(); i++) {
|
||||
if (tag.equals(mSourceDatas.get(i).getBaseIndexTag())) {
|
||||
return i + getHeaderViewCount();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public interface onIndexPressedListener {
|
||||
void onIndexPressed(int index, String text);//当某个Index被按下 // When an Index is pressed
|
||||
|
||||
void onMotionEventEnd();//当触摸事件结束(UP CANCEL) // When the touch event ends (UP CANCEL)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.suspension;
|
||||
|
||||
|
||||
public interface ISuspensionInterface {
|
||||
// 是否需要显示悬停title
|
||||
// Whether to display the hover title
|
||||
boolean isShowSuspension();
|
||||
|
||||
// 悬停的title
|
||||
// hover title
|
||||
String getSuspensionTag();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.component.indexlib.suspension;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SuspensionDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private static final String TAG = SuspensionDecoration.class.getSimpleName();
|
||||
private static int COLOR_TITLE_BG = Color.parseColor("#FFF2F3F5");
|
||||
private static int COLOR_TITLE_BOTTOM_LINE = Color.parseColor("#FFCACACA");
|
||||
private static int COLOR_TITLE_FONT = Color.parseColor("#FF888888");
|
||||
private int mTitleFontSize;
|
||||
private List<? extends ISuspensionInterface> mDatas;
|
||||
private Paint mPaint;
|
||||
private Rect mBounds;
|
||||
private int mTitleHeight;
|
||||
private int mHeaderViewCount = 0;
|
||||
|
||||
|
||||
public SuspensionDecoration(Context context, List<? extends ISuspensionInterface> datas) {
|
||||
super();
|
||||
mDatas = datas;
|
||||
mPaint = new Paint();
|
||||
mBounds = new Rect();
|
||||
mTitleHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 33f, context.getResources().getDisplayMetrics());
|
||||
mTitleFontSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 13f, context.getResources().getDisplayMetrics());
|
||||
mPaint.setTextSize(mTitleFontSize);
|
||||
mPaint.setAntiAlias(true);
|
||||
}
|
||||
|
||||
|
||||
public SuspensionDecoration setTitleHeight(int mTitleHeight) {
|
||||
this.mTitleHeight = mTitleHeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public SuspensionDecoration setColorTitleBg(int colorTitleBg) {
|
||||
COLOR_TITLE_BG = colorTitleBg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuspensionDecoration setColorTitleFont(int colorTitleFont) {
|
||||
COLOR_TITLE_FONT = colorTitleFont;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuspensionDecoration setTitleFontSize(int mTitleFontSize) {
|
||||
mPaint.setTextSize(mTitleFontSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuspensionDecoration setDatas(List<? extends ISuspensionInterface> mDatas) {
|
||||
this.mDatas = mDatas;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getHeaderViewCount() {
|
||||
return mHeaderViewCount;
|
||||
}
|
||||
|
||||
public SuspensionDecoration setHeaderViewCount(int headerViewCount) {
|
||||
mHeaderViewCount = headerViewCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
super.onDraw(c, parent, state);
|
||||
final int left = parent.getPaddingLeft();
|
||||
final int right = parent.getWidth() - parent.getPaddingRight();
|
||||
final int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = parent.getChildAt(i);
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
int position = params.getViewLayoutPosition();
|
||||
position -= getHeaderViewCount();
|
||||
|
||||
if (mDatas == null || mDatas.isEmpty() || position > mDatas.size() - 1 || position < 0 || !mDatas.get(position).isShowSuspension()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (position > -1) {
|
||||
if (position == 0) {
|
||||
drawTitleArea(c, left, right, child, params, position);
|
||||
|
||||
} else {
|
||||
if (null != mDatas.get(position).getSuspensionTag() && !mDatas.get(position).getSuspensionTag().equals(mDatas.get(position - 1).getSuspensionTag())) {
|
||||
drawTitleArea(c, left, right, child, params, position);
|
||||
} else {
|
||||
//none
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Title区域背景和文字的方法
|
||||
*
|
||||
* How to draw the background and text of the Title area
|
||||
*
|
||||
* @param c
|
||||
* @param left
|
||||
* @param right
|
||||
* @param child
|
||||
* @param params
|
||||
* @param position
|
||||
*/
|
||||
private void drawTitleArea(Canvas c, int left, int right, View child, RecyclerView.LayoutParams params, int position) {//最先调用,绘制在最下层 // Called first, drawn at the bottom layer
|
||||
mPaint.setColor(COLOR_TITLE_BG);
|
||||
c.drawRect(left, child.getTop() - params.topMargin - mTitleHeight, right, child.getTop() - params.topMargin, mPaint);
|
||||
|
||||
mPaint.setColor(COLOR_TITLE_BOTTOM_LINE);
|
||||
c.drawRect(left, child.getTop() - params.topMargin - 1, right, child.getTop() - params.topMargin, mPaint);
|
||||
|
||||
mPaint.setColor(COLOR_TITLE_FONT);
|
||||
mPaint.getTextBounds(mDatas.get(position).getSuspensionTag(), 0, mDatas.get(position).getSuspensionTag().length(), mBounds);
|
||||
c.drawText(mDatas.get(position).getSuspensionTag(), child.getPaddingLeft() + 61, child.getTop() - params.topMargin - (mTitleHeight / 2 - mBounds.height() / 2), mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawOver(Canvas c, final RecyclerView parent, RecyclerView.State state) {//最后调用 绘制在最上层 // Last call to draw on top
|
||||
int pos = ((LinearLayoutManager) (parent.getLayoutManager())).findFirstVisibleItemPosition();
|
||||
pos -= getHeaderViewCount();
|
||||
|
||||
if (mDatas == null || mDatas.isEmpty() || pos > mDatas.size() - 1 || pos < 0 || !mDatas.get(pos).isShowSuspension()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String tag = mDatas.get(pos).getSuspensionTag();
|
||||
//View child = parent.getChildAt(pos);
|
||||
View child = parent.findViewHolderForLayoutPosition(pos + getHeaderViewCount()).itemView;
|
||||
|
||||
boolean flag = false;//定义一个flag,Canvas是否位移过的标志 // Define a flag, whether the Canvas is shifted or not
|
||||
if ((pos + 1) < mDatas.size()) {
|
||||
if (null != tag && !tag.equals(mDatas.get(pos + 1).getSuspensionTag())) {
|
||||
// 当前第一个可见的Item的tag,不等于其后一个item的tag,说明悬浮的View要切换了
|
||||
// The tag of the current first visible item is not equal to the tag of the next item, indicating that the floating View is about to be switched.
|
||||
// TUIKitLog.d(TAG, "onDrawOver() called with: c = [" + child.getTop());
|
||||
if (child.getHeight() + child.getTop() < mTitleHeight) {
|
||||
// 当第一个可见的item在屏幕中还剩的高度小于title区域的高度时,我们也该开始做悬浮Title的“交换动画”
|
||||
// When the remaining height of the first visible item on the screen is less than the height of the title area, we should also start to do the "swap animation" of the floating Title
|
||||
c.save();
|
||||
flag = true;
|
||||
|
||||
//一种头部折叠起来的视效,个人觉得也还不错~
|
||||
//可与123行 c.drawRect 比较,只有bottom参数不一样,由于 child.getHeight() + child.getTop() < mTitleHeight,所以绘制区域是在不断的减小,有种折叠起来的感觉
|
||||
//c.clipRect(parent.getPaddingLeft(), parent.getPaddingTop(), parent.getRight() - parent.getPaddingRight(), parent.getPaddingTop() + child.getHeight() + child.getTop());
|
||||
|
||||
//类似饿了么点餐时,商品列表的悬停头部切换“动画效果”
|
||||
//上滑时,将canvas上移 (y为负数) ,所以后面canvas 画出来的Rect和Text都上移了,有种切换的“动画”感觉
|
||||
// Similar to Ele.me ordering, the hover head of the product list switches the "animation effect"
|
||||
// When sliding up, move the canvas up (y is a negative number), so the Rect and Text drawn by the canvas are moved up, and there is a kind of "animation" feeling of switching
|
||||
c.translate(0, child.getHeight() + child.getTop() - mTitleHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
mPaint.setColor(COLOR_TITLE_BG);
|
||||
c.drawRect(parent.getPaddingLeft(), parent.getPaddingTop(), parent.getRight() - parent.getPaddingRight(), parent.getPaddingTop() + mTitleHeight, mPaint);
|
||||
mPaint.setColor(COLOR_TITLE_FONT);
|
||||
mPaint.getTextBounds(tag, 0, tag.length(), mBounds);
|
||||
c.drawText(tag, child.getPaddingLeft() + 40,
|
||||
parent.getPaddingTop() + mTitleHeight - (mTitleHeight / 2 - mBounds.height() / 2),
|
||||
mPaint);
|
||||
if (flag)
|
||||
c.restore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
|
||||
position -= getHeaderViewCount();
|
||||
if (mDatas == null || mDatas.isEmpty() || position > mDatas.size() - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (position > -1) {
|
||||
ISuspensionInterface titleCategoryInterface = mDatas.get(position);
|
||||
if (titleCategoryInterface.isShowSuspension()) {
|
||||
if (position == 0) {
|
||||
outRect.set(0, mTitleHeight, 0, 0);
|
||||
} else {
|
||||
if (null != titleCategoryInterface.getSuspensionTag() && !titleCategoryInterface.getSuspensionTag().equals(mDatas.get(position - 1).getSuspensionTag())) {
|
||||
outRect.set(0, mTitleHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.config;
|
||||
|
||||
public class TUIContactConfig {
|
||||
public static final String TAG = TUIContactConfig.class.getSimpleName();
|
||||
private static TUIContactConfig instance;
|
||||
private boolean isShowUserStatus;
|
||||
|
||||
public static TUIContactConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TUIContactConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否显示用户在线状态
|
||||
*/
|
||||
public boolean isShowUserStatus() {
|
||||
return isShowUserStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否显示用户在线状态
|
||||
*/
|
||||
public void setShowUserStatus(boolean showUserStatus) {
|
||||
isShowUserStatus = showUserStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.interfaces;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ContactEventListener {
|
||||
/**
|
||||
* 好友申请新增通知,两种情况会收到这个回调:
|
||||
* 1. 自己申请加别人好友
|
||||
* 2. 别人申请加自己好友
|
||||
*
|
||||
* New friend request notification. You will receive this callback in the following cases:
|
||||
* 1. You send a friend request to others.
|
||||
* 2. You receive a friend request from others.
|
||||
*/
|
||||
public void onFriendApplicationListAdded(List<FriendApplicationBean> applicationList) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友申请删除通知,四种情况会收到这个回调
|
||||
* 1. 调用 deleteFriendApplication 主动删除好友申请
|
||||
* 2. 调用 refuseFriendApplication 拒绝好友申请
|
||||
* 3. 调用 acceptFriendApplication 同意好友申请且同意类型为 V2TIM_FRIEND_ACCEPT_AGREE 时
|
||||
* 4. 申请加别人好友被拒绝
|
||||
*
|
||||
*
|
||||
* Friend request deletion notification. You will receive this callback in the following cases:
|
||||
* 1. You call deleteFriendApplication to proactively delete a friend request.
|
||||
* 2. You call refuseFriendApplication to reject a friend request.
|
||||
* 3. You call acceptFriendApplication to accept a friend request and the acceptance type is V2TIM_FRIEND_ACCEPT_AGREE.
|
||||
* 4. Your friend request is rejected by others.
|
||||
*/
|
||||
public void onFriendApplicationListDeleted(List<String> userIDList) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友申请已读通知,如果调用 setFriendApplicationRead 设置好友申请列表已读,会收到这个回调(主要用于多端同步)
|
||||
*
|
||||
* Friend request read notification. When you call setFriendApplicationRead to set the friend request list as read, you will receive this callback (mainly used for multi-device synchronization).
|
||||
*/
|
||||
public void onFriendApplicationListRead() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友新增通知
|
||||
*
|
||||
* New friend notification
|
||||
*/
|
||||
public void onFriendListAdded(List<ContactItemBean> users) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友删除通知,,两种情况会收到这个回调:
|
||||
* 1. 自己删除好友(单向和双向删除都会收到回调)
|
||||
* 2. 好友把自己删除(双向删除会收到)
|
||||
*
|
||||
* Friend deletion notification. You will receive this callback in the following cases:
|
||||
* 1. You delete a friend (received for one-way or two-way friend deletion).
|
||||
* 2. You are deleted by a friend (received for two-way friend deletion).
|
||||
*/
|
||||
public void onFriendListDeleted(List<String> userList) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 黑名单新增通知
|
||||
*
|
||||
* New blocklist notification
|
||||
*/
|
||||
public void onBlackListAdd(List<ContactItemBean> infoList) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 黑名单删除通知
|
||||
*
|
||||
* Blocklist deletion notification
|
||||
*/
|
||||
public void onBlackListDeleted(List<String> userList) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友资料更新通知
|
||||
*
|
||||
* Friend profile update notification
|
||||
*/
|
||||
public void onFriendInfoChanged(List<ContactItemBean> infoList) {
|
||||
}
|
||||
/**
|
||||
* 好友资料更新通知
|
||||
*
|
||||
* Friend Remark update notification
|
||||
*/
|
||||
public void onFriendRemarkChanged(String id, String remark) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友在线状态变更通知
|
||||
*
|
||||
* User status update notification
|
||||
*/
|
||||
public void onUserStatusChanged(List<V2TIMUserStatus> userStatusList){
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新界面在线状态显示隐藏
|
||||
*/
|
||||
public void refreshUserStatusFragmentUI() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.interfaces;
|
||||
|
||||
public interface IAddMoreActivity {
|
||||
String getString(int resId);
|
||||
void finish();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.interfaces;
|
||||
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IContactListView {
|
||||
|
||||
class DataSource {
|
||||
public static final int UNKNOWN = -1;
|
||||
public static final int FRIEND_LIST = 1;
|
||||
public static final int BLACK_LIST = 2;
|
||||
public static final int GROUP_LIST = 3;
|
||||
public static final int CONTACT_LIST = 4;
|
||||
public static final int GROUP_MEMBER_LIST = 5;
|
||||
}
|
||||
|
||||
void onDataSourceChanged(List<ContactItemBean> contactItemBeanList);
|
||||
void onFriendApplicationChanged();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.interfaces;
|
||||
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
|
||||
public interface IFriendProfileLayout {
|
||||
void onDataSourceChanged(ContactItemBean bean);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.interfaces;
|
||||
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface INewFriendActivity {
|
||||
void onDataSourceChanged(List<FriendApplicationBean> beanList);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ILayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
|
||||
public interface IContactLayout extends ILayout {
|
||||
|
||||
ContactListView getContactListView();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IAddMoreActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.AddMorePresenter;
|
||||
|
||||
public class AddMoreMinimalistActivity extends BaseLightActivity implements IAddMoreActivity {
|
||||
|
||||
private static final String TAG = AddMoreMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private EditText searchEdit;
|
||||
private TextView idLabel;
|
||||
private TextView notFoundTip;
|
||||
private TextView searchBtn;
|
||||
private View detailArea;
|
||||
|
||||
private ImageView faceImgView;
|
||||
private TextView idTextView;
|
||||
private TextView groupTypeView;
|
||||
private TextView groupTypeTagView;
|
||||
private TextView nickNameView;
|
||||
|
||||
private boolean mIsGroup;
|
||||
|
||||
private AddMorePresenter presenter;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.contact_add_activity);
|
||||
if (getIntent() != null) {
|
||||
mIsGroup = getIntent().getExtras().getBoolean(TUIContactConstants.GroupType.GROUP);
|
||||
}
|
||||
|
||||
presenter = new AddMorePresenter();
|
||||
presenter.setAddMoreActivity(this);
|
||||
|
||||
faceImgView = findViewById(R.id.friend_icon);
|
||||
idTextView = findViewById(R.id.friend_account);
|
||||
groupTypeView = findViewById(R.id.group_type);
|
||||
nickNameView = findViewById(R.id.friend_nick_name);
|
||||
groupTypeTagView = findViewById(R.id.group_type_tag);
|
||||
|
||||
mTitleBar = findViewById(R.id.add_friend_titlebar);
|
||||
mTitleBar.setTitle(mIsGroup ? getResources().getString(R.string.add_group) : getResources().getString(R.string.add_friend), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
|
||||
searchEdit = findViewById(R.id.search_edit);
|
||||
if (mIsGroup) {
|
||||
searchEdit.setHint(R.string.hint_search_group_id);
|
||||
}
|
||||
|
||||
idLabel = findViewById(R.id.id_label);
|
||||
notFoundTip = findViewById(R.id.not_found_tip);
|
||||
searchBtn = findViewById(R.id.search_button);
|
||||
detailArea = findViewById(R.id.friend_detail_area);
|
||||
searchBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
notFoundTip.setVisibility(View.GONE);
|
||||
String id = searchEdit.getText().toString();
|
||||
|
||||
if (mIsGroup) {
|
||||
presenter.getGroupInfo(id, new IUIKitCallback<GroupInfo>() {
|
||||
@Override
|
||||
public void onSuccess(GroupInfo data) {
|
||||
setGroupDetail(data);
|
||||
detailArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), FriendProfileMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, data);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
setNotFound(true);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
presenter.getUserInfo(id, new IUIKitCallback<ContactItemBean>() {
|
||||
@Override
|
||||
public void onSuccess(ContactItemBean data) {
|
||||
setFriendDetail(data.getAvatarUrl(), data.getId(), data.getNickName());
|
||||
detailArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), FriendProfileMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, data);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
setNotFound(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!mIsGroup) {
|
||||
idLabel.setText(getString(R.string.contact_my_user_id, TUILogin.getLoginUser()));
|
||||
}
|
||||
|
||||
searchEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
idLabel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
searchEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (TextUtils.isEmpty(searchEdit.getText())) {
|
||||
detailArea.setVisibility(View.GONE);
|
||||
notFoundTip.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setGroupDetail(GroupInfo groupInfo) {
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(faceImgView, groupInfo.getFaceUrl(),
|
||||
TUIUtil.getDefaultGroupIconResIDByGroupType(this, groupInfo.getGroupType()), radius);
|
||||
idTextView.setText(groupInfo.getId());
|
||||
nickNameView.setText(groupInfo.getGroupName());
|
||||
groupTypeTagView.setVisibility(View.VISIBLE);
|
||||
groupTypeView.setVisibility(View.VISIBLE);
|
||||
groupTypeView.setText(groupInfo.getGroupType());
|
||||
detailArea.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setFriendDetail(String faceUrl, String id, String nickName) {
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(faceImgView, faceUrl, radius);
|
||||
idTextView.setText(id);
|
||||
if (TextUtils.isEmpty(nickName)) {
|
||||
nickNameView.setText(id);
|
||||
} else {
|
||||
nickNameView.setText(nickName);
|
||||
}
|
||||
groupTypeTagView.setVisibility(View.GONE);
|
||||
groupTypeView.setVisibility(View.GONE);
|
||||
detailArea.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setNotFound(boolean isGroup) {
|
||||
detailArea.setVisibility(View.GONE);
|
||||
if (isGroup) {
|
||||
notFoundTip.setText(getString(R.string.contact_no_such_group));
|
||||
} else {
|
||||
notFoundTip.setText(getString(R.string.contact_no_such_user));
|
||||
}
|
||||
notFoundTip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
public class BlackListMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mListView;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.minimalist_contact_blacklist_activity);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mTitleBar = findViewById(R.id.black_list_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.blacklist), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
|
||||
mListView = findViewById(R.id.black_list);
|
||||
mListView.setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
Intent intent = new Intent(BlackListMinimalistActivity.this, FriendProfileMinimalistActivity.class);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, contact);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
loadDataSource();
|
||||
}
|
||||
|
||||
public void loadDataSource() {
|
||||
presenter = new ContactPresenter();
|
||||
mListView.setPresenter(presenter);
|
||||
mListView.setNotFoundTip(getString(R.string.contact_no_block_list));
|
||||
presenter.setContactListView(mListView);
|
||||
presenter.setBlackListListener();
|
||||
mListView.loadDataSource(ContactListView.DataSource.BLACK_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.ImageSelectActivity;
|
||||
import com.tencent.qcloud.tuicore.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuicore.component.gatherimage.SynthesizedImageView;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.component.popupcard.PopupInputCard;
|
||||
import com.tencent.qcloud.tuicore.util.ImageUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ChatInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateGroupMinimalistActivity extends BaseLightActivity implements View.OnClickListener {
|
||||
private static final String TAG = CreateGroupMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private static final int CHOOSE_AVATAR_REQUEST_CODE = 1;
|
||||
private static final int CHOOSE_GROUP_TYPE_REQUEST_CODE = 2;
|
||||
private TitleBarLayout titleBarLayout;
|
||||
private SynthesizedImageView groupAvatar;
|
||||
private LineControllerView groupNameLv;
|
||||
private LineControllerView groupIdLv;
|
||||
private LineControllerView groupTypeLv;
|
||||
private View groupAvatarLayout;
|
||||
private TextView confirmButton;
|
||||
private TextView groupTypeContentView, groupTypeContentUrlView;
|
||||
|
||||
private String groupName;
|
||||
private String groupId;
|
||||
private String groupType = V2TIMManager.GROUP_TYPE_WORK;
|
||||
private String groupAvatarUrl;
|
||||
private List<Object> groupAvatarUrlList;
|
||||
private int joinTypeIndex;
|
||||
private String groupAvatarImageId = "";
|
||||
|
||||
private ArrayList<GroupMemberInfo> mGroupMembers = new ArrayList<>();
|
||||
private boolean mCreating;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.create_group_layout);
|
||||
|
||||
titleBarLayout = findViewById(R.id.create_group_bar);
|
||||
groupNameLv = findViewById(R.id.group_name_layout);
|
||||
groupIdLv = findViewById(R.id.group_id_layout);
|
||||
groupTypeLv = findViewById(R.id.group_type_layout);
|
||||
groupAvatarLayout = findViewById(R.id.group_avatar_layout);
|
||||
groupAvatar = findViewById(R.id.group_avatar);
|
||||
groupAvatar.setRadius(25);
|
||||
confirmButton = findViewById(R.id.confirm_button);
|
||||
groupTypeContentView = findViewById(R.id.group_type_text);
|
||||
groupTypeContentUrlView = findViewById(R.id.group_type_text_url);
|
||||
|
||||
initData();
|
||||
setupViews();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
TUIContactLog.e(TAG, "intent is null");
|
||||
return;
|
||||
}
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) {
|
||||
TUIContactLog.e(TAG, "bundle is null");
|
||||
return;
|
||||
}
|
||||
|
||||
mGroupMembers = (ArrayList<GroupMemberInfo>) bundle.getSerializable(TUIConstants.TUIGroup.GROUP_MEMBER_ID_LIST);
|
||||
|
||||
if (mGroupMembers == null || mGroupMembers.size() <= 1) {
|
||||
TUIContactLog.e(TAG, "mGroupMemberIcons <= 1");
|
||||
}
|
||||
|
||||
int num = mGroupMembers.size();
|
||||
if (num > 9) {
|
||||
num = 9;
|
||||
}
|
||||
for (int i = 0; i < num; i++) {
|
||||
groupAvatarImageId += mGroupMembers.get(i).getAccount();
|
||||
}
|
||||
|
||||
groupName = bundle.getString(TUIConstants.TUIGroup.GROUP_NAME);
|
||||
groupNameLv.setContent(groupName);
|
||||
|
||||
groupTypeLv.setContent(groupType);
|
||||
|
||||
if (TUIConfig.isEnableGroupGridAvatar()) {
|
||||
groupAvatarUrlList = fillGroupGridAvatar();
|
||||
groupAvatar.setImageId(groupAvatarImageId);
|
||||
groupAvatar.displayImage(groupAvatarUrlList).load(groupAvatarImageId);
|
||||
groupAvatarUrl = null;
|
||||
}
|
||||
|
||||
joinTypeIndex = bundle.getInt(TUIConstants.TUIGroup.JOIN_TYPE_INDEX, 2);
|
||||
}
|
||||
|
||||
private void setupViews() {
|
||||
titleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
titleBarLayout.setTitle(getString(R.string.create_group_chat), ITitleBarLayout.Position.MIDDLE);
|
||||
titleBarLayout.setOnLeftClickListener(this);
|
||||
|
||||
groupAvatar.setOnClickListener(this);
|
||||
groupAvatarLayout.setOnClickListener(this);
|
||||
groupNameLv.setOnClickListener(this);
|
||||
groupIdLv.setOnClickListener(this);
|
||||
groupTypeLv.setOnClickListener(this);
|
||||
groupAvatarLayout.setOnClickListener(this);
|
||||
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createGroupChat();
|
||||
}
|
||||
});
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
initGroupTypeContentView();
|
||||
}
|
||||
|
||||
private void initGroupTypeContentView() {
|
||||
switch(groupType) {
|
||||
case V2TIMManager.GROUP_TYPE_WORK:
|
||||
groupTypeContentView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_PUBLIC:
|
||||
groupTypeContentView.setText(getString(R.string.group_public_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_MEETING:
|
||||
groupTypeContentView.setText(getString(R.string.group_meeting_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_COMMUNITY:
|
||||
groupTypeContentView.setText(getString(R.string.group_commnity_des));
|
||||
break;
|
||||
default:
|
||||
groupTypeContentView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
}
|
||||
|
||||
String groupTypeContent = getResources().getString(R.string.group_type_content_title);
|
||||
String urlContent = getResources().getString(R.string.group_type_content_url);
|
||||
int urlContentIndex = groupTypeContent.lastIndexOf(urlContent);
|
||||
|
||||
final int foregroundColor;
|
||||
int currentTheme = TUIThemeManager.getInstance().getCurrentTheme();
|
||||
if (currentTheme == TUIThemeManager.THEME_LIVELY) {
|
||||
foregroundColor = getResources().getColor(com.tencent.qcloud.tuicore.R.color.core_primary_color_lively);
|
||||
} else if (currentTheme == TUIThemeManager.THEME_SERIOUS) {
|
||||
foregroundColor = getResources().getColor(com.tencent.qcloud.tuicore.R.color.core_primary_color_serious);
|
||||
} else {
|
||||
foregroundColor = getResources().getColor(com.tencent.qcloud.tuicore.R.color.core_primary_color_light);
|
||||
}
|
||||
|
||||
SpannableString spannedString = new SpannableString(groupTypeContent);
|
||||
ForegroundColorSpan colorSpan = new ForegroundColorSpan(foregroundColor);
|
||||
spannedString.setSpan(colorSpan, urlContentIndex, urlContentIndex + urlContent.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
openWebUrl(TUIContactConstants.IM_PRODUCT_DOC_URL);
|
||||
} else {
|
||||
openWebUrl(TUIContactConstants.IM_PRODUCT_DOC_URL_EN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
};
|
||||
spannedString.setSpan(clickableSpan, urlContentIndex, urlContentIndex + urlContent.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
groupTypeContentUrlView.setText(spannedString);
|
||||
groupTypeContentUrlView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == groupAvatar || v == groupAvatarLayout) {
|
||||
ArrayList<ImageSelectActivity.ImageBean> faceList = new ArrayList<>();
|
||||
if (TUIConfig.isEnableGroupGridAvatar()) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setGroupGridAvatar(fillGroupGridAvatar());
|
||||
imageBean.setImageId(groupAvatarImageId);
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
for (int i = 0; i < TUIConstants.TUIContact.GROUP_FACE_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setThumbnailUri(String.format(TUIConstants.TUIContact.GROUP_FACE_URL, (i + 1) + ""));
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CreateGroupMinimalistActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getString(R.string.group_choose_avatar));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 4);
|
||||
intent.putExtra(ImageSelectActivity.PLACEHOLDER, com.tencent.qcloud.tuicore.R.drawable.core_default_user_icon_light);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_WIDTH, ScreenUtil.dip2px(77));
|
||||
intent.putExtra(ImageSelectActivity.ITEM_HEIGHT, ScreenUtil.dip2px(77));
|
||||
intent.putExtra(ImageSelectActivity.DATA, faceList);
|
||||
intent.putExtra(ImageSelectActivity.SELECTED, faceList.get(0));
|
||||
startActivityForResult(intent, CHOOSE_AVATAR_REQUEST_CODE);
|
||||
} else if (v == groupNameLv) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(this);
|
||||
popupInputCard.setContent(groupNameLv.getContent().toString());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.modify_group_name));
|
||||
popupInputCard.setMaxLimit(30);
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
groupName = result;
|
||||
groupNameLv.setContent(groupName);
|
||||
|
||||
} else {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_name_edit_null_tips));
|
||||
}
|
||||
}
|
||||
});
|
||||
popupInputCard.setTextExceedListener(new PopupInputCard.OnTextExceedListener() {
|
||||
@Override
|
||||
public void onTextExceedMax() {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_name_edit_exceed_tips));
|
||||
}
|
||||
});
|
||||
popupInputCard.show(groupNameLv, Gravity.BOTTOM);
|
||||
} else if (v == groupIdLv) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(this);
|
||||
popupInputCard.setContent(groupIdLv.getContent().toString());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.modify_group_id));
|
||||
popupInputCard.setMaxLimit(48);
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
if (!TextUtils.isEmpty(result) && result.startsWith("@TGS#")) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_id_edit_format_tips));
|
||||
groupIdLv.setContent("");
|
||||
groupId = "";
|
||||
return;
|
||||
}
|
||||
|
||||
groupIdLv.setContent(result);
|
||||
groupId = result;
|
||||
}
|
||||
});
|
||||
popupInputCard.setTextExceedListener(new PopupInputCard.OnTextExceedListener() {
|
||||
@Override
|
||||
public void onTextExceedMax(){
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.group_id_edit_exceed_tips));
|
||||
}
|
||||
});
|
||||
popupInputCard.show(groupIdLv, Gravity.BOTTOM);
|
||||
} else if (v == groupTypeLv) {
|
||||
Intent intent = new Intent(this, GroupTypeSelectMinimalistActivity.class);
|
||||
startActivityForResult(intent, CHOOSE_GROUP_TYPE_REQUEST_CODE);
|
||||
} else if (v == titleBarLayout.getLeftGroup()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> fillGroupGridAvatar() {
|
||||
final List<Object> urlList = new ArrayList<>();
|
||||
String savedIcon = ImageUtil.getGroupConversationAvatar(groupAvatarImageId);
|
||||
if (TextUtils.isEmpty(savedIcon)) {
|
||||
int faceSize = Math.min(mGroupMembers.size(), 9);
|
||||
for (int i = 0; i < faceSize; i++) {
|
||||
String iconUrl = mGroupMembers.get(i).getIconUrl();
|
||||
urlList.add(TextUtils.isEmpty(iconUrl) ? TUIConfig.getDefaultAvatarImage() : iconUrl);
|
||||
}
|
||||
} else {
|
||||
urlList.add(savedIcon);
|
||||
}
|
||||
|
||||
return urlList;
|
||||
}
|
||||
|
||||
private void createGroupChat() {
|
||||
if (mCreating) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GroupInfo groupInfo = new GroupInfo();
|
||||
groupInfo.setChatName(groupName);
|
||||
groupInfo.setGroupName(groupName);
|
||||
groupInfo.setMemberDetails(mGroupMembers);
|
||||
groupInfo.setGroupType(groupType);
|
||||
groupInfo.setJoinType(joinTypeIndex);
|
||||
groupInfo.setCommunitySupportTopic(false);
|
||||
groupInfo.setFaceUrl(groupAvatarUrl);
|
||||
groupInfo.setId(groupId);
|
||||
|
||||
mCreating = true;
|
||||
|
||||
presenter.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ContactStartChatUtils.startChatActivity(data, ChatInfo.TYPE_GROUP, groupInfo.getGroupName(), groupInfo.getGroupType());
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mCreating = false;
|
||||
//mGroupMembers.remove(selfInfo);
|
||||
if (errCode == TUIConstants.BuyingFeature.ERR_SDK_INTERFACE_NOT_SUPPORT || errCode == 11000) {
|
||||
showNotSupportDialog();
|
||||
}
|
||||
ToastUtil.toastLongMessage("createGroupChat fail:" + errCode + "=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showNotSupportDialog() {
|
||||
String string = getResources().getString(R.string.contact_im_flagship_edition_update_tip, getString(R.string.contact_community));
|
||||
String buyingGuidelines = getResources().getString(R.string.contact_buying_guidelines);
|
||||
int buyingGuidelinesIndex = string.lastIndexOf(buyingGuidelines);
|
||||
final int foregroundColor = getResources().getColor(TUIThemeManager.getAttrResId(this, com.tencent.qcloud.tuicore.R.attr.core_primary_color));
|
||||
SpannableString spannedString = new SpannableString(string);
|
||||
ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(foregroundColor);
|
||||
spannedString.setSpan(colorSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
ClickableSpan clickableSpan2 = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC);
|
||||
} else {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC_EN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
};
|
||||
spannedString.setSpan(clickableSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance()
|
||||
.createDialog(this)
|
||||
.setMovementMethod(LinkMovementMethod.getInstance())
|
||||
.setShowOnlyDebug(true)
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(spannedString)
|
||||
.setDialogWidth(0.75f)
|
||||
.setDialogFeatureName(TUIConstants.BuyingFeature.BUYING_FEATURE_COMMUNITY)
|
||||
.setPositiveButton(getString(R.string.contact_no_more_reminders), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().setNeverShow(true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.contact_i_know), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void openWebUrl(String url) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == CHOOSE_AVATAR_REQUEST_CODE && resultCode == ImageSelectActivity.RESULT_CODE_SUCCESS) {
|
||||
if (data != null) {
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Object> faceUrl = imageBean.getGroupGridAvatar();
|
||||
if (faceUrl != null && !faceUrl.isEmpty()) {
|
||||
groupAvatar.setImageId(groupAvatarImageId);
|
||||
groupAvatar.displayImage(faceUrl).load(groupAvatarImageId);
|
||||
groupAvatarUrlList = faceUrl;
|
||||
groupAvatarUrl = null;
|
||||
} else {
|
||||
groupAvatarUrl = imageBean.getThumbnailUri();
|
||||
GlideEngine.loadImage(groupAvatar, groupAvatarUrl);
|
||||
}
|
||||
}
|
||||
} else if (requestCode == CHOOSE_GROUP_TYPE_REQUEST_CODE) {
|
||||
if (data != null) {
|
||||
String type = data.getStringExtra(TUIContactConstants.Selection.TYPE);
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
TUIContactLog.e(TAG, "onActivityResult type is null");
|
||||
return;
|
||||
}
|
||||
|
||||
groupType = type;
|
||||
groupTypeLv.setContent(type);
|
||||
initGroupTypeContentView();
|
||||
if (TextUtils.equals(groupType, V2TIMManager.GROUP_TYPE_COMMUNITY)) {
|
||||
groupIdLv.setOnClickListener(null);
|
||||
groupIdLv.setClickable(false);
|
||||
} else {
|
||||
groupIdLv.setClickable(true);
|
||||
groupIdLv.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.CustomLinearLayoutManager;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.SelectionActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ConversationInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ForwardContactSelectorAdapter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ForwardSelectGroupMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = ForwardSelectGroupMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private LineControllerView mJoinType;
|
||||
private ArrayList<GroupMemberInfo> mMembers = new ArrayList<>();
|
||||
private int mGroupType = -1;
|
||||
private int mJoinTypeIndex = 2;
|
||||
private ArrayList<String> mJoinTypes = new ArrayList<>();
|
||||
private ArrayList<String> mGroupTypeValue = new ArrayList<>();
|
||||
private boolean mCreating;
|
||||
private boolean isCreateNewChat = true;
|
||||
|
||||
private RecyclerView mForwardSelectlistView;
|
||||
private ForwardContactSelectorAdapter mAdapter;
|
||||
private List<String> mSelectConversationIcons = new ArrayList<>();
|
||||
private RelativeLayout mForwardSelectlistViewLayout;
|
||||
private TextView mSureView;
|
||||
|
||||
private List<ConversationInfo> mContactDataSource = new ArrayList<>();
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.minimalist_forward_select_group_contact);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private String getMembersUserId(){
|
||||
if (mMembers.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String userIdString = "";
|
||||
for(int i = 0; i < mMembers.size(); i++){
|
||||
userIdString += mMembers.get(i).getAccount();
|
||||
userIdString += " ";
|
||||
}
|
||||
return userIdString;
|
||||
}
|
||||
|
||||
private void refreshMembers(){
|
||||
if (mContactDataSource == null || mContactDataSource.size() ==0){
|
||||
mMembers.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0;i<mContactDataSource.size();i++){
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(mContactDataSource.get(i).getId());
|
||||
memberInfo.setIconUrl((String)mContactDataSource.get(i).getIconUrlList().get(0));
|
||||
mMembers.add(memberInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null){
|
||||
isCreateNewChat = intent.getBooleanExtra(TUIContactConstants.FORWARD_CREATE_NEW_CHAT, false);
|
||||
}
|
||||
|
||||
mTitleBar = findViewById(R.id.group_create_title_bar);
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mJoinType = findViewById(R.id.group_type_join);
|
||||
mJoinType.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showJoinTypePickerView();
|
||||
}
|
||||
});
|
||||
mJoinType.setCanNav(true);
|
||||
mJoinType.setContent("Public");
|
||||
mJoinType.setVisibility(View.GONE);
|
||||
|
||||
mContactListView = findViewById(R.id.group_create_member_list);
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setFriendListListener();
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(contact.getId());
|
||||
memberInfo.setIconUrl(contact.getAvatarUrl());
|
||||
mMembers.add(memberInfo);
|
||||
} else {
|
||||
for (int i = mMembers.size() - 1; i >= 0; i--) {
|
||||
if (mMembers.get(i).getAccount().equals(contact.getId())) {
|
||||
mMembers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshSelectConversations();
|
||||
}
|
||||
});
|
||||
|
||||
setGroupType(TUIContactConstants.GroupType.PUBLIC);
|
||||
|
||||
mForwardSelectlistViewLayout = findViewById(R.id.forward_contact_select_list_layout);
|
||||
mForwardSelectlistViewLayout.setVisibility(View.VISIBLE);
|
||||
mForwardSelectlistView = findViewById(R.id.forward_contact_select_list);
|
||||
mForwardSelectlistView.setLayoutManager(new CustomLinearLayoutManager(this, CustomLinearLayoutManager.HORIZONTAL, false));
|
||||
mAdapter = new ForwardContactSelectorAdapter(this);
|
||||
mForwardSelectlistView.setAdapter(mAdapter);
|
||||
|
||||
mSureView = findViewById(R.id.btn_msg_ok);
|
||||
mSureView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isCreateNewChat){
|
||||
createGroupChat();
|
||||
} else {
|
||||
Intent intent = new Intent();
|
||||
HashMap<String, String> conversationMap = new HashMap<>();
|
||||
if (mMembers != null && mMembers.size() != 0){
|
||||
for (int i=0;i<mMembers.size();i++){
|
||||
conversationMap.put(mMembers.get(i).getAccount(), mMembers.get(i).getIconUrl());
|
||||
}
|
||||
}
|
||||
|
||||
intent.putExtra(TUIContactConstants.FORWARD_SELECT_CONVERSATION_KEY, conversationMap);
|
||||
setResult(TUIContactConstants.FORWARD_SELECT_MEMBERS_CODE, intent);
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
refreshSelectConversations();
|
||||
}
|
||||
|
||||
private void refreshSelectConversations(){
|
||||
mSelectConversationIcons.clear();
|
||||
if (mMembers != null && mMembers.size() != 0){
|
||||
for (int i=0;i<mMembers.size();i++){
|
||||
mSelectConversationIcons.add(mMembers.get(i).getIconUrl());
|
||||
}
|
||||
}
|
||||
mAdapter.setDataSource(mSelectConversationIcons);
|
||||
|
||||
if (mSelectConversationIcons == null || mSelectConversationIcons.size() == 0){
|
||||
mSureView.setText(getString(com.tencent.qcloud.tuicore.R.string.sure));
|
||||
mSureView.setVisibility(View.GONE);
|
||||
mForwardSelectlistViewLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
mForwardSelectlistViewLayout.setVisibility(View.VISIBLE);
|
||||
mSureView.setVisibility(View.VISIBLE);
|
||||
mSureView.setText(getString(com.tencent.qcloud.tuicore.R.string.sure) + "(" + mSelectConversationIcons.size() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public void setGroupType(int type) {
|
||||
mGroupType = type;
|
||||
mTitleBar.setTitle(getResources().getString(R.string.contact_title), ITitleBarLayout.Position.MIDDLE);
|
||||
mJoinType.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showJoinTypePickerView() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SelectionActivity.Selection.TITLE, getResources().getString(R.string.group_join_type));
|
||||
bundle.putStringArrayList(SelectionActivity.Selection.LIST, mJoinTypes);
|
||||
bundle.putInt(SelectionActivity.Selection.DEFAULT_SELECT_ITEM_INDEX, mJoinTypeIndex);
|
||||
SelectionActivity.startListSelection(this, bundle, new SelectionActivity.OnResultReturnListener() {
|
||||
@Override
|
||||
public void onReturn(Object text) {
|
||||
mJoinType.setContent(mJoinTypes.get((Integer) text));
|
||||
mJoinTypeIndex = (Integer) text;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createGroupChat() {
|
||||
if (mCreating || mMembers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMembers.size() == 1){
|
||||
Intent intent = new Intent();
|
||||
HashMap<String, Boolean> conversationMap = new HashMap<>();
|
||||
conversationMap.put(mMembers.get(0).getAccount(), false);
|
||||
intent.putExtra(TUIContactConstants.FORWARD_SELECT_CONVERSATION_KEY, conversationMap);
|
||||
setResult(TUIContactConstants.FORWARD_CREATE_GROUP_CODE, intent);
|
||||
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(ContactUtils.getLoginUser());
|
||||
mMembers.add(memberInfo);
|
||||
|
||||
final GroupInfo groupInfo = new GroupInfo();
|
||||
String groupName = ContactUtils.getLoginUser();
|
||||
for (int i = 1; i < mMembers.size(); i++) {
|
||||
groupName = groupName + "、" + mMembers.get(i).getAccount();
|
||||
}
|
||||
if (groupName.length() > 20) {
|
||||
groupName = groupName.substring(0, 17) + "...";
|
||||
}
|
||||
groupInfo.setChatName(groupName);
|
||||
groupInfo.setGroupName(groupName);
|
||||
groupInfo.setMemberDetails(mMembers);
|
||||
groupInfo.setGroupType(TUIContactConstants.GroupType.TYPE_PUBLIC);
|
||||
groupInfo.setJoinType(0);
|
||||
|
||||
mCreating = true;
|
||||
|
||||
presenter.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
Intent intent = new Intent();
|
||||
HashMap<String, Boolean> conversationMap = new HashMap<>();
|
||||
conversationMap.put(data, true);
|
||||
|
||||
intent.putExtra(TUIContactConstants.FORWARD_SELECT_CONVERSATION_KEY, conversationMap);
|
||||
setResult(TUIContactConstants.FORWARD_CREATE_GROUP_CODE, intent);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mCreating = false;
|
||||
ToastUtil.toastLongMessage("createGroupChat fail:" + errCode + "=" + errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupApplication;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.ImageSelectActivity;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactGroupApplyInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.FriendProfileLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.FriendProfilePresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class FriendProfileMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private FriendProfilePresenter presenter;
|
||||
private FriendProfileLayout layout;
|
||||
private String mChatId;
|
||||
private String mChatBackgroundThumbnailUrl;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.minimalist_contact_friend_profile_activity);
|
||||
layout = findViewById(R.id.friend_profile);
|
||||
|
||||
presenter = new FriendProfilePresenter();
|
||||
layout.setPresenter(presenter);
|
||||
presenter.setFriendProfileLayout(layout);
|
||||
Intent intent = getIntent();
|
||||
mChatId = intent.getStringExtra(TUIConstants.TUIChat.CHAT_ID);
|
||||
mChatBackgroundThumbnailUrl = intent.getStringExtra(TUIConstants.TUIChat.CHAT_BACKGROUND_URI);
|
||||
String fromUser = intent.getStringExtra("fromUser");
|
||||
String fromUserNickName = intent.getStringExtra("fromUserNickName");
|
||||
String requestMsg = intent.getStringExtra("requestMsg");
|
||||
V2TIMGroupApplication application = (V2TIMGroupApplication) intent.getSerializableExtra("groupApplication");
|
||||
|
||||
if (!TextUtils.isEmpty(mChatId)) {
|
||||
layout.initData(mChatId);
|
||||
} else if (!TextUtils.isEmpty(fromUser)) {
|
||||
ContactGroupApplyInfo contactGroupApplyInfo = new ContactGroupApplyInfo();
|
||||
contactGroupApplyInfo.setFromUser(fromUser);
|
||||
contactGroupApplyInfo.setFromUserNickName(fromUserNickName);
|
||||
contactGroupApplyInfo.setRequestMsg(requestMsg);
|
||||
contactGroupApplyInfo.setTimGroupApplication(application);
|
||||
layout.initData(contactGroupApplyInfo);
|
||||
} else {
|
||||
layout.initData(intent.getSerializableExtra(TUIContactConstants.ProfileType.CONTENT));
|
||||
}
|
||||
layout.setOnButtonClickListener(new FriendProfileLayout.OnButtonClickListener() {
|
||||
@Override
|
||||
public void onStartConversationClick(ContactItemBean info) {
|
||||
String chatName = info.getId();
|
||||
if (!TextUtils.isEmpty(info.getRemark())) {
|
||||
chatName = info.getRemark();
|
||||
} else if (!TextUtils.isEmpty(info.getNickName())) {
|
||||
chatName = info.getNickName();
|
||||
}
|
||||
ContactStartChatUtils.startChatActivity(info.getId(), ContactItemBean.TYPE_C2C, chatName, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteFriendClick(String id) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetChatBackground() {
|
||||
ArrayList<ImageSelectActivity.ImageBean> faceList = new ArrayList<>();
|
||||
ImageSelectActivity.ImageBean defaultFace = new ImageSelectActivity.ImageBean();
|
||||
defaultFace.setDefault(true);
|
||||
faceList.add(defaultFace);
|
||||
for (int i = 0; i < TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setImageUri(String.format(TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_URL, (i + 1) + ""));
|
||||
imageBean.setThumbnailUri(String.format(TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_THUMBNAIL_URL, (i + 1) + ""));
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(FriendProfileMinimalistActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getResources().getString(R.string.chat_background_title));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 2);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_WIDTH, ScreenUtil.dip2px(186));
|
||||
intent.putExtra(ImageSelectActivity.ITEM_HEIGHT, ScreenUtil.dip2px(124));
|
||||
intent.putExtra(ImageSelectActivity.DATA, faceList);
|
||||
if (TextUtils.isEmpty(mChatBackgroundThumbnailUrl) || TextUtils.equals(TUIConstants.TUIChat.CHAT_CONVERSATION_BACKGROUND_DEFAULT_URL, mChatBackgroundThumbnailUrl)) {
|
||||
intent.putExtra(ImageSelectActivity.SELECTED, defaultFace);
|
||||
} else {
|
||||
intent.putExtra(ImageSelectActivity.SELECTED, new ImageSelectActivity.ImageBean(mChatBackgroundThumbnailUrl, "", false));
|
||||
}
|
||||
intent.putExtra(ImageSelectActivity.NEED_DOWLOAD_LOCAL, true);
|
||||
startActivityForResult(intent, TUIConstants.TUIChat.CHAT_REQUEST_BACKGROUND_CODE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == TUIConstants.TUIChat.CHAT_REQUEST_BACKGROUND_CODE) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
TUIContactLog.e("FriendProfileMinimalistActivity", "onActivityResult imageBean is null");
|
||||
return;
|
||||
}
|
||||
|
||||
String backgroundUri = imageBean.getLocalPath();
|
||||
String thumbnailUri = imageBean.getThumbnailUri();
|
||||
String dataUri = thumbnailUri + "," + backgroundUri;
|
||||
TUIContactLog.d("FriendProfileMinimalistActivity", "onActivityResult backgroundUri = " + backgroundUri);
|
||||
mChatBackgroundThumbnailUrl = thumbnailUri;
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIChat.CHAT_ID, mChatId);
|
||||
param.put(TUIConstants.TUIChat.CHAT_BACKGROUND_URI, dataUri);
|
||||
TUICore.callService(TUIConstants.TUIChat.SERVICE_NAME, TUIConstants.TUIChat.METHOD_UPDATE_DATA_STORE_CHAT_URI, param);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
public class GroupListMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = GroupListMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mListView;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.minimalist_group_list_activity);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
loadDataSource();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mTitleBar = findViewById(R.id.group_list_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.group), ITitleBarLayout.Position.LEFT);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.setTitle(getResources().getString(R.string.add_group), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(GroupListMinimalistActivity.this, AddMoreMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("isGroup", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
mListView = findViewById(R.id.group_list);
|
||||
mListView.setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
String chatName = contact.getId();
|
||||
if (!TextUtils.isEmpty(contact.getRemark())) {
|
||||
chatName = contact.getRemark();
|
||||
} else if (!TextUtils.isEmpty(contact.getNickName())) {
|
||||
chatName = contact.getNickName();
|
||||
}
|
||||
ContactStartChatUtils.startChatActivity(contact.getId(), ContactItemBean.TYPE_GROUP, chatName, contact.getGroupType());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadDataSource() {
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mListView.setIsGroupList(true);
|
||||
mListView.setPresenter(presenter);
|
||||
mListView.setNotFoundTip(getString(R.string.contact_no_group));
|
||||
presenter.setContactListView(mListView);
|
||||
mListView.loadDataSource(ContactListView.DataSource.GROUP_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupTypeSelectMinimalistActivity extends BaseLightActivity implements View.OnClickListener {
|
||||
private static final String TAG = GroupTypeSelectMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private RecyclerView.LayoutManager mLayoutManager;
|
||||
private RecyclerView.Adapter mAdapter;
|
||||
private List<String> mDatas = new ArrayList<>();
|
||||
private TitleBarLayout titleBarLayout;
|
||||
private TextView groupTypeTextView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.group_type_select_layout);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
||||
mAdapter = new MyAdapter(mDatas);
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
titleBarLayout = findViewById(R.id.create_group_bar);
|
||||
titleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
titleBarLayout.setTitle(getString(R.string.group_type_select_text), ITitleBarLayout.Position.MIDDLE);
|
||||
titleBarLayout.setOnLeftClickListener(this);
|
||||
groupTypeTextView = findViewById(R.id.group_type_text);
|
||||
groupTypeTextView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String url = "";
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
url = TUIContactConstants.IM_PRODUCT_DOC_URL;
|
||||
} else {
|
||||
url = TUIContactConstants.IM_PRODUCT_DOC_URL_EN;
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
String[] array = getResources().getStringArray(R.array.group_type);
|
||||
mDatas.addAll(Arrays.asList(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view == titleBarLayout.getLeftGroup()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>{
|
||||
private List<String> mDatas;
|
||||
|
||||
public MyAdapter(List<String> datas) {
|
||||
this.mDatas = datas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.group_type_item, parent, false);
|
||||
ViewHolder viewHolder = new ViewHolder(v);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
String type = this.mDatas.get(position);
|
||||
holder.imageView.setImageResource(TUIUtil.getDefaultGroupIconResIDByGroupType(getApplicationContext(), type));
|
||||
switch(type) {
|
||||
case V2TIMManager.GROUP_TYPE_WORK:
|
||||
holder.textView.setText(getString(R.string.group_work_type));
|
||||
holder.subTextView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_PUBLIC:
|
||||
holder.textView.setText(getString(R.string.group_public_type));
|
||||
holder.subTextView.setText(getString(R.string.group_public_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_MEETING:
|
||||
holder.textView.setText(getString(R.string.group_meeting_type));
|
||||
holder.subTextView.setText(getString(R.string.group_meeting_des));
|
||||
break;
|
||||
case V2TIMManager.GROUP_TYPE_COMMUNITY:
|
||||
holder.textView.setText(getString(R.string.group_commnity_type));
|
||||
holder.subTextView.setText(getString(R.string.group_commnity_des));
|
||||
break;
|
||||
default:
|
||||
holder.textView.setText(getString(R.string.group_work_type));
|
||||
holder.subTextView.setText(getString(R.string.group_work_content));
|
||||
break;
|
||||
}
|
||||
|
||||
holder.rootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(TUIContactConstants.Selection.TYPE, type);
|
||||
setResult(0, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.mDatas == null ? 0 : this.mDatas.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
View rootView;
|
||||
RelativeLayout itemLayout;
|
||||
ImageView imageView;
|
||||
TextView textView, subTextView;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
rootView = itemView;
|
||||
itemLayout = (RelativeLayout) itemView.findViewById(R.id.item_layout);
|
||||
imageView = (ImageView) itemView.findViewById(R.id.group_type_icon);
|
||||
textView = (TextView) itemView.findViewById(R.id.group_type_text);
|
||||
subTextView = (TextView) itemView.findViewById(R.id.group_type_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.INewFriendActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.NewFriendListAdapter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.NewFriendPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NewFriendMinimalistActivity extends BaseLightActivity implements INewFriendActivity {
|
||||
|
||||
private static final String TAG = NewFriendMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ListView mNewFriendLv;
|
||||
private NewFriendListAdapter mAdapter;
|
||||
private TextView notFoundTip;
|
||||
|
||||
private NewFriendPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.contact_new_friend_activity);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
initPendency();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mTitleBar = findViewById(R.id.new_friend_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.new_friend), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
presenter = new NewFriendPresenter();
|
||||
presenter.setFriendActivity(this);
|
||||
presenter.setFriendApplicationListAllRead(new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
mNewFriendLv = findViewById(R.id.new_friend_list);
|
||||
notFoundTip = findViewById(R.id.not_found_tip);
|
||||
}
|
||||
|
||||
private void initPendency() {
|
||||
presenter.loadFriendApplicationList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSourceChanged(List<FriendApplicationBean> dataSource) {
|
||||
TUIContactLog.i(TAG, "getFriendApplicationList success");
|
||||
if (dataSource == null || dataSource.isEmpty()) {
|
||||
notFoundTip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
notFoundTip.setVisibility(View.GONE);
|
||||
}
|
||||
mNewFriendLv.setVisibility(View.VISIBLE);
|
||||
mAdapter = new NewFriendListAdapter(NewFriendMinimalistActivity.this, R.layout.contact_new_friend_item, dataSource);
|
||||
mAdapter.setPresenter(presenter);
|
||||
mNewFriendLv.setAdapter(mAdapter);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StartC2CChatMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = StartC2CChatMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private ContactItemBean mSelectedItem;
|
||||
private List<ContactItemBean> mContacts = new ArrayList<>();
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.minimalist_popup_start_c2c_chat_activity);
|
||||
|
||||
mTitleBar = findViewById(R.id.start_c2c_chat_title);
|
||||
mTitleBar.setTitle(getResources().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startConversation();
|
||||
}
|
||||
});
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mContactListView = findViewById(R.id.contact_list_view);
|
||||
mContactListView.setSingleSelectMode(true);
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
if (mSelectedItem == contact) {
|
||||
|
||||
} else {
|
||||
if (mSelectedItem != null) {
|
||||
mSelectedItem.setSelected(false);
|
||||
}
|
||||
mSelectedItem = contact;
|
||||
}
|
||||
} else {
|
||||
if (mSelectedItem == contact) {
|
||||
mSelectedItem.setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void startConversation() {
|
||||
if (mSelectedItem == null || !mSelectedItem.isSelected()) {
|
||||
ToastUtil.toastLongMessage(getString(R.string.select_chat));
|
||||
return;
|
||||
}
|
||||
String chatName = mSelectedItem.getId();
|
||||
if (!TextUtils.isEmpty(mSelectedItem.getRemark())) {
|
||||
chatName = mSelectedItem.getRemark();
|
||||
} else if (!TextUtils.isEmpty(mSelectedItem.getNickName())) {
|
||||
chatName = mSelectedItem.getNickName();
|
||||
}
|
||||
|
||||
ContactStartChatUtils.startChatActivity(mSelectedItem.getId(), ContactItemBean.TYPE_C2C, chatName, "");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.activities.SelectionActivity;
|
||||
import com.tencent.qcloud.tuicore.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ChatInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.util.ContactStartChatUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StartGroupChatMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = StartGroupChatMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private LineControllerView mJoinType;
|
||||
private ArrayList<GroupMemberInfo> mMembers = new ArrayList<>();
|
||||
private int mGroupType = -1;
|
||||
private boolean communitySupportTopic = false;
|
||||
private int mJoinTypeIndex = 2;
|
||||
private ArrayList<String> mJoinTypes = new ArrayList<>();
|
||||
private ArrayList<String> mGroupTypeValue = new ArrayList<>();
|
||||
private boolean mCreating;
|
||||
private RecyclerView selectedList;
|
||||
private StartGroupMemberSelectMinimalistActivity.SelectedAdapter selectedListAdapter;
|
||||
private TextView confirmButton;
|
||||
private ContactPresenter presenter;
|
||||
private GroupMemberInfo selfInfo;
|
||||
private int limit;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.minimalist_popup_start_group_chat_activity);
|
||||
selfInfo = new GroupMemberInfo();
|
||||
selfInfo.setAccount(ContactUtils.getLoginUser());
|
||||
selfInfo.setNickName(TUIConfig.getSelfNickName());
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
limit = getIntent().getIntExtra(TUIContactConstants.Selection.LIMIT, Integer.MAX_VALUE);
|
||||
String[] array = getResources().getStringArray(R.array.group_type);
|
||||
mGroupTypeValue.addAll(Arrays.asList(array));
|
||||
array = getResources().getStringArray(R.array.group_join_type);
|
||||
mJoinTypes.addAll(Arrays.asList(array));
|
||||
|
||||
mTitleBar = findViewById(R.id.group_create_title_bar);
|
||||
mTitleBar.setTitle(getResources().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toCreateGroupChat();
|
||||
}
|
||||
});
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mJoinType = findViewById(R.id.group_type_join);
|
||||
mJoinType.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showJoinTypePickerView();
|
||||
}
|
||||
});
|
||||
mJoinType.setCanNav(true);
|
||||
mJoinType.setContent(mJoinTypes.get(2));
|
||||
|
||||
mContactListView = findViewById(R.id.group_create_member_list);
|
||||
confirmButton = findViewById(R.id.confirm_button);
|
||||
selectedList = findViewById(R.id.selected_list);
|
||||
selectedListAdapter = new StartGroupMemberSelectMinimalistActivity.SelectedAdapter();
|
||||
selectedList.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
|
||||
selectedList.setAdapter(selectedListAdapter);
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
ArrayList<String> alreadySelectedList = new ArrayList<>();
|
||||
alreadySelectedList.add(TUILogin.getLoginUser());
|
||||
mContactListView.setAlreadySelectedList(alreadySelectedList);
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(contact.getId());
|
||||
memberInfo.setNickName(contact.getNickName());
|
||||
memberInfo.setIconUrl(contact.getAvatarUrl());
|
||||
mMembers.add(memberInfo);
|
||||
} else {
|
||||
for (int i = mMembers.size() - 1; i >= 0; i--) {
|
||||
if (mMembers.get(i).getAccount().equals(contact.getId())) {
|
||||
mMembers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedListAdapter.setMembers(mMembers);
|
||||
selectedListAdapter.notifyDataSetChanged();
|
||||
if (mMembers.size() > 0) {
|
||||
confirmButton.setAlpha(1f);
|
||||
confirmButton.setEnabled(true);
|
||||
} else {
|
||||
confirmButton.setAlpha(0.5f);
|
||||
confirmButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toCreateGroupChat();
|
||||
}
|
||||
});
|
||||
confirmButton.setAlpha(0.5f);
|
||||
confirmButton.setEnabled(false);
|
||||
Intent intent = getIntent();
|
||||
communitySupportTopic = intent.getBooleanExtra(TUIConstants.TUIContact.COMMUNITY_SUPPORT_TOPIC_KEY, false);
|
||||
setGroupType(intent.getIntExtra(TUIConstants.TUIContact.GROUP_TYPE_KEY, TUIContactConstants.GroupType.PRIVATE));
|
||||
}
|
||||
|
||||
public void setGroupType(int type) {
|
||||
mGroupType = type;
|
||||
switch (type) {
|
||||
case TUIContactConstants.GroupType.PUBLIC:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_group_chat), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
case TUIContactConstants.GroupType.CHAT_ROOM:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_chat_room), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
case TUIContactConstants.GroupType.COMMUNITY:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_community), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
case TUIContactConstants.GroupType.PRIVATE:
|
||||
default:
|
||||
mTitleBar.setTitle(getResources().getString(R.string.create_private_group), ITitleBarLayout.Position.MIDDLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showJoinTypePickerView() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SelectionActivity.Selection.TITLE, getResources().getString(R.string.group_join_type));
|
||||
bundle.putStringArrayList(SelectionActivity.Selection.LIST, mJoinTypes);
|
||||
bundle.putInt(SelectionActivity.Selection.DEFAULT_SELECT_ITEM_INDEX, mJoinTypeIndex);
|
||||
SelectionActivity.startListSelection(this, bundle, new SelectionActivity.OnResultReturnListener() {
|
||||
@Override
|
||||
public void onReturn(Object text) {
|
||||
mJoinType.setContent(mJoinTypes.get((Integer) text));
|
||||
mJoinTypeIndex = (Integer) text;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toCreateGroupChat() {
|
||||
mMembers.add(0, selfInfo);
|
||||
if (mMembers.size() == 1) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.tips_empty_group_member));
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = selfInfo.getDisplayName();
|
||||
for (int i = 1; i < mMembers.size(); i++) {
|
||||
groupName = groupName + "、" + mMembers.get(i).getDisplayName();
|
||||
}
|
||||
if (groupName.length() >= 10) {
|
||||
groupName = groupName.substring(0, 7) + "..";
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TUIGroup.GROUP_NAME, groupName);
|
||||
bundle.putInt(TUIConstants.TUIGroup.JOIN_TYPE_INDEX, mJoinTypeIndex);
|
||||
bundle.putSerializable(TUIConstants.TUIGroup.GROUP_MEMBER_ID_LIST, mMembers);
|
||||
TUICore.startActivity("CreateGroupMinimalistActivity", bundle);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void createGroupChat() {
|
||||
if (mCreating) {
|
||||
return;
|
||||
}
|
||||
mMembers.add(0, selfInfo);
|
||||
if (mGroupType < 3 && mMembers.size() == 1) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.tips_empty_group_member));
|
||||
return;
|
||||
}
|
||||
if (mGroupType > 0 && mJoinTypeIndex == -1) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.tips_empty_group_type));
|
||||
return;
|
||||
}
|
||||
if (mGroupType == 0) {
|
||||
mJoinTypeIndex = -1;
|
||||
}
|
||||
final GroupInfo groupInfo = new GroupInfo();
|
||||
String groupName = selfInfo.getDisplayName();
|
||||
for (int i = 1; i < mMembers.size(); i++) {
|
||||
groupName = groupName + "、" + mMembers.get(i).getDisplayName();
|
||||
}
|
||||
if (groupName.length() >= 10) {
|
||||
groupName = groupName.substring(0, 7) + "..";
|
||||
}
|
||||
groupInfo.setChatName(groupName);
|
||||
groupInfo.setGroupName(groupName);
|
||||
groupInfo.setMemberDetails(mMembers);
|
||||
groupInfo.setGroupType(mGroupTypeValue.get(mGroupType));
|
||||
groupInfo.setJoinType(mJoinTypeIndex);
|
||||
groupInfo.setCommunitySupportTopic(communitySupportTopic);
|
||||
|
||||
mCreating = true;
|
||||
|
||||
presenter.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
if (!communitySupportTopic) {
|
||||
ContactStartChatUtils.startChatActivity(data, ChatInfo.TYPE_GROUP, groupInfo.getGroupName(), groupInfo.getGroupType());
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mCreating = false;
|
||||
mMembers.remove(selfInfo);
|
||||
if (errCode == TUIConstants.BuyingFeature.ERR_SDK_INTERFACE_NOT_SUPPORT || errCode == 11000) {
|
||||
showNotSupportDialog();
|
||||
}
|
||||
ToastUtil.toastLongMessage("createGroupChat fail:" + errCode + "=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showNotSupportDialog() {
|
||||
String string = getResources().getString(R.string.contact_im_flagship_edition_update_tip, getString(R.string.contact_community));
|
||||
String buyingGuidelines = getResources().getString(R.string.contact_buying_guidelines);
|
||||
int buyingGuidelinesIndex = string.lastIndexOf(buyingGuidelines);
|
||||
final int foregroundColor = getResources().getColor(TUIThemeManager.getAttrResId(this, com.tencent.qcloud.tuicore.R.attr.core_primary_color));
|
||||
SpannableString spannedString = new SpannableString(string);
|
||||
ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(foregroundColor);
|
||||
spannedString.setSpan(colorSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
ClickableSpan clickableSpan2 = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), "zh")) {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC);
|
||||
} else {
|
||||
openWebUrl(TUIConstants.BuyingFeature.BUYING_PRICE_DESC_EN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
};
|
||||
spannedString.setSpan(clickableSpan2, buyingGuidelinesIndex, buyingGuidelinesIndex + buyingGuidelines.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance()
|
||||
.createDialog(this)
|
||||
.setMovementMethod(LinkMovementMethod.getInstance())
|
||||
.setShowOnlyDebug(true)
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(spannedString)
|
||||
.setDialogWidth(0.75f)
|
||||
.setDialogFeatureName(TUIConstants.BuyingFeature.BUYING_FEATURE_COMMUNITY)
|
||||
.setPositiveButton(getString(R.string.contact_no_more_reminders), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().setNeverShow(true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.contact_i_know), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUIKitDialog.TUIIMUpdateDialog.getInstance().dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void openWebUrl(String url) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.RoundCornerImageView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StartGroupMemberSelectMinimalistActivity extends BaseLightActivity {
|
||||
|
||||
private static final String TAG = StartGroupMemberSelectMinimalistActivity.class.getSimpleName();
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ContactListView mContactListView;
|
||||
private ArrayList<GroupMemberInfo> mMembers = new ArrayList<>();
|
||||
private ArrayList<String> alreadySelectedList;
|
||||
private RecyclerView selectedList;
|
||||
private SelectedAdapter selectedListAdapter;
|
||||
private TextView confirmButton;
|
||||
private ContactPresenter presenter;
|
||||
private int limit;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.contact_minimalist_start_group_select_activity);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private ArrayList<String> getMembersNameCard(){
|
||||
if (mMembers.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ArrayList<String> nameCards = new ArrayList<>();
|
||||
for(int i = 0; i < mMembers.size(); i++){
|
||||
nameCards.add(mMembers.get(i).getNameCard());
|
||||
}
|
||||
return nameCards;
|
||||
}
|
||||
|
||||
private ArrayList<String> getMembersUserId(){
|
||||
if (mMembers.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ArrayList<String> userIds = new ArrayList<>();
|
||||
for(int i = 0; i < mMembers.size(); i++){
|
||||
userIds.add(mMembers.get(i).getAccount());
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMembers.clear();
|
||||
|
||||
String groupId = getIntent().getStringExtra(TUIContactConstants.Group.GROUP_ID);
|
||||
boolean isSelectFriends = getIntent().getBooleanExtra(TUIContactConstants.Selection.SELECT_FRIENDS, false);
|
||||
boolean isSelectForCall = getIntent().getBooleanExtra(TUIContactConstants.Selection.SELECT_FOR_CALL, false);
|
||||
limit = getIntent().getIntExtra(TUIContactConstants.Selection.LIMIT, Integer.MAX_VALUE);
|
||||
alreadySelectedList = getIntent().getStringArrayListExtra(TUIContactConstants.Selection.SELECTED_LIST);
|
||||
mTitleBar = findViewById(R.id.group_create_title_bar);
|
||||
mTitleBar.setTitle(getResources().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
mTitleBar.getRightIcon().setVisibility(View.GONE);
|
||||
mTitleBar.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmAndFinish();
|
||||
}
|
||||
});
|
||||
mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
confirmButton = findViewById(R.id.confirm_button);
|
||||
selectedList = findViewById(R.id.selected_list);
|
||||
selectedListAdapter = new SelectedAdapter();
|
||||
selectedList.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
|
||||
selectedList.setAdapter(selectedListAdapter);
|
||||
mContactListView = findViewById(R.id.group_create_member_list);
|
||||
mContactListView.setAlreadySelectedList(alreadySelectedList);
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
presenter.setIsForCall(isSelectForCall);
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
|
||||
mContactListView.setGroupId(groupId);
|
||||
if (isSelectFriends) {
|
||||
mTitleBar.setTitle(getString(R.string.add_group_member), TitleBarLayout.Position.MIDDLE);
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.FRIEND_LIST);
|
||||
} else {
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.GROUP_MEMBER_LIST);
|
||||
}
|
||||
|
||||
if (!isSelectForCall && !isSelectFriends) {
|
||||
mContactListView.setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
if (position == 0) {
|
||||
mMembers.clear();
|
||||
|
||||
Intent i = new Intent();
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_NAMECARD_SELECT, new ArrayList<String>(Arrays.asList(getString(R.string.at_all))));
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_ID_SELECT, new ArrayList<String>(Arrays.asList(TUIContactConstants.Selection.SELECT_ALL)));
|
||||
setResult(3, i);
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mContactListView.setOnSelectChangeListener(new ContactListView.OnSelectChangedListener() {
|
||||
@Override
|
||||
public void onSelectChanged(ContactItemBean contact, boolean selected) {
|
||||
if (selected) {
|
||||
GroupMemberInfo memberInfo = new GroupMemberInfo();
|
||||
memberInfo.setAccount(contact.getId());
|
||||
memberInfo.setIconUrl(contact.getAvatarUrl());
|
||||
memberInfo.setNameCard(TextUtils.isEmpty(contact.getNickName()) ? contact.getId() : contact.getNickName());
|
||||
mMembers.add(memberInfo);
|
||||
} else {
|
||||
for (int i = mMembers.size() - 1; i >= 0; i--) {
|
||||
if (mMembers.get(i).getAccount().equals(contact.getId())) {
|
||||
mMembers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedListAdapter.setMembers(mMembers);
|
||||
selectedListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmAndFinish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void confirmAndFinish() {
|
||||
if (mMembers.size() > limit) {
|
||||
String overLimitTip = getString(R.string.contact_over_limit_tip, limit);
|
||||
ToastUtil.toastShortMessage(overLimitTip);
|
||||
return;
|
||||
}
|
||||
Intent i = new Intent();
|
||||
List<String> friendIdList = new ArrayList<>();
|
||||
for (GroupMemberInfo memberInfo : mMembers) {
|
||||
friendIdList.add(memberInfo.getAccount());
|
||||
}
|
||||
i.putExtra(TUIContactConstants.Selection.LIST, (Serializable) friendIdList);
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_NAMECARD_SELECT, getMembersNameCard());
|
||||
i.putStringArrayListExtra(TUIContactConstants.Selection.USER_ID_SELECT, getMembersUserId());
|
||||
i.putExtras(getIntent());
|
||||
setResult(3, i);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class SelectedAdapter extends RecyclerView.Adapter<SelectedAdapter.SelectedViewHolder> {
|
||||
private List<GroupMemberInfo> mMembers;
|
||||
|
||||
public void setMembers(List<GroupMemberInfo> mMembers) {
|
||||
this.mMembers = mMembers;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SelectedViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new SelectedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.forward_contact_selector_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull SelectedViewHolder holder, int position) {
|
||||
GlideEngine.loadImage(holder.userIconView, mMembers.get(position).getIconUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mMembers == null) {
|
||||
return 0;
|
||||
}
|
||||
return mMembers.size();
|
||||
}
|
||||
|
||||
public class SelectedViewHolder extends RecyclerView.ViewHolder {
|
||||
public RoundCornerImageView userIconView;
|
||||
public SelectedViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
userIconView = itemView.findViewById(R.id.ivAvatar);
|
||||
userIconView.setRadius(ScreenUtil.dip2px(20));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.fragments.BaseFragment;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
public class TUIContactMinimalistFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = TUIContactMinimalistFragment.class.getSimpleName();
|
||||
private ContactLayout mContactLayout;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||
View baseView = inflater.inflate(R.layout.minimalist_contact_fragment, container, false);
|
||||
initViews(baseView);
|
||||
|
||||
return baseView;
|
||||
}
|
||||
|
||||
private void initViews(View view) {
|
||||
mContactLayout = view.findViewById(R.id.contact_layout);
|
||||
|
||||
presenter = new ContactPresenter();
|
||||
presenter.setFriendListListener();
|
||||
mContactLayout.setPresenter(presenter);
|
||||
mContactLayout.initDefault();
|
||||
|
||||
mContactLayout.getContactListView().setOnItemClickListener(new ContactListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, ContactItemBean contact) {
|
||||
if (position == 0) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), NewFriendMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
} else if (position == 1) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), GroupListMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
} else if (position == 2) {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), BlackListMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(TUIContactService.getAppContext(), FriendProfileMinimalistActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(TUIContactConstants.ProfileType.CONTENT, contact);
|
||||
TUIContactService.getAppContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
TUIContactLog.i(TAG, "onResume");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.util;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
|
||||
public class ContactStartChatUtils {
|
||||
public static boolean isC2CChat(int chatType) {
|
||||
return chatType == V2TIMConversation.V2TIM_C2C;
|
||||
}
|
||||
|
||||
public static boolean isGroupChat(int chatType) {
|
||||
return chatType == V2TIMConversation.V2TIM_GROUP;
|
||||
}
|
||||
|
||||
public static void startChatActivity(String chatId, int chatType, String chatName, String groupType) {
|
||||
if (TextUtils.isEmpty(chatId)) {
|
||||
return;
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_ID, chatId);
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_NAME, chatName);
|
||||
bundle.putInt(TUIConstants.TUIChat.CHAT_TYPE, chatType);
|
||||
if (isGroupChat(chatType)) {
|
||||
TUICore.startActivity("TUIGroupChatMinimalistActivity", bundle);
|
||||
} else {
|
||||
TUICore.startActivity("TUIC2CChatMinimalistActivity", bundle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.component.gatherimage.ShadeImageView;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.config.TUIContactConfig;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ViewHolder> {
|
||||
|
||||
protected List<ContactItemBean> mData;
|
||||
private ContactListView.OnSelectChangedListener mOnSelectChangedListener;
|
||||
private ContactListView.OnItemClickListener mOnClickListener;
|
||||
|
||||
private int mPreSelectedPosition;
|
||||
private boolean isSingleSelectMode;
|
||||
private ContactPresenter presenter;
|
||||
private boolean isGroupList = false;
|
||||
private int dataSourceType = ContactListView.DataSource.UNKNOWN;
|
||||
private ArrayList<String> alreadySelectedList;
|
||||
|
||||
public ContactAdapter(List<ContactItemBean> data) {
|
||||
this.mData = data;
|
||||
}
|
||||
|
||||
public void setPresenter(ContactPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
public void setIsGroupList(boolean groupList) {
|
||||
isGroupList = groupList;
|
||||
}
|
||||
|
||||
public void setAlreadySelectedList(ArrayList<String> alreadySelectedList) {
|
||||
this.alreadySelectedList = alreadySelectedList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_selecable_adapter_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, final int position) {
|
||||
final ContactItemBean contactBean = mData.get(position);
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)holder.line.getLayoutParams();
|
||||
if (position < mData.size() - 1) {
|
||||
String tag1 = contactBean.getSuspensionTag();
|
||||
String tag2 = mData.get(position + 1).getSuspensionTag();
|
||||
|
||||
if (TextUtils.equals(tag1, tag2)) {
|
||||
params.leftMargin = holder.tvName.getLeft();
|
||||
} else {
|
||||
params.leftMargin = 0;
|
||||
}
|
||||
} else {
|
||||
params.leftMargin = 0;
|
||||
}
|
||||
holder.line.setLayoutParams(params);
|
||||
if (!TextUtils.isEmpty(contactBean.getRemark())) {
|
||||
holder.tvName.setText(contactBean.getRemark());
|
||||
} else if (!TextUtils.isEmpty(contactBean.getNickName())) {
|
||||
holder.tvName.setText(contactBean.getNickName());
|
||||
} else {
|
||||
holder.tvName.setText(contactBean.getId());
|
||||
}
|
||||
if (mOnSelectChangedListener != null) {
|
||||
holder.ccSelect.setVisibility(View.VISIBLE);
|
||||
holder.ccSelect.setChecked(contactBean.isSelected());
|
||||
}
|
||||
|
||||
holder.content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!contactBean.isEnable()) {
|
||||
return;
|
||||
}
|
||||
holder.ccSelect.setChecked(!holder.ccSelect.isChecked());
|
||||
if (mOnSelectChangedListener != null) {
|
||||
mOnSelectChangedListener.onSelectChanged(getItem(position), holder.ccSelect.isChecked());
|
||||
}
|
||||
contactBean.setSelected(holder.ccSelect.isChecked());
|
||||
if (mOnClickListener != null) {
|
||||
mOnClickListener.onItemClick(position, contactBean);
|
||||
}
|
||||
if (isSingleSelectMode && position != mPreSelectedPosition && contactBean.isSelected()) {
|
||||
mData.get(mPreSelectedPosition).setSelected(false);
|
||||
notifyItemChanged(mPreSelectedPosition);
|
||||
}
|
||||
mPreSelectedPosition = position;
|
||||
}
|
||||
});
|
||||
holder.unreadText.setVisibility(View.GONE);
|
||||
holder.userStatusView.setVisibility(View.GONE);
|
||||
if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.new_friend), contactBean.getId())) {
|
||||
holder.avatar.setImageResource(TUIThemeManager.getAttrResId(holder.itemView.getContext(), R.attr.contact_new_friend_icon));
|
||||
|
||||
presenter.getFriendApplicationUnreadCount(new IUIKitCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer data) {
|
||||
if (data == 0) {
|
||||
holder.unreadText.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.unreadText.setVisibility(View.VISIBLE);
|
||||
holder.unreadText.setText("" + data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.group), contactBean.getId())) {
|
||||
holder.avatar.setImageResource(TUIThemeManager.getAttrResId(holder.itemView.getContext(), R.attr.contact_group_list_icon));
|
||||
} else if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.blacklist), contactBean.getId())) {
|
||||
holder.avatar.setImageResource(TUIThemeManager.getAttrResId(holder.itemView.getContext(), R.attr.contact_black_list_icon));
|
||||
} else {
|
||||
int radius = holder.itemView.getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
if (isGroupList) {
|
||||
int defaultIconResId = TUIUtil.getDefaultGroupIconResIDByGroupType(holder.itemView.getContext(), contactBean.getGroupType());
|
||||
GlideEngine.loadUserIcon(holder.avatar, contactBean.getAvatarUrl(), defaultIconResId, radius);
|
||||
} else {
|
||||
GlideEngine.loadUserIcon(holder.avatar, contactBean.getAvatarUrl(), radius);
|
||||
}
|
||||
if (dataSourceType == ContactListView.DataSource.CONTACT_LIST && TUIContactConfig.getInstance().isShowUserStatus()) {
|
||||
holder.userStatusView.setVisibility(View.VISIBLE);
|
||||
if (contactBean.getStatusType() == V2TIMUserStatus.V2TIM_USER_STATUS_ONLINE) {
|
||||
holder.userStatusView.setBackgroundResource(TUIThemeManager.getAttrResId(TUIContactService.getAppContext(), com.tencent.qcloud.tuicore.R.attr.user_status_online));
|
||||
} else {
|
||||
holder.userStatusView.setBackgroundResource(TUIThemeManager.getAttrResId(TUIContactService.getAppContext(), com.tencent.qcloud.tuicore.R.attr.user_status_offline));
|
||||
}
|
||||
} else {
|
||||
holder.userStatusView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
setAlreadySelected(holder, contactBean);
|
||||
}
|
||||
|
||||
private void setAlreadySelected(ViewHolder holder, ContactItemBean contactItemBean) {
|
||||
if (alreadySelectedList != null && alreadySelectedList.contains(contactItemBean.getId())) {
|
||||
holder.ccSelect.setChecked(true);
|
||||
holder.itemView.setEnabled(false);
|
||||
holder.ccSelect.setEnabled(false);
|
||||
} else {
|
||||
holder.itemView.setEnabled(true);
|
||||
holder.ccSelect.setEnabled(true);
|
||||
holder.ccSelect.setSelected(contactItemBean.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(ViewHolder holder) {
|
||||
if (holder != null) {
|
||||
GlideEngine.clear(holder.avatar);
|
||||
holder.avatar.setImageResource(0);
|
||||
|
||||
}
|
||||
super.onViewRecycled(holder);
|
||||
}
|
||||
|
||||
private ContactItemBean getItem(int position) {
|
||||
if (position < mData.size()) {
|
||||
return mData.get(position);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData != null ? mData.size() : 0;
|
||||
}
|
||||
|
||||
public void setDataSource(List<ContactItemBean> datas) {
|
||||
this.mData = datas;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setSingleSelectMode(boolean mode) {
|
||||
isSingleSelectMode = mode;
|
||||
}
|
||||
|
||||
public void setOnSelectChangedListener(ContactListView.OnSelectChangedListener selectListener) {
|
||||
mOnSelectChangedListener = selectListener;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(ContactListView.OnItemClickListener listener) {
|
||||
mOnClickListener = listener;
|
||||
}
|
||||
|
||||
public void setDataSourceType(int dataSourceType) {
|
||||
this.dataSourceType = dataSourceType;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvName;
|
||||
TextView unreadText;
|
||||
ShadeImageView avatar;
|
||||
CheckBox ccSelect;
|
||||
View content;
|
||||
View line;
|
||||
View userStatusView;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvName = itemView.findViewById(R.id.tvCity);
|
||||
unreadText = itemView.findViewById(R.id.conversation_unread);
|
||||
unreadText.setVisibility(View.GONE);
|
||||
avatar = itemView.findViewById(R.id.ivAvatar);
|
||||
ccSelect = itemView.findViewById(R.id.contact_check_box);
|
||||
content = itemView.findViewById(R.id.selectable_contact_item);
|
||||
line = itemView.findViewById(R.id.view_line);
|
||||
userStatusView = itemView.findViewById(R.id.user_status);
|
||||
|
||||
avatar.setRadius(ScreenUtil.dip2px(20));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.action.PopActionClickListener;
|
||||
import com.tencent.qcloud.tuicore.component.action.PopMenuAction;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.interfaces.IContactLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.minimalistui.pages.AddMoreMinimalistActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ContactLayout extends LinearLayout implements IContactLayout {
|
||||
|
||||
private static final String TAG = ContactLayout.class.getSimpleName();
|
||||
|
||||
private ContactListView mContactListView;
|
||||
private View createNewButton;
|
||||
private Menu menu;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
|
||||
public ContactLayout(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactLayout(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setPresenter(ContactPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.minimalist_contact_layout, this);
|
||||
mContactListView = findViewById(R.id.contact_listview);
|
||||
createNewButton = findViewById(R.id.create_new_button);
|
||||
initContactMenu();
|
||||
createNewButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (menu != null && !menu.isShowing()) {
|
||||
menu.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initContactMenu() {
|
||||
menu = new Menu((Activity) getContext(), createNewButton);
|
||||
List<PopMenuAction> menuActionList = new ArrayList<>(2);
|
||||
PopActionClickListener popActionClickListener = new PopActionClickListener() {
|
||||
@Override
|
||||
public void onActionClick(int index, Object data) {
|
||||
PopMenuAction action = (PopMenuAction) data;
|
||||
boolean isGroup = false;
|
||||
if (TextUtils.equals(action.getActionName(), getResources().getString(R.string.add_friend))) {
|
||||
isGroup = false;
|
||||
}
|
||||
if (TextUtils.equals(action.getActionName(), getResources().getString(R.string.add_group))) {
|
||||
isGroup = true;
|
||||
}
|
||||
Intent intent = new Intent(getContext(), AddMoreMinimalistActivity.class);
|
||||
intent.putExtra(TUIContactConstants.GroupType.GROUP, isGroup);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getContext().startActivity(intent);
|
||||
menu.hide();
|
||||
}
|
||||
};
|
||||
PopMenuAction action = new PopMenuAction();
|
||||
action.setActionName(getResources().getString(R.string.add_friend));
|
||||
action.setIconResId(R.drawable.contact_add_friend);
|
||||
action.setActionClickListener(popActionClickListener);
|
||||
menuActionList.add(action);
|
||||
|
||||
action = new PopMenuAction();
|
||||
action.setActionName(getResources().getString(R.string.add_group));
|
||||
action.setIconResId(R.drawable.contact_add_group);
|
||||
action.setActionClickListener(popActionClickListener);
|
||||
menuActionList.add(action);
|
||||
menu.setMenuAction(menuActionList);
|
||||
}
|
||||
|
||||
|
||||
public void initDefault() {
|
||||
mContactListView.setPresenter(presenter);
|
||||
presenter.setContactListView(mContactListView);
|
||||
mContactListView.loadDataSource(ContactListView.DataSource.CONTACT_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactListView getContactListView() {
|
||||
return mContactListView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TitleBarLayout getTitleBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentLayout(Object parent) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.CustomLinearLayoutManager;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.widget.IndexBar;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.component.indexlib.suspension.SuspensionDecoration;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.ContactPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ContactListView extends LinearLayout implements IContactListView {
|
||||
|
||||
private static final String TAG = ContactListView.class.getSimpleName();
|
||||
|
||||
private RecyclerView mRv;
|
||||
private ContactAdapter mAdapter;
|
||||
private CustomLinearLayoutManager mManager;
|
||||
private List<ContactItemBean> mData = new ArrayList<>();
|
||||
private SuspensionDecoration mDecoration;
|
||||
private ProgressBar mContactLoadingBar;
|
||||
private String groupId;
|
||||
private boolean isGroupList = false;
|
||||
|
||||
private TextView notFoundTip;
|
||||
/**
|
||||
* 右侧边栏导航区域
|
||||
*/
|
||||
private IndexBar mIndexBar;
|
||||
|
||||
private TextView mTvSideBarHint;
|
||||
|
||||
private ContactPresenter presenter;
|
||||
|
||||
private int dataSourceType = DataSource.UNKNOWN;
|
||||
private ArrayList<String> alreadySelectedList;
|
||||
|
||||
public ContactListView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactListView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ContactListView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setPresenter(ContactPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setPresenter(presenter);
|
||||
mAdapter.setIsGroupList(isGroupList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsGroupList(boolean isGroupList) {
|
||||
this.isGroupList = isGroupList;
|
||||
}
|
||||
|
||||
public void setAlreadySelectedList(ArrayList<String> alreadySelectedList) {
|
||||
this.alreadySelectedList = alreadySelectedList;
|
||||
mAdapter.setAlreadySelectedList(alreadySelectedList);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.minimalist_contact_list, this);
|
||||
mRv = findViewById(R.id.contact_member_list);
|
||||
notFoundTip = findViewById(R.id.not_found_tip);
|
||||
mManager = new CustomLinearLayoutManager(getContext());
|
||||
mRv.setLayoutManager(mManager);
|
||||
|
||||
mAdapter = new ContactAdapter(mData);
|
||||
mRv.setAdapter(mAdapter);
|
||||
mRv.addItemDecoration(mDecoration = new SuspensionDecoration(getContext(), mData));
|
||||
mRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
int lastCompletelyVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
|
||||
if(lastCompletelyVisibleItemPosition==layoutManager.getItemCount()-1) {
|
||||
if (presenter.getNextSeq() > 0) {
|
||||
presenter.loadGroupMemberList(groupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
mTvSideBarHint = findViewById(R.id.contact_tvSideBarHint);
|
||||
mIndexBar = findViewById(R.id.contact_indexBar);
|
||||
mIndexBar.setPressedShowTextView(mTvSideBarHint)
|
||||
.setNeedRealIndex(false)
|
||||
.setLayoutManager(mManager);
|
||||
mContactLoadingBar = findViewById(R.id.contact_loading_bar);
|
||||
}
|
||||
|
||||
public ContactAdapter getAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
public void setNotFoundTip(String text) {
|
||||
notFoundTip.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSourceChanged(List<ContactItemBean> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
if (!TextUtils.isEmpty(notFoundTip.getText())) {
|
||||
notFoundTip.setVisibility(VISIBLE);
|
||||
}
|
||||
} else {
|
||||
notFoundTip.setVisibility(GONE);
|
||||
}
|
||||
mContactLoadingBar.setVisibility(GONE);
|
||||
this.mData = data;
|
||||
mAdapter.setDataSource(mData);
|
||||
mIndexBar.setSourceDatas(mData).invalidate();
|
||||
mDecoration.setDatas(mData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationChanged() {
|
||||
if (dataSourceType == DataSource.CONTACT_LIST) {
|
||||
mAdapter.notifyItemChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSingleSelectMode(boolean mode) {
|
||||
mAdapter.setSingleSelectMode(mode);
|
||||
}
|
||||
|
||||
public void setOnSelectChangeListener(OnSelectChangedListener selectChangeListener) {
|
||||
mAdapter.setOnSelectChangedListener(selectChangeListener);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
mAdapter.setOnItemClickListener(listener);
|
||||
}
|
||||
|
||||
public void loadDataSource(int dataSource) {
|
||||
this.dataSourceType = dataSource;
|
||||
if (presenter == null) {
|
||||
return;
|
||||
}
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setDataSourceType(dataSource);
|
||||
}
|
||||
mContactLoadingBar.setVisibility(VISIBLE);
|
||||
if (dataSource == DataSource.GROUP_MEMBER_LIST) {
|
||||
presenter.loadGroupMemberList(groupId);
|
||||
} else {
|
||||
presenter.loadDataSource(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public interface OnSelectChangedListener {
|
||||
void onSelectChanged(ContactItemBean contact, boolean selected);
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int position, ContactItemBean contact);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ForwardContactSelectorAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
private Context context;
|
||||
private List<String> list;
|
||||
private RecyclerView mRecycleView;
|
||||
|
||||
public ForwardContactSelectorAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
mRecycleView = (RecyclerView) recyclerView;
|
||||
//mRecycleView.setItemViewCacheSize(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ContactViewHolder(LayoutInflater.from(context).inflate(R.layout.forward_contact_selector_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ContactViewHolder viewHolder = (ContactViewHolder) holder;
|
||||
if (viewHolder != null){
|
||||
if (!TextUtils.isEmpty(list.get(position))) {
|
||||
GlideEngine.loadImage(viewHolder.userIconView, list.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setDataSource(List<String> provider) {
|
||||
if (provider == null) {
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
}
|
||||
} else {
|
||||
list = provider;
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
}
|
||||
|
||||
class ContactViewHolder extends RecyclerView.ViewHolder {
|
||||
public ImageView userIconView;
|
||||
public ContactViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
userIconView = (ImageView) itemView.findViewById(R.id.ivAvatar);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,662 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuicore.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuicore.component.gatherimage.ShadeImageView;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.component.popupcard.PopupInputCard;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuicore.util.TUIUtil;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ChatInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactGroupApplyInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IFriendProfileLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.FriendProfilePresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FriendProfileLayout extends LinearLayout implements View.OnClickListener, IFriendProfileLayout {
|
||||
|
||||
private static final String TAG = FriendProfileLayout.class.getSimpleName();
|
||||
|
||||
private final int CHANGE_REMARK_CODE = 200;
|
||||
|
||||
private TitleBarLayout mTitleBar;
|
||||
private ShadeImageView mHeadImageView;
|
||||
private TextView mNickNameView;
|
||||
private TextView mIDView;
|
||||
private TextView mSignatureView;
|
||||
private TextView mSignatureTagView;
|
||||
private TextView remarkAndGroupTip;
|
||||
private LineControllerView mRemarkView;
|
||||
private LineControllerView mAddBlackView;
|
||||
private LineControllerView mChatTopView;
|
||||
private LineControllerView mMessageOptionView;
|
||||
private LineControllerView addFriendRemarkLv;
|
||||
private LineControllerView addFriendGroupLv;
|
||||
private LineControllerView mChatBackground;
|
||||
private Button deleteFriendBtn;
|
||||
private Button clearMessageBtn;
|
||||
private Button chatBtn;
|
||||
private Button audioCallBtn;
|
||||
private Button videoCallBtn;
|
||||
private Button addFriendSendBtn;
|
||||
private Button acceptFriendBtn;
|
||||
private Button refuseFriendBtn;
|
||||
private View addFriendArea;
|
||||
private EditText addWordingEditText;
|
||||
private View friendApplicationVerifyArea;
|
||||
private TextView friendApplicationAddWording;
|
||||
|
||||
private ContactItemBean mContactInfo;
|
||||
private FriendApplicationBean friendApplicationBean;
|
||||
private OnButtonClickListener mListener;
|
||||
private String mId;
|
||||
private String mNickname;
|
||||
private String mRemark;
|
||||
private String mAddWords;
|
||||
private boolean isFriend;
|
||||
private boolean isGroup = false;
|
||||
|
||||
private FriendProfilePresenter presenter;
|
||||
|
||||
public FriendProfileLayout(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public FriendProfileLayout(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public FriendProfileLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setPresenter(FriendProfilePresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.minimalist_contact_friend_profile_layout, this);
|
||||
|
||||
mHeadImageView = findViewById(R.id.friend_icon);
|
||||
mNickNameView = findViewById(R.id.friend_nick_name);
|
||||
mIDView = findViewById(R.id.friend_account);
|
||||
mRemarkView = findViewById(R.id.remark);
|
||||
mRemarkView.setOnClickListener(this);
|
||||
mSignatureTagView = findViewById(R.id.friend_signature_tag);
|
||||
mSignatureView = findViewById(R.id.friend_signature);
|
||||
mMessageOptionView = findViewById(R.id.msg_rev_opt);
|
||||
mMessageOptionView.setOnClickListener(this);
|
||||
mChatTopView = findViewById(R.id.chat_to_top);
|
||||
mAddBlackView = findViewById(R.id.blackList);
|
||||
deleteFriendBtn = findViewById(R.id.btn_delete);
|
||||
deleteFriendBtn.setOnClickListener(this);
|
||||
clearMessageBtn = findViewById(R.id.btn_clear_chat_history);
|
||||
clearMessageBtn.setOnClickListener(this);
|
||||
chatBtn = findViewById(R.id.btn_chat);
|
||||
chatBtn.setOnClickListener(this);
|
||||
mChatBackground = findViewById(R.id.chat_background);
|
||||
mChatBackground.setOnClickListener(this);
|
||||
|
||||
audioCallBtn = findViewById(R.id.btn_voice);
|
||||
audioCallBtn.setOnClickListener(this);
|
||||
videoCallBtn = findViewById(R.id.btn_video);
|
||||
videoCallBtn.setOnClickListener(this);
|
||||
|
||||
addFriendSendBtn = findViewById(R.id.add_friend_send_btn);
|
||||
addFriendSendBtn.setOnClickListener(this);
|
||||
|
||||
acceptFriendBtn = findViewById(R.id.accept_friend_send_btn);
|
||||
refuseFriendBtn = findViewById(R.id.refuse_friend_send_btn);
|
||||
|
||||
addFriendArea = findViewById(R.id.add_friend_verify_area);
|
||||
addWordingEditText = findViewById(R.id.add_wording_edit);
|
||||
|
||||
friendApplicationVerifyArea = findViewById(R.id.friend_application_verify_area);
|
||||
friendApplicationAddWording = findViewById(R.id.friend_application_add_wording);
|
||||
|
||||
addFriendRemarkLv = findViewById(R.id.friend_remark_lv);
|
||||
addFriendRemarkLv.setOnClickListener(this);
|
||||
addFriendGroupLv = findViewById(R.id.friend_group_lv);
|
||||
addFriendGroupLv.setContent(getContext().getString(R.string.contact_my_friend));
|
||||
|
||||
remarkAndGroupTip = findViewById(R.id.remark_and_group_tip);
|
||||
|
||||
mTitleBar = findViewById(R.id.friend_titlebar);
|
||||
mTitleBar.setTitle(getResources().getString(R.string.profile_detail), ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBar.getRightGroup().setVisibility(View.GONE);
|
||||
mTitleBar.setOnLeftClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupCall() {
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIChat.CHAT_ID, mId);
|
||||
param.put(TUIConstants.TUIChat.CHAT_NAME, mNickname);
|
||||
param.put(TUIConstants.TUIChat.CHAT_TYPE, ChatInfo.TYPE_C2C);
|
||||
param.put(TUIConstants.TUIChat.CONTEXT, getContext());
|
||||
Map<String, Object> videoCallExtension = TUICore.getExtensionInfo(TUIConstants.TUIChat.EXTENSION_INPUT_MORE_VIDEO_CALL, param);
|
||||
if (videoCallExtension == null) {
|
||||
videoCallBtn.setVisibility(GONE);
|
||||
}
|
||||
|
||||
Map<String, Object> audioCallExtension = TUICore.getExtensionInfo(TUIConstants.TUIChat.EXTENSION_INPUT_MORE_AUDIO_CALL, param);
|
||||
if (audioCallExtension == null) {
|
||||
audioCallBtn.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
mChatTopView.setCheckListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
|
||||
if (presenter != null) {
|
||||
presenter.setConversationTop(mId, isChecked);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mAddBlackView.setCheckListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
addBlack();
|
||||
} else {
|
||||
deleteBlack();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
refuseFriendBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
refuse();
|
||||
}
|
||||
});
|
||||
|
||||
acceptFriendBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
accept();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initData(Object data) {
|
||||
initEvent();
|
||||
|
||||
if (data instanceof String) {
|
||||
mId = (String) data;
|
||||
loadUserProfile(mId);
|
||||
} else if (data instanceof ContactItemBean) {
|
||||
setViewContentFromItemBean((ContactItemBean) data);
|
||||
} else if (data instanceof FriendApplicationBean) {
|
||||
setViewContentFromFriendApplicationBean((FriendApplicationBean) data);
|
||||
} else if (data instanceof ContactGroupApplyInfo) {
|
||||
setViewContentFromContactGroupApplyInfo((ContactGroupApplyInfo) data);
|
||||
} else if (data instanceof GroupInfo) {
|
||||
setViewContentFromGroupInfo((GroupInfo) data);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mNickname)) {
|
||||
mNickNameView.setText(mNickname);
|
||||
} else {
|
||||
mNickNameView.setText(mId);
|
||||
}
|
||||
mIDView.setText(mId);
|
||||
|
||||
setupCall();
|
||||
}
|
||||
|
||||
private void setViewContentFromContactGroupApplyInfo(ContactGroupApplyInfo data) {
|
||||
final ContactGroupApplyInfo info = data;
|
||||
mId = info.getFromUser();
|
||||
mNickname = info.getFromUserNickName();
|
||||
mRemarkView.setVisibility(GONE);
|
||||
mAddBlackView.setVisibility(GONE);
|
||||
mMessageOptionView.setVisibility(GONE);
|
||||
mChatBackground.setVisibility(GONE);
|
||||
deleteFriendBtn.setText(R.string.refuse);
|
||||
deleteFriendBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
refuseJoinGroupApply(info);
|
||||
}
|
||||
});
|
||||
chatBtn.setText(R.string.accept);
|
||||
chatBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
acceptJoinGroupApply(info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setViewContentFromGroupInfo(GroupInfo groupInfo) {
|
||||
mTitleBar.setTitle(getResources().getString(R.string.add_group), ITitleBarLayout.Position.MIDDLE);
|
||||
isGroup = true;
|
||||
mId = groupInfo.getId();
|
||||
mNickname = groupInfo.getGroupName();
|
||||
mSignatureTagView.setText(getResources().getString(R.string.contact_group_type_tag));
|
||||
mSignatureView.setText(groupInfo.getGroupType());
|
||||
int radius = ScreenUtil.dip2px(24);
|
||||
mHeadImageView.setRadius(radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, groupInfo.getFaceUrl(), TUIUtil.getDefaultGroupIconResIDByGroupType(getContext(), groupInfo.getGroupType()), radius);
|
||||
addFriendSendBtn.setVisibility(VISIBLE);
|
||||
addFriendArea.setVisibility(VISIBLE);
|
||||
remarkAndGroupTip.setVisibility(GONE);
|
||||
addFriendRemarkLv.setVisibility(GONE);
|
||||
addFriendGroupLv.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void setViewContentFromFriendApplicationBean(FriendApplicationBean data) {
|
||||
friendApplicationBean = data;
|
||||
mId = friendApplicationBean.getUserId();
|
||||
mNickname = friendApplicationBean.getNickName();
|
||||
mSignatureTagView.setVisibility(GONE);
|
||||
mSignatureView.setVisibility(GONE);
|
||||
mRemarkView.setVisibility(GONE);
|
||||
mAddBlackView.setVisibility(GONE);
|
||||
mMessageOptionView.setVisibility(GONE);
|
||||
mChatBackground.setVisibility(GONE);
|
||||
|
||||
friendApplicationVerifyArea.setVisibility(VISIBLE);
|
||||
friendApplicationAddWording.setText(friendApplicationBean.getAddWording());
|
||||
|
||||
refuseFriendBtn.setVisibility(VISIBLE);
|
||||
acceptFriendBtn.setVisibility(VISIBLE);
|
||||
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, friendApplicationBean.getFaceUrl(), radius);
|
||||
}
|
||||
|
||||
private void setViewContentFromItemBean(ContactItemBean data) {
|
||||
mContactInfo = data;
|
||||
isFriend = mContactInfo.isFriend();
|
||||
mId = mContactInfo.getId();
|
||||
mNickname = mContactInfo.getNickName();
|
||||
mSignatureView.setText(mContactInfo.getSignature());
|
||||
if (TextUtils.isEmpty(mContactInfo.getSignature())) {
|
||||
mSignatureTagView.setText(getResources().getString(R.string.contact_no_status));
|
||||
} else {
|
||||
mSignatureTagView.setText(getResources().getString(R.string.contact_signature_tag));
|
||||
}
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, mContactInfo.getAvatarUrl(), radius);
|
||||
mChatTopView.setChecked(presenter.isTopConversation(mId));
|
||||
mAddBlackView.setChecked(mContactInfo.isBlackList());
|
||||
mRemarkView.setContent(mContactInfo.getRemark());
|
||||
|
||||
if (TextUtils.equals(mContactInfo.getId(), TUILogin.getLoginUser())) {
|
||||
if (isFriend) {
|
||||
mRemarkView.setVisibility(VISIBLE);
|
||||
chatBtn.setVisibility(VISIBLE);
|
||||
audioCallBtn.setVisibility(VISIBLE);
|
||||
videoCallBtn.setVisibility(VISIBLE);
|
||||
deleteFriendBtn.setVisibility(VISIBLE);
|
||||
mAddBlackView.setVisibility(VISIBLE);
|
||||
mChatTopView.setVisibility(View.VISIBLE);
|
||||
mChatBackground.setVisibility(VISIBLE);
|
||||
updateMessageOptionView();
|
||||
} else {
|
||||
// DO NOTHING
|
||||
}
|
||||
} else {
|
||||
if (mContactInfo.isBlackList()) {
|
||||
deleteFriendBtn.setVisibility(VISIBLE);
|
||||
chatBtn.setVisibility(VISIBLE);
|
||||
audioCallBtn.setVisibility(VISIBLE);
|
||||
videoCallBtn.setVisibility(VISIBLE);
|
||||
mRemarkView.setVisibility(VISIBLE);
|
||||
mAddBlackView.setVisibility(VISIBLE);
|
||||
mMessageOptionView.setVisibility(VISIBLE);
|
||||
mChatTopView.setVisibility(VISIBLE);
|
||||
mChatBackground.setVisibility(VISIBLE);
|
||||
} else {
|
||||
if (!isFriend) {
|
||||
if (isGroup) {
|
||||
addFriendRemarkLv.setVisibility(GONE);
|
||||
addFriendGroupLv.setVisibility(GONE);
|
||||
}
|
||||
mTitleBar.setTitle(getResources().getString(R.string.add_friend), ITitleBarLayout.Position.MIDDLE);
|
||||
addFriendSendBtn.setVisibility(VISIBLE);
|
||||
addFriendArea.setVisibility(VISIBLE);
|
||||
} else {
|
||||
mRemarkView.setVisibility(VISIBLE);
|
||||
chatBtn.setVisibility(VISIBLE);
|
||||
audioCallBtn.setVisibility(VISIBLE);
|
||||
videoCallBtn.setVisibility(VISIBLE);
|
||||
deleteFriendBtn.setVisibility(VISIBLE);
|
||||
mAddBlackView.setVisibility(VISIBLE);
|
||||
mChatTopView.setVisibility(View.VISIBLE);
|
||||
mChatBackground.setVisibility(VISIBLE);
|
||||
updateMessageOptionView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateMessageOptionView() {
|
||||
mMessageOptionView.setVisibility(VISIBLE);
|
||||
//get
|
||||
final ArrayList<String> userIdList = new ArrayList<>();
|
||||
userIdList.add(mId);
|
||||
|
||||
presenter.getC2CReceiveMessageOpt(userIdList, new IUIKitCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
mMessageOptionView.setChecked(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
mMessageOptionView.setChecked(false);
|
||||
}
|
||||
});
|
||||
|
||||
//set
|
||||
mMessageOptionView.setCheckListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
presenter.setC2CReceiveMessageOpt(userIdList, isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSourceChanged(ContactItemBean bean) {
|
||||
setViewContentFromItemBean(bean);
|
||||
setupCall();
|
||||
if (bean.isFriend()) {
|
||||
updateMessageOptionView();
|
||||
clearMessageBtn.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mNickname)) {
|
||||
mNickNameView.setText(mNickname);
|
||||
} else {
|
||||
mNickNameView.setText(mId);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(bean.getAvatarUrl())) {
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mHeadImageView, bean.getAvatarUrl(), radius);
|
||||
}
|
||||
mIDView.setText(mId);
|
||||
}
|
||||
|
||||
private void loadUserProfile(String id) {
|
||||
final ContactItemBean bean = new ContactItemBean();
|
||||
presenter.getUsersInfo(id, bean);
|
||||
}
|
||||
|
||||
private void accept() {
|
||||
presenter.acceptFriendApplication(friendApplicationBean, FriendApplicationBean.FRIEND_ACCEPT_AGREE_AND_ADD, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
chatBtn.setText(R.string.accepted);
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("accept Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refuse() {
|
||||
presenter.refuseFriendApplication(friendApplicationBean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
deleteFriendBtn.setText(R.string.refused);
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("refuse Error code = " + errCode + ", desc = " + errMsg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void acceptJoinGroupApply(final ContactGroupApplyInfo item) {
|
||||
presenter.acceptJoinGroupApply(item, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastLongMessage(errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refuseJoinGroupApply(final ContactGroupApplyInfo item) {
|
||||
presenter.refuseJoinGroupApply(item, "", new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastLongMessage(errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void delete() {
|
||||
List<String> identifiers = new ArrayList<>();
|
||||
identifiers.add(mId);
|
||||
|
||||
presenter.deleteFriend(identifiers, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
if (mListener != null) {
|
||||
mListener.onDeleteFriendClick(mId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("deleteFriend Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void chat() {
|
||||
if (mListener != null || mContactInfo != null) {
|
||||
mListener.onStartConversationClick(mContactInfo);
|
||||
}
|
||||
((Activity) getContext()).finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == chatBtn) {
|
||||
chat();
|
||||
} else if (v == deleteFriendBtn) {
|
||||
delete();
|
||||
}else if (v == clearMessageBtn) {
|
||||
new TUIKitDialog(getContext())
|
||||
.builder()
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(getContext().getString(R.string.clear_msg_tip))
|
||||
.setDialogWidth(0.75f)
|
||||
.setPositiveButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.sure), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Map<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put(TUIConstants.TUIContact.FRIEND_ID, mId);
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_USER,
|
||||
TUIConstants.TUIContact.EVENT_SUB_KEY_CLEAR_MESSAGE, hashMap);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.cancel), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
})
|
||||
.show();
|
||||
} else if (v == videoCallBtn) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_USERIDS, new String[]{mId});
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_TYPE, TUIConstants.TUICalling.TYPE_VIDEO);
|
||||
TUICore.callService(TUIConstants.TUICalling.SERVICE_NAME, TUIConstants.TUICalling.METHOD_NAME_CALL, map);
|
||||
} else if (v == audioCallBtn) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_USERIDS, new String[]{mId});
|
||||
map.put(TUIConstants.TUICalling.PARAM_NAME_TYPE, TUIConstants.TUICalling.TYPE_AUDIO);
|
||||
TUICore.callService(TUIConstants.TUICalling.SERVICE_NAME, TUIConstants.TUICalling.METHOD_NAME_CALL, map);
|
||||
} else if (v == addFriendSendBtn) {
|
||||
String addWording = addWordingEditText.getText().toString();
|
||||
String friendGroup = "";
|
||||
String remark = addFriendRemarkLv.getContent();
|
||||
|
||||
if (isGroup) {
|
||||
presenter.joinGroup(mId, addWording, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ToastUtil.toastShortMessage(getContext().getString(R.string.success));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(getContext().getString(R.string.contact_add_failed) + " " + errMsg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
presenter.addFriend(mId, addWording, friendGroup, remark, new IUIKitCallback<Pair<Integer, String>>() {
|
||||
@Override
|
||||
public void onSuccess(Pair<Integer, String> data) {
|
||||
ToastUtil.toastShortMessage(data.second);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(getContext().getString(R.string.contact_add_failed));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (v == addFriendRemarkLv) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard((Activity) getContext());
|
||||
popupInputCard.setContent(addFriendRemarkLv.getContent());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.contact_friend_remark));
|
||||
popupInputCard.setOnPositive((result -> {
|
||||
addFriendRemarkLv.setContent(result);
|
||||
if (TextUtils.isEmpty(result)) {
|
||||
result = "";
|
||||
}
|
||||
modifyRemark(result);
|
||||
}));
|
||||
popupInputCard.show(addFriendRemarkLv, Gravity.BOTTOM);
|
||||
} else if (v == mRemarkView) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard((Activity) getContext());
|
||||
popupInputCard.setContent(mRemarkView.getContent());
|
||||
popupInputCard.setTitle(getResources().getString(R.string.profile_remark_edit));
|
||||
String description = getResources().getString(R.string.contact_modify_remark_rule);
|
||||
popupInputCard.setRule("^[a-zA-Z0-9_\u4e00-\u9fa5]*$");
|
||||
popupInputCard.setDescription(description);
|
||||
popupInputCard.setOnPositive((result -> {
|
||||
mRemarkView.setContent(result);
|
||||
if (TextUtils.isEmpty(result)) {
|
||||
result = "";
|
||||
}
|
||||
modifyRemark(result);
|
||||
}));
|
||||
popupInputCard.show(mRemarkView, Gravity.BOTTOM);
|
||||
|
||||
} else if (v == mChatBackground) {
|
||||
if (mListener != null) {
|
||||
mListener.onSetChatBackground();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void modifyRemark(final String txt) {
|
||||
presenter.modifyRemark(mId, txt, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
mContactInfo.setRemark(txt);
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIContact.FRIEND_ID, mId);
|
||||
param.put(TUIConstants.TUIContact.FRIEND_REMARK, txt);
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_FRIEND_INFO_CHANGED, TUIConstants.TUIContact.EVENT_SUB_KEY_FRIEND_REMARK_CHANGED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBlack() {
|
||||
String[] idStringList = mId.split(",");
|
||||
List<String> idList = new ArrayList<>(Arrays.asList(idStringList));
|
||||
presenter.addToBlackList(idList);
|
||||
}
|
||||
|
||||
private void deleteBlack() {
|
||||
String[] idStringList = mId.split(",");
|
||||
List<String> idList = new ArrayList<>(Arrays.asList(idStringList));
|
||||
presenter.deleteFromBlackList(idList);
|
||||
}
|
||||
|
||||
public void setOnButtonClickListener(OnButtonClickListener l) {
|
||||
mListener = l;
|
||||
}
|
||||
|
||||
public interface OnButtonClickListener {
|
||||
void onStartConversationClick(ContactItemBean info);
|
||||
|
||||
void onDeleteFriendClick(String id);
|
||||
|
||||
default void onSetChatBackground() {};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.qcloud.tuicore.R;
|
||||
import com.tencent.qcloud.tuicore.component.action.PopMenuAction;
|
||||
import com.tencent.qcloud.tuicore.component.action.PopMenuAdapter;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Menu {
|
||||
|
||||
private static final int SHADOW_WIDTH = 10;
|
||||
private static final int Y_OFFSET = 4;
|
||||
|
||||
private ListView mMenuList;
|
||||
private PopMenuAdapter mMenuAdapter;
|
||||
private PopupWindow mMenuWindow;
|
||||
private List<PopMenuAction> mActions = new ArrayList<>();
|
||||
private Activity mActivity;
|
||||
private View mAttachView;
|
||||
|
||||
public Menu(Activity activity, View attach) {
|
||||
mActivity = activity;
|
||||
mAttachView = attach;
|
||||
}
|
||||
|
||||
public void setMenuAction(List<PopMenuAction> menuActions) {
|
||||
mActions.clear();
|
||||
mActions.addAll(menuActions);
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
if (mMenuWindow == null) {
|
||||
return false;
|
||||
}
|
||||
return mMenuWindow.isShowing();
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
mMenuWindow.dismiss();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
if (mActions == null || mActions.size() == 0) {
|
||||
return;
|
||||
}
|
||||
mMenuWindow = new PopupWindow(mActivity);
|
||||
mMenuWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mMenuWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mMenuWindow.setBackgroundDrawable(new ColorDrawable());
|
||||
|
||||
mMenuAdapter = new PopMenuAdapter();
|
||||
mMenuAdapter.setDataSource(mActions);
|
||||
View menuView = LayoutInflater.from(mActivity).inflate(R.layout.core_pop_menu, null);
|
||||
|
||||
menuView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
mMenuWindow.setContentView(menuView);
|
||||
mMenuList = menuView.findViewById(R.id.menu_pop_list);
|
||||
mMenuList.setAdapter(mMenuAdapter);
|
||||
mMenuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
PopMenuAction action = (PopMenuAction) mMenuAdapter.getItem(position);
|
||||
if (action != null && action.getActionClickListener() != null) {
|
||||
action.getActionClickListener().onActionClick(position, mActions.get(position));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int paddingLeftRight = ScreenUtil.dip2px(15.0f);
|
||||
int paddingTopBottom = ScreenUtil.dip2px(12.0f);
|
||||
|
||||
int itemWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.core_pop_menu_item_width);
|
||||
int itemHeight = mActivity.getResources().getDimensionPixelSize(R.dimen.core_pop_menu_item_height);
|
||||
float anchorWidth = mAttachView.getWidth();
|
||||
float anchorHeight = mAttachView.getHeight();
|
||||
|
||||
mMenuWindow.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
int[] location = new int[2];
|
||||
mAttachView.getLocationOnScreen(location);
|
||||
int rowCount = mActions.size();
|
||||
int indicatorHeight = mActivity.getResources().getDimensionPixelOffset(R.dimen.core_pop_menu_indicator_height);
|
||||
|
||||
int popWidth = itemWidth + paddingLeftRight * 2 - SHADOW_WIDTH;
|
||||
int popHeight = itemHeight * rowCount + paddingTopBottom * 2 - SHADOW_WIDTH;
|
||||
|
||||
float indicatorX = anchorWidth / 2;
|
||||
int screenWidth = ScreenUtil.getScreenWidth(mActivity);
|
||||
int x = location[0];
|
||||
int y;
|
||||
float xOffset = anchorWidth / 2;
|
||||
// If it is on the right, the x-coordinate of the small arrow and the x-position of the pop-up window will change
|
||||
if (location[0] * 2 + anchorWidth > screenWidth) {
|
||||
indicatorX = popWidth - anchorWidth / 2 - xOffset;
|
||||
x = (int) (location[0] + anchorWidth - popWidth + xOffset);
|
||||
}
|
||||
|
||||
y = (int) (location[1] + anchorHeight) + Y_OFFSET;
|
||||
popHeight = popHeight - indicatorHeight;
|
||||
|
||||
Drawable backgroundDrawable = getBackgroundDrawable(popWidth, popHeight, indicatorX, indicatorHeight, 16);
|
||||
menuView.setBackground(backgroundDrawable);
|
||||
|
||||
mMenuWindow.setFocusable(true);
|
||||
mMenuWindow.setTouchable(true);
|
||||
mMenuWindow.setOutsideTouchable(true);
|
||||
mMenuWindow.showAtLocation(mAttachView, Gravity.NO_GRAVITY, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a popup background with small triangles
|
||||
*/
|
||||
public Drawable getBackgroundDrawable(final float widthPixel, final float heightPixel, float indicatorX, float indicatorHeight, float radius) {
|
||||
int borderWidth = SHADOW_WIDTH;
|
||||
|
||||
Path path = new Path();
|
||||
Drawable drawable = new Drawable() {
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(Color.WHITE);
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
paint.setShadowLayer(borderWidth, 0,0,0xFFAAAAAA);
|
||||
path.addRoundRect(new RectF(borderWidth, indicatorHeight + borderWidth, widthPixel - borderWidth, heightPixel + indicatorHeight - borderWidth), radius, radius, Path.Direction.CW);
|
||||
path.moveTo(indicatorX - indicatorHeight, indicatorHeight + borderWidth);
|
||||
path.lineTo(indicatorX, borderWidth);
|
||||
path.lineTo(indicatorX + indicatorHeight, indicatorHeight + borderWidth);
|
||||
path.close();
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
};
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.component.imageEngine.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.presenter.NewFriendPresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NewFriendListAdapter extends ArrayAdapter<FriendApplicationBean> {
|
||||
|
||||
private static final String TAG = NewFriendListAdapter.class.getSimpleName();
|
||||
|
||||
private int mResourceId;
|
||||
private View mView;
|
||||
private ViewHolder mViewHolder;
|
||||
|
||||
private NewFriendPresenter presenter;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param context The current context.
|
||||
* @param resource The resource ID for a layout ic_chat_input_file containing a TextView to use when
|
||||
* instantiating views.
|
||||
* @param objects The objects to represent in the ListView.
|
||||
*/
|
||||
public NewFriendListAdapter(Context context, int resource, List<FriendApplicationBean> objects) {
|
||||
super(context, resource, objects);
|
||||
mResourceId = resource;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final FriendApplicationBean data = getItem(position);
|
||||
if (convertView != null) {
|
||||
mView = convertView;
|
||||
mViewHolder = (ViewHolder) mView.getTag();
|
||||
} else {
|
||||
mView = LayoutInflater.from(getContext()).inflate(mResourceId, null);
|
||||
mView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(TUIContactConstants.ProfileType.CONTENT, data);
|
||||
TUICore.startActivity("FriendProfileMinimalistActivity", bundle);
|
||||
}
|
||||
});
|
||||
mViewHolder = new ViewHolder();
|
||||
mViewHolder.avatar = mView.findViewById(R.id.avatar);
|
||||
mViewHolder.name = mView.findViewById(R.id.name);
|
||||
mViewHolder.des = mView.findViewById(R.id.description);
|
||||
mViewHolder.agree = mView.findViewById(R.id.agree);
|
||||
mViewHolder.reject = mView.findViewById(R.id.reject);
|
||||
mViewHolder.result = mView.findViewById(R.id.result_tv);
|
||||
mView.setTag(mViewHolder);
|
||||
}
|
||||
Resources res = getContext().getResources();
|
||||
int radius = mView.getResources().getDimensionPixelSize(R.dimen.contact_profile_face_radius);
|
||||
GlideEngine.loadUserIcon(mViewHolder.avatar, data.getFaceUrl(), radius);
|
||||
mViewHolder.name.setText(TextUtils.isEmpty(data.getNickName()) ? data.getUserId() : data.getNickName());
|
||||
mViewHolder.des.setText(data.getAddWording());
|
||||
switch (data.getAddType()) {
|
||||
case FriendApplicationBean.FRIEND_APPLICATION_COME_IN:
|
||||
mViewHolder.agree.setText(res.getString(R.string.request_agree));
|
||||
mViewHolder.agree.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
doResponse(data, true);
|
||||
}
|
||||
});
|
||||
mViewHolder.reject.setText(res.getString(R.string.refuse));
|
||||
mViewHolder.reject.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
doResponse(data, false);
|
||||
}
|
||||
});
|
||||
if (data.isAccept()) {
|
||||
mViewHolder.agree.setVisibility(View.GONE);
|
||||
mViewHolder.reject.setVisibility(View.GONE);
|
||||
mViewHolder.result.setVisibility(View.VISIBLE);
|
||||
}
|
||||
break;
|
||||
case FriendApplicationBean.FRIEND_APPLICATION_BOTH:
|
||||
mViewHolder.agree.setText(res.getString(R.string.request_accepted));
|
||||
break;
|
||||
}
|
||||
return mView;
|
||||
}
|
||||
|
||||
private void doResponse(FriendApplicationBean bean, boolean isAccept) {
|
||||
if (presenter != null) {
|
||||
if (isAccept) {
|
||||
presenter.acceptFriendApplication(bean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
bean.setAccept(true);
|
||||
refreshList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
presenter.refuseFriendApplication(bean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshList() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setPresenter(NewFriendPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
public class ViewHolder {
|
||||
ImageView avatar;
|
||||
TextView name;
|
||||
TextView des;
|
||||
TextView agree;
|
||||
TextView reject;
|
||||
TextView result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,660 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.model;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMCreateGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendAddApplication;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendApplication;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendApplicationResult;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMFriendOperationResult;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupApplication;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMReceiveMessageOptInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMSendCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
import com.tencent.qcloud.tuicore.BuildConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ErrorMessageConverter;
|
||||
import com.tencent.qcloud.tuicore.util.ThreadHelper;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactGroupApplyInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupMemberInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.config.TUIContactConfig;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ContactProvider {
|
||||
private static final String TAG = ContactProvider.class.getSimpleName();
|
||||
private long mNextSeq = 0;
|
||||
|
||||
public void loadFriendListDataAsync(IUIKitCallback<List<ContactItemBean>> callback) {
|
||||
TUIContactLog.i(TAG, "loadFriendListDataAsync");
|
||||
ThreadHelper.INST.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 压测时数据量比较大,query耗时比较久,所以这里使用新线程来处理
|
||||
// The amount of data during the stress test is relatively large, and the query takes a long time, so a new thread is used here to process
|
||||
V2TIMManager.getFriendshipManager().getFriendList(new V2TIMValueCallback<List<V2TIMFriendInfo>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "loadFriendListDataAsync err code:" + code + ", desc:" + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendInfo> v2TIMFriendInfos) {
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
TUIContactLog.i(TAG, "loadFriendListDataAsync->getFriendList:" + v2TIMFriendInfos.size());
|
||||
for (V2TIMFriendInfo timFriendInfo : v2TIMFriendInfos) {
|
||||
ContactItemBean info = new ContactItemBean();
|
||||
info.setFriend(true);
|
||||
info.covertTIMFriend(timFriendInfo);
|
||||
contactItemBeanList.add(info);
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, contactItemBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void loadBlackListData(IUIKitCallback<List<ContactItemBean>> callback) {
|
||||
TUIContactLog.i(TAG, "loadBlackListData");
|
||||
|
||||
V2TIMManager.getFriendshipManager().getBlackList(new V2TIMValueCallback<List<V2TIMFriendInfo>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getBlackList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendInfo> v2TIMFriendInfos) {
|
||||
TUIContactLog.i(TAG, "getBlackList success: " + v2TIMFriendInfos.size());
|
||||
if (v2TIMFriendInfos.size() == 0) {
|
||||
TUIContactLog.i(TAG, "getBlackList success but no data");
|
||||
}
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
for (V2TIMFriendInfo timFriendInfo : v2TIMFriendInfos) {
|
||||
ContactItemBean info = new ContactItemBean();
|
||||
info.covertTIMFriend(timFriendInfo).setBlackList(true);
|
||||
contactItemBeanList.add(info);
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, contactItemBeanList);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void loadGroupListData(IUIKitCallback<List<ContactItemBean>> callback) {
|
||||
TUIContactLog.i(TAG, "loadGroupListData");
|
||||
V2TIMManager.getGroupManager().getJoinedGroupList(new V2TIMValueCallback<List<V2TIMGroupInfo>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getGroupList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfo> v2TIMGroupInfos) {
|
||||
TUIContactLog.i(TAG, "getGroupList success: " + v2TIMGroupInfos.size());
|
||||
if (v2TIMGroupInfos.size() == 0) {
|
||||
TUIContactLog.i(TAG, "getGroupList success but no data");
|
||||
}
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
|
||||
for (V2TIMGroupInfo info : v2TIMGroupInfos) {
|
||||
ContactItemBean bean = new ContactItemBean();
|
||||
contactItemBeanList.add(bean.covertTIMGroupBaseInfo(info));
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, contactItemBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public long getNextSeq() {
|
||||
return mNextSeq;
|
||||
}
|
||||
|
||||
public void setNextSeq(long nextSeq) {
|
||||
this.mNextSeq = nextSeq;
|
||||
}
|
||||
|
||||
public void loadGroupMembers(String groupId, IUIKitCallback<List<ContactItemBean>> callback) {
|
||||
V2TIMManager.getGroupManager().getGroupMemberList(groupId, V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_ALL, mNextSeq, new V2TIMValueCallback<V2TIMGroupMemberInfoResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
TUIContactLog.e(TAG, "loadGroupMembers failed, code: " + code + "|desc: " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMGroupMemberInfoResult v2TIMGroupMemberInfoResult) {
|
||||
List<V2TIMGroupMemberFullInfo> members = new ArrayList<>();
|
||||
for (int i = 0; i < v2TIMGroupMemberInfoResult.getMemberInfoList().size(); i++) {
|
||||
if (v2TIMGroupMemberInfoResult.getMemberInfoList().get(i).getUserID().equals(V2TIMManager.getInstance().getLoginUser())) {
|
||||
continue;
|
||||
}
|
||||
members.add(v2TIMGroupMemberInfoResult.getMemberInfoList().get(i));
|
||||
}
|
||||
|
||||
mNextSeq = v2TIMGroupMemberInfoResult.getNextSeq();
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
for (V2TIMGroupMemberFullInfo info : members) {
|
||||
ContactItemBean bean = new ContactItemBean();
|
||||
contactItemBeanList.add(bean.covertTIMGroupMemberFullInfo(info));
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, contactItemBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addFriend(String userId, String addWording, IUIKitCallback<Pair<Integer, String>> callback) {
|
||||
addFriend(userId, addWording, null, null, callback);
|
||||
}
|
||||
|
||||
public void addFriend(String userId, String addWording, String friendGroup, String remark, IUIKitCallback<Pair<Integer, String>> callback) {
|
||||
V2TIMFriendAddApplication v2TIMFriendAddApplication = new V2TIMFriendAddApplication(userId);
|
||||
v2TIMFriendAddApplication.setAddWording(addWording);
|
||||
v2TIMFriendAddApplication.setAddSource("android");
|
||||
v2TIMFriendAddApplication.setFriendGroup(friendGroup);
|
||||
v2TIMFriendAddApplication.setFriendRemark(remark);
|
||||
V2TIMManager.getFriendshipManager().addFriend(v2TIMFriendAddApplication, new V2TIMValueCallback<V2TIMFriendOperationResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "addFriend err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMFriendOperationResult v2TIMFriendOperationResult) {
|
||||
TUIContactLog.i(TAG, "addFriend success");
|
||||
ContactUtils.callbackOnSuccess(callback, new Pair<>(v2TIMFriendOperationResult.getResultCode(), v2TIMFriendOperationResult.getResultInfo()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinGroup(String groupId, String addWording, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getInstance().joinGroup(groupId, addWording, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "addGroup err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
TUIContactLog.i(TAG, "addGroup success");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadFriendApplicationList(IUIKitCallback<List<FriendApplicationBean>> callback) {
|
||||
V2TIMManager.getFriendshipManager().getFriendApplicationList(new V2TIMValueCallback<V2TIMFriendApplicationResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getPendencyList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMFriendApplicationResult v2TIMFriendApplicationResult) {
|
||||
List<FriendApplicationBean> applicationBeanList = new ArrayList<>();
|
||||
for (V2TIMFriendApplication application : v2TIMFriendApplicationResult.getFriendApplicationList()) {
|
||||
FriendApplicationBean bean = new FriendApplicationBean();
|
||||
bean.convertFromTimFriendApplication(application);
|
||||
applicationBeanList.add(bean);
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, applicationBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getFriendApplicationListUnreadCount(IUIKitCallback<Integer> callback) {
|
||||
V2TIMManager.getFriendshipManager().getFriendApplicationList(new V2TIMValueCallback<V2TIMFriendApplicationResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getPendencyList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMFriendApplicationResult v2TIMFriendApplicationResult) {
|
||||
ContactUtils.callbackOnSuccess(callback, v2TIMFriendApplicationResult.getUnreadCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void acceptFriendApplication(V2TIMFriendApplication friendApplication, int responseType, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getFriendshipManager().acceptFriendApplication(
|
||||
friendApplication, responseType, new V2TIMValueCallback<V2TIMFriendOperationResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "acceptFriend err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMFriendOperationResult v2TIMFriendOperationResult) {
|
||||
TUIContactLog.i(TAG, "acceptFriend success");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void acceptFriendApplication(FriendApplicationBean bean, int responseType, IUIKitCallback<Void> callback) {
|
||||
V2TIMFriendApplication friendApplication = bean.getFriendApplication();
|
||||
acceptFriendApplication(friendApplication, responseType, callback);
|
||||
|
||||
}
|
||||
|
||||
public void getC2CReceiveMessageOpt(List<String> userIdList, IUIKitCallback<Boolean> callback) {
|
||||
V2TIMManager.getMessageManager().getC2CReceiveMessageOpt(userIdList, new V2TIMValueCallback<List<V2TIMReceiveMessageOptInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMReceiveMessageOptInfo> V2TIMReceiveMessageOptInfos) {
|
||||
if (V2TIMReceiveMessageOptInfos == null || V2TIMReceiveMessageOptInfos.isEmpty()) {
|
||||
TUIContactLog.d(TAG, "getC2CReceiveMessageOpt null");
|
||||
ContactUtils.callbackOnError(callback, TAG, -1, "getC2CReceiveMessageOpt null");
|
||||
return;
|
||||
}
|
||||
V2TIMReceiveMessageOptInfo V2TIMReceiveMessageOptInfo = V2TIMReceiveMessageOptInfos.get(0);
|
||||
int option = V2TIMReceiveMessageOptInfo.getC2CReceiveMessageOpt();
|
||||
|
||||
TUIContactLog.d(TAG, "getC2CReceiveMessageOpt option = " + option);
|
||||
ContactUtils.callbackOnSuccess(callback, option == V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.d(TAG, "getC2CReceiveMessageOpt onError code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setC2CReceiveMessageOpt(List<String> userIdList, boolean isReceiveMessage, IUIKitCallback<Void> callback) {
|
||||
int option;
|
||||
if (isReceiveMessage) {
|
||||
option = V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE;
|
||||
} else {
|
||||
option = V2TIMMessage.V2TIM_RECEIVE_MESSAGE;
|
||||
}
|
||||
V2TIMManager.getMessageManager().setC2CReceiveMessageOpt(userIdList, option, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
TUIContactLog.d(TAG, "setC2CReceiveMessageOpt onSuccess");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.d(TAG, "setC2CReceiveMessageOpt onError code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getGroupInfo(List<String> groupIds, IUIKitCallback<List<GroupInfo>> callback) {
|
||||
V2TIMManager.getGroupManager().getGroupsInfo(groupIds, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
|
||||
List<GroupInfo> groupInfos = new ArrayList<>();
|
||||
for (V2TIMGroupInfoResult result : v2TIMGroupInfoResults) {
|
||||
if (result.getResultCode() != 0) {
|
||||
ContactUtils.callbackOnError(callback, result.getResultCode(), result.getResultMessage());
|
||||
return;
|
||||
}
|
||||
GroupInfo groupInfo = new GroupInfo();
|
||||
groupInfo.setId(result.getGroupInfo().getGroupID());
|
||||
groupInfo.setFaceUrl(result.getGroupInfo().getFaceUrl());
|
||||
groupInfo.setGroupName(result.getGroupInfo().getGroupName());
|
||||
groupInfo.setMemberCount(result.getGroupInfo().getMemberCount());
|
||||
groupInfo.setGroupType(result.getGroupInfo().getGroupType());
|
||||
groupInfos.add(groupInfo);
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, groupInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
ContactUtils.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getUserInfo(List<String> userIdList, IUIKitCallback<List<ContactItemBean>> callback) {
|
||||
V2TIMManager.getInstance().getUsersInfo(userIdList, new V2TIMValueCallback<List<V2TIMUserFullInfo>>() {
|
||||
@Override
|
||||
public void onError ( int code, String desc){
|
||||
TUIContactLog.e(TAG, "loadUserProfile err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess (List<V2TIMUserFullInfo > v2TIMUserFullInfos) {
|
||||
List<ContactItemBean> contactItemBeanList = new ArrayList<>();
|
||||
for(V2TIMUserFullInfo userFullInfo : v2TIMUserFullInfos) {
|
||||
ContactItemBean contactItemBean = new ContactItemBean();
|
||||
contactItemBean.setNickName(userFullInfo.getNickName());
|
||||
contactItemBean.setId(userFullInfo.getUserID());
|
||||
contactItemBean.setAvatarUrl(userFullInfo.getFaceUrl());
|
||||
contactItemBean.setSignature(userFullInfo.getSelfSignature());
|
||||
contactItemBeanList.add(contactItemBean);
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, contactItemBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void isInBlackList(String id, IUIKitCallback<Boolean> callback) {
|
||||
V2TIMManager.getFriendshipManager().getBlackList(new V2TIMValueCallback<List<V2TIMFriendInfo>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getBlackList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendInfo> v2TIMFriendInfos) {
|
||||
if (v2TIMFriendInfos != null && v2TIMFriendInfos.size() > 0) {
|
||||
for (V2TIMFriendInfo friendInfo : v2TIMFriendInfos) {
|
||||
if (TextUtils.equals(friendInfo.getUserID(), id)) {
|
||||
ContactUtils.callbackOnSuccess(callback, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void isFriend(String id, ContactItemBean bean, IUIKitCallback<Boolean> callback) {
|
||||
V2TIMManager.getFriendshipManager().getFriendList(new V2TIMValueCallback<List<V2TIMFriendInfo>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getFriendList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendInfo> v2TIMFriendInfos) {
|
||||
if (v2TIMFriendInfos != null && v2TIMFriendInfos.size() > 0) {
|
||||
for (V2TIMFriendInfo friendInfo : v2TIMFriendInfos) {
|
||||
if (TextUtils.equals(friendInfo.getUserID(), id)) {
|
||||
bean.setFriend(true);
|
||||
bean.setRemark(friendInfo.getFriendRemark());
|
||||
bean.setAvatarUrl(friendInfo.getUserProfile().getFaceUrl());
|
||||
ContactUtils.callbackOnSuccess(callback, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteFromBlackList(List<String> idList, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getFriendshipManager().deleteFromBlackList(idList, new V2TIMValueCallback<List<V2TIMFriendOperationResult>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "deleteBlackList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendOperationResult> v2TIMFriendOperationResults) {
|
||||
TUIContactLog.i(TAG, "deleteBlackList success");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addToBlackList(List<String> idList, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getFriendshipManager().addToBlackList(idList, new V2TIMValueCallback<List<V2TIMFriendOperationResult>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "deleteBlackList err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendOperationResult> v2TIMFriendOperationResults) {
|
||||
TUIContactLog.i(TAG, "deleteBlackList success");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyRemark(String id, String remark, IUIKitCallback<String> callback) {
|
||||
|
||||
V2TIMFriendInfo v2TIMFriendInfo = new V2TIMFriendInfo();
|
||||
v2TIMFriendInfo.setUserID(id);
|
||||
v2TIMFriendInfo.setFriendRemark(remark);
|
||||
|
||||
V2TIMManager.getFriendshipManager().setFriendInfo(v2TIMFriendInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "modifyRemark err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
ContactUtils.callbackOnSuccess(callback, remark);
|
||||
TUIContactLog.i(TAG, "modifyRemark success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteFriend(List<String> identifiers, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getFriendshipManager().deleteFromFriendList(identifiers, V2TIMFriendInfo.V2TIM_FRIEND_TYPE_BOTH, new V2TIMValueCallback<List<V2TIMFriendOperationResult>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "deleteFriends err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMFriendOperationResult> v2TIMFriendOperationResults) {
|
||||
TUIContactLog.i(TAG, "deleteFriends success");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refuseFriendApplication(FriendApplicationBean friendApplication, IUIKitCallback<Void> callback) {
|
||||
V2TIMFriendApplication v2TIMFriendApplication = friendApplication.getFriendApplication();
|
||||
if (v2TIMFriendApplication == null) {
|
||||
ContactUtils.callbackOnError(callback, "refuseFriendApplication", -1, "V2TIMFriendApplication is null");
|
||||
return;
|
||||
}
|
||||
V2TIMManager.getFriendshipManager().refuseFriendApplication(v2TIMFriendApplication, new V2TIMValueCallback<V2TIMFriendOperationResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "accept err code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
ToastUtil.toastShortMessage("Error code = " + code + ", desc = " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMFriendOperationResult v2TIMFriendOperationResult) {
|
||||
TUIContactLog.i(TAG, "refuse success");
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createGroupChat(GroupInfo groupInfo, IUIKitCallback<String> callback) {
|
||||
V2TIMGroupInfo v2TIMGroupInfo = new V2TIMGroupInfo();
|
||||
v2TIMGroupInfo.setGroupType(groupInfo.getGroupType());
|
||||
v2TIMGroupInfo.setGroupName(groupInfo.getGroupName());
|
||||
v2TIMGroupInfo.setGroupAddOpt(groupInfo.getJoinType());
|
||||
v2TIMGroupInfo.setGroupID(groupInfo.getId());
|
||||
v2TIMGroupInfo.setFaceUrl(groupInfo.getFaceUrl());
|
||||
if (TextUtils.equals(v2TIMGroupInfo.getGroupType(), V2TIMManager.GROUP_TYPE_COMMUNITY)) {
|
||||
v2TIMGroupInfo.setSupportTopic(groupInfo.isCommunitySupportTopic());
|
||||
}
|
||||
|
||||
List<V2TIMCreateGroupMemberInfo> v2TIMCreateGroupMemberInfoList = new ArrayList<>();
|
||||
for (int i = 0; i < groupInfo.getMemberDetails().size(); i++) {
|
||||
GroupMemberInfo groupMemberInfo = groupInfo.getMemberDetails().get(i);
|
||||
V2TIMCreateGroupMemberInfo v2TIMCreateGroupMemberInfo = new V2TIMCreateGroupMemberInfo();
|
||||
v2TIMCreateGroupMemberInfo.setUserID(groupMemberInfo.getAccount());
|
||||
v2TIMCreateGroupMemberInfoList.add(v2TIMCreateGroupMemberInfo);
|
||||
}
|
||||
|
||||
V2TIMManager.getGroupManager().createGroup(v2TIMGroupInfo, v2TIMCreateGroupMemberInfoList, new V2TIMValueCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
ContactUtils.callbackOnSuccess(callback, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
ContactUtils.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void sendGroupTipsMessage(String groupId, String message, IUIKitCallback<String> callback) {
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(message.getBytes());
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, groupId,
|
||||
V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.i(TAG, "sendTipsMessage error , code : " + code + " desc : " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
ContactUtils.callbackOnError(callback, TAG, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMMessage v2TIMMessage) {
|
||||
TUIContactLog.i(TAG, "sendTipsMessage onSuccess");
|
||||
ContactUtils.callbackOnSuccess(callback, groupId);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void acceptJoinGroupApply(ContactGroupApplyInfo applyInfo, IUIKitCallback<Void> callback) {
|
||||
V2TIMGroupApplication application = applyInfo.getTimGroupApplication();
|
||||
String reason = applyInfo.getRequestMsg();
|
||||
V2TIMManager.getGroupManager().acceptGroupApplication(application, reason, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
ContactUtils.callbackOnError(callback, code, desc);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refuseJoinGroupApply(ContactGroupApplyInfo info, String reason, IUIKitCallback<Void> callback) {
|
||||
V2TIMGroupApplication application = info.getTimGroupApplication();
|
||||
V2TIMManager.getGroupManager().refuseGroupApplication(application, reason, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
ContactUtils.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setGroupApplicationRead(IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getGroupManager().setGroupApplicationRead(new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
ContactUtils.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadContactUserStatus(List<ContactItemBean> dataSource, IUIKitCallback<Void> callback) {
|
||||
if (dataSource == null || dataSource.size() == 0) {
|
||||
TUIContactLog.d(TAG, "loadContactUserStatus datasource is null");
|
||||
ContactUtils.callbackOnError(callback, -1, "data list is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<String, ContactItemBean> dataSourceMap = new HashMap<>();
|
||||
List<String> userList = new ArrayList<>();
|
||||
for(ContactItemBean itemBean : dataSource) {
|
||||
if (TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.new_friend), itemBean.getId())
|
||||
|| TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.blacklist), itemBean.getId())
|
||||
|| TextUtils.equals(TUIContactService.getAppContext().getResources().getString(R.string.group), itemBean.getId())) {
|
||||
continue;
|
||||
}
|
||||
userList.add(itemBean.getId());
|
||||
dataSourceMap.put(itemBean.getId(), itemBean);
|
||||
}
|
||||
V2TIMManager.getInstance().getUserStatus(userList, new V2TIMValueCallback<List<V2TIMUserStatus>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMUserStatus> v2TIMUserStatuses) {
|
||||
TUIContactLog.i(TAG, "getUserStatus success");
|
||||
|
||||
for (V2TIMUserStatus item : v2TIMUserStatuses) {
|
||||
ContactItemBean bean = dataSourceMap.get(item.getUserID());
|
||||
if (bean != null) {
|
||||
bean.setStatusType(item.getStatusType());
|
||||
}
|
||||
}
|
||||
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUIContactLog.e(TAG, "getUserStatus error code = " + code + ",des = " + desc);
|
||||
ContactUtils.callbackOnError(callback, code, desc);
|
||||
if (code == TUIConstants.BuyingFeature.ERR_SDK_INTERFACE_NOT_SUPPORT &&
|
||||
TUIContactConfig.getInstance().isShowUserStatus() && BuildConfig.DEBUG) {
|
||||
ToastUtil.toastLongMessage(desc);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IAddMoreActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.model.ContactProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AddMorePresenter {
|
||||
private static final String TAG = AddMorePresenter.class.getSimpleName();
|
||||
|
||||
private ContactProvider provider;
|
||||
|
||||
private IAddMoreActivity addMoreActivity;
|
||||
public AddMorePresenter() {
|
||||
provider = new ContactProvider();
|
||||
}
|
||||
|
||||
public void setAddMoreActivity(IAddMoreActivity addMoreActivity) {
|
||||
this.addMoreActivity = addMoreActivity;
|
||||
}
|
||||
|
||||
public void addFriend(String userId, String addWording) {
|
||||
|
||||
provider.addFriend(userId, addWording, new IUIKitCallback<Pair<Integer, String>>() {
|
||||
@Override
|
||||
public void onSuccess(Pair<Integer, String> data) {
|
||||
switch (data.first) {
|
||||
case FriendApplicationBean.ERR_SUCC:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.success));
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_INVALID_PARAMETERS:
|
||||
if (TextUtils.equals(data.second, "Err_SNS_FriendAdd_Friend_Exist")) {
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.have_be_friend));
|
||||
break;
|
||||
}
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_COUNT_LIMIT:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.friend_limit));
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_PEER_FRIEND_LIMIT:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.other_friend_limit));
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_IN_SELF_BLACKLIST:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.in_blacklist));
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_ALLOW_TYPE_DENY_ANY:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.forbid_add_friend));
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_IN_PEER_BLACKLIST:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.set_in_blacklist));
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_ALLOW_TYPE_NEED_CONFIRM:
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.wait_agree_friend));
|
||||
break;
|
||||
default:
|
||||
ToastUtil.toastLongMessage(data.first + " " + data.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinGroup(String groupId, String addWording) {
|
||||
provider.joinGroup(groupId, addWording, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ToastUtil.toastShortMessage(addMoreActivity.getString(R.string.send_request));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void getUserInfo(String userId, IUIKitCallback<ContactItemBean> callback) {
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
userIdList.add(userId);
|
||||
provider.getUserInfo(userIdList, new IUIKitCallback<List<ContactItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ContactItemBean> data) {
|
||||
ContactUtils.callbackOnSuccess(callback, data.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getGroupInfo(String groupId, IUIKitCallback<GroupInfo> callback) {
|
||||
List<String> groupIds = new ArrayList<>();
|
||||
groupIds.add(groupId);
|
||||
provider.getGroupInfo(groupIds, new IUIKitCallback<List<GroupInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(List<GroupInfo> data) {
|
||||
ContactUtils.callbackOnSuccess(callback, data.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, errCode, errMsg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.imsdk.group.GroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMUserStatus;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.BackgroundTasks;
|
||||
import com.tencent.qcloud.tuicore.util.ThreadHelper;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.MessageCustom;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.config.TUIContactConfig;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.ContactEventListener;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IContactListView;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.model.ContactProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ContactPresenter {
|
||||
private static final String TAG = ContactPresenter.class.getSimpleName();
|
||||
|
||||
private final ContactProvider provider;
|
||||
|
||||
private IContactListView contactListView;
|
||||
|
||||
private final List<ContactItemBean> dataSource = new ArrayList<>();
|
||||
|
||||
// Strong references avoid GC
|
||||
private ContactEventListener friendListListener;
|
||||
private ContactEventListener blackListListener;
|
||||
private IUIKitCallback<Void> getUserStatusCallback;
|
||||
|
||||
private boolean isSelectForCall = false;
|
||||
|
||||
public ContactPresenter() {
|
||||
provider = new ContactProvider();
|
||||
provider.setNextSeq(0);
|
||||
}
|
||||
|
||||
public void setContactListView(IContactListView contactListView) {
|
||||
this.contactListView = contactListView;
|
||||
}
|
||||
|
||||
public void setFriendListListener() {
|
||||
friendListListener = new ContactEventListener() {
|
||||
@Override
|
||||
public void onFriendListAdded(List<ContactItemBean> users) {
|
||||
onDataListAdd(users);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendListDeleted(List<String> userList) {
|
||||
onDataListDeleted(userList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendInfoChanged(List<ContactItemBean> infoList) {
|
||||
ContactPresenter.this.onFriendInfoChanged(infoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendRemarkChanged(String id, String remark) {
|
||||
ContactPresenter.this.onFriendRemarkChanged(id, remark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationListAdded(List<FriendApplicationBean> applicationList) {
|
||||
if (contactListView != null) {
|
||||
contactListView.onFriendApplicationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationListDeleted(List<String> userIDList) {
|
||||
if (contactListView != null) {
|
||||
contactListView.onFriendApplicationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserStatusChanged(List<V2TIMUserStatus> userStatusList) {
|
||||
ContactPresenter.this.onUserStatusChanged(userStatusList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUserStatusFragmentUI() {
|
||||
ContactPresenter.this.notifyDataSourceChanged();
|
||||
}
|
||||
};
|
||||
TUIContactService.getInstance().addContactEventListener(friendListListener);
|
||||
}
|
||||
|
||||
public void setBlackListListener() {
|
||||
blackListListener = new ContactEventListener() {
|
||||
@Override
|
||||
public void onBlackListAdd(List<ContactItemBean> infoList) {
|
||||
onDataListAdd(infoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlackListDeleted(List<String> userList) {
|
||||
onDataListDeleted(userList);
|
||||
}
|
||||
};
|
||||
TUIContactService.getInstance().addContactEventListener(blackListListener);
|
||||
}
|
||||
|
||||
public void setIsForCall(boolean isSelectForCall) {
|
||||
this.isSelectForCall = isSelectForCall;
|
||||
}
|
||||
|
||||
public void loadDataSource(int dataSourceType) {
|
||||
IUIKitCallback<List<ContactItemBean>> callback = new IUIKitCallback<List<ContactItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ContactItemBean> data) {
|
||||
TUIContactLog.i(TAG, "load data source success , loadType = " + dataSourceType);
|
||||
onDataLoaded(data, dataSourceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUIContactLog.e(TAG, "load data source error , loadType = " + dataSourceType +
|
||||
" " + "errCode = " + errCode + " errMsg = " + errMsg);
|
||||
onDataLoaded(new ArrayList<>(), dataSourceType);
|
||||
}
|
||||
};
|
||||
|
||||
dataSource.clear();
|
||||
switch (dataSourceType) {
|
||||
case IContactListView.DataSource.FRIEND_LIST:
|
||||
provider.loadFriendListDataAsync(callback);
|
||||
break;
|
||||
case IContactListView.DataSource.BLACK_LIST:
|
||||
provider.loadBlackListData(callback);
|
||||
break;
|
||||
case IContactListView.DataSource.GROUP_LIST:
|
||||
provider.loadGroupListData(callback);
|
||||
break;
|
||||
case IContactListView.DataSource.CONTACT_LIST:
|
||||
dataSource.add((ContactItemBean) new ContactItemBean(TUIContactService.getAppContext().getResources().getString(R.string.new_friend))
|
||||
.setTop(true).setBaseIndexTag(ContactItemBean.INDEX_STRING_TOP));
|
||||
dataSource.add((ContactItemBean) new ContactItemBean(TUIContactService.getAppContext().getResources().getString(R.string.group)).
|
||||
setTop(true).setBaseIndexTag(ContactItemBean.INDEX_STRING_TOP));
|
||||
dataSource.add((ContactItemBean) new ContactItemBean(TUIContactService.getAppContext().getResources().getString(R.string.blacklist)).
|
||||
setTop(true).setBaseIndexTag(ContactItemBean.INDEX_STRING_TOP));
|
||||
provider.loadFriendListDataAsync(callback);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public long getNextSeq() {
|
||||
return provider == null ? 0 : provider.getNextSeq();
|
||||
}
|
||||
|
||||
public void loadGroupMemberList(String groupId) {
|
||||
if (!isSelectForCall && getNextSeq() == 0) {
|
||||
dataSource.add((ContactItemBean) new ContactItemBean(TUIContactService.getAppContext().getResources().getString(R.string.at_all))
|
||||
.setTop(true).setBaseIndexTag(ContactItemBean.INDEX_STRING_TOP));
|
||||
}
|
||||
provider.loadGroupMembers(groupId, new IUIKitCallback<List<ContactItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ContactItemBean> data) {
|
||||
TUIContactLog.i(TAG, "load data source success , loadType = " + IContactListView.DataSource.GROUP_MEMBER_LIST);
|
||||
onDataLoaded(data, IContactListView.DataSource.GROUP_MEMBER_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUIContactLog.e(TAG, "load data source error , loadType = " + IContactListView.DataSource.GROUP_MEMBER_LIST +
|
||||
" " + "errCode = " + errCode + " errMsg = " + errMsg);
|
||||
onDataLoaded(new ArrayList<>(), IContactListView.DataSource.GROUP_MEMBER_LIST);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onDataLoaded(List<ContactItemBean> loadedData, int dataSourceType) {
|
||||
dataSource.addAll(onDataListDeletedAdmin(loadedData));
|
||||
notifyDataSourceChanged();
|
||||
if (dataSourceType != IContactListView.DataSource.GROUP_LIST) {
|
||||
loadContactUserStatus(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadContactUserStatus(List<ContactItemBean> loadedData) {
|
||||
getUserStatusCallback = new IUIKitCallback<Void>(){
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
TUIContactLog.i(TAG, "loadContactUserStatus success");
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUIContactLog.e(TAG, "loadContactUserStatus error code = " + errCode + ",des = " + errMsg);
|
||||
}
|
||||
};
|
||||
GetUserStatusHelper.GetUserStatusTask task = new GetUserStatusHelper.GetUserStatusTask();
|
||||
task.setLoadedData(loadedData);
|
||||
task.setCallback(getUserStatusCallback);
|
||||
GetUserStatusHelper.enqueue(task);
|
||||
}
|
||||
|
||||
private void notifyDataSourceChanged() {
|
||||
if (contactListView != null) {
|
||||
contactListView.onDataSourceChanged(dataSource);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 剔除群创建者
|
||||
* @param loadedData
|
||||
* @return
|
||||
*/
|
||||
private List<ContactItemBean> onDataListDeletedAdmin(List<ContactItemBean> loadedData){
|
||||
Iterator<ContactItemBean> userIterator = loadedData.iterator();
|
||||
while(userIterator.hasNext()) {
|
||||
ContactItemBean contactItemBean = userIterator.next();
|
||||
if (GroupMemberInfo.MEMBER_ROLE_OWNER == contactItemBean.getRole()) {//剔除群的创建者(创建者为后台虚拟账号,所以需要剔除)
|
||||
userIterator.remove();
|
||||
}
|
||||
}
|
||||
return loadedData;
|
||||
}
|
||||
private void onDataListDeleted(List<String> userList) {
|
||||
Iterator<ContactItemBean> userIterator = dataSource.iterator();
|
||||
while(userIterator.hasNext()) {
|
||||
ContactItemBean contactItemBean = userIterator.next();
|
||||
for(String id : userList) {
|
||||
if (TextUtils.equals(id, contactItemBean.getId())) {
|
||||
userIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
|
||||
public void onUserStatusChanged(List<V2TIMUserStatus> userStatusList) {
|
||||
if (!TUIContactConfig.getInstance().isShowUserStatus()) {
|
||||
return;
|
||||
}
|
||||
HashMap<String, ContactItemBean> dataSourceMap = new HashMap<>();
|
||||
for(ContactItemBean itemBean : dataSource) {
|
||||
dataSourceMap.put(itemBean.getId(), itemBean);
|
||||
}
|
||||
|
||||
boolean isrefresh = false;
|
||||
for(V2TIMUserStatus timUserStatus : userStatusList) {
|
||||
String userid = timUserStatus.getUserID();
|
||||
ContactItemBean bean = dataSourceMap.get(userid);
|
||||
if (bean != null && bean.getStatusType() != timUserStatus.getStatusType()) {
|
||||
isrefresh = true;
|
||||
bean.setStatusType(timUserStatus.getStatusType());
|
||||
}
|
||||
}
|
||||
|
||||
if (isrefresh) {
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void onDataListAdd(List<ContactItemBean> users) {
|
||||
List<ContactItemBean> addUserList = new ArrayList<>(users);
|
||||
Iterator<ContactItemBean> beanIterator = addUserList.iterator();
|
||||
while(beanIterator.hasNext()) {
|
||||
ContactItemBean contactItemBean = beanIterator.next();
|
||||
for(ContactItemBean dataItemBean : dataSource) {
|
||||
if (TextUtils.equals(contactItemBean.getId(), dataItemBean.getId())) {
|
||||
beanIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSource.addAll(addUserList);
|
||||
notifyDataSourceChanged();
|
||||
|
||||
loadContactUserStatus(addUserList);
|
||||
}
|
||||
|
||||
public void getFriendApplicationUnreadCount(IUIKitCallback<Integer> callback) {
|
||||
provider.getFriendApplicationListUnreadCount(callback);
|
||||
}
|
||||
|
||||
public void loadFriendApplicationList(IUIKitCallback<Integer> callback) {
|
||||
provider.loadFriendApplicationList(new IUIKitCallback<List<FriendApplicationBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<FriendApplicationBean> data) {
|
||||
int size = 0;
|
||||
for (FriendApplicationBean friendApplicationBean : data) {
|
||||
if (friendApplicationBean.getAddType() == FriendApplicationBean.FRIEND_APPLICATION_COME_IN) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createGroupChat(GroupInfo groupInfo, IUIKitCallback<String> callback) {
|
||||
provider.createGroupChat(groupInfo, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String groupId) {
|
||||
groupInfo.setId(groupId);
|
||||
Gson gson = new Gson();
|
||||
MessageCustom messageCustom = new MessageCustom();
|
||||
messageCustom.version = TUIContactConstants.version;
|
||||
messageCustom.businessID = MessageCustom.BUSINESS_ID_GROUP_CREATE;
|
||||
messageCustom.opUser = TUILogin.getLoginUser();
|
||||
messageCustom.content = TUIContactService.getAppContext().getString(R.string.create_group);
|
||||
String data = gson.toJson(messageCustom);
|
||||
|
||||
ThreadHelper.INST.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sendGroupTipsMessage(groupId, data, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
BackgroundTasks.getInstance().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ContactUtils.callbackOnSuccess(callback, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
BackgroundTasks.getInstance().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ContactUtils.callbackOnError(callback, module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onFriendInfoChanged(List<ContactItemBean> infoList) {
|
||||
for (ContactItemBean changedItem : infoList) {
|
||||
for (int i = 0;i < dataSource.size();i++) {
|
||||
if (TextUtils.equals(dataSource.get(i).getId(), changedItem.getId())) {
|
||||
if (changedItem.getStatusType() == V2TIMUserStatus.V2TIM_USER_STATUS_UNKNOWN) {
|
||||
changedItem.setStatusType(dataSource.get(i).getStatusType());
|
||||
}
|
||||
dataSource.set(i, changedItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
|
||||
public void onFriendRemarkChanged(String id, String remark) {
|
||||
loadDataSource(IContactListView.DataSource.CONTACT_LIST);
|
||||
}
|
||||
|
||||
public void sendGroupTipsMessage(String groupId, String messageData, IUIKitCallback<String> callback) {
|
||||
provider.sendGroupTipsMessage(groupId, messageData, callback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.presenter;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.BackgroundTasks;
|
||||
import com.tencent.qcloud.tuicore.util.ThreadHelper;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.R;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactGroupApplyInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.GroupInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.IFriendProfileLayout;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.model.ContactProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class FriendProfilePresenter {
|
||||
private static final String TAG = FriendProfilePresenter.class.getSimpleName();
|
||||
|
||||
private final ContactProvider provider;
|
||||
|
||||
private IFriendProfileLayout friendProfileLayout;
|
||||
|
||||
public FriendProfilePresenter() {
|
||||
provider = new ContactProvider();
|
||||
}
|
||||
|
||||
public void setFriendProfileLayout(IFriendProfileLayout friendProfileLayout) {
|
||||
this.friendProfileLayout = friendProfileLayout;
|
||||
}
|
||||
|
||||
public void getC2CReceiveMessageOpt(List<String> userIdList, IUIKitCallback<Boolean> callback) {
|
||||
provider.getC2CReceiveMessageOpt(userIdList, new IUIKitCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
ContactUtils.callbackOnSuccess(callback, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, TAG, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setC2CReceiveMessageOpt(List<String> userIdList, boolean isReceiveMessage) {
|
||||
provider.setC2CReceiveMessageOpt(userIdList, isReceiveMessage, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getUsersInfo(String id, ContactItemBean bean) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(id);
|
||||
provider.getUserInfo(list, new IUIKitCallback<List<ContactItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ContactItemBean> data) {
|
||||
if (data == null || data.size() != 1) {
|
||||
return;
|
||||
}
|
||||
ContactItemBean user = data.get(0);
|
||||
bean.setNickName(user.getNickName());
|
||||
bean.setId(user.getId());
|
||||
bean.setAvatarUrl(user.getAvatarUrl());
|
||||
bean.setSignature(user.getSignature());
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
ThreadHelper.INST.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isInBlackList(id, new IUIKitCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
bean.setBlackList(data);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ThreadHelper.INST.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isFriend(id, bean, new IUIKitCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
bean.setFriend(data);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ThreadHelper.INST.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BackgroundTasks.getInstance().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (friendProfileLayout != null) {
|
||||
friendProfileLayout.onDataSourceChanged(bean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("getUsersInfo error , code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void isInBlackList(String id, IUIKitCallback<Boolean> callback) {
|
||||
provider.isInBlackList(id, new IUIKitCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
ContactUtils.callbackOnSuccess(callback, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("getBlackList error , code = " + errCode + ", desc = " + errMsg);
|
||||
ContactUtils.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void isFriend(String id, ContactItemBean bean, IUIKitCallback<Boolean> callback) {
|
||||
provider.isFriend(id, bean, callback);
|
||||
}
|
||||
|
||||
public void deleteFromBlackList(List<String> idList) {
|
||||
provider.deleteFromBlackList(idList, new IUIKitCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("deleteFromBlackList Error code = " + errCode + ", desc = " + errMsg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addToBlackList(List<String> idList) {
|
||||
provider.addToBlackList(idList, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("addToBlackList Error code = " + errCode + ", desc = " + errMsg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyRemark(String id, String remark, IUIKitCallback<String> callback) {
|
||||
provider.modifyRemark(id, remark, callback);
|
||||
}
|
||||
|
||||
public void deleteFriend(List<String> idList, IUIKitCallback<Void> callback) {
|
||||
provider.deleteFriend(idList, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
for (String id : idList) {
|
||||
String conversationId = TUIConstants.TUIConversation.CONVERSATION_C2C_PREFIX + id;
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIConversation.CONVERSATION_ID, conversationId);
|
||||
param.put(TUIConstants.TUIChat.CHAT_ID, id);
|
||||
param.put(TUIConstants.TUIChat.IS_GROUP_CHAT, false);
|
||||
TUICore.callService(TUIConstants.TUIConversation.SERVICE_NAME, TUIConstants.TUIConversation.METHOD_DELETE_CONVERSATION, param);
|
||||
TUICore.callService(TUIConstants.TUIChat.SERVICE_NAME, TUIConstants.TUIChat.METHOD_EXIT_CHAT, param);
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refuseFriendApplication(FriendApplicationBean friendApplication, IUIKitCallback<Void> callback) {
|
||||
provider.refuseFriendApplication(friendApplication, callback);
|
||||
}
|
||||
|
||||
public void acceptFriendApplication(FriendApplicationBean friendApplication, int responseType, IUIKitCallback<Void> callback) {
|
||||
provider.acceptFriendApplication(friendApplication, responseType, callback);
|
||||
}
|
||||
|
||||
public boolean isTopConversation(String chatId) {
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIConversation.CHAT_ID, chatId);
|
||||
Object result = TUICore.callService(TUIConstants.TUIConversation.SERVICE_NAME,
|
||||
TUIConstants.TUIConversation.METHOD_IS_TOP_CONVERSATION, param);
|
||||
if (result instanceof Bundle) {
|
||||
return ((Bundle) result).getBoolean(TUIConstants.TUIConversation.IS_TOP, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setConversationTop(String chatId, boolean isSetTop) {
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIConversation.CHAT_ID, chatId);
|
||||
param.put(TUIConstants.TUIConversation.IS_SET_TOP, isSetTop);
|
||||
TUICore.callService(TUIConstants.TUIConversation.SERVICE_NAME, TUIConstants.TUIConversation.METHOD_SET_TOP_CONVERSATION, param);
|
||||
}
|
||||
|
||||
|
||||
public void acceptJoinGroupApply(ContactGroupApplyInfo info, IUIKitCallback<Void> callback) {
|
||||
provider.acceptJoinGroupApply(info, callback);
|
||||
}
|
||||
|
||||
public void refuseJoinGroupApply(ContactGroupApplyInfo info, String reason, IUIKitCallback<Void> callback) {
|
||||
provider.refuseJoinGroupApply(info, reason, callback);
|
||||
}
|
||||
|
||||
public void addFriend(String userId, String addWord, String friendGroup, String remark, IUIKitCallback<Pair<Integer, String>> callback) {
|
||||
provider.addFriend(userId, addWord, friendGroup, remark, new IUIKitCallback<Pair<Integer, String>>() {
|
||||
@Override
|
||||
public void onSuccess(Pair<Integer, String> data) {
|
||||
int code = data.first;
|
||||
String result = "";
|
||||
switch (code) {
|
||||
case FriendApplicationBean.ERR_SUCC:
|
||||
result = TUIContactService.getAppContext().getString(R.string.success);
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_INVALID_PARAMETERS:
|
||||
if (TextUtils.equals(data.second, "Err_SNS_FriendAdd_Friend_Exist")) {
|
||||
result = TUIContactService.getAppContext().getString(R.string.have_be_friend);
|
||||
break;
|
||||
}
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_COUNT_LIMIT:
|
||||
result = TUIContactService.getAppContext().getString(R.string.friend_limit);
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_PEER_FRIEND_LIMIT:
|
||||
result = TUIContactService.getAppContext().getString(R.string.other_friend_limit);
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_IN_SELF_BLACKLIST:
|
||||
result = TUIContactService.getAppContext().getString(R.string.in_blacklist);
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_ALLOW_TYPE_DENY_ANY:
|
||||
result = TUIContactService.getAppContext().getString(R.string.forbid_add_friend);
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_IN_PEER_BLACKLIST:
|
||||
result = TUIContactService.getAppContext().getString(R.string.set_in_blacklist);
|
||||
break;
|
||||
case FriendApplicationBean.ERR_SVR_FRIENDSHIP_ALLOW_TYPE_NEED_CONFIRM:
|
||||
result = TUIContactService.getAppContext().getString(R.string.wait_agree_friend);
|
||||
break;
|
||||
default:
|
||||
result = TUIContactService.getAppContext().getString(R.string.other_friend_limit);
|
||||
ToastUtil.toastLongMessage(data.first + " " + data.second);
|
||||
break;
|
||||
}
|
||||
ContactUtils.callbackOnSuccess(callback, new Pair<>(code, result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ContactUtils.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinGroup(String groupId, String addWord, IUIKitCallback<Void> callback) {
|
||||
provider.joinGroup(groupId, addWord, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
String msg = errMsg;
|
||||
if (errCode == GroupInfo.ERR_SVR_GROUP_PERMISSION_DENY) {
|
||||
msg = TUIContactService.getAppContext().getString(R.string.add_group_permission_deny);
|
||||
} else if (errCode == GroupInfo.ERR_SVR_GROUP_ALLREADY_MEMBER) {
|
||||
msg = TUIContactService.getAppContext().getString(R.string.add_group_allready_member);
|
||||
} else if (errCode == GroupInfo.ERR_SVR_GROUP_NOT_FOUND) {
|
||||
msg = TUIContactService.getAppContext().getString(R.string.add_group_not_found);
|
||||
} else if (errCode == GroupInfo.ERR_SVR_GROUP_FULL_MEMBER_COUNT) {
|
||||
msg = TUIContactService.getAppContext().getString(R.string.add_group_full_member);
|
||||
}
|
||||
ContactUtils.callbackOnError(callback, errCode, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.presenter;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ThreadHelper;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.ContactItemBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.model.ContactProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
/**
|
||||
* A get user status task queue which has a limit frequency mechanism
|
||||
* 具有接口调用限频机制的获取用户状态的任务队列
|
||||
*/
|
||||
public class GetUserStatusHelper {
|
||||
private static final String TAG = "GetUserStatusHelper";
|
||||
private static final GetUserStatusHelper instance = new GetUserStatusHelper();
|
||||
|
||||
private static final int MAX_USER_LIMIT = 500;
|
||||
private static final int INTERFACE_CALL_PERIOD = 1000; // 1s
|
||||
|
||||
private final ContactProvider provider;
|
||||
private final LinkedBlockingDeque<GetUserStatusTask> taskQueue;
|
||||
private Thread getUserStatusThread;
|
||||
|
||||
private GetUserStatusHelper() {
|
||||
provider = new ContactProvider();
|
||||
taskQueue = new LinkedBlockingDeque<>();
|
||||
}
|
||||
|
||||
public static void enqueue(GetUserStatusTask task) {
|
||||
TUIContactLog.i(TAG, "GetUserStatusTask enqueue " + task);
|
||||
instance.taskQueue.offerFirst(task);
|
||||
instance.execute();
|
||||
}
|
||||
|
||||
private synchronized void execute() {
|
||||
if (getUserStatusThread == null) {
|
||||
getUserStatusThread = new Thread("GetUserStatusThread") {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
GetUserStatusTask task = taskQueue.poll();
|
||||
if (task == null) {
|
||||
getUserStatusThread = null;
|
||||
return;
|
||||
}
|
||||
if (!task.isNeedRequest()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<ContactItemBean> dataList;
|
||||
if (task.data == null || task.data.size() <= MAX_USER_LIMIT) {
|
||||
dataList = task.data;
|
||||
} else {
|
||||
dataList = task.data.subList(0, MAX_USER_LIMIT);
|
||||
task.data = task.data.subList(MAX_USER_LIMIT, task.data.size());
|
||||
taskQueue.offerFirst(task);
|
||||
}
|
||||
provider.loadContactUserStatus(dataList, new IUIKitCallback<Void>() {
|
||||
// callback run on ui thread
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
task.callbackSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
task.callbackError(errCode, errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
Thread.sleep(INTERFACE_CALL_PERIOD);
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
ThreadHelper.INST.execute(getUserStatusThread);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetUserStatusTask {
|
||||
private List<ContactItemBean> data;
|
||||
// Avoid memory leaks
|
||||
private WeakReference<IUIKitCallback<Void>> callbackWeakReference;
|
||||
|
||||
// if callback exists
|
||||
private boolean isNeedRequest() {
|
||||
return callbackWeakReference != null && callbackWeakReference.get() != null;
|
||||
}
|
||||
|
||||
// run on ui thread
|
||||
private void callbackSuccess() {
|
||||
if (callbackWeakReference != null) {
|
||||
IUIKitCallback<Void> callback = callbackWeakReference.get();
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
}
|
||||
|
||||
// run on ui thread
|
||||
private void callbackError(int errCode, String errMsg) {
|
||||
if (callbackWeakReference != null) {
|
||||
IUIKitCallback<Void> callback = callbackWeakReference.get();
|
||||
ContactUtils.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLoadedData(List<ContactItemBean> loadedData) {
|
||||
this.data = new ArrayList<>(loadedData);
|
||||
}
|
||||
|
||||
public void setCallback(IUIKitCallback<Void> callback) {
|
||||
this.callbackWeakReference = new WeakReference<>(callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.TUIContactService;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.bean.FriendApplicationBean;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.ContactEventListener;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.interfaces.INewFriendActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.model.ContactProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.ContactUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicontact.util.TUIContactLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class NewFriendPresenter {
|
||||
private static final String TAG = NewFriendPresenter.class.getSimpleName();
|
||||
|
||||
private final ContactProvider provider;
|
||||
|
||||
private INewFriendActivity friendActivity;
|
||||
|
||||
private final List<FriendApplicationBean> dataSource = new ArrayList<>();
|
||||
|
||||
private ContactEventListener friendApplicationListener;
|
||||
|
||||
public NewFriendPresenter() {
|
||||
provider = new ContactProvider();
|
||||
|
||||
friendApplicationListener = new ContactEventListener() {
|
||||
@Override
|
||||
public void onFriendApplicationListAdded(List<FriendApplicationBean> applicationList) {
|
||||
Iterator<FriendApplicationBean> beanIterator = applicationList.iterator();
|
||||
while(beanIterator.hasNext()) {
|
||||
FriendApplicationBean friendApplicationBean = beanIterator.next();
|
||||
for(FriendApplicationBean dataBean : dataSource) {
|
||||
if (TextUtils.equals(dataBean.getUserId(), friendApplicationBean.getUserId())) {
|
||||
beanIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSource.addAll(applicationList);
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationListDeleted(List<String> userIDList) {
|
||||
Iterator<FriendApplicationBean> applicationIterator = dataSource.iterator();
|
||||
while(applicationIterator.hasNext()) {
|
||||
FriendApplicationBean friendApplicationBean = applicationIterator.next();
|
||||
for(String id : userIDList) {
|
||||
if (TextUtils.equals(id, friendApplicationBean.getUserId())) {
|
||||
applicationIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendApplicationListRead() {
|
||||
super.onFriendApplicationListRead();
|
||||
}
|
||||
};
|
||||
TUIContactService.getInstance().addContactEventListener(friendApplicationListener);
|
||||
}
|
||||
|
||||
public void setFriendActivity(INewFriendActivity friendActivity) {
|
||||
this.friendActivity = friendActivity;
|
||||
}
|
||||
|
||||
public void loadFriendApplicationList() {
|
||||
dataSource.clear();
|
||||
provider.loadFriendApplicationList(new IUIKitCallback<List<FriendApplicationBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<FriendApplicationBean> data) {
|
||||
for (FriendApplicationBean friendApplicationBean : data) {
|
||||
if (friendApplicationBean.getAddType() == FriendApplicationBean.FRIEND_APPLICATION_COME_IN) {
|
||||
dataSource.add(friendApplicationBean);
|
||||
}
|
||||
}
|
||||
notifyDataSourceChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("Error code = " + errCode + ", desc = " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void notifyDataSourceChanged() {
|
||||
if (friendActivity != null) {
|
||||
friendActivity.onDataSourceChanged(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptFriendApplication(FriendApplicationBean friendApplicationBean, IUIKitCallback<Void> callback) {
|
||||
provider.acceptFriendApplication(friendApplicationBean, FriendApplicationBean.FRIEND_ACCEPT_AGREE_AND_ADD, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUIContactLog.e(TAG, "acceptFriendApplication error " + errCode + " " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refuseFriendApplication(FriendApplicationBean friendApplicationBean, IUIKitCallback<Void> callback) {
|
||||
provider.refuseFriendApplication(friendApplicationBean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ContactUtils.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUIContactLog.e(TAG, "acceptFriendApplication error " + errCode + " " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void setFriendApplicationListAllRead(IUIKitCallback<Void> callback) {
|
||||
provider.setGroupApplicationRead(callback);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.util;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuicore.util.ErrorMessageConverter;
|
||||
|
||||
public class ContactUtils {
|
||||
|
||||
public static <T> void callbackOnError(IUIKitCallback<T> callBack, String module, int errCode, String desc) {
|
||||
if (callBack != null) {
|
||||
callBack.onError(module, errCode, ErrorMessageConverter.convertIMError(errCode, desc));
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void callbackOnError(IUIKitCallback<T> callBack, int errCode, String desc) {
|
||||
if (callBack != null) {
|
||||
callBack.onError(null, errCode, ErrorMessageConverter.convertIMError(errCode, desc));
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void callbackOnSuccess(IUIKitCallback<T> callBack, T data) {
|
||||
if (callBack != null) {
|
||||
callBack.onSuccess(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isC2CChat(int chatType) {
|
||||
return chatType == V2TIMConversation.V2TIM_C2C;
|
||||
}
|
||||
|
||||
public static boolean isGroupChat(int chatType) {
|
||||
return chatType == V2TIMConversation.V2TIM_GROUP;
|
||||
}
|
||||
|
||||
public static String getLoginUser() {
|
||||
return V2TIMManager.getInstance().getLoginUser();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.tencent.qcloud.tuikit.tuicontact.util;
|
||||
|
||||
import com.tencent.imsdk.common.IMLog;
|
||||
|
||||
public class TUIContactLog extends IMLog {
|
||||
|
||||
private static final String PRE = "TUIContact-";
|
||||
|
||||
private static String mixTag(String tag) {
|
||||
return PRE + tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印INFO级别日志
|
||||
*
|
||||
* Print INFO level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo 消息
|
||||
*/
|
||||
public static void v(String strTag, String strInfo) {
|
||||
IMLog.v(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印DEBUG级别日志
|
||||
*
|
||||
* Print DEBUG level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo 消息
|
||||
*/
|
||||
public static void d(String strTag, String strInfo) {
|
||||
IMLog.d(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印INFO级别日志
|
||||
*
|
||||
* Print INFO level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo 消息
|
||||
*/
|
||||
public static void i(String strTag, String strInfo) {
|
||||
IMLog.i(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印WARN级别日志
|
||||
*
|
||||
* Print WARN level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo 消息
|
||||
*/
|
||||
public static void w(String strTag, String strInfo) {
|
||||
IMLog.w(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印WARN级别日志
|
||||
*
|
||||
* Print WARN level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo 消息
|
||||
*/
|
||||
public static void w(String strTag, String strInfo, Throwable e) {
|
||||
IMLog.w(mixTag(strTag), strInfo + e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印ERROR级别日志
|
||||
*
|
||||
* Print ERROR level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo 消息
|
||||
*/
|
||||
public static void e(String strTag, String strInfo) {
|
||||
IMLog.e(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="TUIContactLightTheme" parent="TUIBaseLightTheme">
|
||||
<item name="contact_new_friend_icon">@drawable/contact_new_friend_icon_light</item>
|
||||
<item name="contact_group_list_icon">@drawable/contact_group_list_icon_light</item>
|
||||
<item name="contact_black_list_icon">@drawable/contact_black_list_icon_light</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
</resources>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="TUIContactLivelyTheme" parent="TUIBaseLivelyTheme">
|
||||
<item name="contact_new_friend_icon">@drawable/contact_new_friend_icon_lively</item>
|
||||
<item name="contact_group_list_icon">@drawable/contact_group_list_icon_lively</item>
|
||||
<item name="contact_black_list_icon">@drawable/contact_black_list_icon_lively</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@color/white"
|
||||
android:paddingTop="9dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="34sp"
|
||||
android:lineHeight="41dp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/black_font_color"
|
||||
android:text="@string/contact_minimalist_contacts"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/create_new_button"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginLeft="25dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:background="@drawable/contact_minimalist_create_icon" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.TitleBarLayout
|
||||
android:id="@+id/group_create_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/page_title_height" />
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView
|
||||
android:id="@+id/group_create_member_list"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/selected_list"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/confirm_button"
|
||||
android:background="@drawable/contact_confirm_button_bg"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/sure"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/limit_tips"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="36dp"
|
||||
android:paddingTop="12dp"
|
||||
android:background="#F6F6F6"
|
||||
android:textColor="#999999"
|
||||
android:textSize="12sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:visibility="visible"
|
||||
tools:text="123"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.TitleBarLayout
|
||||
android:id="@+id/black_list_titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/page_title_height" />
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView
|
||||
android:id="@+id/black_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactLayout
|
||||
android:id="@+id/contact_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/status_bar_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.FriendProfileLayout
|
||||
android:id="@+id/friend_profile"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,353 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/core_bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.TitleBarLayout
|
||||
android:id="@+id/friend_titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/page_title_height" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/friend_detail_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_self_height"
|
||||
android:background="#FFFFFF"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/page_margin">
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.gatherimage.ShadeImageView
|
||||
android:id="@+id/friend_icon"
|
||||
android:layout_width="@dimen/contact_profile_face_size"
|
||||
android:layout_height="@dimen/contact_profile_face_size"
|
||||
android:layout_gravity="start"
|
||||
app:round_radius="24dp"
|
||||
android:layout_marginLeft="@dimen/contact_profile_face_margin_left"
|
||||
android:layout_marginTop="@dimen/contact_profile_face_margin_top"
|
||||
android:layout_marginRight="@dimen/contact_profile_face_margin_right"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friend_nick_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/friend_icon"
|
||||
android:layout_toEndOf="@id/friend_icon"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/contact_profile_nick_name_text_size"
|
||||
tools:text="林" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friend_account_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/friend_nick_name"
|
||||
android:layout_alignStart="@id/friend_nick_name"
|
||||
android:layout_marginTop="@dimen/contact_profile_text_margin"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/contact_account_tag"
|
||||
android:textSize="@dimen/contact_profile_account_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friend_account"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/friend_nick_name"
|
||||
android:layout_alignTop="@+id/friend_account_tag"
|
||||
android:layout_toEndOf="@id/friend_account_tag"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="@dimen/contact_profile_account_text_size"
|
||||
tools:text="99618" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friend_signature_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/friend_account_tag"
|
||||
android:layout_alignStart="@id/friend_account_tag"
|
||||
android:layout_marginTop="@dimen/contact_profile_text_margin"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/contact_signature_tag"
|
||||
android:textSize="@dimen/contact_profile_account_text_size" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friend_signature"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/friend_signature_tag"
|
||||
android:layout_toEndOf="@id/friend_signature_tag"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/contact_profile_signature_text_size"
|
||||
tools:text="相信光" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/friend_application_verify_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="@color/white"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15.36dp"
|
||||
android:text="@string/contact_add_wording" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friend_application_add_wording"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="你好啊" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/add_friend_verify_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15.36dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:text="@string/contact_set_add_wording" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/add_wording_edit"
|
||||
android:longClickable="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="138dp"
|
||||
android:background="@color/white"
|
||||
android:gravity="top"
|
||||
android:maxLines="5" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/remark_and_group_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15.36dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/contact_set_remark_and_group" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/friend_remark_lv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
android:layout_marginTop="10dp"
|
||||
app:canNav="true"
|
||||
app:name="@string/contact_friend_remark" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/friend_group_lv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
app:canNav="true"
|
||||
app:name="@string/contact_friend_group" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/remark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
app:canNav="true"
|
||||
app:name="@string/profile_remark"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/msg_rev_opt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
app:isSwitch="true"
|
||||
app:name="@string/profile_msgrev_opt" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/chat_to_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
android:visibility="gone"
|
||||
app:isSwitch="true"
|
||||
app:isTop="true"
|
||||
app:name="@string/chat_to_top" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/chat_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
android:visibility="gone"
|
||||
app:canNav="true"
|
||||
app:name="@string/profile_chat_background"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/blackList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_item_height"
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
app:isSwitch="true"
|
||||
app:name="@string/profile_black" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_friend_send_btn"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/contact_add"
|
||||
android:textColor="?attr/core_primary_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/accept_friend_send_btn"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/accept"
|
||||
android:textColor="?attr/core_primary_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_chat"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/profile_chat"
|
||||
android:textColor="?attr/core_primary_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_voice"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="0.68dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/profile_voice_chat"
|
||||
android:textColor="?attr/core_primary_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_video"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="0.68dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/profile_video_chat"
|
||||
android:textColor="?attr/core_primary_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_clear_chat_history"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="0.68dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/profile_clear_message"
|
||||
android:textColor="?attr/core_error_tip_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:visibility="gone"
|
||||
android:textAllCaps="false"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_delete"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="0.68dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/profile_delete_friend"
|
||||
android:textColor="?attr/core_error_tip_color"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:visibility="gone"
|
||||
android:textAllCaps="false"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/refuse_friend_send_btn"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_profile_btn_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="0.6dp"
|
||||
android:background="@drawable/btn_bg_color"
|
||||
android:text="@string/refuse"
|
||||
android:textColor="?attr/core_error_tip_color"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="@dimen/contact_profile_btn_text_size"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,17 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/core_bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/contact_minimalist_header_view_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView
|
||||
android:id="@+id/contact_listview"
|
||||
android:background="?attr/core_bg_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="#F2F3F5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/contact_member_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/not_found_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="120dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="13.44sp"
|
||||
android:textColor="#444444"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
tools:text="暂无群聊"/>
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.component.indexlib.IndexBar.widget.IndexBar
|
||||
android:id="@+id/contact_indexBar"
|
||||
android:layout_width="24dp"
|
||||
android:layout_marginTop="54dp"
|
||||
android:layout_marginBottom="40.8dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
app:indexBarPressBackground="@color/partTranslucent"
|
||||
app:indexBarTextSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_tvSideBarHint"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/shape_side_bar_bg"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="40sp"
|
||||
android:visibility="gone"
|
||||
tools:text="A"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ProgressBar
|
||||
android:id="@+id/contact_loading_bar"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_centerInParent="true"/>
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.TitleBarLayout
|
||||
android:id="@+id/group_create_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_height="@dimen/page_title_height" />
|
||||
|
||||
<com.tencent.qcloud.tuicore.component.LineControllerView
|
||||
android:id="@+id/group_type_join"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/group_create_title_bar"
|
||||
android:layout_marginTop="1dp"
|
||||
android:visibility="gone"
|
||||
app:name="@string/group_join_type" />
|
||||
|
||||
<com.tencent.qcloud.tuikit.tuicontact.minimalistui.widget.ContactListView
|
||||
android:id="@+id/group_create_member_list"
|
||||
android:layout_below="@+id/group_create_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/btn_height"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/forward_contact_select_list_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:paddingLeft="14.85dp"
|
||||
android:paddingRight="14.85dp"
|
||||
android:orientation="horizontal">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/forward_contact_select_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/forward_margin"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_msg_ok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/btn_margin_right"
|
||||
android:text="@string/sure"
|
||||
android:textColor="@color/bg_positive_btn"
|
||||
android:textSize="14sp"
|
||||
android:visibility="visible" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||