Is there any way to handle touch events for surface?

335 views Asked by At

I would like to support map dragging, scaling, etc. in the android-auto (AA) navigation app. Was very excited to read car-lib announce (and a little disappointed about the old androidx-car library remove:). But I was not able to find documentation and examples of any user interaction handling.

Is there any callback or a special manager for handling user interactions with Surface? Could not find any related stuff in SurfaceListener, Surface, NavigationTemplate or documentation. AFAIK, Google Maps and Waze handles scaling and rotation because of using the old private activity providing method (not suggested screen providing).

The documentation states that AA takes care of input. Not sure if it is applicable for navigation scenarios.

Android Auto takes care of the following, in general: .... Input: Handling user input to templates via mechanisms available in specific cars, such as a touchscreen or rotary...

It would be cool to handle raw touch events, but if there are no plans to add this (for security purposes or whatever), more specific events seems to be ok.

interface SurfaceListener {
...
void onSurfaceScaleChanged(Float scale);
void onSurfaceRotated(Float angle);
void onSurfaceDragging(Int x, Int y);
void onSurfaceClicked(Int x, Int y);
...
}
2

There are 2 answers

1
marcinj On BEST ANSWER

There is an open issue for this here: https://issuetracker.google.com/issues/171715013, the answer from google as for 28.dec.2020 is:

This is a limitation in version 1, and we are evaluating adding this functionality for future updates.

so we have to wait:-)

0
Takeshi Inoue On

Now SurfaceCallback supports onScroll(), onFling(), and onScale() handlers (source).