From 5f82a28ac63237d63c09d16dda431a9178ebea0e Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sun, 12 Apr 2026 23:32:19 +0200 Subject: [PATCH] Slight layout changes --- lib/I18n/translations/english.yaml | 3 +++ src/activities/util/KeyboardEntryActivity.cpp | 8 ++++---- src/activities/util/KeyboardEntryActivity.h | 2 +- src/components/themes/BaseTheme.cpp | 10 +++++++--- src/components/themes/lyra/LyraTheme.cpp | 10 +++++++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index 891beed4..7976dd4c 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -254,6 +254,9 @@ STR_YES: "Yes" STR_NO: "No" STR_SHOW: "Show" STR_HIDE: "Hide" +STR_SHIFT: "shift" +STR_SHIFT_CAPS: "SHIFT" +STR_ABC: "abc" STR_STATE_ON: "ON" STR_STATE_OFF: "OFF" STR_NOT_SET: "Not Set" diff --git a/src/activities/util/KeyboardEntryActivity.cpp b/src/activities/util/KeyboardEntryActivity.cpp index c9f53e3b..1d9249fd 100644 --- a/src/activities/util/KeyboardEntryActivity.cpp +++ b/src/activities/util/KeyboardEntryActivity.cpp @@ -8,8 +8,6 @@ #include "components/UITheme.h" #include "fontIds.h" -const char* const KeyboardEntryActivity::shiftString[2] = {"shift", "SHIFT"}; - void KeyboardEntryActivity::onEnter() { Activity::onEnter(); requestUpdate(); @@ -25,6 +23,8 @@ int KeyboardEntryActivity::getBottomKeyCount() const { return isPassword ? 6 : 5 bool KeyboardEntryActivity::isBottomRow(const int row) const { return row == getContentRowCount(); } +const char* KeyboardEntryActivity::getShiftLabel() const { return tr(shiftState > 0 ? STR_SHIFT_CAPS : STR_SHIFT); } + char KeyboardEntryActivity::getSelectedChar() const { const KeyDef(*layout)[COLS] = symMode ? symLayout : abcLayout; @@ -308,8 +308,8 @@ void KeyboardEntryActivity::render(RenderLock&&) { std::vector bottomKeys; bottomKeys.reserve(6); - bottomKeys.push_back({KeyboardKeyType::Shift, symMode ? shiftString[0] : shiftString[shiftState]}); - bottomKeys.push_back({KeyboardKeyType::Mode, symMode ? "abc" : "#@!"}); + bottomKeys.push_back({KeyboardKeyType::Shift, getShiftLabel()}); + bottomKeys.push_back({KeyboardKeyType::Mode, symMode ? tr(STR_ABC) : "#@!"}); if (isPassword) { bottomKeys.push_back({KeyboardKeyType::Reveal, passwordVisible ? tr(STR_HIDE) : tr(STR_SHOW)}); } diff --git a/src/activities/util/KeyboardEntryActivity.h b/src/activities/util/KeyboardEntryActivity.h index 89409f11..e28e23f7 100644 --- a/src/activities/util/KeyboardEntryActivity.h +++ b/src/activities/util/KeyboardEntryActivity.h @@ -144,7 +144,7 @@ class KeyboardEntryActivity : public Activity { {'`', '\0'}}, }; - static const char* const shiftString[2]; + const char* getShiftLabel() const; int getContentRowCount() const; int getTotalRowCount() const; diff --git a/src/components/themes/BaseTheme.cpp b/src/components/themes/BaseTheme.cpp index bb76c030..1170fc46 100644 --- a/src/components/themes/BaseTheme.cpp +++ b/src/components/themes/BaseTheme.cpp @@ -913,10 +913,14 @@ void BaseTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0'; const int primaryOffset = 0; - const int itemWidth = renderer.getTextWidth(UI_12_FONT_ID, label); + const int fontId = (keyType == KeyboardKeyType::Shift || keyType == KeyboardKeyType::Mode || + keyType == KeyboardKeyType::Reveal || keyType == KeyboardKeyType::Ok) + ? UI_10_FONT_ID + : UI_12_FONT_ID; + const int itemWidth = renderer.getTextWidth(fontId, label); const int textX = rect.x + (rect.width - itemWidth) / 2; - const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset; - renderer.drawText(UI_12_FONT_ID, textX, textY, label, !isSelected); + const int textY = rect.y + (rect.height - renderer.getLineHeight(fontId)) / 2 + primaryOffset; + renderer.drawText(fontId, textX, textY, label, !isSelected); if (hasSecondary) { const int secWidth = renderer.getTextWidth(SMALL_FONT_ID, secondaryLabel); diff --git a/src/components/themes/lyra/LyraTheme.cpp b/src/components/themes/lyra/LyraTheme.cpp index 09de2622..739a7afb 100644 --- a/src/components/themes/lyra/LyraTheme.cpp +++ b/src/components/themes/lyra/LyraTheme.cpp @@ -830,10 +830,14 @@ void LyraTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0'; const int primaryOffset = 0; - const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, label); + const int fontId = (keyType == KeyboardKeyType::Shift || keyType == KeyboardKeyType::Mode || + keyType == KeyboardKeyType::Reveal || keyType == KeyboardKeyType::Ok) + ? UI_10_FONT_ID + : UI_12_FONT_ID; + const int textWidth = renderer.getTextWidth(fontId, label); const int textX = rect.x + (rect.width - textWidth) / 2; - const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset; - renderer.drawText(UI_12_FONT_ID, textX, textY, label, !invert); + const int textY = rect.y + (rect.height - renderer.getLineHeight(fontId)) / 2 + primaryOffset; + renderer.drawText(fontId, textX, textY, label, !invert); if (hasSecondary) { const int secWidth = renderer.getTextWidth(SMALL_FONT_ID, secondaryLabel);