diff --git a/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/DatabaseRepo.kt b/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/DatabaseRepo.kt index fe897a9c..3fbabeea 100644 --- a/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/DatabaseRepo.kt +++ b/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/DatabaseRepo.kt @@ -46,8 +46,10 @@ class DatabaseRepo( } override suspend fun updateTLEFromFile(uri: String) = withContext(dispatcher) { - remoteSource.getFileStream(uri)?.let { - localSource.insertEntries(dataParser.parseTLEStream(it)) + remoteSource.getFileStream(uri)?.let { stream -> + val entries = dataParser.parseTLEStream(stream) + localSource.insertEntries(entries) + settingsRepo.setSatelliteTypeIds("Other", entries.map { it.catnum }) } setUpdateSuccessful(System.currentTimeMillis()) } diff --git a/core/presentation/src/main/res/values-es/strings.xml b/core/presentation/src/main/res/values-es/strings.xml index a68859e2..75d6c764 100644 --- a/core/presentation/src/main/res/values-es/strings.xml +++ b/core/presentation/src/main/res/values-es/strings.xml @@ -118,12 +118,10 @@ Salida de datos de red Enable rotation output - Dirección IP - Puerto + IP:Puerto Formato de datos Enable frequency output - Dirección IP - Puerto + IP:Puerto Formato de datos Salida por Bluetooth diff --git a/core/presentation/src/main/res/values-ru/strings.xml b/core/presentation/src/main/res/values-ru/strings.xml index 83e5d918..358fd036 100644 --- a/core/presentation/src/main/res/values-ru/strings.xml +++ b/core/presentation/src/main/res/values-ru/strings.xml @@ -117,12 +117,10 @@ Вывод сетевых данных Включить вывод ротатора - IP адрес - Порт + IP:Порт Формат Включить вывод частоты - IP адрес - Порт + IP:Порт Формат Вывод данных Bluetooth diff --git a/core/presentation/src/main/res/values-si/strings.xml b/core/presentation/src/main/res/values-si/strings.xml index b8a1c495..6777d1b5 100644 --- a/core/presentation/src/main/res/values-si/strings.xml +++ b/core/presentation/src/main/res/values-si/strings.xml @@ -118,12 +118,10 @@ ජාල ප්‍රතිදානය Enable rotation output - IP ලිපිනය - Port + IP:Port දත්ත අකාරය Enable frequency output - IP ලිපිනය - Port + IP:Port දත්ත අකාරය Bluetooth දත්ත ප්‍රතිදානය diff --git a/core/presentation/src/main/res/values-uk/strings.xml b/core/presentation/src/main/res/values-uk/strings.xml index 19c0d6d7..85d94a03 100644 --- a/core/presentation/src/main/res/values-uk/strings.xml +++ b/core/presentation/src/main/res/values-uk/strings.xml @@ -118,12 +118,10 @@ Вивід мережевих даних Enable rotation output - IP адреса - Порт + IP:Порт Формат даних Enable frequency output - IP адреса - Порт + IP:Порт Формат даних Вивід даних Bluetooth diff --git a/core/presentation/src/main/res/values-zh/strings.xml b/core/presentation/src/main/res/values-zh/strings.xml index bd55a20c..40b7c0e8 100644 --- a/core/presentation/src/main/res/values-zh/strings.xml +++ b/core/presentation/src/main/res/values-zh/strings.xml @@ -110,12 +110,10 @@ 网络数据输出 启用方位俯仰角输出 - IP地址 - 端口 + IP:端口 数据格式 启用多普勒频率输出 - IP地址 - 端口 + IP:端口 数据格式 蓝牙数据输出 diff --git a/core/presentation/src/main/res/values/strings.xml b/core/presentation/src/main/res/values/strings.xml index 9705d024..7bcc1c68 100644 --- a/core/presentation/src/main/res/values/strings.xml +++ b/core/presentation/src/main/res/values/strings.xml @@ -147,12 +147,10 @@ Network data output Enable rotation output - IP address - Port + IP:Port Format Enable frequency output - IP address - Port + IP:Port Format Bluetooth data output diff --git a/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsDialog.kt b/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsDialog.kt index 07aa8d27..8e3c6d13 100644 --- a/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsDialog.kt +++ b/feature/settings/src/main/java/com/rtbishop/look4sat/feature/settings/SettingsDialog.kt @@ -240,22 +240,26 @@ fun NetworkOutputDialog( ) { val padding = LocalSpacing.current.large val rotatorState = rememberSaveable { mutableStateOf(initialSettings.rotatorState) } - val rotatorAddress = rememberSaveable { mutableStateOf(initialSettings.rotatorAddress) } - val rotatorPort = rememberSaveable { mutableStateOf(initialSettings.rotatorPort) } + val rotatorAddress = rememberSaveable { + mutableStateOf("${initialSettings.rotatorAddress}:${initialSettings.rotatorPort}") + } val rotatorFormat = rememberSaveable { mutableStateOf(initialSettings.rotatorFormat) } val frequencyState = rememberSaveable { mutableStateOf(initialSettings.frequencyState) } - val frequencyAddress = rememberSaveable { mutableStateOf(initialSettings.frequencyAddress) } - val frequencyPort = rememberSaveable { mutableStateOf(initialSettings.frequencyPort) } + val frequencyAddress = rememberSaveable { + mutableStateOf("${initialSettings.frequencyAddress}:${initialSettings.frequencyPort}") + } val frequencyFormat = rememberSaveable { mutableStateOf(initialSettings.frequencyFormat) } val onAccept = { + val (rotIp, rotPort) = splitAddress(rotatorAddress.value) + val (freqIp, freqPort) = splitAddress(frequencyAddress.value) onSave( rotatorState.value, - rotatorAddress.value, - rotatorPort.value, + rotIp, + rotPort, rotatorFormat.value, frequencyState.value, - frequencyAddress.value, - frequencyPort.value, + freqIp, + freqPort, frequencyFormat.value ) onDismiss() @@ -285,29 +289,20 @@ fun NetworkOutputDialog( value = rotatorAddress.value, onValueChange = { rotatorAddress.value = it }, singleLine = true, - label = { Text(stringResource(R.string.prefs_net_rotator_ip_hint)) }, - modifier = Modifier.weight(1.5f), + label = { Text(stringResource(R.string.prefs_net_rotator_address_hint)) }, + modifier = Modifier.weight(0.6f), enabled = rotatorState.value ) OutlinedTextField( - value = rotatorPort.value, - onValueChange = { rotatorPort.value = it }, + value = rotatorFormat.value, + onValueChange = { rotatorFormat.value = it }, singleLine = true, - label = { Text(stringResource(R.string.prefs_net_rotator_port_hint)) }, - modifier = Modifier.weight(1f), + label = { Text(stringResource(R.string.prefs_net_rotator_format_hint)) }, + modifier = Modifier.weight(0.4f), enabled = rotatorState.value ) } Spacer(modifier = Modifier.height(6.dp)) - OutlinedTextField( - value = rotatorFormat.value, - onValueChange = { rotatorFormat.value = it }, - singleLine = true, - label = { Text(stringResource(R.string.prefs_net_rotator_format_hint)) }, - modifier = Modifier.fillMaxWidth(), - enabled = rotatorState.value - ) - Spacer(modifier = Modifier.height(6.dp)) Row( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, @@ -327,32 +322,32 @@ fun NetworkOutputDialog( value = frequencyAddress.value, onValueChange = { frequencyAddress.value = it }, singleLine = true, - label = { Text(stringResource(R.string.prefs_net_frequency_ip_hint)) }, - modifier = Modifier.weight(1.5f), + label = { Text(stringResource(R.string.prefs_net_frequency_address_hint)) }, + modifier = Modifier.weight(0.6f), enabled = frequencyState.value ) OutlinedTextField( - value = frequencyPort.value, - onValueChange = { frequencyPort.value = it }, + value = frequencyFormat.value, + onValueChange = { frequencyFormat.value = it }, singleLine = true, - label = { Text(stringResource(R.string.prefs_net_frequency_port_hint)) }, - modifier = Modifier.weight(1f), + label = { Text(stringResource(R.string.prefs_net_frequency_format_hint)) }, + modifier = Modifier.weight(0.4f), enabled = frequencyState.value ) } - Spacer(modifier = Modifier.height(6.dp)) - OutlinedTextField( - value = frequencyFormat.value, - onValueChange = { frequencyFormat.value = it }, - maxLines = 2, - label = { Text(stringResource(R.string.prefs_net_frequency_format_hint)) }, - modifier = Modifier.fillMaxWidth(), - enabled = frequencyState.value - ) } } } +private fun splitAddress(address: String): Pair { + val lastColon = address.lastIndexOf(':') + return if (lastColon >= 0) { + address.substring(0, lastColon) to address.substring(lastColon + 1) + } else { + address to "" + } +} + @Preview(showBackground = true) @Composable fun PreviewBluetoothOutputDialog() { @@ -434,7 +429,7 @@ fun BluetoothOutputDialog( onValueChange = { rotatorAddress.value = it }, singleLine = true, label = { Text(stringResource(R.string.prefs_bt_rotator_device_hint)) }, - modifier = Modifier.weight(1.5f), + modifier = Modifier.weight(0.6f), enabled = rotatorState.value ) OutlinedTextField( @@ -442,7 +437,7 @@ fun BluetoothOutputDialog( onValueChange = { rotatorFormat.value = it }, singleLine = true, label = { Text(stringResource(R.string.prefs_bt_rotator_output_hint)) }, - modifier = Modifier.weight(1f), + modifier = Modifier.weight(0.4f), enabled = rotatorState.value ) } @@ -467,7 +462,7 @@ fun BluetoothOutputDialog( onValueChange = { frequencyAddress.value = it }, singleLine = true, label = { Text(stringResource(R.string.prefs_bt_frequency_device_hint)) }, - modifier = Modifier.weight(1.5f), + modifier = Modifier.weight(0.6f), enabled = frequencyState.value ) OutlinedTextField( @@ -475,7 +470,7 @@ fun BluetoothOutputDialog( onValueChange = { frequencyFormat.value = it }, singleLine = true, label = { Text(stringResource(R.string.prefs_bt_frequency_output_hint)) }, - modifier = Modifier.weight(1f), + modifier = Modifier.weight(0.4f), enabled = frequencyState.value ) }