mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-25 00:56:35 +00:00
fix small almost-edge keys (#478)
This commit is contained in:
parent
f657ebad3d
commit
5ec55f3e0e
3 changed files with 7 additions and 39 deletions
|
@ -960,8 +960,6 @@ public class Key implements Comparable<Key> {
|
||||||
private final KeyboardParams mKeyboardParams; // for reading gaps and keyboard width / height
|
private final KeyboardParams mKeyboardParams; // for reading gaps and keyboard width / height
|
||||||
public float mRelativeWidth;
|
public float mRelativeWidth;
|
||||||
public float mRelativeHeight; // also should allow negative values, indicating absolute height is defined
|
public float mRelativeHeight; // also should allow negative values, indicating absolute height is defined
|
||||||
public float mRelativeVisualInsetLeft;
|
|
||||||
public float mRelativeVisualInsetRight;
|
|
||||||
|
|
||||||
// params that may change
|
// params that may change
|
||||||
public float mFullWidth;
|
public float mFullWidth;
|
||||||
|
@ -980,7 +978,7 @@ public class Key implements Comparable<Key> {
|
||||||
public int mBackgroundType;
|
public int mBackgroundType;
|
||||||
public final int mActionFlags;
|
public final int mActionFlags;
|
||||||
@Nullable public final KeyVisualAttributes mKeyVisualAttributes;
|
@Nullable public final KeyVisualAttributes mKeyVisualAttributes;
|
||||||
@Nullable public OptionalAttributes mOptionalAttributes;
|
@Nullable public final OptionalAttributes mOptionalAttributes;
|
||||||
public final boolean mEnabled;
|
public final boolean mEnabled;
|
||||||
|
|
||||||
public static KeyParams newSpacer(final KeyboardParams params, final float relativeWidth) {
|
public static KeyParams newSpacer(final KeyboardParams params, final float relativeWidth) {
|
||||||
|
@ -1007,18 +1005,6 @@ public class Key implements Comparable<Key> {
|
||||||
yPos = newY;
|
yPos = newY;
|
||||||
mFullWidth = mRelativeWidth * mKeyboardParams.mBaseWidth;
|
mFullWidth = mRelativeWidth * mKeyboardParams.mBaseWidth;
|
||||||
mFullHeight = mRelativeHeight * mKeyboardParams.mBaseHeight;
|
mFullHeight = mRelativeHeight * mKeyboardParams.mBaseHeight;
|
||||||
|
|
||||||
// set visual insets if any
|
|
||||||
if (mRelativeVisualInsetRight != 0f || mRelativeVisualInsetLeft != 0f) {
|
|
||||||
final int insetLeft = (int) (mRelativeVisualInsetLeft * mKeyboardParams.mBaseWidth);
|
|
||||||
final int insetRight = (int) (mRelativeVisualInsetRight * mKeyboardParams.mBaseWidth);
|
|
||||||
if (mOptionalAttributes == null) {
|
|
||||||
mOptionalAttributes = OptionalAttributes.newInstance(null, CODE_UNSPECIFIED, ICON_UNDEFINED, insetLeft, insetRight);
|
|
||||||
} else {
|
|
||||||
mOptionalAttributes = OptionalAttributes
|
|
||||||
.newInstance(mOptionalAttributes.mOutputText, mOptionalAttributes.mAltCode, mOptionalAttributes.mDisabledIconId, insetLeft, insetRight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPopupKeysColumnAndFlagsAndSetNullInArray(final KeyboardParams params, final String[] popupKeys) {
|
private static int getPopupKeysColumnAndFlagsAndSetNullInArray(final KeyboardParams params, final String[] popupKeys) {
|
||||||
|
@ -1269,8 +1255,6 @@ public class Key implements Comparable<Key> {
|
||||||
mActionFlags = keyParams.mActionFlags;
|
mActionFlags = keyParams.mActionFlags;
|
||||||
mKeyVisualAttributes = keyParams.mKeyVisualAttributes;
|
mKeyVisualAttributes = keyParams.mKeyVisualAttributes;
|
||||||
mOptionalAttributes = keyParams.mOptionalAttributes;
|
mOptionalAttributes = keyParams.mOptionalAttributes;
|
||||||
mRelativeVisualInsetLeft = keyParams.mRelativeVisualInsetLeft;
|
|
||||||
mRelativeVisualInsetRight = keyParams.mRelativeVisualInsetRight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,14 +248,16 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
|
|
||||||
private fun endKey(key: Key) {
|
private fun endKey(key: Key) {
|
||||||
mParams.onAddKey(key)
|
mParams.onAddKey(key)
|
||||||
if (mLeftEdge) {
|
if (mLeftEdge && !key.isSpacer) {
|
||||||
key.markAsLeftEdge(mParams)
|
key.markAsLeftEdge(mParams)
|
||||||
mLeftEdge = false
|
mLeftEdge = false
|
||||||
}
|
}
|
||||||
if (mTopEdge) {
|
if (mTopEdge) {
|
||||||
key.markAsTopEdge(mParams)
|
key.markAsTopEdge(mParams)
|
||||||
}
|
}
|
||||||
mRightEdgeKey = key
|
if (!key.isSpacer) {
|
||||||
|
mRightEdgeKey = key
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun endKeyboard() {
|
private fun endKeyboard() {
|
||||||
|
|
|
@ -122,8 +122,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
spacerWidth = 0f
|
spacerWidth = 0f
|
||||||
keyWidth = availableWidth / row.size
|
keyWidth = availableWidth / row.size
|
||||||
}
|
}
|
||||||
if (spacerWidth != 0f && functionalKeysLeft.isNotEmpty()) {
|
if (spacerWidth != 0f) {
|
||||||
// add a spacer between left functional key and keyboard key
|
|
||||||
paramsRow.add(KeyParams.newSpacer(params, spacerWidth))
|
paramsRow.add(KeyParams.newSpacer(params, spacerWidth))
|
||||||
}
|
}
|
||||||
if (keyWidth < params.mDefaultRelativeKeyWidth * 0.82 && spacerWidth == 0f) {
|
if (keyWidth < params.mDefaultRelativeKeyWidth * 0.82 && spacerWidth == 0f) {
|
||||||
|
@ -146,24 +145,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
paramsRow.add(keyParams)
|
paramsRow.add(keyParams)
|
||||||
}
|
}
|
||||||
if (spacerWidth != 0f) {
|
if (spacerWidth != 0f) {
|
||||||
if (functionalKeysLeft.isEmpty()) {
|
paramsRow.add(KeyParams.newSpacer(params, spacerWidth))
|
||||||
// we did not add a spacer above, but extend the key to the edge and set visual insets
|
|
||||||
paramsRow.first().mRelativeWidth += spacerWidth
|
|
||||||
paramsRow.first().mRelativeVisualInsetLeft = spacerWidth
|
|
||||||
}
|
|
||||||
if (functionalKeysRight.isEmpty()) {
|
|
||||||
// extend right key to the edge and set visual insets
|
|
||||||
paramsRow.last().mRelativeWidth += spacerWidth
|
|
||||||
paramsRow.last().mRelativeVisualInsetRight = spacerWidth
|
|
||||||
} else {
|
|
||||||
// add a spacer between keyboard key and right functional key (like for the left side)
|
|
||||||
// unless it's the enter key, in that case increase the key's width (to match original layout in tablet mode)
|
|
||||||
if (functionalKeysRight.singleOrNull()?.mBackgroundType == Key.BACKGROUND_TYPE_ACTION) {
|
|
||||||
functionalKeysRight.single().mRelativeWidth += spacerWidth
|
|
||||||
} else {
|
|
||||||
paramsRow.add(KeyParams.newSpacer(params, spacerWidth))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
functionalKeysRight.forEach { paramsRow.add(it) }
|
functionalKeysRight.forEach { paramsRow.add(it) }
|
||||||
keysInRows.add(paramsRow)
|
keysInRows.add(paramsRow)
|
||||||
|
|
Loading…
Add table
Reference in a new issue