Fix edge key popup: use hitbox bounds in squaredDistanceToEdge - #391
Open
AZADAYAZ wants to merge 9 commits into
Open
Fix edge key popup: use hitbox bounds in squaredDistanceToEdge#391AZADAYAZ wants to merge 9 commits into
AZADAYAZ wants to merge 9 commits into
Conversation
Co-authored-by: LeanBitLab <173956434+LeanBitLab@users.noreply.github.com>
Co-authored-by: LeanBitLab <245915690+LeanBitLab@users.noreply.github.com>
Update strings.xml
Edge keys (leftmost and rightmost column keys like 1, Q, A and 0, Ü, İ) have their touch hitbox extended via markAsLeftEdge() and markAsRightEdge() to respond to touches near the screen edges. However, squaredDistanceToEdge() was using the visual bounds (getX(), mWidth, getY(), mHeight) instead of the extended hitbox (mHitBox) for distance calculations. This caused a mismatch: isOnKey() correctly recognized touches in the extended hitbox area, but squaredDistanceToEdge() calculated a large distance from the visual edge, making the pointer tracker think the finger had left the key. As a result, key preview popups never appeared on edge keys during normal tapping, and long-press popup panels could not detect finger position on the extended area. This change makes squaredDistanceToEdge() use mHitBox bounds consistently, fixing popup behavior for edge keys while preserving existing behavior for interior keys where hitbox equals visual bounds. Fixes: LeanBitLab#292
…squared-distance # Conflicts: # app/src/main/java/helium314/keyboard/latin/RichInputConnection.java # app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java # app/src/main/res/values-tr/strings.xml
After merge conflict resolution, 32 string entries were duplicated (pinned_toolbar_keys, quick_pin_toolbar_keys, show_popup_keys_main, etc.). This caused Resource and asset merger to fail with: 'Found item String/pinned_toolbar_keys more than one time' Remove the duplicates, keeping the first occurrence of each key.
In Android XML string resources, single quotes must be escaped as \'. Unescaped single quotes cause 'Invalid unicode escape sequence' errors during AAPT2 compilation. This fixes the CI build error for PR LeanBitLab#391.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On edge keys (leftmost column: 1, Q, A and rightmost column: 0, Ü, İ), key preview popups do not appear during normal tapping — they only show up when long-pressing. Additionally, when the finger is in the extended hitbox area (near the screen edge), the popup panel cannot correctly detect finger position.
Root Cause
The
squaredDistanceToEdge()method inKey.javauses the visual bounds of the key (getX(),mWidth,getY(),mHeight) for distance calculations. However, for edge keys,markAsLeftEdge()andmarkAsRightEdge()extend the hitbox (mHitBox) beyond the visual bounds. This inconsistency creates the following problem:isOnKey()correctly uses the extended hitbox → the touch is recognized as being on the keysquaredDistanceToEdge()uses visual bounds → the distance from the visual edge is very largePointerTrackerinisMajorEnoughMoveToBeOnNewKey()interprets the finger as having left the key, canceling the key preview popupSince the long-press flow (
onLongPressed) does not perform this distance check, long-press popups still work — which is why the issue only manifests during normal tapping.Fix
Changed
squaredDistanceToEdge()to usemHitBoxbounds instead of visual bounds: