Post merge conflict reformatting
This commit is contained in:
parent
e6e05317e1
commit
8af49891ff
|
@ -151,10 +151,12 @@ class VerificationTest : InstrumentedTest {
|
||||||
|
|
||||||
// TODO Add tests without SAS
|
// TODO Add tests without SAS
|
||||||
|
|
||||||
private fun doTest(aliceSupportedMethods: List<VerificationMethod>,
|
private fun doTest(
|
||||||
bobSupportedMethods: List<VerificationMethod>,
|
aliceSupportedMethods: List<VerificationMethod>,
|
||||||
expectedResultForAlice: ExpectedResult,
|
bobSupportedMethods: List<VerificationMethod>,
|
||||||
expectedResultForBob: ExpectedResult) = runCryptoTest(context()) { cryptoTestHelper, testHelper ->
|
expectedResultForAlice: ExpectedResult,
|
||||||
|
expectedResultForBob: ExpectedResult
|
||||||
|
) = runCryptoTest(context()) { cryptoTestHelper, testHelper ->
|
||||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||||
|
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
|
|
|
@ -151,9 +151,11 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
keysBackupStateManager.removeListener(listener)
|
keysBackupStateManager.removeListener(listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun prepareKeysBackupVersion(password: String?,
|
override fun prepareKeysBackupVersion(
|
||||||
progressListener: ProgressListener?,
|
password: String?,
|
||||||
callback: MatrixCallback<MegolmBackupCreationInfo>) {
|
progressListener: ProgressListener?,
|
||||||
|
callback: MatrixCallback<MegolmBackupCreationInfo>
|
||||||
|
) {
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
||||||
try {
|
try {
|
||||||
val olmPkDecryption = OlmPkDecryption()
|
val olmPkDecryption = OlmPkDecryption()
|
||||||
|
@ -227,8 +229,10 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo,
|
override fun createKeysBackupVersion(
|
||||||
callback: MatrixCallback<KeysVersion>) {
|
keysBackupCreationInfo: MegolmBackupCreationInfo,
|
||||||
|
callback: MatrixCallback<KeysVersion>
|
||||||
|
) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val createKeysBackupVersionBody = CreateKeysBackupVersionBody(
|
val createKeysBackupVersionBody = CreateKeysBackupVersionBody(
|
||||||
algorithm = keysBackupCreationInfo.algorithm,
|
algorithm = keysBackupCreationInfo.algorithm,
|
||||||
|
@ -339,8 +343,10 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
return cryptoStore.inboundGroupSessionsCount(true)
|
return cryptoStore.inboundGroupSessionsCount(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun backupAllGroupSessions(progressListener: ProgressListener?,
|
override fun backupAllGroupSessions(
|
||||||
callback: MatrixCallback<Unit>?) {
|
progressListener: ProgressListener?,
|
||||||
|
callback: MatrixCallback<Unit>?
|
||||||
|
) {
|
||||||
if (!isEnabled() || backupOlmPkEncryption == null || keysBackupVersion == null) {
|
if (!isEnabled() || backupOlmPkEncryption == null || keysBackupVersion == null) {
|
||||||
callback?.onFailure(Throwable("Backup not enabled"))
|
callback?.onFailure(Throwable("Backup not enabled"))
|
||||||
return
|
return
|
||||||
|
@ -391,8 +397,10 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getKeysBackupTrust(keysBackupVersion: KeysVersionResult,
|
override fun getKeysBackupTrust(
|
||||||
callback: MatrixCallback<KeysBackupVersionTrust>) {
|
keysBackupVersion: KeysVersionResult,
|
||||||
|
callback: MatrixCallback<KeysBackupVersionTrust>
|
||||||
|
) {
|
||||||
// TODO Validate with François that this is correct
|
// TODO Validate with François that this is correct
|
||||||
object : Task<KeysVersionResult, KeysBackupVersionTrust> {
|
object : Task<KeysVersionResult, KeysBackupVersionTrust> {
|
||||||
override suspend fun execute(params: KeysVersionResult): KeysBackupVersionTrust {
|
override suspend fun execute(params: KeysVersionResult): KeysBackupVersionTrust {
|
||||||
|
@ -499,9 +507,11 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun trustKeysBackupVersion(keysBackupVersion: KeysVersionResult,
|
override fun trustKeysBackupVersion(
|
||||||
trust: Boolean,
|
keysBackupVersion: KeysVersionResult,
|
||||||
callback: MatrixCallback<Unit>) {
|
trust: Boolean,
|
||||||
|
callback: MatrixCallback<Unit>
|
||||||
|
) {
|
||||||
Timber.v("trustKeyBackupVersion: $trust, version ${keysBackupVersion.version}")
|
Timber.v("trustKeyBackupVersion: $trust, version ${keysBackupVersion.version}")
|
||||||
|
|
||||||
// Get auth data to update it
|
// Get auth data to update it
|
||||||
|
@ -583,9 +593,11 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun trustKeysBackupVersionWithRecoveryKey(keysBackupVersion: KeysVersionResult,
|
override fun trustKeysBackupVersionWithRecoveryKey(
|
||||||
recoveryKey: String,
|
keysBackupVersion: KeysVersionResult,
|
||||||
callback: MatrixCallback<Unit>) {
|
recoveryKey: String,
|
||||||
|
callback: MatrixCallback<Unit>
|
||||||
|
) {
|
||||||
Timber.v("trustKeysBackupVersionWithRecoveryKey: version ${keysBackupVersion.version}")
|
Timber.v("trustKeysBackupVersionWithRecoveryKey: version ${keysBackupVersion.version}")
|
||||||
|
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
||||||
|
@ -602,9 +614,11 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun trustKeysBackupVersionWithPassphrase(keysBackupVersion: KeysVersionResult,
|
override fun trustKeysBackupVersionWithPassphrase(
|
||||||
password: String,
|
keysBackupVersion: KeysVersionResult,
|
||||||
callback: MatrixCallback<Unit>) {
|
password: String,
|
||||||
|
callback: MatrixCallback<Unit>
|
||||||
|
) {
|
||||||
Timber.v("trustKeysBackupVersionWithPassphrase: version ${keysBackupVersion.version}")
|
Timber.v("trustKeysBackupVersionWithPassphrase: version ${keysBackupVersion.version}")
|
||||||
|
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
||||||
|
@ -701,12 +715,14 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
progressListener.onProgress(backedUpKeys, total)
|
progressListener.onProgress(backedUpKeys, total)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun restoreKeysWithRecoveryKey(keysVersionResult: KeysVersionResult,
|
override fun restoreKeysWithRecoveryKey(
|
||||||
recoveryKey: String,
|
keysVersionResult: KeysVersionResult,
|
||||||
roomId: String?,
|
recoveryKey: String,
|
||||||
sessionId: String?,
|
roomId: String?,
|
||||||
stepProgressListener: StepProgressListener?,
|
sessionId: String?,
|
||||||
callback: MatrixCallback<ImportRoomKeysResult>) {
|
stepProgressListener: StepProgressListener?,
|
||||||
|
callback: MatrixCallback<ImportRoomKeysResult>
|
||||||
|
) {
|
||||||
Timber.v("restoreKeysWithRecoveryKey: From backup version: ${keysVersionResult.version}")
|
Timber.v("restoreKeysWithRecoveryKey: From backup version: ${keysVersionResult.version}")
|
||||||
|
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
||||||
|
@ -800,12 +816,14 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun restoreKeyBackupWithPassword(keysBackupVersion: KeysVersionResult,
|
override fun restoreKeyBackupWithPassword(
|
||||||
password: String,
|
keysBackupVersion: KeysVersionResult,
|
||||||
roomId: String?,
|
password: String,
|
||||||
sessionId: String?,
|
roomId: String?,
|
||||||
stepProgressListener: StepProgressListener?,
|
sessionId: String?,
|
||||||
callback: MatrixCallback<ImportRoomKeysResult>) {
|
stepProgressListener: StepProgressListener?,
|
||||||
|
callback: MatrixCallback<ImportRoomKeysResult>
|
||||||
|
) {
|
||||||
Timber.v("[MXKeyBackup] restoreKeyBackup with password: From backup version: ${keysBackupVersion.version}")
|
Timber.v("[MXKeyBackup] restoreKeyBackup with password: From backup version: ${keysBackupVersion.version}")
|
||||||
|
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
||||||
|
@ -853,9 +871,11 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
* Same method as [RoomKeysRestClient.getRoomKey] except that it accepts nullable
|
* Same method as [RoomKeysRestClient.getRoomKey] except that it accepts nullable
|
||||||
* parameters and always returns a KeysBackupData object through the Callback.
|
* parameters and always returns a KeysBackupData object through the Callback.
|
||||||
*/
|
*/
|
||||||
private suspend fun getKeys(sessionId: String?,
|
private suspend fun getKeys(
|
||||||
roomId: String?,
|
sessionId: String?,
|
||||||
version: String): KeysBackupData {
|
roomId: String?,
|
||||||
|
version: String
|
||||||
|
): KeysBackupData {
|
||||||
return if (roomId != null && sessionId != null) {
|
return if (roomId != null && sessionId != null) {
|
||||||
// Get key for the room and for the session
|
// Get key for the room and for the session
|
||||||
val data = getRoomSessionDataTask.execute(GetRoomSessionDataTask.Params(roomId, sessionId, version))
|
val data = getRoomSessionDataTask.execute(GetRoomSessionDataTask.Params(roomId, sessionId, version))
|
||||||
|
@ -933,8 +953,10 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getVersion(version: String,
|
override fun getVersion(
|
||||||
callback: MatrixCallback<KeysVersionResult?>) {
|
version: String,
|
||||||
|
callback: MatrixCallback<KeysVersionResult?>
|
||||||
|
) {
|
||||||
getKeysBackupVersionTask
|
getKeysBackupVersionTask
|
||||||
.configureWith(version) {
|
.configureWith(version) {
|
||||||
this.callback = object : MatrixCallback<KeysVersionResult> {
|
this.callback = object : MatrixCallback<KeysVersionResult> {
|
||||||
|
@ -1173,10 +1195,12 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun computePrivateKey(passphrase: String,
|
override fun computePrivateKey(
|
||||||
privateKeySalt: String,
|
passphrase: String,
|
||||||
privateKeyIterations: Int,
|
privateKeySalt: String,
|
||||||
progressListener: ProgressListener): ByteArray {
|
privateKeyIterations: Int,
|
||||||
|
progressListener: ProgressListener
|
||||||
|
): ByteArray {
|
||||||
return deriveKey(passphrase, privateKeySalt, privateKeyIterations, progressListener)
|
return deriveKey(passphrase, privateKeySalt, privateKeyIterations, progressListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1476,8 +1500,10 @@ internal class DefaultKeysBackupService @Inject constructor(
|
||||||
get() = cryptoStore
|
get() = cryptoStore
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
fun createFakeKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo,
|
fun createFakeKeysBackupVersion(
|
||||||
callback: MatrixCallback<KeysVersion>) {
|
keysBackupCreationInfo: MegolmBackupCreationInfo,
|
||||||
|
callback: MatrixCallback<KeysVersion>
|
||||||
|
) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val createKeysBackupVersionBody = CreateKeysBackupVersionBody(
|
val createKeysBackupVersionBody = CreateKeysBackupVersionBody(
|
||||||
algorithm = keysBackupCreationInfo.algorithm,
|
algorithm = keysBackupCreationInfo.algorithm,
|
||||||
|
|
|
@ -94,8 +94,10 @@ internal class DefaultRoomService @Inject constructor(
|
||||||
return roomSummaryDataSource.getRoomSummaryLive(roomId)
|
return roomSummaryDataSource.getRoomSummaryLive(roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRoomSummaries(queryParams: RoomSummaryQueryParams,
|
override fun getRoomSummaries(
|
||||||
sortOrder: RoomSortOrder): List<RoomSummary> {
|
queryParams: RoomSummaryQueryParams,
|
||||||
|
sortOrder: RoomSortOrder
|
||||||
|
): List<RoomSummary> {
|
||||||
return roomSummaryDataSource.getRoomSummaries(queryParams, sortOrder)
|
return roomSummaryDataSource.getRoomSummaries(queryParams, sortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,20 +121,26 @@ internal class DefaultRoomService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
override fun getRoomSummariesLive(
|
||||||
sortOrder: RoomSortOrder): LiveData<List<RoomSummary>> {
|
queryParams: RoomSummaryQueryParams,
|
||||||
|
sortOrder: RoomSortOrder
|
||||||
|
): LiveData<List<RoomSummary>> {
|
||||||
return roomSummaryDataSource.getRoomSummariesLive(queryParams, sortOrder)
|
return roomSummaryDataSource.getRoomSummariesLive(queryParams, sortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
override fun getPagedRoomSummariesLive(
|
||||||
pagedListConfig: PagedList.Config,
|
queryParams: RoomSummaryQueryParams,
|
||||||
sortOrder: RoomSortOrder): LiveData<PagedList<RoomSummary>> {
|
pagedListConfig: PagedList.Config,
|
||||||
|
sortOrder: RoomSortOrder
|
||||||
|
): LiveData<PagedList<RoomSummary>> {
|
||||||
return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
|
return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
override fun getFilteredPagedRoomSummariesLive(
|
||||||
pagedListConfig: PagedList.Config,
|
queryParams: RoomSummaryQueryParams,
|
||||||
sortOrder: RoomSortOrder): UpdatableLivePageResult {
|
pagedListConfig: PagedList.Config,
|
||||||
|
sortOrder: RoomSortOrder
|
||||||
|
): UpdatableLivePageResult {
|
||||||
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true)
|
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,9 +168,11 @@ internal class DefaultRoomService @Inject constructor(
|
||||||
joinRoomTask.execute(JoinRoomTask.Params(roomIdOrAlias, reason, viaServers))
|
joinRoomTask.execute(JoinRoomTask.Params(roomIdOrAlias, reason, viaServers))
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun joinRoom(roomId: String,
|
override suspend fun joinRoom(
|
||||||
reason: String?,
|
roomId: String,
|
||||||
thirdPartySigned: SignInvitationResult) {
|
reason: String?,
|
||||||
|
thirdPartySigned: SignInvitationResult
|
||||||
|
) {
|
||||||
joinRoomTask.execute(JoinRoomTask.Params(roomId, reason, thirdPartySigned = thirdPartySigned))
|
joinRoomTask.execute(JoinRoomTask.Params(roomId, reason, thirdPartySigned = thirdPartySigned))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,16 +85,20 @@ internal class RoomSummaryDataSource @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoomSummaries(queryParams: RoomSummaryQueryParams,
|
fun getRoomSummaries(
|
||||||
sortOrder: RoomSortOrder = RoomSortOrder.NONE): List<RoomSummary> {
|
queryParams: RoomSummaryQueryParams,
|
||||||
|
sortOrder: RoomSortOrder = RoomSortOrder.NONE
|
||||||
|
): List<RoomSummary> {
|
||||||
return monarchy.fetchAllMappedSync(
|
return monarchy.fetchAllMappedSync(
|
||||||
{ roomSummariesQuery(it, queryParams).process(sortOrder) },
|
{ roomSummariesQuery(it, queryParams).process(sortOrder) },
|
||||||
{ roomSummaryMapper.map(it) }
|
{ roomSummaryMapper.map(it) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
fun getRoomSummariesLive(
|
||||||
sortOrder: RoomSortOrder = RoomSortOrder.NONE): LiveData<List<RoomSummary>> {
|
queryParams: RoomSummaryQueryParams,
|
||||||
|
sortOrder: RoomSortOrder = RoomSortOrder.NONE
|
||||||
|
): LiveData<List<RoomSummary>> {
|
||||||
return monarchy.findAllMappedWithChanges(
|
return monarchy.findAllMappedWithChanges(
|
||||||
{
|
{
|
||||||
roomSummariesQuery(it, queryParams).process(sortOrder)
|
roomSummariesQuery(it, queryParams).process(sortOrder)
|
||||||
|
@ -103,8 +107,10 @@ internal class RoomSummaryDataSource @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSpaceSummariesLive(queryParams: SpaceSummaryQueryParams,
|
fun getSpaceSummariesLive(
|
||||||
sortOrder: RoomSortOrder = RoomSortOrder.NONE): LiveData<List<RoomSummary>> {
|
queryParams: SpaceSummaryQueryParams,
|
||||||
|
sortOrder: RoomSortOrder = RoomSortOrder.NONE
|
||||||
|
): LiveData<List<RoomSummary>> {
|
||||||
return getRoomSummariesLive(queryParams, sortOrder)
|
return getRoomSummariesLive(queryParams, sortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +135,10 @@ internal class RoomSummaryDataSource @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams,
|
fun getSpaceSummaries(
|
||||||
sortOrder: RoomSortOrder = RoomSortOrder.NONE): List<RoomSummary> {
|
spaceSummaryQueryParams: SpaceSummaryQueryParams,
|
||||||
|
sortOrder: RoomSortOrder = RoomSortOrder.NONE
|
||||||
|
): List<RoomSummary> {
|
||||||
return getRoomSummaries(spaceSummaryQueryParams, sortOrder)
|
return getRoomSummaries(spaceSummaryQueryParams, sortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,9 +179,11 @@ internal class RoomSummaryDataSource @Inject constructor(
|
||||||
.sort(RoomSummaryEntityFields.BREADCRUMBS_INDEX)
|
.sort(RoomSummaryEntityFields.BREADCRUMBS_INDEX)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSortedPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
fun getSortedPagedRoomSummariesLive(
|
||||||
pagedListConfig: PagedList.Config,
|
queryParams: RoomSummaryQueryParams,
|
||||||
sortOrder: RoomSortOrder): LiveData<PagedList<RoomSummary>> {
|
pagedListConfig: PagedList.Config,
|
||||||
|
sortOrder: RoomSortOrder
|
||||||
|
): LiveData<PagedList<RoomSummary>> {
|
||||||
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
||||||
roomSummariesQuery(realm, queryParams).process(sortOrder)
|
roomSummariesQuery(realm, queryParams).process(sortOrder)
|
||||||
}
|
}
|
||||||
|
@ -186,10 +196,12 @@ internal class RoomSummaryDataSource @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUpdatablePagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
fun getUpdatablePagedRoomSummariesLive(
|
||||||
pagedListConfig: PagedList.Config,
|
queryParams: RoomSummaryQueryParams,
|
||||||
sortOrder: RoomSortOrder,
|
pagedListConfig: PagedList.Config,
|
||||||
getFlattenedParents: Boolean = false): UpdatableLivePageResult {
|
sortOrder: RoomSortOrder,
|
||||||
|
getFlattenedParents: Boolean = false
|
||||||
|
): UpdatableLivePageResult {
|
||||||
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
||||||
roomSummariesQuery(realm, queryParams).process(sortOrder)
|
roomSummariesQuery(realm, queryParams).process(sortOrder)
|
||||||
}
|
}
|
||||||
|
@ -424,11 +436,13 @@ internal class RoomSummaryDataSource @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun flattenSubSpace(current: RoomSummary,
|
fun flattenSubSpace(
|
||||||
parenting: List<String>,
|
current: RoomSummary,
|
||||||
output: MutableList<RoomSummary>,
|
parenting: List<String>,
|
||||||
memberShips: List<Membership>,
|
output: MutableList<RoomSummary>,
|
||||||
includeCurrent: Boolean = true) {
|
memberShips: List<Membership>,
|
||||||
|
includeCurrent: Boolean = true
|
||||||
|
) {
|
||||||
if (includeCurrent) {
|
if (includeCurrent) {
|
||||||
output.add(current)
|
output.add(current)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,22 @@ import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class RoomSummaryItemFactory @Inject constructor(private val displayableEventFormatter: DisplayableEventFormatter,
|
class RoomSummaryItemFactory @Inject constructor(
|
||||||
private val dateFormatter: VectorDateFormatter,
|
private val displayableEventFormatter: DisplayableEventFormatter,
|
||||||
private val stringProvider: StringProvider,
|
private val dateFormatter: VectorDateFormatter,
|
||||||
private val typingHelper: TypingHelper,
|
private val stringProvider: StringProvider,
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val typingHelper: TypingHelper,
|
||||||
private val errorFormatter: ErrorFormatter) {
|
private val avatarRenderer: AvatarRenderer,
|
||||||
|
private val errorFormatter: ErrorFormatter
|
||||||
|
) {
|
||||||
|
|
||||||
fun create(roomSummary: RoomSummary,
|
fun create(
|
||||||
roomChangeMembershipStates: Map<String, ChangeMembershipState>,
|
roomSummary: RoomSummary,
|
||||||
selectedRoomIds: Set<String>,
|
roomChangeMembershipStates: Map<String, ChangeMembershipState>,
|
||||||
displayMode: RoomListDisplayMode,
|
selectedRoomIds: Set<String>,
|
||||||
listener: RoomListListener?): VectorEpoxyModel<*> {
|
displayMode: RoomListDisplayMode,
|
||||||
|
listener: RoomListListener?
|
||||||
|
): VectorEpoxyModel<*> {
|
||||||
return when (roomSummary.membership) {
|
return when (roomSummary.membership) {
|
||||||
Membership.INVITE -> {
|
Membership.INVITE -> {
|
||||||
val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown
|
val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown
|
||||||
|
@ -60,9 +64,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createSuggestion(spaceChildInfo: SpaceChildInfo,
|
fun createSuggestion(
|
||||||
suggestedRoomJoiningStates: Map<String, Async<Unit>>,
|
spaceChildInfo: SpaceChildInfo,
|
||||||
listener: RoomListListener?): VectorEpoxyModel<*> {
|
suggestedRoomJoiningStates: Map<String, Async<Unit>>,
|
||||||
|
listener: RoomListListener?
|
||||||
|
): VectorEpoxyModel<*> {
|
||||||
val error = (suggestedRoomJoiningStates[spaceChildInfo.childRoomId] as? Fail)?.error
|
val error = (suggestedRoomJoiningStates[spaceChildInfo.childRoomId] as? Fail)?.error
|
||||||
return SpaceChildInfoItem_()
|
return SpaceChildInfoItem_()
|
||||||
.id("sug_${spaceChildInfo.childRoomId}")
|
.id("sug_${spaceChildInfo.childRoomId}")
|
||||||
|
@ -84,9 +90,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
.itemClickListener { listener?.onSuggestedRoomClicked(spaceChildInfo) }
|
.itemClickListener { listener?.onSuggestedRoomClicked(spaceChildInfo) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createInvitationItem(roomSummary: RoomSummary,
|
private fun createInvitationItem(
|
||||||
changeMembershipState: ChangeMembershipState,
|
roomSummary: RoomSummary,
|
||||||
listener: RoomListListener?): VectorEpoxyModel<*> {
|
changeMembershipState: ChangeMembershipState,
|
||||||
|
listener: RoomListListener?
|
||||||
|
): VectorEpoxyModel<*> {
|
||||||
val secondLine = if (roomSummary.isDirect) {
|
val secondLine = if (roomSummary.isDirect) {
|
||||||
roomSummary.inviterId
|
roomSummary.inviterId
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,10 +66,12 @@ interface AttachmentData : Parcelable {
|
||||||
private const val URL_PREVIEW_IMAGE_MIN_FULL_WIDTH_PX = 600
|
private const val URL_PREVIEW_IMAGE_MIN_FULL_WIDTH_PX = 600
|
||||||
private const val URL_PREVIEW_IMAGE_MIN_FULL_HEIGHT_PX = 315
|
private const val URL_PREVIEW_IMAGE_MIN_FULL_HEIGHT_PX = 315
|
||||||
|
|
||||||
class ImageContentRenderer @Inject constructor(private val localFilesHelper: LocalFilesHelper,
|
class ImageContentRenderer @Inject constructor(
|
||||||
private val activeSessionHolder: ActiveSessionHolder,
|
private val localFilesHelper: LocalFilesHelper,
|
||||||
private val dimensionConverter: DimensionConverter,
|
private val activeSessionHolder: ActiveSessionHolder,
|
||||||
private val vectorPreferences: VectorPreferences) {
|
private val dimensionConverter: DimensionConverter,
|
||||||
|
private val vectorPreferences: VectorPreferences
|
||||||
|
) {
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class Data(
|
data class Data(
|
||||||
|
@ -184,19 +186,23 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
||||||
|
|
||||||
createGlideRequest(data, mode, imageView, size)
|
createGlideRequest(data, mode, imageView, size)
|
||||||
.listener(object : RequestListener<Drawable> {
|
.listener(object : RequestListener<Drawable> {
|
||||||
override fun onLoadFailed(e: GlideException?,
|
override fun onLoadFailed(
|
||||||
model: Any?,
|
e: GlideException?,
|
||||||
target: Target<Drawable>?,
|
model: Any?,
|
||||||
isFirstResource: Boolean): Boolean {
|
target: Target<Drawable>?,
|
||||||
|
isFirstResource: Boolean
|
||||||
|
): Boolean {
|
||||||
callback?.invoke(false)
|
callback?.invoke(false)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResourceReady(resource: Drawable?,
|
override fun onResourceReady(
|
||||||
model: Any?,
|
resource: Drawable?,
|
||||||
target: Target<Drawable>?,
|
model: Any?,
|
||||||
dataSource: DataSource?,
|
target: Target<Drawable>?,
|
||||||
isFirstResource: Boolean): Boolean {
|
dataSource: DataSource?,
|
||||||
|
isFirstResource: Boolean
|
||||||
|
): Boolean {
|
||||||
callback?.invoke(true)
|
callback?.invoke(true)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -227,19 +233,23 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
||||||
}
|
}
|
||||||
|
|
||||||
req.listener(object : RequestListener<Drawable> {
|
req.listener(object : RequestListener<Drawable> {
|
||||||
override fun onLoadFailed(e: GlideException?,
|
override fun onLoadFailed(
|
||||||
model: Any?,
|
e: GlideException?,
|
||||||
target: Target<Drawable>?,
|
model: Any?,
|
||||||
isFirstResource: Boolean): Boolean {
|
target: Target<Drawable>?,
|
||||||
|
isFirstResource: Boolean
|
||||||
|
): Boolean {
|
||||||
callback?.invoke(false)
|
callback?.invoke(false)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResourceReady(resource: Drawable?,
|
override fun onResourceReady(
|
||||||
model: Any?,
|
resource: Drawable?,
|
||||||
target: Target<Drawable>?,
|
model: Any?,
|
||||||
dataSource: DataSource?,
|
target: Target<Drawable>?,
|
||||||
isFirstResource: Boolean): Boolean {
|
dataSource: DataSource?,
|
||||||
|
isFirstResource: Boolean
|
||||||
|
): Boolean {
|
||||||
callback?.invoke(true)
|
callback?.invoke(true)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue