1
0
Fork 0

the LF4 virtual key no longer displays a globe icon when there is only 1 enabled language and it grays it out when in 123 mode

This commit is contained in:
sspanak 2024-09-23 15:25:29 +03:00 committed by Dimo Karaivanov
parent 83479e373a
commit ec2ad9937a
2 changed files with 32 additions and 5 deletions

View file

@ -7,6 +7,7 @@ import android.os.Handler;
import android.os.Looper;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.util.AttributeSet;
@ -37,6 +38,8 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
private static int lastPressedKey = -1;
private boolean ignoreLastPressedKey = false;
private boolean isTitleDisabled = false;
public SoftKey(Context context) {
super(context);
@ -275,10 +278,16 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
padding /= 10;
}
// title styles
sb.setSpan(new RelativeSizeSpan(getTitleRelativeSize()), 0, titleLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
if (!new Text(title).startsWithGraphic()) {
sb.setSpan(new StyleSpan(Typeface.ITALIC), 0, titleLength, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
}
if (isTitleDisabled) {
sb.setSpan(new ForegroundColorSpan(0x44000000), 0, titleLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
}
// subtitle styles
sb.setSpan(new RelativeSizeSpan(padding), titleLength, titleLength + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(new RelativeSizeSpan(getSubTitleRelativeSize()), titleLength + 1, sb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
@ -286,6 +295,11 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
}
protected void setTitleDisabled(boolean yes) {
isTitleDisabled = yes;
}
protected void vibrate(int vibrationType) {
if (tt9 != null) {
vibration = vibration == null ? new Vibration(tt9.getSettings(), this) : vibration;

View file

@ -14,6 +14,10 @@ public class SoftKeyLF4 extends SwipeableKey {
@Override protected float getTitleRelativeSize() { return super.getTitleRelativeSize() / 0.85f; }
@Override protected float getSubTitleRelativeSize() { return super.getSubTitleRelativeSize() / 0.85f; }
private boolean areThereManyLanguages() {
return tt9 != null && tt9.getSettings().getEnabledLanguageIds().size() > 1;
}
@Override
protected void handleHold() {
preventRepeat();
@ -41,13 +45,11 @@ public class SoftKeyLF4 extends SwipeableKey {
}
}
@Override
protected String getTitle() {
return tt9.isInputModeNumeric() ? "" : "🌐";
protected String getHoldIcon() {
return "🌐";
}
@Override
protected String getSubTitle() {
protected String getPressIcon() {
if (tt9 == null || tt9.getLanguage() == null) {
return getContext().getString(R.string.virtual_key_input_mode);
}
@ -63,8 +65,19 @@ public class SoftKeyLF4 extends SwipeableKey {
return "T9";
}
@Override
protected String getTitle() {
return areThereManyLanguages() ? getHoldIcon() : getPressIcon();
}
@Override
protected String getSubTitle() {
return areThereManyLanguages() ? getPressIcon() : null;
}
@Override
public void render() {
setTitleDisabled(tt9 != null && tt9.isInputModeNumeric() && areThereManyLanguages());
super.render();
setEnabled(