mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix key preview text size being dependent on keyboard size
This commit is contained in:
parent
c937a618e1
commit
bed5f68b11
@ -711,11 +711,8 @@ public class Key implements Comparable<Key> {
|
||||
}
|
||||
|
||||
public final int selectPreviewTextSize(final KeyDrawParams params) {
|
||||
if (previewHasLetterSize()) {
|
||||
return params.mPreviewTextSize;
|
||||
}
|
||||
return params.mLetterSize;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Typeface selectPreviewTypeface(final KeyDrawParams params) {
|
||||
|
@ -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()) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user