Compare commits
2 commits
7e5673f96e
...
86338e6e1f
Author | SHA1 | Date | |
---|---|---|---|
86338e6e1f | |||
525f840ce8 |
4 changed files with 89 additions and 4 deletions
|
@ -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
|
||||
|
|
59
app/src/main/java/ru/nm17/narodmon/ui/dialogs/UuidDialog.kt
Normal file
59
app/src/main/java/ru/nm17/narodmon/ui/dialogs/UuidDialog.kt
Normal file
|
@ -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
|
||||
|
||||
)
|
||||
}
|
|
@ -52,4 +52,7 @@
|
|||
<string name="apply">Применить</string>
|
||||
<string name="sort_by_distance_desc">От дальних к ближним</string>
|
||||
<string name="cancel1">Отменить</string>
|
||||
<string name="uuid_dialog_title">Введите UUID приложения</string>
|
||||
<string name="uuid_confirm">Сохранить</string>
|
||||
<string name="uuid_generate">Сгенерировать</string>
|
||||
</resources>
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue