Files
letro-android/settings.gradle.kts
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

83 lines
2.6 KiB
Kotlin

import java.net.URI
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pluginManagement {
repositories {
includeBuild("plugins")
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = URI("https://oss.sonatype.org/content/repositories/snapshots/") }
maven {
url = URI("https://www.jitpack.io")
content {
includeModule("com.github.UnifiedPush", "android-connector")
includeModule("com.github.matrix-org", "matrix-analytics-events")
includeModule("com.github.lincollincol", "compose-audiowaveform")
}
}
// To have immediate access to Rust SDK versions
maven {
url = URI("https://s01.oss.sonatype.org/content/repositories/releases")
}
flatDir {
dirs("libraries/matrix/libs")
}
}
}
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
rootProject.name = "ElementX"
include(":app")
include(":appnav")
include(":appconfig")
include(":tests:konsist")
include(":tests:uitests")
include(":tests:testutils")
include(":anvilannotations")
include(":anvilcodegen")
include(":samples:minimal")
fun includeProjects(directory: File, path: String, maxDepth: Int = 1) {
directory.listFiles().orEmpty().also { it.sort() }.forEach { file ->
if (file.isDirectory) {
val newPath = "$path:${file.name}"
val buildFile = File(file, "build.gradle.kts")
if (buildFile.exists()) {
include(newPath)
logger.lifecycle("Included project: $newPath")
} else if (maxDepth > 0) {
includeProjects(file, newPath, maxDepth - 1)
}
}
}
}
includeProjects(File(rootDir, "features"), ":features")
includeProjects(File(rootDir, "libraries"), ":libraries")
includeProjects(File(rootDir, "services"), ":services")