Fix key preview text size being dependent on keyboard size

This commit is contained in:
Aleksandras Kostarevas 2024-05-06 17:00:00 -05:00
parent c937a618e1
commit bed5f68b11
4 changed files with 11 additions and 13 deletions

View File

@ -711,10 +711,7 @@ public class Key implements Comparable<Key> {
}
public final int selectPreviewTextSize(final KeyDrawParams params) {
if (previewHasLetterSize()) {
return params.mPreviewTextSize;
}
return params.mLetterSize;
return params.mPreviewTextSize;
}
@Nonnull

View File

@ -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()) {

View File

@ -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);

View File

@ -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;
}