1
0
Fork 0

fixed the virtual keypad labels not updating when auto-switching the language

This commit is contained in:
sspanak 2024-05-22 11:04:05 +03:00 committed by Dimo Karaivanov
parent 9a13272fdc
commit 7edbfb19be
5 changed files with 13 additions and 13 deletions

View file

@ -1,5 +1,8 @@
package io.github.sspanak.tt9.ime; package io.github.sspanak.tt9.ime;
import androidx.annotation.Nullable;
import io.github.sspanak.tt9.languages.Language;
import io.github.sspanak.tt9.preferences.settings.SettingsStore; import io.github.sspanak.tt9.preferences.settings.SettingsStore;
abstract public class MainViewOps extends HotkeyHandler { abstract public class MainViewOps extends HotkeyHandler {
@ -24,6 +27,11 @@ abstract public class MainViewOps extends HotkeyHandler {
return mInputMode.is123() && inputType.isPhoneNumber(); return mInputMode.is123() && inputType.isPhoneNumber();
} }
@Nullable
public Language getLanguage() {
return mLanguage;
}
public SettingsStore getSettings() { public SettingsStore getSettings() {
return settings; return settings;
} }

View file

@ -50,6 +50,6 @@ public class SoftBackspaceKey extends SoftKey {
return "Del"; return "Del";
} }
return LanguageKind.isRTL(getCurrentLanguage()) ? "" : ""; return LanguageKind.isRTL(tt9.getLanguage()) ? "" : "";
} }
} }

View file

@ -12,13 +12,10 @@ import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import io.github.sspanak.tt9.R; import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.ime.TraditionalT9; import io.github.sspanak.tt9.ime.TraditionalT9;
import io.github.sspanak.tt9.languages.Language;
import io.github.sspanak.tt9.languages.LanguageCollection;
import io.github.sspanak.tt9.preferences.settings.SettingsStore; import io.github.sspanak.tt9.preferences.settings.SettingsStore;
import io.github.sspanak.tt9.util.Logger; import io.github.sspanak.tt9.util.Logger;
@ -169,10 +166,6 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
return true; return true;
} }
@Nullable protected Language getCurrentLanguage() {
return LanguageCollection.getLanguage(tt9.getApplicationContext(), tt9.getSettings().getInputLanguage());
}
/** /**
* getTitle * getTitle
* Generates the name of the key, for example: "OK", "Backspace", "1", etc... * Generates the name of the key, for example: "OK", "Backspace", "1", etc...

View file

@ -59,10 +59,9 @@ public class SoftNumberKey extends SoftKey {
protected String getTitle() { protected String getTitle() {
int number = getNumber(getId()); int number = getNumber(getId());
Language language = getCurrentLanguage(); if (tt9 != null && !tt9.isInputModeNumeric() && LanguageKind.isArabic(tt9.getLanguage())) {
if (LanguageKind.isArabic(language) && tt9 != null && !tt9.isInputModeNumeric()) {
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_SIZE; complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_SIZE;
return language.getKeyNumber(number); return tt9.getLanguage().getKeyNumber(number);
} else { } else {
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE; complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE;
return String.valueOf(number); return String.valueOf(number);
@ -102,7 +101,7 @@ public class SoftNumberKey extends SoftKey {
} }
// 2-9 // 2-9
Language language = getCurrentLanguage(); Language language = tt9.getLanguage();
if (language == null) { if (language == null) {
Logger.d("SoftNumberKey.getLabel", "Cannot generate a label when the language is NULL."); Logger.d("SoftNumberKey.getLabel", "Cannot generate a label when the language is NULL.");
return ""; return "";

View file

@ -52,7 +52,7 @@ public class SoftPunctuationKey extends SoftKey {
} else { } else {
if (keyId == R.id.soft_key_punctuation_1) return "!"; if (keyId == R.id.soft_key_punctuation_1) return "!";
if (keyId == R.id.soft_key_punctuation_2) { if (keyId == R.id.soft_key_punctuation_2) {
return LanguageKind.isArabic(getCurrentLanguage()) ? "؟" : "?"; return LanguageKind.isArabic(tt9.getLanguage()) ? "؟" : "?";
} }
} }