rename prefs for more keys to popup keys

more internal renaming will follow (later)
This commit is contained in:
Helium314 2024-01-31 16:54:31 +01:00
parent 0c868ab22a
commit 09803fdf92
12 changed files with 41 additions and 29 deletions

View file

@ -233,9 +233,9 @@ fun addLocaleKeyTextsToParams(context: Context, params: KeyboardParams, moreKeys
private fun createLocaleKeyTexts(context: Context, params: KeyboardParams, moreKeysSetting: Int): LocaleKeyTexts { private fun createLocaleKeyTexts(context: Context, params: KeyboardParams, moreKeysSetting: Int): LocaleKeyTexts {
val lkt = LocaleKeyTexts(getStreamForLocale(params.mId.locale, context), params.mId.locale) val lkt = LocaleKeyTexts(getStreamForLocale(params.mId.locale, context), params.mId.locale)
if (moreKeysSetting == MORE_KEYS_MORE) if (moreKeysSetting == MORE_KEYS_MORE)
lkt.addFile(context.assets.open("$LANGUAGE_TEXTS_FOLDER/all_more_keys.txt")) lkt.addFile(context.assets.open("$LANGUAGE_TEXTS_FOLDER/all_popup_keys.txt"))
else if (moreKeysSetting == MORE_KEYS_ALL) else if (moreKeysSetting == MORE_KEYS_ALL)
lkt.addFile(context.assets.open("$LANGUAGE_TEXTS_FOLDER/more_more_keys.txt")) lkt.addFile(context.assets.open("$LANGUAGE_TEXTS_FOLDER/more_popup_keys.txt"))
params.mSecondaryLocales.forEach { locale -> params.mSecondaryLocales.forEach { locale ->
if (locale == params.mId.locale) return@forEach if (locale == params.mId.locale) return@forEach
lkt.addFile(getStreamForLocale(locale, context)) lkt.addFile(getStreamForLocale(locale, context))
@ -245,7 +245,7 @@ private fun createLocaleKeyTexts(context: Context, params: KeyboardParams, moreK
private fun getStreamForLocale(locale: Locale, context: Context) = private fun getStreamForLocale(locale: Locale, context: Context) =
try { try {
if (locale.toLanguageTag() == SubtypeLocaleUtils.NO_LANGUAGE) context.assets.open("$LANGUAGE_TEXTS_FOLDER/more_more_keys.txt") if (locale.toLanguageTag() == SubtypeLocaleUtils.NO_LANGUAGE) context.assets.open("$LANGUAGE_TEXTS_FOLDER/more_popup_keys.txt")
else context.assets.open("$LANGUAGE_TEXTS_FOLDER/${locale.toLanguageTag()}.txt") else context.assets.open("$LANGUAGE_TEXTS_FOLDER/${locale.toLanguageTag()}.txt")
} catch (_: Exception) { } catch (_: Exception) {
try { try {

View file

@ -110,6 +110,19 @@ private fun upgradesWhenComingFromOldAppName(context: Context) {
prefs.edit().remove(it.key).apply() prefs.edit().remove(it.key).apply()
} }
} }
// change more_keys to popup_keys
if (prefs.contains("more_keys_order")) {
prefs.edit().putString(Settings.PREF_POPUP_KEYS_ORDER, prefs.getString("more_keys_order", "")).apply()
prefs.edit().remove("more_keys_order").apply()
}
if (prefs.contains("more_keys_labels_order")) {
prefs.edit().putString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, prefs.getString("more_keys_labels_order", "")).apply()
prefs.edit().remove("more_keys_labels_order").apply()
}
if (prefs.contains("more_more_keys")) {
prefs.edit().putString(Settings.PREF_POPUP_KEYS_ORDER, prefs.getString("more_more_keys", "")).apply()
prefs.edit().remove("more_more_keys").apply()
}
// upgrade additional subtype locale strings // upgrade additional subtype locale strings
val additionalSubtypes = mutableListOf<String>() val additionalSubtypes = mutableListOf<String>()
Settings.readPrefAdditionalSubtypes(prefs, context.resources).split(";").forEach { Settings.readPrefAdditionalSubtypes(prefs, context.resources).split(";").forEach {

View file

@ -44,7 +44,6 @@ import java.io.FileInputStream
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
import java.io.OutputStream import java.io.OutputStream
import java.io.Writer
import java.util.zip.ZipEntry import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream import java.util.zip.ZipOutputStream
@ -442,7 +441,7 @@ class AdvancedSettingsFragment : SubScreenFragment() {
override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String?) { override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String?) {
when (key) { when (key) {
Settings.PREF_SHOW_SETUP_WIZARD_ICON -> SystemBroadcastReceiver.toggleAppIcon(requireContext()) Settings.PREF_SHOW_SETUP_WIZARD_ICON -> SystemBroadcastReceiver.toggleAppIcon(requireContext())
Settings.PREF_MORE_MORE_KEYS -> KeyboardLayoutSet.onSystemLocaleChanged() Settings.PREF_MORE_POPUP_KEYS -> KeyboardLayoutSet.onSystemLocaleChanged()
} }
} }

View file

@ -365,13 +365,13 @@ class LanguageSettingsDialog(
private fun setupPopupSettings() { private fun setupPopupSettings() {
binding.popupOrder.setOnClickListener { binding.popupOrder.setOnClickListener {
val moreKeyTypesDefault = prefs.getString(Settings.PREF_MORE_KEYS_ORDER, MORE_KEYS_ORDER_DEFAULT)!! val moreKeyTypesDefault = prefs.getString(Settings.PREF_POPUP_KEYS_ORDER, MORE_KEYS_ORDER_DEFAULT)!!
reorderMoreKeysDialog(context, Settings.PREF_MORE_KEYS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.popup_order) reorderMoreKeysDialog(context, Settings.PREF_POPUP_KEYS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.popup_order)
KeyboardLayoutSet.onKeyboardThemeChanged() KeyboardLayoutSet.onKeyboardThemeChanged()
} }
binding.popupLabelPriority.setOnClickListener { binding.popupLabelPriority.setOnClickListener {
val moreKeyTypesDefault = prefs.getString(Settings.PREF_MORE_KEYS_LABELS_ORDER, MORE_KEYS_LABEL_DEFAULT)!! val moreKeyTypesDefault = prefs.getString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, MORE_KEYS_LABEL_DEFAULT)!!
reorderMoreKeysDialog(context, Settings.PREF_MORE_KEYS_LABELS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.hint_source) reorderMoreKeysDialog(context, Settings.PREF_POPUP_KEYS_LABELS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.hint_source)
KeyboardLayoutSet.onKeyboardThemeChanged() KeyboardLayoutSet.onKeyboardThemeChanged()
} }
} }

View file

@ -56,13 +56,13 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
setupHistoryRetentionTimeSettings(); setupHistoryRetentionTimeSettings();
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings(); refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
setLocalizedNumberRowVisibility(); setLocalizedNumberRowVisibility();
findPreference(Settings.PREF_MORE_KEYS_LABELS_ORDER).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false)); findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false));
findPreference(Settings.PREF_MORE_KEYS_ORDER).setOnPreferenceClickListener((pref) -> { findPreference(Settings.PREF_POPUP_KEYS_ORDER).setOnPreferenceClickListener((pref) -> {
MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_MORE_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT, R.string.popup_order); MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_POPUP_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT, R.string.popup_order);
return true; return true;
}); });
findPreference(Settings.PREF_MORE_KEYS_LABELS_ORDER).setOnPreferenceClickListener((pref) -> { findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setOnPreferenceClickListener((pref) -> {
MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_MORE_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT, R.string.hint_source); MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_POPUP_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT, R.string.hint_source);
return true; return true;
}); });
findPreference(Settings.PREF_TOOLBAR_KEYS).setOnPreferenceClickListener((pref) -> { findPreference(Settings.PREF_TOOLBAR_KEYS).setOnPreferenceClickListener((pref) -> {
@ -81,12 +81,12 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings(); refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
if (key == null) return; if (key == null) return;
switch (key) { switch (key) {
case Settings.PREF_MORE_KEYS_ORDER, Settings.PREF_SHOW_POPUP_HINTS, Settings.PREF_SHOW_NUMBER_ROW, case Settings.PREF_POPUP_KEYS_ORDER, Settings.PREF_SHOW_POPUP_HINTS, Settings.PREF_SHOW_NUMBER_ROW,
Settings.PREF_MORE_KEYS_LABELS_ORDER, Settings.PREF_TOOLBAR_KEYS Settings.PREF_POPUP_KEYS_LABELS_ORDER, Settings.PREF_TOOLBAR_KEYS
-> mReloadKeyboard = true; -> mReloadKeyboard = true;
case Settings.PREF_LOCALIZED_NUMBER_ROW -> KeyboardLayoutSet.onSystemLocaleChanged(); case Settings.PREF_LOCALIZED_NUMBER_ROW -> KeyboardLayoutSet.onSystemLocaleChanged();
case Settings.PREF_SHOW_HINTS case Settings.PREF_SHOW_HINTS
-> findPreference(Settings.PREF_MORE_KEYS_LABELS_ORDER).setVisible(prefs.getBoolean(Settings.PREF_SHOW_HINTS, false)); -> findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(prefs.getBoolean(Settings.PREF_SHOW_HINTS, false));
} }
} }

View file

@ -122,10 +122,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_LOCALIZED_NUMBER_ROW = "localized_number_row"; public static final String PREF_LOCALIZED_NUMBER_ROW = "localized_number_row";
public static final String PREF_SHOW_HINTS = "show_hints"; public static final String PREF_SHOW_HINTS = "show_hints";
public static final String PREF_MORE_KEYS_ORDER = "more_keys_order"; public static final String PREF_POPUP_KEYS_ORDER = "popup_keys_order";
public static final String PREF_MORE_KEYS_LABELS_ORDER = "more_keys_labels_order"; public static final String PREF_POPUP_KEYS_LABELS_ORDER = "popup_keys_labels_order";
public static final String PREF_SHOW_POPUP_HINTS = "show_popup_hints"; public static final String PREF_SHOW_POPUP_HINTS = "show_popup_hints";
public static final String PREF_MORE_MORE_KEYS = "more_more_keys"; public static final String PREF_MORE_POPUP_KEYS = "more_popup_keys";
public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang"; public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang";
public static final String PREF_SPACE_LANGUAGE_SLIDE = "space_language_slide"; public static final String PREF_SPACE_LANGUAGE_SLIDE = "space_language_slide";
@ -503,7 +503,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
} }
public static int readMoreMoreKeysPref(final SharedPreferences prefs) { public static int readMoreMoreKeysPref(final SharedPreferences prefs) {
return switch (prefs.getString(Settings.PREF_MORE_MORE_KEYS, "normal")) { return switch (prefs.getString(Settings.PREF_MORE_POPUP_KEYS, "normal")) {
case "all" -> LocaleKeyTextsKt.MORE_KEYS_ALL; case "all" -> LocaleKeyTextsKt.MORE_KEYS_ALL;
case "more" -> LocaleKeyTextsKt.MORE_KEYS_MORE; case "more" -> LocaleKeyTextsKt.MORE_KEYS_MORE;
default -> LocaleKeyTextsKt.MORE_KEYS_NORMAL; default -> LocaleKeyTextsKt.MORE_KEYS_NORMAL;

View file

@ -216,10 +216,10 @@ public class SettingsValues {
mColors = Settings.getColorsForCurrentTheme(context, prefs); mColors = Settings.getColorsForCurrentTheme(context, prefs);
// read locale-specific popup key settings, fall back to global settings // read locale-specific popup key settings, fall back to global settings
final String moreKeyTypesDefault = prefs.getString(Settings.PREF_MORE_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT); final String moreKeyTypesDefault = prefs.getString(Settings.PREF_POPUP_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT);
mMoreKeyTypes = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_MORE_KEYS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyTypesDefault); mMoreKeyTypes = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_POPUP_KEYS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyTypesDefault);
final String moreKeyLabelDefault = prefs.getString(Settings.PREF_MORE_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT); final String moreKeyLabelDefault = prefs.getString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT);
mMoreKeyLabelSources = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_MORE_KEYS_LABELS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyLabelDefault); mMoreKeyLabelSources = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_POPUP_KEYS_LABELS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyLabelDefault);
mAddToPersonalDictionary = prefs.getBoolean(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, false); mAddToPersonalDictionary = prefs.getBoolean(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, false);
mUseContactsDictionary = prefs.getBoolean(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY, false); mUseContactsDictionary = prefs.getBoolean(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY, false);

View file

@ -135,7 +135,7 @@ fun reorderMoreKeysDialog(context: Context, key: String, defaultSetting: String,
p0.itemView.findViewById<TextView>(R.id.morekeys_type)?.text = displayText p0.itemView.findViewById<TextView>(R.id.morekeys_type)?.text = displayText
val switch = p0.itemView.findViewById<Switch>(R.id.morekeys_switch) val switch = p0.itemView.findViewById<Switch>(R.id.morekeys_switch)
switch?.isChecked = wasChecked switch?.isChecked = wasChecked
switch?.isEnabled = !(key.contains(Settings.PREF_MORE_KEYS_ORDER) && text == MORE_KEYS_LAYOUT) // layout can't be disabled switch?.isEnabled = !(key.contains(Settings.PREF_POPUP_KEYS_ORDER) && text == MORE_KEYS_LAYOUT) // layout can't be disabled
switch?.setOnCheckedChangeListener { _, isChecked -> switch?.setOnCheckedChangeListener { _, isChecked ->
val position = orderedItems.indexOfFirst { it.first == text } val position = orderedItems.indexOfFirst { it.first == text }
orderedItems[position] = text to isChecked orderedItems[position] = text to isChecked

View file

@ -57,7 +57,7 @@
android:persistent="true" /> android:persistent="true" />
<ListPreference <ListPreference
android:key="more_more_keys" android:key="more_popup_keys"
android:title="@string/show_more_keys_title" android:title="@string/show_more_keys_title"
android:entries="@array/show_more_keys_entries" android:entries="@array/show_more_keys_entries"
android:entryValues="@array/show_more_keys_values" android:entryValues="@array/show_more_keys_values"

View file

@ -18,11 +18,11 @@
android:persistent="true" /> android:persistent="true" />
<Preference <Preference
android:key="more_keys_labels_order" android:key="popup_keys_labels_order"
android:title="@string/hint_source" /> android:title="@string/hint_source" />
<Preference <Preference
android:key="more_keys_order" android:key="popup_keys_order"
android:title="@string/popup_order" /> android:title="@string/popup_order" />
<SwitchPreference <SwitchPreference