-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android click sounds on press #6825
Conversation
this.touchableHandlePress(e); | ||
} | ||
} | ||
|
||
this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout); | ||
this.touchableDelayTimeout = null; | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyword-spacing: Expected space(s) after "if".
c895571
to
7cd5ea0
Compare
@mikemonteith updated the pull request. |
@sahrens would you mind taking a look at this pull request? It's been a while since the last commit was reviewed. |
Nice, but I doubt all apps want this - can you add a global config to turn it off? Like Touchable.DISABLE_DEFAULT_SOUNDS that people can set when there app first initializes, and a comment in the docs? cc @dmmiller and @mkonicek for thoughts. For the propTypes, does it work to factor them out into a shared class, Also, please rebase and fix the conflicts and get tests passing. |
It's rare for apps in Android to play a sound on touch. So I'd say it should be off by default. |
@mikemonteith Ah. Weird. |
Tested a few apps on Android and every touchable element always produces a sound so I think this should be enabled by default and not even be a prop. It's up to the user to enable / disable touch sounds but apps should not decide whether or not there should be one. Also right now react native apps touch sounds are inconsistent since touchable elements don't produce sounds but other native controls like Toolbar buttons do. |
@janicduplessis You're right, as long as it's enabled in the system settings. On my Nexus 5X I actually had sounds disabled in Settings -> Sounds & notifications -> Other sounds -> Touch sounds. Now when I enabled it all touchables produce a sound, as long as the media volume is not muted. @mikemonteith Let's play the sounds by default, agree with @janicduplessis we don't need the prop, as long as the behavior respects the system setting. |
Is there a way we could cleanly fake this? Ex: by calling into an audio library directly, or sending fake touch events to a single offscreen button? |
@ide I'm pretty sure this PR does exactly what we want by calling https://developer.android.com/reference/android/view/View.html#playSoundEffect(int) |
Looks like there's some interest in this PR. Would you like me to make any changes to it? |
@mikemonteith Yes, could you remove the prop you added and always play the touch sounds, could you also make sure it repects the system setting for touch sounds. |
7cd5ea0
to
e0bad29
Compare
@mikemonteith updated the pull request. |
@@ -712,12 +714,21 @@ var TouchableMixin = { | |||
|
|||
var shouldInvokePress = !IsLongPressingIn[curState] || pressIsLongButStillCallOnPress; | |||
if (shouldInvokePress && this.touchableHandlePress) { | |||
this._playClickSound(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called on iOS as well as Android. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it should just be android. Should I add a Platform.os === 'android' check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably add the platform check to make sure it doesn't do unnecessary stuff on ios.
Thanks for updating the pull request @mikemonteith 👍 I added one question. Can you please add a test plan demonstrating the system setting is respected (you can hear sounds if and only if this is enabled in system settings)? |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review internal test results. |
Tried importing and this is failing on some internal tests. The problem is that you call findNodeHandle on things that might not end up in the tree. In particular, it is failing on a test like this :
Try clicking on one of the nested text pieces. This fires an event on a virtual node which you then dispatch on. That doesn't actually exist in the tree. I think you can get around this by perhaps just always passing the root or something. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
Hi, any updates on this? |
@mikemonteith I'm going through all pull requests and noticed this one hasn't been updated in a while and the last comment requests changes. I'll close this pull request so it doesn't stay open indefinitely but please send a new one if you want to continue working on this. I think this is useful! If anyone wants to send a new PR with this code, addressing the comment about |
Hey guys, why did we not implement this? It's driving me crazy as a new react-native user. It totally pulls me away from the 'native' feeling. |
I can't believe this issue is still not fixed for years. |
I gave up.
…On Oct 8, 2017 21:18, "Burak Çalık" ***@***.***> wrote:
I can't believe this issue is still not fixed for years.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6825 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AcCuP_b7xBMJK4TFTMT90Ea8De_58Ddsks5sqXRvgaJpZM4IAb0i>
.
|
Hi. I haven't worked on a react-native project for over a year now so this is very low on my priority list. The pull request is so old that I'm sure it needs to be looked at anew. Hopefully someone else can pick this up before I eventually get round to looking at it again. |
Summary: Android apps play a touch sound on press, as long as you have "Touch sounds" enabled in the settings. As and Android user, when building my app using React Native, one of the first things I noticed was that there were not any touch sounds. This is missing from React Native and there have been multiple PRs to have this implemented, but no success. This PR iterates over [#6825](#6825) and [#11136](#11136) This PR keeps it simple by only implementing the enhancement for Android, as iOS apps typically do not use touch sounds, and follows the users' system settings for whether or not the sound is played. I have manually tested this on multiple devices and emulators with zero problems [ANDROID] [ENHANCEMENT] [UIManagerModule.java]- Adds Android click sound to touchables [ANDROID] [ENHANCEMENT] [Touchable] - Adds Android click sound to touchables Closes #17183 Differential Revision: D7560327 Pulled By: hramos fbshipit-source-id: ce1094c437541bc677c7d64b0dba343dd9574422
Summary: Android apps play a touch sound on press, as long as you have "Touch sounds" enabled in the settings. As and Android user, when building my app using React Native, one of the first things I noticed was that there were not any touch sounds. This is missing from React Native and there have been multiple PRs to have this implemented, but no success. This PR iterates over [facebook#6825](facebook#6825) and [facebook#11136](facebook#11136) This PR keeps it simple by only implementing the enhancement for Android, as iOS apps typically do not use touch sounds, and follows the users' system settings for whether or not the sound is played. I have manually tested this on multiple devices and emulators with zero problems [ANDROID] [ENHANCEMENT] [UIManagerModule.java]- Adds Android click sound to touchables [ANDROID] [ENHANCEMENT] [Touchable] - Adds Android click sound to touchables Closes facebook#17183 Differential Revision: D7560327 Pulled By: hramos fbshipit-source-id: ce1094c437541bc677c7d64b0dba343dd9574422
Summary: Android apps play a touch sound on press, as long as you have "Touch sounds" enabled in the settings. As and Android user, when building my app using React Native, one of the first things I noticed was that there were not any touch sounds. This is missing from React Native and there have been multiple PRs to have this implemented, but no success. This PR iterates over [facebook#6825](facebook#6825) and [facebook#11136](facebook#11136) This PR keeps it simple by only implementing the enhancement for Android, as iOS apps typically do not use touch sounds, and follows the users' system settings for whether or not the sound is played. I have manually tested this on multiple devices and emulators with zero problems [ANDROID] [ENHANCEMENT] [UIManagerModule.java]- Adds Android click sound to touchables [ANDROID] [ENHANCEMENT] [Touchable] - Adds Android click sound to touchables Closes facebook#17183 Differential Revision: D7560327 Pulled By: hramos fbshipit-source-id: ce1094c437541bc677c7d64b0dba343dd9574422
Summary: Android apps play a touch sound on press, as long as you have "Touch sounds" enabled in the settings. As and Android user, when building my app using React Native, one of the first things I noticed was that there were not any touch sounds. This is missing from React Native and there have been multiple PRs to have this implemented, but no success. This PR iterates over [facebook#6825](facebook#6825) and [facebook#11136](facebook#11136) This PR keeps it simple by only implementing the enhancement for Android, as iOS apps typically do not use touch sounds, and follows the users' system settings for whether or not the sound is played. I have manually tested this on multiple devices and emulators with zero problems [ANDROID] [ENHANCEMENT] [UIManagerModule.java]- Adds Android click sound to touchables [ANDROID] [ENHANCEMENT] [Touchable] - Adds Android click sound to touchables Closes facebook#17183 Differential Revision: D7560327 Pulled By: hramos fbshipit-source-id: ce1094c437541bc677c7d64b0dba343dd9574422
Summary: Android apps play a touch sound on press, as long as you have "Touch sounds" enabled in the settings. As and Android user, when building my app using React Native, one of the first things I noticed was that there were not any touch sounds. This is missing from React Native and there have been multiple PRs to have this implemented, but no success. This PR iterates over [facebook#6825](facebook#6825) and [facebook#11136](facebook#11136) This PR keeps it simple by only implementing the enhancement for Android, as iOS apps typically do not use touch sounds, and follows the users' system settings for whether or not the sound is played. I have manually tested this on multiple devices and emulators with zero problems [ANDROID] [ENHANCEMENT] [UIManagerModule.java]- Adds Android click sound to touchables [ANDROID] [ENHANCEMENT] [Touchable] - Adds Android click sound to touchables Closes facebook#17183 Differential Revision: D7560327 Pulled By: hramos fbshipit-source-id: ce1094c437541bc677c7d64b0dba343dd9574422
Summary: Android apps play a touch sound on press, as long as you have "Touch sounds" enabled in the settings. As and Android user, when building my app using React Native, one of the first things I noticed was that there were not any touch sounds. This is missing from React Native and there have been multiple PRs to have this implemented, but no success. This PR iterates over [facebook#6825](facebook#6825) and [facebook#11136](facebook#11136) This PR keeps it simple by only implementing the enhancement for Android, as iOS apps typically do not use touch sounds, and follows the users' system settings for whether or not the sound is played. I have manually tested this on multiple devices and emulators with zero problems [ANDROID] [ENHANCEMENT] [UIManagerModule.java]- Adds Android click sound to touchables [ANDROID] [ENHANCEMENT] [Touchable] - Adds Android click sound to touchables Closes facebook#17183 Differential Revision: D7560327 Pulled By: hramos fbshipit-source-id: ce1094c437541bc677c7d64b0dba343dd9574422
Memo check compared elements of prevProps to nextProps but failed to take new props into account. Fixed the logic and added a new test.
Android should play a sound effect on click by default.
Since the ReactNative touch event model circumvents the usual Android OnClickListener, we trigger the click sound manually.