Fix detekted issues.
This commit is contained in:
parent
2128bfe853
commit
8a46faeaf8
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,32 +206,34 @@ fun LogLevelDropdownMenu(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
DropdownMenuItem(
|
Box(modifier = modifier) {
|
||||||
modifier = modifier.widthIn(max = 120.dp),
|
DropdownMenuItem(
|
||||||
text = { Text(text = logLevel.filter) },
|
modifier = Modifier.widthIn(max = 120.dp),
|
||||||
onClick = { expanded = !expanded },
|
text = { Text(text = logLevel.filter) },
|
||||||
trailingIcon = {
|
onClick = { expanded = !expanded },
|
||||||
if (expanded) {
|
trailingIcon = {
|
||||||
Icon(Icons.Default.ArrowDropUp, contentDescription = null)
|
if (expanded) {
|
||||||
} else {
|
Icon(Icons.Default.ArrowDropUp, contentDescription = null)
|
||||||
Icon(Icons.Default.ArrowDropDown, 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)
|
|
||||||
}
|
}
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = expanded,
|
||||||
|
onDismissRequest = { expanded = false },
|
||||||
|
) {
|
||||||
|
LogLevel.values().forEach { logLevel ->
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Text(text = logLevel.filter)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onLogLevelChange(logLevel)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue