fix issues with restoring old settings

This commit is contained in:
Helium314 2025-02-16 20:32:32 +01:00
parent 0fa8f58750
commit 56c7748dff
3 changed files with 7 additions and 3 deletions

View file

@ -252,6 +252,7 @@ fun checkVersionUpgrade(context: Context) {
if (oldVersion <= 2303) { if (oldVersion <= 2303) {
File(DeviceProtectedUtils.getFilesDir(context), "layouts").listFiles()?.forEach { file -> File(DeviceProtectedUtils.getFilesDir(context), "layouts").listFiles()?.forEach { file ->
val folder = DeviceProtectedUtils.getFilesDir(context) val folder = DeviceProtectedUtils.getFilesDir(context)
if (file.isDirectory) return@forEach
when (file.name) { when (file.name) {
"custom.symbols." -> { "custom.symbols." -> {
val dir = File(folder, LayoutType.SYMBOLS.folder) val dir = File(folder, LayoutType.SYMBOLS.folder)

View file

@ -134,8 +134,11 @@ fun BackupRestorePreference(setting: Setting) {
ctx.getActivity()?.contentResolver?.openInputStream(uri)?.use { inputStream -> ctx.getActivity()?.contentResolver?.openInputStream(uri)?.use { inputStream ->
ZipInputStream(inputStream).use { zip -> ZipInputStream(inputStream).use { zip ->
var entry: ZipEntry? = zip.nextEntry var entry: ZipEntry? = zip.nextEntry
val filesDir = ctx.filesDir?.path ?: return@execute val filesDir = ctx.filesDir ?: return@execute
val deviceProtectedFilesDir = DeviceProtectedUtils.getFilesDir(ctx).path val deviceProtectedFilesDir = DeviceProtectedUtils.getFilesDir(ctx)
filesDir.deleteRecursively()
deviceProtectedFilesDir.deleteRecursively()
LayoutUtilsCustom.onLayoutFileChanged()
Settings.getInstance().stopListener() Settings.getInstance().stopListener()
while (entry != null) { while (entry != null) {
if (entry.name.startsWith("unprotected${File.separator}")) { if (entry.name.startsWith("unprotected${File.separator}")) {

View file

@ -25,7 +25,7 @@ import helium314.keyboard.settings.dialogs.LayoutPickerDialog
import helium314.keyboard.settings.preferences.Preference import helium314.keyboard.settings.preferences.Preference
@Composable @Composable
fun LayoutScreen( fun SecondaryLayoutScreen(
onClickBack: () -> Unit, onClickBack: () -> Unit,
) { ) {
// todo: enable main layouts // todo: enable main layouts