Skip to content

Commit

Permalink
determination can be more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
devycarol committed Jun 28, 2024
1 parent 0008bef commit ef79d24
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/src/main/java/helium314/keyboard/keyboard/PointerTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {

// the popup keys panel currently being shown. equals null if no panel is active.
private PopupKeysPanel mPopupKeysPanel;
private boolean mDidShowPopupKeys = false;

private static final int MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT = 3;
// true if this pointer is in the dragging finger mode.
Expand All @@ -146,6 +145,8 @@ public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {

// true if dragging finger is allowed.
private boolean mIsAllowedDraggingFinger;
// true if key swipes are allowed.
private boolean mKeySwipeAllowed;

private final BatchInputArbiter mBatchInputArbiter;
private final GestureStrokeDrawingPoints mGestureStrokeDrawingPoints;
Expand Down Expand Up @@ -698,13 +699,15 @@ private void startKeySelectionByDraggingFinger(final Key key) {
if (!mIsInDraggingFinger) {
final int code = key.getCode(); // todo: no sliding input yet for those keys, but it would be really useful
mIsInSlidingKeyInput = key.isModifier() && code != KeyCode.CTRL && code != KeyCode.ALT && code != KeyCode.FN && code != KeyCode.META;
mKeySwipeAllowed = !mIsInSlidingKeyInput;
}
mIsInDraggingFinger = true;
}

private void resetKeySelectionByDraggingFinger() {
mIsInDraggingFinger = false;
mIsInSlidingKeyInput = false;
mKeySwipeAllowed = true;
sDrawingProxy.showSlidingKeyInputPreview(null);
}

Expand Down Expand Up @@ -889,7 +892,8 @@ private boolean keySwipe(final int code, final int x, final int y) {
}

// Horizontal movement
if (sv.mSpaceSwipeHorizontal == KeyboardActionListener.SWIPE_NO_ACTION) return false;
if (sv.mSpaceSwipeHorizontal == KeyboardActionListener.SWIPE_NO_ACTION)
return false;
int stepsX = dX / sPointerStep;
if (stepsX != 0 && !mInVerticalSwipe) {
mInHorizontalSwipe = true;
Expand Down Expand Up @@ -918,8 +922,8 @@ private void onMoveEventInternal(final int x, final int y, final long eventTime)
final Key oldKey = mCurrentKey;

// todo (later): extend key swipe stuff
if (!mIsInSlidingKeyInput && !mDidShowPopupKeys && mCurrentRepeatingKeyCode == Constants.NOT_A_CODE
&& oldKey != null && keySwipe(oldKey.getCode(), x, y)) return;
if (mKeySwipeAllowed && oldKey != null && keySwipe(oldKey.getCode(), x, y))
return;

final Key newKey = onMoveKey(x, y);
final int lastX = mLastX;
Expand Down Expand Up @@ -994,14 +998,14 @@ private void onUpEventInternal(final int x, final int y, final long eventTime) {
mCurrentKey = null;
final int currentRepeatingKeyCode = mCurrentRepeatingKeyCode;
mCurrentRepeatingKeyCode = Constants.NOT_A_CODE;
mKeySwipeAllowed = true;
// Release the last pressed key.
setReleasedKeyGraphics(currentKey, true);

if (mInHorizontalSwipe && currentKey.getCode() == KeyCode.DELETE) {
sListener.onUpWithDeletePointerActive();
}

mDidShowPopupKeys = false;
if (isShowingPopupKeysPanel()) {
if (!mIsTrackingForActionDisabled) {
final int translatedX = mPopupKeysPanel.translateX(x);
Expand Down Expand Up @@ -1106,7 +1110,7 @@ public void onLongPressed() {
final int translatedY = popupKeysPanel.translateY(mLastY);
popupKeysPanel.onDownEvent(translatedX, translatedY, mPointerId, SystemClock.uptimeMillis());
mPopupKeysPanel = popupKeysPanel;
mDidShowPopupKeys = true;
mKeySwipeAllowed = false;
}

private void cancelKeyTracking() {
Expand Down Expand Up @@ -1229,9 +1233,11 @@ public void onKeyRepeat(final int code, final int repeatCount) {
final Key key = getKey();
if (key == null || key.getCode() != code) {
mCurrentRepeatingKeyCode = Constants.NOT_A_CODE;
mKeySwipeAllowed = true;
return;
}
mCurrentRepeatingKeyCode = code;
mKeySwipeAllowed = false;
mIsDetectingGesture = false;
final int nextRepeatCount = repeatCount + 1;
startKeyRepeatTimer(nextRepeatCount);
Expand Down

0 comments on commit ef79d24

Please sign in to comment.