diff --git a/app/build.gradle b/app/build.gradle index fa341d70..9f791167 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.27.0' + implementation 'com.simplemobiletools:commons:5.27.1' implementation 'joda-time:joda-time:2.10.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5' diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/CallActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/CallActivity.kt index 8cb146ea..0ed6b7e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/CallActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/CallActivity.kt @@ -1,20 +1,21 @@ package com.simplemobiletools.contacts.pro.activities import android.annotation.SuppressLint -import android.app.Notification -import android.app.NotificationChannel -import android.app.NotificationManager -import android.app.PendingIntent +import android.app.* +import android.content.Context import android.content.Intent import android.graphics.* import android.net.Uri +import android.os.Build import android.os.Bundle import android.provider.MediaStore import android.telecom.Call import android.util.Size +import android.view.WindowManager import android.widget.RemoteViews import androidx.core.app.NotificationCompat import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.isOreoMr1Plus import com.simplemobiletools.commons.helpers.isOreoPlus import com.simplemobiletools.commons.helpers.isQPlus import com.simplemobiletools.contacts.pro.R @@ -43,11 +44,12 @@ class CallActivity : SimpleActivity() { callContact = CallManager.getCallContact(applicationContext) callContactAvatar = getCallContactAvatar() + addLockScreenFlags() showNotification() + updateOtherPersonsInfo() CallManager.registerCallback(getCallCallback()) updateCallState(CallManager.getState()) - updateOtherPersonsInfo() } override fun onDestroy() { @@ -134,6 +136,22 @@ class CallActivity : SimpleActivity() { } } + @SuppressLint("NewApi") + private fun addLockScreenFlags() { + if (isOreoMr1Plus()) { + setShowWhenLocked(true) + setTurnScreenOn(true) + } else { + window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON) + } + + if (isOreoPlus()) { + (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).requestDismissKeyguard(this, null) + } else { + window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD) + } + } + @SuppressLint("NewApi") private fun showNotification() { val channelId = "simple_contacts_call"