Commit Graph

84 Commits

Author SHA1 Message Date
Benoit Marty
826cacf209 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +02:00
Benoit Marty
64b5b53510 Improve API and documentation 2025-10-21 11:53:36 +02:00
Benoit Marty
c4884879d8 Avoid emitted a new value each time the token is refreshed (for instance) 2025-10-20 16:33:48 +02:00
Benoit Marty
64ff19c808 Update API around brandColor. 2025-10-20 16:33:46 +02:00
Benoit Marty
2109ad74b5 Add missing @Immutable annotation 2025-10-09 18:22:17 +02:00
Benoit Marty
73a6ba2849 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 e409630856d7a7e741548016d7afe174ff1b40f7.

* Revert "Rename Node to follow naming convention."

This reverts commit 883b1f37c7207512d9f6605749977ad9045846a1.

* Revert "Introduce LoggedInAccountSwitcherNode, to improve animation when switching between accounts."

This reverts commit 9c698ff8152aceb5fd2b8b5ab5f609d28de64d24.

* Metro now have `@AssistedInject`.

* Update screenshots

* Introduce DelegateTransitionHandler and use it in RootFlowNode

---------

Co-authored-by: ElementBot <android@element.io>
Co-authored-by: ganfra <francoisg@element.io>
2025-09-26 15:45:06 +02:00
Benoit Marty
8e819d48ed Rename API and update test. 2025-09-19 10:57:18 +02:00
Benoit Marty
06bcbb8bb8 Rename method storeData to addSession. 2025-09-19 10:57:17 +02:00
Benoit Marty
629fc552e5 Use DependencyHandlerScope.testCommonDependencies() 2025-09-16 14:38:31 +02:00
Jorge Martín
dca1c5b516 Remove dagger and anvil dependencies, try to simplify gradle build scripts a bit 2025-09-04 16:49:21 +02:00
Jorge Martín
e06bacbff3 Redo DI gradle setup code 2025-09-04 16:49:20 +02:00
Jorge Martín
fc3153bd26 Fix lint issues and restore commented out code 2025-09-04 16:49:18 +02:00
Jorge Martín
92a4b8b66b Start migrating Anvil KSP to Metro 2025-09-04 16:48:34 +02:00
Benoit Marty
a3fa1744b2 Fix error. 2025-09-01 16:41:12 +02:00
Benoit Marty
a00623e490 Cleanup tests. 2025-09-01 15:03:41 +02:00
Benoit Marty
5f223f3c89 Refactor: Move InMemorySessionStore to test module
- Delete `libraries/session-storage/impl-memory` module
- Move `InMemorySessionStore.kt` to `libraries/session-storage/test`
2025-09-01 14:47:42 +02:00
Benoit Marty
03e23477b7 Fix coroutine scope (#4820)
* Inject the session scope instead of the application scope where it's possible.

* Create AppCoroutineScope annotation to let developers explicitly choose the appropriate CoroutineScope when injecting one.
2025-06-04 15:33:51 +00:00
renovate[bot]
5ec485911e fix(deps): update sqldelight to v2.1.0 (#4735)
* fix(deps): update sqldelight to v2.1.0

* Ignore new returned value from database query which know have type QueryResult<Long>.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2025-05-26 14:58:57 +02:00
renovate[bot]
88727098ec fix(deps): update kotlin (#4552)
* fix(deps): update kotlin

* Fix deprecation warning

* Remove this workaround, it's not needed anymore, and was causing a compilation error:

* What went wrong:
A problem occurred configuring project ':libraries:session-storage:impl'.
> Failed to notify project evaluation listener.
   > Element 'kspDebugKotlin' of type 'com.google.devtools.ksp.gradle.KspAATask_Decorated' from container 'task set' cannot be cast to 'org.jetbrains.kotlin.gradle.tasks.KotlinCompile'.
   > Element 'kspReleaseKotlin' of type 'com.google.devtools.ksp.gradle.KspAATask_Decorated' from container 'task set' cannot be cast to 'org.jetbrains.kotlin.gradle.tasks.KotlinCompile'.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2025-04-09 16:45:48 +02:00
Jorge Martin Espinosa
e2afa9a691 Add Google Tink dependency, replacing androidx.security.crypto (#4405)
* Add Google Tink dependency, replacing `androidx.security.crypto`

* Replace the `EncryptedFile` implementation too

* Extract constants, add some more docs
2025-03-17 10:04:21 +01:00
Benoit Marty
05fc76822a Apply dual licenses: AGPL + Element Commercial to file headers.
2 replace all actions have been performed:
- "SPDX-License-Identifier: AGPL-3.0-only" to "SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial"
- "Please see LICENSE in the repository root for full details." to "Please see LICENSE files in the repository root for full details."
2025-01-07 10:05:04 +01:00
Jorge Martin Espinosa
4a43fcb69a Use Anvil KSP instead of the Square KAPT one (#3564)
* Use Anvil KSP instead of the Square KAPT one

* Fix several configuration cache, lint and test issues

* Allow incremental kotlin compilation in the CI

* Workaround Robolectric + Compose issue that caused `AppNotIdleException`

* Update the `enterprise` commit hash

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
2024-10-02 11:52:17 +00:00
Jorge Martin Espinosa
2efdb3ae45 Centralise the DI code generation logic (#3562)
* Create Anvil extension helper

* Use the helper everywhere
2024-09-30 12:20:28 +00:00
Benoit Marty
cc78096d87 Add test on RustClientSessionDelegate 2024-09-19 12:30:40 +02:00
Benoit Marty
888d3420d7 Use aSessionData() from the test module.
And fix typo.
2024-09-18 17:16:06 +02:00
Benoit Marty
2b016227e9 Migrate license to AGPL.
Run script `uv run license-editor --repository ../element-x-android`
2024-09-06 17:19:19 +02:00
Benoit Marty
9693a248f7 Add missing test for AppMigration06 2024-09-06 11:51:59 +02:00
Benoit Marty
c51d098679 Add missing test for AppMigration05 2024-09-06 11:41:13 +02:00
Benoit Marty
b062431f1b Fix test compilation issue. 2024-09-03 10:01:45 +02:00
Benoit Marty
93cace6954 Provide distinct cache directory to the Rust SDK. 2024-08-30 18:36:20 +02:00
Benoit Marty
e31bbc2b7e Add unit test on DefaultImageLoaderHolder 2024-06-24 14:42:04 +02:00
ganfra
056cf0a884 Session : fix sessionPath missing 2024-06-12 15:42:30 +02:00
Jorge Martín
841558c3b4 Add session path migration to SessionData 2024-06-06 17:06:57 +02:00
Benoit Marty
cdf6f48112 Change Test class suffix. 2024-05-30 10:11:18 +02:00
Benoit Marty
9762962586 Add test on DefaultFirebaseNewTokenHandler 2024-05-22 18:42:39 +02:00
Jorge Martin Espinosa
822705195f Fix crash when creating an EncryptedFile in Android 6 (#2853) 2024-05-15 16:10:16 +00:00
Jorge Martin Espinosa
9aadec8435 Enforce mandatory session verification only for new logins (#2811)
* Enforce mandatory session verification only for new logins

- Creates `AppMigration` base interface as a way to isolate migration logic, app migrations must implement this interface.
- Creates `AppMigration01` with the existing logs removal migration and `AppMigration02` with the logic to allow existing sessions to skip verification.
- Add `DefaultSessionPreferencesStoreFactory.remove(sessionId)` to allow a ephemeral session store access to exist outside the `SessionScope` for this new migration.

* Fix tests

* Add more tests.

This also includes creating several abstractions.

* Review changes.

- Make `orderedMigrations` a class property, `migrations` just a constructor parameter to avoid incorrect usages.
- Create `lastMigration` property too, use it instead of `MIGRATION_VERSION`.
2024-05-07 14:06:34 +00:00
Jorge Martin Espinosa
2cc124bda2 Remove SessionData.needsVerification as the source of truth for session verification status (#2748)
* Remove `SessionData.needsVerification` as the source of truth for session verification status.

- Use the Rust SDK `EncryptionService.verificationState()` instead, but always waiting for the first 'known' result (either verified or not, discarding 'unknown').
- Add a workaround in the super rare case when reading this value gets stuck somehow. We'll assume the user is not verified in that case.
- Make `DefaultFtueService.getNextStep` and dependent checks `suspend`.
- Make the `skip` button use a value in the session preferences instead.

* Log exception when the verification status can't be loaded

Co-authored-by: Benoit Marty <benoit@matrix.org>

* Fix review comments

---------

Co-authored-by: Benoit Marty <benoit@matrix.org>
2024-04-24 13:55:25 +00:00
Jorge Martin Espinosa
c8b5458878 Add SessionData.needsVerification field (#2672)
* Add `SessionData.needsVerification`:
  - Allows us to add a skip button for debug builds.
  - We can have the verification state almost instantly.
  - It doesn't depend on network availability to know the verification state and display the UI.
* Add DB migration.
- Make the skip button in the verification flow skip the whole flow including the completed screen.
- Save the session as verified in `RustEncryptionService.recover(recoveryKey)`.
* Enforce session verification for existing users too.
* Fix verification confirmed screen subtitle (typo in id, was using the wrong string)
* Update screenshots

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2024-04-09 17:28:12 +02:00
Benoit Marty
142338be07 An interface is enough. 2024-02-27 14:42:43 +01:00
Benoit Marty
0c8631417a Add test for DatabaseSessionStore.getAllSessions(), and update data when session is not found. 2024-02-27 12:04:59 +01:00
Benoit Marty
0c6a26f6c1 Add test on DefaultSessionObserver. 2024-02-27 11:39:17 +01:00
Benoit Marty
ca35c0a800 Remove useless log. 2024-02-27 10:41:14 +01:00
Benoit Marty
5e5eddd537 Merge pull request #2244 from element-hq/feature/bma/encryptedDb2
Encrypted db
2024-01-19 17:40:23 +01:00
Jorge Martin Espinosa
b755a2584b Try mitigating unexpected logouts (#2251)
* Try mitigating unexpected logouts.

Try making getting/storing session data use a Mutex for synchronization.

Also added some more logs so we can understand exactly where it's failing.
2024-01-18 16:22:25 +01:00
Benoit Marty
95e228a993 Fix test. 2024-01-18 12:44:20 +01:00
Benoit Marty
d04f76e8cf SessionData: add the passphrase. 2024-01-18 11:50:05 +01:00
Benoit Marty
378692f743 Fix moar ktlint issues 2024-01-11 10:02:10 +01:00
renovate[bot]
7e9cda3aa9 Update plugin ktlint to v12.1.0 (#2200)
* Update plugin ktlint to v12.1.0

* Run `./gradlew ktlintFormat` and fix some issues manually.

* Fix other issues reproted by Ktlint

* Limit false positives, KtLint removes unnecessary curly brace in String templates.

* Remove useless Unit

* Minor improvements over ktlint changes

* Restore `AlertDialogContent` behaviour

* Update screenshots

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2024-01-10 16:22:24 +01:00
Marco Romano
fb02f698d7 Include desugaring lib also in library modules (#1604)
## Type of change

- [ ] Feature
- [ ] Bugfix
- [x] Technical
- [ ] Other :

## Content

Includes the `coreLibraryDesugaring(libs.android.desugar)` dependency in all modules which use one of our gradle plugins.

## Motivation and context

Right now desugaring is enabled also in library modules but the desugar dependency is not included in those.
This causes some unwanted side effects such as being unable to run compose previews in an emu.

This change will also include the desugar dependency in those libraries.
2023-10-19 09:00:32 +00:00