mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-10 00:27:45 +00:00
fix theme not appearing after importing from file
This commit is contained in:
parent
761b56fdc3
commit
6212f44283
1 changed files with 7 additions and 3 deletions
|
@ -26,6 +26,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -53,6 +54,7 @@ import helium314.keyboard.settings.SettingsDestination
|
||||||
import helium314.keyboard.settings.filePicker
|
import helium314.keyboard.settings.filePicker
|
||||||
import helium314.keyboard.settings.keyboardNeedsReload
|
import helium314.keyboard.settings.keyboardNeedsReload
|
||||||
import helium314.keyboard.settings.screens.SaveThoseColors
|
import helium314.keyboard.settings.screens.SaveThoseColors
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.util.EnumMap
|
import java.util.EnumMap
|
||||||
|
@ -118,16 +120,18 @@ fun ColorThemePickerDialog(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
var errorDialog by remember { mutableStateOf(false) }
|
var errorDialog by remember { mutableStateOf(false) }
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
val loadFilePicker = filePicker { uri ->
|
val loadFilePicker = filePicker { uri ->
|
||||||
ctx.getActivity()?.contentResolver?.openInputStream(uri)?.use {
|
ctx.getActivity()?.contentResolver?.openInputStream(uri)?.use {
|
||||||
errorDialog = !loadColorString(it.reader().readText(), prefs)
|
val text = it.reader().readText()
|
||||||
if (!errorDialog)
|
// theme not added when done without coroutine (maybe prefs listener is not yet registered?)
|
||||||
onDismissRequest() // todo: for some reason the list doesn't update after importing a file, only from clipboard
|
scope.launch { errorDialog = !loadColorString(text, prefs) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (showLoadDialog) {
|
if (showLoadDialog) {
|
||||||
ConfirmationDialog(
|
ConfirmationDialog(
|
||||||
onDismissRequest = { showLoadDialog = false },
|
onDismissRequest = { showLoadDialog = false },
|
||||||
|
title = { Text(stringResource(R.string.load)) },
|
||||||
onConfirmed = {
|
onConfirmed = {
|
||||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue