Commit Graph

647 Commits

Author SHA1 Message Date
David Langley
0c4e7547a2 Merge branch 'develop' into langleyd/live_waveform 2023-10-27 09:37:21 +01:00
David Langley
d0664dae0d Fix tests 2023-10-27 09:32:05 +01:00
Marco Romano
eb223deba1 Move MediaPlayer from messages module to new dedicated library module (#1654) 2023-10-27 09:58:17 +02:00
David Langley
1db2adae7e Merge branch 'develop' of https://github.com/vector-im/element-x-android into langleyd/live_waveform 2023-10-27 08:44:25 +01:00
David Langley
510b1f63b9 Simple live waveform implementation. 2023-10-26 23:46:03 +01:00
Marco Romano
a67560c74b Convert mx waveform to floats as early as possible in the chain (#1652)
This way we're sure that internally we always deal with [0;1] float samples. the [0;1024] int range is used only at the rust sdk boundary.
2023-10-26 16:58:00 +00:00
Marco Romano
4a390296cf Include waveform when sending voice messages (#1650)
- New `AudioLevelCalculator` that outputs dB0v rescaled to the [0;1] range.
- `VoiceRecorder` now stores the audio levels sampled while recording, then resamples them to 100 samples to use as waveform preview.
- Waveform data is carried all the way as a `List<Float>` and converted to `List<Int>` in the [0;1024] range as per matrix spec only before sending it.
2023-10-26 17:37:24 +02:00
jonnyandrew
517b422992 Add voice message preview player (#1646)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-26 15:33:58 +00:00
jonnyandrew
8258bdcf80 Move waveform UI to design system library (#1649) 2023-10-26 15:15:42 +00:00
ganfra
35d32c0500 Merge pull request #1642 from vector-im/feature/fga/pin_settings
PIN : settings and branch flow
2023-10-26 16:40:38 +02:00
Jorge Martin Espinosa
c40a39bbfa Update the chat screen UI using RoomInfo. (#1640)
* Update the chat screen UI using `RoomInfo`.

This is specially useful for getting live values for `hasRoomCall`.

* Ensure the first `MatrixRoomInfo` is emitted ASAP

* Try excluding `*Present$present$*` inner functions from kover as separate entities

* Update strings

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-26 14:27:42 +00:00
ganfra
b8ce848a0c PIN : fix quality 2023-10-26 15:25:40 +02:00
Marco Romano
4d9a3bddaf Use Float instead of Double for all the level metering logic. (#1645)
This is in preparation of further changes to the way the audio level is computed and to allow recording and sending of the waveform. The main reasoning behind the change is twofold:
1) We don't need the precision of Double in our context (we just need a rough indication of the changes in audio level to successfully draw a level meter or a waveform in our UI).
2) Performance: It is true that on 64 bit CPUs single operations involving Floats or Doubles take the same amount of time (i.e one clock cycle). But there are other aspects here that vouch in favor of Floats:
	- A float takes half the space in memory compared to a double, so when storing long lists of them this can add up.
	- On Android O and greater the ART runtime can "vectorize" certain operations on lists and make use of the CPU's SIMD registers which are generally 128 bits. So by using floats 4 of them can fit and be computed at the same time whilst with doubles only 2 will fit halving the throughput.

References:
- https://source.android.com/docs/core/runtime/improvements
- https://www.slideshare.net/linaroorg/automatic-vectorization-in-art-android-runtime-sfo17216
2023-10-26 12:55:23 +00:00
Marco Romano
10ce75f74e Merge branch 'develop' into langleyd/custom_waveform 2023-10-26 13:07:45 +02:00
Marco Romano
40e19349b5 Refactor of voice message playing code (#1643)
After PR review suggestions from @jonnyandrew 
User facing functionality doesn't change, but overall architecture and testing is better.
2023-10-26 12:51:12 +02:00
ganfra
fae051ef82 Merge branch 'develop' into feature/fga/pin_settings 2023-10-26 11:13:52 +02:00
David Langley
34f7111f48 -Fix waveform preview 2023-10-26 09:10:38 +01:00
David Langley
9b7f66446a Don't need added state from bad merge. 2023-10-26 09:06:08 +01:00
David Langley
a8016fa6ed Remove WaveformProgressIndicator call. 2023-10-26 09:02:31 +01:00
David Langley
fbce953527 Merge branch 'develop' of https://github.com/vector-im/element-x-android into langleyd/custom_waveform 2023-10-26 09:02:14 +01:00
David Langley
5a646a8362 Remove WaveformProgressIndicator and waveform library and lint.
-Remove WaveformProgressIndicator - Remove waveform library
- lint.
2023-10-26 08:58:03 +01:00
David Langley
4b403ae57c Add custom waveform with cursor and nice gesture support. 2023-10-25 22:12:01 +01:00
Marco Romano
e2a40c8bd1 Voice message bubble design improvements (#1637)
- Fixes color and size of both text and icons.
2023-10-25 17:33:50 +02:00
ganfra
f105455bd6 PIN: branch SignOut 2023-10-25 11:15:15 +02:00
Marco Romano
3b20120705 Receive and play a voice message (#1503)
## Type of change

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

## Content

This PR consists of several macro-blocks separated by path/package:
- `messages.impl.mediaplayer` : Global (room-wide) media player, now used only for voice messages but could be used for all media within EX in the future. It is backed by media3's exoplayer. Currently not unit-tested because mocking exoplayer is not trivial.
- `messages.impl.voicemessages.play` : Business logic of a timeline voice message. This is all the logic that manages the voice message bubble.
- `messages.impl.timeline.model` & `messages.impl.timeline.factories`: Timeline code that takes care of creating the `content` object for voice messages.
-  `messages.impl.timeline.components` : The actual View composable that shows the UI inside a voice message bubble.

All the rest is just small related changes that must be done here and there in existing code.

From a high level perspective this is how it works:
- Voice messages are unlike other message bubbles because they carry state (i.e. playing, downloading...) so they have a Presenter managing this state.
- Media content (i.e. the ogg file) of a voice message is downloaded from the rust SDK on first play then stored in a voice messages cache (see the `VoiceMessageCache` class, it is just a subdirectory in the app's cacheDir which is indexed by the matrix content uri). All further play attempts are done from the cache without hitting the rust SDK anymore.
- Playback of the ogg file is handled with the `VoiceMessagePlayer` class which is basically a "view" of the global `MediaPlayer` that allow the voice message to only see the media player state belonging to its media content. 
- Drawing of the waveform is done with an OSS library wrapped in the `WaveformProgressIndicator` composable.

Known issues:
 - The waveform has no position slider.
 - The waveform (and together with it the whole message bubble) is taller than the actual Figma design.
 - Swipe to reply for voice messages is disabled to avoid conflict with the audio scrubbing gesture (to reply to a voice message you have to use the long press menu).
 - The loading indicator is always shown (there is no delay).
 - Voice messages don't stop playing when redacted.

## Motivation and context

https://github.com/vector-im/element-meta/issues/2083

## Screenshots / GIFs

Provided by Screenshot tests in the PR itself.
2023-10-24 21:47:51 +00:00
jonnyandrew
98b75424a8 Allow deleting a recorded voice message (#1635)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-24 21:02:19 +00:00
Benoit Marty
fa6d13426e Test coverage: Add missing preview for MessagesView. 2023-10-24 17:17:15 +02:00
Benoit Marty
5f7ae9598e Test coverage: extract EmojiItem to improve coverage. 2023-10-24 17:17:15 +02:00
jonnyandrew
d07b7e0d87 Update package of voice message composer (#1633) 2023-10-24 14:48:35 +00:00
jonnyandrew
9046ac4c8a Add voice message recording duration indicator and limit (#1628)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-24 11:44:53 +00:00
jonnyandrew
bdc52332bb Add progress indicator for sending voice messages (#1618)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-24 08:36:42 +00:00
jonnyandrew
5c582bba1b Record and send voice messages (#1596)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-23 17:28:00 +00:00
David Langley
da345f9afa Merge pull request #1625 from vector-im/langleyd/fix_emoji_shortcut_values
Fix emoji shortcut values
2023-10-23 16:49:56 +01:00
ganfra
40f677192a Merge pull request #1624 from vector-im/feature/fga/pin_auth_ui
PIN : unlock screen ui
2023-10-23 16:35:22 +02:00
David Langley
a0c192266f Update thumbs up emoji in the state provider. 2023-10-23 15:25:28 +01:00
David Langley
3763593a66 Fix emoji shortcut values 2023-10-23 12:06:52 +01:00
Benoit Marty
577527902f Konsist: add test to ensure that functions with @PreviewsDayNight contain ElementTheme composable, and fix existing issues. 2023-10-23 12:23:27 +02:00
jonnyandrew
3a39e747fd Fix issue where text is cleared when cancelling a reply (#1617) 2023-10-23 08:31:32 +00:00
ElementBot
46bfbc06fa Sync Strings (#1623)
* Sync Strings from Localazy

* Fix strings

* Update screenshots

---------

Co-authored-by: bmarty <bmarty@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2023-10-23 08:20:49 +00:00
renovate[bot]
7c5fab732b Update dependency org.matrix.rustcomponents:sdk-android to v0.1.63 (#1619)
* Update dependency org.matrix.rustcomponents:sdk-android to v0.1.63

* Update Element Call integrated APIs

* Take into account the new `MessageType.Other` from the SDK

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2023-10-20 22:32:59 +02:00
Jorge Martin Espinosa
5e547269e7 Integrate Element Call with widget API (#1581)
* Integrate Element Call with widget API.

- Add `appconfig` module and extract constants that can be overridden in forks there.
- Add an Element Call feature flag, disabled by default.
- Refactor the whole `ElementCallActivity`, move most logic out of it.
- Integrate with the Rust Widget Driver API (note the Rust SDK version used in this PR lacks some needed changes to make the calls actually work).
- Handle calls differently based on `CallType`.
- Add UI to create/join a call.

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-19 15:38:43 +00:00
Marco Romano
cf3039c6f3 TimelineItemPresenterFactories (#1609)
DI infrastructure to allow injection of presenters into the timeline.
Add an `@AssistedFactory` of type `TimelineItemPresenterFactory` to a `Presenter` class and bind this factory into the TimelineItemPresenterFactory map multi binding using:

```
@Binds
@IntoMap
@TimelineItemEventContentKey(MyTimelineItemContent::class)
```

A map multibinding of such factories will be available in the `LocalTimelineItemPresenterFactories` composition local for further use down the UI tree.
2023-10-19 15:57:34 +02:00
Marco Romano
80870adfe3 Extract more content from audio messages. (#1607)
`TimelineItemAudioContent`:
- Use `java.time.Duration` instead of milliseconds. This will ease up things in the future because currently milliseconds are sent over the wire but in the future seconds will be sent (as per the stable MSC). Using `Duration` will allow our downstream code to be independent of what's passed over the wire.
- Rename `audioSource` property to `mediaSource` to better match its type.

`AudioMessageType`:
- Add and populate new fields `details` and `isVoiceMessage` to be used by voice messages.
2023-10-19 13:32:43 +02:00
Jorge Martin Espinosa
643fe1a5e5 Hide keyboard when exiting the room screen (#1593) 2023-10-19 10:49:11 +02:00
bmarty
379139a88f Sync Strings from Localazy 2023-10-16 00:09:47 +00:00
Benoit Marty
5f56961fd0 Merge pull request #1556 from vector-im/feature/bma/videoLock
Ensure screen does not turn off when playing a video (#1519)
2023-10-13 14:05:30 +02:00
Benoit Marty
e8fcf7b950 Fix issue detected by Konsist. 2023-10-12 18:46:14 +02:00
jonnyandrew
ffa6c43503 [Voice messages] Add voice recording UI (#1546)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-12 15:17:18 +00:00
Benoit Marty
a71fb431d3 Ensure screen does not turn off when playing a video (#1519) 2023-10-12 15:53:05 +02:00
Benoit Marty
07a2643bd2 Merge pull request #1549 from vector-im/feature/bma/unknownMsgtype
Render unknown msgtype
2023-10-12 10:56:35 +02:00