1
0
Fork 0

fixed the special character order being unexpectedly reset sometimes

This commit is contained in:
sspanak 2025-05-30 10:51:41 +03:00 committed by Dimo Karaivanov
parent 1a03c55e0d
commit 3e4f3d5d53
3 changed files with 9 additions and 23 deletions

View file

@ -68,7 +68,7 @@ public abstract class TypingHandler extends KeyPadHandler {
return false;
}
settings.setDefaultCharOrder(mLanguage, true);
settings.setDefaultCharOrder(mLanguage, false);
resetKeyRepeat();
mInputMode = determineInputMode();
determineTextCase();

View file

@ -15,7 +15,7 @@ import io.github.sspanak.tt9.preferences.settings.SettingsStore;
abstract class AbstractPreferenceCharList extends TextInputPreference {
@NonNull protected String currentChars = "";
protected Language language;
private Runnable onRender;
private boolean isInitialized = false;
protected static SettingsStore settings;
@ -28,8 +28,9 @@ abstract class AbstractPreferenceCharList extends TextInputPreference {
@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
if (holder.itemView.findViewById(R.id.input_text_input_field) != null && onRender != null) {
onRender.run();
if (!isInitialized && holder.itemView.findViewById(R.id.input_text_input_field) != null) {
isInitialized = true;
onLanguageChange(language);
}
}
@ -56,6 +57,9 @@ abstract class AbstractPreferenceCharList extends TextInputPreference {
void onLanguageChange(Language language) {
this.language = language;
if (!isInitialized) {
return;
}
String all = getChars();
char[] mandatory = getMandatoryChars();
@ -83,11 +87,6 @@ abstract class AbstractPreferenceCharList extends TextInputPreference {
}
void setOnRender(Runnable onRender) {
this.onRender = onRender;
}
protected String validateForbiddenChars() {
StringBuilder forbiddenCharList = new StringBuilder();

View file

@ -54,7 +54,7 @@ public class PunctuationScreen extends BaseScreenFragment {
initLanguageList();
initResetDefaults();
initSaveButton();
loadCharLists();
onLanguageChanged(languageList.getValue());
resetFontSize(false);
}
@ -115,17 +115,4 @@ public class PunctuationScreen extends BaseScreenFragment {
}
}
}
private void loadCharLists() {
for (AbstractPreferenceCharList list : charLists) {
if (list == null) {
continue;
}
list.setOnRender(() -> {
list.setOnRender(null);
onLanguageChanged(languageList.getValue());
});
}
}
}