Fix detekted issues.

This commit is contained in:
Benoit Marty
2023-09-01 17:39:46 +02:00
committed by Benoit Marty
parent 55f3b935c3
commit 73b5ce5fe3
4 changed files with 36 additions and 30 deletions
@@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.architecture.Presenter
import kotlinx.collections.immutable.toImmutableMap
import javax.inject.Inject import javax.inject.Inject
class ConfigureTracingPresenter @Inject constructor( class ConfigureTracingPresenter @Inject constructor(
@@ -46,7 +47,7 @@ class ConfigureTracingPresenter @Inject constructor(
} }
return ConfigureTracingState( return ConfigureTracingState(
targetsToLogLevel = modifiedMap.value, targetsToLogLevel = modifiedMap.value.toImmutableMap(),
eventSink = ::handleEvents eventSink = ::handleEvents
) )
} }
@@ -18,8 +18,9 @@ package io.element.android.features.preferences.impl.developer.tracing
import io.element.android.libraries.matrix.api.tracing.LogLevel import io.element.android.libraries.matrix.api.tracing.LogLevel
import io.element.android.libraries.matrix.api.tracing.Target import io.element.android.libraries.matrix.api.tracing.Target
import kotlinx.collections.immutable.ImmutableMap
data class ConfigureTracingState( data class ConfigureTracingState(
val targetsToLogLevel: Map<Target, LogLevel>, val targetsToLogLevel: ImmutableMap<Target, LogLevel>,
val eventSink: (ConfigureTracingEvents) -> Unit val eventSink: (ConfigureTracingEvents) -> Unit
) )
@@ -19,6 +19,7 @@ package io.element.android.features.preferences.impl.developer.tracing
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import io.element.android.libraries.matrix.api.tracing.LogLevel import io.element.android.libraries.matrix.api.tracing.LogLevel
import io.element.android.libraries.matrix.api.tracing.Target import io.element.android.libraries.matrix.api.tracing.Target
import kotlinx.collections.immutable.persistentMapOf
open class ConfigureTracingStateProvider : PreviewParameterProvider<ConfigureTracingState> { open class ConfigureTracingStateProvider : PreviewParameterProvider<ConfigureTracingState> {
override val values: Sequence<ConfigureTracingState> override val values: Sequence<ConfigureTracingState>
@@ -28,7 +29,7 @@ open class ConfigureTracingStateProvider : PreviewParameterProvider<ConfigureTra
} }
fun aConfigureTracingState() = ConfigureTracingState( fun aConfigureTracingState() = ConfigureTracingState(
targetsToLogLevel = mapOf( targetsToLogLevel = persistentMapOf(
Target.COMMON to LogLevel.INFO, Target.COMMON to LogLevel.INFO,
Target.MATRIX_SDK_FFI to LogLevel.WARN, Target.MATRIX_SDK_FFI to LogLevel.WARN,
Target.MATRIX_SDK_BASE_SLIDING_SYNC to LogLevel.ERROR, Target.MATRIX_SDK_BASE_SLIDING_SYNC to LogLevel.ERROR,
@@ -16,6 +16,7 @@
package io.element.android.features.preferences.impl.developer.tracing package io.element.android.features.preferences.impl.developer.tracing
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.consumeWindowInsets
@@ -58,6 +59,7 @@ import io.element.android.libraries.designsystem.theme.components.TopAppBar
import io.element.android.libraries.matrix.api.tracing.LogLevel import io.element.android.libraries.matrix.api.tracing.LogLevel
import io.element.android.libraries.matrix.api.tracing.Target import io.element.android.libraries.matrix.api.tracing.Target
import io.element.android.libraries.theme.ElementTheme import io.element.android.libraries.theme.ElementTheme
import kotlinx.collections.immutable.ImmutableMap
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
@@ -75,7 +77,6 @@ fun ConfigureTracingView(
contentWindowInsets = WindowInsets.statusBars, contentWindowInsets = WindowInsets.statusBars,
topBar = { topBar = {
TopAppBar( TopAppBar(
modifier = modifier,
navigationIcon = { navigationIcon = {
BackButton(onClick = onBackPressed) BackButton(onClick = onBackPressed)
}, },
@@ -158,7 +159,7 @@ fun CrateListContent(
@Composable @Composable
private fun TargetAndLogLevelListView( private fun TargetAndLogLevelListView(
data: Map<Target, LogLevel>, data: ImmutableMap<Target, LogLevel>,
onLogLevelChange: (Target, LogLevel) -> Unit, onLogLevelChange: (Target, LogLevel) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
@@ -205,8 +206,9 @@ fun LogLevelDropdownMenu(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
var expanded by remember { mutableStateOf(false) } var expanded by remember { mutableStateOf(false) }
Box(modifier = modifier) {
DropdownMenuItem( DropdownMenuItem(
modifier = modifier.widthIn(max = 120.dp), modifier = Modifier.widthIn(max = 120.dp),
text = { Text(text = logLevel.filter) }, text = { Text(text = logLevel.filter) },
onClick = { expanded = !expanded }, onClick = { expanded = !expanded },
trailingIcon = { trailingIcon = {
@@ -233,6 +235,7 @@ fun LogLevelDropdownMenu(
) )
} }
} }
}
} }
@DayNightPreviews @DayNightPreviews