Skip to content

Commit

Permalink
Brightness slider buttons: Vibrate after a long press
Browse files Browse the repository at this point in the history
- A small haptic feedback after long pressing feels good
  • Loading branch information
PMS22 committed Apr 23, 2018
1 parent fb0c74a commit 971622e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import android.os.Handler;
import android.os.Message;
import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.util.AttributeSet;
Expand Down Expand Up @@ -106,6 +108,8 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
private BrightnessMirrorController mBrightnessMirrorController;
private View mDivider;

private final Vibrator mVibrator;

public QSPanel(Context context) {
this(context, null);
}
Expand All @@ -114,7 +118,7 @@ public QSPanel(final Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
ContentResolver resolver = context.getContentResolver();

mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
setOrientation(VERTICAL);

mBrightnessView = LayoutInflater.from(context).inflate(
Expand Down Expand Up @@ -154,6 +158,7 @@ public void onClick(View v) {
@Override
public boolean onLongClick(View v) {
setBrightnessMin(context, isAdaptiveBrightness(context));
mVibrator.vibrate(VibrationEffect.createOneShot(45, VibrationEffect.DEFAULT_AMPLITUDE));
return false;
}
});
Expand Down Expand Up @@ -186,6 +191,7 @@ public void onClick(View v) {
@Override
public boolean onLongClick(View v) {
setBrightnessMax(context, isAdaptiveBrightness(context));
mVibrator.vibrate(VibrationEffect.createOneShot(45, VibrationEffect.DEFAULT_AMPLITUDE));
return false;
}
});
Expand Down

0 comments on commit 971622e

Please sign in to comment.