-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Adds touchSoundEnabled
prop to Touchables
#11136
Conversation
Which, when set to true, allows them to play system default touch sound both on iOS ans Android. Relasted to #6188
By analyzing the blame information on this pull request, we identified @ericvicenti and @JoelMarcey to be potential reviewers. |
public void playTouchSound() { | ||
AudioManager audioManager = | ||
(AudioManager) getReactApplicationContext().getSystemService(Context.AUDIO_SERVICE); | ||
if (audioManager != 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.
iirc in this codebase braces should be used even on single line if statements
React/Modules/RCTUIManager.m
Outdated
@@ -1119,6 +1119,10 @@ - (void)batchDidComplete | |||
[self _layoutAndMount]; | |||
} | |||
|
|||
RCT_EXPORT_METHOD(playTouchSound){ |
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 be on newline to follow code style conventions
Libraries/Text/Text.js
Outdated
@@ -151,6 +151,10 @@ const Text = React.createClass({ | |||
*/ | |||
testID: React.PropTypes.string, | |||
/** | |||
* If true, plays system sound on touch | |||
**/ | |||
touchSoundEnabled: React.PropTypes.bool, |
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.
is this actually doing anything on Text
?
I fixed code style issues @brentvatne mentioned above. |
Check Brent's question:
|
@mkonicek <Text touchSoundEnabled={true} style={styles.text} onPress={() => this.handlePress('Top-level text Sound ON')}>
<Text style={styles.nestedText} onPress={() => this.handlePress('Nested text Sound OFF')}>Nested</Text>
{' text '}
<Text style={styles.nestedText} onPress={() => this.handlePress('Nested text Sound ON')} touchSoundEnabled={true}> sound </Text>
{' ON '}
</Text> In this fragment, it plays sound when you press on |
@janicduplessis pointed out:
Thoughts @doomsower? Also there is a related PR that was closed: https://github.com/facebook/react-native/pull/6825/files Thanks for the PR by the way! :) |
This PR was abandoned and got closed, because it used reactTag to obtain native view and then call method on of this view. As it was mentioned in the discussion there, reactTag doesn't always resolve to actual native view. Moreover, in this PR only I don't play sound by default for two reasons. Firstly this change affects both iOS and Android, and I want to have similar behavior on both platforms. Secondly It's possible to set different default prop value based on platform and component class ( |
I'm fine with merging this |
Seems like we're almost there! Who can merge this by solving conflicts? |
@facebook-github-bot shipit |
@janicduplessis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@@ -1143,6 +1143,11 @@ - (void)batchDidComplete | |||
[self _layoutAndMount]; | |||
} | |||
|
|||
RCT_EXPORT_METHOD(playTouchSound) |
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.
I dislike an idea to put something related to sound into RCTUIManager
. We just have to have dedicated AudioManager (if we still don't have one) and then implement whole feature on Javascript side.
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.
Adding dedicated managers is beyond my area of expertise. I found no other classes dealing with sound or audio in RN, so I think it's ok to do it this way until more sound business is needed.
@@ -177,6 +177,10 @@ const Text = React.createClass({ | |||
*/ | |||
testID: PropTypes.string, | |||
/** | |||
* If true, plays system sound on touch |
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.
Wait, why <Text>
? Text has nothing to do with sound. A property of <Touchable*>
would be enough.
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.
Because Text
has onPress
too, and it can by used without being wrapped in touchable. If something can handle press, then it should be able to make sound. Besides, in discussion of first PR #6825 Text
was used in internal tests.
Any news or some progress on this? Thanks |
It sounds like we do not want to move forward with an implementation like this. If the change was exclusively to TouchableNativeFeedback, it would be more likely to get merged |
Hey guys, was this ever implemented in any way? My native app feels so empty and un androidy :( |
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
Just found that any touchable always plays sound on Android and there is no way to disable it. Any plans to fix it and introduce a touchSoundEnabled prop? |
@yurykorzun #17183 was merged to add touch sounds but does not include a prop to disable it. I don't think there are any plans to add a prop currently but feel free to submit a PR. |
Summary: Currently, every time a touchable is pressed on Android, a system sound is played. It was added in the PR #17183. There is no way to disable it, except disabling touch on sound on the system level. I am pretty sure there are cases when touches should be silent and there should be an option to disable it. Related PRs - #17183, #11136 [Android][added] - Added a touchSoundDisabled prop to Touchable. If true, doesn't system sound on touch. Pull Request resolved: #24666 Differential Revision: D15166582 Pulled By: cpojer fbshipit-source-id: 48bfe88f03f791e3b9c7cbd0e2eed80a2cfba8ee
This PR addresses issue #6188
It allows touchables to play system default sound when touched, and adds a prop to control this behavior (off by default)
It also allows to play default touch sound by calling
UIManager.playTouchSound()
, which can be used manually in gesture responders.Test plan (required)
Tested this manually on following code fragment on both iOS and Android physical devices: