Commit Graph

77 Commits

Author SHA1 Message Date
Benoit Marty
953af00fa2 It seems that SqlDelight v2.3.1 does not like unnecessary file 2026-03-13 18:53:08 +01:00
Jorge Martin Espinosa
721add707c Simplify push notification flow by using locally stored values for pending pushes (#6258)
* Create `PushRequest` in push history DB: this will be used to store requests for push notifications, either pending or completed ones.

* Rename `WorkManagerRequest` to `WorkManagerRequestBuilder`: make its `build` method return a list of `WorkManagerRequestWrapper`, which can be used to enqueue normal or unique workers.

* Rename `PerformDatabaseVacuumRequestBuilder` and adapt it to the new API.

* Adjust other components using `WorkManagerRequest`.

* Replace `SyncNotificationWorkManagerRequestBuilder` with `SyncPendingNotificationsRequestBuilder` and `FetchNotificationsWorker` with `FetchPendingNotificationsWorker`: this new pair of request builder and worker allow enqueuing requests for a session id and, once the worker runs, retrieve all the pending request data and use it to fetch the associated events. This simplifies quite a bit how this data had to be passed or grouped, since it's no longer necessary to do so

* Add new methods to `PushHistoryService` to modify the `PushDatabase`:

- insertOrUpdatePushRequest
- insertOrUpdatePushRequests
- getPendingPushRequests
- removeOldPushRequests

* Make `PushHandler` just handle incoming pushes: those will be inserted into the pending push request table in DB, then handled by the new worker. Once the process finished, a new `NotificationResultProcessor` will handle the results and what needs to be done with them (call ringing, displaying notifications, etc.)

* Add `requestType` optional parameter to `WorkManagerScheduler.cancel` so we can decide to only cancel some kinds of requests.

* Add migration to remove existing work manager requests for fetching notifications, since the previous worker class no longer exists.
2026-03-03 15:14:36 +00:00
Benoit Marty
5728452e68 Remove unused slidingSyncProxy from DB. 2025-11-18 15:58:22 +01:00
Benoit Marty
1292da2a72 Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
Benoit Marty
b748fcc631 Copyright: Add final period 2025-11-10 10:13:41 +01:00
Benoit Marty
0a0224b586 Copyright: run command uv run license-editor --repository ../element-x-android 2025-11-10 10:09:26 +01:00
Benoit Marty
9070420860 Session database: add count query. 2025-11-04 15:25:13 +01:00
Benoit Marty
fdc64e9be7 Use TestScope.backgroundScope 2025-10-23 16:48:24 +02:00
Benoit Marty
b8c7e16c50 Add test on wasLastSession value. 2025-10-23 16:48:23 +02:00
Benoit Marty
2d1b4b1ede Rename fixture fun for clarity. 2025-10-23 16:48:22 +02:00
Benoit Marty
44e125dbc7 Add parameter wasLastSession to SessionListener.onSessionDeleted 2025-10-23 16:20:15 +02:00
Benoit Marty
826cacf209 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +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
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
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
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
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
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
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
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
Marco Romano
f32817e71f Other fixes as per https://cashapp.github.io/sqldelight/2.0.0/upgrading-2.0/ 2023-10-13 15:17:12 +02:00
Marco Romano
0e1a8d506d Find and replace 2023-10-13 14:55:12 +02:00