Add haptic effect for the seekbar in Settings 4/n.
- in Font size/Display size, perform haptic feedback as the seekbar's progress value is updated. - screenshot, https://screenshot.googleplex.com/6tcD7a9hvCcWaui - screenshot, https://screenshot.googleplex.com/89y4Q3RXskyajnL Bug: 174109628 Test: make -j42 RunSettingsRoboTests ROBOTEST_FILTER=LabeledSeekBarTest Change-Id: I7aff859e4fdaed6fe95a5d77564059ef1a7f6ff0
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user