Merge "Add haptic effect for the seekbar in Settings 3/n."

This commit is contained in:
John Li
2020-12-02 05:59:28 +00:00
committed by Android (Google) Code Review
2 changed files with 65 additions and 0 deletions

View File

@@ -16,6 +16,8 @@
package com.android.settings;
import static android.view.HapticFeedbackConstants.CLOCK_TICK;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -37,6 +39,7 @@ public class PointerSpeedPreference extends SeekBarDialogPreference implements
private boolean mRestoredOldState;
private boolean mTouchInProgress;
private int mLastProgress = -1;
private ContentObserver mSpeedObserver = new ContentObserver(new Handler()) {
@Override
@@ -76,6 +79,10 @@ public class PointerSpeedPreference extends SeekBarDialogPreference implements
if (!mTouchInProgress) {
mIm.tryPointerSpeed(progress + InputManager.MIN_POINTER_SPEED);
}
if (progress != mLastProgress) {
seekBar.performHapticFeedback(CLOCK_TICK);
mLastProgress = progress;
}
}
public void onStartTrackingTouch(SeekBar seekBar) {