fix(ui): keep the Agent composer above the keyboard and release search fields on tap (#2852)

* fix(agent): keep the composer above the keyboard outside fullscreen

* fix(ui): release a search field when another control is tapped

* fix(ui): release the add-on search field in its dialog, and let a reopened search take focus

* fix(ui): a drag that returns to where it began does not release the search field
This commit is contained in:
Tushar Gandhe authored and GitHub committed 2026-11-22 16:58:57 -05:00
1 parent 71b7b6efad
commit c3809c0a75
7 files changed
+146 -9

No files matched your search

@@ -17,8 +17,11 @@ import android.os.Looper
import android.util.Log
import android.view.Display
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.view.WindowManager
import android.widget.EditText
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.result.contract.ActivityResultContracts
@@ -2042,6 +2045,36 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
}
private var touchDownX = 0f
private var touchDownY = 0f
private var touchDragged = false
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
com.droiddeck.launcher.ui.ScreenTaps.count++
touchDownX = event.rawX
touchDownY = event.rawY
touchDragged = false
}
// A drag that wanders back to where it began is still a drag, not a tap.
MotionEvent.ACTION_MOVE -> if (!touchDragged &&
kotlin.math.hypot(event.rawX - touchDownX, event.rawY - touchDownY) > ViewConfiguration.get(this).scaledTouchSlop
) touchDragged = true
MotionEvent.ACTION_CANCEL -> touchDragged = true
}
val handled = super.dispatchTouchEvent(event)
if (event.actionMasked == MotionEvent.ACTION_UP) leaveTextFieldOnOutsideTap(event)
return handled
}
private fun leaveTextFieldOnOutsideTap(event: MotionEvent) {
val field = currentFocus as? EditText ?: return
val slop = ViewConfiguration.get(this).scaledTouchSlop
if (touchDragged || kotlin.math.hypot(event.rawX - touchDownX, event.rawY - touchDownY) > slop) return
com.droiddeck.launcher.ui.releaseTextField(field, IntArray(2).also(field::getLocationOnScreen), event.rawX, event.rawY)
}
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
if (com.droiddeck.launcher.ui.AgentPet.handleBack(this, event)) return true
if (compatLaunch != null) {