Add pre-alpha text to spacebar

This commit is contained in:
Aleksandras Kostarevas 2024-04-11 00:54:27 -05:00
parent 9308bcbfb0
commit 81cc428e92
2 changed files with 8 additions and 4 deletions

View File

@ -42,4 +42,5 @@
<string name="disable_emoji">Disable emoji suggestions</string> <string name="disable_emoji">Disable emoji suggestions</string>
<string name="try_typing">Try typing here…</string> <string name="try_typing">Try typing here…</string>
<string name="externally_imported_model">Externally imported model</string> <string name="externally_imported_model">Externally imported model</string>
<string name="spacebar_default_text">Pre-Alpha</string>
</resources> </resources>

View File

@ -815,10 +815,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
super.onDrawKeyTopVisuals(key, canvas, paint, params); super.onDrawKeyTopVisuals(key, canvas, paint, params);
final int code = key.getCode(); final int code = key.getCode();
if (code == Constants.CODE_SPACE) { if (code == Constants.CODE_SPACE) {
// If input language are explicitly selected. drawLanguageOnSpacebar(key, canvas, paint);
if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
drawLanguageOnSpacebar(key, canvas, paint);
}
// Whether space key needs to show the "..." popup hint for special purposes // Whether space key needs to show the "..." popup hint for special purposes
if (key.isLongPressEnabled() && mHasMultipleEnabledIMEsOrSubtypes) { if (key.isLongPressEnabled() && mHasMultipleEnabledIMEsOrSubtypes) {
drawKeyPopupHint(key, canvas, paint, params); drawKeyPopupHint(key, canvas, paint, params);
@ -848,6 +845,12 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
// Layout language name on spacebar. // Layout language name on spacebar.
private String layoutLanguageOnSpacebar(final Paint paint, private String layoutLanguageOnSpacebar(final Paint paint,
final RichInputMethodSubtype subtype, final int width) { final RichInputMethodSubtype subtype, final int width) {
if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
final String text = getContext().getString(R.string.spacebar_default_text);
if(fitsTextIntoWidth(width, text, paint)) {
return text;
}
}
// Choose appropriate language name to fit into the width. // Choose appropriate language name to fit into the width.
if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarUtils.FORMAT_TYPE_FULL_LOCALE) { if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarUtils.FORMAT_TYPE_FULL_LOCALE) {
final String fullText = subtype.getFullDisplayName(); final String fullText = subtype.getFullDisplayName();