From b39e51aee4c044059dd97c20f0c78f982ed9e388 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Wed, 28 Oct 2009 15:47:49 -0400 Subject: [PATCH] Fix 2201778 - Key click on all apps Do it by hand, because the default on click handling doesn't do what we want. --- src/com/android/launcher2/AllAppsView.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index f5fdd36199..783be9315a 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -54,6 +54,7 @@ import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.SoundEffectConstants; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -132,6 +133,7 @@ public class AllAppsView extends RSSurfaceView public AllAppsView(Context context, AttributeSet attrs) { super(context, attrs); setFocusable(true); + setSoundEffectsEnabled(false); getHolder().setFormat(PixelFormat.TRANSLUCENT); final ViewConfiguration config = ViewConfiguration.get(context); mSlop = config.getScaledTouchSlop(); @@ -143,6 +145,17 @@ public class AllAppsView extends RSSurfaceView getHolder().setFormat(PixelFormat.TRANSLUCENT); } + /** + * If you have an attached click listener, View always plays the click sound!?!? + * Deal with sound effects by hand. + */ + public void reallyPlaySoundEffect(int sound) { + boolean old = isSoundEffectsEnabled(); + setSoundEffectsEnabled(true); + playSoundEffect(sound); + setSoundEffectsEnabled(old); + } + public AllAppsView(Context context, AttributeSet attrs, int defStyle) { this(context, attrs); } @@ -188,7 +201,6 @@ public class AllAppsView extends RSSurfaceView Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms"); } - @Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); @@ -381,6 +393,7 @@ public class AllAppsView extends RSSurfaceView if (mTouchTracking == TRACKING_HOME) { if (action == MotionEvent.ACTION_UP) { if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) { + reallyPlaySoundEffect(SoundEffectConstants.CLICK); mLauncher.closeAllApps(true); } mRollo.setHomeSelected(false); @@ -415,6 +428,7 @@ public class AllAppsView extends RSSurfaceView } if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) { + reallyPlaySoundEffect(SoundEffectConstants.CLICK); ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex); mLauncher.startActivitySafely(app.intent); }