Skip to content

Commit 1e54633

Browse files
bmartyElementBotganfra
authored
Multi accounts - experimental first implementation (#5285)
* Multi account - Do not reset analytics store on sign out. Else when 1 of many accounts is removed, the analytics opt in screen is displayed again. * Multi accounts - first implementation. * Multi accounts - Prevent user from logging twice with the same account * Multi accounts - ignore automatic GoBack in case of error. * Multi accounts - update first view when adding an account. * Rename method storeData to addSession. * Multi accounts - handle account switch when coming from a notification * Multi accounts - handle login link when there is already an account. * Multi accounts - handle click on push history for not current account. * Multi accounts - improve layout and add preview. * Add accountselect modules * Multi accounts - incoming share with account selection * Multi accounts - check the feature flag before allowing login using login link. * Multi accounts - swipe on account icon * Cleanup * Multi accounts - fix other implementation of SessionStore * Multi accounts - fix PreferencesRootPresenterTest * Multi accounts - Add test on AccountSelectPresenter * Multi accounts - Fix test on HomePresenter - WIP * Update database to be able to sort accounts by creation date. * Add unit test on takeCurrentUserWithNeighbors * Fix test and improve code. * Add exception * Multi accounts - handle permalink * Code quality * Multi accounts - localization * Fix issue after rebase on develop * Fix issue after rebase on develop * Fix tests * Fix tests * Fix tests * Fix tests * Update Multi accounts flag details. * Add missing test on DatabaseSessionStore * Add missing preview on LoginModeView * Remove dead code. * Add missing preview on PushHistoryView * Document API. * Rename API and update test. * Remove MatrixAuthenticationService.loggedInStateFlow() * Update screenshots * Remove unused import * Add exception * Fix compilation issue after rebase on develop. * Update screenshots * Fix test * Avoid calling getLatestSession() twice * Rename `matrixUserAndNeighbors` to `currentUserAndNeighbors` * Extract code to its own class. * Add comment to clarify the code. * Init current user profile with what we now have in the database. It allows having the cached data (user display name and avatar) when starting the application when no network is available. * Let the RustMatrixClient update the profile in the session database * Fix test. * When logging out from Pin code screen, logout from all the sessions. tom * Make PushData.clientSecret mandatory. Also do not restore the last session as a fallback, it can lead to error in a multi account context, or even when a ghost pusher send a Push. * Change test in RustMatrixAuthenticationServiceTest * Do not use MatrixAuthenticationService in RootFlowNode, only use SessionStore * Remove MatrixAuthenticationService.getLatestSessionId() * Fix compilation issue after merging develop * Add test on DefaultAccountSelectEntryPoint * Fix compilation issue after merging develop * Introduce LoggedInAccountSwitcherNode, to improve animation when switching between accounts. * Rename Node to follow naming convention. * Fix navigation issue after login. * Remove unused import * Revert "Fix navigation issue after login." This reverts commit e409630. * Revert "Rename Node to follow naming convention." This reverts commit 883b1f3. * Revert "Introduce LoggedInAccountSwitcherNode, to improve animation when switching between accounts." This reverts commit 9c698ff. * Metro now have `@AssistedInject`. * Update screenshots * Introduce DelegateTransitionHandler and use it in RootFlowNode --------- Co-authored-by: ElementBot <[email protected]> Co-authored-by: ganfra <[email protected]>
1 parent a8c4d5d commit 1e54633

File tree

117 files changed

+2161
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2161
-281
lines changed

appnav/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ dependencies {
2626
allFeaturesApi(project)
2727

2828
implementation(projects.libraries.core)
29+
implementation(projects.libraries.accountselect.api)
2930
implementation(projects.libraries.androidutils)
3031
implementation(projects.libraries.architecture)
3132
implementation(projects.libraries.deeplink.api)
33+
implementation(projects.libraries.featureflag.api)
3234
implementation(projects.libraries.matrix.api)
3335
implementation(projects.libraries.oidc.api)
3436
implementation(projects.libraries.preferences.api)

appnav/src/main/kotlin/io/element/android/appnav/LoggedInAppScopeFlowNode.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class LoggedInAppScopeFlowNode(
5757
), DependencyInjectionGraphOwner {
5858
interface Callback : Plugin {
5959
fun onOpenBugReport()
60+
fun onAddAccount()
6061
}
6162

6263
@Parcelize
@@ -83,6 +84,10 @@ class LoggedInAppScopeFlowNode(
8384
override fun onOpenBugReport() {
8485
plugins<Callback>().forEach { it.onOpenBugReport() }
8586
}
87+
88+
override fun onAddAccount() {
89+
plugins<Callback>().forEach { it.onAddAccount() }
90+
}
8691
}
8792
return createNode<LoggedInFlowNode>(buildContext, listOf(callback))
8893
}

appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ import io.element.android.libraries.matrix.api.core.EventId
7676
import io.element.android.libraries.matrix.api.core.MAIN_SPACE
7777
import io.element.android.libraries.matrix.api.core.RoomId
7878
import io.element.android.libraries.matrix.api.core.RoomIdOrAlias
79-
import io.element.android.libraries.matrix.api.core.SessionId
8079
import io.element.android.libraries.matrix.api.core.UserId
8180
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
8281
import io.element.android.libraries.matrix.api.permalink.PermalinkData
@@ -139,6 +138,7 @@ class LoggedInFlowNode(
139138
) {
140139
interface Callback : Plugin {
141140
fun onOpenBugReport()
141+
fun onAddAccount()
142142
}
143143

144144
private val loggedInFlowProcessor = LoggedInEventProcessor(
@@ -393,6 +393,10 @@ class LoggedInFlowNode(
393393
}
394394
is NavTarget.Settings -> {
395395
val callback = object : PreferencesEntryPoint.Callback {
396+
override fun onAddAccount() {
397+
plugins<Callback>().forEach { it.onAddAccount() }
398+
}
399+
396400
override fun onOpenBugReport() {
397401
plugins<Callback>().forEach { it.onOpenBugReport() }
398402
}
@@ -405,11 +409,7 @@ class LoggedInFlowNode(
405409
backstack.push(NavTarget.Room(roomId.toRoomIdOrAlias(), initialElement = RoomNavigationTarget.NotificationSettings))
406410
}
407411

408-
override fun navigateTo(sessionId: SessionId, roomId: RoomId, eventId: EventId) {
409-
// We do not check the sessionId, but it will have to be done at some point (multi account)
410-
if (sessionId != matrixClient.sessionId) {
411-
Timber.e("SessionId mismatch, expected ${matrixClient.sessionId} but got $sessionId")
412-
}
412+
override fun navigateTo(roomId: RoomId, eventId: EventId) {
413413
backstack.push(NavTarget.Room(roomId.toRoomIdOrAlias(), initialElement = RoomNavigationTarget.Messages(eventId)))
414414
}
415415
}

0 commit comments

Comments
 (0)