From d644d2bf0e84beb942142ef8deee143c9e54ce8c Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 11 Nov 2022 16:14:44 +0100 Subject: [PATCH] Disable the back-gesture on the keyboard area as well as other system gestures that would interfere with the keyboard's own swipe gesture. --- srcs/juloo.keyboard2/Keyboard2View.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index d82b58a..949eb0b 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.ContextWrapper; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.RectF; import android.inputmethodservice.InputMethodService; import android.os.Build.VERSION; @@ -14,6 +15,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.Window; +import java.util.Arrays; public class Keyboard2View extends View implements View.OnTouchListener, Pointers.IPointerEventHandler @@ -234,6 +236,20 @@ public class Keyboard2View extends View _keyWidth = (width - (_config.horizontalMargin * 2)) / _keyboard.keysWidth; } + @Override + public void onLayout(boolean changed, int left, int top, int right, int bottom) + { + if (!changed) + return; + // Disable the back-gesture on the keyboard area + Rect keyboard_area = new Rect( + left + (int)_config.horizontalMargin, + top + (int)_config.marginTop, + right - (int)_config.horizontalMargin, + bottom - (int)_config.marginBottom); + setSystemGestureExclusionRects(Arrays.asList(keyboard_area)); + } + @Override protected void onDraw(Canvas canvas) {