diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 690206e4..81758a5c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,7 +36,7 @@ kotlinxCoroutines = "1.11.0" kotlinxImmutable = "0.5.0" kotlinxSerialization = "1.11.0" kover = "0.9.8" -ktfmt = "0.63" +ktfmt = "0.64" licenses = "3.1.4" oshi = "7.3.1" profileinstaller = "1.4.1" diff --git a/shared/src/commonMain/kotlin/com/kgurgul/cpuinfo/features/settings/licenses/LicensesViewModel.kt b/shared/src/commonMain/kotlin/com/kgurgul/cpuinfo/features/settings/licenses/LicensesViewModel.kt index 66442a80..9af5d4cb 100644 --- a/shared/src/commonMain/kotlin/com/kgurgul/cpuinfo/features/settings/licenses/LicensesViewModel.kt +++ b/shared/src/commonMain/kotlin/com/kgurgul/cpuinfo/features/settings/licenses/LicensesViewModel.kt @@ -28,14 +28,13 @@ import kotlinx.coroutines.flow.stateIn class LicensesViewModel(getLicensesInteractor: GetLicensesInteractor) : ViewModel() { - val uiStateFlow = - flow { - emit(UiState(isLoading = true)) - getLicensesInteractor(Unit) - .onSuccess { emit(UiState(isLoading = false, licenses = it.toImmutableList())) } - .onFailure { emit(UiState(isLoading = false, isError = true)) } - } - .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), UiState()) + val uiStateFlow = flow { + emit(UiState(isLoading = true)) + getLicensesInteractor(Unit) + .onSuccess { emit(UiState(isLoading = false, licenses = it.toImmutableList())) } + .onFailure { emit(UiState(isLoading = false, isError = true)) } + } + .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), UiState()) data class UiState( val isLoading: Boolean = false, diff --git a/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/HardwareDataProvider.jvm.kt b/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/HardwareDataProvider.jvm.kt index b40512e3..2112373a 100644 --- a/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/HardwareDataProvider.jvm.kt +++ b/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/HardwareDataProvider.jvm.kt @@ -69,48 +69,46 @@ actual class HardwareDataProvider actual constructor() : KoinComponent { add(ItemValue.NameResource(Res.string.model, hardware.computerSystem.model)) add(ItemValue.NameResource(Res.string.serial, hardware.computerSystem.serialNumber)) add(ItemValue.NameResource(Res.string.hardware_uuid, hardware.computerSystem.hardwareUUID)) - val firmware = - buildString { - if (hardware.computerSystem.firmware.manufacturer != UNKNOWN) { - append(hardware.computerSystem.firmware.manufacturer) - append(" ") - } - if (hardware.computerSystem.firmware.name != UNKNOWN) { - append(hardware.computerSystem.firmware.name) - append(" ") - } - if (hardware.computerSystem.firmware.version != UNKNOWN) { - append(hardware.computerSystem.firmware.version) - append(" ") - } - if (hardware.computerSystem.firmware.description != UNKNOWN) { - append(hardware.computerSystem.firmware.description) - append(" ") - } - if (hardware.computerSystem.firmware.releaseDate != UNKNOWN) { - append(hardware.computerSystem.firmware.releaseDate) - } - } - .trim() - val motherboard = - buildString { - if (hardware.computerSystem.baseboard.manufacturer != UNKNOWN) { - append(hardware.computerSystem.baseboard.manufacturer) - append(" ") - } - if (hardware.computerSystem.baseboard.model != UNKNOWN) { - append(hardware.computerSystem.baseboard.model) - append(" ") - } - if (hardware.computerSystem.baseboard.version != UNKNOWN) { - append(hardware.computerSystem.baseboard.version) - append(" ") - } - if (hardware.computerSystem.baseboard.serialNumber != UNKNOWN) { - append(hardware.computerSystem.baseboard.serialNumber) - } - } - .trim() + val firmware = buildString { + if (hardware.computerSystem.firmware.manufacturer != UNKNOWN) { + append(hardware.computerSystem.firmware.manufacturer) + append(" ") + } + if (hardware.computerSystem.firmware.name != UNKNOWN) { + append(hardware.computerSystem.firmware.name) + append(" ") + } + if (hardware.computerSystem.firmware.version != UNKNOWN) { + append(hardware.computerSystem.firmware.version) + append(" ") + } + if (hardware.computerSystem.firmware.description != UNKNOWN) { + append(hardware.computerSystem.firmware.description) + append(" ") + } + if (hardware.computerSystem.firmware.releaseDate != UNKNOWN) { + append(hardware.computerSystem.firmware.releaseDate) + } + } + .trim() + val motherboard = buildString { + if (hardware.computerSystem.baseboard.manufacturer != UNKNOWN) { + append(hardware.computerSystem.baseboard.manufacturer) + append(" ") + } + if (hardware.computerSystem.baseboard.model != UNKNOWN) { + append(hardware.computerSystem.baseboard.model) + append(" ") + } + if (hardware.computerSystem.baseboard.version != UNKNOWN) { + append(hardware.computerSystem.baseboard.version) + append(" ") + } + if (hardware.computerSystem.baseboard.serialNumber != UNKNOWN) { + append(hardware.computerSystem.baseboard.serialNumber) + } + } + .trim() add(ItemValue.NameResource(Res.string.hardware_firmware, firmware)) add(ItemValue.NameResource(Res.string.hardware_motherboard, motherboard)) } @@ -119,18 +117,17 @@ actual class HardwareDataProvider actual constructor() : KoinComponent { if (hardware.diskStores.isNotEmpty()) { add(ItemValue.NameResource(Res.string.hardware_hard_drives, "")) hardware.diskStores.forEach { diskStore -> - val value = - buildString { - appendLine(diskStore.model.trim()) - appendLine(diskStore.diskType.trim()) - if (diskStore.serial.isNotEmpty()) { - appendLine(diskStore.serial.trim()) - } - if (diskStore.size > 0) { - appendLine(Utils.humanReadableByteCount(diskStore.size)) - } - } - .trim() + val value = buildString { + appendLine(diskStore.model.trim()) + appendLine(diskStore.diskType.trim()) + if (diskStore.serial.isNotEmpty()) { + appendLine(diskStore.serial.trim()) + } + if (diskStore.size > 0) { + appendLine(Utils.humanReadableByteCount(diskStore.size)) + } + } + .trim() add(ItemValue.Text(diskStore.name, value)) } } @@ -149,17 +146,16 @@ actual class HardwareDataProvider actual constructor() : KoinComponent { if (hardware.networkIFs.isNotEmpty()) { add(ItemValue.NameResource(Res.string.hardware_network_interfaces, "")) hardware.networkIFs.forEach { networkIF -> - val value = - buildString { - appendLine(networkIF.macaddr) - if (networkIF.iPv4addr.isNotEmpty()) { - appendLine(networkIF.iPv4addr.joinToString { "\n" }) - } - if (networkIF.iPv6addr.isNotEmpty()) { - appendLine(networkIF.iPv6addr.joinToString { "\n" }) - } - } - .trim() + val value = buildString { + appendLine(networkIF.macaddr) + if (networkIF.iPv4addr.isNotEmpty()) { + appendLine(networkIF.iPv4addr.joinToString { "\n" }) + } + if (networkIF.iPv6addr.isNotEmpty()) { + appendLine(networkIF.iPv6addr.joinToString { "\n" }) + } + } + .trim() add(ItemValue.Text(networkIF.name, value)) } } @@ -188,23 +184,22 @@ actual class HardwareDataProvider actual constructor() : KoinComponent { if (hardware.printers.isNotEmpty()) { add(ItemValue.NameResource(Res.string.hardware_printers, "")) hardware.printers.forEach { printer -> - val name = - buildString { - appendLine(printer.name) - if (!printer.driverName.isNullOrEmpty()) { - appendLine(printer.driverName) - } - if (!printer.description.isNullOrEmpty()) { - appendLine(printer.description) - } - if ( - !printer.statusReason.isNullOrEmpty() && - !printer.statusReason.equals(UNKNOWN, ignoreCase = true) - ) { - appendLine(printer.statusReason) - } - } - .trim() + val name = buildString { + appendLine(printer.name) + if (!printer.driverName.isNullOrEmpty()) { + appendLine(printer.driverName) + } + if (!printer.description.isNullOrEmpty()) { + appendLine(printer.description) + } + if ( + !printer.statusReason.isNullOrEmpty() && + !printer.statusReason.equals(UNKNOWN, ignoreCase = true) + ) { + appendLine(printer.statusReason) + } + } + .trim() val status = when (printer.status) { Printer.PrinterStatus.IDLE -> Res.string.hardware_printers_status_idle diff --git a/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/SensorsInfoProvider.jvm.kt b/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/SensorsInfoProvider.jvm.kt index cb2c6991..7abf0663 100644 --- a/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/SensorsInfoProvider.jvm.kt +++ b/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/SensorsInfoProvider.jvm.kt @@ -57,8 +57,10 @@ actual class SensorsInfoProvider actual constructor() : KoinComponent { ) } if (sensors.fanSpeeds.isNotEmpty()) { - val fanSpeeds = - buildString { sensors.fanSpeeds.forEach { appendLine("${it}RPM") } }.trim() + val fanSpeeds = buildString { + sensors.fanSpeeds.forEach { appendLine("${it}RPM") } + } + .trim() add( SensorData( id = FAN_SPEED_ID, diff --git a/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/StorageDataProvider.jvm.kt b/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/StorageDataProvider.jvm.kt index eaa94628..01297be9 100644 --- a/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/StorageDataProvider.jvm.kt +++ b/shared/src/desktopMain/kotlin/com/kgurgul/cpuinfo/data/provider/StorageDataProvider.jvm.kt @@ -30,25 +30,25 @@ actual class StorageDataProvider actual constructor() : IStorageDataProvider, Ko actual override suspend fun getStorageInfo(): List { val fileStores = systemInfo.operatingSystem.fileSystem.fileStores return buildList { - fileStores.forEach { osFileStore -> - val label = buildString { - if (!osFileStore.label.isNullOrEmpty()) { - appendLine(osFileStore.label) - } - appendLine(osFileStore.name) - appendLine(osFileStore.type) + fileStores.forEach { osFileStore -> + val label = buildString { + if (!osFileStore.label.isNullOrEmpty()) { + appendLine(osFileStore.label) } - add( - StorageItem( - id = osFileStore.uuid, - label = TextResource.Text(label), - iconDrawable = Res.drawable.ic_hard_drive, - storageTotal = osFileStore.totalSpace, - storageUsed = osFileStore.totalSpace - osFileStore.freeSpace, - ) - ) + appendLine(osFileStore.name) + appendLine(osFileStore.type) } + add( + StorageItem( + id = osFileStore.uuid, + label = TextResource.Text(label), + iconDrawable = Res.drawable.ic_hard_drive, + storageTotal = osFileStore.totalSpace, + storageUsed = osFileStore.totalSpace - osFileStore.freeSpace, + ) + ) } + } .distinctBy { it.id } .sortedBy { (it.label as? TextResource.Text)?.value } }