Post merge conflict reformatting

This commit is contained in:
ericdecanini 2022-05-31 14:23:02 +02:00
parent e6e05317e1
commit 8af49891ff
6 changed files with 187 additions and 117 deletions

View File

@ -151,10 +151,12 @@ class VerificationTest : InstrumentedTest {
// TODO Add tests without SAS
private fun doTest(aliceSupportedMethods: List<VerificationMethod>,
private fun doTest(
aliceSupportedMethods: List<VerificationMethod>,
bobSupportedMethods: List<VerificationMethod>,
expectedResultForAlice: ExpectedResult,
expectedResultForBob: ExpectedResult) = runCryptoTest(context()) { cryptoTestHelper, testHelper ->
expectedResultForBob: ExpectedResult
) = runCryptoTest(context()) { cryptoTestHelper, testHelper ->
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
val aliceSession = cryptoTestData.firstSession

View File

@ -151,9 +151,11 @@ internal class DefaultKeysBackupService @Inject constructor(
keysBackupStateManager.removeListener(listener)
}
override fun prepareKeysBackupVersion(password: String?,
override fun prepareKeysBackupVersion(
password: String?,
progressListener: ProgressListener?,
callback: MatrixCallback<MegolmBackupCreationInfo>) {
callback: MatrixCallback<MegolmBackupCreationInfo>
) {
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
try {
val olmPkDecryption = OlmPkDecryption()
@ -227,8 +229,10 @@ internal class DefaultKeysBackupService @Inject constructor(
}
}
override fun createKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo,
callback: MatrixCallback<KeysVersion>) {
override fun createKeysBackupVersion(
keysBackupCreationInfo: MegolmBackupCreationInfo,
callback: MatrixCallback<KeysVersion>
) {
@Suppress("UNCHECKED_CAST")
val createKeysBackupVersionBody = CreateKeysBackupVersionBody(
algorithm = keysBackupCreationInfo.algorithm,
@ -339,8 +343,10 @@ internal class DefaultKeysBackupService @Inject constructor(
return cryptoStore.inboundGroupSessionsCount(true)
}
override fun backupAllGroupSessions(progressListener: ProgressListener?,
callback: MatrixCallback<Unit>?) {
override fun backupAllGroupSessions(
progressListener: ProgressListener?,
callback: MatrixCallback<Unit>?
) {
if (!isEnabled() || backupOlmPkEncryption == null || keysBackupVersion == null) {
callback?.onFailure(Throwable("Backup not enabled"))
return
@ -391,8 +397,10 @@ internal class DefaultKeysBackupService @Inject constructor(
})
}
override fun getKeysBackupTrust(keysBackupVersion: KeysVersionResult,
callback: MatrixCallback<KeysBackupVersionTrust>) {
override fun getKeysBackupTrust(
keysBackupVersion: KeysVersionResult,
callback: MatrixCallback<KeysBackupVersionTrust>
) {
// TODO Validate with François that this is correct
object : Task<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(
keysBackupVersion: KeysVersionResult,
trust: Boolean,
callback: MatrixCallback<Unit>) {
callback: MatrixCallback<Unit>
) {
Timber.v("trustKeyBackupVersion: $trust, version ${keysBackupVersion.version}")
// Get auth data to update it
@ -583,9 +593,11 @@ internal class DefaultKeysBackupService @Inject constructor(
}
}
override fun trustKeysBackupVersionWithRecoveryKey(keysBackupVersion: KeysVersionResult,
override fun trustKeysBackupVersionWithRecoveryKey(
keysBackupVersion: KeysVersionResult,
recoveryKey: String,
callback: MatrixCallback<Unit>) {
callback: MatrixCallback<Unit>
) {
Timber.v("trustKeysBackupVersionWithRecoveryKey: version ${keysBackupVersion.version}")
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
@ -602,9 +614,11 @@ internal class DefaultKeysBackupService @Inject constructor(
}
}
override fun trustKeysBackupVersionWithPassphrase(keysBackupVersion: KeysVersionResult,
override fun trustKeysBackupVersionWithPassphrase(
keysBackupVersion: KeysVersionResult,
password: String,
callback: MatrixCallback<Unit>) {
callback: MatrixCallback<Unit>
) {
Timber.v("trustKeysBackupVersionWithPassphrase: version ${keysBackupVersion.version}")
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
@ -701,12 +715,14 @@ internal class DefaultKeysBackupService @Inject constructor(
progressListener.onProgress(backedUpKeys, total)
}
override fun restoreKeysWithRecoveryKey(keysVersionResult: KeysVersionResult,
override fun restoreKeysWithRecoveryKey(
keysVersionResult: KeysVersionResult,
recoveryKey: String,
roomId: String?,
sessionId: String?,
stepProgressListener: StepProgressListener?,
callback: MatrixCallback<ImportRoomKeysResult>) {
callback: MatrixCallback<ImportRoomKeysResult>
) {
Timber.v("restoreKeysWithRecoveryKey: From backup version: ${keysVersionResult.version}")
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
@ -800,12 +816,14 @@ internal class DefaultKeysBackupService @Inject constructor(
}
}
override fun restoreKeyBackupWithPassword(keysBackupVersion: KeysVersionResult,
override fun restoreKeyBackupWithPassword(
keysBackupVersion: KeysVersionResult,
password: String,
roomId: String?,
sessionId: String?,
stepProgressListener: StepProgressListener?,
callback: MatrixCallback<ImportRoomKeysResult>) {
callback: MatrixCallback<ImportRoomKeysResult>
) {
Timber.v("[MXKeyBackup] restoreKeyBackup with password: From backup version: ${keysBackupVersion.version}")
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
@ -853,9 +871,11 @@ internal class DefaultKeysBackupService @Inject constructor(
* Same method as [RoomKeysRestClient.getRoomKey] except that it accepts nullable
* parameters and always returns a KeysBackupData object through the Callback.
*/
private suspend fun getKeys(sessionId: String?,
private suspend fun getKeys(
sessionId: String?,
roomId: String?,
version: String): KeysBackupData {
version: String
): KeysBackupData {
return if (roomId != null && sessionId != null) {
// Get key for the room and for the session
val data = getRoomSessionDataTask.execute(GetRoomSessionDataTask.Params(roomId, sessionId, version))
@ -933,8 +953,10 @@ internal class DefaultKeysBackupService @Inject constructor(
}
}
override fun getVersion(version: String,
callback: MatrixCallback<KeysVersionResult?>) {
override fun getVersion(
version: String,
callback: MatrixCallback<KeysVersionResult?>
) {
getKeysBackupVersionTask
.configureWith(version) {
this.callback = object : MatrixCallback<KeysVersionResult> {
@ -1173,10 +1195,12 @@ internal class DefaultKeysBackupService @Inject constructor(
}
}
override fun computePrivateKey(passphrase: String,
override fun computePrivateKey(
passphrase: String,
privateKeySalt: String,
privateKeyIterations: Int,
progressListener: ProgressListener): ByteArray {
progressListener: ProgressListener
): ByteArray {
return deriveKey(passphrase, privateKeySalt, privateKeyIterations, progressListener)
}
@ -1476,8 +1500,10 @@ internal class DefaultKeysBackupService @Inject constructor(
get() = cryptoStore
@VisibleForTesting
fun createFakeKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo,
callback: MatrixCallback<KeysVersion>) {
fun createFakeKeysBackupVersion(
keysBackupCreationInfo: MegolmBackupCreationInfo,
callback: MatrixCallback<KeysVersion>
) {
@Suppress("UNCHECKED_CAST")
val createKeysBackupVersionBody = CreateKeysBackupVersionBody(
algorithm = keysBackupCreationInfo.algorithm,

View File

@ -94,8 +94,10 @@ internal class DefaultRoomService @Inject constructor(
return roomSummaryDataSource.getRoomSummaryLive(roomId)
}
override fun getRoomSummaries(queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder): List<RoomSummary> {
override fun getRoomSummaries(
queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder
): List<RoomSummary> {
return roomSummaryDataSource.getRoomSummaries(queryParams, sortOrder)
}
@ -119,20 +121,26 @@ internal class DefaultRoomService @Inject constructor(
}
}
override fun getRoomSummariesLive(queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder): LiveData<List<RoomSummary>> {
override fun getRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder
): LiveData<List<RoomSummary>> {
return roomSummaryDataSource.getRoomSummariesLive(queryParams, sortOrder)
}
override fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
override fun getPagedRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
pagedListConfig: PagedList.Config,
sortOrder: RoomSortOrder): LiveData<PagedList<RoomSummary>> {
sortOrder: RoomSortOrder
): LiveData<PagedList<RoomSummary>> {
return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
}
override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
override fun getFilteredPagedRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
pagedListConfig: PagedList.Config,
sortOrder: RoomSortOrder): UpdatableLivePageResult {
sortOrder: RoomSortOrder
): UpdatableLivePageResult {
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true)
}
@ -160,9 +168,11 @@ internal class DefaultRoomService @Inject constructor(
joinRoomTask.execute(JoinRoomTask.Params(roomIdOrAlias, reason, viaServers))
}
override suspend fun joinRoom(roomId: String,
override suspend fun joinRoom(
roomId: String,
reason: String?,
thirdPartySigned: SignInvitationResult) {
thirdPartySigned: SignInvitationResult
) {
joinRoomTask.execute(JoinRoomTask.Params(roomId, reason, thirdPartySigned = thirdPartySigned))
}

View File

@ -85,16 +85,20 @@ internal class RoomSummaryDataSource @Inject constructor(
}
}
fun getRoomSummaries(queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE): List<RoomSummary> {
fun getRoomSummaries(
queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE
): List<RoomSummary> {
return monarchy.fetchAllMappedSync(
{ roomSummariesQuery(it, queryParams).process(sortOrder) },
{ roomSummaryMapper.map(it) }
)
}
fun getRoomSummariesLive(queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE): LiveData<List<RoomSummary>> {
fun getRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE
): LiveData<List<RoomSummary>> {
return monarchy.findAllMappedWithChanges(
{
roomSummariesQuery(it, queryParams).process(sortOrder)
@ -103,8 +107,10 @@ internal class RoomSummaryDataSource @Inject constructor(
)
}
fun getSpaceSummariesLive(queryParams: SpaceSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE): LiveData<List<RoomSummary>> {
fun getSpaceSummariesLive(
queryParams: SpaceSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE
): LiveData<List<RoomSummary>> {
return getRoomSummariesLive(queryParams, sortOrder)
}
@ -129,8 +135,10 @@ internal class RoomSummaryDataSource @Inject constructor(
}
}
fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE): List<RoomSummary> {
fun getSpaceSummaries(
spaceSummaryQueryParams: SpaceSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.NONE
): List<RoomSummary> {
return getRoomSummaries(spaceSummaryQueryParams, sortOrder)
}
@ -171,9 +179,11 @@ internal class RoomSummaryDataSource @Inject constructor(
.sort(RoomSummaryEntityFields.BREADCRUMBS_INDEX)
}
fun getSortedPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
fun getSortedPagedRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
pagedListConfig: PagedList.Config,
sortOrder: RoomSortOrder): LiveData<PagedList<RoomSummary>> {
sortOrder: RoomSortOrder
): LiveData<PagedList<RoomSummary>> {
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
roomSummariesQuery(realm, queryParams).process(sortOrder)
}
@ -186,10 +196,12 @@ internal class RoomSummaryDataSource @Inject constructor(
)
}
fun getUpdatablePagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
fun getUpdatablePagedRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
pagedListConfig: PagedList.Config,
sortOrder: RoomSortOrder,
getFlattenedParents: Boolean = false): UpdatableLivePageResult {
getFlattenedParents: Boolean = false
): UpdatableLivePageResult {
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
roomSummariesQuery(realm, queryParams).process(sortOrder)
}
@ -424,11 +436,13 @@ internal class RoomSummaryDataSource @Inject constructor(
}
}
fun flattenSubSpace(current: RoomSummary,
fun flattenSubSpace(
current: RoomSummary,
parenting: List<String>,
output: MutableList<RoomSummary>,
memberShips: List<Membership>,
includeCurrent: Boolean = true) {
includeCurrent: Boolean = true
) {
if (includeCurrent) {
output.add(current)
}

View File

@ -37,18 +37,22 @@ import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
class RoomSummaryItemFactory @Inject constructor(private val displayableEventFormatter: DisplayableEventFormatter,
class RoomSummaryItemFactory @Inject constructor(
private val displayableEventFormatter: DisplayableEventFormatter,
private val dateFormatter: VectorDateFormatter,
private val stringProvider: StringProvider,
private val typingHelper: TypingHelper,
private val avatarRenderer: AvatarRenderer,
private val errorFormatter: ErrorFormatter) {
private val errorFormatter: ErrorFormatter
) {
fun create(roomSummary: RoomSummary,
fun create(
roomSummary: RoomSummary,
roomChangeMembershipStates: Map<String, ChangeMembershipState>,
selectedRoomIds: Set<String>,
displayMode: RoomListDisplayMode,
listener: RoomListListener?): VectorEpoxyModel<*> {
listener: RoomListListener?
): VectorEpoxyModel<*> {
return when (roomSummary.membership) {
Membership.INVITE -> {
val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown
@ -60,9 +64,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
}
}
fun createSuggestion(spaceChildInfo: SpaceChildInfo,
fun createSuggestion(
spaceChildInfo: SpaceChildInfo,
suggestedRoomJoiningStates: Map<String, Async<Unit>>,
listener: RoomListListener?): VectorEpoxyModel<*> {
listener: RoomListListener?
): VectorEpoxyModel<*> {
val error = (suggestedRoomJoiningStates[spaceChildInfo.childRoomId] as? Fail)?.error
return SpaceChildInfoItem_()
.id("sug_${spaceChildInfo.childRoomId}")
@ -84,9 +90,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
.itemClickListener { listener?.onSuggestedRoomClicked(spaceChildInfo) }
}
private fun createInvitationItem(roomSummary: RoomSummary,
private fun createInvitationItem(
roomSummary: RoomSummary,
changeMembershipState: ChangeMembershipState,
listener: RoomListListener?): VectorEpoxyModel<*> {
listener: RoomListListener?
): VectorEpoxyModel<*> {
val secondLine = if (roomSummary.isDirect) {
roomSummary.inviterId
} else {

View File

@ -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_HEIGHT_PX = 315
class ImageContentRenderer @Inject constructor(private val localFilesHelper: LocalFilesHelper,
class ImageContentRenderer @Inject constructor(
private val localFilesHelper: LocalFilesHelper,
private val activeSessionHolder: ActiveSessionHolder,
private val dimensionConverter: DimensionConverter,
private val vectorPreferences: VectorPreferences) {
private val vectorPreferences: VectorPreferences
) {
@Parcelize
data class Data(
@ -184,19 +186,23 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
createGlideRequest(data, mode, imageView, size)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?,
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean): Boolean {
isFirstResource: Boolean
): Boolean {
callback?.invoke(false)
return false
}
override fun onResourceReady(resource: Drawable?,
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean): Boolean {
isFirstResource: Boolean
): Boolean {
callback?.invoke(true)
return false
}
@ -227,19 +233,23 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
}
req.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?,
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean): Boolean {
isFirstResource: Boolean
): Boolean {
callback?.invoke(false)
return false
}
override fun onResourceReady(resource: Drawable?,
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean): Boolean {
isFirstResource: Boolean
): Boolean {
callback?.invoke(true)
return false
}