mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Introduce ShareDataSender so that SharePresenter is not session scoped
Instead of creating a SharePresenter from the graph of another session, the SharePresenter now gets the client of the selected session from the MatrixClientProvider and uses an AppScope ShareDataSender to send the data. To be able to send media from AppScope, MediaSenderRoomFactory is now bound in AppScope and takes the MatrixClient as a parameter, and a new MediaOptimizationConfigProviderFactory provides the media optimization config of any session. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+14
@@ -8,6 +8,8 @@
|
||||
|
||||
package io.element.android.libraries.mediaupload.api
|
||||
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
|
||||
/**
|
||||
* Resolves how aggressively media should be compressed, combining the user's own preferences with the app defaults.
|
||||
*/
|
||||
@@ -15,3 +17,15 @@ fun interface MediaOptimizationConfigProvider {
|
||||
/** Returns the configuration to pass to the pre-processing and sending calls. */
|
||||
suspend fun get(): MediaOptimizationConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [MediaOptimizationConfigProvider] for a given session, used outside the session scope, for instance when sharing to another account.
|
||||
*/
|
||||
fun interface MediaOptimizationConfigProviderFactory {
|
||||
/**
|
||||
* Create a [MediaOptimizationConfigProvider] using the preferences of the session of [client].
|
||||
*
|
||||
* @param client the client of the session whose preferences should be used.
|
||||
*/
|
||||
fun create(client: MatrixClient): MediaOptimizationConfigProvider
|
||||
}
|
||||
|
||||
+3
@@ -9,6 +9,7 @@
|
||||
package io.element.android.libraries.mediaupload.api
|
||||
|
||||
import android.net.Uri
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
||||
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||
@@ -34,9 +35,11 @@ fun interface MediaSenderRoomFactory {
|
||||
/**
|
||||
* Create a [MediaSender] for the given [JoinedRoom], with timeline mode Live.
|
||||
*
|
||||
* @param client the client of the session the room belongs to, used to read the media preferences of that session.
|
||||
* @param room the room the media should be sent to.
|
||||
*/
|
||||
fun create(
|
||||
client: MatrixClient,
|
||||
room: JoinedRoom,
|
||||
): MediaSender
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user