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
@@ -10,20 +10,31 @@ package io.element.android.libraries.workmanager.api
import io.element.android.libraries.matrix.api.core.SessionId
/**
* Schedules background work, wrapping `WorkManager` so the rest of the app does not depend on it directly.
*/
interface WorkManagerScheduler {
/**
* Submits a new work request built from [workManagerRequestBuilder] to run in `WorkManager`.
*
* @param workManagerRequestBuilder describes the work to schedule.
*/
suspend fun submit(workManagerRequestBuilder: WorkManagerRequestBuilder)
/**
* Checks if there are any pending requests scheduled for the provided [sessionId] and [requestType].
*
* @param sessionId the session the work belongs to.
* @param requestType the kind of work to look for.
*/
fun hasPendingWork(sessionId: SessionId, requestType: WorkManagerRequestType): Boolean
/**
* Cancel pending work requests for the session [SessionId].
* If [requestType] is provided, it will only cancel requests for that type, otherwise it will cancel all requests.
*
* @param sessionId the session whose work is cancelled.
* @param requestType the kind of work to cancel, or `null` to cancel every kind.
*/
fun cancel(sessionId: SessionId, requestType: WorkManagerRequestType? = null)
}
@@ -28,7 +28,13 @@ class MetroWorkerFactory(
return workerProviders[Class.forName(workerClassName).kotlin]?.create(workerParameters)
}
/**
* Creates one worker type with its dependencies injected, since `WorkManager` instantiates workers itself and cannot use the graph.
*/
interface WorkerInstanceFactory<T : ListenableWorker> {
/**
* @param params the parameters `WorkManager` built the worker with.
*/
fun create(params: WorkerParameters): T
}
}