mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-18 06:15:02 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71ec123de0 | ||
|
|
e645adbd0b |
@@ -49,6 +49,21 @@ restarting the process. It writes snapshots and native failure state under
|
||||
production package. This needs a native rebuild when the Unistyles patch changes; a Metro
|
||||
reload cannot update it.
|
||||
|
||||
To check the first Android composer tap after pinch-to-zoom, install the rebuilt
|
||||
APK and connect it to a chat whose latest assistant message contains a visible
|
||||
Markdown image. For example, put `picture.png` in the agent workspace and have
|
||||
the assistant reply with ``. Set `CHAT_URL` to the
|
||||
chat's Paseo deep link and run from the repository root:
|
||||
|
||||
```bash
|
||||
agent-device test packages/app/e2e/mobile/composer-keyboard/lightbox-pinch.android.ad \
|
||||
--platform android --serial emulator-5554 -e APP_ID=sh.paseo -e "CHAT_URL=$CHAT_URL"
|
||||
```
|
||||
|
||||
Use `APP_ID=sh.paseo.debug` for a development build. If the image has different
|
||||
alt text, pass it with `-e IMAGE_LABEL="..."`. The test pinches the image, closes
|
||||
it, types in the composer, and checks that a single Attach tap opens Upload file.
|
||||
|
||||
For Android keyboard continuity, run the current checkout in the app, open an idle terminal
|
||||
with an empty prompt, hide its keyboard, and run:
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# CHAT_URL opens a connected chat containing a visible Markdown image with alt text IMAGE_LABEL.
|
||||
context platform=android timeout=120000 retries=0
|
||||
env APP_ID=sh.paseo.debug
|
||||
env IMAGE_LABEL="Test image"
|
||||
|
||||
open "${APP_ID}" "${CHAT_URL}"
|
||||
wait "label=\"${IMAGE_LABEL}\"" 30000
|
||||
press "label=\"${IMAGE_LABEL}\""
|
||||
wait "label=\"Close image\"" 5000
|
||||
gesture pinch 1.7
|
||||
press "label=\"Close image\""
|
||||
press "editable=true"
|
||||
type "pinch regression"
|
||||
press "role=\"button\" label=\"Add attachment\""
|
||||
wait "label=\"Upload file\"" 3000
|
||||
@@ -152,18 +152,92 @@ index 8d78aea..b84d19e 100644
|
||||
viewGroup: ViewGroup,
|
||||
coords: FloatArray,
|
||||
diff --git a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
|
||||
index 629c155..dc0790d 100644
|
||||
index 629c155..2efd508 100644
|
||||
--- a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
|
||||
+++ b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
|
||||
@@ -19,6 +19,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
||||
@@ -19,7 +19,9 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
||||
private val jsGestureHandler: GestureHandler?
|
||||
val rootView: ViewGroup
|
||||
private var shouldIntercept = false
|
||||
+ private var wasIntercepting = false
|
||||
private var passingTouch = false
|
||||
+ private var lastTouch: MotionEvent? = null
|
||||
|
||||
init {
|
||||
@@ -118,6 +119,14 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
||||
UiThreadUtil.assertOnUiThread()
|
||||
@@ -47,6 +49,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
||||
}
|
||||
|
||||
fun tearDown() {
|
||||
+ clearLastTouch()
|
||||
Log.i(
|
||||
ReactConstants.TAG,
|
||||
"[GESTURE HANDLER] Tearing down gesture handler registered for root view $rootView",
|
||||
@@ -90,17 +93,46 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
||||
|
||||
override fun onCancel() {
|
||||
shouldIntercept = true
|
||||
- val time = SystemClock.uptimeMillis()
|
||||
- val event = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0f, 0f, 0).apply {
|
||||
- action = MotionEvent.ACTION_CANCEL
|
||||
- }
|
||||
if (rootView is RootView) {
|
||||
- rootView.onChildStartedNativeGesture(rootView, event)
|
||||
+ val cancel = createReactCancelEvent()
|
||||
+ try {
|
||||
+ rootView.onChildStartedNativeGesture(rootView, cancel)
|
||||
+ } finally {
|
||||
+ cancel.recycle()
|
||||
+ clearLastTouch()
|
||||
+ }
|
||||
}
|
||||
- event.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
+ private fun clearLastTouch() {
|
||||
+ lastTouch?.recycle()
|
||||
+ lastTouch = null
|
||||
+ }
|
||||
+
|
||||
+ private fun createReactCancelEvent(): MotionEvent {
|
||||
+ val now = SystemClock.uptimeMillis()
|
||||
+ val touch = lastTouch ?: return MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0f, 0f, 0)
|
||||
+ // The enclosing React root already dispatched this event before it reached the
|
||||
+ // gesture handler. A POINTER_UP is still in MotionEvent but already ended in JS.
|
||||
+ val lifted = if (touch.actionMasked == MotionEvent.ACTION_POINTER_UP) touch.actionIndex else -1
|
||||
+ val count = touch.pointerCount - if (lifted >= 0) 1 else 0
|
||||
+ val properties = Array(count) { MotionEvent.PointerProperties() }
|
||||
+ val coords = Array(count) { MotionEvent.PointerCoords() }
|
||||
+ var index = 0
|
||||
+ for (pointer in 0 until touch.pointerCount) {
|
||||
+ if (pointer == lifted) continue
|
||||
+ touch.getPointerProperties(pointer, properties[index])
|
||||
+ touch.getPointerCoords(pointer, coords[index])
|
||||
+ index++
|
||||
+ }
|
||||
+ return MotionEvent.obtain(
|
||||
+ touch.downTime, now, MotionEvent.ACTION_CANCEL, count, properties, coords,
|
||||
+ touch.metaState, touch.buttonState, touch.xPrecision, touch.yPrecision,
|
||||
+ touch.deviceId, touch.edgeFlags, touch.source, touch.flags,
|
||||
+ )
|
||||
+ }
|
||||
+
|
||||
fun requestDisallowInterceptTouchEvent() {
|
||||
// If this method gets called it means that some native view is attempting to grab lock for
|
||||
// touch event delivery. In that case we cancel all gesture recognizers
|
||||
@@ -115,9 +147,25 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
||||
// We mark `mPassingTouch` before we get into `mOrchestrator.onTouchEvent` so that we can tell
|
||||
// if `requestDisallow` has been called as a result of a normal gesture handling process or
|
||||
// as a result of one of the gesture handlers activating
|
||||
+ // Keep the stream for recognizers that activate between events (e.g. long press).
|
||||
+ // Once native handling begins, React no longer receives the remaining touches.
|
||||
+ if (!event.isHoverAction() && (!shouldIntercept || event.actionMasked == MotionEvent.ACTION_DOWN)) {
|
||||
+ clearLastTouch()
|
||||
+ if (event.actionMasked != MotionEvent.ACTION_UP && event.actionMasked != MotionEvent.ACTION_CANCEL) {
|
||||
+ lastTouch = MotionEvent.obtainNoHistory(event)
|
||||
+ }
|
||||
+ }
|
||||
passingTouch = true
|
||||
orchestrator!!.onTouchEvent(event)
|
||||
passingTouch = false
|
||||
|
||||
Reference in New Issue
Block a user