diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java index 86520b5b..df1fe09f 100644 --- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java +++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java @@ -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; diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java index e20bc56c..fc527b61 100644 --- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java +++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java @@ -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(