mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Move all binding containers to a di package and normalize their method names
Every @BindingContainer now lives in a di subpackage, in a file named after it. Containers that were declared inside a shared file (SimplePlayer.kt, LockScreenConfig.kt, VoiceMessagePresenter.kt, TimelineItemPresenterFactories.kt, MediaItemPresenterFactories.kt) are extracted into their own file. Method names are made consistent too: - @Binds functions are named bind<ConcreteParameterType>, fixing three that named something else (notably RoomAliasResolverBindingContainer, whose provider was still called providesJoinRoomPresenterFactory). - @Provides functions are named after what they provide, and all use the provides prefix rather than a mix of provide and provides. ANDROID_KEYSTORE moves back to the cryptography impl package, next to KeyStoreSecretKeyRepository which uses it; it is not DI specific and would otherwise be unreachable from there. No behaviour change: Metro discovers containers via @ContributesTo and does not care about method names, so the only call site to follow was in DefaultVoiceRecorderTest. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
-17
@@ -8,16 +8,8 @@
|
||||
|
||||
package io.element.android.libraries.mediaplayer.impl
|
||||
|
||||
import android.content.Context
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import dev.zacsweers.metro.BindingContainer
|
||||
import dev.zacsweers.metro.ContributesTo
|
||||
import dev.zacsweers.metro.Provides
|
||||
import io.element.android.libraries.di.RoomScope
|
||||
import io.element.android.libraries.di.annotations.ApplicationContext
|
||||
|
||||
/**
|
||||
* A subset of media3 [Player] that only exposes the few methods we need making it easier to mock.
|
||||
@@ -44,15 +36,6 @@ interface SimplePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@ContributesTo(RoomScope::class)
|
||||
@BindingContainer
|
||||
object SimplePlayerBindingContainer {
|
||||
@Provides
|
||||
fun simplePlayerProvider(
|
||||
@ApplicationContext context: Context,
|
||||
): SimplePlayer = DefaultSimplePlayer(ExoPlayer.Builder(context).setWakeMode(C.WAKE_MODE_LOCAL).build())
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of [SimplePlayer] backed by a media3 [Player].
|
||||
*/
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.mediaplayer.impl.di
|
||||
|
||||
import android.content.Context
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import dev.zacsweers.metro.BindingContainer
|
||||
import dev.zacsweers.metro.ContributesTo
|
||||
import dev.zacsweers.metro.Provides
|
||||
import io.element.android.libraries.di.RoomScope
|
||||
import io.element.android.libraries.di.annotations.ApplicationContext
|
||||
import io.element.android.libraries.mediaplayer.impl.DefaultSimplePlayer
|
||||
import io.element.android.libraries.mediaplayer.impl.SimplePlayer
|
||||
|
||||
@ContributesTo(RoomScope::class)
|
||||
@BindingContainer
|
||||
object SimplePlayerBindingContainer {
|
||||
@Provides
|
||||
fun providesSimplePlayer(
|
||||
@ApplicationContext context: Context,
|
||||
): SimplePlayer = DefaultSimplePlayer(ExoPlayer.Builder(context).setWakeMode(C.WAKE_MODE_LOCAL).build())
|
||||
}
|
||||
Reference in New Issue
Block a user