From f2165201ebcdb9a7dc84c4f7bce172c5db8abd26 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 13 Jan 2022 17:53:26 +0100 Subject: [PATCH] Remove unused module matrix-sdk-android-rx and do some cleanup --- attachment-viewer/build.gradle | 3 - build.gradle | 10 - changelog.d/4942.misc | 1 + dependencies.gradle | 4 +- matrix-sdk-android-rx/.gitignore | 1 - matrix-sdk-android-rx/build.gradle | 47 ---- matrix-sdk-android-rx/proguard-rules.pro | 21 -- .../src/main/AndroidManifest.xml | 1 - .../android/sdk/rx/LiveDataObservable.kt | 71 ----- .../org/matrix/android/sdk/rx/OptionalRx.kt | 30 --- .../java/org/matrix/android/sdk/rx/RxRoom.kt | 158 ----------- .../org/matrix/android/sdk/rx/RxSession.kt | 251 ------------------ .../sdk/rx/SecretsSynchronisationInfo.kt | 27 -- settings.gradle | 1 - 14 files changed, 2 insertions(+), 624 deletions(-) create mode 100644 changelog.d/4942.misc delete mode 100644 matrix-sdk-android-rx/.gitignore delete mode 100644 matrix-sdk-android-rx/build.gradle delete mode 100644 matrix-sdk-android-rx/proguard-rules.pro delete mode 100644 matrix-sdk-android-rx/src/main/AndroidManifest.xml delete mode 100644 matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt delete mode 100644 matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt delete mode 100644 matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt delete mode 100644 matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt delete mode 100644 matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/SecretsSynchronisationInfo.kt diff --git a/attachment-viewer/build.gradle b/attachment-viewer/build.gradle index 02fbfc794c..8f3d970834 100644 --- a/attachment-viewer/build.gradle +++ b/attachment-viewer/build.gradle @@ -50,9 +50,6 @@ dependencies { implementation 'com.github.chrisbanes:PhotoView:2.3.0' - implementation libs.rx.rxKotlin - implementation libs.rx.rxAndroid - implementation libs.androidx.core implementation libs.androidx.appCompat implementation libs.androidx.recyclerview diff --git a/build.gradle b/build.gradle index b7299b01f7..5fdeba24de 100644 --- a/build.gradle +++ b/build.gradle @@ -153,13 +153,3 @@ project(":diff-match-patch") { // } // } //} -// -//project(":matrix-sdk-android-rx") { -// sonarqube { -// properties { -// property "sonar.sources", project(":matrix-sdk-android-rx").android.sourceSets.main.java.srcDirs -// // exclude source code from analyses separated by a colon (:) -// // property "sonar.exclusions", "**/*.*" -// } -// } -//} diff --git a/changelog.d/4942.misc b/changelog.d/4942.misc new file mode 100644 index 0000000000..29fb8cee55 --- /dev/null +++ b/changelog.d/4942.misc @@ -0,0 +1 @@ +Remove unused module matrix-sdk-android-rx and do some cleanup \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle index 2243510f92..b4e1a7e7fa 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -42,7 +42,6 @@ ext.libs = [ jetbrains : [ 'coroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutines", 'coroutinesAndroid' : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutines", - 'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines", 'coroutinesTest' : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutines" ], androidx : [ @@ -87,8 +86,7 @@ ext.libs = [ 'retrofitMoshi' : "com.squareup.retrofit2:converter-moshi:$retrofit" ], rx : [ - 'rxKotlin' : "io.reactivex.rxjava2:rxkotlin:2.4.0", - 'rxAndroid' : "io.reactivex.rxjava2:rxandroid:2.1.1" + 'rxKotlin' : "io.reactivex.rxjava2:rxkotlin:2.4.0" ], arrow : [ 'core' : "io.arrow-kt:arrow-core:$arrow", diff --git a/matrix-sdk-android-rx/.gitignore b/matrix-sdk-android-rx/.gitignore deleted file mode 100644 index 796b96d1c4..0000000000 --- a/matrix-sdk-android-rx/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle deleted file mode 100644 index dbd761cee3..0000000000 --- a/matrix-sdk-android-rx/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' - -android { - compileSdk versions.compileSdk - - defaultConfig { - minSdk versions.minSdk - targetSdk versions.targetSdk - - // Multidex is useful for tests - multiDexEnabled true - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility versions.sourceCompat - targetCompatibility versions.targetCompat - } - - kotlinOptions { - jvmTarget = "11" - } -} - -dependencies { - - implementation project(":matrix-sdk-android") - implementation libs.androidx.appCompat - implementation libs.rx.rxKotlin - implementation libs.rx.rxAndroid - implementation libs.jetbrains.coroutinesRx2 - - // Paging - implementation libs.androidx.pagingRuntimeKtx - - // Logging - implementation libs.jakewharton.timber -} diff --git a/matrix-sdk-android-rx/proguard-rules.pro b/matrix-sdk-android-rx/proguard-rules.pro deleted file mode 100644 index f1b424510d..0000000000 --- a/matrix-sdk-android-rx/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/matrix-sdk-android-rx/src/main/AndroidManifest.xml b/matrix-sdk-android-rx/src/main/AndroidManifest.xml deleted file mode 100644 index 5f399e9f84..0000000000 --- a/matrix-sdk-android-rx/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt deleted file mode 100644 index 56b52facf9..0000000000 --- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.matrix.android.sdk.rx - -import androidx.lifecycle.LiveData -import androidx.lifecycle.Observer -import io.reactivex.Observable -import io.reactivex.android.MainThreadDisposable -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.schedulers.Schedulers - -private class LiveDataObservable( - private val liveData: LiveData, - private val valueIfNull: T? = null -) : Observable() { - - override fun subscribeActual(observer: io.reactivex.Observer) { - val relay = RemoveObserverInMainThread(observer) - observer.onSubscribe(relay) - liveData.observeForever(relay) - } - - private inner class RemoveObserverInMainThread(private val observer: io.reactivex.Observer) : - MainThreadDisposable(), Observer { - - override fun onChanged(t: T?) { - if (!isDisposed) { - if (t == null) { - if (valueIfNull != null) { - observer.onNext(valueIfNull) - } else { - observer.onError(NullPointerException( - "convert liveData value t to RxJava onNext(t), t cannot be null")) - } - } else { - observer.onNext(t) - } - } - } - - override fun onDispose() { - liveData.removeObserver(this) - } - } -} - -fun LiveData.asObservable(): Observable { - return LiveDataObservable(this).observeOn(Schedulers.computation()) -} - -internal fun Observable.startWithCallable(supplier: () -> T): Observable { - val startObservable = Observable - .fromCallable(supplier) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - return startWith(startObservable) -} diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt deleted file mode 100644 index 936bd824e7..0000000000 --- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.matrix.android.sdk.rx - -import io.reactivex.Observable -import org.matrix.android.sdk.api.util.Optional - -fun Observable>.unwrap(): Observable { - return filter { it.hasValue() }.map { it.get() } -} - -fun Observable>.mapOptional(fn: (T) -> U?): Observable> { - return map { - it.map(fn) - } -} diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt deleted file mode 100644 index b3495c4493..0000000000 --- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.matrix.android.sdk.rx - -import android.net.Uri -import io.reactivex.Completable -import io.reactivex.Observable -import io.reactivex.Single -import kotlinx.coroutines.rx2.rxCompletable -import kotlinx.coroutines.rx2.rxSingle -import org.matrix.android.sdk.api.query.QueryStringValue -import org.matrix.android.sdk.api.session.content.ContentAttachmentData -import org.matrix.android.sdk.api.session.events.model.Event -import org.matrix.android.sdk.api.session.identity.ThreePid -import org.matrix.android.sdk.api.session.room.Room -import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams -import org.matrix.android.sdk.api.session.room.model.EventAnnotationsSummary -import org.matrix.android.sdk.api.session.room.model.GuestAccess -import org.matrix.android.sdk.api.session.room.model.ReadReceipt -import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility -import org.matrix.android.sdk.api.session.room.model.RoomJoinRules -import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary -import org.matrix.android.sdk.api.session.room.model.RoomSummary -import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState -import org.matrix.android.sdk.api.session.room.send.UserDraft -import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent -import org.matrix.android.sdk.api.util.Optional -import org.matrix.android.sdk.api.util.toOptional - -class RxRoom(private val room: Room) { - - fun liveRoomSummary(): Observable> { - return room.getRoomSummaryLive() - .asObservable() - .startWithCallable { room.roomSummary().toOptional() } - } - - fun liveRoomMembers(queryParams: RoomMemberQueryParams): Observable> { - return room.getRoomMembersLive(queryParams).asObservable() - .startWithCallable { - room.getRoomMembers(queryParams) - } - } - - fun liveAnnotationSummary(eventId: String): Observable> { - return room.getEventAnnotationsSummaryLive(eventId).asObservable() - .startWithCallable { - room.getEventAnnotationsSummary(eventId).toOptional() - } - } - - fun liveTimelineEvent(eventId: String): Observable> { - return room.getTimeLineEventLive(eventId).asObservable() - .startWithCallable { - room.getTimeLineEvent(eventId).toOptional() - } - } - - fun liveStateEvent(eventType: String, stateKey: QueryStringValue): Observable> { - return room.getStateEventLive(eventType, stateKey).asObservable() - .startWithCallable { - room.getStateEvent(eventType, stateKey).toOptional() - } - } - - fun liveStateEvents(eventTypes: Set): Observable> { - return room.getStateEventsLive(eventTypes).asObservable() - .startWithCallable { - room.getStateEvents(eventTypes) - } - } - - fun liveReadMarker(): Observable> { - return room.getReadMarkerLive().asObservable() - } - - fun liveReadReceipt(): Observable> { - return room.getMyReadReceiptLive().asObservable() - } - - fun loadRoomMembersIfNeeded(): Single = rxSingle { - room.loadRoomMembersIfNeeded() - } - - fun joinRoom(reason: String? = null, - viaServers: List = emptyList()): Single = rxSingle { - room.join(reason, viaServers) - } - - fun liveEventReadReceipts(eventId: String): Observable> { - return room.getEventReadReceiptsLive(eventId).asObservable() - } - - fun liveDraft(): Observable> { - return room.getDraftLive().asObservable() - .startWithCallable { - room.getDraft().toOptional() - } - } - - fun liveNotificationState(): Observable { - return room.getLiveRoomNotificationState().asObservable() - } - - fun invite(userId: String, reason: String? = null): Completable = rxCompletable { - room.invite(userId, reason) - } - - fun invite3pid(threePid: ThreePid): Completable = rxCompletable { - room.invite3pid(threePid) - } - - fun updateTopic(topic: String): Completable = rxCompletable { - room.updateTopic(topic) - } - - fun updateName(name: String): Completable = rxCompletable { - room.updateName(name) - } - - fun updateHistoryReadability(readability: RoomHistoryVisibility): Completable = rxCompletable { - room.updateHistoryReadability(readability) - } - - fun updateJoinRule(joinRules: RoomJoinRules?, guestAccess: GuestAccess?): Completable = rxCompletable { - room.updateJoinRule(joinRules, guestAccess) - } - - fun updateAvatar(avatarUri: Uri, fileName: String): Completable = rxCompletable { - room.updateAvatar(avatarUri, fileName) - } - - fun deleteAvatar(): Completable = rxCompletable { - room.deleteAvatar() - } - - fun sendMedia(attachment: ContentAttachmentData, compressBeforeSending: Boolean, roomIds: Set): Completable = rxCompletable { - room.sendMedia(attachment, compressBeforeSending, roomIds) - } -} - -fun Room.rx(): RxRoom { - return RxRoom(this) -} diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt deleted file mode 100644 index 47203816b4..0000000000 --- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.matrix.android.sdk.rx - -import androidx.paging.PagedList -import io.reactivex.Observable -import io.reactivex.Single -import io.reactivex.functions.Function3 -import kotlinx.coroutines.rx2.rxSingle -import org.matrix.android.sdk.api.extensions.orFalse -import org.matrix.android.sdk.api.query.QueryStringValue -import org.matrix.android.sdk.api.session.Session -import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent -import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME -import org.matrix.android.sdk.api.session.crypto.crosssigning.MASTER_KEY_SSSS_NAME -import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo -import org.matrix.android.sdk.api.session.crypto.crosssigning.SELF_SIGNING_KEY_SSSS_NAME -import org.matrix.android.sdk.api.session.crypto.crosssigning.USER_SIGNING_KEY_SSSS_NAME -import org.matrix.android.sdk.api.session.group.GroupSummaryQueryParams -import org.matrix.android.sdk.api.session.group.model.GroupSummary -import org.matrix.android.sdk.api.session.identity.FoundThreePid -import org.matrix.android.sdk.api.session.identity.ThreePid -import org.matrix.android.sdk.api.session.pushers.Pusher -import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams -import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataEvent -import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState -import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary -import org.matrix.android.sdk.api.session.room.model.RoomSummary -import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams -import org.matrix.android.sdk.api.session.space.SpaceSummaryQueryParams -import org.matrix.android.sdk.api.session.sync.SyncState -import org.matrix.android.sdk.api.session.user.model.User -import org.matrix.android.sdk.api.session.widgets.model.Widget -import org.matrix.android.sdk.api.util.JsonDict -import org.matrix.android.sdk.api.util.Optional -import org.matrix.android.sdk.api.util.toOptional -import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo -import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo -import org.matrix.android.sdk.internal.crypto.store.PrivateKeysInfo -import org.matrix.android.sdk.internal.session.room.alias.RoomAliasDescription - -class RxSession(private val session: Session) { - - fun liveRoomSummaries(queryParams: RoomSummaryQueryParams): Observable> { - return session.getRoomSummariesLive(queryParams).asObservable() - .startWithCallable { - session.getRoomSummaries(queryParams) - } - } - - fun liveGroupSummaries(queryParams: GroupSummaryQueryParams): Observable> { - return session.getGroupSummariesLive(queryParams).asObservable() - .startWithCallable { - session.getGroupSummaries(queryParams) - } - } - - fun liveSpaceSummaries(queryParams: SpaceSummaryQueryParams): Observable> { - return session.spaceService().getSpaceSummariesLive(queryParams).asObservable() - .startWithCallable { - session.spaceService().getSpaceSummaries(queryParams) - } - } - - fun liveBreadcrumbs(queryParams: RoomSummaryQueryParams): Observable> { - return session.getBreadcrumbsLive(queryParams).asObservable() - .startWithCallable { - session.getBreadcrumbs(queryParams) - } - } - - fun liveMyDevicesInfo(): Observable> { - return session.cryptoService().getLiveMyDevicesInfo().asObservable() - .startWithCallable { - session.cryptoService().getMyDevicesInfo() - } - } - - fun liveSyncState(): Observable { - return session.getSyncStateLive().asObservable() - } - - fun livePushers(): Observable> { - return session.getPushersLive().asObservable() - } - - fun liveUser(userId: String): Observable> { - return session.getUserLive(userId).asObservable() - .startWithCallable { - session.getUser(userId).toOptional() - } - } - - fun liveRoomMember(userId: String, roomId: String): Observable> { - return session.getRoomMemberLive(userId, roomId).asObservable() - .startWithCallable { - session.getRoomMember(userId, roomId).toOptional() - } - } - - fun liveUsers(): Observable> { - return session.getUsersLive().asObservable() - } - - fun liveIgnoredUsers(): Observable> { - return session.getIgnoredUsersLive().asObservable() - } - - fun livePagedUsers(filter: String? = null, excludedUserIds: Set? = null): Observable> { - return session.getPagedUsersLive(filter, excludedUserIds).asObservable() - } - - fun liveThreePIds(refreshData: Boolean): Observable> { - return session.getThreePidsLive(refreshData).asObservable() - .startWithCallable { session.getThreePids() } - } - - fun livePendingThreePIds(): Observable> { - return session.getPendingThreePidsLive().asObservable() - .startWithCallable { session.getPendingThreePids() } - } - - fun createRoom(roomParams: CreateRoomParams): Single = rxSingle { - session.createRoom(roomParams) - } - - fun searchUsersDirectory(search: String, - limit: Int, - excludedUserIds: Set): Single> = rxSingle { - session.searchUsersDirectory(search, limit, excludedUserIds) - } - - fun joinRoom(roomIdOrAlias: String, - reason: String? = null, - viaServers: List = emptyList()): Single = rxSingle { - session.joinRoom(roomIdOrAlias, reason, viaServers) - } - - fun getRoomIdByAlias(roomAlias: String, - searchOnServer: Boolean): Single> = rxSingle { - session.getRoomIdByAlias(roomAlias, searchOnServer) - } - - fun getProfileInfo(userId: String): Single = rxSingle { - session.getProfile(userId) - } - - fun liveUserCryptoDevices(userId: String): Observable> { - return session.cryptoService().getLiveCryptoDeviceInfo(userId).asObservable().startWithCallable { - session.cryptoService().getCryptoDeviceInfo(userId) - } - } - - fun liveCrossSigningInfo(userId: String): Observable> { - return session.cryptoService().crossSigningService().getLiveCrossSigningKeys(userId).asObservable() - .startWithCallable { - session.cryptoService().crossSigningService().getUserCrossSigningKeys(userId).toOptional() - } - } - - fun liveCrossSigningPrivateKeys(): Observable> { - return session.cryptoService().crossSigningService().getLiveCrossSigningPrivateKeys().asObservable() - .startWithCallable { - session.cryptoService().crossSigningService().getCrossSigningPrivateKeys().toOptional() - } - } - - fun liveUserAccountData(types: Set): Observable> { - return session.accountDataService().getLiveUserAccountDataEvents(types).asObservable() - .startWithCallable { - session.accountDataService().getUserAccountDataEvents(types) - } - } - - fun liveRoomAccountData(types: Set): Observable> { - return session.accountDataService().getLiveRoomAccountDataEvents(types).asObservable() - .startWithCallable { - session.accountDataService().getRoomAccountDataEvents(types) - } - } - - fun liveRoomWidgets( - roomId: String, - widgetId: QueryStringValue, - widgetTypes: Set? = null, - excludedTypes: Set? = null - ): Observable> { - return session.widgetService().getRoomWidgetsLive(roomId, widgetId, widgetTypes, excludedTypes).asObservable() - .startWithCallable { - session.widgetService().getRoomWidgets(roomId, widgetId, widgetTypes, excludedTypes) - } - } - - fun liveRoomChangeMembershipState(): Observable> { - return session.getChangeMembershipsLive().asObservable() - } - - fun liveSecretSynchronisationInfo(): Observable { - return Observable.combineLatest, Optional, Optional, SecretsSynchronisationInfo>( - liveUserAccountData(setOf(MASTER_KEY_SSSS_NAME, USER_SIGNING_KEY_SSSS_NAME, SELF_SIGNING_KEY_SSSS_NAME, KEYBACKUP_SECRET_SSSS_NAME)), - liveCrossSigningInfo(session.myUserId), - liveCrossSigningPrivateKeys(), - Function3 { _, crossSigningInfo, pInfo -> - // first check if 4S is already setup - val is4SSetup = session.sharedSecretStorageService.isRecoverySetup() - val isCrossSigningEnabled = crossSigningInfo.getOrNull() != null - val isCrossSigningTrusted = crossSigningInfo.getOrNull()?.isTrusted() == true - val allPrivateKeysKnown = pInfo.getOrNull()?.allKnown().orFalse() - - val keysBackupService = session.cryptoService().keysBackupService() - val currentBackupVersion = keysBackupService.currentBackupVersion - val megolmBackupAvailable = currentBackupVersion != null - val savedBackupKey = keysBackupService.getKeyBackupRecoveryKeyInfo() - - val megolmKeyKnown = savedBackupKey?.version == currentBackupVersion - SecretsSynchronisationInfo( - isBackupSetup = is4SSetup, - isCrossSigningEnabled = isCrossSigningEnabled, - isCrossSigningTrusted = isCrossSigningTrusted, - allPrivateKeysKnown = allPrivateKeysKnown, - megolmBackupAvailable = megolmBackupAvailable, - megolmSecretKnown = megolmKeyKnown, - isMegolmKeyIn4S = session.sharedSecretStorageService.isMegolmKeyInBackup() - ) - } - ) - .distinctUntilChanged() - } - - fun lookupThreePid(threePid: ThreePid): Single> = rxSingle { - session.identityService().lookUp(listOf(threePid)).firstOrNull().toOptional() - } -} - -fun Session.rx(): RxSession { - return RxSession(this) -} diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/SecretsSynchronisationInfo.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/SecretsSynchronisationInfo.kt deleted file mode 100644 index 6da3217070..0000000000 --- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/SecretsSynchronisationInfo.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.matrix.android.sdk.rx - -data class SecretsSynchronisationInfo( - val isBackupSetup: Boolean, - val isCrossSigningEnabled: Boolean, - val isCrossSigningTrusted: Boolean, - val allPrivateKeysKnown: Boolean, - val megolmBackupAvailable: Boolean, - val megolmSecretKnown: Boolean, - val isMegolmKeyIn4S: Boolean -) diff --git a/settings.gradle b/settings.gradle index e3b84b4733..84b908e97c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,5 @@ include ':vector' include ':matrix-sdk-android' -include ':matrix-sdk-android-rx' include ':diff-match-patch' include ':attachment-viewer' include ':multipicker'