Add KDoc to six small library API modules

Cover the remaining interfaces of libraries/troubleshoot, libraries/matrixmedia,
libraries/dateformatter, libraries/featureflag, libraries/workmanager and
libraries/mediaviewer, along with their members and parameters.

Behaviours worth recording: NotificationTroubleshootTest reports its outcome
through its state flow rather than by returning, and its quickFix throws unless
the test offers one; DateFormatter.format turns a null timestamp into an empty
string so callers need no null check; ImageLoaderHolder keeps one loader per
session because decrypting room media needs that session's client.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benoit Marty
2026-08-14 11:43:40 +02:00
parent d80aaf6be4
commit 2284cff25a
13 changed files with 118 additions and 0 deletions
@@ -12,9 +12,15 @@ import android.net.Uri
import io.element.android.libraries.matrix.api.media.MediaFile
import io.element.android.libraries.mediaviewer.api.MediaInfo
/**
* Builds the [LocalMedia] the media viewer renders, from either a downloaded Matrix media file or an arbitrary content uri.
*/
interface LocalMediaFactory {
/**
* This method will create a [LocalMedia] with the given [MediaFile] and [MediaInfo].
*
* @param mediaFile the file already downloaded from the homeserver.
* @param mediaInfo what is known about the media from the event that carried it.
*/
fun createFromMediaFile(
mediaFile: MediaFile,
@@ -24,6 +30,11 @@ interface LocalMediaFactory {
/**
* This method will create a [LocalMedia] with the given mimeType, name and formattedFileSize
* If any of those params are null, it'll try to read them from the content.
*
* @param uri the content to display, for instance one just picked by the user.
* @param mimeType the MIME type, or `null` to read it from the content.
* @param name the file name, or `null` to read it from the content.
* @param formattedFileSize the size to display, or `null` to read it from the content.
*/
fun createFromUri(
uri: Uri,
@@ -10,7 +10,15 @@ package io.element.android.libraries.mediaviewer.api.local
import androidx.compose.runtime.Composable
/**
* Renders a media file held on the device, picking the right player or viewer for its type.
*/
interface LocalMediaRenderer {
/**
* Draws the media, filling the space it is given.
*
* @param localMedia the file to display, along with what is known about its type.
*/
@Composable
fun Render(localMedia: LocalMedia)
}
@@ -8,6 +8,13 @@
package io.element.android.libraries.mediaviewer.api.util
/**
* Extracts the extension of a file name, so it can be shown to the user and used to pick an icon.
*/
interface FileExtensionExtractor {
/**
* @param name the file name to inspect.
* @return the extension without its dot, or an empty string when the name has none.
*/
fun extractFromName(name: String): String
}