Commit 220aae18 by YKai

feat: audioim和m-confide组件耦合拆分

parent c51351ef
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../publish.gradle"
android {
compileSdk 32
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdk 21
targetSdk 32
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
......@@ -31,10 +29,6 @@ android {
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
package com.ydl.audioim.api
import android.app.Activity
import android.content.Context
import com.alibaba.android.arouter.facade.template.IProvider
/**
* Created by Ykai on 2022/7/26.
*/
interface IAudioImService : IProvider{
/**
* YDLavManager初始化方法
*/
fun yDLAvManagerInit(context: Context, appId: String)
/**
* 获取rtm是否在线
*/
fun getIsOnlineRtm(): Boolean
/**
* rtm登录返回并登录状态
*/
fun loginRtm(userId:String?,event: (isSuccess: Boolean, msg: String?) -> Unit)
/**
* rtm登录
*/
fun loginRtm(userId:String?)
/**
* 拨打语音电话转axb弹窗
*/
fun openAxbDialog(activity: Activity?, type:Int, phoneNumber: String?)
/**
* 事件上报
*/
fun callEventSave(status: String, res: String, session: String?, line: String)
}
\ No newline at end of file
......@@ -75,4 +75,5 @@ dependencies {
api project(':ydl-webview')
implementation project(":api:user")
implementation project(":api:im")
implementation project(":api:audioim")
}
......@@ -32,6 +32,7 @@ import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand
import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.listener.IntentConstants
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.router.AudioImIn
......
package com.ydl.audioim;
/**
* @author jiucheng
* @描述:页面参数传递常量
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/7
*/
public interface IntentConstants {
String INTENT_EXPERT_HEAD_URL = "intent_expert_head_url";
String INTENT_EXPERT_NAME = "intent_expert_name";
String INTENT_EXPERT_TIPS = "intent_expert_tips";
String INTENT_ROOM_ID = "intent_room_id";
String INTENT_REMAIN_TIME = "intent_remain_time";
String INTENT_RELATION_ID = "intent_relation_id";
String INTENT_CALL_ID = "INTENT_CALL_ID";
String INTENT_TOKEN = "intent_token";
String INTENT_SIGNAL_TOKEN= "intent_signal_token";
String INTENT_LISTENER_UID= "intent_listener_uid";
String INTENT_TOTAL_DURATION= "intent_total_duration";
String INTENT_LISTEN_ID= "intent_listen_id";
String INTENT_COMMENT_URL= "intent_comment_url";
String INTENT_ISSHOWAXB= "intent_isshowaxb";
String INTENT_DIALSTATUS="intent_dialstatus";
}
......@@ -398,7 +398,7 @@ class YDLavManager {
@SuppressLint("CheckResult")
fun login(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
if (TextUtils.isEmpty(userId) || userId ?: "0" <= "0") {
if (TextUtils.isEmpty(userId) || (userId ?: "0") <= "0") {
//如果uid为空或小于等于0 ,则不进行登录,因为uid为0也会登录成功,会导致后面uid正确时无法登录
LogUtil.e("[agora]login-uid:$userId")
AliYunRichLogsHelper.getInstance()
......
package com.ydl.audioim.bean;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/10
*/
public class ExpertInfoBean {
public String expertHeadUrl;
public String expertName;
public String expertTips;
public String token;
public String signalToken;
public String listenerUid;
public int listenerStatus;
public String listenerIsOpen;
public String listenOrderStatus;
public String channelId;
public ExpertInfoBean.ListenRemainingTime remainingTime;
public String totalDuration;
public String commentUrl;
public ExpertInfoBean() {
}
public static class ListenRemainingTime {
public String remainingTime;
public ListenRemainingTime() {
}
public ListenRemainingTime(String remainingTime) {
this.remainingTime = remainingTime;
}
}
}
package com.ydl.audioim.modular
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.audioim.widget.AxbConfirmDialog
/**
* Created by Ykai on 2022/7/26.
*/
@Route(path = "/audioim/AudioImService")
class AudioImServiceImp : IAudioImService {
override fun yDLAvManagerInit(context: Context, appId: String) {
YDLavManager.instances.init(context, appId)
}
override fun getIsOnlineRtm(): Boolean {
return YDLavManager.isOnlineRtm
}
override fun loginRtm(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
YDLavManager.instances.login(userId) { success: Boolean, _ ->
event(success, "")
}
}
override fun loginRtm(userId: String?) {
YDLavManager.instances.login(userId)
}
override fun openAxbDialog(activity: Activity?, type: Int, phoneNumber: String?) {
val dialog = AxbConfirmDialog(activity, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
phoneNumber?.let {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$phoneNumber"))
activity?.startActivity(phoneIntent)
}
}
override fun onClose() {
}
})
dialog.show()
}
override fun callEventSave(status: String, res: String, session: String?, line: String) {
YDLavManager.instances.callEventSave(status, res, session, line)
}
override fun init(context: Context?) {
}
}
\ No newline at end of file
# 声网module
\ No newline at end of file
......@@ -71,10 +71,10 @@ dependencies {
api rootProject.ext.dependencies["ydl-user-router"]
api project(':ydl-media')
api project(':ydl-platform')
api project(':m-audioim')
api project(":ydl-pay")
api project(':ydl-webview')
api project(':ydl-utils')
implementation project(":api:audioim")
implementation project(":api:im")
implementation project(":api:user")
implementation project(":api:consultant")
......
package com.ydl.confide.home
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
......@@ -24,7 +25,7 @@ import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.interfaces.DraweeController
import com.jcodecraeer.xrecyclerview.ProgressStyle
import com.jcodecraeer.xrecyclerview.XRecyclerView
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.home.adapter.ConfideHomeAdapter
......@@ -51,6 +52,7 @@ import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.listener.YDLImageRecyclerOnScrollListener
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.base.config.HttpConfig.Companion.YDL_H5
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
import com.ydl.ydlcommon.router.IYDLRouterConstant
......@@ -60,6 +62,7 @@ import com.ydl.ydlcommon.view.DrawableRightTextView
import com.ydl.ydlcommon.view.WrapContentLinearLayoutManager
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.im.api.service.IImService
import com.yidianling.user.api.service.IUserService
import kotlinx.android.synthetic.main.confide_home_activity.*
......@@ -248,10 +251,8 @@ class ConfideHomeActivity :
}
if (!confidedId.isNullOrBlank() && !doctorId.isNullOrBlank()) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(
PhoneCallIn.getUserService().getUserInfo()?.uid
) { _: Boolean, _ ->
if (!ModularServiceManager.provide(IAudioImService::class.java).getIsOnlineRtm()) {
ModularServiceManager.provide(IAudioImService::class.java).loginRtm(PhoneCallIn.getUserService().getUserInfo()?.uid) { _: Boolean, _ ->
showPayOrDetail(confidedId, doctorId)
}
} else {
......
......@@ -4,14 +4,12 @@ import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.api.IConfideService
import com.ydl.confide.home.ConfideBottomSheetDialogFragment
import com.ydl.confide.home.ConfideHomeActivity
......@@ -20,6 +18,7 @@ import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.webview.TellData
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.YDLCacheUtils
/**
......@@ -73,7 +72,7 @@ class ConfdieServiceImpl : IConfideService {
override fun ydlAvManagerLogin(uid: String?) {
YDLavManager.instances.login(uid)
ModularServiceManager.provide(IAudioImService::class.java).loginRtm(uid)
}
override fun startCondifeHomePage(context: Context, isSplash: Boolean) {
......@@ -91,17 +90,17 @@ class ConfdieServiceImpl : IConfideService {
//debug包根据url判断使用正式或者测试key
val cacheAppEnv = YDLCacheUtils.getCacheApi()
if (!TextUtils.isEmpty(cacheAppEnv)) {
avManagerKey = if (!TextUtils.isEmpty(cacheAppEnv)) {
if (YDLConstants.ENV_TEST == cacheAppEnv) {
avManagerKey = "13b1536698f64905a1e7e5bb978ba821"
"13b1536698f64905a1e7e5bb978ba821"
} else {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
"3387e9b251f3491e9221a9877e8f7830"
}
} else {
if (YDLConstants.ENV_TEST == appEnv || YDLConstants.ENV_AUTO_TEST == appEnv) {
avManagerKey = "13b1536698f64905a1e7e5bb978ba821"
"13b1536698f64905a1e7e5bb978ba821"
} else {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
"3387e9b251f3491e9221a9877e8f7830"
}
}
} else {
......@@ -109,27 +108,15 @@ class ConfdieServiceImpl : IConfideService {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
}
YDLavManager.instances.init(app, avManagerKey)
ModularServiceManager.provide(IAudioImService::class.java).yDLAvManagerInit(app,avManagerKey)
}
override fun isOnlineRtm(): Boolean {
return YDLavManager.isOnlineRtm
return ModularServiceManager.provide(IAudioImService::class.java).getIsOnlineRtm()
}
override fun showAxbConfirmDialog(activity: Activity?, type: Int, phoneNumber: String?) {
val dialog = AxbConfirmDialog(activity, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
phoneNumber?.let {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber!!))
activity?.startActivity(phoneIntent)
}
}
override fun onClose() {
}
})
dialog.show()
ModularServiceManager.provide(IAudioImService::class.java).openAxbDialog(activity,type,phoneNumber)
}
override fun closePlayer() {
......
......@@ -3,15 +3,12 @@ package com.ydl.confide.home.modular.service
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.audioim.bean.ExpertInfoBean
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.listener.IntentConstants
import com.ydl.confide.home.ConfidePermissionDialog
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConnectParamJava
......@@ -21,6 +18,7 @@ import com.ydl.confide.router.PhoneCallIn
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.TellData
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.ui.Loading
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
......@@ -109,7 +107,7 @@ class ConfideWebServiceImpl {
data: ConfideConnectResponse?
) {
val expertInfo = data?.dialDetail?.agoraExpertInfo ?: return
if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线
if (!ModularServiceManager.provide(IAudioImService::class.java).getIsOnlineRtm()) { // 判断如果账号在其它设备登录rtm是否在线
ToastUtil.toastShort("网络通话错误代码001")
return
}
......@@ -128,21 +126,9 @@ class ConfideWebServiceImpl {
* axb 通话
* */
fun axb(activity: Activity, phone: String?) {
if (phone.isNullOrEmpty()) return
val dialog = AxbConfirmDialog(
activity,
1,
object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:${phone}"))
activity.startActivity(phoneIntent)
}
override fun onClose() {
}
})
dialog.show()
if (phone.isNullOrEmpty())
return
ModularServiceManager.provide(IAudioImService::class.java).openAxbDialog(activity,1,phone)
}
//java版axb和声网接口
......@@ -154,8 +140,8 @@ class ConfideWebServiceImpl {
tellData: TellData?,
callType: String?
) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(PhoneCallIn.getUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (!ModularServiceManager.provide(IAudioImService::class.java).getIsOnlineRtm()) {
ModularServiceManager.provide(IAudioImService::class.java).loginRtm(PhoneCallIn.getUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
toDial(id, type, callType, activity, tellData)
} else {
......@@ -340,7 +326,7 @@ class ConfideWebServiceImpl {
expertInfo.remainingTime =
ExpertInfoBean.ListenRemainingTime(expertInfo.totalDuration);
}
YDLavManager.instances.callEventSave("10", "用户点击拨打", expertInfo.channelId, "7")
ModularServiceManager.provide(IAudioImService::class.java).callEventSave("10","用户点击拨打",expertInfo.channelId, "7")
Loading.close()
ARouter.getInstance().build("/av/AudioHomeActivity")
.withString(IntentConstants.INTENT_EXPERT_HEAD_URL, expertInfo.expertHeadUrl)
......
......@@ -16,7 +16,7 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.dou361.ijkplayer.widget.IjkVideoView
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.interfaces.DraweeController
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.databinding.ItemExpertIntroBinding
......@@ -27,6 +27,7 @@ import com.ydl.confide.router.PhoneCallIn
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
......@@ -123,8 +124,8 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
else -> {
if (!item.confideId.isNullOrBlank()) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(
if (!ModularServiceManager.provide(IAudioImService::class.java).getIsOnlineRtm()) {
ModularServiceManager.provide(IAudioImService::class.java).loginRtm(
PhoneCallIn.getUserService().getUserInfo()?.uid
) { _: Boolean, _ ->
showPayOrDetail(item, it)
......
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