Fix moar ktlint issues

This commit is contained in:
Benoit Marty 2024-01-11 09:41:14 +01:00 committed by Benoit Marty
parent 5d086ad82d
commit d01c70a4fd
27 changed files with 69 additions and 53 deletions

View file

@ -17,5 +17,5 @@
package io.element.android.libraries.matrix.api.auth
object OidcConfig {
const val redirectUri = "io.element:/callback"
const val REDIRECT_URI = "io.element:/callback"
}

View file

@ -21,7 +21,7 @@ import org.matrix.rustcomponents.sdk.OidcConfiguration
val oidcConfiguration: OidcConfiguration = OidcConfiguration(
clientName = "Element",
redirectUri = OidcConfig.redirectUri,
redirectUri = OidcConfig.REDIRECT_URI,
clientUri = "https://element.io",
logoUri = "https://element.io/mobile-icon.png",
tosUri = "https://element.io/acceptable-use-policy-terms",
@ -29,9 +29,7 @@ val oidcConfiguration: OidcConfiguration = OidcConfiguration(
contacts = listOf(
"support@element.io",
),
/**
* Some homeservers/auth issuers don't support dynamic client registration, and have to be registered manually
*/
// Some homeservers/auth issuers don't support dynamic client registration, and have to be registered manually
staticRegistrations = mapOf(
"https://id.thirdroom.io/realms/thirdroom" to "elementx",
),

View file

@ -84,7 +84,7 @@ class FakeEncryptionService : EncryptionService {
}
override suspend fun resetRecoveryKey(): Result<String> = simulateLongTask {
return Result.success(fakeRecoveryKey)
return Result.success(FAKE_RECOVERY_KEY)
}
override suspend fun enableRecovery(waitForBackupsToUpload: Boolean): Result<Unit> = simulateLongTask {
@ -108,6 +108,6 @@ class FakeEncryptionService : EncryptionService {
}
companion object {
const val fakeRecoveryKey = "fake"
const val FAKE_RECOVERY_KEY = "fake"
}
}

View file

@ -33,7 +33,7 @@ class FakeNotificationSettingsService(
initialOneToOneDefaultMode: RoomNotificationMode = RoomNotificationMode.ALL_MESSAGES,
initialEncryptedOneToOneDefaultMode: RoomNotificationMode = RoomNotificationMode.ALL_MESSAGES,
) : NotificationSettingsService {
private var _notificationSettingsStateFlow = MutableStateFlow(Unit)
private val notificationSettingsStateFlow = MutableStateFlow(Unit)
private var defaultGroupRoomNotificationMode: RoomNotificationMode = initialGroupDefaultMode
private var defaultEncryptedGroupRoomNotificationMode: RoomNotificationMode = initialEncryptedGroupDefaultMode
private var defaultOneToOneRoomNotificationMode: RoomNotificationMode = initialOneToOneDefaultMode
@ -49,7 +49,7 @@ class FakeNotificationSettingsService(
private var setAtRoomError: Throwable? = null
private var canHomeServerPushEncryptedEventsToDeviceResult = Result.success(true)
override val notificationSettingsChangeFlow: SharedFlow<Unit>
get() = _notificationSettingsStateFlow
get() = notificationSettingsStateFlow
override suspend fun getRoomNotificationSettings(roomId: RoomId, isEncrypted: Boolean, isOneToOne: Boolean): Result<RoomNotificationSettings> {
return Result.success(
@ -94,7 +94,7 @@ class FakeNotificationSettingsService(
defaultGroupRoomNotificationMode = mode
}
}
_notificationSettingsStateFlow.emit(Unit)
notificationSettingsStateFlow.emit(Unit)
return Result.success(Unit)
}
@ -105,7 +105,7 @@ class FakeNotificationSettingsService(
} else {
roomNotificationModeIsDefault = false
roomNotificationMode = mode
_notificationSettingsStateFlow.emit(Unit)
notificationSettingsStateFlow.emit(Unit)
Result.success(Unit)
}
}
@ -117,7 +117,7 @@ class FakeNotificationSettingsService(
}
roomNotificationModeIsDefault = true
roomNotificationMode = defaultEncryptedGroupRoomNotificationMode
_notificationSettingsStateFlow.emit(Unit)
notificationSettingsStateFlow.emit(Unit)
return Result.success(Unit)
}

View file

@ -49,9 +49,11 @@ class PushersManager @Inject constructor(
suspend fun testPush() {
pushGatewayNotifyRequest.execute(
PushGatewayNotifyRequest.Params(
url = "TODO", // unifiedPushHelper.getPushGateway() ?: return,
// unifiedPushHelper.getPushGateway() ?: return
url = "TODO",
appId = PushConfig.PUSHER_APP_ID,
pushKey = "TODO", // unifiedPushHelper.getEndpointOrToken().orEmpty(),
// unifiedPushHelper.getEndpointOrToken().orEmpty()
pushKey = "TODO",
eventId = TEST_EVENT_ID
)
)
@ -86,10 +88,13 @@ class PushersManager @Inject constructor(
SetHttpPusherData(
pushKey = pushKey,
appId = PushConfig.PUSHER_APP_ID,
profileTag = DEFAULT_PUSHER_FILE_TAG + "_" /* TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())*/,
lang = "en", // TODO localeProvider.current().language,
// TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())
profileTag = DEFAULT_PUSHER_FILE_TAG + "_",
// TODO localeProvider.current().language
lang = "en",
appDisplayName = buildMeta.applicationName,
deviceDisplayName = "MyDevice", // TODO getDeviceInfoUseCase.execute().displayName().orEmpty(),
// TODO getDeviceInfoUseCase.execute().displayName().orEmpty()
deviceDisplayName = "MyDevice",
url = gateway,
defaultPayload = createDefaultPayload(pushClientSecret.getSecretForUser(userId))
)

View file

@ -21,8 +21,8 @@ object UnifiedPushConfig {
* It is the push gateway for UnifiedPush.
* Note: default_push_gateway_http_url should have path '/_matrix/push/v1/notify'
*/
const val default_push_gateway_http_url: String = "https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify"
const val DEFAULT_PUSH_GATEWAY_HTTP_URL: String = "https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify"
const val index = 1
const val name = "UnifiedPush"
const val INDEX = 1
const val NAME = "UnifiedPush"
}

View file

@ -29,7 +29,7 @@ class UnifiedPushGatewayResolver @Inject constructor(
private val coroutineDispatchers: CoroutineDispatchers,
) {
suspend fun getGateway(endpoint: String): String? {
val gateway = UnifiedPushConfig.default_push_gateway_http_url
val gateway = UnifiedPushConfig.DEFAULT_PUSH_GATEWAY_HTTP_URL
val url = URL(endpoint)
val port = if (url.port != -1) ":${url.port}" else ""
val customBase = "${url.protocol}://${url.host}$port"

View file

@ -41,7 +41,7 @@ class UnifiedPushNewGatewayHandler @Inject constructor(
Timber.w("Unable to retrieve session")
}
val userDataStore = userPushStoreFactory.create(userId)
if (userDataStore.getPushProviderName() == UnifiedPushConfig.name) {
if (userDataStore.getPushProviderName() == UnifiedPushConfig.NAME) {
matrixAuthenticationService.restoreSession(userId).getOrNull()?.use { client ->
pusherSubscriber.registerPusher(client, endpoint, pushGateway)
}

View file

@ -35,8 +35,8 @@ class UnifiedPushProvider @Inject constructor(
private val unRegisterUnifiedPushUseCase: UnregisterUnifiedPushUseCase,
private val pushClientSecret: PushClientSecret,
) : PushProvider {
override val index = UnifiedPushConfig.index
override val name = UnifiedPushConfig.name
override val index = UnifiedPushConfig.INDEX
override val name = UnifiedPushConfig.NAME
override fun getDistributors(): List<Distributor> {
val distributors = UnifiedPush.getDistributors(context)

View file

@ -138,7 +138,8 @@ fun RoomSelectView(
LazyColumn {
item {
SelectedRoomsHelper(
isForwarding = false, // TODO state.isForwarding,
// TODO state.isForwarding
isForwarding = false,
selectedRooms = state.selectedRooms
)
}

View file

@ -93,7 +93,7 @@ private constructor(
private fun createOutputBuffer(sampleRate: SampleRate): ShortArray {
val bufferSizeInShorts = AudioRecord.getMinBufferSize(
sampleRate.hz,
sampleRate.HZ,
config.format.channelMask,
config.format.encoding
)

View file

@ -19,6 +19,6 @@ package io.element.android.libraries.voicerecorder.impl.audio
import io.element.android.opusencoder.configuration.SampleRate as LibOpusOggSampleRate
data object SampleRate {
const val hz = 48_000
const val HZ = 48_000
fun asEncoderModel() = LibOpusOggSampleRate.Rate48kHz
}

View file

@ -37,10 +37,11 @@ object VoiceRecorderModule {
return AudioConfig(
format = AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(sampleRate.hz)
.setSampleRate(sampleRate.HZ)
.setChannelMask(AudioFormat.CHANNEL_IN_MONO)
.build(),
bitRate = 24_000, // 24 kbps
// 24 kbps
bitRate = 24_000,
sampleRate = sampleRate,
source = MediaRecorder.AudioSource.MIC,
)

View file

@ -141,8 +141,9 @@ class VoiceRecorderImplTest {
),
encoder = FakeEncoder(fakeFileSystem),
config = AudioConfig(
format = AUDIO_FORMAT,
bitRate = 24_000, // 24 kbps
format = audioFormat,
// 24 kbps
bitRate = 24_000,
sampleRate = SampleRate,
source = MediaRecorder.AudioSource.MIC,
),
@ -156,7 +157,7 @@ class VoiceRecorderImplTest {
companion object {
const val FILE_ID: String = "recording"
const val FILE_PATH = "voice_recordings/$FILE_ID.ogg"
private lateinit var AUDIO_FORMAT: AudioFormat
private lateinit var audioFormat: AudioFormat
// FakeEncoder doesn't actually encode, it just writes the data to the file
private const val ENCODED_DATA = "[32767, 32767, 32767][32767, 32767, 32767]"
@ -170,7 +171,7 @@ class VoiceRecorderImplTest {
@BeforeClass
@JvmStatic
fun initAudioFormat() {
AUDIO_FORMAT = mockk()
audioFormat = mockk()
}
}
}