Commit ee3dbe51 by 刘鹏

Merge branch 'd/v4.3.97' into 'release'

D/v4.3.97

See merge request app_android_lib/YDL-Component!162
parents 9014f2e8 3bad977f
......@@ -53,9 +53,6 @@
<meta-data
android:name="com.ydl.component.base.DemoGlobalConfig"
android:value="ModuleConfig" />
<meta-data
android:name="com.openinstall.APP_KEY"
android:value="jz0d0s"/>
<activity
android:name="com.tencent.tauth.AuthActivity"
android:launchMode="singleTask"
......
......@@ -12,10 +12,10 @@ import android.provider.Settings
import android.util.Log
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.fm.openinstall.OpenInstall
import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper
import com.tbruyelle.rxpermissions2.RxPermissions
import com.umeng.analytics.MobclickAgent
import com.ydl.audioim.YDLavManager
import com.ydl.component.music.FragmentContainerActivity
import com.ydl.component.mvp.DemoContract
import com.ydl.component.mvp.DemoPresenter
......@@ -35,6 +35,7 @@ import com.yidianling.muse.helper.MediaPlayerManager
import com.yidianling.muse.service.MeditationWindowService
import com.yidianling.tests.home.NewTestHomeActivity
import com.yidianling.user.StatusUtils
import com.yidianling.user.api.service.IUserService
import com.yidianling.user.ui.collect.CollectSexAndBirthActivity
import com.yidianling.user.ui.login.OneKeyLoginHelp
import com.yidianling.user.widget.SecretDescriptionDialog
......@@ -84,11 +85,12 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override fun initDataAndEvent() {
EventBus.getDefault().register(this)
//线上
// YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830")
//测试
YDLavManager.instances.init(this, "13b1536698f64905a1e7e5bb978ba821")
YdlCommonRouterManager.initYdlCommonRoute(PlatformTempCommonRouteImpl())
OpenInstall.init(this);// TODO: 1/29/21 统计渠道测试
StatusUtils.isUseOpenInstall = true
// 初始化一键登录sdk
OneKeyLoginHelp.sdkInit(this, OneKeyLoginHelp.YDL_USER_APP, PhoneNumberAuthHelper.SERVICE_TYPE_LOGIN)
bindService()
......@@ -159,7 +161,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
startActivity(Intent(this, CollectSexAndBirthActivity::class.java))
}
bt_to_confide.setOnClickListener {
// YDLavManager.instances.login("1193016")
YDLavManager.instances.login(ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid)
startActivity(Intent(this, ConfideHomeActivity::class.java))
}
......
......@@ -137,7 +137,6 @@
android:id="@+id/bt_to_tests"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="测评" />
......
......@@ -5,8 +5,8 @@ ext {
ydlPublishVersion = [
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.50.21",
"m-consultant" : "0.0.60.66",
"m-confide" : "0.0.50.25",
"m-consultant" : "0.0.60.67",
"m-fm" : "0.0.30.09",
"m-user" : "0.0.62.48",
"m-home" : "0.0.23.90",
......@@ -14,7 +14,7 @@ ext {
"m-dynamic" : "0.0.7.74",
"m-article" : "0.0.0.10",
"m-muse" : "0.0.28.76",
"m-muse" : "0.0.28.78",
"m-tests" : "0.0.24.18",
"m-course" : "0.0.43.39",
......@@ -36,13 +36,14 @@ ext {
"ydl-tuicore" : "0.0.23",
//第一步
"ydl-platform" : "0.0.41.33",
"ydl-platform" : "0.0.41.39",
//第二步 若干
"ydl-webview" : "0.0.38.92",
"ydl-media" : "0.0.21.52",
"ydl-pay" : "0.0.18.19",
"m-audioim" : "0.0.49.30.15",
"m-audioim" : "0.0.49.30.18",
......@@ -93,8 +94,8 @@ ext {
ydlCompileVersion = [
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.50.21",
"m-consultant" : "0.0.60.66",
"m-confide" : "0.0.50.25",
"m-consultant" : "0.0.60.67",
"m-fm" : "0.0.30.09",
"m-user" : "0.0.62.48",
"m-home" : "0.0.23.90",
......@@ -102,7 +103,7 @@ ext {
"m-dynamic" : "0.0.7.74",
"m-article" : "0.0.0.10",
"m-muse" : "0.0.28.76",
"m-muse" : "0.0.28.78",
"m-tests" : "0.0.24.18",
"m-course" : "0.0.43.39",
......@@ -123,13 +124,13 @@ ext {
//mdt 组件
"ydl-tuicore" : "0.0.23",
//第一步
"ydl-platform" : "0.0.41.33",
"ydl-platform" : "0.0.41.39",
//第二步 若干
"ydl-webview" : "0.0.38.92",
"ydl-media" : "0.0.21.52",
"ydl-pay" : "0.0.18.19",
"m-audioim" : "0.0.49.30.15",
"m-audioim" : "0.0.49.30.18",
"ydl-flutter-base": "0.0.14.38",
//以下 几乎不会动
......
......@@ -50,7 +50,6 @@ import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.ScreenUtil
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
......@@ -396,9 +395,9 @@ class AudioHomeActivity :
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "对方离开频道")
if (totalDisposable != null) {
totalDisposable!!.dispose()
totalDisposable?.dispose()
}
handler!!.postDelayed({
handler?.postDelayed({
//另一方离开频道
updateExpertStatus(false, 1)
}, 500)
......@@ -485,7 +484,7 @@ class AudioHomeActivity :
//权限申请
requestPermission()
ActionCountUtils.record("call_phone_page", "call_phone_page_visit", "0", "1")
ActionCountUtils.record("call_phone_page", "call_phone_page_visit", listenerUid ?: "0", "1")
}
......@@ -510,21 +509,21 @@ class AudioHomeActivity :
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager?
localPowerManager = getSystemService(POWER_SERVICE) as PowerManager?
localWakeLock = localPowerManager!!.newWakeLock(
localWakeLock = localPowerManager?.newWakeLock(
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"yidianling"
)
// 获取电源管理器对象
val screenOn = localPowerManager!!.isScreenOn
if (!screenOn) {
val screenOn = localPowerManager?.isScreenOn
if (screenOn == false) {
// 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag
val wl = localPowerManager!!.newWakeLock(
val wl = localPowerManager?.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP or
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright"
)
wl.acquire(10000) // 点亮屏幕
wl.release() // 释放
wl?.acquire(10000) // 点亮屏幕
wl?.release() // 释放
}
}
......@@ -618,7 +617,8 @@ class AudioHomeActivity :
// tv_tips.text = expertTips
var time = totalDuration?.minus(remainTime!!.toInt())
tv_remain_time.text = DateUtils.formatTime((time).toString())
val timeTotal= totalDuration?.div(60);
tv_totalDuration.text="(满${timeTotal}分钟自动挂断,限24小时内拨打)"
if (!TextUtils.isEmpty(expertHeadUrl)) {
var option = SimpleImageOpConfiger()
option.errorPic = R.drawable.audioim_head_place_hold_pic
......@@ -647,10 +647,14 @@ class AudioHomeActivity :
iv_mute_on_off.setImageResource(R.drawable.audiohome_muteoff)
audio_mute_text.text = "麦克风已关"
voiceManage?.getVoiceApi()?.enableLocalAudio(false)
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "用户端点击:麦克风已关")
} else {
iv_mute_on_off.isSelected = true
iv_mute_on_off.setImageResource(R.drawable.audiohome_muteon)
audio_mute_text.text = "麦克风已开"
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "用户端点击:麦克风已开")
voiceManage?.getVoiceApi()?.enableLocalAudio(true)
}
}
......@@ -661,6 +665,8 @@ class AudioHomeActivity :
showHangUpTimeTraditionalDialog()
return@setOnClickListener
}
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "用户端点击:切换线路")
ActionCountUtils.record("call_phone_page", "call_phone_icon_click", "0", "4")
showChooseDialog(1)
......@@ -668,6 +674,8 @@ class AudioHomeActivity :
//挂断
iv_hang_up.setOnClickListener {
if (!canHangUp) {
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "用户端点击:挂断,展示提示弹窗")
showHangUpTimeOnlineDialog()
return@setOnClickListener
}
......@@ -702,19 +710,25 @@ class AudioHomeActivity :
if (iv_hands_free.isSelected) {
iv_hands_free.isSelected = false
iv_hands_free.setImageResource(R.drawable.audioim_img_hands_free_unuse)
hands_free_text.text="扬声器已关"
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "用户端点击:免提,扬声器已关")
} else {
iv_hands_free.isSelected = true
iv_hands_free.setImageResource(R.drawable.audioim_img_hands_free)
hands_free_text.text="扬声器已开"
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "用户端点击:免提,扬声器已开")
}
//已经接通
if (isConnectSuccess) {
//是否开启外放
voiceManage!!.getVoiceApi().setEnableSpeakerphone(iv_hands_free.isSelected)
voiceManage?.getVoiceApi()?.setEnableSpeakerphone(iv_hands_free.isSelected)
} else {
//未接通
if (mPlayer != null) {
mPlayer!!.switchPlayType(iv_hands_free.isSelected)
mPlayer?.switchPlayType(iv_hands_free.isSelected)
}
}
}
......@@ -814,15 +828,15 @@ class AudioHomeActivity :
}
private fun dismissHangUpTimeTraditionalDialog() {
if (mHangUpTimeTraditionalDialog != null && mHangUpTimeTraditionalDialog!!.isShowing) {
mHangUpTimeTraditionalDialog!!.dismiss()
if (mHangUpTimeTraditionalDialog != null && mHangUpTimeTraditionalDialog?.isShowing == true) {
mHangUpTimeTraditionalDialog?.dismiss()
mHangUpTimeTraditionalDialog = null
}
}
private fun dismissHangUpTimeOnlineDialog() {
if (mHangUpTimeOnlineDialog != null && mHangUpTimeOnlineDialog!!.isShowing) {
mHangUpTimeOnlineDialog!!.dismiss()
if (mHangUpTimeOnlineDialog != null && mHangUpTimeOnlineDialog?.isShowing == true) {
mHangUpTimeOnlineDialog?.dismiss()
mHangUpTimeOnlineDialog = null
}
}
......@@ -887,12 +901,12 @@ class AudioHomeActivity :
waittingStatus()
} else {
tv_change_time_counter.text = "转传统电话(${remainTime}s)"
if (mHangUpTimeTraditionalDialog != null && mHangUpTimeTraditionalDialog!!.isShowing) {
if (mHangUpTimeTraditionalDialog != null && mHangUpTimeTraditionalDialog?.isShowing == true) {
val callTime = String.format(
getString(R.string.audioim_audio_time_alarm_msg_tradition_dialog),
traditionCallTime
)
(mHangUpTimeTraditionalDialog!!.findDialogView(R.id.third_title) as TextView).text =
(mHangUpTimeTraditionalDialog?.findDialogView(R.id.third_title) as TextView).text =
callTime
}
}
......@@ -903,12 +917,12 @@ class AudioHomeActivity :
dismissHangUpTimeOnlineDialog()
} else {
audio_hangup_text.text = "挂断(${remainTime - 20}s)"
if (mHangUpTimeOnlineDialog != null && mHangUpTimeOnlineDialog!!.isShowing) {
if (mHangUpTimeOnlineDialog != null && mHangUpTimeOnlineDialog?.isShowing == true) {
val callTime = String.format(
getString(R.string.audioim_audio_time_alarm_msg_online_dialog),
onlineCallTime
)
(mHangUpTimeOnlineDialog!!.findDialogView(R.id.third_title) as TextView).text =
(mHangUpTimeOnlineDialog?.findDialogView(R.id.third_title) as TextView).text =
callTime
}
}
......@@ -990,7 +1004,7 @@ class AudioHomeActivity :
* param mRtcEventHandler 事件回调(SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
voiceManage = YDLVoiceManager(this, BuildConfig.AGORA_APPID, mRtcEventHandler)
voiceManage!!.init()
voiceManage?.init()
}
/**
......@@ -1002,7 +1016,7 @@ class AudioHomeActivity :
writeAgoraLog("对方(专家)接受了通话邀请,主叫(用户)开始加入频道:$channelId")
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "对方(专家)接受了通话邀请,主叫(用户)开始加入频道:$channelId")
voiceManage!!.getVoiceApi().joinChannel(
voiceManage?.getVoiceApi()?.joinChannel(
token!!,
channelId!!,
"Extra Optional Data",
......@@ -1036,7 +1050,7 @@ class AudioHomeActivity :
}
//通话结束或挂断时,上传日志文件
uploadLog()
handler!!.postDelayed({
handler?.postDelayed({
LogUtil.e("离开频道")
leaveChannel()
}, 100)
......@@ -1179,9 +1193,9 @@ class AudioHomeActivity :
mPlayer = AudioPlayer(this)
}
if ((Math.random() * 10 + 1).toInt() >= 5) {
mPlayer!!.setTwoDataAndStart(R.raw.audioim_audio_music_1, R.raw.audioim_loop_music)
mPlayer?.setTwoDataAndStart(R.raw.audioim_audio_music_1, R.raw.audioim_loop_music)
} else {
mPlayer!!.setTwoDataAndStart(R.raw.audioim_audio_music_2, R.raw.audioim_loop_music)
mPlayer?.setTwoDataAndStart(R.raw.audioim_audio_music_2, R.raw.audioim_loop_music)
}
}
......@@ -1192,12 +1206,12 @@ class AudioHomeActivity :
if (mPlayer == null) {
mPlayer = AudioPlayer(this)
}
mPlayer!!.setDataSource(R.raw.audioim_hand_down_music)
mPlayer!!.switchPlayType(iv_hands_free.isSelected)
mPlayer!!.setCompletionListener(MediaPlayer.OnCompletionListener {
mPlayer?.setDataSource(R.raw.audioim_hand_down_music)
mPlayer?.switchPlayType(iv_hands_free.isSelected)
mPlayer?.setCompletionListener(MediaPlayer.OnCompletionListener {
LogUtil.e("播放结束")
//通话剩余时间不足60s时,默认
if (localRemainTime!! > (totalDuration ?: 1500).minus(60) && !TextUtils.isEmpty(
if (localRemainTime!! <= 60 && !TextUtils.isEmpty(
commentUrl
)
) {
......@@ -1210,7 +1224,7 @@ class AudioHomeActivity :
}
finish()
})
mPlayer!!.start(false, true)
mPlayer?.start(false, true)
}
/**
......@@ -1218,7 +1232,7 @@ class AudioHomeActivity :
*/
private fun stopPlaying() {
if (mPlayer != null) {
mPlayer!!.pause()
mPlayer?.pause()
}
}
......@@ -1230,20 +1244,25 @@ class AudioHomeActivity :
phoneHandler?.removeCallbacksAndMessages(null)
//通知服务端,此次通话已经接通,服务端开始订单
updateExpertStatus(false, 0)
//是否开启外放
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
voiceManage?.getVoiceApi()?.setEnableSpeakerphone(false)
if (iv_mute_on_off.isSelected) {
iv_mute_on_off.setImageResource(R.drawable.audiohome_muteoff)
audio_mute_text.text = "麦克风已关"
} else {
iv_mute_on_off.isSelected = true
iv_mute_on_off.setImageResource(R.drawable.audiohome_muteon)
audio_mute_text.text = "麦克风已开"
}
hands_free_text.text="扬声器已关"
iv_hands_free.isSelected = false
iv_hands_free.setImageResource(R.drawable.audioim_img_hands_free_unuse)
// if (waitDisposable != null) {
// waitDisposable!!.dispose()
// }
if (disposable != null) {
disposable!!.dispose()
}
disposable?.dispose()
stopPlaying()
vibrator!!.vibrate(1000)
vibrator?.vibrate(1000)
//等待状态的相关ui隐藏(挂断按钮的倒计时不清除,挂断按钮必须在30s后才能点击)
tv_change_doctor.visibility = View.GONE
......@@ -1262,10 +1281,17 @@ class AudioHomeActivity :
.take(remainTime!!.toLong() + 1)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
localRemainTime =
(totalDuration ?: 1500).minus(remainTime!!.toInt()).plus(it.toInt())
localRemainTime = remainTime!!.toInt().minus(it.toInt())
if (localRemainTime!! >= (totalDuration ?: 1500).minus(60)) {
if (localRemainTime == 180) {
//三分钟语音播报
playNoticeMusic(3)
}
if (localRemainTime == 60) {
//一分钟语音播报
playNoticeMusic(1)
}
if (localRemainTime!! <=60) {
if (canChangeRoute) {
canChangeRoute = false
}
......@@ -1274,8 +1300,9 @@ class AudioHomeActivity :
}, {
LogUtil.d(it.message)
}, {
leaveChannel()
uploadLog()
callEventSave("50", "倾诉时间已用完")
YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "倾诉时间已用完")
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
showToast("通话已结束")
......@@ -1294,13 +1321,24 @@ class AudioHomeActivity :
if (mPlayer == null) {
mPlayer = AudioPlayer(this)
}
if (3 == min) {
mPlayer!!.setDataSource(R.raw.audioim_last_3_min)
} else {
mPlayer!!.setDataSource(R.raw.audioim_last_1_min)
when (min) {
0 -> {
//结束音
mPlayer?.setDataSource(R.raw.audioim_audio_out_channel)
}
1 -> {
//1分钟提示
mPlayer?.setDataSource(R.raw.audioim_last_1_min)
}
mPlayer!!.switchPlayType(iv_hands_free.isSelected)
mPlayer!!.start(false, false)
3 -> {
//3分钟提示
mPlayer?.setDataSource(R.raw.audioim_last_3_min)
}
}
mPlayer?.switchPlayType(iv_hands_free.isSelected)
mPlayer?.start(false, false)
}
/**
......@@ -1345,6 +1383,7 @@ class AudioHomeActivity :
LogUtil.e("调用leaveChannel方法,isLeavelChannel=$isLeavelChannel")
if (!isLeavelChannel) {
isLeavelChannel = true
playNoticeMusic(0)
//刷新h5页面
EventBus.getDefault().post(RefreshWebEvent(false))
stopPlaying()
......@@ -1356,9 +1395,9 @@ class AudioHomeActivity :
override fun onResume() {
super.onResume()
sensorManager!!.registerListener(
sensorManager?.registerListener(
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
sensorManager?.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL
)
ActionCountUtils.count(
......@@ -1377,14 +1416,14 @@ class AudioHomeActivity :
Sensor.TYPE_PROXIMITY -> {
if (values[0] == 0.0f) {
//贴近手机
if (!localWakeLock!!.isHeld) {
localWakeLock!!.acquire()
if (localWakeLock?.isHeld == false) {
localWakeLock?.acquire()
}
} else {
//离开手机
//唤醒设备
if (localWakeLock!!.isHeld) {
localWakeLock!!.release()
if (localWakeLock?.isHeld == true) {
localWakeLock?.release()
}
}
}
......@@ -1430,7 +1469,6 @@ class AudioHomeActivity :
}
if (status == -1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
}
tv_nte_status.visibility = View.VISIBLE
tv_nte_status.postDelayed({
......@@ -1519,33 +1557,33 @@ class AudioHomeActivity :
hasUpLoadLog = false
if (waitDisposable != null) {
waitDisposable!!.dispose()
waitDisposable?.dispose()
}
if (disposable != null) {
disposable!!.dispose()
disposable?.dispose()
}
if (totalDisposable != null) {
totalDisposable!!.dispose()
totalDisposable?.dispose()
}
if (sensorManager != null) {
sensorManager!!.unregisterListener(this)
sensorManager?.unregisterListener(this)
}
//唤醒设备
if (localWakeLock != null && localWakeLock!!.isHeld) {
localWakeLock!!.release()
localWakeLock?.release()
}
sensorManager = null
localWakeLock = null
localPowerManager = null
if (null != voiceManage && null != voiceManage!!.getVoiceApi()) {
voiceManage!!.getVoiceApi().leaveChannel()
voiceManage!!.getVoiceApi().destroy()
if (null != voiceManage && null != voiceManage?.getVoiceApi()) {
voiceManage?.getVoiceApi()?.leaveChannel()
voiceManage?.getVoiceApi()?.destroy()
voiceManage = null
}
if (mPlayer != null) {
mPlayer!!.clear()
mPlayer?.clear()
mPlayer = null
}
}
......
......@@ -4,9 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.os.Handler
import android.text.TextUtils
import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter
import com.bytedance.apm.insight.ApmInsightAgent
import com.google.gson.Gson
import com.ydl.audioim.bean.AgoraInvitationBean
import com.ydl.audioim.http.AudioApiRequestUtil
......@@ -25,6 +23,7 @@ import com.ydl.ydl_av.messge_service.callback.LoginCallback
import com.ydl.ydl_av.messge_service.request.LoginParam
import com.ydl.ydl_av.messge_service.response.CallLocalResponse
import com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.LogUtil
......@@ -43,7 +42,6 @@ import io.agora.rtm.RtmStatusCode.ConnectionChangeReason.CONNECTION_CHANGE_REASO
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import org.json.JSONObject
import java.util.*
import java.util.concurrent.TimeUnit
......@@ -326,53 +324,6 @@ class YDLavManager {
toUid: String,
content: String
) {
// LogUtil.e("[agora]收到云信的通知消息:$content")
// val agoraInvitationBean = Gson().fromJson(content, AgoraInvitationBean::class.java)
//1发起呼叫 2接受呼叫 3取消呼叫 4拒绝呼叫邀请 5呼叫超时
// when (agoraInvitationBean.callType) {
// "1" -> {
// writeAgoraLog("1收到云信消息通知电话-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
// receivedCall(agoraInvitationBean.data, "来自云信")
// }
// "2" -> {
// writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:callType${agoraInvitationBean.callType}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}",
// FILE_NAME
// )
// val act = ActivityManager.getInstance().getTopTaskActivity()
// if (act is AudioHomeActivity) {
// act.runOnUiThread {
// act.joinChannel()
// }
// }
// }
// "3" -> {
// writeAgoraLog("呼叫邀请被取消:主叫主动取消-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
// closePage()
// }
// "4" -> {
// writeAgoraLog("被叫拒绝了通话邀请-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
// val act = ActivityManager.getInstance().getTopTaskActivity()
// if (act is AudioHomeActivity) {
// act.runOnUiThread {
// ToastUtil.toastShort("对方已挂断")
// //通话结束或挂断时,上传日志文件
// act.uploadLog()
// act.leaveChannel()
// }
// }
// }
// "5" -> {
// writeAgoraLog("呼叫邀请被取消:呼叫邀请过期-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
// //关闭页面
// closePage()
// }
// else -> {
// writeAgoraLog("其它AgoraInvitationBean,${agoraInvitationBean.callType}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
// }
// }
}
})
}
......@@ -498,6 +449,7 @@ class YDLavManager {
}
override fun onFailure(msg: String?) {
Apm.reportCustom("agora_login_error", msg ?: "", Exception(msg))
LogUtil.e("[agora]实时消息登录失败:$msg")
writeAgoraLog(
"声网rtm登录失败:$msg-------Time:${
......@@ -714,6 +666,8 @@ class YDLavManager {
* https://docs.agora.io/cn/Voice/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler.html#a31b2974a574ec45e62bb768e17d1f49e
* */
override fun onConnectionStateChanged(state: Int, reason: Int) {
val msg = "state:${state},reason:${reason}"
Apm.reportCustom("agora_connectionstate_error", msg, Exception(msg))
sdkStatus = state
writeAgoraLog(
"声网rtm登录状态:${state}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}",
......
......@@ -129,6 +129,7 @@
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_totalDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_notes"
......@@ -232,7 +233,7 @@
android:layout_width="66dp"
android:layout_height="66dp"
android:layout_marginTop="1dp"
android:src="@drawable/audiohome_muteon"
android:src="@drawable/audioim_home_muteon_enable"
android:visibility="visible" />
<TextView
......@@ -302,11 +303,12 @@
android:src="@drawable/audioim_img_hands_free_unuse" />
<TextView
android:id="@+id/hands_free_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_hands_free"
android:layout_marginTop="8dp"
android:text="免提"
android:text="扬声器已关"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
......
......@@ -31,6 +31,7 @@ import com.ydl.confide.home.event.ConfideDialogEvent
import com.ydl.confide.home.http.ConfideHomeApi
import com.ydl.confide.router.PhoneCallIn
import com.ydl.utils.WebUrlParamsUtils
import com.ydl.webview.IJavascriptHandler
import com.ydl.webview.ProgressWebView
import com.ydl.webview.TellData
import com.ydl.webview.WebModularServiceUtils
......@@ -42,6 +43,7 @@ import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.service.IImService
import com.yidianling.user.api.event.UserLoginEvent
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
......@@ -75,7 +77,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
lateinit var layoutBottom: View
lateinit var itemView: View
var bottomSheet :FrameLayout?=null
var mJtoJHandle:IJavascriptHandler?=null
private var behavior: BottomSheetBehavior<*>? = null
......@@ -345,14 +347,13 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
setting.setAllowFileAccess(true)
setting.setBlockNetworkImage(false)
wv_content!!.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY //滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
val jtoJHandle = WebModularServiceUtils.getWebService()
wv_content?.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY //滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
mJtoJHandle = WebModularServiceUtils.getWebService()
.getJavascripHandler(requireActivity(), tellData = TellData())
wv_content!!.addJavascriptInterface(jtoJHandle, "javascriptHandler")
wv_content?.addJavascriptInterface(mJtoJHandle, "javascriptHandler")
// var jumpurl = "http://192.168.210.152/jy/listenMask?listenerId=257&isFromApp=1"
val url = WebUrlParamsUtils.getSuffix(jumpUrl, jtoJHandle.getUriAppendSuffix())
wv_content.loadUrl(url)
loadUrl()
// wv_content.loadUrl(jumpUrl)
wv_content.setOnTouchListener { p0, p1 -> //canScrollVertically(-1)的值表示是否能向下滚动,false表示已经滚动到顶部
......@@ -418,6 +419,11 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
}
private fun loadUrl() {
val url = WebUrlParamsUtils.getSuffix(jumpUrl, mJtoJHandle?.getUriAppendSuffix())
wv_content?.loadUrl(url)
}
private fun shouldOverridePayUrl(view: WebView, url: String): Boolean {
if (url.startsWith("weixin://")) {
return try {
......@@ -574,4 +580,8 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
wv_content.destroy()
EventBus.getDefault().unregister(this)
}
fun onEvent(event: UserLoginEvent) {
loadUrl()
}
}
\ No newline at end of file
......@@ -99,7 +99,7 @@ class ExpertIntroActivity : AppCompatActivity() {
binding.viewPager.adapter = adapter
binding.viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
adapter.onSelect(position)
adapter.onSelect(position, lastSelectPos)
if (position == data.size - 1 && lastSelectPos < position) {
loadMore()
}
......
......@@ -166,7 +166,7 @@ internal class IntroAdapter(
ijkVideoView?.pause()
}
fun onSelect(position: Int) {
fun onSelect(position: Int, lastPos:Int) {
curPos = position
onLoadDialStatus(position)
if (!ConfideNetworkUtil.isWifi(context) && !hasAgreePlayWithoutWiFi) {
......@@ -177,6 +177,15 @@ internal class IntroAdapter(
// entry.value.seekTo(0)
entry.value.start()
} else {
if (entry.key == lastPos) {
ActionCountUtils.record(
"listen_counselor_content_play_page",
"listen_counselor_content_playtime_click",
data[lastPos].confideId ?: "",
if (data[lastPos].isVideo) "1" else "2",
(entry.value.currentPosition / 1000F).toString()
)
}
entry.value.seekTo(0)
entry.value.pause()
}
......
......@@ -577,6 +577,7 @@ class ExpertSearchAdapter(
doctor.id ?: ""
)
}
onExpertClick?.onExpertClick()
//判断是否已登录
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(context, true)) {
return@setOnClickListener
......
......@@ -11,6 +11,7 @@ import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.ydl.ydlcommon.utils.DeviceTool;
import com.ydl.ydlcommon.utils.log.AliYunLogConfig;
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper;
import com.yidianling.avchatkit.common.log.LogUtil;
......@@ -543,6 +544,9 @@ public class NetworkUtil {
*/
public static String getActiveMacAddress(Context context) {
if (!DeviceTool.checkHasAgreeSecret()) {
return "";
}
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
......
......@@ -8,8 +8,6 @@ import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
import androidx.viewpager.widget.PagerAdapter;
import androidx.core.view.ViewCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
......@@ -17,6 +15,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.PagerAdapter;
import com.bumptech.glide.Glide;
import com.luck.picture.lib.photoview.PhotoView;
import com.netease.nimlib.sdk.AbortableFuture;
......@@ -31,6 +32,7 @@ import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R;
import com.yidianling.nimbase.common.ToastHelper;
import com.yidianling.nimbase.common.activity.ToolBarOptions;
......@@ -335,6 +337,22 @@ public class WatchMessagePictureActivity extends UI {
onDownloadStart(msg);
message = msg; // 下载成功之后,判断是否是同一条消息时需要使用
downloadFuture = NIMClient.getService(MsgService.class).downloadAttachment(msg, false);
downloadFuture.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
}
private boolean isOriginImageHasDownloaded(final IMMessage message) {
......
......@@ -10,7 +10,6 @@ import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.ActionBar;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.SurfaceHolder;
......@@ -23,21 +22,25 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import com.netease.nimlib.sdk.AbortableFuture;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.MsgServiceObserve;
import com.netease.nimlib.sdk.msg.attachment.VideoAttachment;
import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
import com.netease.nimlib.sdk.msg.model.AttachmentProgress;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R;
import com.yidianling.nimbase.common.ToastHelper;
import com.yidianling.nimbase.common.activity.ToolBarOptions;
import com.yidianling.nimbase.common.activity.UI;
import com.yidianling.nimbase.common.util.file.FileUtil;
import com.yidianling.nimbase.common.util.sys.TimeUtil;
import com.yidianling.im.R;
import com.yidianling.uikit.custom.config.YDLToolBarOptions;
/**
......@@ -499,6 +502,21 @@ public class WatchVideoActivity extends UI implements Callback {
// async download original image
onDownloadStart(message);
downloadFuture = NIMClient.getService(MsgService.class).downloadAttachment(message, false);
downloadFuture.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
downloading = true;
}
}
......
......@@ -4,13 +4,9 @@ import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
......@@ -30,7 +26,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.Gson;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer;
......@@ -49,28 +44,20 @@ import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.config.HttpConfig;
import com.ydl.ydlcommon.data.PlatformDataManager;
import com.ydl.ydlcommon.app.Apm;
import com.ydl.ydlcommon.data.http.RxUtils;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.ydl.ydlcommon.ui.LoadingDialogFragment;
import com.ydl.ydlcommon.utils.AnimUtils;
import com.ydl.ydlcommon.utils.LogUtil;
import com.ydl.ydlcommon.utils.NetworkParamsUtils;
import com.ydl.ydlcommon.utils.SharedPreferencesEditor;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils;
import com.ydl.ydlcommon.utils.log.AliYunLogConfig;
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper;
import com.ydl.ydlcommon.utils.log.LogHelper;
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils;
import com.ydl.ydlcommon.view.CircleImageView;
import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.ydl.ydlcommon.view.dialog.ListDialog;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.im.bean.RemoveHistory;
import com.yidianling.im.config.constants.ImConstants;
import com.yidianling.im.event.CloseBottomWebviewEvent;
import com.yidianling.im.event.MultipleAnswerBean;
import com.yidianling.im.event.MultipleSelectedEvent;
......@@ -97,7 +84,6 @@ import com.yidianling.uikit.api.NimUIKitImpl;
import com.yidianling.uikit.business.ait.AitManager;
import com.yidianling.uikit.business.session.activity.YDLBaseMessageActivity;
import com.yidianling.uikit.business.session.helper.ChatStatusCacheHelper;
import com.yidianling.uikit.business.session.helper.MessageListPanelHelper;
import com.yidianling.uikit.business.session.module.input.InputPanel;
import com.yidianling.uikit.business.session.module.list.MessageListPanelEx;
import com.yidianling.uikit.business.session.view.ChatPrivateTips;
......@@ -1336,6 +1322,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
public void onFailed(int code) {
if (msg != null) {
sendFailWithBlackList(code, msg);
Apm.INSTANCE.reportCustom("yx_sendmessage_error", "sessionId:" + msg.getSessionId(), new Exception(String.valueOf(code)));
}
}
......
......@@ -7,14 +7,15 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.provider.MediaStore;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.NIMSDK;
import com.netease.nimlib.sdk.Observer;
......@@ -40,6 +41,7 @@ import com.netease.nimlib.sdk.msg.model.TeamMessageReceipt;
import com.netease.nimlib.sdk.robot.model.RobotAttachment;
import com.netease.nimlib.sdk.team.constant.TeamMemberType;
import com.netease.nimlib.sdk.team.model.TeamMember;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion;
......@@ -838,7 +840,23 @@ public class MessageListPanelEx {
public void doOkAction() {
// 正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载
if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
NIMClient.getService(MsgService.class).downloadAttachment(message, true);
NIMClient.getService(MsgService.class).downloadAttachment(message, true)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
}
};
......@@ -1145,6 +1163,8 @@ public class MessageListPanelEx {
@Override
public void onFailed(int code) {
String sessionId = item.getSessionId();
Apm.INSTANCE.reportCustom("yx_revoke_error", "sessionId:" + sessionId, new Exception(String.valueOf(code)));
if (code == ResponseCode.RES_OVERDUE) {
ToastHelper.showToast(container.activity, R.string.im_revoke_failed);
} else {
......
......@@ -10,18 +10,20 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.attachment.AudioAttachment;
import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R;
import com.yidianling.nimbase.business.session.audio.MessageAudioControl;
import com.yidianling.nimbase.common.media.audioplayer.Playable;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.nimbase.common.util.sys.ScreenUtil;
import com.yidianling.nimbase.common.util.sys.TimeUtil;
import com.yidianling.im.R;
import com.yidianling.uikit.api.NimUIKitImpl;
/**
......@@ -71,7 +73,24 @@ public class MsgViewHolderAudio extends MsgViewHolderBase {
if (audioControl != null) {
if (message.getDirect() == MsgDirectionEnum.In && message.getAttachStatus() != AttachStatusEnum.transferred) {
if (message.getAttachStatus() == AttachStatusEnum.fail || message.getAttachStatus() == AttachStatusEnum.def) {
NIMClient.getService(MsgService.class).downloadAttachment(message, false);
NIMClient.getService(MsgService.class).downloadAttachment(message, false)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
}
return;
}
......
......@@ -13,12 +13,14 @@ import android.widget.TextView;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.NIMSDK;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R;
import com.yidianling.nimbase.common.ui.imageview.HeadImageView;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
......@@ -140,7 +142,23 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem
*/
protected void downloadAttachment() {
if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
NIMClient.getService(MsgService.class).downloadAttachment(message, true);
NIMClient.getService(MsgService.class).downloadAttachment(message, true)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
}
// 设置FrameLayout子控件的gravity参数
......
......@@ -138,40 +138,79 @@ class PlayMeditationActivity : BaseActivity() {
if (it.code.equals("200") && it.data != null) {
val module = it.data
mMediaId = module.mediaId
mediaListLink = module.playDetailUrl?:""
val mediaList = module.mediaList
if(!mediaList.isNullOrEmpty()){
val meditation = mediaList[0]
currentMeditation = meditation.copy(meditationType = mMeditationType,meditationId = mMeditationId!!)
mTitle = meditation.title
mDesc = meditation.desc?:""
mMediaUrl = meditation.mediaUrl
mMediaCoverUrl = meditation.coverImageUrl
val currentPosition = meditation.broadcastTime
mBusinessType = meditation.businessType
mBuried = meditation.buried
mStatus = meditation.status
meditations.clear()
module.mediaList?.forEach { meditationPlayBean ->
meditations.add(meditationPlayBean)
if (meditationPlayBean.mediaId == mMediaId) {
currentMeditation =
meditationPlayBean.copy(meditationType = mMeditationType,meditationId = mMeditationId!!)
mMediaId = module?.mediaId ?: 0L
mTitle = meditationPlayBean.title
mDesc = meditationPlayBean.desc ?: ""
mMediaCoverUrl = meditationPlayBean.coverImageUrl
mMediaUrl = meditationPlayBean.mediaUrl
val currentPosition = meditationPlayBean.broadcastTime
mBusinessType = meditationPlayBean.businessType
mStatus = meditationPlayBean.status
mBuried = meditationPlayBean.buried
collected = mStatus == 1
updateUI()
initMediaPlayer(
mMediaUrl,
currentPosition,
mMediaIdFromLocal == mMediaId
)
//快进点击事件
ActionCountUtils.baiDuCountSign3(
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PAGE_VISIT,
currentMeditation?.title ?: "",
mBuried ?: "",
""
)
initMediaPlayer(mMediaUrl, currentPosition,mMediaIdFromLocal == mMediaId)
}
}
// mediaListLink = module.playDetailUrl?:""
//
// val mediaList = module.mediaList
// if(!mediaList.isNullOrEmpty()){
// val meditation = mediaList[0]
//
//
//
// currentMeditation = meditation.copy(meditationType = mMeditationType,meditationId = mMeditationId!!)
// mTitle = meditation.title
// mDesc = meditation.desc?:""
// mMediaUrl = meditation.mediaUrl
// mMediaCoverUrl = meditation.coverImageUrl
// val currentPosition = meditation.broadcastTime
// mBusinessType = meditation.businessType
// mBuried = meditation.buried
// mStatus = meditation.status
//
// collected = mStatus == 1
//
// updateUI()
//
// initMediaPlayer(
// mMediaUrl,
// currentPosition,
// mMediaIdFromLocal == mMediaId
// )
//
// //快进点击事件
// ActionCountUtils.baiDuCountSign3(
// MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
// MuseBIConstants.YDL_MUSE_PLAY_PAGE_VISIT,
// currentMeditation?.title ?: "",
// mBuried ?: "",
// ""
// )
// }
}
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
......@@ -284,8 +323,6 @@ class PlayMeditationActivity : BaseActivity() {
)
if (!mediaListLink.isNullOrBlank()) {
ChooseMusicActivity.launch(this, H5Params(mediaListLink,"") )
// val chooseMusicDialog = ChooseMusicDialog(this,H5Params(mediaListLink!!, null))
// chooseMusicDialog.show()
}
}
......@@ -571,7 +608,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI(needRefresh = false)
initMediaPlayer(mMediaUrl, currentPosition, mMediaIdFromLocal == mMediaId)
initMediaPlayer(mMediaUrl, 0, mMediaIdFromLocal == mMediaId)
} else {
ToastUtil.toastShort("暂无内容")
}
......@@ -621,7 +658,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI(needRefresh = false)
initMediaPlayer(mMediaUrl, currentPosition, mMediaIdFromLocal == mMediaId)
initMediaPlayer(mMediaUrl, 0, mMediaIdFromLocal == mMediaId)
} else {
ToastUtil.toastShort("暂无内容")
}
......@@ -706,7 +743,8 @@ class PlayMeditationActivity : BaseActivity() {
})
initPlayCompletionListener()
val isLoop = MediaPlayerManager.getInstance(this@PlayMeditationActivity)?.getTimeOffStatus() == true
initPlayCompletionListener(isLoop = isLoop)
MeditationFloatPermissionUtil.checkSuspendedWindowPermission(this){
......@@ -734,30 +772,10 @@ class PlayMeditationActivity : BaseActivity() {
if (isLoop){
if (isSingle || meditations.size == 1){
MediaPlayerManager
.getInstance(this)?.setAudioPath(currentMeditation?.mediaUrl?:"",isLoop = true)
switchSound()
// MediaPlayerManager.getInstance(this)?.setAudioPath(mMediaUrl)
}else{
currentMeditationIndex = meditations.indexOf(currentMeditation)
if(currentMeditationIndex == meditations.size - 1){
currentMeditationIndex = 0
}else{
currentMeditationIndex++
}
currentMeditation = meditations[currentMeditationIndex]
val event = MeditationEvent(
currentMeditation?.mediaId?.toInt()?:0,
mMeditationId?:0L,
mMeditationType?:0,
mBusinessType,
status = mStatus,
buried = mBuried?:"",
mediaUrl = currentMeditation?.mediaUrl?:"",
mediaCoverUrl = currentMeditation?.coverImageUrl?:"",
title = currentMeditation?.title?:"",
desc = currentMeditation?.desc?:""
)
EventBus.getDefault().post(event)
switchSound()
}
}
......@@ -772,6 +790,38 @@ class PlayMeditationActivity : BaseActivity() {
mMediaPlayer?.pause()
}
}
mMediaPlayer?.setOnErrorListener { mp, what, extra -> true }
}
private fun switchSound(){
var meditation:MeditationPlayModuleBean.MeditationDetail? = null
meditations?.forEachIndexed { index, meditationDetail ->
if (meditationDetail.mediaId == mMediaId){
currentMeditationIndex = index
}
}
if (mMeditationId == null || mMediaId == null) return
if (currentMeditationIndex < meditations.size - 1) {
meditation = meditations[currentMeditationIndex + 1]
} else {
meditation = meditations[0]
}
currentMeditation = meditation.copy(meditationId = mMeditationId!!)
mMediaId = meditation.mediaId
mMediaCoverUrl = meditation.coverImageUrl
mMediaUrl = meditation.mediaUrl
mStatus = meditation.status
mTitle = meditation.title
mDesc = meditation.title
updateUI(needRefresh = false)
initMediaPlayer(mMediaUrl, 0, mMediaIdFromLocal == mMediaId)
}
private fun initMediaPlayer(path: String, current: Int, isSameOne: Boolean = false) {
......@@ -787,7 +837,7 @@ class PlayMeditationActivity : BaseActivity() {
val currentPosition = mMediaPlayer?.currentPosition
duration = mMediaPlayer?.duration ?: 0
if (current > 0) {
if (current >= 0) {
seekbar_play_progress.max = duration
seekbar_play_progress.progress = current
exo_position.text = MediaPlayerTimeUtil.calculateTime(current)
......@@ -911,6 +961,14 @@ class PlayMeditationActivity : BaseActivity() {
}
}
ActionCountUtils.baiDuCountSign3(
MuseBIConstants.YDL_MUSE_MEDITATION_MUSIC_PLAY_PAGE,
MuseBIConstants.YDL_MUSE_PLAY_PAGE_VISIT,
mTitle,
mBuried ?: "",
""
)
}
private fun initRxTimeOff(time: Long, meditationType: Int) {
......
......@@ -45,7 +45,7 @@ class MediaPlayerManager private constructor() {
mTime = time
}
fun setAudioPath(path: String,isLoop:Boolean = false){
fun setAudioPath(path: String){
val attrs = AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
......@@ -60,9 +60,6 @@ class MediaPlayerManager private constructor() {
mMediaPlayer?.prepareAsync()
mMediaPlayer?.setOnPreparedListener {
listener?.onPrepared(it)
if (isLoop){
mMediaPlayer?.seekTo(0)
}
}
}
......
......@@ -28,7 +28,7 @@ class MediaPlayerTimeUtil {
"$minute:$second"
}
}
}else if (time in 1..59){
}else if (time in 0..59){
second = time
return if (second in 0..9){
"00:0$second"
......
......@@ -13,7 +13,4 @@ public class StatusUtils {
// 是否第一次启动App
public static boolean isFirstStartApp = false;
// 是否使用openInstall
public static boolean isUseOpenInstall = false;
}
......@@ -5,7 +5,6 @@ import android.content.Intent
import android.text.TextUtils
import android.util.Log
import android.view.View
import com.fm.openinstall.OpenInstall
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.data.http.RxUtils
......@@ -32,7 +31,6 @@ import com.yidianling.user.route.UserIn
import com.yidianling.user.safePrivate.FingerPrintCheckActivity
import com.yidianling.user.safePrivate.FingerPrintUtil
import com.yidianling.user.safePrivate.HandUnlockCheckActivity
import com.yidianling.user.ui.login.OneKeyLoginHelp
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
......@@ -187,23 +185,12 @@ class SmsLoginActivity : BaseActivity() {
* 注册流程成功之后,进行百度监测 注册埋点
*/
fun baiduActionBury() {
if (OneKeyLoginHelp.openInstallKey.isNotEmpty() && StatusUtils.isUseOpenInstall) {
ActionCountUtils.baiduCount(
UserBIConstants.APP_REGISTER_PAGE,
UserBIConstants.POSITION_CODE_REGISTER_CLICK,
25,
OneKeyLoginHelp.openInstallKey
)
// 用户注册成功后调用
OpenInstall.reportRegister();
} else {
ActionCountUtils.baiduCount(
UserBIConstants.APP_REGISTER_PAGE,
UserBIConstants.POSITION_CODE_REGISTER_CLICK,
25
)
}
}
//关闭手势解锁页面与指纹解锁页面
private fun finishFinger() {
......
......@@ -11,7 +11,6 @@ import android.text.method.HideReturnsTransformationMethod
import android.text.method.PasswordTransformationMethod
import android.view.View
import android.view.animation.AnimationUtils
import com.fm.openinstall.OpenInstall
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.StatusBarUtils
......@@ -21,7 +20,6 @@ import com.yidianling.common.tools.RxKeyboardTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.LoginUtils
import com.yidianling.user.R
import com.yidianling.user.StatusUtils
import com.yidianling.user.constants.UserBIConstants
import com.yidianling.user.ui.login.contract.IInputPassWordContract
import com.yidianling.user.ui.login.presenter.InputPassWordPresenterImpl
......@@ -152,17 +150,6 @@ class InputPassWordActivity : BaseMvpActivity<IInputPassWordContract.View,IInput
UserBIConstants.POSITION_PHONE_REGISTER_CLICK,
25
)
if (OneKeyLoginHelp.openInstallKey.isNotEmpty() && StatusUtils.isUseOpenInstall) {
ActionCountUtils.baiduCount(
UserBIConstants.APP_REGISTER_PAGE,
UserBIConstants.POSITION_PHONE_REGISTER_CLICK,
25,
OneKeyLoginHelp.openInstallKey
)
// 用户注册成功后调用
OpenInstall.reportRegister();
}
}
......
......@@ -12,10 +12,7 @@ import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.fm.openinstall.OpenInstall
import com.fm.openinstall.listener.AppInstallAdapter
import com.fm.openinstall.model.AppData
import com.meituan.android.walle.WalleChannelReader
import com.blankj.utilcode.util.ToastUtils
import com.mobile.auth.gatewayauth.*
import com.mobile.auth.gatewayauth.model.TokenRet
import com.ydl.ydlcommon.base.BaseActivity
......@@ -32,6 +29,7 @@ import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.LoginUtils
import com.yidianling.user.R
import com.yidianling.user.StatusUtils
import com.yidianling.user.UserHelper
import com.yidianling.user.api.bean.UserResponseBean
......@@ -71,7 +69,6 @@ object OneKeyLoginHelp {
private var checkBoxHidden = false // 协议勾选框是否展示m-user
var mPrivacyBeforeText = "登录即代表您同意" // 隐私协议文案
private lateinit var mActivity: BaseActivity
var openInstallKey = ""
fun sdkInit(activity: BaseActivity, appType: Int, authType: Int) {
mActivity = activity
......@@ -107,9 +104,6 @@ object OneKeyLoginHelp {
if (!checkBoxHidden) {
mPrivacyBeforeText = "同意"
}
if (appType == YDL_USER_APP) {
getOpenInstallKey()
}
}
/**
......@@ -306,7 +300,8 @@ object OneKeyLoginHelp {
var loginLogo = "ic_ydl_login_logo"
var loginHeight = 40
var loginWidth = 118
var appPrivacyOneTip = "壹点灵用户使用协议"
val appName= mActivity.resources.getString(R.string.user_login_name_start)
var appPrivacyOneTip = "${appName}用户使用协议"
var appPrivacyOne = "https://h5.ydl.com/SDUserProtol"
var appPrivacyTwo = "https://m.ydl.com/Protol/yinsi"
if (mAppType == YDL_EXPERT_APP) {
......@@ -483,12 +478,8 @@ object OneKeyLoginHelp {
"",
"",
25,
openInstallKey
""
)
if (OneKeyLoginHelp.openInstallKey.isNotEmpty() && StatusUtils.isUseOpenInstall) {
// 用户注册成功后调用
OpenInstall.reportRegister()
}
} else {
ActionCountUtils.countUid(
UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK,
......@@ -545,6 +536,7 @@ object OneKeyLoginHelp {
// }
}
else -> { // 其它失败原因
ToastUtils.showShort("您的网络环境较差,请输入手机号码进行登录。")
mPhoneNumberAuthHelper?.hideLoginLoading()
// 跳转到原生登录界面
mActivity.runOnUiThread {
......@@ -595,21 +587,6 @@ object OneKeyLoginHelp {
}
/**
* CPA(CPS)推广渠道统计
* 获取安装携带的参数
* 注:1、不要在 init 之后,紧接着调用 getInstall,防止网络等问题导致 getInstall 超时,从而获取数据失败
*/
private fun getOpenInstallKey() {
OpenInstall.getInstall(object : AppInstallAdapter() {
override fun onInstall(appData: AppData) {
// 获取渠道数据 转换值同步IOS "AppData{channel='" + this.channel + '\'' + ", data='" + this.data + '\'' + '}'
openInstallKey =
appData.toString().replace("AppData", "").replace("channel", "channelCode")
}
})
}
/**
* @param isOpenDialog true: 使用弹窗展示一键登录
* false: 使用全页面展示一键登录
* @return true:登录。false:未登录
......
......@@ -13,7 +13,6 @@ import android.view.View
import android.view.animation.AnimationUtils
import androidx.core.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.fm.openinstall.OpenInstall
import com.meituan.android.walle.WalleChannelReader
import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper
import com.mobile.auth.gatewayauth.ResultCode
......@@ -56,8 +55,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.user_activity_register_and_login_bottom.*
import kotlinx.android.synthetic.main.user_activity_register_and_login_new.*
import kotlinx.android.synthetic.main.user_activity_register_and_login_new.img_reg_back
import kotlinx.android.synthetic.main.user_activity_register_and_login_new.view_lin
/**
* @author jiucheng
......@@ -160,12 +157,8 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
"",
"",
25,
OneKeyLoginHelp.openInstallKey
""
)
if (OneKeyLoginHelp.openInstallKey.isNotEmpty() && StatusUtils.isUseOpenInstall) {
// 用户注册成功后调用
OpenInstall.reportRegister();
}
}
......@@ -198,7 +191,9 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
}
private fun initView() {
val str = "壹点灵用户使用协议、隐私保护政策"
val name = resources.getString(R.string.user_login_name_start)
val str = "${name}用户使用协议、隐私保护政策"
var start = name.length
val spannableString = SpannableString(str)
spannableString.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
......@@ -217,7 +212,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
)
}
}
}, 3, 9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
}, start, start+6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
spannableString.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
......@@ -235,7 +230,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
)
}
}
}, 10, str.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
}, start + 7, str.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
tv_protocol.text = spannableString
tv_protocol.movementMethod = LinkMovementMethod.getInstance()
......@@ -494,21 +489,6 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
}
/**
* 三方登录成功后绑定手机号
*/
private fun umengLoginBindPhone(accessCode: String?) {
val param = BindPhoneJavaParam(
accessCode!!,
countryCode!!,
userPhoneNumber!!,
"",
UserHelper.getUserInfo()!!.uid!!
)
mPresenter.bindPhone(param)
}
/**
* 动画
*/
private fun startAnim() {
......
......@@ -6,13 +6,12 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import androidx.core.content.ContextCompat
import android.text.TextUtils
import android.view.View
import android.view.animation.AnimationUtils
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import com.fm.openinstall.OpenInstall
import androidx.core.content.ContextCompat
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.StatusBarUtils
......@@ -22,7 +21,6 @@ import com.yidianling.common.tools.RxKeyboardTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.LoginUtils
import com.yidianling.user.R
import com.yidianling.user.StatusUtils
import com.yidianling.user.UserHelper
import com.yidianling.user.constants.UserBIConstants
import com.yidianling.user.http.request.BindPhoneJavaParam
......@@ -271,23 +269,12 @@ class VerificationCodeActivity :
override fun baiduActionBury() {
if (StatusUtils.isUseOpenInstall) {
ActionCountUtils.baiduCount(
UserBIConstants.APP_REGISTER_PAGE,
UserBIConstants.POSITION_CODE_REGISTER_CLICK,
25,
OneKeyLoginHelp.openInstallKey
)
// 用户注册成功后调用
OpenInstall.reportRegister();
} else {
ActionCountUtils.baiduCount(
UserBIConstants.APP_REGISTER_PAGE,
UserBIConstants.POSITION_CODE_REGISTER_CLICK,
25
)
}
}
override fun verificationErrorCode() {
//验证码异常回调
......
......@@ -3,7 +3,6 @@ package com.yidianling.user.ui.login.presenter
import android.annotation.SuppressLint
import android.app.Activity
import android.text.TextUtils
import com.fm.openinstall.OpenInstall
import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.router.YdlCommonOut
......@@ -230,7 +229,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
"",
"",
25,
OneKeyLoginHelp.openInstallKey
""
)
} else {
mView.baiduActionBury(
......@@ -244,11 +243,9 @@ class LoginPresenterImpl(view: ILoginContract.View) :
"",
"",
25,
OneKeyLoginHelp.openInstallKey
""
)
}
// 用户注册成功后调用
OpenInstall.reportRegister()
} else {
ActionCountUtils.countUid(
UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK,
......
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ResourceName">
<string name="user_login_name_start">心理咨询</string>
</resources>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ResourceName">
<string name="user_login_name_start">壹点灵</string>
</resources>
package com.ydl.ydlcommon.app
import android.content.Context
import com.apm.insight.MonitorCrash
import com.apm.insight.log.VLog
import com.bytedance.apm.insight.ApmInsight
import com.bytedance.apm.insight.ApmInsightInitConfig
import com.bytedance.apm.insight.IDynamicParams
import com.meituan.android.walle.WalleChannelReader
object Apm {
private var crash: MonitorCrash? = null
fun initApm(context: Context, appId: String, vCode: Long, vName: String, debug: Boolean, uidCall: () -> String?) {
val channel = if (debug) "debug" else WalleChannelReader.getChannel(context)
crash = MonitorCrash.init(
context,
appId,
vCode,
vName
)
crash?.config()?.setChannel(channel)
val builder = ApmInsightInitConfig.builder()
.aid(appId)
//.batteryMonitor(true)
//.cpuMonitor(true)
//.fpsMonitor(true)
//.seriousBlockDetect(true)
.blockDetect(true)
// .enableWebViewMonitor(true)
.channel(channel)
.debugMode(debug)
.enableLogRecovery(true)
.setDynamicParams(ApmParams(crash, uidCall))
ApmInsight.getInstance().init(context, builder.build())
VLog.init(context, 20)
}
fun reportCustom(type: String, msg: String, throwable: Throwable) {
crash?.reportCustomErr(msg, type, throwable)
}
}
private class ApmParams(val crash: MonitorCrash?, val uidCall: () -> String?) : IDynamicParams() {
override fun getUserUniqueID(): String? {
return null
}
override fun getAbSdkVersion(): String? {
return null
}
override fun getSsid(): String? {
return null
}
override fun getDid(): String? {
return null
}
override fun getUserId(): String? {
val uid = uidCall.invoke()
crash?.config()?.setUID(uid)
return uid
}
}
\ No newline at end of file
......@@ -4,7 +4,9 @@ import android.annotation.SuppressLint
import android.content.Context
import android.text.TextUtils
import com.facebook.stetho.okhttp3.StethoInterceptor
import com.google.gson.Gson
import com.ydl.pushserver.pushagent.YdlPushAgent
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.bean.AuthBean
import com.ydl.ydlcommon.bean.GatewayRequestDTO
......@@ -15,6 +17,7 @@ import com.ydl.ydlcommon.data.http.GsonProvider
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.api.ApiRequestUtil
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
......@@ -23,7 +26,6 @@ import com.ydl.ydlnet.builder.config.OkHttpConfig
import com.ydl.ydlnet.builder.factory.ApiFactory
import com.ydl.ydlnet.builder.interceptor.log.RequestHandler
import com.ydl.ydlnet.builder.interceptor.log.RequestLogInterceptor
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.ToastUtil
......@@ -31,6 +33,8 @@ import io.reactivex.functions.Action
import okhttp3.*
import okio.Buffer
import okio.BufferedSink
import java.io.EOFException
import java.nio.charset.Charset
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
......@@ -141,7 +145,8 @@ class HttpConfig {
commonParams(),
requestHead(appName),
addEncryptionHeaderParamsInterceptor(),
responseErrorInterceptor()
responseErrorInterceptor(),
respErrorInterceptor()
)
.setRequestHandler(getRequestHandler())
.setReadTimeout(15)
......@@ -183,6 +188,53 @@ class HttpConfig {
}
}
private fun respErrorInterceptor(): Interceptor {
return Interceptor {
val req = it.request()
val resp = it.proceed(req)
if (appDebug) return@Interceptor resp
val code = resp.code()
val message = resp.message()
val api = req.url().encodedPath()
if (!resp.isSuccessful) {
Apm.reportCustom("network_request_error", "${api}(${code},${message})", Exception("${api}(${code},${message})"))
} else {
try {
val body = resp.body() ?: return@Interceptor resp
val buffer = body.source().buffer()
if(!isPlaintext(buffer)) return@Interceptor resp
val readString = buffer.clone().readString(Charset.forName("UTF-8"))
val fromJson = Gson().fromJson<BaseAPIResponse<Any>>(readString, BaseAPIResponse::class.java)
if (fromJson.code != "200") {
Apm.reportCustom("network_business_error", "${api}(${fromJson.code},${fromJson.msg})", Exception("${api}(${fromJson.code},${fromJson.msg})"))
}
} catch (throwable: Throwable) {
LogUtil.e(throwable.message)
}
}
return@Interceptor resp
}
}
private fun isPlaintext(buffer: Buffer): Boolean {
return try {
val prefix = Buffer()
val byteCount = if (buffer.size() < 64L) buffer.size() else 64L
buffer.copyTo(prefix, 0L, byteCount)
var i = 0
while (i < 16 && !prefix.exhausted()) {
val codePoint = prefix.readUtf8CodePoint()
if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) {
return false
}
++i
}
true
} catch (var6: EOFException) {
false
}
}
/**
* 接口返回错误日志埋点
*/
......
......@@ -122,7 +122,9 @@ public class DeviceTool {
@SuppressLint("MissingPermission")
public static final String getIMEI() {
Activity topTaskActivity = ActivityManager.Companion.getInstance().getTopTaskActivity();
if (!checkHasAgreeSecret()) {
return "";
}
try {
String imei = "";
RxPermissions rxPermissions = new RxPermissions(topTaskActivity);
......@@ -147,9 +149,19 @@ public class DeviceTool {
}
}
/**
* 检查是否同意隐私协议
* */
public static boolean checkHasAgreeSecret() {
String hasAgreeSecret = SharedPreferencesEditor.getString("hasAgreeSecret");
return "true".equals(hasAgreeSecret);
}
public static String getEncryptionAndroidID() {
if (!checkHasAgreeSecret()) {
return "";
}
try {
@SuppressLint("HardwareIds") String id = Settings.Secure.getString(
RxTool.getContext().getContentResolver(),
......@@ -161,6 +173,9 @@ public class DeviceTool {
}
}
public static String getAndroidID() {
if (!checkHasAgreeSecret()) {
return "";
}
try {
@SuppressLint("HardwareIds") String id = Settings.Secure.getString(
RxTool.getContext().getContentResolver(),
......@@ -251,7 +266,9 @@ public class DeviceTool {
}
public static String getMac(Context context) {
if (!checkHasAgreeSecret()) {
return "02:00:00:00:00:00";
}
String strMac = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
......@@ -281,6 +298,9 @@ public class DeviceTool {
*GPRS链接和WIFI链接返回同一个MAC地址
* */
public static String getMacFromHardware() {
if (!checkHasAgreeSecret()) {
return "02:00:00:00:00:00";
}
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
......@@ -328,6 +348,9 @@ public class DeviceTool {
* @return
*/
public static String getLocalWifiIpAddress(Context context) {
if (!checkHasAgreeSecret()) {
return "隐私协议未同意,不让获取";
}
try {
WifiManager wifiManager = (WifiManager) context
......@@ -343,6 +366,9 @@ public class DeviceTool {
//GPRS连接下的ip
public static String getLocalGPRSIpAddress() {
if (!checkHasAgreeSecret()) {
return null;
}
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface intf = en.nextElement();
......@@ -364,6 +390,9 @@ public class DeviceTool {
* @return
*/
public static String getNewMac() {
if (!checkHasAgreeSecret()) {
return null;
}
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
......@@ -390,6 +419,9 @@ public class DeviceTool {
return null;
}
public static String getLocalMacAddressFromWifiInfo(Context context) {
if (!checkHasAgreeSecret()) {
return null;
}
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo winfo = wifi.getConnectionInfo();
String mac = winfo.getMacAddress();
......@@ -400,6 +432,9 @@ public class DeviceTool {
* 获取IPV6地址
* */
public static String getLocalIpV6() {
if (!checkHasAgreeSecret()) {
return null;
}
try {
for (Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements(); ) {
......@@ -425,7 +460,9 @@ public class DeviceTool {
return null;
}
public static String getMacAddress(Context context) {
if (!checkHasAgreeSecret()) {
return null;
}
// 如果是6.0以下,直接通过wifimanager获取
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
String macAddress0 = getMacAddress0(context);
......@@ -465,6 +502,10 @@ public class DeviceTool {
}
private static String getMacAddress0(Context context) {
if (!checkHasAgreeSecret()) {
return null;
}
if (isAccessWifiStateAuthorized(context)) {
WifiManager wifiMgr = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
......@@ -494,9 +535,10 @@ public class DeviceTool {
Log.e("----->" + "NetInfoManager", "isAccessWifiStateAuthorized:"
+ "access wifi state is enabled");
return true;
} else
} else {
return false;
}
}
private static String loadFileAsString(String fileName) throws Exception {
FileReader reader = new FileReader(fileName);
......@@ -522,6 +564,9 @@ public class DeviceTool {
* @return
*/
public static String getMacAddress() {
if (!checkHasAgreeSecret()) {
return null;
}
String strMacAddr = null;
try {
// 获得IpD地址
......@@ -547,6 +592,9 @@ public class DeviceTool {
* @return
*/
private static InetAddress getLocalInetAddress() {
if (!checkHasAgreeSecret()) {
return null;
}
InetAddress ip = null;
try {
// 列举
......@@ -582,6 +630,9 @@ public class DeviceTool {
* @return
*/
public static String getLocalIpAddress() {
if (!checkHasAgreeSecret()) {
return null;
}
try {
for (Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements(); ) {
......@@ -601,6 +652,9 @@ public class DeviceTool {
}
public static String getMachineHardwareAddress() {
if (!checkHasAgreeSecret()) {
return null;
}
Enumeration<NetworkInterface> interfaces = null;
try {
interfaces = NetworkInterface.getNetworkInterfaces();
......@@ -646,6 +700,9 @@ public class DeviceTool {
}
public static String getLocalMacAddressFromBusybox() {
if (!checkHasAgreeSecret()) {
return "";
}
String result = "";
String Mac = "";
result = callCmd("busybox ifconfig", "HWaddr");
......
......@@ -434,6 +434,10 @@ class ActionCountUtils {
* @return
*/
fun getIpAddress(context: Context): String {
if (!DeviceTool.checkHasAgreeSecret()) {
return ""
}
// 获取WiFi服务
val wifiManager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
// 判断WiFi是否开启
......
......@@ -3,7 +3,6 @@ package com.ydl.webview;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
......@@ -35,7 +34,6 @@ import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.ydl.event.ReloadUrlEvent;
import com.ydl.utils.PopUtils;
import com.ydl.utils.ProxyCheckUtils;
import com.ydl.utils.WebUrlParamsUtils;
......@@ -534,7 +532,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
public void openShareMenu(H5JsBean.H5JsCmd.Params params) {
if (params.getShare() != null) {
if (params.getShare().getType().equals("Meditation")){
if ("Meditation".equals(params.getShare().getType())){
shareUrl = params.getShare().getShare_url();
shareTitle = params.getShare().getTitle();
shareDesc = params.getShare().getDesc();
......@@ -1388,7 +1386,6 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
super.onDestroy();
cancelSendNetLossMessage();
EventBus.getDefault().unregister(this);
super.onDestroy();
if (wv_content != null) {
wv_content.destroy();
}
......
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