diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt index a08060e65f..9211371dd5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt @@ -22,12 +22,6 @@ interface ContentUploadStateTracker { fun untrack(key: String, updateListener: UpdateListener) - fun setFailure(key: String) - - fun setSuccess(key: String) - - fun setProgress(key: String, current: Long, total: Long) - interface UpdateListener { fun onUpdate(state: State) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt index 67ff2d7bc9..7fb9b75768 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt @@ -27,7 +27,11 @@ internal class ContentModule { val definition = module(override = true) { scope(DefaultSession.SCOPE) { - DefaultContentUploadStateTracker() as ContentUploadStateTracker + DefaultContentUploadStateTracker() + } + + scope(DefaultSession.SCOPE) { + get() as ContentUploadStateTracker } scope(DefaultSession.SCOPE) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt index 66bd5a8200..a5dd16fbdd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt @@ -40,17 +40,17 @@ internal class DefaultContentUploadStateTracker : ContentUploadStateTracker { } } - override fun setFailure(key: String) { + internal fun setFailure(key: String) { val failure = ContentUploadStateTracker.State.Failure updateState(key, failure) } - override fun setSuccess(key: String) { + internal fun setSuccess(key: String) { val success = ContentUploadStateTracker.State.Success updateState(key, success) } - override fun setProgress(key: String, current: Long, total: Long) { + internal fun setProgress(key: String, current: Long, total: Long) { val progressData = ContentUploadStateTracker.State.ProgressData(current, total) updateState(key, progressData) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt index 4eeb124de9..0182eb6c76 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt @@ -21,15 +21,10 @@ import androidx.work.CoroutineWorker import androidx.work.WorkerParameters import com.squareup.moshi.JsonClass import im.vector.matrix.android.api.session.content.ContentAttachmentData -import im.vector.matrix.android.api.session.content.ContentUploadStateTracker import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.events.model.toContent import im.vector.matrix.android.api.session.events.model.toModel -import im.vector.matrix.android.api.session.room.model.message.MessageAudioContent -import im.vector.matrix.android.api.session.room.model.message.MessageContent -import im.vector.matrix.android.api.session.room.model.message.MessageFileContent -import im.vector.matrix.android.api.session.room.model.message.MessageImageContent -import im.vector.matrix.android.api.session.room.model.message.MessageVideoContent +import im.vector.matrix.android.api.session.room.model.message.* import im.vector.matrix.android.internal.di.MatrixKoinComponent import im.vector.matrix.android.internal.network.ProgressRequestBody import im.vector.matrix.android.internal.session.room.send.SendEventWorker @@ -43,7 +38,7 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params), MatrixKoinComponent { private val fileUploader by inject() - private val contentUploadProgressTracker by inject() + private val contentUploadProgressTracker by inject() @JsonClass(generateAdapter = true) internal data class Params( @@ -54,7 +49,7 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters) override suspend fun doWork(): Result { val params = WorkerParamsFactory.fromData(inputData) - ?: return Result.failure() + ?: return Result.failure() val eventId = params.event.eventId ?: return Result.failure() val attachment = params.attachment