feat(app): adding edge gesture handlers#2542
Conversation
- @capacitor/push-notifications@8.1.1
|
Released dev build of app with dev version: 8.1.1-dev-2542-20260611T172948.0 |
| let translation = recognizer.translation(in: view) | ||
| let touch = recognizer.location(in: view) | ||
| let viewWidth = view.bounds.width | ||
| let viewHeight = view.bounds.height |
There was a problem hiding this comment.
viewHeight is declared but never used, can be removed.
| }); | ||
| this.onBackPressedCallback = new OnBackPressedCallback(!disableBackButtonHandler) { | ||
| this.backButtonHandlerEnabled = !getConfig().getBoolean("disableBackButtonHandler", false); | ||
| this.edgeGestureHandlerEnabled = getConfig().getBoolean("enableEdgeGestureHandler", false); |
There was a problem hiding this comment.
I think there might be an issue here worth investigating.
On Android < 14, if the developer opts into enableEdgeGestureHandler, this assignment makes edgeGestureHandlerEnabled = true. applyBackButtonHandlerState() then disables the backButton handler (via backButtonHandlerEnabled && !edgeGestureHandlerEnabled), but setupBackGestureHandlers() no-ops because OnBackAnimationCallback requires API 34+.
Net effect for users on Android < 14, backButton stops dispatching.
Suggest gating the flag by SDK:
boolean canUseEdgeGesture = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
this.edgeGestureHandlerEnabled = canUseEdgeGesture && getConfig().getBoolean("enableEdgeGestureHandler", false);
Same fix needed in toggleEdgeGestureHandler .
Could you double-check this scenario? Might be that I'm missing something.
|
|
||
| private void applyBackButtonHandlerState() { | ||
| if (this.onBackPressedCallback != null) { | ||
| this.onBackPressedCallback.setEnabled(backButtonHandlerEnabled && !edgeGestureHandlerEnabled); |
There was a problem hiding this comment.
Tied to the earlier comment on line 53: on Android < 14, if the developer opts into enableEdgeGestureHandler, this line evaluates setEnabled(true && !true) = setEnabled(false) and disables the backButton handler. But setupBackGestureHandlers() no-ops on those versions because OnBackAnimationCallback requires API 34+. backButton stops dispatching.
Silent regression with no error. Gating the flag at assignment (see line 53) would prevent this.
OS-ruimoreiramendes
left a comment
There was a problem hiding this comment.
Besides the inline comments I left, I tested the changes locally on a test app and everything seems to be working correctly. Nice work overall.
Description
Adds a new
edgeGestureevent that adds support for system edge-swipe gestures on both iOS and Android.Change Type
Rationale / Problems Fixed
Tests or Reproductions
Screenshots / Media
Platforms Affected
Notes / Comments