Open RedAuburn opened 3 months ago
i think iOS has similar sounds, not sure if it's properly handled there either
Hello @RedAuburn,
I tried out adding both sound and haptic feedback, but there's an issue for the tap sounds. When the user touches the map interface, the onTouch() method is invoked at least twice. And the calls to onTouch() only grow when the user drags the map interface.
As a result, if view.performClick() is invoked from within onTouch(), it leads to a barrage of tap sounds and quickly becomes annoying.
We could add the sound and haptic feedback for long press with no issues, however.
Could you please let me know what you think of this and how we can proceed?
Thanks in advance!
Hiya @varad64!
I tried out adding both sound and haptic feedback, but there's an issue for the tap sounds. When the user touches the map interface, the onTouch() method is invoked at least twice. And the calls to onTouch() only grow when the user drags the map interface.
As a result, if view.performClick() is invoked from within onTouch(), it leads to a barrage of tap sounds and quickly becomes annoying.
Unfortunately, a simple fix of adding onTouch() to the view won't suffice, a proper implementation that only has tap sounds when actually tapping something on the map will require passing the touch from the C++ core to native via JNI, then triggering a performClick().
Thanks for responding, @RedAuburn. Okay, I understand. Is there any documentation on how to to get the C++ core to talk to the Java code?
Thank you!
Is there any documentation on how to to get the C++ core to talk to the Java code?
there's JNI docs, but not anything Organic Maps specific as far as i know.
it's probably easiest to understand via example; have a look at https://github.com/search?q=repo%3Aorganicmaps%2Forganicmaps+nativeontouch&type=code
Okay, great. Let me try implementing this and get back to you!
Thanks for the useful example
Hello @RedAuburn,
I spent some time analysing the concerned native code execution and its interaction with the Java code. I now have a better understanding. But there are 2 challenges:
user_event_stream.cpp
. How do I figure out what is the native equivalent of performClick()
or alternatively playSoundEffect() and performHapticFeedback()
?performClick
method is called in MapFragment.java
, the tap sound and haptic feedback will be duplicated. If not called, the original problem remains unsolved.The long tap behavior can be solved for by means of the onLongClick
method without any issues.
Thanks in advance!
if tap & click sounds are enabled in android settings (it's enabled by default), tapping or long-pressing on the map should trigger the sounds/vibration like it does with the other buttons in the app, and across the system. this will make the map feel more integrated & tactile.
see https://m2.material.io/design/sound/applying-sound-to-ui.html#system-sounds