tms config download page
This commit is contained in:
parent
8b3fb9a1a5
commit
18851cf7a1
@ -22,6 +22,7 @@ import androidx.compose.material3.CardDefaults
|
|||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LinearProgressIndicator
|
import androidx.compose.material3.LinearProgressIndicator
|
||||||
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
@ -49,14 +50,16 @@ fun TmsSetupRoute(
|
|||||||
|
|
||||||
TmsSetupScreen(
|
TmsSetupScreen(
|
||||||
state = state,
|
state = state,
|
||||||
onRetry = viewModel::downloadConfigs
|
onRetry = viewModel::downloadConfigs,
|
||||||
|
onSkip = viewModel::skipDownload
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TmsSetupScreen(
|
fun TmsSetupScreen(
|
||||||
state: TmsSetupUiState,
|
state: TmsSetupUiState,
|
||||||
onRetry: () -> Unit
|
onRetry: () -> Unit,
|
||||||
|
onSkip: () -> Unit
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -155,6 +158,15 @@ fun TmsSetupScreen(
|
|||||||
)
|
)
|
||||||
Text(text = "Retry", fontSize = 16.sp)
|
Text(text = "Retry", fontSize = 16.sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = onSkip,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(12.dp),
|
||||||
|
colors = ButtonDefaults.outlinedButtonColors(contentColor = AppColor.LegacyRed)
|
||||||
|
) {
|
||||||
|
Text(text = "Skip", fontSize = 16.sp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ class TmsSetupViewModel @Inject constructor(
|
|||||||
isLoading = false,
|
isLoading = false,
|
||||||
isError = true,
|
isError = true,
|
||||||
statusText = "Download failed",
|
statusText = "Download failed",
|
||||||
errorMessage = error.message ?: "Network error"
|
errorMessage = formatNetworkError(error)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,6 +122,31 @@ class TmsSetupViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun skipDownload() {
|
||||||
|
viewModelScope.launch { _navigateToDashboard.emit(Unit) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun formatNetworkError(error: Throwable): String {
|
||||||
|
return when (error) {
|
||||||
|
is javax.net.ssl.SSLHandshakeException ->
|
||||||
|
"SSL handshake failed: ${error.message ?: "Certificate or protocol mismatch"}"
|
||||||
|
is javax.net.ssl.SSLException ->
|
||||||
|
"SSL/TLS error: ${error.message ?: "Secure connection could not be established"}"
|
||||||
|
is java.security.cert.CertificateException ->
|
||||||
|
"Server certificate error: ${error.message ?: "Certificate is invalid or untrusted"}"
|
||||||
|
is java.net.UnknownHostException ->
|
||||||
|
"Host not found: ${error.message ?: "Check server URL and network connection"}"
|
||||||
|
is java.net.ConnectException ->
|
||||||
|
"Connection refused: ${error.message ?: "Server is unreachable"}"
|
||||||
|
is java.net.SocketTimeoutException ->
|
||||||
|
"Connection timed out: ${error.message ?: "Server did not respond in time"}"
|
||||||
|
is retrofit2.HttpException ->
|
||||||
|
"HTTP ${error.code()} ${error.message()}"
|
||||||
|
else ->
|
||||||
|
error.message ?: "Unknown network error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
private fun buildRequest(): SiriusRequest {
|
private fun buildRequest(): SiriusRequest {
|
||||||
return try {
|
return try {
|
||||||
|
|||||||
@ -143,11 +143,9 @@ class TMSSetupsImpl : TMSSetups {
|
|||||||
"carousel_img_4",
|
"carousel_img_4",
|
||||||
"carousel_img_5",
|
"carousel_img_5",
|
||||||
"carousel_img_6" -> imgUrls.add(data)
|
"carousel_img_6" -> imgUrls.add(data)
|
||||||
|
|
||||||
//host
|
//host
|
||||||
"host_timeout",
|
"host_timeout",
|
||||||
"host_connect_timeout" -> ops.hostResponseTimeout = data
|
"host_connect_timeout" -> ops.hostResponseTimeout = data
|
||||||
|
|
||||||
"host_read_timeout" -> ops.hostReadTimeout = data
|
"host_read_timeout" -> ops.hostReadTimeout = data
|
||||||
"reversal_delay" -> ops.reversalDelay = data
|
"reversal_delay" -> ops.reversalDelay = data
|
||||||
"key_index" -> ops.tmkIndex = data
|
"key_index" -> ops.tmkIndex = data
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user