mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
feat(app/scripting): warning dialog
This commit is contained in:
@ -144,7 +144,7 @@ class ScriptsSection : Section() {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ScriptSettings(script: ModuleInfo) {
|
fun ScriptSettings(script: ModuleInfo) {
|
||||||
val settingsInterface = remember {
|
val settingsInterface = remember {
|
||||||
val module = context.scriptManager.runtime.getModuleByName(script.name) ?: return@remember null
|
val module = context.scriptManager.runtime.getModuleByName(script.name) ?: return@remember null
|
||||||
(module.getBinding(InterfaceManager::class))?.buildInterface(EnumScriptInterface.SETTINGS)
|
(module.getBinding(InterfaceManager::class))?.buildInterface(EnumScriptInterface.SETTINGS)
|
||||||
}
|
}
|
||||||
@ -247,6 +247,46 @@ class ScriptsSection : Section() {
|
|||||||
modifier = Modifier.align(Alignment.TopCenter)
|
modifier = Modifier.align(Alignment.TopCenter)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scriptingWarning by remember {
|
||||||
|
mutableStateOf(context.sharedPreferences.run {
|
||||||
|
getBoolean("scripting_warning", true).also {
|
||||||
|
edit().putBoolean("scripting_warning", false).apply()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scriptingWarning) {
|
||||||
|
var timeout by remember {
|
||||||
|
mutableIntStateOf(10)
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
while (timeout > 0) {
|
||||||
|
delay(1000)
|
||||||
|
timeout--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog(onDismissRequest = {
|
||||||
|
if (timeout == 0) {
|
||||||
|
scriptingWarning = false
|
||||||
|
}
|
||||||
|
}, title = {
|
||||||
|
Text(text = context.translation["manager.dialogs.scripting_warning.title"])
|
||||||
|
}, text = {
|
||||||
|
Text(text = context.translation["manager.dialogs.scripting_warning.content"])
|
||||||
|
}, confirmButton = {
|
||||||
|
TextButton(
|
||||||
|
onClick = {
|
||||||
|
scriptingWarning = false
|
||||||
|
},
|
||||||
|
enabled = timeout == 0
|
||||||
|
) {
|
||||||
|
Text(text = "OK " + if (timeout > 0) "($timeout)" else "")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -63,6 +63,10 @@
|
|||||||
"fetch_error": "Failed to fetch data",
|
"fetch_error": "Failed to fetch data",
|
||||||
"category_groups": "Groups",
|
"category_groups": "Groups",
|
||||||
"category_friends": "Friends"
|
"category_friends": "Friends"
|
||||||
|
},
|
||||||
|
"scripting_warning": {
|
||||||
|
"title": "Warning",
|
||||||
|
"content": "SnapEnhance includes a scripting tool, allowing the execution of user-defined code on your device. Use extreme caution and only install modules from known, reliable sources. Unauthorized or unverified modules may pose security risks to your system."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user