Skip to content

Implement touch interception for layouts on Android#13725

Closed
mattleibow wants to merge 2 commits into
mainfrom
dev/fix-touch-interception
Closed

Implement touch interception for layouts on Android#13725
mattleibow wants to merge 2 commits into
mainfrom
dev/fix-touch-interception

Conversation

@mattleibow
Copy link
Copy Markdown
Member

@mattleibow mattleibow commented Mar 6, 2023

Description of Change

Android needs custom logic to "intercept" touch events when tapping on a view that covers another view.

We already have the InputTransparent concept, but this is for children of a layout. The touch interception is needed to stop taps on a layout/view from passing through that layout onto the view below it.

Tasks

  • Code
    • Native views
      • LayoutViewGroup
      • WrapperView
      • ContentView
      • ScrollView
      • Others...
    • Non-interactive views
      • Frame
      • Image
      • Label
      • Box
      • ProgressBar
      • ActivityIndicator
  • Manual Tests
    • ListView / ViewCell
    • CollectionView
    • Layouts (Grids/Stacks)
    • InputTransparency
  • Tests
    • Device Tests
    • UI Tests
      • ListView / ViewCell
      • CollectionView
      • Layouts (Grids/Stacks)
      • InputTransparency
  • Type/member naming!
  • More I am sure

Issues Fixed

Fixes #10252

@mattleibow mattleibow self-assigned this Mar 8, 2023
Comment thread src/Core/src/Platform/Android/TouchEventInterceptor.cs Outdated
@jfversluis
Copy link
Copy Markdown
Member

Probably/maybe related: #10040

@SarthakB26
Copy link
Copy Markdown

Any idea when this will be available ? Adding empty TapGesture is not very efficient.

@samhouts samhouts added this to the .NET 8 GA milestone Jul 26, 2023
@mattleibow mattleibow force-pushed the dev/fix-touch-interception branch from 0ecae70 to 040c1a5 Compare September 6, 2023 20:23
@mattleibow
Copy link
Copy Markdown
Member Author

The PR broke InputTransparent.


AView _borderView;

WeakReference<IOnTouchListener> _touchListener;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What keeps a strong reference to the IOnTouchListener? It looks like the .NET GC would collect it. Java would then try to call TouchEventInterceptor+OnTouchListener and won't be able to.

Does the event continue working after some GCs occur?

@mattleibow mattleibow force-pushed the dev/fix-touch-interception branch from 040c1a5 to 5311098 Compare September 7, 2023 20:16
@samhouts
Copy link
Copy Markdown
Contributor

samhouts commented Sep 13, 2023

Tests failing?

@samhouts samhouts added the s/pr-needs-author-input PR needs an update from the author label Sep 13, 2023
@ghost
Copy link
Copy Markdown

ghost commented Sep 13, 2023

Hi @mattleibow. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time.

@samhouts samhouts modified the milestones: .NET 8 GA, Under Consideration Sep 19, 2023
@mattleibow mattleibow force-pushed the dev/fix-touch-interception branch from 5311098 to 56e9ee4 Compare September 20, 2023 21:53
@mattleibow mattleibow force-pushed the dev/fix-touch-interception branch 4 times, most recently from f7bbdeb to 56d0f2b Compare September 28, 2023 21:15
@ghost
Copy link
Copy Markdown

ghost commented Oct 9, 2023

Hi @mattleibow.
It seems you haven't touched this PR for the last two weeks. To avoid accumulating old PRs, we're marking it as stale. As a result, it will be closed if no further activity occurs within 4 days of this comment. You can learn more about our Issue Management Policies here.

@ghost ghost added the stale Indicates a stale issue/pr and will be closed soon label Oct 9, 2023
@samhouts samhouts modified the milestones: Under Consideration, .NET 8 SR2 Oct 12, 2023
@ghost ghost closed this Oct 16, 2023
@mattleibow mattleibow reopened this Oct 16, 2023
@ghost ghost removed stale Indicates a stale issue/pr and will be closed soon s/pr-needs-author-input PR needs an update from the author labels Oct 16, 2023
@mattleibow mattleibow force-pushed the dev/fix-touch-interception branch 4 times, most recently from 790c5fa to a564221 Compare October 23, 2023 14:02
@mattleibow
Copy link
Copy Markdown
Member Author

/rebase

@github-actions github-actions Bot force-pushed the dev/fix-touch-interception branch from a564221 to 043035b Compare November 9, 2023 12:54
@mattleibow
Copy link
Copy Markdown
Member Author

/rebase

@github-actions github-actions Bot force-pushed the dev/fix-touch-interception branch from 043035b to c9e55b9 Compare November 16, 2023 00:38
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Dec 7, 2023
@Redth Redth modified the milestones: .NET 8 SR2, .NET 8 + Servicing Jan 10, 2024
@samhouts samhouts added platform/android and removed stale Indicates a stale issue/pr and will be closed soon labels Feb 1, 2024
@jsuarezruiz
Copy link
Copy Markdown
Contributor

Could you rebase Matt?

…ption

# Conflicts:
#	src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/InputTransparencyGalleryTests.cs
#	src/Core/src/Platform/Android/MauiTextView.cs
#	src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
@michalsedlak
Copy link
Copy Markdown

Hi, do you have any ideal when this fix will be released? Thank you so much.

@michalsedlak
Copy link
Copy Markdown

Please, any update here? Thank you.

@PureWeen PureWeen modified the milestones: .NET 8 + Servicing, Backlog Aug 2, 2024
@aeonblaire
Copy link
Copy Markdown

This may be the fix I need for my project, is there any target version for this? Thanks!

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Aug 4, 2025

closing this for now

If this seems good to still get in for NET10, create a new PR :-)

@PureWeen PureWeen closed this Aug 4, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overlaying a StackLayout on another StackLayout does not block interaction