Commit 654226aa by 万齐军

feat: im改造,删除无用东西,初始化方法修改

parent b2a72dd1
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../maven_push_api.gradle"
version = '1.0.0'
version = '1.0.1'
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
......
package com.yidianling.im.api.bean;
import androidx.annotation.DrawableRes;
/**
* Created by haorui on 2020/3/6.
* Des:
*/
public class IMInitConfigBean {
@DrawableRes public int notificationIconRes;
/**
* 测试环境AppKey
*/
......
......@@ -180,8 +180,6 @@ interface IImService : IProvider {
toUid: Int
)
fun initIm(app: Application, activity: Class<out Activity>)
fun initIm(app: Application, activity: Class<out Activity>, imInitBean: IMInitConfigBean)
fun isWifiOr3G(activity: Activity): Boolean
......
......@@ -7,8 +7,8 @@ import android.content.Intent
import android.os.Build
import android.os.Looper
import android.os.Process
import androidx.annotation.RequiresApi
import android.util.Log
import androidx.annotation.RequiresApi
import com.channel.ydl_flutter_base.plugin.YDLCommonPlugin
import com.facebook.stetho.Stetho
import com.meituan.android.walle.WalleChannelReader
......@@ -20,6 +20,7 @@ import com.umeng.socialize.PlatformConfig
import com.umeng.socialize.UMShareAPI
import com.ydl.component.BuildConfig
import com.ydl.component.MainActivity
import com.ydl.component.R
import com.ydl.media.audio.PlayService
import com.ydl.ydlcommon.actions.crash.Cockroach
import com.ydl.ydlcommon.actions.crash.ExceptionHandler
......@@ -31,6 +32,7 @@ import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.YdlBuryPointUtil
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.bean.IMInitConfigBean
import com.yidianling.im.config.NimApplication
import io.flutter.view.FlutterMain
import io.reactivex.functions.Action
......@@ -93,6 +95,8 @@ class DemoAppLifecycles : IAppLifecycles {
override fun onTerminate(application: Application) {}
private fun moduleInit(application: Application) {
val imInitConfigBean = IMInitConfigBean()
imInitConfigBean.notificationIconRes = R.drawable.im_ic_launcher
NimApplication.getInstance().initIm(application, MainActivity::class.java)
}
......
......@@ -232,7 +232,7 @@ ext {
"ydl-m-user-api" : "com.ydl:m-user-api:1.0.0",
"ydl-m-fm-api" : "com.ydl:m-fm-api:1.0.0",
"ydl-m-tests-api" : "com.ydl:m-tests-api:1.0.0",
"ydl-m-im-api" : "com.ydl:m-im-api:1.0.0",
"ydl-m-im-api" : "com.ydl:m-im-api:1.0.1",
"ydl-m-home-api" : "com.ydl:m-home-api:${ydlPublishVersion["m-home-api"]}",
"ydl-m-consultant-api" : "com.ydl:m-consultant-api:1.0.0",
"ydl-m-dynamic-api" : "com.ydl:m-dynamic-api:1.0.0",
......
......@@ -63,7 +63,6 @@ dependencies {
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapterHelper"]
api 'com.tencent.tbs.tbssdk:sdk:43903'
compileOnly "com.ydl.aar:resource:0.0.1-ydl"
if (rootProject.ext.dev_mode){
//开发时使用
api project(':ydl-webview')
......
......@@ -6,6 +6,8 @@ import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import androidx.annotation.DrawableRes;
import com.alibaba.fastjson.JSON;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.auth.LoginInfo;
......@@ -70,7 +72,7 @@ public class NimApplication {
// 云信sdk相关业务初始化
NIMInitManager.getInstance().init(true);
// 初始化音视频模块
initAVChatKit(activity);
initAVChatKit(activity, configBean.notificationIconRes);
//注册状态观察者
ImObserversHelper.Companion.getInstance().registerObserver(true);
// 初始化听筒模式
......@@ -134,7 +136,7 @@ public class NimApplication {
return options;
}
private void initAVChatKit(Class activity) {
private void initAVChatKit(Class activity, @DrawableRes int notificationIconRes) {
AVChatOptions avChatOptions = new AVChatOptions() {
@Override
public void logout(Context context) {
......@@ -142,7 +144,7 @@ public class NimApplication {
}
};
avChatOptions.entranceActivity = activity;
avChatOptions.notificationIconRes = R.drawable.im_ic_launcher;
avChatOptions.notificationIconRes = notificationIconRes;
AVChatKit.init(avChatOptions);
// 设置用户相关资料提供者
......
......@@ -5,6 +5,8 @@ import android.graphics.Color;
import android.os.Environment;
import android.text.TextUtils;
import androidx.annotation.DrawableRes;
import com.netease.nimlib.sdk.SDKOptions;
import com.netease.nimlib.sdk.StatusBarNotificationConfig;
import com.netease.nimlib.sdk.mixpush.MixPushConfig;
......@@ -41,7 +43,7 @@ class NimSDKOptionConfig {
options.appKey = getIMAppKey(configBean);
// 如果将新消息通知提醒托管给SDK完成,需要添加以下配置。
initStatusBarNotificationConfig(context, options, activity);
initStatusBarNotificationConfig(context, options, activity, configBean.notificationIconRes);
// 配置 APP 保存图片/语音/文件/log等数据的目录
options.sdkStorageRootPath = getAppCacheDir(context) + "/yidianling"; // 可以不设置,那么将采用默认路径
......@@ -108,9 +110,9 @@ class NimSDKOptionConfig {
return storageRootPath;
}
private static void initStatusBarNotificationConfig(Context context, SDKOptions options, Class activity) {
private static void initStatusBarNotificationConfig(Context context, SDKOptions options, Class activity,@DrawableRes int notificationIconRes) {
// load 应用的状态栏配置
StatusBarNotificationConfig config = loadStatusBarNotificationConfig(context, activity);
StatusBarNotificationConfig config = loadStatusBarNotificationConfig(context, activity, notificationIconRes);
// load 用户的 StatusBarNotificationConfig 设置项
StatusBarNotificationConfig userConfig = UserPreferences.getStatusConfig();
......@@ -131,11 +133,11 @@ class NimSDKOptionConfig {
}
// 这里开发者可以自定义该应用初始的 StatusBarNotificationConfig
private static StatusBarNotificationConfig loadStatusBarNotificationConfig(Context context, Class activity) {
private static StatusBarNotificationConfig loadStatusBarNotificationConfig(Context context, Class activity, @DrawableRes int notificationIconRes) {
StatusBarNotificationConfig config = new StatusBarNotificationConfig();
// 点击通知需要跳转到的界面
config.notificationEntrance = activity;
config.notificationSmallIconId = R.drawable.im_ic_launcher;
config.notificationSmallIconId = notificationIconRes;
config.notificationColor = IMCache.getContext().getResources().getColor(R.color.platform_color_blue_3a9efb);
// 通知铃声的uri字符串
// config.notificationSound = "android.resource://com.yidianling.im/raw/msg";
......
......@@ -400,16 +400,12 @@ class IMServiceImpl : IImService {
}
override fun initIm(app: Application, activity: Class<out Activity>) {
NimApplication.getInstance().initIm(app, activity)
}
override fun initIm(
app: Application,
activity: Class<out Activity>,
imInitBean: IMInitConfigBean
) {
NimApplication.getInstance().initIm(app, activity,imInitBean)
NimApplication.getInstance().initIm(app, activity, imInitBean)
}
override fun isWifiOr3G(activity: Activity): Boolean {
......
package com.yidianling.im.api.bean;
/**
* Created by xj on 2019/6/27.
*/
public class IMDoctorBriefInfo {
public String smallImage = "";
public double feedbackRate = 0.000;
public String feedbackRateForShow = "";
public int orderNum = 0;
public int helpLong = 0;
}
package com.yidianling.im.api.bean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by hgw on 2018/3/13.
*/
public class IMExpertBuild {
public IMShareDataBuild shareData;
public String tips; //禁言提示内容
public String url;//禁言帮助URL
public IMDoctorBriefInfo doctorBriefInfo = new IMDoctorBriefInfo();
public List<ImCommendDetailBean> commentList = new ArrayList(); //评论列表
public int commentCounter = 0; //评论总数
public String commentCounterUrl = ""; //评论总数url
}
\ No newline at end of file
package com.yidianling.im.api.bean;
/**
* Created by haorui on 2020/3/6.
* Des:
*/
public class IMInitConfigBean {
/**
* 测试环境AppKey
*/
public String debugAppKey;
/**
* 正式环境AppKey
*/
public String releaseAppKey;
/**
* 小米推送 appId
*/
public String xmAppId;
/**
* 小米推送 appKey
*/
public String xmAppKey;
/**
* 小米推送证书,请在云信管理后台申请
*/
public String xmCertificateName;
/**
* 华为推送 hwAppId
*/
public String hwAppId;
/**
*
* 华为推送证书,请在云信管理后台申请
*/
public String hwCertificateName;
/**
* 魅族推送 appId
*/
public String mzAppId;
/**
* 魅族推送 appKey
*/
public String mzAppKey;
/**
* 魅族推送证书,请在云信管理后台申请
*/
public String mzCertificateName;
/**
* FCM 推送证书,请在云信管理后台申请
* 海外客户使用
*/
public String fcmCertificateName;
/**
* VIVO推送 appId apiKey请在 AndroidManifest.xml 文件中配置
* VIVO推送证书,请在云信管理后台申请
*/
public String vivoCertificateName;
/**
* oppo 推送appId
*/
public String oppoAppId;
/**
* oppo 推送appKey
*/
public String oppoAppKey;
/**
* oppo 推送AppSecret
*/
public String oppoAppSercet;
/**
* OPPO推送证书,请在云信管理后台申请
*/
public String oppoCertificateName;
}
package com.yidianling.im.api.bean
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/03/23
* 登录 im 时传入的参数,对应 im 模块中的 IMLoginInfo
*/
data class IMLoginInfo(val account: String, val passWord: String)
\ No newline at end of file
package com.yidianling.im.api.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/4/21
*/
interface IMRegisterObserverCustomNotificationCallBack {
fun onObserverCustomNotification(fromUid:String,toUid:String,content: String)
}
\ No newline at end of file
package com.yidianling.im.api.bean
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/03/23
* 登录 im 时传入的接口,对应 im 模块中的 IMRequestCallback
*/
interface IMRequestCallback<in T> {
fun onSuccess(t: T?)
fun onFailed(i: Int)
fun onException(throwable: Throwable?)
}
\ No newline at end of file
package com.yidianling.im.api.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/4/21
*/
interface IMSendCustomNotificationResultCallBack {
fun onSuccess()
fun onFailed(code: Int)
fun onException(throwable: Throwable)
}
\ No newline at end of file
package com.yidianling.im.api.bean;
import com.google.gson.annotations.SerializedName;
/**
* Created by hgw on 2018/3/13.
*/
public class IMShareDataBuild {
public String toUid;
public String doctorId;
public String listenerId;
// public String name;
public String title;
@SerializedName(value = "isOnline", alternate = "is_online")
public int is_online;//专家倾述在线状态 1.在线 2.离线 3通话中 4-继续拨打 ,
public int isChatOnline;//专家私聊在线状态 1.在线 2.离线
public String cover;
public String desc;
@SerializedName(value = "urlShare", alternate = "url_share")
public String url_share;
public String price;
public String unitTxt;
public String url;
public String urlTitle;
public String blackStatus;
@SerializedName(value = "userType", alternate = "user_type")
public int user_type;//1用户,2专家,3助理
public int is_first;//1表示第一次聊天0不是
public paramsBuild params = new paramsBuild();
public int hasAvailableListenOrder;//是否还有未完成的倾诉订单 1、没有 2、有
public int listenOrderCommentStatus;//倾诉订单评论状态 1:未评价 9:已评价 ,
public String listenOrderCommentUrl;//倾诉订单评价页url
public String listenOrderUrl;//订单详情页面url
public String listenOrderDesc;//倾诉订单状态描述
public String listenOrderRemainTime;//未完成倾诉订单剩余时间
@SerializedName(value = "orderUrl", alternate = "order_url")
public String order_url;
@SerializedName(value = "name", alternate = "doctorName")
public String doctorName;
public Boolean isFollowed = false; // 是否关注
/**
* 是否开启电话倾诉
* 1.开启 2.关闭
*/
public int listenerIsOpen;
public static class paramsBuild {
//php接口此字段返回值始终为0,更换java接口后,服务端去掉了此字段,本地改动太多,先给默认值
public String orderid = "0";
}
public String tag1 = ""; //该字段是私聊改造项目新加的,用于在获取推荐专家列表的时候,catName字段
}
\ No newline at end of file
package com.yidianling.im.api.bean
/**
* 评论细节bean
*/
class ImCommendDetailBean {
var nickName: String = ""
var commentContent: String = ""
var commentUrl: String = ""
}
\ No newline at end of file
package com.yidianling.im.api.bean;
/**
* type: 消息类型
* 1、2、501 502为预约消息;
* 3、4、503、1001、1002为心事消息;
*/
public class MsgDetail {
public int id;//消息的id
public int type;//
public String content;
public String create_time;
public String image_url;//消息封面图
public String relation_id1;//关联的业务id
}
\ No newline at end of file
package com.yidianling.im.api.bean;
public class MsgReadAll {
public int update_status;
public String msg;
}
\ No newline at end of file
package com.yidianling.im.api.bean
import android.os.Parcel
import android.os.Parcelable
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/05/04
*/
data class ReceiveRedPacketParam(
var status: Int = 0,
var money: String? = null,
var name: String? = null,
var headUrl: String? = null,
var expertUrl: String? = null,
var expertName: String? = null,
var expertTime: String? = null) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readInt(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString()) {
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(status)
parcel.writeString(money)
parcel.writeString(name)
parcel.writeString(headUrl)
parcel.writeString(expertUrl)
parcel.writeString(expertName)
parcel.writeString(expertTime)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<ReceiveRedPacketParam> {
override fun createFromParcel(parcel: Parcel): ReceiveRedPacketParam {
return ReceiveRedPacketParam(parcel)
}
override fun newArray(size: Int): Array<ReceiveRedPacketParam?> {
return arrayOfNulls(size)
}
}
}
\ No newline at end of file
package com.yidianling.im.api.bean;
public class UpdateStatusBean {
public int update_status;
public String msg;
}
\ No newline at end of file
package com.yidianling.im.api.event
/**
* 账号被剔出事件
* Created by hgw on 2018/3/20.
*/
class AccountChangeEvent{
var code : Int = 0 //1表示账号被踢出,2表示需要重新登录
constructor(code: Int) {
this.code = code
}
}
\ No newline at end of file
package com.yidianling.im.api.event;
/**
* 黑名单更新通知
* Created by xiongyu on 2017/3/7.
*/
public class BlackEvent {
private boolean change;
public BlackEvent(boolean change) {
this.change = change;
}
public boolean isChange() {
return change;
}
public void setChange(boolean change) {
this.change = change;
}
}
package com.yidianling.im.api.event
/**
* Created by xj on 2019/10/25.
*/
class ImLogoutEvent()
\ No newline at end of file
package com.yidianling.im.api.event;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/12/13
*/
public class MsgPushEvent {
public String toUid;
public String headUrl;
public String content;
public String name;
@Override
public String toString() {
return "MsgPushEvent{" +
"toUid='" + toUid + '\'' +
", headUrl='" + headUrl + '\'' +
", content='" + content + '\'' +
", name='" + name + '\'' +
'}';
}
}
package com.yidianling.im.api.event
/**
* Created by haorui on 2019-12-10.
* Des:选中Tab事件
*/
class SelectTabIMEvent(var tab: Int)
package com.yidianling.im.api.event
/**
* 刷新底部导航栏角标
* Created by xj on 2019/10/23.
*/
class UpdateBottomBarUnreadNumEvent(val unreadNum: Int)
\ No newline at end of file
package com.yidianling.im.api.listener
interface ApiStringResponseCallback {
fun onUidCallback(uid: String)
}
\ No newline at end of file
package com.yidianling.im.message.param
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/03/12
*/
data class MsgDetailParam(val id: String)
\ No newline at end of file
package com.yidianling.im.message.param
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/03/12
*/
data class MsgListParam(val page: String, val type: Int)
\ No newline at end of file
package com.yidianling.im.api.param;
//消息列表 全部已读
public class ReadMsgAllParam {
public int type;
public ReadMsgAllParam(int type) {
this.type = type;
}
}
\ No newline at end of file
package com.yidianling.im.message.param
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/03/12
*/
data class ReadParam(val type: Int)
\ No newline at end of file
package com.yidianling.im.api.param;
public class RmHistoryParam {
public String toUid;//私聊对象
public int type;//1全部移除 2移除单条
public int msgId;//type为2时,要移除的消息
public RmHistoryParam(String toUid, int type) {
this.toUid = toUid;
this.type = type;
}
}
\ No newline at end of file
package com.yidianling.im.api.param;
public class RmTalkParam {
public String toUid;
public RmTalkParam(String toUid) {
super();
this.toUid = toUid;
}
}
\ No newline at end of file
package com.yidianling.im.api.param;
public class TopMessageParam {
public String to_uid;
public int act;//1置顶操作 2待定
public int val;// 1置顶,0取消置顶
public TopMessageParam(String to_uid, int act, int val) {
this.to_uid = to_uid;
this.act = act;
this.val = val;
}
}
\ No newline at end of file
package com.yidianling.im.api.service
import android.app.Activity
import android.app.Application
import android.content.Context
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.template.IProvider
import com.yidianling.im.api.bean.*
import com.yidianling.im.api.listener.ApiStringResponseCallback
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/13
*/
interface IImService : IProvider {
// 打开与小壹聊天界面
fun startP2PXiaoYi(context: Context)
// 打开私聊界面
fun startP2PSession(context: Activity, toUid: String)
// 直接打开聊天页面,不走分配导医
fun startChatBySessionId(context: Activity, toUid: String)
// 打开信息前置收集页
fun startP2PSession(context: Activity, location: Int, ffrom2: String?)
fun setAccount(account: String)
fun setChattingAccountAll()
fun setChattingAccountNone()
fun isHasUnread(): Boolean
fun login(info: IMLoginInfo, callback: IMRequestCallback<IMLoginInfo>?)
/**
* 绑定手机后,重新登录IM
*/
fun imLogin(info: IMLoginInfo)
fun logout()
fun clear()
/**
* 创建一条普通文本消息
* @param sessionId 聊天对象ID
* @param content 文本消息内容
*/
fun createTextMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>)
fun sendSubscriptionTimeMessage(
sessionId: String?,
content: String,
callback: IMRequestCallback<Void>
)
fun showSelector(activity: Activity, requestCode: Int)
fun sendTestResultMessage(
uid: String,
content: String,
title: String?,
head: String?,
url: String?,
id: Int,
share_url: String?,
callback: IMRequestCallback<Void>
)
fun startChat(context: Activity, toUid: String, flag: Int, canTalk: Int)
fun startChat(
context: Activity,
toUid: String,
flag: Int,
canTalk: Int,
isFramQingsu: Int,
isFromMessageList: Boolean
)
fun startChatCloseReplaceChat(context: Activity, toUid: String)
/**
* 根据对方uid获取未读数
*/
fun getUnReadByUid(uid: String): Int
/**
* 获取自己的所有未读数
*/
fun getAllUnReadNum(): Int
/**
* 发送自定义通知
*/
fun sendCustomNotification(
toUid: String,
content: String,
callback: IMSendCustomNotificationResultCallBack
)
/**
* 注册自定通知接收器
*/
fun registerObserveCustomNotification(callback: IMRegisterObserverCustomNotificationCallBack)
fun unregisterObserveCustomNotification(callback: IMRegisterObserverCustomNotificationCallBack)
fun getMultiMessageFragment(): Fragment
// 跳转下一个未读数
fun nextUnreadItem(fragment: Fragment): Boolean
// 判断是否存在私聊页面
fun isChatFragment(fragment: Fragment): Boolean
// 判断云信是否登录
fun isImLogin(): Boolean
// 刷新未读数
fun requestTopUnReadNumber(fragment: Fragment)
// 登录IM
fun loginIm(uid: String?, hxPwd: String?)
//注销
fun logoutAll()
// 初始化imcache
fun initImCache(mContext: Context)
// 客服
fun startKefuChat(context: Context, toUid: String, flag: Int, canTalk: Int)
//
fun startP2PSession(
mContext: Context,
userType: Int,
account: String,
toChatUsername: String,
toName: String,
head: String
)
fun updateUserHead(head: String?)
fun updateUserName(name: String?)
fun imInSetRing(bool: Boolean)
fun imInSetVibrate(bool: Boolean)
fun getUserInfoDescription(): String?
fun getEarModeKey(): String
fun getEarModeOpenType(): String
fun getEarModeIsOpen(): Boolean
fun getEarModeCloseType(): String
fun updateEarMode(bool: Boolean)
fun getChatUid(context: Context?, uid: String, callback: ApiStringResponseCallback)
fun chatScheule(
context: Activity,
userUrl: String,
docUrl: String,
dsmId: Int,
title: String,
toUid: Int
)
fun initIm(app: Application, activity: Class<out Activity>)
fun initIm(app: Application, activity: Class<out Activity>, imInitBean: IMInitConfigBean)
fun isWifiOr3G(activity: Activity): Boolean
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment