[TIMOB-16080] Android: Remove Default Sound Effect when touchEnabled = false
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2017-03-07T19:46:35.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.1.0 |
| Components | Android |
| Labels | n/a |
| Reporter | Andrew Greenstreet |
| Assignee | Andy Waldman |
| Created | 2013-12-17T20:52:08.000+0000 |
| Updated | 2017-03-07T22:06:04.000+0000 |
Description
Please update "registerForTouch" in TiUIView.java with
if (clickable) {
registerTouchEvents(touchable);
doSetClickable(touchable);
} else {
touchable.setSoundEffectsEnabled(false);
}
Reasoning: If a developer has specifically set a view to be non-touchable, then there should not be a touch sound on that view.
Alternative would be to add another view property for soundEffectsEnabled, such that in either Alloy
<View soundEffectsEnabled='false'></View>
or
Ti.UI.createView({
soundEffectsEnabled : false
});
Where View is any kind of View (View, Label, Image, etc)
Makes sense. Moving this enhancement request to engineering for further evaluation.
PR https://github.com/appcelerator/titanium_mobile/pull/5373
IMHO - this should enabled by default, native Android apps have that kind of behaviour. So, sound should be played only if view have touch events added.
I agree. I've been rolling a custom version of the Ti Android SDK that work this way for almost a year. Touch sounds on non-interactive items is just plain wrong. This is what I use:
protected void registerForTouch(final View touchable) { if (touchable == null) { return; } if (proxy.hasProperty(TiC.PROPERTY_TOUCH_ENABLED)) { boolean enabled = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_TOUCH_ENABLED), true); if (!enabled) { if (touchable.getClass().toString() != android.widget.TextView.class.toString()) { //setting enabled on some early versions of 4.0 causes a Java exception when the label has no text touchable.setEnabled(false); } touchable.setSoundEffectsEnabled(false); } else { touchable.setSoundEffectsEnabled(true); } } else { touchable.setSoundEffectsEnabled(false); //Turn off the touch sound unless this item is specifically set to touch enabled } registerTouchEvents(touchable); // Previously, we used the single tap handling above to fire our click event. It doesn't // work: a single tap is not the same as a click. A click can be held for a while before // lifting the finger; a single-tap is only generated from a quick tap (which will also cause // a click.) We wanted to do it in single-tap handling presumably because the singletap // listener gets a MotionEvent, which gives us the information we want to provide to our // users in our click event, whereas Android's standard OnClickListener does _not_ contain // that info. However, an "up" seems to always occur before the click listener gets invoked, // so we store the last up event's x,y coordinates (see onTouch above) and use them here. // Note: AdapterView throws an exception if you try to put a click listener on it. doSetClickable(touchable); }Updated PR: https://github.com/appcelerator/titanium_mobile/pull/8816 Basically, we should normalize the SDK behavior to the native behaviorm which is described above.
Lastest PR: https://github.com/appcelerator/titanium_mobile/pull/8852
Closing https://github.com/appcelerator/titanium_mobile/pull/8816 Find above the current PR
Improvement present in SDK build 6.1.0.v20170307124208 Test information available in https://github.com/appcelerator/titanium_mobile/pull/8852