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:
Benoit Marty
2026-08-24 11:38:11 +02:00
parent a845763f5b
commit e6116d5840
38 changed files with 204 additions and 131 deletions
@@ -24,7 +24,7 @@ import io.element.android.opusencoder.OggOpusEncoder
@ContributesTo(RoomScope::class)
object VoiceRecorderBindingContainer {
@Provides
fun provideAudioConfig(): AudioConfig {
fun providesAudioConfig(): AudioConfig {
val sampleRate = SampleRate
return AudioConfig(
format = AudioFormat.Builder()
@@ -40,7 +40,7 @@ object VoiceRecorderBindingContainer {
}
@Provides
public fun provideVoiceFileConfig(): VoiceFileConfig =
public fun providesVoiceFileConfig(): VoiceFileConfig =
VoiceFileConfig(
cacheSubdir = "voice_recordings",
fileExt = "ogg",
@@ -48,5 +48,5 @@ object VoiceRecorderBindingContainer {
)
@Provides
fun provideOggOpusEncoder(): OggOpusEncoder = OggOpusEncoder.create()
fun providesOggOpusEncoder(): OggOpusEncoder = OggOpusEncoder.create()
}
@@ -151,7 +151,7 @@ class DefaultVoiceRecorderTest {
}
private fun TestScope.createDefaultVoiceRecorder(): DefaultVoiceRecorder {
val fileConfig = VoiceRecorderBindingContainer.provideVoiceFileConfig()
val fileConfig = VoiceRecorderBindingContainer.providesVoiceFileConfig()
return DefaultVoiceRecorder(
dispatchers = testCoroutineDispatchers(),
timeSource = timeSource,