mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 03:11:10 +01:00
Add peek and join capabilities to call links implementation.
This commit is contained in:
committed by
Cody Henthorne
parent
f8434bede5
commit
62940893f0
@@ -12,5 +12,10 @@ enum class CallLogFilter {
|
||||
/**
|
||||
* Only missed calls will be displayed
|
||||
*/
|
||||
MISSED
|
||||
MISSED,
|
||||
|
||||
/**
|
||||
* Only ad-hoc calls will be returned
|
||||
*/
|
||||
AD_HOC
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.thoughtcrime.securesms.database.DatabaseObserver
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobs.CallLinkPeekJob
|
||||
|
||||
class CallLogRepository : CallLogPagedDataSource.CallRepository {
|
||||
override fun getCallsCount(query: String?, filter: CallLogFilter): Int {
|
||||
@@ -20,14 +21,14 @@ class CallLogRepository : CallLogPagedDataSource.CallRepository {
|
||||
override fun getCallLinksCount(query: String?, filter: CallLogFilter): Int {
|
||||
return when (filter) {
|
||||
CallLogFilter.MISSED -> 0
|
||||
CallLogFilter.ALL -> SignalDatabase.callLinks.getCallLinksCount(query)
|
||||
CallLogFilter.ALL, CallLogFilter.AD_HOC -> SignalDatabase.callLinks.getCallLinksCount(query)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCallLinks(query: String?, filter: CallLogFilter, start: Int, length: Int): List<CallLogRow> {
|
||||
return when (filter) {
|
||||
CallLogFilter.MISSED -> emptyList()
|
||||
CallLogFilter.ALL -> SignalDatabase.callLinks.getCallLinks(query, start, length)
|
||||
CallLogFilter.ALL, CallLogFilter.AD_HOC -> SignalDatabase.callLinks.getCallLinks(query, start, length)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,4 +73,29 @@ class CallLogRepository : CallLogPagedDataSource.CallRepository {
|
||||
SignalDatabase.calls.deleteAllCallEventsExcept(selectedCallRowIds, missedOnly)
|
||||
}.observeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
fun peekCallLinks(): Completable {
|
||||
return Completable.fromAction {
|
||||
val callLinks: List<CallLogRow.CallLink> = SignalDatabase.callLinks.getCallLinks(
|
||||
query = null,
|
||||
offset = 0,
|
||||
limit = 10
|
||||
)
|
||||
|
||||
val callEvents: List<CallLogRow.Call> = SignalDatabase.calls.getCalls(
|
||||
offset = 0,
|
||||
limit = 10,
|
||||
searchTerm = null,
|
||||
filter = CallLogFilter.AD_HOC
|
||||
)
|
||||
|
||||
val recipients = (callLinks.map { it.recipient } + callEvents.map { it.peer }).toSet()
|
||||
|
||||
val jobs = recipients.take(10).map {
|
||||
CallLinkPeekJob(it.id)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getJobManager().addAll(jobs)
|
||||
}.observeOn(Schedulers.io())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.database.CallLinkTable
|
||||
import org.thoughtcrime.securesms.database.CallTable
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GroupCallUpdateDetails
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.service.webrtc.CallLinkPeekInfo
|
||||
import org.thoughtcrime.securesms.service.webrtc.links.CallLinkRoomId
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,7 @@ sealed class CallLogRow {
|
||||
val record: CallLinkTable.CallLink,
|
||||
val recipient: Recipient,
|
||||
val searchQuery: String?,
|
||||
val callLinkPeekInfo: CallLinkPeekInfo?,
|
||||
override val id: Id = Id.CallLink(record.roomId)
|
||||
) : CallLogRow()
|
||||
|
||||
@@ -38,6 +40,7 @@ sealed class CallLogRow {
|
||||
val groupCallState: GroupCallState,
|
||||
val children: Set<Long>,
|
||||
val searchQuery: String?,
|
||||
val callLinkPeekInfo: CallLinkPeekInfo?,
|
||||
override val id: Id = Id.Call(children)
|
||||
) : CallLogRow()
|
||||
|
||||
|
||||
@@ -4,14 +4,19 @@ import androidx.annotation.MainThread
|
||||
import androidx.lifecycle.ViewModel
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import io.reactivex.rxjava3.processors.BehaviorProcessor
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.paging.ObservablePagedData
|
||||
import org.signal.paging.PagedData
|
||||
import org.signal.paging.PagingConfig
|
||||
import org.signal.paging.ProxyPagingController
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* ViewModel for call log management.
|
||||
@@ -70,6 +75,22 @@ class CallLogViewModel(
|
||||
disposables += callLogRepository.listenForChanges().subscribe {
|
||||
controller.onDataInvalidated()
|
||||
}
|
||||
|
||||
if (FeatureFlags.adHocCalling()) {
|
||||
disposables += Observable
|
||||
.interval(30, TimeUnit.SECONDS, Schedulers.computation())
|
||||
.flatMapCompletable { callLogRepository.peekCallLinks() }
|
||||
.subscribe()
|
||||
|
||||
disposables += ApplicationDependencies
|
||||
.getSignalCallManager()
|
||||
.peekInfoCache
|
||||
.observeOn(Schedulers.computation())
|
||||
.distinctUntilChanged()
|
||||
.subscribe {
|
||||
controller.onDataInvalidated()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
|
||||
Reference in New Issue
Block a user