Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] The default click sound on button press is lost after updating xamarin forms nuget. #10035

Open
jessiezh0320 opened this issue Mar 20, 2020 · 9 comments

Comments

@jessiezh0320
Copy link

Description

The default click sound on button press is lost after updating xamarin forms nuget to the newer version(e.g. 4.3.0.908675).

But in older version, the default click sound on button press still exists.(e.g.Xamarin forms nuget 3.6.0.293080)

Steps to Reproduce

  1. Create a new xamari forms demo and add a button in xaml;
    <Button Text="test" VerticalOptions="Center" HorizontalOptions="Center" Clicked="Button_Clicked"/>

  2. Then add event Click for the Button;
    private void Button_Clicked(object sender, EventArgs e) { }

  3. Put on headphone and run the app , click the button, and pay attention to the sound when clicking the Button.

Expected Behavior

The default click sound on button press is not lost after updating xamarin forms nuget.

remains the same as the old version

Actual Behavior

The default click sound on button press is lost after updating xamarin forms nuget.

Basic Information

@jessiezh0320 jessiezh0320 added s/unverified New report that has yet to be verified t/bug 🐛 labels Mar 20, 2020
@pauldipietro pauldipietro added this to New in Triage Mar 20, 2020
@jfversluis
Copy link
Member

Hey @jessiezh0320 thanks for the report! I can't seem to detect which platform you are talking about. Is this iOS, Android, UWP? As far as I can recall none of these have a "click" sound, so I'm curious to find out what this is about. Thanks!

@jfversluis jfversluis added a/button s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Mar 20, 2020
@jfversluis jfversluis moved this from New to Needs Info in Triage Mar 20, 2020
@samhouts samhouts moved this from Needs Info to New in Triage Mar 20, 2020
@samhouts samhouts moved this from New to Needs Info in Triage Mar 20, 2020
@leocdi
Copy link

leocdi commented Mar 20, 2020

Hi @jfversluis this concerns Android platform.
Here is a sample project with old Xamarin.Forms Version 3.4.0.1008975 where we can hear the click default sound
https://github.com/leocdi/ButtonSoundFeedback.git

@jfversluis
Copy link
Member

I have just tried this project on a recent device (Galaxy S10) and I don't hear a clicking sound out of the box. However, I can enable the sound by going into the settings of the phone and enabling it under touch interactions (might be named differently in other Android versions).

When I then upgrade to 4.5 stable, even with the OS setting on, the touch feedback is no longer there. I think this is something that is dropped with the Material design, but I can't find any source to back that up.

@jessiezh0320
Copy link
Author

@jfversluis Yes, this problem does exist on the Android platform. I hope you can help solve this problem.Thanks.

@PureWeen PureWeen moved this from Needs Info to New in Triage Apr 3, 2020
@kingces95 kingces95 moved this from New to Ready For Work in Triage Apr 4, 2020
@kingces95 kingces95 removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified labels Apr 4, 2020
@jfversluis
Copy link
Member

jfversluis commented Apr 4, 2020

I was going through the ButtonRenderer on Android for a different reason, but found this: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/FastRenderers/ButtonRenderer.cs#L310

That might be some hint as to why it is not working. Now to find out why that was added.. Looks like it has been in there from the start.

@jessiezh0320 could you do me a favor and try to enable the legacy renderers (see the doc) and see if that brings back the sound?

@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Apr 10, 2020
@leocdi
Copy link

leocdi commented Apr 23, 2020

@jfversluis
Just tested, Enabling legacy renderer Brind Back the sound.

@jfversluis
Copy link
Member

OK so, what I found is that on a VisualElement level the SoundEffectsEnabled is set to false here: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs#L238

On a Button, but only for the fast renderer, this is repeated here: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/FastRenderers/ButtonRenderer.cs#L312

However! For the Button the sound is indeed disabled, but for other controls the sound is still enabled nonetheless. Interestingly enough, as seen above, for the legacy renderers the sound can be heard as well.

The main question is: why are we setting the SoundEffectsEnabled to false. Or at least trying to. The way this works on Android is that the user can set the feedback sounds on/off on OS level. If they're off, they will never hear any of it. If they enabled them, you as the developer can override it for an element by setting the SoundEffectsEnabled to false.

I would say; let's just remove the hard setting SoundEffectsEnabled to false and introduce a PlatformSpecific to set it on any VisualElement. Users can then decide for themselves.

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@larsduewel
Copy link

larsduewel commented Sep 24, 2020

Totally agree with @jfversluis here. The click sound is so important as user feedback sometimes that it should be free to the developer when to enable or disable it.

Comparing a native and xamarin.forms app the first thing i always notice is that there is no click sound feedback on a button.

If the user does not want any click sounds, he can just disable it in the system.

@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@johannperez
Copy link

I worked around it using this renderer

public class ButtonFeedbackRenderer : ButtonRenderer
{
public ButtonFeedbackRenderer(Context context) : base(context)
{
}

    protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
    {
        base.OnElementChanged(e);
        Control.SoundEffectsEnabled = true;
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Needs Estimate
Development

No branches or pull requests

7 participants