Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
dddefaaa
Commit
dddefaaa
authored
Dec 27, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:im升级
parent
c1c5a75c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
168 additions
and
10 deletions
+168
-10
config.gradle
config.gradle
+2
-2
AVChatKit.java
m-im/src/main/java/com/yidianling/avchatkit/AVChatKit.java
+16
-2
AVChatProfile.java
m-im/src/main/java/com/yidianling/avchatkit/AVChatProfile.java
+64
-0
AVChatActivity.java
m-im/src/main/java/com/yidianling/avchatkit/activity/AVChatActivity.java
+15
-0
AVChatNotification.java
m-im/src/main/java/com/yidianling/avchatkit/notification/AVChatNotification.java
+68
-5
avchat_imcoming_call.png
m-im/src/main/res/drawable-hdpi/avchat_imcoming_call.png
+0
-0
avchat_no_pickup.webp
m-im/src/main/res/drawable-hdpi/avchat_no_pickup.webp
+0
-0
strings.xml
m-im/src/main/res/values/strings.xml
+3
-1
No files found.
config.gradle
View file @
dddefaaa
...
...
@@ -10,7 +10,7 @@ ext {
"m-fm"
:
"0.0.30.04"
,
"m-user"
:
"0.0.61.82"
,
"m-home"
:
"0.0.22.84"
,
"m-im"
:
"0.0.20.
07
"
,
"m-im"
:
"0.0.20.
74
"
,
"m-dynamic"
:
"0.0.7.35"
,
"m-article"
:
"0.0.0.10"
,
...
...
@@ -93,7 +93,7 @@ ext {
"m-fm"
:
"0.0.30.07"
,
"m-user"
:
"0.0.61.82"
,
"m-home"
:
"0.0.22.83"
,
"m-im"
:
"0.0.20.
07
"
,
"m-im"
:
"0.0.20.
74
"
,
"m-dynamic"
:
"0.0.7.35"
,
"m-article"
:
"0.0.0.8"
,
...
...
m-im/src/main/java/com/yidianling/avchatkit/AVChatKit.java
View file @
dddefaaa
...
...
@@ -5,9 +5,12 @@ import android.content.Context;
import
android.util.Log
;
import
android.util.SparseArray
;
import
androidx.annotation.NonNull
;
import
com.netease.nimlib.sdk.Observer
;
import
com.netease.nimlib.sdk.avchat.AVChatManager
;
import
com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand
;
import
com.netease.nimlib.sdk.avchat.model.AVChatCommonEvent
;
import
com.netease.nimlib.sdk.avchat.model.AVChatData
;
import
com.ydl.ydlcommon.base.BaseActivityMgr
;
import
com.ydl.ydlcommon.utils.log.AliYunLogConfig
;
...
...
@@ -175,8 +178,19 @@ public class AVChatKit {
*/
private
static
void
registerAVChatIncomingCallObserver
(
boolean
register
)
{
AVChatManager
.
getInstance
().
observeIncomingCall
(
inComingCallObserver
,
register
);
AVChatManager
.
getInstance
().
observeHangUpNotification
(
callHangupObserver
,
register
);
}
// 通话过程中,收到对方挂断电话
@NonNull
private
static
Observer
<
AVChatCommonEvent
>
callHangupObserver
=
new
Observer
<
AVChatCommonEvent
>()
{
@Override
public
void
onEvent
(
AVChatCommonEvent
avChatHangUpInfo
)
{
if
(
AVChatProfile
.
getInstance
().
isBackgroundIncomingCall
(
avChatHangUpInfo
.
getAccount
()))
{
AVChatProfile
.
getInstance
().
setAVChatting
(
false
);
AVChatProfile
.
getInstance
().
removeBackgroundIncomingCall
(
true
);
}
}
};
private
static
Observer
<
AVChatData
>
inComingCallObserver
=
new
Observer
<
AVChatData
>()
{
@Override
public
void
onEvent
(
final
AVChatData
data
)
{
...
...
@@ -195,7 +209,7 @@ public class AVChatKit {
}
// 有网络来电打开AVChatActivity
AVChatProfile
.
getInstance
().
setAVChatting
(
true
);
AVChatProfile
.
getInstance
().
launch
Activity
(
data
,
userInfoProvider
.
getUserDisplayName
(
data
.
getAccount
()),
AVChatActivity
.
FROM_BROADCASTRECEIVER
);
AVChatProfile
.
getInstance
().
launch
IncomingCall
(
data
,
userInfoProvider
.
getUserDisplayName
(
data
.
getAccount
()),
AVChatActivity
.
FROM_BROADCASTRECEIVER
);
}
};
...
...
m-im/src/main/java/com/yidianling/avchatkit/AVChatProfile.java
View file @
dddefaaa
package
com
.
yidianling
.
avchatkit
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Intent
;
import
android.os.Handler
;
import
android.text.TextUtils
;
import
androidx.annotation.Nullable
;
import
androidx.core.app.NotificationCompat
;
import
com.netease.nimlib.sdk.avchat.model.AVChatData
;
import
com.yidianling.avchatkit.activity.AVChatActivity
;
import
com.yidianling.avchatkit.common.Handlers
;
import
com.yidianling.avchatkit.notification.AVChatNotification
;
/**
* Created by huangjun on 2015/5/12.
...
...
@@ -14,6 +22,62 @@ public class AVChatProfile {
private
final
String
TAG
=
"AVChatProfile"
;
private
boolean
isAVChatting
=
false
;
// 是否正在音视频通话
private
NotificationManager
notificationManager
;
@Nullable
private
AVChatData
backgroundIncomingCallData
;
@Nullable
private
AVChatNotification
backgroundIncomingCallNotification
;
public
boolean
isBackgroundIncomingCall
(
String
account
)
{
if
(
backgroundIncomingCallData
==
null
)
{
return
false
;
}
return
TextUtils
.
equals
(
backgroundIncomingCallData
.
getAccount
(),
account
);
}
public
void
removeBackgroundIncomingCall
(
boolean
activeMissCall
)
{
backgroundIncomingCallData
=
null
;
if
(
backgroundIncomingCallNotification
!=
null
)
{
backgroundIncomingCallNotification
.
activeIncomingCallNotification
(
false
,
null
);
if
(
activeMissCall
)
{
backgroundIncomingCallNotification
.
activeMissCallNotification
(
true
);
}
backgroundIncomingCallNotification
=
null
;
}
}
public
void
launchIncomingCall
(
final
AVChatData
data
,
final
String
displayName
,
final
int
source
)
{
Runnable
runnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && AppForegroundWatcherCompat.isBackground()) {
backgroundIncomingCallData = data;
backgroundIncomingCallNotification = new AVChatNotification(AVChatKit.getContext());
backgroundIncomingCallNotification.init(data.getAccount(), displayName);
backgroundIncomingCallNotification.activeIncomingCallNotification(true, backgroundIncomingCallData);
} else {
// 启动,如果 task正在启动,则稍等一下
if (AVChatKit.isMainTaskLaunching()) {
launchIncomingCall(data, displayName, source);
} else {
launchActivityTimeout();
AVChatActivity.incomingCall(AVChatKit.getContext(), data, displayName, source);
}}*/
// 启动,如果 task正在启动,则稍等一下
if
(
AVChatKit
.
isMainTaskLaunching
())
{
launchIncomingCall
(
data
,
displayName
,
source
);
}
else
{
launchActivityTimeout
();
AVChatActivity
.
incomingCall
(
AVChatKit
.
getContext
(),
data
,
displayName
,
source
);
AVChatActivity
.
incomingCall
(
AVChatKit
.
getContext
(),
data
,
displayName
,
source
);
}
}
};
Handlers
.
sharedHandler
(
AVChatKit
.
getContext
()).
postDelayed
(
runnable
,
200
);
}
public
static
AVChatProfile
getInstance
()
{
return
InstanceHolder
.
instance
;
...
...
m-im/src/main/java/com/yidianling/avchatkit/activity/AVChatActivity.java
View file @
dddefaaa
...
...
@@ -9,6 +9,8 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.WindowManager
;
import
androidx.annotation.NonNull
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.Observer
;
import
com.netease.nimlib.sdk.StatusCode
;
...
...
@@ -66,6 +68,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
private
static
final
String
KEY_SOURCE
=
"source"
;
private
static
final
String
KEY_CALL_CONFIG
=
"KEY_CALL_CONFIG"
;
public
static
final
String
INTENT_ACTION_AVCHAT
=
"INTENT_ACTION_AVCHAT"
;
private
static
final
String
KEY_NEED_FINISH
=
"need_finish"
;
public
static
final
int
FROM_BROADCASTRECEIVER
=
0
;
// 来自广播
public
static
final
int
FROM_INTERNAL
=
1
;
// 来自发起方
...
...
@@ -123,7 +126,19 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
intent
.
putExtra
(
KEY_SOURCE
,
source
);
context
.
startActivity
(
intent
);
}
@NonNull
public
static
Intent
incomingCallIntent
(
Context
context
,
AVChatData
config
,
String
displayName
,
int
source
)
{
Intent
intent
=
new
Intent
();
intent
.
setClass
(
context
,
AVChatActivity
.
class
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
|
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
putExtra
(
KEY_CALL_CONFIG
,
config
);
intent
.
putExtra
(
KEY_DISPLAY_NAME
,
displayName
);
intent
.
putExtra
(
KEY_IN_CALLING
,
true
);
intent
.
putExtra
(
KEY_SOURCE
,
source
);
intent
.
putExtra
(
KEY_NEED_FINISH
,
false
);
return
intent
;
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
m-im/src/main/java/com/yidianling/avchatkit/notification/AVChatNotification.java
View file @
dddefaaa
...
...
@@ -5,12 +5,14 @@ import android.app.NotificationManager;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
androidx.core.app.NotificationCompat
;
import
com.netease.nimlib.sdk.avchat.model.AVChatData
;
import
com.yidianling.avchatkit.AVChatKit
;
import
com.yidianling.im.R
;
import
com.yidianling.avchatkit.activity.AVChatActivity
;
import
com.yidianling.avchatkit.constant.AVChatExtras
;
import
com.yidianling.im.R
;
/**
* 音视频聊天通知栏
...
...
@@ -27,6 +29,8 @@ public class AVChatNotification {
private
String
displayName
;
private
static
final
int
CALLING_NOTIFY_ID
=
111
;
private
static
final
int
MISS_CALL_NOTIFY_ID
=
112
;
private
static
final
int
INCOMING_CALL_NOTIFY_ID
=
113
;
private
Notification
incomingCallNotification
;
public
AVChatNotification
(
Context
context
)
{
this
.
context
=
context
;
...
...
@@ -46,12 +50,12 @@ public class AVChatNotification {
localIntent
.
setClass
(
context
,
AVChatActivity
.
class
);
localIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
String
tickerText
=
String
.
format
(
context
.
getString
(
R
.
string
.
im_
avchat_notification
),
displayName
);
String
tickerText
=
String
.
format
(
context
.
getString
(
R
.
string
.
avchat_notification
),
displayName
);
int
iconId
=
AVChatKit
.
getAvChatOptions
().
notificationIconRes
;
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
CALLING_NOTIFY_ID
,
localIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
callingNotification
=
makeNotification
(
pendingIntent
,
context
.
getString
(
R
.
string
.
im_
avchat_call
),
tickerText
,
tickerText
,
callingNotification
=
makeNotification
(
pendingIntent
,
context
.
getString
(
R
.
string
.
avchat_call
),
tickerText
,
tickerText
,
iconId
,
false
,
false
);
}
}
...
...
@@ -68,9 +72,9 @@ public class AVChatNotification {
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
CALLING_NOTIFY_ID
,
notifyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
String
title
=
context
.
getString
(
R
.
string
.
im_
avchat_no_pickup_call
);
String
title
=
context
.
getString
(
R
.
string
.
avchat_no_pickup_call
);
String
tickerText
=
displayName
+
": 【网络通话】"
;
int
iconId
=
R
.
drawable
.
im_
avchat_no_pickup
;
int
iconId
=
R
.
drawable
.
avchat_no_pickup
;
missCallNotification
=
makeNotification
(
pendingIntent
,
title
,
tickerText
,
tickerText
,
iconId
,
true
,
true
);
}
...
...
@@ -122,4 +126,63 @@ public class AVChatNotification {
}
}
}
public
void
activeIncomingCallNotification
(
boolean
active
,
AVChatData
backgroundIncomingCallData
)
{
if
(
notificationManager
!=
null
)
{
if
(
active
)
{
buildIncomingCallNotification
(
backgroundIncomingCallData
);
notificationManager
.
notify
(
INCOMING_CALL_NOTIFY_ID
,
incomingCallNotification
);
AVChatKit
.
getNotifications
().
put
(
INCOMING_CALL_NOTIFY_ID
,
incomingCallNotification
);
}
else
{
notificationManager
.
cancel
(
INCOMING_CALL_NOTIFY_ID
);
AVChatKit
.
getNotifications
().
remove
(
INCOMING_CALL_NOTIFY_ID
);
}
}
}
private
void
buildIncomingCallNotification
(
AVChatData
backgroundIncomingCallData
)
{
String
displayName
;
if
(
AVChatKit
.
getUserInfoProvider
()
!=
null
)
{
displayName
=
AVChatKit
.
getUserInfoProvider
().
getUserDisplayName
(
backgroundIncomingCallData
.
getAccount
());
}
else
{
displayName
=
backgroundIncomingCallData
.
getAccount
();
}
Intent
notifyIntent
=
AVChatActivity
.
incomingCallIntent
(
context
,
backgroundIncomingCallData
,
displayName
,
AVChatActivity
.
FROM_BROADCASTRECEIVER
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
CALLING_NOTIFY_ID
,
notifyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
String
title
=
"你有新的来电,请查看"
;
String
content
=
displayName
+
":【网络通话】"
;
String
tickerText
=
displayName
+
" "
+
title
;
int
iconId
=
R
.
drawable
.
avchat_imcoming_call
;
NotificationCompat
.
Builder
incomingCallNotificationBuilder
=
makeNotificationBuilder
(
pendingIntent
,
title
,
content
,
tickerText
,
iconId
,
true
,
true
);
incomingCallNotificationBuilder
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
);
incomingCallNotificationBuilder
.
setCategory
(
NotificationCompat
.
CATEGORY_CALL
);
incomingCallNotificationBuilder
.
setFullScreenIntent
(
pendingIntent
,
true
);
incomingCallNotificationBuilder
.
setAutoCancel
(
true
);
incomingCallNotification
=
incomingCallNotificationBuilder
.
build
();
}
private
NotificationCompat
.
Builder
makeNotificationBuilder
(
PendingIntent
pendingIntent
,
String
title
,
String
content
,
String
tickerText
,
int
iconId
,
boolean
ring
,
boolean
vibrate
)
{
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
context
,
AVChatNotificationChannelCompat26
.
getNIMChannelId
(
context
));
builder
.
setContentTitle
(
title
)
.
setContentText
(
content
)
.
setAutoCancel
(
true
)
.
setContentIntent
(
pendingIntent
)
.
setTicker
(
tickerText
)
.
setSmallIcon
(
iconId
);
int
defaults
=
Notification
.
DEFAULT_LIGHTS
;
if
(
vibrate
)
{
defaults
|=
Notification
.
DEFAULT_VIBRATE
;
}
if
(
ring
)
{
defaults
|=
Notification
.
DEFAULT_SOUND
;
}
builder
.
setDefaults
(
defaults
);
return
builder
;
}
}
m-im/src/main/res/drawable-hdpi/avchat_imcoming_call.png
0 → 100644
View file @
dddefaaa
2.01 KB
m-im/src/main/res/drawable-hdpi/avchat_no_pickup.webp
0 → 100644
View file @
dddefaaa
File added
m-im/src/main/res/values/strings.xml
View file @
dddefaaa
...
...
@@ -33,7 +33,9 @@
<!--====================RES_AVCHAT====================-->
<!--====================RES_AVCHAT====================-->
<!--====================RES_AVCHAT====================-->
<string
name=
"avchat_notification"
>
正在与%1$s通话中,点击继续
</string>
<string
name=
"avchat_call"
>
网络通话
</string>
<string
name=
"avchat_no_pickup_call"
>
未接听
</string>
<string
name=
"im_cancel"
>
取消
</string>
<string
name=
"im_ok"
>
确定
</string>
<string
name=
"im_empty"
>
""
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment