Fix moar ktlint issues
This commit is contained in:
committed by
Benoit Marty
parent
378692f743
commit
72a363c244
@@ -85,7 +85,8 @@ fun RoomPrivacyOption(
|
||||
.align(Alignment.CenterVertically)
|
||||
.size(48.dp),
|
||||
selected = isSelected,
|
||||
onClick = null // null recommended for accessibility with screenreaders
|
||||
// null recommended for accessibility with screenreaders
|
||||
onClick = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class OidcUrlParser @Inject constructor() {
|
||||
* `io.element:/callback?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB`
|
||||
*/
|
||||
fun parse(url: String): OidcAction? {
|
||||
if (url.startsWith(OidcConfig.redirectUri).not()) return null
|
||||
if (url.startsWith(OidcConfig.REDIRECT_URI).not()) return null
|
||||
if (url.contains("error=access_denied")) return OidcAction.GoBack
|
||||
if (url.contains("code=")) return OidcAction.Success(url)
|
||||
|
||||
|
||||
@@ -201,7 +201,8 @@ private fun HomeserverData.toAccountProvider(): AccountProvider {
|
||||
return AccountProvider(
|
||||
url = homeserverUrl,
|
||||
subtitle = if (isMatrixOrg) stringResource(id = R.string.screen_change_account_provider_matrix_org_subtitle) else null,
|
||||
isPublic = isMatrixOrg, // There is no need to know for other servers right now
|
||||
// There is no need to know for other servers right now
|
||||
isPublic = isMatrixOrg,
|
||||
isMatrixOrg = isMatrixOrg,
|
||||
isValid = isWellknownValid,
|
||||
supportSlidingSync = supportSlidingSync,
|
||||
|
||||
@@ -38,21 +38,21 @@ class OidcUrlParserTest {
|
||||
@Test
|
||||
fun `test cancel url`() {
|
||||
val sut = OidcUrlParser()
|
||||
val aCancelUrl = OidcConfig.redirectUri + "?error=access_denied&state=IFF1UETGye2ZA8pO"
|
||||
val aCancelUrl = OidcConfig.REDIRECT_URI + "?error=access_denied&state=IFF1UETGye2ZA8pO"
|
||||
assertThat(sut.parse(aCancelUrl)).isEqualTo(OidcAction.GoBack)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test success url`() {
|
||||
val sut = OidcUrlParser()
|
||||
val aSuccessUrl = OidcConfig.redirectUri + "?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB"
|
||||
val aSuccessUrl = OidcConfig.REDIRECT_URI + "?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB"
|
||||
assertThat(sut.parse(aSuccessUrl)).isEqualTo(OidcAction.Success(aSuccessUrl))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test unknown url`() {
|
||||
val sut = OidcUrlParser()
|
||||
val anUnknownUrl = OidcConfig.redirectUri + "?state=IFF1UETGye2ZA8pO&goat=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB"
|
||||
val anUnknownUrl = OidcConfig.REDIRECT_URI + "?state=IFF1UETGye2ZA8pO&goat=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB"
|
||||
Assert.assertThrows(IllegalStateException::class.java) {
|
||||
assertThat(sut.parse(anUnknownUrl))
|
||||
}
|
||||
|
||||
@@ -130,7 +130,8 @@ internal fun ExpandableBottomSheetScaffold(
|
||||
contentOverflows = contentHeight > maxHeight
|
||||
|
||||
val peekHeight = min(
|
||||
maxHeight, // prevent the sheet from expanding beyond the screen
|
||||
// prevent the sheet from expanding beyond the screen
|
||||
maxHeight,
|
||||
contentHeight
|
||||
)
|
||||
|
||||
|
||||
@@ -416,8 +416,9 @@ private fun MessageEventBubbleContent(
|
||||
onMentionClicked: (Mention) -> Unit,
|
||||
eventSink: (TimelineEvents) -> Unit,
|
||||
@SuppressLint("ModifierParameter")
|
||||
// need to rename this modifier to prevent linter false positives
|
||||
@Suppress("ModifierNaming")
|
||||
bubbleModifier: Modifier = Modifier, // need to rename this modifier to prevent linter false positives
|
||||
bubbleModifier: Modifier = Modifier,
|
||||
) {
|
||||
// Long clicks are not not automatically propagated from a `clickable`
|
||||
// to its `combinedClickable` parent so we do it manually
|
||||
@@ -462,10 +463,12 @@ private fun MessageEventBubbleContent(
|
||||
onClick = onTimestampClicked,
|
||||
onLongClick = ::onTimestampLongClick,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 4.dp, vertical = 4.dp) // Outer padding
|
||||
// Outer padding
|
||||
.padding(horizontal = 4.dp, vertical = 4.dp)
|
||||
.background(ElementTheme.colors.bgSubtleSecondary, RoundedCornerShape(10.0.dp))
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(horizontal = 4.dp, vertical = 2.dp) // Inner padding
|
||||
// Inner padding
|
||||
.padding(horizontal = 4.dp, vertical = 2.dp)
|
||||
)
|
||||
}
|
||||
TimestampPosition.Aligned ->
|
||||
|
||||
@@ -95,7 +95,8 @@ fun EventDebugInfoView(
|
||||
.fillMaxWidth()
|
||||
.padding(padding) // Window insets
|
||||
.consumeWindowInsets(padding)
|
||||
.padding(horizontal = 16.dp) // Internal padding
|
||||
// Internal padding
|
||||
.padding(horizontal = 16.dp)
|
||||
) {
|
||||
item {
|
||||
Column(Modifier.padding(vertical = 10.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
package io.element.android.features.onboarding.impl
|
||||
|
||||
object OnBoardingConfig {
|
||||
const val canLoginWithQrCode = false
|
||||
const val canCreateAccount = false
|
||||
const val CAN_LOGIN_WITH_QR_CODE = false
|
||||
const val CAN_CREATE_ACCOUNT = false
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ class OnBoardingPresenter @Inject constructor(
|
||||
override fun present(): OnBoardingState {
|
||||
return OnBoardingState(
|
||||
isDebugBuild = buildMeta.buildType != BuildType.RELEASE,
|
||||
canLoginWithQrCode = OnBoardingConfig.canLoginWithQrCode,
|
||||
canCreateAccount = OnBoardingConfig.canCreateAccount,
|
||||
canLoginWithQrCode = OnBoardingConfig.CAN_LOGIN_WITH_QR_CODE,
|
||||
canCreateAccount = OnBoardingConfig.CAN_CREATE_ACCOUNT,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ private fun CrashDetectionContent(
|
||||
) {
|
||||
ConfirmationDialog(
|
||||
title = stringResource(id = CommonStrings.action_report_bug),
|
||||
content = stringResource(id = R.string.crash_detection_dialog_content, /* TODO App name */ "Element"),
|
||||
// TODO: Replace with app name
|
||||
content = stringResource(id = R.string.crash_detection_dialog_content, "Element"),
|
||||
submitText = stringResource(id = CommonStrings.action_yes),
|
||||
cancelText = stringResource(id = CommonStrings.action_no),
|
||||
onCancelClicked = onNoClicked,
|
||||
|
||||
@@ -56,7 +56,8 @@ internal fun BlockUserSection(state: RoomMemberDetailsState, modifier: Modifier
|
||||
val event = when (state.isBlocked.prevData) {
|
||||
true -> RoomMemberDetailsEvents.UnblockUser(needsConfirmation = false)
|
||||
false -> RoomMemberDetailsEvents.BlockUser(needsConfirmation = false)
|
||||
null -> /*Should not happen */ RoomMemberDetailsEvents.ClearBlockUserError
|
||||
// null case Should not happen
|
||||
null -> RoomMemberDetailsEvents.ClearBlockUserError
|
||||
}
|
||||
state.eventSink(event)
|
||||
},
|
||||
|
||||
@@ -140,11 +140,11 @@ class SecureBackupSetupPresenterTest {
|
||||
)
|
||||
)
|
||||
val createdState = awaitItem()
|
||||
assertThat(createdState.setupState).isEqualTo(SetupState.Created(FakeEncryptionService.fakeRecoveryKey))
|
||||
assertThat(createdState.setupState).isEqualTo(SetupState.Created(FakeEncryptionService.FAKE_RECOVERY_KEY))
|
||||
assertThat(createdState.recoveryKeyViewState).isEqualTo(
|
||||
RecoveryKeyViewState(
|
||||
recoveryKeyUserStory = RecoveryKeyUserStory.Change,
|
||||
formattedRecoveryKey = FakeEncryptionService.fakeRecoveryKey,
|
||||
formattedRecoveryKey = FakeEncryptionService.FAKE_RECOVERY_KEY,
|
||||
inProgress = false,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -58,7 +58,8 @@ class RecoveryKeyVisualTransformationTest {
|
||||
|
||||
@Test
|
||||
fun `RecoveryKeyOffsetMapping computes correct transformedToOriginal values`() {
|
||||
val sut = RecoveryKeyVisualTransformation.RecoveryKeyOffsetMapping("" /* Not used by transformedToOriginal */)
|
||||
// text parameter is not used by transformedToOriginal
|
||||
val sut = RecoveryKeyVisualTransformation.RecoveryKeyOffsetMapping("")
|
||||
assertThat(sut.transformedToOriginal(0)).isEqualTo(0)
|
||||
assertThat(sut.transformedToOriginal(1)).isEqualTo(1)
|
||||
assertThat(sut.transformedToOriginal(2)).isEqualTo(2)
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
),
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -138,7 +138,8 @@ fun RoomSelectView(
|
||||
LazyColumn {
|
||||
item {
|
||||
SelectedRoomsHelper(
|
||||
isForwarding = false, // TODO state.isForwarding,
|
||||
// TODO state.isForwarding
|
||||
isForwarding = false,
|
||||
selectedRooms = state.selectedRooms
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user