Fixed proximity sensor not turning screen off during outgoing call
This commit is contained in:
parent
047665afac
commit
11c33bb1b0
2 changed files with 38 additions and 6 deletions
|
@ -217,13 +217,17 @@ class ChatMessagesListAdapter(
|
|||
previousList: MutableList<EventLogData>,
|
||||
currentList: MutableList<EventLogData>
|
||||
) {
|
||||
Log.i("[Chat Messages Adapter] List has changed, clearing previous first unread message position")
|
||||
Log.i(
|
||||
"[Chat Messages Adapter] List has changed, clearing previous first unread message position"
|
||||
)
|
||||
// Need to wait for messages to be added before computing new first unread message position
|
||||
firstUnreadMessagePosition = -1
|
||||
}
|
||||
|
||||
override fun displayHeaderForPosition(position: Int): Boolean {
|
||||
Log.i("[Chat Messages Adapter] Unread message count is [$unreadMessagesCount], first unread message position is [$firstUnreadMessagePosition]")
|
||||
Log.i(
|
||||
"[Chat Messages Adapter] Unread message count is [$unreadMessagesCount], first unread message position is [$firstUnreadMessagePosition]"
|
||||
)
|
||||
if (unreadMessagesCount > 0 && firstUnreadMessagePosition == -1) {
|
||||
computeFirstUnreadMessagePosition()
|
||||
}
|
||||
|
@ -255,16 +259,22 @@ class ChatMessagesListAdapter(
|
|||
// when new messages are added to the history whilst it is visible
|
||||
unreadMessagesCount = if (itemCount == 0 || forceUpdate) count else 0
|
||||
firstUnreadMessagePosition = -1
|
||||
Log.i("[Chat Messages Adapter] Set [$unreadMessagesCount] unread message(s) for current chat room")
|
||||
Log.i(
|
||||
"[Chat Messages Adapter] Set [$unreadMessagesCount] unread message(s) for current chat room"
|
||||
)
|
||||
}
|
||||
|
||||
fun getFirstUnreadMessagePosition(): Int {
|
||||
Log.i("[Chat Messages Adapter] First unread message position is [$firstUnreadMessagePosition]")
|
||||
Log.i(
|
||||
"[Chat Messages Adapter] First unread message position is [$firstUnreadMessagePosition]"
|
||||
)
|
||||
return firstUnreadMessagePosition
|
||||
}
|
||||
|
||||
private fun computeFirstUnreadMessagePosition() {
|
||||
Log.i("[Chat Messages Adapter] [$unreadMessagesCount] unread message(s) for current chat room")
|
||||
Log.i(
|
||||
"[Chat Messages Adapter] [$unreadMessagesCount] unread message(s) for current chat room"
|
||||
)
|
||||
if (unreadMessagesCount > 0) {
|
||||
Log.i("[Chat Messages Adapter] Computing first unread message position")
|
||||
var messageCount = 0
|
||||
|
@ -275,7 +285,9 @@ class ChatMessagesListAdapter(
|
|||
messageCount += 1
|
||||
if (messageCount == unreadMessagesCount) {
|
||||
firstUnreadMessagePosition = position
|
||||
Log.i("[Chat Messages Adapter] First unread message position found [$firstUnreadMessagePosition]")
|
||||
Log.i(
|
||||
"[Chat Messages Adapter] First unread message position found [$firstUnreadMessagePosition]"
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ class ControlsViewModel : ViewModel() {
|
|||
fullScreenMode.value = false
|
||||
}
|
||||
isVideoUpdateInProgress.value = false
|
||||
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||
} else if (state == Call.State.PausedByRemote) {
|
||||
fullScreenMode.value = false
|
||||
}
|
||||
|
@ -550,6 +551,25 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
private fun shouldProximitySensorBeEnabled(): Boolean {
|
||||
val currentCall = coreContext.core.currentCall ?: coreContext.core.calls.firstOrNull()
|
||||
if (currentCall != null) {
|
||||
when (val state = currentCall.state) {
|
||||
Call.State.OutgoingEarlyMedia, Call.State.OutgoingProgress, Call.State.OutgoingRinging, Call.State.OutgoingInit -> {
|
||||
Log.i(
|
||||
"[Call Controls] Call is in outgoing state [$state], enabling proximity sensor"
|
||||
)
|
||||
return true
|
||||
}
|
||||
Call.State.IncomingEarlyMedia, Call.State.IncomingReceived -> {
|
||||
Log.i(
|
||||
"[Call Controls] Call is in incoming state [$state], enabling proximity sensor"
|
||||
)
|
||||
return true
|
||||
}
|
||||
else -> { }
|
||||
}
|
||||
}
|
||||
|
||||
if (forceDisableProximitySensor.value == true) {
|
||||
Log.i(
|
||||
"[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)"
|
||||
|
|
Loading…
Reference in a new issue