mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 05:52:47 +00:00
Fix key preview text cut off (#744)
This commit is contained in:
parent
6ff98d3a05
commit
dc4cdea687
9 changed files with 3 additions and 20 deletions
|
@ -83,7 +83,6 @@ import java.util.WeakHashMap;
|
|||
* @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout
|
||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewLayout
|
||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewOffset
|
||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
|
||||
* @attr ref R.styleable#MainKeyboardView_popupKeysKeyboardLayout
|
||||
* @attr ref R.styleable#MainKeyboardView_popupKeysKeyboardForActionLayout
|
||||
* @attr ref R.styleable#MainKeyboardView_backgroundDimAlpha
|
||||
|
|
|
@ -89,7 +89,7 @@ public final class KeyPreviewChoreographer {
|
|||
keyPreviewView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mParams.setGeometry(keyPreviewView);
|
||||
final int previewWidth = keyPreviewView.getMeasuredWidth();
|
||||
final int previewHeight = mParams.mPreviewHeight;
|
||||
final int previewHeight = keyPreviewView.getMeasuredHeight();
|
||||
final int keyDrawWidth = key.getDrawWidth();
|
||||
// The key preview is horizontally aligned with the center of the visible part of the
|
||||
// parent key. If it doesn't fit in this {@link KeyboardView}, it is moved inward to fit and
|
||||
|
|
|
@ -15,7 +15,6 @@ import helium314.keyboard.latin.settings.Settings;
|
|||
public final class KeyPreviewDrawParams {
|
||||
// XML attributes of {@link MainKeyboardView}.
|
||||
public final int mPreviewOffset;
|
||||
public final int mPreviewHeight;
|
||||
public final int mPreviewBackgroundResId;
|
||||
private boolean mShowPopup = true;
|
||||
|
||||
|
@ -47,13 +46,6 @@ public final class KeyPreviewDrawParams {
|
|||
public KeyPreviewDrawParams(final TypedArray mainKeyboardViewAttr) {
|
||||
mPreviewOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
||||
R.styleable.MainKeyboardView_keyPreviewOffset, 0);
|
||||
// crashes when too small (or just < 1?)
|
||||
final float heightScale = (float) Math.max(1f, Math.sqrt(Settings.getInstance().getCurrent().mKeyboardHeightScale));
|
||||
// todo: further scaling issue
|
||||
// key height and thus text height (in pixels) don't change with display density,
|
||||
// but keyPreviewHeight does -> how to do it right?
|
||||
mPreviewHeight = (int) (mainKeyboardViewAttr.getDimensionPixelSize(
|
||||
R.styleable.MainKeyboardView_keyPreviewHeight, 0) * heightScale);
|
||||
mPreviewBackgroundResId = mainKeyboardViewAttr.getResourceId(
|
||||
R.styleable.MainKeyboardView_keyPreviewBackground, 0);
|
||||
}
|
||||
|
@ -68,10 +60,11 @@ public final class KeyPreviewDrawParams {
|
|||
|
||||
public void setGeometry(final View previewTextView) {
|
||||
final int previewWidth = previewTextView.getMeasuredWidth();
|
||||
final int previewHeight = previewTextView.getMeasuredHeight();
|
||||
// The width and height of visible part of the key preview background. The content marker
|
||||
// of the background 9-patch have to cover the visible part of the background.
|
||||
mVisibleWidth = previewWidth - previewTextView.getPaddingLeft() - previewTextView.getPaddingRight();
|
||||
mVisibleHeight = mPreviewHeight - previewTextView.getPaddingTop() - previewTextView.getPaddingBottom();
|
||||
mVisibleHeight = previewHeight - previewTextView.getPaddingTop() - previewTextView.getPaddingBottom();
|
||||
// The distance between the top edge of the parent key and the bottom of the visible part
|
||||
// of the key preview background.
|
||||
setVisibleOffset(-previewTextView.getPaddingBottom() / 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue