From e342ff24b578b25c05b66366b3dda0cb9e40bf0f Mon Sep 17 00:00:00 2001 From: Helium314 Date: Sun, 2 Mar 2025 11:39:33 +0100 Subject: [PATCH] fix user-defined theme being added to list on first startup --- .../main/java/helium314/keyboard/latin/App.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/latin/App.kt b/app/src/main/java/helium314/keyboard/latin/App.kt index 0fd190f29..c68536942 100644 --- a/app/src/main/java/helium314/keyboard/latin/App.kt +++ b/app/src/main/java/helium314/keyboard/latin/App.kt @@ -201,9 +201,11 @@ fun checkVersionUpgrade(context: Context) { if (colorsDay.any { it.color != null }) { KeyboardTheme.writeUserColors(prefs, themeNameDay, colorsDay) } - val moreColorsDay = prefs.getInt("theme_color_show_more_colors", 0) - prefs.edit().remove("theme_color_show_more_colors").apply() - KeyboardTheme.writeUserMoreColors(prefs, themeNameDay, moreColorsDay) + if (prefs.contains("theme_color_show_more_colors")) { + val moreColorsDay = prefs.getInt("theme_color_show_more_colors", 0) + prefs.edit().remove("theme_color_show_more_colors").apply() + KeyboardTheme.writeUserMoreColors(prefs, themeNameDay, moreColorsDay) + } if (prefs.contains("theme_color_all_colors")) { val allColorsDay = readAllColorsMap(false) prefs.edit().remove("theme_color_all_colors").apply() @@ -224,9 +226,11 @@ fun checkVersionUpgrade(context: Context) { if (colorsNight.any { it.color!= null }) { KeyboardTheme.writeUserColors(prefs, themeNameNight, colorsNight) } - val moreColorsNight = prefs.getInt("theme_dark_color_show_more_colors", 0) - prefs.edit().remove("theme_dark_color_show_more_colors").apply() - KeyboardTheme.writeUserMoreColors(prefs, themeNameNight, moreColorsNight) + if (prefs.contains("theme_dark_color_show_more_colors")) { + val moreColorsNight = prefs.getInt("theme_dark_color_show_more_colors", 0) + prefs.edit().remove("theme_dark_color_show_more_colors").apply() + KeyboardTheme.writeUserMoreColors(prefs, themeNameNight, moreColorsNight) + } if (prefs.contains("theme_dark_color_all_colors")) { val allColorsNight = readAllColorsMap(false) prefs.edit().remove("theme_dark_color_all_colors").apply()