From 9ff1510aeba910c22b2e31c29a93b08281feae4f Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 10 Jun 2015 15:58:08 -0700 Subject: [PATCH] Fix vibration when expanding notifications To make it more consistent with other vibration feedback in the system. Bug: 21549323 Change-Id: Ia4ef1cf17c28f6069635797af94991a639e1cef0 --- packages/SystemUI/res/values/config.xml | 2 -- .../src/com/android/systemui/ExpandHelper.java | 28 ++++------------------ 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index de5639bb0141..260d81b1f59f 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -135,8 +135,6 @@ 7 - 10 - true diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java index fece07fa9167..b0e2afae1bcb 100644 --- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java +++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java @@ -25,6 +25,7 @@ import android.media.AudioAttributes; import android.os.Vibrator; import android.util.Log; import android.view.Gravity; +import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.ScaleGestureDetector.OnScaleGestureListener; @@ -64,15 +65,6 @@ public class ExpandHelper implements Gefingerpoken { // 2f: maximum brightness is stretching a 1U to 3U, or a 4U to 6U private static final float STRETCH_INTERVAL = 2f; - // level of glow for a touch, without overstretch - // overstretch fills the range (GLOW_BASE, 1.0] - private static final float GLOW_BASE = 0.5f; - - private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .build(); - @SuppressWarnings("unused") private Context mContext; @@ -94,13 +86,11 @@ public class ExpandHelper implements Gefingerpoken { private float mLastSpanY; private int mTouchSlop; private float mLastMotionY; - private int mPopDuration; private float mPullGestureMinXSpan; private Callback mCallback; private ScaleGestureDetector mSGD; private ViewScaler mScaler; private ObjectAnimator mScaleAnimation; - private Vibrator mVibrator; private boolean mEnabled = true; private ExpandableView mResizedView; private float mCurrentHeight; @@ -174,7 +164,6 @@ public class ExpandHelper implements Gefingerpoken { mScaler = new ViewScaler(); mGravity = Gravity.TOP; mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f); - mPopDuration = mContext.getResources().getInteger(R.integer.blinds_pop_duration_ms); mPullGestureMinXSpan = mContext.getResources().getDimension(R.dimen.pull_span_min); final ViewConfiguration configuration = ViewConfiguration.get(mContext); @@ -452,7 +441,9 @@ public class ExpandHelper implements Gefingerpoken { } if (!mHasPopped) { - vibrate(mPopDuration); + if (mEventSource != null) { + mEventSource.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + } mHasPopped = true; } @@ -600,16 +591,5 @@ public class ExpandHelper implements Gefingerpoken { public void onlyObserveMovements(boolean onlyMovements) { mOnlyMovements = onlyMovements; } - - /** - * Triggers haptic feedback. - */ - private synchronized void vibrate(long duration) { - if (mVibrator == null) { - mVibrator = (android.os.Vibrator) - mContext.getSystemService(Context.VIBRATOR_SERVICE); - } - mVibrator.vibrate(duration, VIBRATION_ATTRIBUTES); - } } -- 2.11.0