Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16080] Android: Remove Default Sound Effect when touchEnabled = false

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-03-07T19:46:35.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsn/a
ReporterAndrew Greenstreet
AssigneeAndy Waldman
Created2013-12-17T20:52:08.000+0000
Updated2017-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)

Comments

  1. Ritu Agrawal 2013-12-26

    Makes sense. Moving this enhancement request to engineering for further evaluation.
  2. Tim Poulsen 2014-12-01

    PR https://github.com/appcelerator/titanium_mobile/pull/5373
  3. Ivan Skugor 2014-12-01

    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.
  4. Andrew Greenstreet 2014-12-03

    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);
       
       }
       
  5. Hans Knöchel 2017-02-03

    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.
  6. Andy Waldman 2017-02-28

    Lastest PR: https://github.com/appcelerator/titanium_mobile/pull/8852
  7. Andy Waldman 2017-03-07

    Closing https://github.com/appcelerator/titanium_mobile/pull/8816 Find above the current PR
  8. Samir Mohammed 2017-03-07

    Improvement present in SDK build 6.1.0.v20170307124208 Test information available in https://github.com/appcelerator/titanium_mobile/pull/8852

JSON Source