Skip to content

Commit 2f40e58

Browse files
committed
Fix keyboard background bounds
Fill only the keyboard, not the whole view. Will be important for drawing preview popups; we don't want a white bar in the allocated space.
1 parent ad5e36e commit 2f40e58

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(adds glyphs for qwerty symbols etc.)
88
- Reduced key label font sizes
99
- Fixed InputContainer background not transparent
10+
- Fixed keyboard background bounds (fill only the keyboard, not the whole view)
1011

1112

1213
## [v0.5.0] Implemented qwerty (2021-07-12)

app/src/main/java/io/github/yawnoc/strokeinput/InputContainer.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public class InputContainer
8686
private int shiftMode;
8787

8888
// Keyboard drawing
89+
private final Rect keyboardRectangle;
90+
private final Paint keyboardFillPaint;
8991
private final Rect keyRectangle;
9092
private final Paint keyFillPaint;
9193
private final Paint keyBorderPaint;
@@ -123,6 +125,9 @@ public void handleMessage(Message message) {
123125

124126
this.setBackgroundColor(Color.TRANSPARENT);
125127

128+
keyboardRectangle = new Rect();
129+
keyboardFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
130+
126131
keyRectangle = new Rect();
127132

128133
keyFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
@@ -158,6 +163,7 @@ public Keyboard getKeyboard() {
158163
public void setKeyboard(final Keyboard keyboard) {
159164
this.keyboard = keyboard;
160165
keyArray = keyboard.getKeyList().toArray(new Keyboard.Key[0]);
166+
keyboardFillPaint.setColor(keyboard.fillColour);
161167
requestLayout();
162168
}
163169

@@ -200,6 +206,13 @@ public void onMeasure(
200206
keyboardHeight = keyboard.getHeight();
201207
}
202208

209+
keyboardRectangle.set(
210+
0,
211+
Keyboard.KEYBOARD_GUTTER_HEIGHT_PX,
212+
keyboardWidth,
213+
Keyboard.KEYBOARD_GUTTER_HEIGHT_PX + keyboardHeight
214+
);
215+
203216
setMeasuredDimension(
204217
keyboardWidth + paddingHorizontal,
205218
keyboardHeight + paddingVertical
@@ -213,7 +226,7 @@ public void onDraw(final Canvas canvas) {
213226
return;
214227
}
215228

216-
canvas.drawColor(keyboard.fillColour);
229+
canvas.drawRect(keyboardRectangle, keyboardFillPaint);
217230

218231
for (final Keyboard.Key key : keyArray) {
219232

app/src/main/java/io/github/yawnoc/strokeinput/Keyboard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Keyboard {
5353

5454
private static final int DEFAULT_OFFSET_X = 0;
5555
private static final int DEFAULT_KEYBOARD_FILL_COLOUR = Color.BLACK;
56-
private static final int KEYBOARD_GUTTER_HEIGHT_PX = 1;
56+
public static final int KEYBOARD_GUTTER_HEIGHT_PX = 1;
5757

5858
// Key properties
5959
private boolean keysAreShiftable;

0 commit comments

Comments
 (0)