Skip to content

Commit 45e0703

Browse files
committed
Improve keyboard height adjustment trigger mechanism
Previous approach was hideSoftInputFromWindow + showSoftInput. This approach was bad because: 1. It caused a flash due to the keyboard being hidden then reshown. 2. It failed to actually redraw at the new size in Android 16 (API 36), presumably due to changes in the heuristics used to determine whether a redraw is actually required. --- New approach is restartInput + showSoftInput. This seems to fix both problems: 1. The flash no longer occurs. 2. The keyboard is properly redrawn at the new size in Android 16 (API 36). --- Fixes <#21>.
1 parent 06c5a92 commit 45e0703

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
## [Unreleased]
55

6+
- Fixed keyboard height not immediately updating in Android 16
7+
68

79
## [v1.4.3] (69) Cursed be Android 16 (2025-06-29)
810

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ public void onStartTrackingTouch(SeekBar seekBar)
9393
@Override
9494
public void onStopTrackingTouch(SeekBar seekBar)
9595
{
96-
// Hide and reshow keyboard to trigger height readjustment
96+
// Trigger height readjustment and ensure keyboard shown
9797
final View focusView = getCurrentFocus();
9898
if (focusView != null)
9999
{
100100
final InputMethodManager inputMethodManager =
101101
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
102-
inputMethodManager.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
102+
inputMethodManager.restartInput(focusView);
103103
inputMethodManager.showSoftInput(findViewById(R.id.test_input), InputMethodManager.SHOW_IMPLICIT);
104104
}
105105
}

0 commit comments

Comments
 (0)