mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-02-19 04:50:53 +01:00
add an extra check to avoid showing both incoming screen and notification
This commit is contained in:
parent
7be52f9af8
commit
d4f9fc28b7
@ -27,11 +27,11 @@ class CallNotificationManager(private val context: Context) {
|
|||||||
private val callContactAvatarHelper = CallContactAvatarHelper(context)
|
private val callContactAvatarHelper = CallContactAvatarHelper(context)
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
fun setupNotification() {
|
fun setupNotification(forceLowPriority: Boolean = false) {
|
||||||
getCallContact(context.applicationContext, CallManager.getPrimaryCall()) { callContact ->
|
getCallContact(context.applicationContext, CallManager.getPrimaryCall()) { callContact ->
|
||||||
val callContactAvatar = callContactAvatarHelper.getCallContactAvatar(callContact)
|
val callContactAvatar = callContactAvatarHelper.getCallContactAvatar(callContact)
|
||||||
val callState = CallManager.getState()
|
val callState = CallManager.getState()
|
||||||
val isHighPriority = context.powerManager.isInteractive && callState == Call.STATE_RINGING
|
val isHighPriority = context.powerManager.isInteractive && callState == Call.STATE_RINGING && !forceLowPriority
|
||||||
val channelId = if (isHighPriority) "simple_dialer_call_high_priority" else "simple_dialer_call"
|
val channelId = if (isHighPriority) "simple_dialer_call_high_priority" else "simple_dialer_call"
|
||||||
if (isOreoPlus()) {
|
if (isOreoPlus()) {
|
||||||
val importance = if (isHighPriority) NotificationManager.IMPORTANCE_HIGH else NotificationManager.IMPORTANCE_DEFAULT
|
val importance = if (isHighPriority) NotificationManager.IMPORTANCE_HIGH else NotificationManager.IMPORTANCE_DEFAULT
|
||||||
|
@ -33,7 +33,7 @@ class CallService : InCallService() {
|
|||||||
val isScreenLocked = (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isDeviceLocked
|
val isScreenLocked = (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isDeviceLocked
|
||||||
if (!powerManager.isInteractive || call.isOutgoing() || isScreenLocked) {
|
if (!powerManager.isInteractive || call.isOutgoing() || isScreenLocked) {
|
||||||
try {
|
try {
|
||||||
callNotificationManager.setupNotification()
|
callNotificationManager.setupNotification(true)
|
||||||
startActivity(CallActivity.getStartIntent(this))
|
startActivity(CallActivity.getStartIntent(this))
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
// seems like startActivity can thrown AndroidRuntimeException and ActivityNotFoundException, not yet sure when and why, lets show a notification
|
// seems like startActivity can thrown AndroidRuntimeException and ActivityNotFoundException, not yet sure when and why, lets show a notification
|
||||||
|
Loading…
x
Reference in New Issue
Block a user