summaryrefslogtreecommitdiff
path: root/core/java/android/widget/CompoundButton.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-10-28 00:57:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-28 00:57:11 +0000
commite5d27a22a6908026d346e86389cf414b5badeab6 (patch)
tree1718045fafbb725a0d7f45150a64a4ba70d359aa /core/java/android/widget/CompoundButton.java
parent80c9fbe36fe8b1e298a70c465e85ee677fc12e12 (diff)
parentd4e7790fee10e21b41a1c387c2734722bda56a0b (diff)
Merge "Play CLICK sound effect when compound buttons are clicked" into lmp-mr1-dev
Diffstat (limited to 'core/java/android/widget/CompoundButton.java')
-rw-r--r--core/java/android/widget/CompoundButton.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 7d9d3052fe22..092e31c5a6b4 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -29,6 +29,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.Gravity;
+import android.view.SoundEffectConstants;
import android.view.ViewDebug;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -114,15 +115,16 @@ public abstract class CompoundButton extends Button implements Checkable {
@Override
public boolean performClick() {
- /*
- * XXX: These are tiny, need some surrounding 'expanded touch area',
- * which will need to be implemented in Button if we only override
- * performClick()
- */
-
- /* When clicked, toggle the state */
toggle();
- return super.performClick();
+
+ final boolean handled = super.performClick();
+ if (!handled) {
+ // View only makes a sound effect if the onClickListener was
+ // called, so we'll need to make one here instead.
+ playSoundEffect(SoundEffectConstants.CLICK);
+ }
+
+ return handled;
}
@ViewDebug.ExportedProperty