Merge pull request #2957 from element-hq/feature/bma/konsistClassName
Konsist class name
This commit is contained in:
commit
e29f919abc
39 changed files with 131 additions and 143 deletions
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.di
|
||||
|
||||
import javax.inject.Qualifier
|
||||
|
||||
@Qualifier annotation class DefaultPreferences
|
||||
|
|
@ -37,7 +37,7 @@ import java.util.UUID
|
|||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class PickerProviderImpl(private val isInTest: Boolean) : PickerProvider {
|
||||
class DefaultPickerProvider(private val isInTest: Boolean) : PickerProvider {
|
||||
@Inject
|
||||
constructor() : this(false)
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ import kotlin.time.Duration.Companion.seconds
|
|||
*/
|
||||
@ContributesBinding(RoomScope::class)
|
||||
@SingleIn(RoomScope::class)
|
||||
class MediaPlayerImpl @Inject constructor(
|
||||
class DefaultMediaPlayer @Inject constructor(
|
||||
private val player: SimplePlayer,
|
||||
) : MediaPlayer {
|
||||
private val listener = object : SimplePlayer.Listener {
|
||||
|
|
@ -55,13 +55,13 @@ object SimplePlayerModule {
|
|||
@Provides
|
||||
fun simplePlayerProvider(
|
||||
@ApplicationContext context: Context,
|
||||
): SimplePlayer = SimplePlayerImpl(ExoPlayer.Builder(context).build())
|
||||
): SimplePlayer = DefaultSimplePlayer(ExoPlayer.Builder(context).build())
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of [SimplePlayer] backed by a media3 [Player].
|
||||
*/
|
||||
class SimplePlayerImpl(
|
||||
class DefaultSimplePlayer(
|
||||
private val p: Player
|
||||
) : SimplePlayer {
|
||||
override fun addListener(listener: SimplePlayer.Listener) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package io.element.android.libraries.mediaplayer.impl
|
|||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
class MediaPlayerImplTest {
|
||||
class DefaultMediaPlayerTest {
|
||||
@Test
|
||||
fun `default test`() = runTest {
|
||||
// TODO
|
||||
|
|
@ -20,7 +20,6 @@ import android.content.SharedPreferences
|
|||
import androidx.core.content.edit
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.DefaultPreferences
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
|
@ -32,15 +31,15 @@ interface FirebaseStore {
|
|||
}
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultFirebaseStore @Inject constructor(
|
||||
@DefaultPreferences private val sharedPrefs: SharedPreferences,
|
||||
class SharedPreferencesFirebaseStore @Inject constructor(
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) : FirebaseStore {
|
||||
override fun getFcmToken(): String? {
|
||||
return sharedPrefs.getString(PREFS_KEY_FCM_TOKEN, null)
|
||||
return sharedPreferences.getString(PREFS_KEY_FCM_TOKEN, null)
|
||||
}
|
||||
|
||||
override fun storeFcmToken(token: String?) {
|
||||
sharedPrefs.edit {
|
||||
sharedPreferences.edit {
|
||||
putString(PREFS_KEY_FCM_TOKEN, token)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import androidx.core.content.edit
|
|||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.di.DefaultPreferences
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -36,9 +35,9 @@ interface UnifiedPushStore {
|
|||
}
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultUnifiedPushStore @Inject constructor(
|
||||
class SharedPreferencesUnifiedPushStore @Inject constructor(
|
||||
@ApplicationContext val context: Context,
|
||||
@DefaultPreferences private val defaultPrefs: SharedPreferences,
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) : UnifiedPushStore {
|
||||
/**
|
||||
* Retrieves the UnifiedPush Endpoint.
|
||||
|
|
@ -47,7 +46,7 @@ class DefaultUnifiedPushStore @Inject constructor(
|
|||
* @return the UnifiedPush Endpoint or null if not received
|
||||
*/
|
||||
override fun getEndpoint(clientSecret: String): String? {
|
||||
return defaultPrefs.getString(PREFS_ENDPOINT_OR_TOKEN + clientSecret, null)
|
||||
return sharedPreferences.getString(PREFS_ENDPOINT_OR_TOKEN + clientSecret, null)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +56,7 @@ class DefaultUnifiedPushStore @Inject constructor(
|
|||
* @param endpoint the endpoint to store
|
||||
*/
|
||||
override fun storeUpEndpoint(clientSecret: String, endpoint: String?) {
|
||||
defaultPrefs.edit {
|
||||
sharedPreferences.edit {
|
||||
putString(PREFS_ENDPOINT_OR_TOKEN + clientSecret, endpoint)
|
||||
}
|
||||
}
|
||||
|
|
@ -69,7 +68,7 @@ class DefaultUnifiedPushStore @Inject constructor(
|
|||
* @return the Push Gateway or null if not defined
|
||||
*/
|
||||
override fun getPushGateway(clientSecret: String): String? {
|
||||
return defaultPrefs.getString(PREFS_PUSH_GATEWAY + clientSecret, null)
|
||||
return sharedPreferences.getString(PREFS_PUSH_GATEWAY + clientSecret, null)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -79,17 +78,17 @@ class DefaultUnifiedPushStore @Inject constructor(
|
|||
* @param gateway the push gateway to store
|
||||
*/
|
||||
override fun storePushGateway(clientSecret: String, gateway: String?) {
|
||||
defaultPrefs.edit {
|
||||
sharedPreferences.edit {
|
||||
putString(PREFS_PUSH_GATEWAY + clientSecret, gateway)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDistributorValue(userId: UserId): String? {
|
||||
return defaultPrefs.getString(PREFS_DISTRIBUTOR + userId, null)
|
||||
return sharedPreferences.getString(PREFS_DISTRIBUTOR + userId, null)
|
||||
}
|
||||
|
||||
override fun setDistributorValue(userId: UserId, value: String) {
|
||||
defaultPrefs.edit {
|
||||
sharedPreferences.edit {
|
||||
putString(PREFS_DISTRIBUTOR + userId, value)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import javax.inject.Inject
|
|||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "push_client_secret_store")
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class PushClientSecretStoreDataStore @Inject constructor(
|
||||
class DataStorePushClientSecretStore @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
) : PushClientSecretStore {
|
||||
override suspend fun storeSecret(userId: SessionId, clientSecret: String) {
|
||||
|
|
@ -29,7 +29,7 @@ import javax.inject.Inject
|
|||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class, boundType = PushClientSecret::class)
|
||||
class PushClientSecretImpl @Inject constructor(
|
||||
class DefaultPushClientSecret @Inject constructor(
|
||||
private val pushClientSecretFactory: PushClientSecretFactory,
|
||||
private val pushClientSecretStore: PushClientSecretStore,
|
||||
private val sessionObserver: SessionObserver,
|
||||
|
|
@ -23,7 +23,7 @@ import java.util.UUID
|
|||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class PushClientSecretFactoryImpl @Inject constructor() : PushClientSecretFactory {
|
||||
class DefaultPushClientSecretFactory @Inject constructor() : PushClientSecretFactory {
|
||||
override fun create(): String {
|
||||
return UUID.randomUUID().toString()
|
||||
}
|
||||
|
|
@ -28,12 +28,12 @@ private val A_USER_ID_1 = SessionId("@A_USER_ID_1:domain")
|
|||
|
||||
private const val A_UNKNOWN_SECRET = "A_UNKNOWN_SECRET"
|
||||
|
||||
internal class PushClientSecretImplTest {
|
||||
internal class DefaultPushClientSecretTest {
|
||||
@Test
|
||||
fun test() = runTest {
|
||||
val factory = FakePushClientSecretFactory()
|
||||
val store = InMemoryPushClientSecretStore()
|
||||
val sut = PushClientSecretImpl(factory, store, NoOpSessionObserver())
|
||||
val sut = DefaultPushClientSecret(factory, store, NoOpSessionObserver())
|
||||
|
||||
val secret0 = factory.getSecretForUser(0)
|
||||
val secret1 = factory.getSecretForUser(1)
|
||||
|
|
@ -51,7 +51,7 @@ import kotlin.time.TimeSource
|
|||
|
||||
@SingleIn(RoomScope::class)
|
||||
@ContributesBinding(RoomScope::class)
|
||||
class VoiceRecorderImpl @Inject constructor(
|
||||
class DefaultVoiceRecorder @Inject constructor(
|
||||
private val dispatchers: CoroutineDispatchers,
|
||||
private val timeSource: TimeSource,
|
||||
private val audioReaderFactory: AudioReader.Factory,
|
||||
|
|
@ -44,13 +44,13 @@ import kotlin.time.Duration.Companion.minutes
|
|||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.TestTimeSource
|
||||
|
||||
class VoiceRecorderImplTest {
|
||||
class DefaultVoiceRecorderTest {
|
||||
private val fakeFileSystem = FakeFileSystem()
|
||||
private val timeSource = TestTimeSource()
|
||||
|
||||
@Test
|
||||
fun `it emits the initial state`() = runTest {
|
||||
val voiceRecorder = createVoiceRecorder()
|
||||
val voiceRecorder = createDefaultVoiceRecorder()
|
||||
voiceRecorder.state.test {
|
||||
assertThat(awaitItem()).isEqualTo(VoiceRecorderState.Idle)
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class VoiceRecorderImplTest {
|
|||
|
||||
@Test
|
||||
fun `when recording, it emits the recording state`() = runTest {
|
||||
val voiceRecorder = createVoiceRecorder()
|
||||
val voiceRecorder = createDefaultVoiceRecorder()
|
||||
voiceRecorder.state.test {
|
||||
assertThat(awaitItem()).isEqualTo(VoiceRecorderState.Idle)
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class VoiceRecorderImplTest {
|
|||
|
||||
@Test
|
||||
fun `when elapsed time reaches 30 minutes, it stops recording`() = runTest {
|
||||
val voiceRecorder = createVoiceRecorder()
|
||||
val voiceRecorder = createDefaultVoiceRecorder()
|
||||
voiceRecorder.state.test {
|
||||
assertThat(awaitItem()).isEqualTo(VoiceRecorderState.Idle)
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ class VoiceRecorderImplTest {
|
|||
|
||||
@Test
|
||||
fun `when stopped, it provides a file and duration`() = runTest {
|
||||
val voiceRecorder = createVoiceRecorder()
|
||||
val voiceRecorder = createDefaultVoiceRecorder()
|
||||
voiceRecorder.state.test {
|
||||
assertThat(awaitItem()).isEqualTo(VoiceRecorderState.Idle)
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ class VoiceRecorderImplTest {
|
|||
|
||||
@Test
|
||||
fun `when cancelled, it deletes the file`() = runTest {
|
||||
val voiceRecorder = createVoiceRecorder()
|
||||
val voiceRecorder = createDefaultVoiceRecorder()
|
||||
voiceRecorder.state.test {
|
||||
assertThat(awaitItem()).isEqualTo(VoiceRecorderState.Idle)
|
||||
|
||||
|
|
@ -131,9 +131,9 @@ class VoiceRecorderImplTest {
|
|||
}
|
||||
}
|
||||
|
||||
private fun TestScope.createVoiceRecorder(): VoiceRecorderImpl {
|
||||
private fun TestScope.createDefaultVoiceRecorder(): DefaultVoiceRecorder {
|
||||
val fileConfig = VoiceRecorderModule.provideVoiceFileConfig()
|
||||
return VoiceRecorderImpl(
|
||||
return DefaultVoiceRecorder(
|
||||
dispatchers = testCoroutineDispatchers(),
|
||||
timeSource = timeSource,
|
||||
audioReaderFactory = FakeAudioReaderFactory(
|
||||
Loading…
Add table
Add a link
Reference in a new issue