Skip to content

Commit

Permalink
Track scan state to go back to after keyboard is hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenMcGirr committed Mar 7, 2024
1 parent 21d8791 commit ec1d29a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ object KeyboardInfo {
var isKeyboardVisible = false
var keyboardHeight = 0

// Track last scan state to go back to it after keyboard is dismissed
var lastScanState: ScanReceiver.ReceiverState = ScanReceiver.ReceiverState.CURSOR

fun updateKeyboardState(windows: List<AccessibilityWindowInfo>) {
val keyboardWindow = windows.firstOrNull { window ->
window.type == AccessibilityWindowInfo.TYPE_INPUT_METHOD
Expand All @@ -21,11 +24,17 @@ object KeyboardInfo {

// Go to cursor as keyboard keys don't report AccessibilityNodeInfo
if (ScanReceiver.state == ScanReceiver.ReceiverState.ITEM_SCAN) {
lastScanState = ScanReceiver.state
ScanReceiver.state = ScanReceiver.ReceiverState.CURSOR
}
} else {
isKeyboardVisible = false
keyboardHeight = 0

// Go back to last scan state
if (ScanReceiver.state == ScanReceiver.ReceiverState.CURSOR) {
ScanReceiver.state = lastScanState
}
}
Log.d("KeyboardInfo", "isKeyboardVisible: $isKeyboardVisible window count: ${windows.size}")
}
Expand Down

0 comments on commit ec1d29a

Please sign in to comment.