mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-22 23:29:10 +00:00
rename prefs for more keys to popup keys
more internal renaming will follow (later)
This commit is contained in:
parent
0c868ab22a
commit
09803fdf92
12 changed files with 41 additions and 29 deletions
|
@ -233,9 +233,9 @@ fun addLocaleKeyTextsToParams(context: Context, params: KeyboardParams, moreKeys
|
|||
private fun createLocaleKeyTexts(context: Context, params: KeyboardParams, moreKeysSetting: Int): LocaleKeyTexts {
|
||||
val lkt = LocaleKeyTexts(getStreamForLocale(params.mId.locale, context), params.mId.locale)
|
||||
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)
|
||||
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 ->
|
||||
if (locale == params.mId.locale) return@forEach
|
||||
lkt.addFile(getStreamForLocale(locale, context))
|
||||
|
@ -245,7 +245,7 @@ private fun createLocaleKeyTexts(context: Context, params: KeyboardParams, moreK
|
|||
|
||||
private fun getStreamForLocale(locale: Locale, context: Context) =
|
||||
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")
|
||||
} catch (_: Exception) {
|
||||
try {
|
||||
|
|
|
@ -110,6 +110,19 @@ private fun upgradesWhenComingFromOldAppName(context: Context) {
|
|||
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
|
||||
val additionalSubtypes = mutableListOf<String>()
|
||||
Settings.readPrefAdditionalSubtypes(prefs, context.resources).split(";").forEach {
|
||||
|
|
|
@ -44,7 +44,6 @@ import java.io.FileInputStream
|
|||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
import java.io.Writer
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
@ -442,7 +441,7 @@ class AdvancedSettingsFragment : SubScreenFragment() {
|
|||
override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String?) {
|
||||
when (key) {
|
||||
Settings.PREF_SHOW_SETUP_WIZARD_ICON -> SystemBroadcastReceiver.toggleAppIcon(requireContext())
|
||||
Settings.PREF_MORE_MORE_KEYS -> KeyboardLayoutSet.onSystemLocaleChanged()
|
||||
Settings.PREF_MORE_POPUP_KEYS -> KeyboardLayoutSet.onSystemLocaleChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -365,13 +365,13 @@ class LanguageSettingsDialog(
|
|||
|
||||
private fun setupPopupSettings() {
|
||||
binding.popupOrder.setOnClickListener {
|
||||
val moreKeyTypesDefault = prefs.getString(Settings.PREF_MORE_KEYS_ORDER, MORE_KEYS_ORDER_DEFAULT)!!
|
||||
reorderMoreKeysDialog(context, Settings.PREF_MORE_KEYS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.popup_order)
|
||||
val moreKeyTypesDefault = prefs.getString(Settings.PREF_POPUP_KEYS_ORDER, MORE_KEYS_ORDER_DEFAULT)!!
|
||||
reorderMoreKeysDialog(context, Settings.PREF_POPUP_KEYS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.popup_order)
|
||||
KeyboardLayoutSet.onKeyboardThemeChanged()
|
||||
}
|
||||
binding.popupLabelPriority.setOnClickListener {
|
||||
val moreKeyTypesDefault = prefs.getString(Settings.PREF_MORE_KEYS_LABELS_ORDER, MORE_KEYS_LABEL_DEFAULT)!!
|
||||
reorderMoreKeysDialog(context, Settings.PREF_MORE_KEYS_LABELS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.hint_source)
|
||||
val moreKeyTypesDefault = prefs.getString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, MORE_KEYS_LABEL_DEFAULT)!!
|
||||
reorderMoreKeysDialog(context, Settings.PREF_POPUP_KEYS_LABELS_ORDER + "_" + mainLocale.toLanguageTag(), moreKeyTypesDefault, R.string.hint_source)
|
||||
KeyboardLayoutSet.onKeyboardThemeChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,13 +56,13 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
|
|||
setupHistoryRetentionTimeSettings();
|
||||
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
|
||||
setLocalizedNumberRowVisibility();
|
||||
findPreference(Settings.PREF_MORE_KEYS_LABELS_ORDER).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false));
|
||||
findPreference(Settings.PREF_MORE_KEYS_ORDER).setOnPreferenceClickListener((pref) -> {
|
||||
MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_MORE_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT, R.string.popup_order);
|
||||
findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false));
|
||||
findPreference(Settings.PREF_POPUP_KEYS_ORDER).setOnPreferenceClickListener((pref) -> {
|
||||
MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_POPUP_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT, R.string.popup_order);
|
||||
return true;
|
||||
});
|
||||
findPreference(Settings.PREF_MORE_KEYS_LABELS_ORDER).setOnPreferenceClickListener((pref) -> {
|
||||
MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_MORE_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT, R.string.hint_source);
|
||||
findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setOnPreferenceClickListener((pref) -> {
|
||||
MoreKeysUtilsKt.reorderMoreKeysDialog(requireContext(), Settings.PREF_POPUP_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT, R.string.hint_source);
|
||||
return true;
|
||||
});
|
||||
findPreference(Settings.PREF_TOOLBAR_KEYS).setOnPreferenceClickListener((pref) -> {
|
||||
|
@ -81,12 +81,12 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
|
|||
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
|
||||
if (key == null) return;
|
||||
switch (key) {
|
||||
case Settings.PREF_MORE_KEYS_ORDER, Settings.PREF_SHOW_POPUP_HINTS, Settings.PREF_SHOW_NUMBER_ROW,
|
||||
Settings.PREF_MORE_KEYS_LABELS_ORDER, Settings.PREF_TOOLBAR_KEYS
|
||||
case Settings.PREF_POPUP_KEYS_ORDER, Settings.PREF_SHOW_POPUP_HINTS, Settings.PREF_SHOW_NUMBER_ROW,
|
||||
Settings.PREF_POPUP_KEYS_LABELS_ORDER, Settings.PREF_TOOLBAR_KEYS
|
||||
-> mReloadKeyboard = true;
|
||||
case Settings.PREF_LOCALIZED_NUMBER_ROW -> KeyboardLayoutSet.onSystemLocaleChanged();
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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_SHOW_HINTS = "show_hints";
|
||||
public static final String PREF_MORE_KEYS_ORDER = "more_keys_order";
|
||||
public static final String PREF_MORE_KEYS_LABELS_ORDER = "more_keys_labels_order";
|
||||
public static final String PREF_POPUP_KEYS_ORDER = "popup_keys_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_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_LANGUAGE_SLIDE = "space_language_slide";
|
||||
|
@ -503,7 +503,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
|
||||
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 "more" -> LocaleKeyTextsKt.MORE_KEYS_MORE;
|
||||
default -> LocaleKeyTextsKt.MORE_KEYS_NORMAL;
|
||||
|
|
|
@ -216,10 +216,10 @@ public class SettingsValues {
|
|||
mColors = Settings.getColorsForCurrentTheme(context, prefs);
|
||||
|
||||
// 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);
|
||||
mMoreKeyTypes = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_MORE_KEYS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyTypesDefault);
|
||||
final String moreKeyLabelDefault = prefs.getString(Settings.PREF_MORE_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT);
|
||||
mMoreKeyLabelSources = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_MORE_KEYS_LABELS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyLabelDefault);
|
||||
final String moreKeyTypesDefault = prefs.getString(Settings.PREF_POPUP_KEYS_ORDER, MoreKeysUtilsKt.MORE_KEYS_ORDER_DEFAULT);
|
||||
mMoreKeyTypes = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_POPUP_KEYS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyTypesDefault);
|
||||
final String moreKeyLabelDefault = prefs.getString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, MoreKeysUtilsKt.MORE_KEYS_LABEL_DEFAULT);
|
||||
mMoreKeyLabelSources = MoreKeysUtilsKt.getEnabledMoreKeys(prefs, Settings.PREF_POPUP_KEYS_LABELS_ORDER + "_" + selectedSubtype.getLocale(), moreKeyLabelDefault);
|
||||
|
||||
mAddToPersonalDictionary = prefs.getBoolean(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, false);
|
||||
mUseContactsDictionary = prefs.getBoolean(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY, false);
|
||||
|
|
|
@ -135,7 +135,7 @@ fun reorderMoreKeysDialog(context: Context, key: String, defaultSetting: String,
|
|||
p0.itemView.findViewById<TextView>(R.id.morekeys_type)?.text = displayText
|
||||
val switch = p0.itemView.findViewById<Switch>(R.id.morekeys_switch)
|
||||
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 ->
|
||||
val position = orderedItems.indexOfFirst { it.first == text }
|
||||
orderedItems[position] = text to isChecked
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
android:persistent="true" />
|
||||
|
||||
<ListPreference
|
||||
android:key="more_more_keys"
|
||||
android:key="more_popup_keys"
|
||||
android:title="@string/show_more_keys_title"
|
||||
android:entries="@array/show_more_keys_entries"
|
||||
android:entryValues="@array/show_more_keys_values"
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
android:persistent="true" />
|
||||
|
||||
<Preference
|
||||
android:key="more_keys_labels_order"
|
||||
android:key="popup_keys_labels_order"
|
||||
android:title="@string/hint_source" />
|
||||
|
||||
<Preference
|
||||
android:key="more_keys_order"
|
||||
android:key="popup_keys_order"
|
||||
android:title="@string/popup_order" />
|
||||
|
||||
<SwitchPreference
|
||||
|
|
Loading…
Add table
Reference in a new issue