File tree Expand file tree Collapse file tree
app/src/main/java/io/github/yawnoc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040
4141import androidx .core .graphics .ColorUtils ;
4242
43+ import io .github .yawnoc .utilities .Valuey ;
44+
4345/*
4446 A container that holds:
4547 - Candidates bar
@@ -682,7 +684,15 @@ private void updateKeyPreview() {
682684 final int previewHeight = keyPreview .height ;
683685
684686 final int previewMargin = activeKey .previewMargin ;
685- final int previewX = activeKey .x - (previewWidth - activeKey .width ) / 2 ;
687+
688+ final int keyboardLeftX = 0 ;
689+ final int keyboardRightX = keyboard .getWidth () - previewWidth ;
690+ final int previewX =
691+ (int ) Valuey .clipValueToRange (
692+ activeKey .x - (previewWidth - activeKey .width ) / 2f ,
693+ keyboardLeftX ,
694+ keyboardRightX
695+ );
686696 final int previewY = activeKey .y - previewHeight - previewMargin ;
687697
688698 if (keyPreviewPopup .isShowing ()) {
Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ private Valuey() {
2929 // Do not instantiate
3030 }
3131
32+ public static float clipValueToRange (
33+ final float value ,
34+ final float rangeMin ,
35+ final float rangeMax
36+ )
37+ {
38+ return Math .max (rangeMin , Math .min (rangeMax , value ));
39+ }
40+
3241 public static int getDimensionOrFraction (
3342 final TypedArray array ,
3443 final int attributeIndex ,
You can’t perform that action at this time.
0 commit comments