diff --git a/app/src/main/java/ru/nm17/narodmon/MainActivity.kt b/app/src/main/java/ru/nm17/narodmon/MainActivity.kt
index 72011a6..a40a85b 100644
--- a/app/src/main/java/ru/nm17/narodmon/MainActivity.kt
+++ b/app/src/main/java/ru/nm17/narodmon/MainActivity.kt
@@ -5,6 +5,7 @@
package ru.nm17.narodmon
+import android.content.pm.ApplicationInfo
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
@@ -47,6 +48,7 @@ import kotlinx.coroutines.launch
import ru.nm17.narodmon.db.AppDatabase
import ru.nm17.narodmon.db.entities.KVSetting
import ru.nm17.narodmon.ui.dialogs.AgreementDialog
+import ru.nm17.narodmon.ui.dialogs.UuidDialog
import ru.nm17.narodmon.ui.sensorsScreen.SensorsScreen
import ru.nm17.narodmon.ui.theme.NarodMonTheme
@@ -123,6 +125,10 @@ class MainActivity : ComponentActivity() {
NarodMonTheme {
var agreed by remember { mutableStateOf(true) }
+ var uuid: String? by remember { mutableStateOf(null) }
+ val debug = remember {
+ 0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE
+ }
LaunchedEffect(key1 = Unit, block = {
coScope.launch(Dispatchers.IO) {
@@ -132,7 +138,7 @@ class MainActivity : ComponentActivity() {
}
})
- if (!agreed) {
+ if (!agreed && !debug) {
Scaffold {
AgreementDialog {
coScope.launch(Dispatchers.IO) {
@@ -151,9 +157,26 @@ class MainActivity : ComponentActivity() {
Text(text = stringResource(R.string.waiting_for_user_agreement))
}
}
- } else {
+ }
+ else if (debug && uuid == null) {
+ Scaffold {
+ UuidDialog { uuidNew ->
+ uuid = uuidNew
+ }
+ Column(
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center,
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(it)
+ ) {
+ CircularProgressIndicator()
+ Text(text = "")
+ }
+ }
+ }
+ else {
AppNavHost()
-
}
// A surface container using the 'background' color from the theme
diff --git a/app/src/main/java/ru/nm17/narodmon/ui/dialogs/UuidDialog.kt b/app/src/main/java/ru/nm17/narodmon/ui/dialogs/UuidDialog.kt
new file mode 100644
index 0000000..05b83ae
--- /dev/null
+++ b/app/src/main/java/ru/nm17/narodmon/ui/dialogs/UuidDialog.kt
@@ -0,0 +1,59 @@
+package ru.nm17.narodmon.ui.dialogs
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.KeyboardArrowRight
+import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.Divider
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.material3.TextField
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import ru.nm17.narodmon.R
+import kotlin.system.exitProcess
+
+@ExperimentalMaterial3Api
+@Composable
+fun UuidDialog(modifier: Modifier = Modifier, onUuidInput: (uuid: String) -> Unit) {
+ var uuid by remember { mutableStateOf("") }
+
+ AlertDialog(
+ onDismissRequest = { },
+ title = { Text(text = stringResource(id = R.string.uuid_dialog_title)) },
+ text = {
+ TextField(
+ value = uuid,
+ onValueChange = { uuid = it },
+ placeholder = { Text(text = "UUID") }
+ )
+ },
+ confirmButton = {
+ TextButton(
+ onClick = { onUuidInput(uuid) }
+ ) {
+ Text(text = stringResource(id = R.string.uuid_confirm))
+ }
+ },
+ dismissButton = {
+ TextButton(
+ onClick = { onUuidInput("") }) {
+ Text(text = stringResource(id = R.string.uuid_generate))
+ }
+ },
+ modifier = modifier
+
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ac3adf6..6711c5a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -52,4 +52,7 @@
Применить
От дальних к ближним
Отменить
+ Введите UUID приложения
+ Сохранить
+ Сгенерировать
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index a1a48e8..4a66751 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,5 +1,5 @@
[versions]
-agp = "8.2.0-alpha07"
+agp = "8.2.0-alpha08"
kotlin = "1.8.10"
core-ktx = "1.9.0"
junit = "4.13.2"