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

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

View File

@@ -16,6 +16,8 @@
package com.android.settings.widget;
import static android.view.HapticFeedbackConstants.CLOCK_TICK;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
@@ -48,6 +50,8 @@ public class LabeledSeekBar extends SeekBar {
/** Labels for discrete progress values. */
private String[] mLabels;
private int mLastProgress = -1;
public LabeledSeekBar(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.seekBarStyle);
}
@@ -118,6 +122,10 @@ public class LabeledSeekBar extends SeekBar {
mOnSeekBarChangeListener.onProgressChanged(seekBar, progress, fromUser);
sendClickEventForAccessibility(progress);
}
if (progress != mLastProgress) {
seekBar.performHapticFeedback(CLOCK_TICK);
mLastProgress = progress;
}
}
};