mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 13:35:33 +03:00
Merge pull request #1585 from nextcloud/bugfix/noid/showKeyguardForToggleChat
enable keyguard for toggle chat
This commit is contained in:
commit
caa8915130
1 changed files with 32 additions and 3 deletions
|
@ -22,7 +22,9 @@
|
|||
|
||||
package com.nextcloud.talk.activities
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
|
@ -56,11 +58,10 @@ class MagicCallActivity : BaseActivity() {
|
|||
setTheme(R.style.CallTheme)
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dismissKeyguard()
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN or
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
)
|
||||
window.decorView.systemUiVisibility = systemUiVisibility
|
||||
|
||||
|
@ -99,6 +100,7 @@ class MagicCallActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
fun showChat() {
|
||||
enableKeyguard()
|
||||
binding.chatControllerView.visibility = View.VISIBLE
|
||||
binding.controllerContainer.visibility = View.GONE
|
||||
chatController.wasDetached = false
|
||||
|
@ -116,6 +118,33 @@ class MagicCallActivity : BaseActivity() {
|
|||
eventBus.post(ConfigurationChangeEvent())
|
||||
}
|
||||
|
||||
private fun dismissKeyguard() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(true)
|
||||
setTurnScreenOn(true)
|
||||
val keyguardManager = getSystemService(KEYGUARD_SERVICE) as KeyguardManager
|
||||
keyguardManager.requestDismissKeyguard(this, null)
|
||||
} else {
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun enableKeyguard() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(false)
|
||||
} else {
|
||||
window.clearFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = "MagicCallActivity"
|
||||
|
||||
|
|
Loading…
Reference in a new issue