Disable the back-gesture on the keyboard area

as well as other system gestures that would interfere with the
keyboard's own swipe gesture.
This commit is contained in:
Jules Aguillon 2022-11-11 16:14:44 +01:00
parent fc68f2e07d
commit d644d2bf0e

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.ContextWrapper; import android.content.ContextWrapper;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.inputmethodservice.InputMethodService; import android.inputmethodservice.InputMethodService;
import android.os.Build.VERSION; import android.os.Build.VERSION;
@ -14,6 +15,7 @@ import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import java.util.Arrays;
public class Keyboard2View extends View public class Keyboard2View extends View
implements View.OnTouchListener, Pointers.IPointerEventHandler implements View.OnTouchListener, Pointers.IPointerEventHandler
@ -234,6 +236,20 @@ public class Keyboard2View extends View
_keyWidth = (width - (_config.horizontalMargin * 2)) / _keyboard.keysWidth; _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 @Override
protected void onDraw(Canvas canvas) protected void onDraw(Canvas canvas)
{ {