Global navigation was implemented
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
package com.helible.pilot
|
package com.helible.pilot
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instrumented test, which will execute on an Android device.
|
* Instrumented test, which will execute on an Android device.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,18 +3,34 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<!-- Request legacy Bluetooth permissions on older devices. -->
|
<!-- Request legacy Bluetooth permissions on older devices. -->
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
|
<uses-permission
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
|
android:name="android.permission.BLUETOOTH"
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
|
android:maxSdkVersion="30" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30"/>
|
<uses-permission
|
||||||
|
android:name="android.permission.BLUETOOTH_ADMIN"
|
||||||
|
android:maxSdkVersion="30" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.ACCESS_FINE_LOCATION"
|
||||||
|
android:maxSdkVersion="30" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.ACCESS_COARSE_LOCATION"
|
||||||
|
android:maxSdkVersion="30" />
|
||||||
|
|
||||||
<!-- Request Bluetooth permissions for API level 31+ -->
|
<!-- Request Bluetooth permissions for API level 31+ -->
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:minSdkVersion="31"
|
<uses-permission
|
||||||
android:usesPermissionFlags="neverForLocation" tools:targetApi="s" />
|
android:name="android.permission.BLUETOOTH_SCAN"
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" android:minSdkVersion="31"
|
android:minSdkVersion="31"
|
||||||
android:usesPermissionFlags="neverForLocation" tools:targetApi="s" />
|
android:usesPermissionFlags="neverForLocation"
|
||||||
|
tools:targetApi="s" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.BLUETOOTH_CONNECT"
|
||||||
|
android:minSdkVersion="31"
|
||||||
|
android:usesPermissionFlags="neverForLocation"
|
||||||
|
tools:targetApi="s" />
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
|
<uses-feature
|
||||||
|
android:name="android.hardware.bluetooth"
|
||||||
|
android:required="true" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import com.helible.pilot.components.scannerScreen.ScannerScreen
|
|
||||||
import com.helible.pilot.components.deviceScreen.DeviceControlScreen
|
import com.helible.pilot.components.deviceScreen.DeviceControlScreen
|
||||||
import com.helible.pilot.viewmodels.AppPreferences
|
|
||||||
import com.helible.pilot.viewmodels.SavedPreferencesImpl
|
|
||||||
import com.helible.pilot.components.deviceScreen.defaultDeviceActionsList
|
import com.helible.pilot.components.deviceScreen.defaultDeviceActionsList
|
||||||
|
import com.helible.pilot.components.scannerScreen.ScannerScreen
|
||||||
import com.helible.pilot.permissions.PermissionsLauncher
|
import com.helible.pilot.permissions.PermissionsLauncher
|
||||||
import com.helible.pilot.permissions.PermissionsRequest
|
import com.helible.pilot.permissions.PermissionsRequest
|
||||||
import com.helible.pilot.permissions.RequestHardwareFeatures
|
import com.helible.pilot.permissions.RequestHardwareFeatures
|
||||||
import com.helible.pilot.ui.theme.TestblueTheme
|
import com.helible.pilot.ui.theme.TestblueTheme
|
||||||
|
import com.helible.pilot.viewmodels.AppPreferences
|
||||||
import com.helible.pilot.viewmodels.BluetoothViewModel
|
import com.helible.pilot.viewmodels.BluetoothViewModel
|
||||||
import com.helible.pilot.viewmodels.BluetoothViewModelFactory
|
import com.helible.pilot.viewmodels.BluetoothViewModelFactory
|
||||||
import com.helible.pilot.viewmodels.PermissionDialogViewModel
|
import com.helible.pilot.viewmodels.PermissionDialogViewModel
|
||||||
import com.helible.pilot.viewmodels.PreferencesViewModel
|
import com.helible.pilot.viewmodels.PreferencesViewModel
|
||||||
|
import com.helible.pilot.viewmodels.SavedPreferencesImpl
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
@@ -144,29 +144,47 @@ class MainActivity : ComponentActivity() {
|
|||||||
)
|
)
|
||||||
if (preferencesViewModel.preferences != null) BackHandler {}
|
if (preferencesViewModel.preferences != null) BackHandler {}
|
||||||
}
|
}
|
||||||
composable("console")
|
composable("console/{title}")
|
||||||
{
|
{ backStackEntry ->
|
||||||
|
NotImplementedPage(
|
||||||
|
title = backStackEntry.arguments?.getString("title") ?: "null",
|
||||||
|
navigateBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
composable("codeblocks")
|
composable("codeblocks/{title}")
|
||||||
{
|
{ backStackEntry ->
|
||||||
|
NotImplementedPage(
|
||||||
|
title = backStackEntry.arguments?.getString("title") ?: "null",
|
||||||
|
navigateBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
composable("imu_calibration")
|
composable("imu_calibration/{title}")
|
||||||
{
|
{ backStackEntry ->
|
||||||
|
NotImplementedPage(
|
||||||
|
title = backStackEntry.arguments?.getString("title") ?: "null",
|
||||||
|
navigateBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
composable("motor_test")
|
composable("motor_test/{title}")
|
||||||
{
|
{ backStackEntry ->
|
||||||
|
NotImplementedPage(
|
||||||
|
title = backStackEntry.arguments?.getString("title") ?: "null",
|
||||||
|
navigateBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
composable("pid_settings")
|
composable("pid_settings/{title}")
|
||||||
{
|
{ backStackEntry ->
|
||||||
|
NotImplementedPage(
|
||||||
|
title = backStackEntry.arguments?.getString("title") ?: "null",
|
||||||
|
navigateBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
composable("reports")
|
composable("reports/{title}")
|
||||||
{
|
{ backStackEntry ->
|
||||||
|
NotImplementedPage(
|
||||||
|
title = backStackEntry.arguments?.getString("title") ?: "null",
|
||||||
|
navigateBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
app/src/main/java/com/helible/pilot/NotImplementedPage.kt
Normal file
21
app/src/main/java/com/helible/pilot/NotImplementedPage.kt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package com.helible.pilot
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.helible.pilot.components.BlankPage
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun NotImplementedPage(title: String, navigateBack: () -> Unit) {
|
||||||
|
BlankPage(title = title, navigateBack = navigateBack) {
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(10.dp)) {
|
||||||
|
Text(text = "Эта страница пока не готова и находится на стадии разработки")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/src/main/java/com/helible/pilot/components/BlankPage.kt
Normal file
59
app/src/main/java/com/helible/pilot/components/BlankPage.kt
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package com.helible.pilot.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BlankPage(title: String, navigateBack: () -> Unit, block: @Composable () -> Unit) {
|
||||||
|
Column(modifier = Modifier.fillMaxSize()) {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
IconButton(onClick = { navigateBack() }) {
|
||||||
|
Icon(
|
||||||
|
Icons.Default.ArrowBack,
|
||||||
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = title,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
fontWeight = FontWeight.ExtraBold,
|
||||||
|
modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun BlankPagePreview() {
|
||||||
|
Surface {
|
||||||
|
BlankPage(title = "Blank page", navigateBack = {}) {
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(5.dp)) {
|
||||||
|
Text(text = "This page in development")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,11 +6,11 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Divider
|
import androidx.compose.material3.Divider
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|||||||
@@ -5,15 +5,20 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.TextUnit
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Title(text: String, modifier: Modifier = Modifier) {
|
fun Title(
|
||||||
|
text: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
fontSize: TextUnit = 23.sp,
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
fontSize = 23.sp,
|
fontSize = fontSize,
|
||||||
fontWeight = FontWeight.ExtraBold
|
fontWeight = FontWeight.ExtraBold
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ import com.helible.pilot.viewmodels.AppPreferences
|
|||||||
fun DeviceBadge(
|
fun DeviceBadge(
|
||||||
bluetoothUiState: BluetoothUiState,
|
bluetoothUiState: BluetoothUiState,
|
||||||
tryToReconnect: () -> Unit,
|
tryToReconnect: () -> Unit,
|
||||||
getPreferences: () -> AppPreferences?
|
getPreferences: () -> AppPreferences?,
|
||||||
) {
|
) {
|
||||||
ElevatedCard(
|
ElevatedCard(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ fun DeviceConnectionStatus(bluetoothState: BluetoothUiState) {
|
|||||||
.padding(2.dp)
|
.padding(2.dp)
|
||||||
)
|
)
|
||||||
Text("На связи")
|
Text("На связи")
|
||||||
}
|
} else if (bluetoothState.errorMessage != null) {
|
||||||
else if (bluetoothState.errorMessage != null) {
|
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.drawable.cancel),
|
painter = painterResource(id = R.drawable.cancel),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
@@ -42,8 +41,7 @@ fun DeviceConnectionStatus(bluetoothState: BluetoothUiState) {
|
|||||||
.padding(2.dp)
|
.padding(2.dp)
|
||||||
)
|
)
|
||||||
Text("Ошибка: ${bluetoothState.errorMessage}")
|
Text("Ошибка: ${bluetoothState.errorMessage}")
|
||||||
}
|
} else if (bluetoothState.isConnecting) {
|
||||||
else if (bluetoothState.isConnecting) {
|
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.drawable.sync),
|
painter = painterResource(id = R.drawable.sync),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
|
|||||||
@@ -1,20 +1,9 @@
|
|||||||
package com.helible.pilot.components.deviceScreen
|
package com.helible.pilot.components.deviceScreen
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredSize
|
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.Refresh
|
|
||||||
import androidx.compose.material3.ElevatedCard
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -22,10 +11,8 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
@@ -90,13 +77,16 @@ fun DeviceControlScreen(
|
|||||||
|
|
||||||
Column(modifier = Modifier.padding(horizontal = 3.dp)) {
|
Column(modifier = Modifier.padding(horizontal = 3.dp)) {
|
||||||
for (section in deviceActionsList) {
|
for (section in deviceActionsList) {
|
||||||
Text(section.key,
|
Text(
|
||||||
|
section.key,
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
fontWeight = FontWeight.Light,
|
fontWeight = FontWeight.Light,
|
||||||
modifier = Modifier.padding(vertical = 15.dp, horizontal = 10.dp)
|
modifier = Modifier.padding(vertical = 15.dp, horizontal = 10.dp)
|
||||||
)
|
)
|
||||||
for (action in section.value) {
|
for (action in section.value) {
|
||||||
TextButton(onClick = { /* TODO */}) {
|
TextButton(
|
||||||
|
onClick = { navigateToPage(action.first + '/' + action.second.second) }
|
||||||
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = action.second.first.first),
|
painter = painterResource(id = action.second.first.first),
|
||||||
tint = action.second.first.second,
|
tint = action.second.first.second,
|
||||||
|
|||||||
@@ -44,8 +44,11 @@ fun DeviceItem(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Row(modifier = Modifier.padding(8.dp)) {
|
Row(modifier = Modifier.padding(8.dp)) {
|
||||||
Column(verticalArrangement = Arrangement.Center,
|
Column(
|
||||||
modifier = Modifier.fillMaxHeight().weight(1f, true)
|
verticalArrangement = Arrangement.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxHeight()
|
||||||
|
.weight(1f, true)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = deviceInfo.name,
|
text = deviceInfo.name,
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.helible.pilot.dataclasses.BluetoothUiState
|
|
||||||
import com.helible.pilot.dataclasses.BluetoothDevice
|
import com.helible.pilot.dataclasses.BluetoothDevice
|
||||||
|
import com.helible.pilot.dataclasses.BluetoothUiState
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DiscoveredDevicesList(
|
fun DiscoveredDevicesList(
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.constraintlayout.compose.ConstraintLayout
|
import androidx.constraintlayout.compose.ConstraintLayout
|
||||||
import androidx.constraintlayout.compose.Dimension
|
import androidx.constraintlayout.compose.Dimension
|
||||||
import com.helible.pilot.components.Title
|
import com.helible.pilot.components.Title
|
||||||
import com.helible.pilot.dataclasses.BluetoothUiState
|
|
||||||
import com.helible.pilot.dataclasses.BluetoothDevice
|
import com.helible.pilot.dataclasses.BluetoothDevice
|
||||||
|
import com.helible.pilot.dataclasses.BluetoothUiState
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import android.util.Log
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import com.helible.pilot.BluetoothDataTransferService
|
import com.helible.pilot.BluetoothDataTransferService
|
||||||
import com.helible.pilot.dataclasses.BluetoothDeviceDomain
|
|
||||||
import com.helible.pilot.KMessage
|
import com.helible.pilot.KMessage
|
||||||
|
import com.helible.pilot.dataclasses.BluetoothDeviceDomain
|
||||||
import com.helible.pilot.receivers.BluetoothAdapterStateReceiver
|
import com.helible.pilot.receivers.BluetoothAdapterStateReceiver
|
||||||
import com.helible.pilot.receivers.BluetoothStateReceiver
|
import com.helible.pilot.receivers.BluetoothStateReceiver
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package com.helible.pilot.receivers
|
package com.helible.pilot.receivers
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.bluetooth.BluetoothAdapter
|
import android.bluetooth.BluetoothAdapter
|
||||||
import android.bluetooth.BluetoothDevice
|
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.location.LocationManager
|
import android.location.LocationManager
|
||||||
import android.os.Build
|
|
||||||
|
|
||||||
class BluetoothAdapterStateReceiver(
|
class BluetoothAdapterStateReceiver(
|
||||||
private val onBluetoothEnabledChanged: (isBluetoothEnabled: Boolean) -> Unit,
|
private val onBluetoothEnabledChanged: (isBluetoothEnabled: Boolean) -> Unit,
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ package com.helible.pilot.viewmodels
|
|||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.helible.pilot.controllers.BluetoothController
|
||||||
|
import com.helible.pilot.controllers.ConnectionResult
|
||||||
import com.helible.pilot.dataclasses.AlarmStateMessage
|
import com.helible.pilot.dataclasses.AlarmStateMessage
|
||||||
|
import com.helible.pilot.dataclasses.BluetoothDevice
|
||||||
import com.helible.pilot.dataclasses.BluetoothUiState
|
import com.helible.pilot.dataclasses.BluetoothUiState
|
||||||
import com.helible.pilot.dataclasses.EmergStopMessage
|
import com.helible.pilot.dataclasses.EmergStopMessage
|
||||||
import com.helible.pilot.dataclasses.RotorsSpeedMessage
|
import com.helible.pilot.dataclasses.RotorsSpeedMessage
|
||||||
import com.helible.pilot.controllers.BluetoothController
|
|
||||||
import com.helible.pilot.controllers.ConnectionResult
|
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@@ -24,7 +25,6 @@ import kotlinx.coroutines.flow.onEach
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import com.helible.pilot.dataclasses.BluetoothDevice
|
|
||||||
|
|
||||||
class BluetoothViewModel(
|
class BluetoothViewModel(
|
||||||
private val bluetoothController: BluetoothController,
|
private val bluetoothController: BluetoothController,
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<vector android:height="24dp" android:tint="#000000"
|
<vector android:height="24dp"
|
||||||
android:viewportHeight="24" android:viewportWidth="24"
|
android:tint="#000000"
|
||||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:viewportHeight="24"
|
||||||
<path android:fillColor="#FF000000" android:pathData="M17.6,11.48 L19.44,8.3a0.63,0.63 0,0 0,-1.09 -0.63l-1.88,3.24a11.43,11.43 0,0 0,-8.94 0L5.65,7.67a0.63,0.63 0,0 0,-1.09 0.63L6.4,11.48A10.81,10.81 0,0 0,1 20L23,20A10.81,10.81 0,0 0,17.6 11.48ZM7,17.25A1.25,1.25 0,1 1,8.25 16,1.25 1.25,0 0,1 7,17.25ZM17,17.25A1.25,1.25 0,1 1,18.25 16,1.25 1.25,0 0,1 17,17.25Z"/>
|
android:viewportWidth="24"
|
||||||
|
android:width="24dp"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M17.6,11.48 L19.44,8.3a0.63,0.63 0,0 0,-1.09 -0.63l-1.88,3.24a11.43,11.43 0,0 0,-8.94 0L5.65,7.67a0.63,0.63 0,0 0,-1.09 0.63L6.4,11.48A10.81,10.81 0,0 0,1 20L23,20A10.81,10.81 0,0 0,17.6 11.48ZM7,17.25A1.25,1.25 0,1 1,8.25 16,1.25 1.25,0 0,1 7,17.25ZM17,17.25A1.25,1.25 0,1 1,18.25 16,1.25 1.25,0 0,1 17,17.25Z" />
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="500" android:viewportHeight="500">
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="500"
|
||||||
|
android:viewportHeight="500">
|
||||||
<path
|
<path
|
||||||
android:fillColor="?android:colorPrimary"
|
android:fillColor="?android:colorPrimary"
|
||||||
android:pathData="M 15 340 L 80 340 Q 95 340 95 355 L 95 485 Q 95 500 80 500 L 15 500 Q 0 500 0 485 L 0 355 Q 0 340 15 340 Z" />
|
android:pathData="M 15 340 L 80 340 Q 95 340 95 355 L 95 485 Q 95 500 80 500 L 15 500 Q 0 500 0 485 L 0 355 Q 0 340 15 340 Z" />
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.helible.pilot
|
package com.helible.pilot
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user