diff options
Diffstat (limited to 'android/app/src')
3 files changed, 19 insertions, 45 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt index 21967c97a3..1329132591 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt @@ -1,21 +1,19 @@ package net.mullvad.mullvadvpn.compose.screen -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.text.selection.SelectionContainer -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold -import androidx.compose.material3.TextField -import androidx.compose.material3.TextFieldDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import net.mullvad.mullvadvpn.R @@ -31,7 +29,7 @@ import net.mullvad.mullvadvpn.viewmodel.ViewLogsUiState @Preview @Composable private fun PreviewViewLogsScreen() { - AppTheme { ViewLogsScreen(uiState = ViewLogsUiState("Lorem ipsum")) } + AppTheme { ViewLogsScreen(uiState = ViewLogsUiState(listOf("Lorem ipsum"))) } } @Preview @@ -72,32 +70,19 @@ fun ViewLogsScreen( color = MaterialTheme.colorScheme.primary ) } else { - SelectionContainer { - val scrollState = rememberScrollState() - Column( - modifier = - Modifier.drawVerticalScrollbar( - scrollState, - color = - MaterialTheme.colorScheme.primary.copy(alpha = AlphaScrollbar) + val scrollState = rememberScrollState() + val state = rememberLazyListState() + LazyColumn( + state = state, + modifier = + Modifier.drawVerticalScrollbar( + state, + MaterialTheme.colorScheme.primary.copy(alpha = AlphaScrollbar) ) - ) { - TextField( - modifier = - Modifier.verticalScroll(scrollState) - .padding(horizontal = Dimens.smallPadding), - value = uiState.allLines, - textStyle = MaterialTheme.typography.bodySmall, - onValueChange = {}, - readOnly = true, - colors = - TextFieldDefaults.colors( - focusedTextColor = Color.Black, - unfocusedTextColor = Color.Black, - disabledTextColor = Color.Black, - cursorColor = MaterialTheme.colorScheme.background, - ) - ) + .padding(horizontal = Dimens.smallPadding) + ) { + items(uiState.allLines) { + Text(text = it, style = MaterialTheme.typography.bodySmall) } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/TimingConstant.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/TimingConstant.kt index cace9b2b79..2a09964a80 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/TimingConstant.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/TimingConstant.kt @@ -1,4 +1,3 @@ package net.mullvad.mullvadvpn.constant const val MINIMUM_LOADING_TIME_MILLIS = 500L -const val NAVIGATION_DELAY_MILLIS = 500L diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt index 7b07adc874..50e5a70277 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ViewLogsViewModel.kt @@ -2,15 +2,13 @@ package net.mullvad.mullvadvpn.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch -import net.mullvad.mullvadvpn.constant.NAVIGATION_DELAY_MILLIS import net.mullvad.mullvadvpn.dataproxy.MullvadProblemReport -data class ViewLogsUiState(val allLines: String = "", val isLoading: Boolean = true) +data class ViewLogsUiState(val allLines: List<String> = emptyList(), val isLoading: Boolean = true) class ViewLogsViewModel(private val mullvadProblemReporter: MullvadProblemReport) : ViewModel() { @@ -19,16 +17,8 @@ class ViewLogsViewModel(private val mullvadProblemReporter: MullvadProblemReport init { viewModelScope.launch { - // Loading this much text takes a while, so we show a loading indicator until the - // fragment transitions is done. I'd very much prefer to use LazyColumn in the view - // which would make the loading way faster but then the SelectionContainer is broken and - // text would not be copyable. - delay(NAVIGATION_DELAY_MILLIS) _uiState.update { - it.copy( - allLines = mullvadProblemReporter.readLogs().joinToString("\n"), - isLoading = false - ) + it.copy(allLines = mullvadProblemReporter.readLogs(), isLoading = false) } } } |
