Commit Graph

49 Commits

Author SHA1 Message Date
Jorge Martin Espinosa
96e2f882a2 Add a foreground service with a wakelock for fetching push notifications (#6321)
* Create `PushHandlingWakeLock` to start a foreground service:

When receiving a push and scheduling the notification fetching, several problems can happen:

1. Some async operation is waiting for a timeout and it takes way longer than that to finish (i.e. timeout of 10s but it took 30s to advance).
2. The same, but when starting new coroutines. I've seen the time between scheduling a coroutine and it running sometimes take up to 1 minute.
3. Notification fetching can be scheduled immediately, but it can take a while to actually run because the OS understands the app is now in Doze.

Having a wakelock that runs as soon as the push handling starts fixes these: it continues the previous wakelock held by either Firebase or the UnifiedPush distributor.

* Acquire the wakelock as soon as we received the pushes in both receivers

* Also release the wakelock ahead of time if possible
2026-03-17 14:24:26 +01:00
Jorge Martin Espinosa
f77098ed47 Add network constraints for fetching notifications with WorkManager (#6305)
* Add `isNetworkBlocked` and `isInAirGappedEnvironment` to `NetworkMonitor`.

* Improve the DI of `SyncPendingNotificationsRequestBuilder` to simplify its usage.

* Only update `isInAirGappedEnvironment` in `DefaultNetworkManager` if the current build is an enterprise one.

* Add network constraints to `DefaultSyncPendingNotificationsRequestBuilder` based on the air-gapped status.

* Add a feature flag to disable the new check, in case it doesn't work as expected.
2026-03-10 12:44:31 +00:00
Jorge Martin Espinosa
fe4554703c Check if network access if blocked when fetching notifications (#6247)
* Add `NetworkMonitor.isNetworkBlocked()`, use it to check if Doze prevented us from loading notifications

* Only check if network is blocked after checking if we have a network available, otherwise it's always `true`

* Extract `NetworkBlockedChecker` to handle deprecations more carefully
2026-02-25 12:04:07 +00: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
826cacf209 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +02:00
ganfra
68daf8d2cf misc: display offline banner directly in LoggedInFlowNode (and fix window insets) 2025-10-21 16:05:20 +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
Benoit Marty
98f793b02e Merge pull request #4226 from element-hq/feature/bma/themeOverride
Theme override
2025-02-06 16:48:16 +01:00
Jorge Martin Espinosa
c040cec108 Create SyncOrchestrator (#4176)
* Create `SyncOrchestrator` to centralise the sync start/stop flow through the whole app: the decision is based on several inputs: sync state, network available, app in foreground, app in call, app needing to sync an event for a notification.

* Make network monitor return network connectivity status, not internet connectivity

* Don't stop the `SyncService` when network connection is lost, let it fail instead. This prevents an issue when using the offline mode of the SDK, which made the wrong UI states to be shown when the `SyncState` is `Idle` (that is, after the service being manually stopped).

* Rename `NetworkStatus.Online/Offline` to `Connected/Disconnected` so they're not easily mistaken with internet connectivity instead
2025-02-06 16:36:57 +01:00
Benoit Marty
0d6d74512f Use ElementTheme instead of MaterialTheme 2025-02-06 15:10:15 +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
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
62a6e916a6 Migrate license to AGPL - XML files. 2024-09-06 17:43:35 +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
Jorge Martin Espinosa
950e502ca6 Improve screenshot testing with ComposablePreviewScanner (#3125)
* Use ComposablePreviewScanner to rework how screenshot testing works
* Add test sharding
* Update screenshots
* Fixes for Element Gallery

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2024-07-03 13:05:06 +02:00
Benoit Marty
9367f58216 Rename some class from Impl to Default 2024-05-31 09:47:27 +02:00
Jorge Martin Espinosa
973c57d401 Update Compound to v0.0.5 and update icons (#2380)
Update Compound to `v0.0.5`:

- Make sure we fix all the breaking changes.
- Update some icons to use the compound version instead.
-Replace icons with their Compound counterparts when possible.
- Clean up unused icons.
- Fix issues with incorrect icons or sizes being used after replacing the temporary icons with the Compound ones.

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2024-02-12 16:41:58 +00:00
Benoit Marty
72b89338b3 Remove Modifier parameter in private function when only default value is used.
This will improve the code coverage metrics, and this also fixes a few potential bug, where the Modifier was used several times.
2024-02-08 11:06:06 +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
Jorge Martin Espinosa
a8b85fb4e6 Extract compound tokens and theming to compound-android library (#1888)
* Replace tokens & icons with the external Compound ones

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-11-27 10:30:07 +01:00
Benoit Marty
308a0c0f57 Konsist: add test to ensure filename match top level Composable View, and fix existing issue 2023-10-10 15:39:22 +02:00
Benoit Marty
d2ca528679 Detekt: Rename DayNightPreviews to PreviewsDayNight to follow naming convention.
MultiPreview annotations should start with `Previews` as prefix
2023-09-21 08:30:36 +02:00
Benoit Marty
d6ea21da22 Migrate other icons to compound icons. 2023-09-20 16:44:59 +02:00
Benoit Marty
e326e49e4c Use DayNightPreview 2023-09-19 11:49:12 +02:00
Jorge Martin Espinosa
c1ae0ead3b Fix top padding in room list when app is opened in offline mode (#1299)
* Fix top padding in room list when app is opened in offline mode

* Fix `avatarBloom` not passing the `bottomSoftEdgeColor` to `bloom`
2023-09-13 15:13:15 +00:00
Jorge Martin Espinosa
94dc6f41e2 [Compound] Bloom (#1253)
* Add `bloom` and `avatarBloom` modifiers.

* Add `ConnectivityIndicatorContainer` to control the padding needed at the top.

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-09-11 15:43:23 +02:00
Benoit Marty
006ecd51ee Improve rendering of offline banner regarding fontScale. 2023-07-27 15:04:32 +02:00
Benoit Marty
55538c2773 Enable detekt rules UnusedImports and cleanup the code. 2023-07-20 18:00:23 +02:00
Benoit Marty
7be0e3ea4b Remove ElementTextStyles. Only ElementTheme.typography.* styles must be used now. 2023-07-10 17:33:42 +02:00
Marco Romano
f33561c25d Revert "Auto generate dark mode previews and screenshots (#776)" (#784)
This reverts commit 79b529193c.
2023-07-05 15:47:53 +02:00
Marco Romano
79b529193c Auto generate dark mode previews and screenshots (#776)
With this change, composable previews and screenshots should be created with just:
```
@ElementPreviews
@Composable
fun MyViewPreview() {
    ElementPreview { 
        MyView()
    }
}
```

- Adds `@ElementPreviews` which is a shorthand for:
```
@Preview(name = "D")
@Preview(name = "N", uiMode = Configuration.UI_MODE_NIGHT_YES)
```
Should be used in connection with the now public `fun ElementPreview()` composable.

- Adds ElementPreviews to previewAnnotations in dangerfile
- Screenshots of night mode previews are now rendered with night mode
- Replaces `ElementPreviewLight` and `ElementThemedPreview` with `ElementPreview`
- Deprecates `ElementPreviewDark` which should be removed.
- Remaining usages of `ElementPreviewDark` are now ignored during screenshot tests
2023-07-05 13:58:24 +02:00
ganfra
e3744636b6 Merge branch 'develop' into feature/fga/room_list_api 2023-06-28 15:14:06 +02:00
Jorge Martin Espinosa
02dc447624 [Compound] Integrate compound tokens (#586)
* Added tokens.

* Apply color to MaterialTheme, also add typography.

* Map colors to the right ones in the themes.

* Create and improve previews of some components

* More preview improvements

* Add `tertiary` and `onTertiary` colors, remove some unused ones.

* Fix usage of deleted color token

* Fix bug in Switch previews

* Create a separate `:libraries:theme` module to keep everything related to colors, typography and Compound in general.

* Fix `DatePickerPreview`

* Add missing Compound generated files by fixing their package name

* Move `ElementTheme` to the `:libraries:theme` module, make some variables internal.

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-06-27 16:15:40 +00:00
ganfra
3765df9c39 NetworkMonitor: new strategy, looks like it works. 2023-06-27 17:58:45 +02:00
Benoit Marty
4a8c49fa28 Use CommonStrings everywhere 2023-06-27 09:45:00 +02:00
ganfra
bb4f61fe12 RoomList: try syncing when network is back and inError state 2023-06-23 17:07:27 +02:00
ganfra
1185dbd276 Network monitor : try to make it more reliable... 2023-06-23 16:48:31 +02:00
ganfra
37174cf53c API: simplify NetworkMonitor api 2023-06-22 15:47:15 +02:00
Chris Smith
1d041578f7 Make danger check view changes (#391)
Make danger check view changes

Add a check that if a file with @Preview or @LargeHeightPreview
in it is changed, then the corresponding build file includes
the showkase processor.

Also change the check that prompts about screenshots to use
the same @Preview logic instead of checking for "/layout" in
the path which doesn't work with compose.

Also add missing showkase processors
2023-05-05 08:24:12 +00:00
Jorge Martin Espinosa
e2b2dbf59f [Room list] Search & menu improvements (#356)
* Remove settings menu item, start splitting search UI. Also, add `applyIf` and `circularReveal` modifiers.

* Split UI & logic for room list search

* Suppress `composed` warning, improve its debuggability

* Add content description to the user's avatar, fix window insets. Also, remove unused `SearchRoomListTopBar`.
2023-04-25 11:35:36 +00:00
Jorge Martin Espinosa
e651d2f9c5 Fix: improve offline indicator designs (#341)
* Use the right font weight for the offline indicator title.

* Remove unneeded suppression in some build files.
2023-04-19 15:58:56 +02:00
Jorge Martin Espinosa
798bedcaed [Room List] Show offline indicator when the device is offline (#239)
* Implement the network status indicator.

* Add `networkmonitor` feature.
2023-04-17 17:01:16 +02:00