Fix detekted issues.

This commit is contained in:
Benoit Marty
2023-09-01 17:39:46 +02:00
committed by Benoit Marty
parent 2128bfe853
commit 8a46faeaf8
4 changed files with 36 additions and 30 deletions

View File

@@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import io.element.android.libraries.architecture.Presenter
import kotlinx.collections.immutable.toImmutableMap
import javax.inject.Inject
class ConfigureTracingPresenter @Inject constructor(
@@ -46,7 +47,7 @@ class ConfigureTracingPresenter @Inject constructor(
}
return ConfigureTracingState(
targetsToLogLevel = modifiedMap.value,
targetsToLogLevel = modifiedMap.value.toImmutableMap(),
eventSink = ::handleEvents
)
}

View File

@@ -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.Target
import kotlinx.collections.immutable.ImmutableMap
data class ConfigureTracingState(
val targetsToLogLevel: Map<Target, LogLevel>,
val targetsToLogLevel: ImmutableMap<Target, LogLevel>,
val eventSink: (ConfigureTracingEvents) -> Unit
)

View File

@@ -19,6 +19,7 @@ package io.element.android.features.preferences.impl.developer.tracing
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import io.element.android.libraries.matrix.api.tracing.LogLevel
import io.element.android.libraries.matrix.api.tracing.Target
import kotlinx.collections.immutable.persistentMapOf
open class ConfigureTracingStateProvider : PreviewParameterProvider<ConfigureTracingState> {
override val values: Sequence<ConfigureTracingState>
@@ -28,7 +29,7 @@ open class ConfigureTracingStateProvider : PreviewParameterProvider<ConfigureTra
}
fun aConfigureTracingState() = ConfigureTracingState(
targetsToLogLevel = mapOf(
targetsToLogLevel = persistentMapOf(
Target.COMMON to LogLevel.INFO,
Target.MATRIX_SDK_FFI to LogLevel.WARN,
Target.MATRIX_SDK_BASE_SLIDING_SYNC to LogLevel.ERROR,

View File

@@ -16,6 +16,7 @@
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.WindowInsets
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.Target
import io.element.android.libraries.theme.ElementTheme
import kotlinx.collections.immutable.ImmutableMap
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -75,7 +77,6 @@ fun ConfigureTracingView(
contentWindowInsets = WindowInsets.statusBars,
topBar = {
TopAppBar(
modifier = modifier,
navigationIcon = {
BackButton(onClick = onBackPressed)
},
@@ -158,7 +159,7 @@ fun CrateListContent(
@Composable
private fun TargetAndLogLevelListView(
data: Map<Target, LogLevel>,
data: ImmutableMap<Target, LogLevel>,
onLogLevelChange: (Target, LogLevel) -> Unit,
modifier: Modifier = Modifier,
) {
@@ -205,32 +206,34 @@ fun LogLevelDropdownMenu(
modifier: Modifier = Modifier,
) {
var expanded by remember { mutableStateOf(false) }
DropdownMenuItem(
modifier = modifier.widthIn(max = 120.dp),
text = { Text(text = logLevel.filter) },
onClick = { expanded = !expanded },
trailingIcon = {
if (expanded) {
Icon(Icons.Default.ArrowDropUp, contentDescription = null)
} else {
Icon(Icons.Default.ArrowDropDown, contentDescription = null)
}
},
)
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
) {
LogLevel.values().forEach { logLevel ->
DropdownMenuItem(
text = {
Text(text = logLevel.filter)
},
onClick = {
expanded = false
onLogLevelChange(logLevel)
Box(modifier = modifier) {
DropdownMenuItem(
modifier = Modifier.widthIn(max = 120.dp),
text = { Text(text = logLevel.filter) },
onClick = { expanded = !expanded },
trailingIcon = {
if (expanded) {
Icon(Icons.Default.ArrowDropUp, contentDescription = null)
} else {
Icon(Icons.Default.ArrowDropDown, contentDescription = null)
}
)
},
)
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
) {
LogLevel.values().forEach { logLevel ->
DropdownMenuItem(
text = {
Text(text = logLevel.filter)
},
onClick = {
expanded = false
onLogLevelChange(logLevel)
}
)
}
}
}
}