mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-22 16:14:23 +01:00
Add CGMS module
This commit is contained in:
@@ -6,6 +6,8 @@ import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -26,10 +28,12 @@ import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navArgument
|
||||
import no.nordicsemi.android.bps.view.BPSScreen
|
||||
import no.nordicsemi.android.cgms.view.CGMScreen
|
||||
import no.nordicsemi.android.csc.view.CSCScreen
|
||||
import no.nordicsemi.android.gls.view.GLSScreen
|
||||
import no.nordicsemi.android.hrs.view.HRSScreen
|
||||
import no.nordicsemi.android.hts.view.HTSScreen
|
||||
import no.nordicsemi.android.permission.bonding.view.BondingScreen
|
||||
import no.nordicsemi.android.permission.view.BluetoothNotAvailableScreen
|
||||
import no.nordicsemi.android.permission.view.BluetoothNotEnabledScreen
|
||||
import no.nordicsemi.android.permission.view.RequestPermissionScreen
|
||||
@@ -59,6 +63,7 @@ internal fun HomeScreen() {
|
||||
composable(NavDestination.BPS.id) { BPSScreen { viewModel.navigateUp() } }
|
||||
composable(NavDestination.PRX.id) { PRXScreen { viewModel.navigateUp() } }
|
||||
composable(NavDestination.RSCS.id) { RSCSScreen { viewModel.navigateUp() } }
|
||||
composable(NavDestination.CGMS.id) { CGMScreen { viewModel.navigateUp() } }
|
||||
composable(NavDestination.REQUEST_PERMISSION.id) { RequestPermissionScreen(continueAction) }
|
||||
composable(NavDestination.BLUETOOTH_NOT_AVAILABLE.id) { BluetoothNotAvailableScreen{ viewModel.finish() } }
|
||||
composable(NavDestination.BLUETOOTH_NOT_ENABLED.id) {
|
||||
@@ -75,6 +80,7 @@ internal fun HomeScreen() {
|
||||
}.exhaustive
|
||||
}
|
||||
}
|
||||
composable(NavDestination.BONDING.id) { BondingScreen(continueAction) }
|
||||
}
|
||||
|
||||
LaunchedEffect(state) {
|
||||
@@ -90,19 +96,23 @@ fun HomeView(callback: (NavDestination) -> Unit) {
|
||||
(context as? Activity)?.finish()
|
||||
}
|
||||
|
||||
FeatureButton(R.drawable.ic_csc, R.string.csc_module) { callback(NavDestination.CSC) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_hrs, R.string.hrs_module) { callback(NavDestination.HRS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_gls, R.string.gls_module) { callback(NavDestination.GLS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_hts, R.string.hts_module) { callback(NavDestination.HTS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_bps, R.string.bps_module) { callback(NavDestination.BPS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_rscs, R.string.rscs_module) { callback(NavDestination.RSCS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_proximity, R.string.prx_module) { callback(NavDestination.PRX) }
|
||||
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
|
||||
FeatureButton(R.drawable.ic_csc, R.string.csc_module) { callback(NavDestination.CSC) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_hrs, R.string.hrs_module) { callback(NavDestination.HRS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_gls, R.string.gls_module) { callback(NavDestination.GLS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_hts, R.string.hts_module) { callback(NavDestination.HTS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_bps, R.string.bps_module) { callback(NavDestination.BPS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_rscs, R.string.rscs_module) { callback(NavDestination.RSCS) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_prx, R.string.prx_module) { callback(NavDestination.PRX) }
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
FeatureButton(R.drawable.ic_cgm, R.string.cgm_module) { callback(NavDestination.CGMS) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,17 +2,19 @@ package no.nordicsemi.android.nrftoolbox
|
||||
|
||||
const val ARGS_KEY = "args"
|
||||
|
||||
enum class NavDestination(val id: String) {
|
||||
HOME("home-screen"),
|
||||
CSC("csc-screen"),
|
||||
HRS("hrs-screen"),
|
||||
HTS("hts-screen"),
|
||||
GLS("gls-screen"),
|
||||
BPS("bps-screen"),
|
||||
PRX("prx-screen"),
|
||||
RSCS("rscs-screen"),
|
||||
REQUEST_PERMISSION("request-permission"),
|
||||
BLUETOOTH_NOT_AVAILABLE("bluetooth-not-available"),
|
||||
BLUETOOTH_NOT_ENABLED("bluetooth-not-enabled"),
|
||||
DEVICE_NOT_CONNECTED("device-not-connected/{$ARGS_KEY}");
|
||||
enum class NavDestination(val id: String, val pairingRequired: Boolean) {
|
||||
HOME("home-screen", false),
|
||||
CSC("csc-screen", false),
|
||||
HRS("hrs-screen", false),
|
||||
HTS("hts-screen", false),
|
||||
GLS("gls-screen", true),
|
||||
BPS("bps-screen", false),
|
||||
PRX("prx-screen", true),
|
||||
RSCS("rscs-screen", false),
|
||||
CGMS("cgms-screen", false),
|
||||
REQUEST_PERMISSION("request-permission", false),
|
||||
BLUETOOTH_NOT_AVAILABLE("bluetooth-not-available", false),
|
||||
BLUETOOTH_NOT_ENABLED("bluetooth-not-enabled", false),
|
||||
DEVICE_NOT_CONNECTED("device-not-connected/{$ARGS_KEY}", false),
|
||||
BONDING("bonding", false);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import no.nordicsemi.android.bps.repository.BPS_SERVICE_UUID
|
||||
import no.nordicsemi.android.cgms.repository.CGMS_UUID
|
||||
import no.nordicsemi.android.csc.service.CYCLING_SPEED_AND_CADENCE_SERVICE_UUID
|
||||
import no.nordicsemi.android.gls.repository.GLS_SERVICE_UUID
|
||||
import no.nordicsemi.android.hrs.service.HR_SERVICE_UUID
|
||||
@@ -49,7 +50,13 @@ class NavigationViewModel @Inject constructor(
|
||||
} else when (bleScanner.getBluetoothStatus()) {
|
||||
ScannerStatus.NOT_AVAILABLE -> BluetoothPermissionState.BLUETOOTH_NOT_AVAILABLE
|
||||
ScannerStatus.DISABLED -> BluetoothPermissionState.BLUETOOTH_NOT_ENABLED
|
||||
ScannerStatus.ENABLED -> selectedDevice.device?.let { BluetoothPermissionState.READY } ?: BluetoothPermissionState.DEVICE_NOT_CONNECTED
|
||||
ScannerStatus.ENABLED -> selectedDevice.device?.let {
|
||||
if (targetDestination.pairingRequired && selectedDevice.isBondingRequired()) {
|
||||
BluetoothPermissionState.BONDING_REQUIRED
|
||||
} else {
|
||||
BluetoothPermissionState.READY
|
||||
}
|
||||
} ?: BluetoothPermissionState.DEVICE_NOT_CONNECTED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +66,7 @@ class NavigationViewModel @Inject constructor(
|
||||
BluetoothPermissionState.BLUETOOTH_NOT_AVAILABLE -> NavDestination.BLUETOOTH_NOT_AVAILABLE
|
||||
BluetoothPermissionState.BLUETOOTH_NOT_ENABLED -> NavDestination.BLUETOOTH_NOT_ENABLED
|
||||
BluetoothPermissionState.DEVICE_NOT_CONNECTED -> NavDestination.DEVICE_NOT_CONNECTED
|
||||
BluetoothPermissionState.BONDING_REQUIRED -> NavDestination.BONDING
|
||||
BluetoothPermissionState.READY -> targetDestination
|
||||
}
|
||||
|
||||
@@ -79,10 +87,12 @@ class NavigationViewModel @Inject constructor(
|
||||
NavDestination.BPS -> BPS_SERVICE_UUID.toString()
|
||||
NavDestination.RSCS -> RSCS_SERVICE_UUID.toString()
|
||||
NavDestination.PRX -> IMMEDIATE_ALERT_SERVICE_UUID.toString()
|
||||
NavDestination.CGMS -> CGMS_UUID.toString()
|
||||
NavDestination.HOME,
|
||||
NavDestination.REQUEST_PERMISSION,
|
||||
NavDestination.BLUETOOTH_NOT_AVAILABLE,
|
||||
NavDestination.BLUETOOTH_NOT_ENABLED,
|
||||
NavDestination.BONDING,
|
||||
NavDestination.DEVICE_NOT_CONNECTED -> throw IllegalArgumentException("There is no serivce related to the destination: $destination")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user