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>,
|
previousList: MutableList<EventLogData>,
|
||||||
currentList: 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
|
// Need to wait for messages to be added before computing new first unread message position
|
||||||
firstUnreadMessagePosition = -1
|
firstUnreadMessagePosition = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun displayHeaderForPosition(position: Int): Boolean {
|
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) {
|
if (unreadMessagesCount > 0 && firstUnreadMessagePosition == -1) {
|
||||||
computeFirstUnreadMessagePosition()
|
computeFirstUnreadMessagePosition()
|
||||||
}
|
}
|
||||||
|
@ -255,16 +259,22 @@ class ChatMessagesListAdapter(
|
||||||
// when new messages are added to the history whilst it is visible
|
// when new messages are added to the history whilst it is visible
|
||||||
unreadMessagesCount = if (itemCount == 0 || forceUpdate) count else 0
|
unreadMessagesCount = if (itemCount == 0 || forceUpdate) count else 0
|
||||||
firstUnreadMessagePosition = -1
|
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 {
|
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
|
return firstUnreadMessagePosition
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun computeFirstUnreadMessagePosition() {
|
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) {
|
if (unreadMessagesCount > 0) {
|
||||||
Log.i("[Chat Messages Adapter] Computing first unread message position")
|
Log.i("[Chat Messages Adapter] Computing first unread message position")
|
||||||
var messageCount = 0
|
var messageCount = 0
|
||||||
|
@ -275,7 +285,9 @@ class ChatMessagesListAdapter(
|
||||||
messageCount += 1
|
messageCount += 1
|
||||||
if (messageCount == unreadMessagesCount) {
|
if (messageCount == unreadMessagesCount) {
|
||||||
firstUnreadMessagePosition = position
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ class ControlsViewModel : ViewModel() {
|
||||||
fullScreenMode.value = false
|
fullScreenMode.value = false
|
||||||
}
|
}
|
||||||
isVideoUpdateInProgress.value = false
|
isVideoUpdateInProgress.value = false
|
||||||
|
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||||
} else if (state == Call.State.PausedByRemote) {
|
} else if (state == Call.State.PausedByRemote) {
|
||||||
fullScreenMode.value = false
|
fullScreenMode.value = false
|
||||||
}
|
}
|
||||||
|
@ -550,6 +551,25 @@ class ControlsViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun shouldProximitySensorBeEnabled(): Boolean {
|
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) {
|
if (forceDisableProximitySensor.value == true) {
|
||||||
Log.i(
|
Log.i(
|
||||||
"[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)"
|
"[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)"
|
||||||
|
|
Loading…
Reference in a new issue