From bed5f68b11ec83f78e222cc8ee12e0bc812a8189 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Mon, 6 May 2024 17:00:00 -0500 Subject: [PATCH] Fix key preview text size being dependent on keyboard size --- java/src/org/futo/inputmethod/keyboard/Key.java | 5 +---- java/src/org/futo/inputmethod/keyboard/KeyboardView.java | 9 +++++---- .../inputmethod/keyboard/emoji/EmojiPalettesView.java | 2 +- .../inputmethod/keyboard/internal/KeyDrawParams.java | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/java/src/org/futo/inputmethod/keyboard/Key.java b/java/src/org/futo/inputmethod/keyboard/Key.java index 09a72f269..173818f98 100644 --- a/java/src/org/futo/inputmethod/keyboard/Key.java +++ b/java/src/org/futo/inputmethod/keyboard/Key.java @@ -711,10 +711,7 @@ public class Key implements Comparable { } public final int selectPreviewTextSize(final KeyDrawParams params) { - if (previewHasLetterSize()) { - return params.mPreviewTextSize; - } - return params.mLetterSize; + return params.mPreviewTextSize; } @Nonnull diff --git a/java/src/org/futo/inputmethod/keyboard/KeyboardView.java b/java/src/org/futo/inputmethod/keyboard/KeyboardView.java index 2a5e8f29c..83e067110 100644 --- a/java/src/org/futo/inputmethod/keyboard/KeyboardView.java +++ b/java/src/org/futo/inputmethod/keyboard/KeyboardView.java @@ -215,8 +215,8 @@ public class KeyboardView extends View { final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; final int keyWidth = keyboard.mMostCommonKeyWidth; - mKeyDrawParams.updateParams(Math.min(keyWidth, keyHeight), mKeyVisualAttributes); - mKeyDrawParams.updateParams(Math.min(keyWidth, keyHeight), keyboard.mKeyVisualAttributes); + mKeyDrawParams.updateParams(keyWidth, Math.min(keyWidth, keyHeight), mKeyVisualAttributes); + mKeyDrawParams.updateParams(keyWidth, Math.min(keyWidth, keyHeight), keyboard.mKeyVisualAttributes); invalidateAllKeys(); requestLayout(); } @@ -242,7 +242,7 @@ public class KeyboardView extends View { protected void updateKeyDrawParams(final int keyHeight) { final int keyWidth = mKeyboard.mMostCommonKeyWidth; - mKeyDrawParams.updateParams(Math.min(keyWidth, keyHeight), mKeyVisualAttributes); + mKeyDrawParams.updateParams(keyWidth, Math.min(keyWidth, keyHeight), mKeyVisualAttributes); } @Override @@ -357,7 +357,8 @@ public class KeyboardView extends View { canvas.translate(keyDrawX, keyDrawY); final KeyVisualAttributes attr = key.getVisualAttributes(); - final KeyDrawParams params = mKeyDrawParams.mayCloneAndUpdateParams(Math.min(key.getHeight(), key.getWidth()), attr); + final KeyDrawParams params = mKeyDrawParams.mayCloneAndUpdateParams(key.getWidth(), + Math.min(key.getHeight(), key.getWidth()), attr); params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE; if (!key.isSpacer()) { diff --git a/java/src/org/futo/inputmethod/keyboard/emoji/EmojiPalettesView.java b/java/src/org/futo/inputmethod/keyboard/emoji/EmojiPalettesView.java index 1690874dd..c3568ffd0 100644 --- a/java/src/org/futo/inputmethod/keyboard/emoji/EmojiPalettesView.java +++ b/java/src/org/futo/inputmethod/keyboard/emoji/EmojiPalettesView.java @@ -385,7 +385,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange mSpacebarIcon.setBackground(spacebarDrawable); } final KeyDrawParams params = new KeyDrawParams(); - params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr); + params.updateParams(0, mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr); setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params); setupAlphabetKey(mAlphabetKeyRight, switchToAlphaLabel, params); mEmojiPager.setAdapter(mEmojiPalettesAdapter); diff --git a/java/src/org/futo/inputmethod/keyboard/internal/KeyDrawParams.java b/java/src/org/futo/inputmethod/keyboard/internal/KeyDrawParams.java index 8447aaae4..151a03e2a 100644 --- a/java/src/org/futo/inputmethod/keyboard/internal/KeyDrawParams.java +++ b/java/src/org/futo/inputmethod/keyboard/internal/KeyDrawParams.java @@ -83,7 +83,7 @@ public final class KeyDrawParams { mAnimAlpha = copyFrom.mAnimAlpha; } - public void updateParams(final int keyHeight, @Nullable final KeyVisualAttributes attr) { + public void updateParams(final int keyWidth, final int keyHeight, @Nullable final KeyVisualAttributes attr) { if (attr == null) { return; } @@ -101,7 +101,7 @@ public final class KeyDrawParams { mShiftedLetterHintSize = selectTextSize(keyHeight, attr.mShiftedLetterHintRatio, mShiftedLetterHintSize); mHintLabelSize = selectTextSize(keyHeight, attr.mHintLabelRatio, mHintLabelSize); - mPreviewTextSize = selectTextSize(keyHeight, attr.mPreviewTextRatio, mPreviewTextSize); + mPreviewTextSize = selectTextSize(keyWidth, attr.mPreviewTextRatio, mPreviewTextSize); mTextColor = selectColor(attr.mTextColor, mTextColor); mTextInactivatedColor = selectColor(attr.mTextInactivatedColor, mTextInactivatedColor); @@ -125,13 +125,13 @@ public final class KeyDrawParams { } @Nonnull - public KeyDrawParams mayCloneAndUpdateParams(final int keyHeight, + public KeyDrawParams mayCloneAndUpdateParams(final int keyWidth, final int keyHeight, @Nullable final KeyVisualAttributes attr) { if (attr == null) { return this; } final KeyDrawParams newParams = new KeyDrawParams(this); - newParams.updateParams(keyHeight, attr); + newParams.updateParams(keyWidth, keyHeight, attr); return newParams; }