Loading core/java/android/widget/CompoundButton.java +10 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading core/java/android/widget/Switch.java +8 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.util.FloatProperty; import android.util.MathUtils; import android.view.Gravity; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.VelocityTracker; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; Loading Loading @@ -797,6 +798,7 @@ public class Switch extends CompoundButton { // Commit the change if the event is up and not canceled and the switch // has not been disabled during the drag. final boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled(); final boolean oldState = isChecked(); final boolean newState; if (commitChange) { mVelocityTracker.computeCurrentVelocity(1000); Loading @@ -807,10 +809,14 @@ public class Switch extends CompoundButton { newState = getTargetCheckedState(); } } else { newState = isChecked(); newState = oldState; } if (newState != oldState) { playSoundEffect(SoundEffectConstants.CLICK); setChecked(newState); } cancelSuperTouch(ev); } Loading Loading
core/java/android/widget/CompoundButton.java +10 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading
core/java/android/widget/Switch.java +8 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.util.FloatProperty; import android.util.MathUtils; import android.view.Gravity; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.VelocityTracker; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; Loading Loading @@ -797,6 +798,7 @@ public class Switch extends CompoundButton { // Commit the change if the event is up and not canceled and the switch // has not been disabled during the drag. final boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled(); final boolean oldState = isChecked(); final boolean newState; if (commitChange) { mVelocityTracker.computeCurrentVelocity(1000); Loading @@ -807,10 +809,14 @@ public class Switch extends CompoundButton { newState = getTargetCheckedState(); } } else { newState = isChecked(); newState = oldState; } if (newState != oldState) { playSoundEffect(SoundEffectConstants.CLICK); setChecked(newState); } cancelSuperTouch(ev); } Loading