mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
remove some values from old settings
preparation for removal
This commit is contained in:
parent
7ec9e1a8cf
commit
f016c20ca8
13 changed files with 33 additions and 38 deletions
|
@ -17,10 +17,9 @@ import helium314.keyboard.latin.settings.Defaults
|
|||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.settings.SettingsSubtype
|
||||
import helium314.keyboard.latin.settings.SettingsSubtype.Companion.toSettingsSubtype
|
||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.settings.colorPrefsAndResIds
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.LayoutType
|
||||
import helium314.keyboard.latin.utils.LayoutType.Companion.folder
|
||||
import helium314.keyboard.latin.utils.LayoutUtilsCustom
|
||||
|
@ -37,6 +36,7 @@ import helium314.keyboard.latin.utils.prefs
|
|||
import helium314.keyboard.latin.utils.protectedPrefs
|
||||
import helium314.keyboard.latin.utils.upgradeToolbarPrefs
|
||||
import helium314.keyboard.latin.utils.writeCustomKeyCodes
|
||||
import helium314.keyboard.settings.screens.colorPrefsAndResIds
|
||||
import java.io.File
|
||||
import java.util.EnumMap
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.content.Context
|
|||
import helium314.keyboard.latin.common.FileUtils
|
||||
import helium314.keyboard.latin.common.LocaleUtils
|
||||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import java.io.File
|
||||
|
@ -31,7 +30,7 @@ fun createMainDictionary(context: Context, locale: Locale): DictionaryCollection
|
|||
val dictList = LinkedList<Dictionary>()
|
||||
// get cached dict files
|
||||
val (userDicts, extractedDicts) = DictionaryInfoUtils.getCachedDictsForLocale(locale, context)
|
||||
.partition { it.name.endsWith(USER_DICTIONARY_SUFFIX) }
|
||||
.partition { it.name.endsWith(DictionaryInfoUtils.USER_DICTIONARY_SUFFIX) }
|
||||
// add user dicts to list
|
||||
userDicts.forEach { checkAndAddDictionaryToListIfNotExisting(it, dictList, locale) }
|
||||
// add extracted dicts to list (after userDicts, to skip extracted dicts of same type)
|
||||
|
|
|
@ -46,6 +46,7 @@ import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
|||
import helium314.keyboard.latin.common.splitOnWhitespace
|
||||
import helium314.keyboard.latin.settings.SeekBarDialogPreference.ValueProxy
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.ExecutorUtils
|
||||
import helium314.keyboard.latin.utils.JniUtils
|
||||
import helium314.keyboard.latin.utils.ResourceUtils
|
||||
|
|
|
@ -438,22 +438,3 @@ class ColorsNightSettingsFragment : ColorsSettingsFragment() {
|
|||
// override val isNight = true
|
||||
// override val titleResId = R.string.select_user_colors_night
|
||||
}
|
||||
|
||||
val colorPrefsAndResIds = listOf(
|
||||
KeyboardTheme.COLOR_BACKGROUND to R.string.select_color_background,
|
||||
KeyboardTheme.COLOR_KEYS to R.string.select_color_key_background,
|
||||
KeyboardTheme.COLOR_FUNCTIONAL_KEYS to R.string.select_color_functional_key_background,
|
||||
KeyboardTheme.COLOR_SPACEBAR to R.string.select_color_spacebar_background,
|
||||
KeyboardTheme.COLOR_TEXT to R.string.select_color_key,
|
||||
KeyboardTheme.COLOR_HINT_TEXT to R.string.select_color_key_hint,
|
||||
KeyboardTheme.COLOR_SUGGESTION_TEXT to R.string.select_color_suggestion,
|
||||
KeyboardTheme.COLOR_SPACEBAR_TEXT to R.string.select_color_spacebar_text,
|
||||
KeyboardTheme.COLOR_ACCENT to R.string.select_color_accent,
|
||||
KeyboardTheme.COLOR_GESTURE to R.string.select_color_gesture,
|
||||
)
|
||||
|
||||
fun getColorPrefsToHideInitially(prefs: SharedPreferences): List<String> {
|
||||
return listOf(KeyboardTheme.COLOR_SUGGESTION_TEXT, KeyboardTheme.COLOR_SPACEBAR_TEXT, KeyboardTheme.COLOR_GESTURE) +
|
||||
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)) listOf(KeyboardTheme.COLOR_SPACEBAR_TEXT)
|
||||
else listOf(KeyboardTheme.COLOR_FUNCTIONAL_KEYS)
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
|||
import helium314.keyboard.latin.databinding.LanguageListItemBinding
|
||||
import helium314.keyboard.latin.databinding.LocaleSettingsDialogBinding
|
||||
import helium314.keyboard.latin.utils.*
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
|
|
@ -155,7 +155,7 @@ class LanguageSettingsFragment : Fragment(R.layout.language_settings) {
|
|||
val localesWithDictionary = DictionaryInfoUtils.getCachedDirectoryList(requireContext())?.mapNotNull { dir ->
|
||||
if (!dir.isDirectory)
|
||||
return@mapNotNull null
|
||||
if (dir.list()?.any { it.endsWith(USER_DICTIONARY_SUFFIX) } == true)
|
||||
if (dir.list()?.any { it.endsWith(DictionaryInfoUtils.USER_DICTIONARY_SUFFIX) } == true)
|
||||
dir.name.constructLocale()
|
||||
else null
|
||||
}
|
||||
|
@ -225,5 +225,3 @@ class SubtypeInfo(val displayName: String, val subtype: InputMethodSubtype, var
|
|||
|
||||
fun InputMethodSubtype.toSubtypeInfo(locale: Locale, context: Context, isEnabled: Boolean, hasDictionary: Boolean): SubtypeInfo =
|
||||
SubtypeInfo(LocaleUtils.getLocaleDisplayNameInSystemLocale(locale, context), this, isEnabled, hasDictionary)
|
||||
|
||||
const val USER_DICTIONARY_SUFFIX = "user.dict"
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Locale;
|
|||
public class DictionaryInfoUtils {
|
||||
private static final String TAG = DictionaryInfoUtils.class.getSimpleName();
|
||||
public static final String DEFAULT_MAIN_DICT = "main";
|
||||
public static final String USER_DICTIONARY_SUFFIX = "user.dict";
|
||||
public static final String MAIN_DICT_PREFIX = DEFAULT_MAIN_DICT + "_";
|
||||
// 6 digits - unicode is limited to 21 bits
|
||||
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
|
||||
|
|
|
@ -108,7 +108,7 @@ class NewDictionaryAdder(private val context: Context, private val onAdded: ((Bo
|
|||
private fun addDictAndAskToReplace(header: DictionaryHeader, mainLocale: Locale) {
|
||||
val dictionaryType = header.mIdString.substringBefore(":")
|
||||
val cacheDir = DictionaryInfoUtils.getAndCreateCacheDirectoryForLocale(mainLocale, context)
|
||||
val dictFile = File(cacheDir, dictionaryType + "_" + USER_DICTIONARY_SUFFIX)
|
||||
val dictFile = File(cacheDir, dictionaryType + "_" + DictionaryInfoUtils.USER_DICTIONARY_SUFFIX)
|
||||
|
||||
fun moveDict(replaced: Boolean) {
|
||||
if (!cachedDictionaryFile.renameTo(dictFile)) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import helium314.keyboard.latin.ReadOnlyBinaryDictionary
|
|||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||
import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
|
||||
import helium314.keyboard.latin.makedict.DictionaryHeader
|
||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
|
@ -52,7 +51,7 @@ fun NewDictionaryDialog(
|
|||
.filter { it.script() == dictLocale.script() || it.script() == mainLocale?.script() }
|
||||
.sortedWith(comparer)
|
||||
val cacheDir = DictionaryInfoUtils.getAndCreateCacheDirectoryForLocale(locale, ctx)
|
||||
val dictFile = File(cacheDir, header.mIdString.substringBefore(":") + "_" + USER_DICTIONARY_SUFFIX)
|
||||
val dictFile = File(cacheDir, header.mIdString.substringBefore(":") + "_" + DictionaryInfoUtils.USER_DICTIONARY_SUFFIX)
|
||||
val type = header.mIdString.substringBefore(":")
|
||||
val info = header.info(ctx.resources.configuration.locale())
|
||||
ThreeButtonAlertDialog(
|
||||
|
|
|
@ -25,8 +25,8 @@ import helium314.keyboard.latin.checkVersionUpgrade
|
|||
import helium314.keyboard.latin.common.FileUtils
|
||||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.ExecutorUtils
|
||||
import helium314.keyboard.latin.utils.LayoutUtilsCustom
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
|
@ -264,7 +264,7 @@ private fun readJsonLinesToSettings(list: List<String>, prefs: SharedPreferences
|
|||
// todo (later): remove this when new package name has been in use for long enough, this is only for migrating from old openboard name
|
||||
private fun upgradeFileNames(originalName: String): String {
|
||||
return when {
|
||||
originalName.endsWith(USER_DICTIONARY_SUFFIX) -> {
|
||||
originalName.endsWith(DictionaryInfoUtils.USER_DICTIONARY_SUFFIX) -> {
|
||||
// replace directory after switch to language tag
|
||||
val dirName = originalName.substringAfter(File.separator).substringBefore(File.separator)
|
||||
originalName.replace(dirName, dirName.constructLocale().toLanguageTag())
|
||||
|
|
|
@ -51,8 +51,6 @@ import helium314.keyboard.latin.common.default
|
|||
import helium314.keyboard.latin.common.encodeBase36
|
||||
import helium314.keyboard.latin.settings.Defaults
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.settings.colorPrefsAndResIds
|
||||
import helium314.keyboard.latin.settings.getColorPrefsToHideInitially
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
|
@ -237,6 +235,25 @@ private fun getColorString(prefs: SharedPreferences, themeName: String): String
|
|||
@Serializable
|
||||
data class SaveThoseColors(val name: String? = null, val moreColors: Int, val colors: Map<String, Pair<Int?, Boolean>>)
|
||||
|
||||
val colorPrefsAndResIds = listOf(
|
||||
KeyboardTheme.COLOR_BACKGROUND to R.string.select_color_background,
|
||||
KeyboardTheme.COLOR_KEYS to R.string.select_color_key_background,
|
||||
KeyboardTheme.COLOR_FUNCTIONAL_KEYS to R.string.select_color_functional_key_background,
|
||||
KeyboardTheme.COLOR_SPACEBAR to R.string.select_color_spacebar_background,
|
||||
KeyboardTheme.COLOR_TEXT to R.string.select_color_key,
|
||||
KeyboardTheme.COLOR_HINT_TEXT to R.string.select_color_key_hint,
|
||||
KeyboardTheme.COLOR_SUGGESTION_TEXT to R.string.select_color_suggestion,
|
||||
KeyboardTheme.COLOR_SPACEBAR_TEXT to R.string.select_color_spacebar_text,
|
||||
KeyboardTheme.COLOR_ACCENT to R.string.select_color_accent,
|
||||
KeyboardTheme.COLOR_GESTURE to R.string.select_color_gesture,
|
||||
)
|
||||
|
||||
private fun getColorPrefsToHideInitially(prefs: SharedPreferences): List<String> {
|
||||
return listOf(KeyboardTheme.COLOR_SUGGESTION_TEXT, KeyboardTheme.COLOR_SPACEBAR_TEXT, KeyboardTheme.COLOR_GESTURE) +
|
||||
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)) listOf(KeyboardTheme.COLOR_SPACEBAR_TEXT)
|
||||
else listOf(KeyboardTheme.COLOR_FUNCTIONAL_KEYS)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
|
|
|
@ -28,7 +28,6 @@ import helium314.keyboard.latin.common.LocaleUtils
|
|||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||
import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
|
||||
import helium314.keyboard.latin.common.splitOnWhitespace
|
||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
|
@ -79,7 +78,7 @@ fun DictionaryScreen(
|
|||
.fillMaxWidth()
|
||||
) {
|
||||
val (dicts, hasInternal) = getUserAndInternalDictionaries(ctx, locale)
|
||||
val types = dicts.mapTo(mutableListOf()) { it.name.substringBefore("_${USER_DICTIONARY_SUFFIX}") }
|
||||
val types = dicts.mapTo(mutableListOf()) { it.name.substringBefore("_${DictionaryInfoUtils.USER_DICTIONARY_SUFFIX}") }
|
||||
if (hasInternal && !types.contains(Dictionary.TYPE_MAIN))
|
||||
types.add(0, stringResource(R.string.internal_dictionary_summary))
|
||||
Text(locale.localizedDisplayName(ctx))
|
||||
|
@ -129,7 +128,7 @@ fun getUserAndInternalDictionaries(context: Context, locale: Locale): Pair<List<
|
|||
val userLocaleDir = File(DictionaryInfoUtils.getCacheDirectoryForLocale(locale, context))
|
||||
if (userLocaleDir.exists() && userLocaleDir.isDirectory) {
|
||||
userLocaleDir.listFiles()?.forEach {
|
||||
if (it.name.endsWith(USER_DICTIONARY_SUFFIX))
|
||||
if (it.name.endsWith(DictionaryInfoUtils.USER_DICTIONARY_SUFFIX))
|
||||
userDicts.add(it)
|
||||
else if (it.name.startsWith(DictionaryInfoUtils.MAIN_DICT_PREFIX))
|
||||
hasInternalDict = true
|
||||
|
|
|
@ -34,7 +34,6 @@ import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
|
|||
import helium314.keyboard.latin.common.splitOnWhitespace
|
||||
import helium314.keyboard.latin.settings.Defaults
|
||||
import helium314.keyboard.latin.settings.SettingsSubtype.Companion.toSettingsSubtype
|
||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.MissingDictionaryDialog
|
||||
|
@ -147,7 +146,7 @@ private fun getSortedSubtypes(context: Context): List<InputMethodSubtype> {
|
|||
val localesWithDictionary = DictionaryInfoUtils.getCachedDirectoryList(context)?.mapNotNull { dir ->
|
||||
if (!dir.isDirectory)
|
||||
return@mapNotNull null
|
||||
if (dir.list()?.any { it.endsWith(USER_DICTIONARY_SUFFIX) } == true)
|
||||
if (dir.list()?.any { it.endsWith(DictionaryInfoUtils.USER_DICTIONARY_SUFFIX) } == true)
|
||||
dir.name.constructLocale()
|
||||
else null
|
||||
}.orEmpty()
|
||||
|
|
Loading…
Add table
Reference in a new issue