From 525f840ce8f118d7c582daa9527bfc1e2f7d4b9d Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 20 Jun 2023 11:24:24 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D1=91?= =?UTF-8?q?=D0=BD=20Gradle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- 2.45.2 From 86338e6e1fd4624c389d32a53e5dee1de9b109ec Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 20 Jun 2023 14:13:27 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=BE=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=B8=D0=BD=D1=83=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=D0=B5?= =?UTF-8?q?=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=D0=BE=D0=B5?= =?UTF-8?q?=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=B4=D0=BB=D1=8F=20UUID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/nm17/narodmon/MainActivity.kt | 29 ++++++++- .../ru/nm17/narodmon/ui/dialogs/UuidDialog.kt | 59 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 + 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/ru/nm17/narodmon/ui/dialogs/UuidDialog.kt 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 -- 2.45.2