diff --git a/lib_scanner/src/main/java/no/nordicsemi/android/toolbox/scanner/ScannerDestination.kt b/lib_scanner/src/main/java/no/nordicsemi/android/toolbox/scanner/ScannerDestination.kt index 1f923c835..4efa386d4 100644 --- a/lib_scanner/src/main/java/no/nordicsemi/android/toolbox/scanner/ScannerDestination.kt +++ b/lib_scanner/src/main/java/no/nordicsemi/android/toolbox/scanner/ScannerDestination.kt @@ -33,5 +33,5 @@ val ScannerDestination = defineDestination(ScannerDestinationId) { } class SelectedDevice(val device: ServerDevice, advertisedName: String?) { - val name: String = advertisedName ?: device.name ?: "Unknown" + val name: String? = advertisedName?.ifBlank { device.name } } \ No newline at end of file diff --git a/lib_ui/src/main/java/no/nordicsemi/android/ui/view/TopAppBar.kt b/lib_ui/src/main/java/no/nordicsemi/android/ui/view/TopAppBar.kt index 20e7e5f36..98ed54e0e 100644 --- a/lib_ui/src/main/java/no/nordicsemi/android/ui/view/TopAppBar.kt +++ b/lib_ui/src/main/java/no/nordicsemi/android/ui/view/TopAppBar.kt @@ -31,7 +31,6 @@ package no.nordicsemi.android.ui.view -import androidx.annotation.StringRes import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close import androidx.compose.material3.ExperimentalMaterial3Api @@ -49,21 +48,12 @@ import no.nordicsemi.android.ui.R @Composable fun CloseIconAppBar(text: String, onClick: () -> Unit) { NordicAppBar( - title = { Text(text, maxLines = 2) }, + title = { Text(text) }, backButtonIcon = Icons.Default.Close, onNavigationButtonClick = onClick, ) } -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun BackIconAppBar(text: String, onClick: () -> Unit) { - NordicAppBar( - title = { Text(text, maxLines = 2) }, - onNavigationButtonClick = onClick, - ) -} - @OptIn(ExperimentalMaterial3Api::class) @Composable fun LoggerIconAppBar( @@ -74,7 +64,7 @@ fun LoggerIconAppBar( onLoggerClick: () -> Unit ) { NordicAppBar( - title = { Text(text, maxLines = 2) }, + title = { Text(text) }, onNavigationButtonClick = onClick, actions = { TextButton( @@ -94,15 +84,10 @@ fun LoggerIconAppBar( fun ProfileAppBar( deviceName: String?, connectionState: GattConnectionStateWithStatus?, - @StringRes title: Int, navigateUp: () -> Unit, disconnect: () -> Unit, openLogger: () -> Unit ) { - if (deviceName?.isNotBlank() == true) { - val isConnected = connectionState?.state == GattConnectionState.STATE_CONNECTED - LoggerIconAppBar(deviceName, navigateUp, isConnected, disconnect, openLogger) - } else { - BackIconAppBar(stringResource(id = title), navigateUp) - } + val isConnected = connectionState?.state == GattConnectionState.STATE_CONNECTED + LoggerIconAppBar(deviceName ?: "No name", navigateUp, isConnected, disconnect, openLogger) } diff --git a/profile_bps/src/main/java/no/nordicsemi/android/bps/view/BPSScreen.kt b/profile_bps/src/main/java/no/nordicsemi/android/bps/view/BPSScreen.kt index 4090bd652..7779547b4 100644 --- a/profile_bps/src/main/java/no/nordicsemi/android/bps/view/BPSScreen.kt +++ b/profile_bps/src/main/java/no/nordicsemi/android/bps/view/BPSScreen.kt @@ -41,7 +41,6 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import no.nordicsemi.android.bps.R import no.nordicsemi.android.bps.viewmodel.BPSViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView @@ -61,7 +60,6 @@ fun BPSScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.result.connectionState, - title = R.string.bps_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_cgms/src/main/java/no/nordicsemi/android/cgms/view/CGMScreen.kt b/profile_cgms/src/main/java/no/nordicsemi/android/cgms/view/CGMScreen.kt index 23d2dd452..7492f0f84 100644 --- a/profile_cgms/src/main/java/no/nordicsemi/android/cgms/view/CGMScreen.kt +++ b/profile_cgms/src/main/java/no/nordicsemi/android/cgms/view/CGMScreen.kt @@ -35,14 +35,12 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import no.nordicsemi.android.cgms.R import no.nordicsemi.android.cgms.viewmodel.CGMViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView @@ -62,7 +60,6 @@ fun CGMScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.connectionState, - title = R.string.cgms_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_csc/src/main/java/no/nordicsemi/android/csc/view/CSCScreen.kt b/profile_csc/src/main/java/no/nordicsemi/android/csc/view/CSCScreen.kt index 6accb0f60..10e2e5cf7 100644 --- a/profile_csc/src/main/java/no/nordicsemi/android/csc/view/CSCScreen.kt +++ b/profile_csc/src/main/java/no/nordicsemi/android/csc/view/CSCScreen.kt @@ -35,14 +35,12 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import no.nordicsemi.android.csc.R import no.nordicsemi.android.csc.viewmodel.CSCViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView @@ -62,7 +60,6 @@ fun CSCScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.connectionState, - title = R.string.csc_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(OnDisconnectButtonClick) }, openLogger = { viewModel.onEvent(OpenLogger) } diff --git a/profile_gls/src/main/java/no/nordicsemi/android/gls/main/view/GLSScreen.kt b/profile_gls/src/main/java/no/nordicsemi/android/gls/main/view/GLSScreen.kt index f7df8e4b4..60669ce20 100644 --- a/profile_gls/src/main/java/no/nordicsemi/android/gls/main/view/GLSScreen.kt +++ b/profile_gls/src/main/java/no/nordicsemi/android/gls/main/view/GLSScreen.kt @@ -35,14 +35,12 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import no.nordicsemi.android.gls.R import no.nordicsemi.android.gls.main.viewmodel.GLSViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView @@ -62,7 +60,6 @@ fun GLSScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.glsServiceData.connectionState, - title = R.string.gls_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_hrs/src/main/java/no/nordicsemi/android/hrs/view/HRSScreen.kt b/profile_hrs/src/main/java/no/nordicsemi/android/hrs/view/HRSScreen.kt index 96dbea61c..78f15243f 100644 --- a/profile_hrs/src/main/java/no/nordicsemi/android/hrs/view/HRSScreen.kt +++ b/profile_hrs/src/main/java/no/nordicsemi/android/hrs/view/HRSScreen.kt @@ -41,7 +41,6 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import no.nordicsemi.android.hrs.R import no.nordicsemi.android.hrs.viewmodel.HRSViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView @@ -61,7 +60,6 @@ fun HRSScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.connectionState, - title = R.string.hrs_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_hts/src/main/java/no/nordicsemi/android/hts/view/HTSScreen.kt b/profile_hts/src/main/java/no/nordicsemi/android/hts/view/HTSScreen.kt index 4e6cf825f..a9cfe3830 100644 --- a/profile_hts/src/main/java/no/nordicsemi/android/hts/view/HTSScreen.kt +++ b/profile_hts/src/main/java/no/nordicsemi/android/hts/view/HTSScreen.kt @@ -41,7 +41,6 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import no.nordicsemi.android.hts.R import no.nordicsemi.android.hts.viewmodel.HTSViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView @@ -61,7 +60,6 @@ fun HTSScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.connectionState, - title = R.string.hts_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_prx/src/main/java/no/nordicsemi/android/prx/view/PRXScreen.kt b/profile_prx/src/main/java/no/nordicsemi/android/prx/view/PRXScreen.kt index 3f511756b..2b037c446 100644 --- a/profile_prx/src/main/java/no/nordicsemi/android/prx/view/PRXScreen.kt +++ b/profile_prx/src/main/java/no/nordicsemi/android/prx/view/PRXScreen.kt @@ -35,7 +35,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState @@ -45,7 +44,6 @@ import androidx.hilt.navigation.compose.hiltViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceDisconnectedView -import no.nordicsemi.android.prx.R import no.nordicsemi.android.prx.viewmodel.PRXViewModel import no.nordicsemi.android.ui.view.NavigateUpButton import no.nordicsemi.android.ui.view.ProfileAppBar @@ -62,7 +60,6 @@ fun PRXScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.connectionState, - title = R.string.prx_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_rscs/src/main/java/no/nordicsemi/android/rscs/view/RSCSScreen.kt b/profile_rscs/src/main/java/no/nordicsemi/android/rscs/view/RSCSScreen.kt index 486561c3f..a6e83e2a2 100644 --- a/profile_rscs/src/main/java/no/nordicsemi/android/rscs/view/RSCSScreen.kt +++ b/profile_rscs/src/main/java/no/nordicsemi/android/rscs/view/RSCSScreen.kt @@ -44,7 +44,6 @@ import androidx.hilt.navigation.compose.hiltViewModel import no.nordicsemi.android.kotlin.ble.core.data.GattConnectionState import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceConnectingView import no.nordicsemi.android.kotlin.ble.ui.scanner.view.DeviceDisconnectedView -import no.nordicsemi.android.rscs.R import no.nordicsemi.android.rscs.viewmodel.RSCSViewModel import no.nordicsemi.android.ui.view.NavigateUpButton import no.nordicsemi.android.ui.view.ProfileAppBar @@ -61,7 +60,6 @@ fun RSCSScreen() { ProfileAppBar( deviceName = state.deviceName, connectionState = state.connectionState, - title = R.string.rscs_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLoggerEvent) } diff --git a/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt b/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt index cdbefacb4..a56964fac 100644 --- a/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt +++ b/profile_uart/src/main/java/no/nordicsemi/android/uart/view/UARTScreen.kt @@ -67,7 +67,6 @@ fun UARTScreen() { ProfileAppBar( deviceName = state.uartManagerState.deviceName, connectionState = state.uartManagerState.connectionState, - title = R.string.uart_title, navigateUp = navigateUp, disconnect = { viewModel.onEvent(DisconnectEvent) }, openLogger = { viewModel.onEvent(OpenLogger) }